diff --git a/.clang-format b/.clang-format index 96165b38cd..04867544d7 100644 --- a/.clang-format +++ b/.clang-format @@ -8,9 +8,9 @@ AlignConsecutiveDeclarations: true AlignEscapedNewlinesLeft: true AlignOperands: true AlignTrailingComments: false -AllowAllParametersOfDeclarationOnNextLine: true +AllowAllParametersOfDeclarationOnNextLine: false AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: true +AllowShortCaseLabelsOnASingleLine: false AllowShortIfStatementsOnASingleLine: true AllowShortFunctionsOnASingleLine: Empty AllowShortLoopsOnASingleLine: false @@ -18,8 +18,8 @@ AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakAfterReturnType: None AlwaysBreakBeforeMultilineStrings: false AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: true +BinPackArguments: false +BinPackParameters: false BraceWrapping: AfterClass: true AfterControlStatement: true @@ -35,7 +35,7 @@ BraceWrapping: BreakBeforeBinaryOperators: None BreakBeforeBraces: Custom BreakBeforeTernaryOperators: true -BreakConstructorInitializersBeforeComma: false +BreakConstructorInitializersBeforeComma: true BreakAfterJavaFieldAnnotations: false BreakStringLiterals: true ColumnLimit: 130 diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..e5ffe435bf --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,5 @@ +--- +Checks: '-*,modernize-use-nullptr' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +... diff --git a/.gitignore b/.gitignore index 9ce453e6f7..ae1ef61545 100644 --- a/.gitignore +++ b/.gitignore @@ -68,3 +68,4 @@ Ankh.NoLoad /Resinsight_Host.files /Resinsight_Host.creator /Resinsight_Host.config +*.RESINSIGHT_IDX diff --git a/ApplicationCode/Application/CMakeLists_files.cmake b/ApplicationCode/Application/CMakeLists_files.cmake index 0554e64e36..6e0a95b270 100644 --- a/ApplicationCode/Application/CMakeLists_files.cmake +++ b/ApplicationCode/Application/CMakeLists_files.cmake @@ -1,26 +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}RiaApplication.h -${CEE_CURRENT_LIST_DIR}RiaDefines.h -${CEE_CURRENT_LIST_DIR}RiaPreferences.h -${CEE_CURRENT_LIST_DIR}RiaPorosityModel.h -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.h -${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RiaApplication.h +${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h +${CMAKE_CURRENT_LIST_DIR}/RiaDefines.h +${CMAKE_CURRENT_LIST_DIR}/RiaFractureDefines.h +${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.h +${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RiaApplication.cpp -${CEE_CURRENT_LIST_DIR}RiaDefines.cpp -${CEE_CURRENT_LIST_DIR}RiaMain.cpp -${CEE_CURRENT_LIST_DIR}RiaPreferences.cpp -${CEE_CURRENT_LIST_DIR}RiaPorosityModel.cpp -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveDefinition.cpp -${CEE_CURRENT_LIST_DIR}RiaRftPltCurveDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaApplication.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaDefines.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaFractureDefines.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaMain.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaRftPltCurveDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.cpp ) list(APPEND CODE_HEADER_FILES @@ -33,8 +34,10 @@ ${SOURCE_GROUP_SOURCE_FILES} set (QT_MOC_HEADERS ${QT_MOC_HEADERS} -${CEE_CURRENT_LIST_DIR}RiaApplication.h +${CMAKE_CURRENT_LIST_DIR}/RiaApplication.h +${CMAKE_CURRENT_LIST_DIR}/RiaCompletionTypeCalculationScheduler.h +${CMAKE_CURRENT_LIST_DIR}/RiaViewRedrawScheduler.h ) -source_group( "Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Application/RiaApplication.cpp b/ApplicationCode/Application/RiaApplication.cpp index 232ee9f0b9..4a932fb6ca 100644 --- a/ApplicationCode/Application/RiaApplication.cpp +++ b/ApplicationCode/Application/RiaApplication.cpp @@ -20,37 +20,29 @@ #include "RiaApplication.h" +#include "RiaArgumentParser.h" #include "RiaBaseDefs.h" -#include "RiaImageCompareReporter.h" -#include "RiaImageFileCompare.h" +#include "RiaFilePathTools.h" #include "RiaImportEclipseCaseTools.h" #include "RiaLogging.h" #include "RiaPreferences.h" #include "RiaProjectModifier.h" #include "RiaSocketServer.h" #include "RiaVersionInfo.h" -#include "RiaArgumentParser.h" - -#include "RigGridManager.h" -#include "RigEclipseCaseData.h" +#include "RiaViewRedrawScheduler.h" +#include "RicImportInputEclipseCaseFeature.h" +#include "RicImportSummaryCasesFeature.h" +#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" -#include "Rim3dOverlayInfoConfig.h" -#include "RimCaseCollection.h" -#include "RimCellEdgeColors.h" +#include "Rim2dIntersectionViewCollection.h" #include "RimCellRangeFilterCollection.h" #include "RimCommandObject.h" -#include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseView.h" -#include "RimFaultInViewCollection.h" -#include "RimFlowCharacteristicsPlot.h" #include "RimFlowPlotCollection.h" #include "RimFormationNamesCollection.h" -#include "RimRftPlotCollection.h" -#include "RimPltPlotCollection.h" - -#include "RimEclipseCase.h" +#include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechModels.h" @@ -60,59 +52,36 @@ #include "RimObservedData.h" #include "RimObservedDataCollection.h" #include "RimOilField.h" +#include "RimPltPlotCollection.h" #include "RimProject.h" -#include "RimReservoirCellResultsStorage.h" -#include "RimScriptCollection.h" +#include "RimRftPlotCollection.h" +#include "RimStimPlanColors.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "RimSummaryCurve.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RimWellAllocationPlot.h" #include "RimWellLogFile.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" -#include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RimWellRftPlot.h" +#include "RimWellPathFracture.h" #include "RimWellPltPlot.h" +#include "RimWellRftPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuDockWidgetTools.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "RiuProcessMonitor.h" #include "RiuRecentFileActionProvider.h" #include "RiuSelectionManager.h" -#include "RiuSummaryQwtPlot.h" #include "RiuViewer.h" -#include "RiuWellLogPlot.h" -#include "RiuWellAllocationPlot.h" -#include "RiuFlowCharacteristicsPlot.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimFractureTemplateCollection.h" -#include "RimWellPathFracture.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - -#include "RicImportInputEclipseCaseFeature.h" -#include "RicImportSummaryCaseFeature.h" -#include "ExportCommands/RicSnapshotViewToFileFeature.h" -#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h" -#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" - -#include "RicfCommandFileExecutor.h" - -#include "cafFixedAtlasFont.h" #include "cafAppEnum.h" -#include "cafCeetronPlusNavigation.h" -#include "cafEffectCache.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" +#include "cafEffectGenerator.h" +#include "cafFixedAtlasFont.h" #include "cafPdmSettings.h" #include "cafPdmUiModelChangeDetector.h" #include "cafPdmUiTreeView.h" @@ -124,22 +93,20 @@ #include "cvfProgramOptions.h" #include "cvfqtUtils.h" -#include -#include #include #include #include #include -#include -#include #include -#include "gtest/gtest.h" -#ifdef WIN32 -#include -#endif +#ifndef WIN32 +#include // for usleep +#endif //WIN32 +#ifdef USE_UNIT_TESTS +#include "gtest/gtest.h" +#endif // USE_UNIT_TESTS namespace caf { @@ -154,18 +121,6 @@ void AppEnum< RiaApplication::RINavigationPolicy >::setUp() } } -namespace RegTestNames -{ - const QString generatedFolderName = "RegTestGeneratedImages"; - const QString diffFolderName = "RegTestDiffImages"; - const QString baseFolderName = "RegTestBaseImages"; - const QString testProjectName = "RegressionTest"; - const QString testFolderFilter = "TestCase*"; - const QString imageCompareExeName = "compare"; - const QString reportFileName = "ResInsightRegressionTestReport.html"; -}; - - @@ -178,6 +133,40 @@ namespace RegTestNames //================================================================================================== +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaApplication::notify(QObject* receiver, QEvent* event) +{ + // Pre-allocating a memory exhaustion message + // Doing som e trickery to avoid deadlock, as creating a messagebox actually triggers a call to this notify method. + + static QMessageBox* memoryExhaustedBox = nullptr; + static bool allocatingMessageBox = false; + if (!memoryExhaustedBox && !allocatingMessageBox) + { + allocatingMessageBox = true; + memoryExhaustedBox = new QMessageBox(QMessageBox::Critical, + "ResInsight Exhausted Memory", + "Memory is Exhausted!\n ResInsight could not allocate the memory needed, and is now unstable and will probably crash soon."); + } + + bool done = true; + try + { + done = QApplication::notify(receiver, event); + } + catch ( const std::bad_alloc& ) + { + if (memoryExhaustedBox) memoryExhaustedBox->exec(); + std::cout << "ResInsight: Memory is Exhausted!\n ResInsight could not allocate the memory needed, and is now unstable and will probably crash soon." << std::endl; + // If we really want to crash instead of limping forward: + // throw; + } + + return done; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -213,7 +202,7 @@ RiaApplication::RiaApplication(int& argc, char** argv) setWindowIcon(QIcon(":/AppLogo48x48.png")); m_socketServer = new RiaSocketServer( this); - m_workerProcess = NULL; + m_workerProcess = nullptr; #ifdef WIN32 m_startupDefaultDirectory = QDir::homePath(); @@ -227,11 +216,6 @@ RiaApplication::RiaApplication(int& argc, char** argv) // instead of using the application font m_standardFont = new caf::FixedAtlasFont(caf::FixedAtlasFont::POINT_SIZE_8); - m_resViewUpdateTimer = nullptr; - m_recalculateCompletionTypeTimer = nullptr; - - m_runningRegressionTests = false; - m_runningWorkerProcess = false; m_mainPlotWindow = nullptr; @@ -245,12 +229,13 @@ RiaApplication::RiaApplication(int& argc, char** argv) //-------------------------------------------------------------------------------------------------- RiaApplication::~RiaApplication() { + RiuDockWidgetTools::instance()->saveDockWidgetsState(); + deleteMainPlotWindow(); delete m_preferences; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -259,7 +244,6 @@ RiaApplication* RiaApplication::instance() return static_castqApp; } - //-------------------------------------------------------------------------------------------------- /// Return -1 if unit test is not executed, returns 0 if test passed, returns 1 if tests failed //-------------------------------------------------------------------------------------------------- @@ -364,16 +348,15 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi RiaLogging::info(QString("Starting to open project file : '%1'").arg(projectFileName)); - // Open the project file and read the serialized data. - // Will initialize itself. - - if (!caf::Utils::fileExists(projectFileName)) + // Create a absolute path file name, as this is required for update of file references in the project modifier object + QString fullPathProjectFileName = caf::Utils::absoluteFileName(projectFileName); + if (!caf::Utils::fileExists(fullPathProjectFileName)) { - RiaLogging::info(QString("File does not exist : '%1'").arg(projectFileName)); + RiaLogging::info(QString("File does not exist : '%1'").arg(fullPathProjectFileName)); return false; } - m_project->fileName = projectFileName; + m_project->fileName = fullPathProjectFileName; m_project->readFile(); // Apply any modifications to the loaded project before we go ahead and load actual data @@ -384,7 +367,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi // Propagate possible new location of project - m_project->setProjectFileNameAndUpdateDependencies(projectFileName); + m_project->setProjectFileNameAndUpdateDependencies(fullPathProjectFileName); // On error, delete everything, and bail out. @@ -392,11 +375,11 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi { closeProject(); - QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(projectFileName); - QMessageBox::warning(NULL, "Error when opening project file", tmp); + QString tmp = QString("Unknown project file version detected in file \n%1\n\nCould not open project.").arg(fullPathProjectFileName); + QMessageBox::warning(nullptr, "Error when opening project file", tmp); RiuMainWindow* mainWnd = RiuMainWindow::instance(); - mainWnd->setPdmRoot(NULL); + mainWnd->setPdmRoot(nullptr); // Delete all object possibly generated by readFile() delete m_project; @@ -439,14 +422,14 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi // VL check regarding specific order mentioned in comment above... - m_preferences->lastUsedProjectFileName = projectFileName; + m_preferences->lastUsedProjectFileName = fullPathProjectFileName; caf::PdmSettings::writeFieldsToApplicationStore(m_preferences); for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; - if (analysisModels == NULL) continue; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; + if (analysisModels == nullptr) continue; for (size_t cgIdx = 0; cgIdx < analysisModels->caseGroups.size(); ++cgIdx) { @@ -460,8 +443,8 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for(RimOilField* oilField: m_project->oilFields) { - if (oilField == NULL) continue; - if(oilField->formationNamesCollection() != NULL) + if (oilField == nullptr) continue; + if(oilField->formationNamesCollection() != nullptr) { oilField->formationNamesCollection()->readAllFormationNames(); } @@ -472,8 +455,8 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - if (oilField == NULL) continue; - if (oilField->wellPathCollection == NULL) + if (oilField == nullptr) continue; + if (oilField->wellPathCollection == nullptr) { //printf("Create well path collection for oil field %i in loadProject.\n", oilFieldIdx); oilField->wellPathCollection = new RimWellPathCollection(); @@ -488,13 +471,12 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (RimOilField* oilField: m_project->oilFields) { - if (oilField == NULL) continue; + if (oilField == nullptr) continue; // Temporary if(!oilField->summaryCaseMainCollection()) { oilField->summaryCaseMainCollection = new RimSummaryCaseMainCollection(); } - oilField->summaryCaseMainCollection()->createSummaryCasesFromRelevantEclipseResultCases(); oilField->summaryCaseMainCollection()->loadAllSummaryCaseData(); if (!oilField->observedDataCollection()) @@ -511,9 +493,9 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi rimObservedData->updateMetaData(); } } - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + oilField->fractureDefinitionCollection()->loadAndUpdateData(); + oilField->fractureDefinitionCollection()->createAndAssignTemplateCopyForNonMatchingUnit(); { std::vector wellPathFractures; @@ -524,7 +506,6 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi fracture->loadDataAndUpdate(); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } @@ -535,7 +516,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi for (size_t oilFieldIdx = 0; oilFieldIdx < m_project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = m_project->oilFields[oilFieldIdx]; - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; if (analysisModels) { analysisModels->recomputeStatisticsForAllCaseGroups(); @@ -544,6 +525,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi } + // Now load the ReservoirViews for the cases // Add all "native" cases in the project std::vector casesToLoad; @@ -557,22 +539,43 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi CVF_ASSERT(cas); caseProgress.setProgressDescription(cas->caseUserDescription()); - std::vector views = cas->views(); + std::vector views = cas->views(); { // To delete the view progress before incrementing the caseProgress caf::ProgressInfo viewProgress(views.size(), "Creating Views"); size_t j; for ( j = 0; j < views.size(); j++ ) { - RimView* riv = views[j]; + Rim3dView* riv = views[j]; CVF_ASSERT(riv); viewProgress.setProgressDescription(riv->name()); + if (m_project->isProjectFileVersionEqualOrOlderThan("2018.1.0.103")) + { + std::vector stimPlanColors; + riv->descendantsIncludingThisOfType(stimPlanColors); + if (stimPlanColors.size() == 1) + { + stimPlanColors[0]->updateConductivityResultName(); + } + } + riv->loadDataAndUpdate(); + + if ( m_project->isProjectFileVersionEqualOrOlderThan("2018.1.1.110") ) + { + auto* geoView = dynamic_cast(riv); + if ( geoView ) + { + geoView->convertCameraPositionFromOldProjectFiles(); + } + } + this->setActiveReservoirView(riv); - riv->rangeFilterCollection()->updateIconState(); + RimGridView* rigv = dynamic_cast(riv); + if (rigv) rigv->rangeFilterCollection()->updateIconState(); viewProgress.incrementProgress(); } @@ -585,6 +588,14 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi { m_project->viewLinkerCollection()->viewLinker()->updateOverrides(); } + + // Intersection Views: Sync from intersections in the case. + + for (RimCase* cas: casesToLoad) + { + cas->intersectionViewCollection()->syncFromExistingIntersections(false); + } + loadAndUpdatePlotData(); @@ -617,7 +628,7 @@ bool RiaApplication::loadProject(const QString& projectFileName, ProjectLoadActi //-------------------------------------------------------------------------------------------------- bool RiaApplication::loadProject(const QString& projectFileName) { - return loadProject(projectFileName, PLA_NONE, NULL); + return loadProject(projectFileName, PLA_NONE, nullptr); } //-------------------------------------------------------------------------------------------------- @@ -765,12 +776,12 @@ void RiaApplication::storeTreeViewState() //-------------------------------------------------------------------------------------------------- void RiaApplication::addWellPathsToModel(QList wellPathFilePaths) { - if (m_project == NULL || m_project->oilFields.size() < 1) return; + if (m_project == nullptr || m_project->oilFields.size() < 1) return; RimOilField* oilField = m_project->activeOilField(); - if (oilField == NULL) return; + if (oilField == nullptr) return; - if (oilField->wellPathCollection == NULL) + if (oilField->wellPathCollection == nullptr) { //printf("Create well path collection.\n"); oilField->wellPathCollection = new RimWellPathCollection(); @@ -871,7 +882,7 @@ bool RiaApplication::saveProjectPromptForFileName() startPath += "/ResInsightProject.rsp"; } - QString fileName = QFileDialog::getSaveFileName(NULL, tr("Save File"), startPath, tr("Project Files (*.rsp);;All files(*.*)")); + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save File"), startPath, tr("Project Files (*.rsp);;All files(*.*)")); if (fileName.isEmpty()) { return false; @@ -942,13 +953,14 @@ bool RiaApplication::askUserToSaveModifiedProject() //-------------------------------------------------------------------------------------------------- bool RiaApplication::saveProjectAs(const QString& fileName) { - m_project->fileName = fileName; + // Make sure we always store path with forward slash to avoid issues when opening the project file on Linux + m_project->fileName = RiaFilePathTools::toInternalSeparator(fileName); storeTreeViewState(); if (!m_project->writeFile()) { - QMessageBox::warning(NULL, "Error when saving project file", QString("Not possible to save project file. Make sure you have sufficient access rights.\n\nProject file location : %1").arg(fileName)); + QMessageBox::warning(nullptr, "Error when saving project file", QString("Not possible to save project file. Make sure you have sufficient access rights.\n\nProject file location : %1").arg(fileName)); return false; } @@ -970,7 +982,7 @@ void RiaApplication::closeProject() { RiuMainWindow* mainWnd = RiuMainWindow::instance(); - clearViewsScheduledForUpdate(); + RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate(); terminateProcess(); @@ -1074,10 +1086,10 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName) geoMechCase->setFileName(fileName); geoMechCase->caseUserDescription = caseName; - RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels() : NULL; + RimGeoMechModels* geoMechModelCollection = m_project->activeOilField() ? m_project->activeOilField()->geoMechModels() : nullptr; // Create the geoMech model container if it is not there already - if (geoMechModelCollection == NULL) + if (geoMechModelCollection == nullptr) { geoMechModelCollection = new RimGeoMechModels(); m_project->activeOilField()->geoMechModels = geoMechModelCollection; @@ -1105,8 +1117,6 @@ bool RiaApplication::openOdbCaseFromFile(const QString& fileName) return true; } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1152,7 +1162,7 @@ void RiaApplication::createInputMockModel() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimView* RiaApplication::activeReservoirView() const +const Rim3dView* RiaApplication::activeReservoirView() const { return m_activeReservoirView; } @@ -1160,11 +1170,19 @@ const RimView* RiaApplication::activeReservoirView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RiaApplication::activeReservoirView() +Rim3dView* RiaApplication::activeReservoirView() { return m_activeReservoirView; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView* RiaApplication::activeGridView() +{ + return dynamic_cast( m_activeReservoirView.p()); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1187,9 +1205,11 @@ RimViewWindow* RiaApplication::activePlotWindow() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiaApplication::setActiveReservoirView(RimView* rv) +void RiaApplication::setActiveReservoirView(Rim3dView* rv) { m_activeReservoirView = rv; + + RiuDockWidgetTools::instance()->changeDockWidgetVisibilityBasedOnView(rv); } //-------------------------------------------------------------------------------------------------- @@ -1311,9 +1331,9 @@ int RiaApplication::launchUnitTestsWithConsole() //-------------------------------------------------------------------------------------------------- void RiaApplication::createMainPlotWindow() { - CVF_ASSERT(m_mainPlotWindow == NULL); + CVF_ASSERT(m_mainPlotWindow == nullptr); - m_mainPlotWindow = new RiuMainPlotWindow; + m_mainPlotWindow = new RiuPlotMainWindow; m_mainPlotWindow->setWindowTitle("Plots - ResInsight"); m_mainPlotWindow->setDefaultWindowSize(); @@ -1329,14 +1349,14 @@ void RiaApplication::deleteMainPlotWindow() if (m_mainPlotWindow) { m_mainPlotWindow->deleteLater(); - m_mainPlotWindow = NULL; + m_mainPlotWindow = nullptr; } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow* RiaApplication::getOrCreateAndShowMainPlotWindow() +RiuPlotMainWindow* RiaApplication::getOrCreateAndShowMainPlotWindow() { if (!m_mainPlotWindow) { @@ -1363,7 +1383,7 @@ RiuMainPlotWindow* RiaApplication::getOrCreateAndShowMainPlotWindow() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow* RiaApplication::mainPlotWindow() +RiuPlotMainWindow* RiaApplication::mainPlotWindow() { return m_mainPlotWindow; } @@ -1383,7 +1403,7 @@ RiuMainWindowBase* RiaApplication::mainWindowByID(int mainWindowID) //-------------------------------------------------------------------------------------------------- RimViewWindow* RiaApplication::activeViewWindow() { - RimViewWindow* viewWindow = NULL; + RimViewWindow* viewWindow = nullptr; QWidget* mainWindowWidget = RiaApplication::activeWindow(); @@ -1391,9 +1411,9 @@ RimViewWindow* RiaApplication::activeViewWindow() { viewWindow = RiaApplication::instance()->activeReservoirView(); } - else if (dynamic_cast(mainWindowWidget)) + else if (dynamic_cast(mainWindowWidget)) { - RiuMainPlotWindow* mainPlotWindow = dynamic_cast(mainWindowWidget); + RiuPlotMainWindow* mainPlotWindow = dynamic_cast(mainWindowWidget); QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); if (subwindows.size() > 0) @@ -1512,6 +1532,36 @@ std::vector RiaApplication::readFileListFromTextFile(QString listFileNa return fileList; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaApplication::waitUntilCommandObjectsHasBeenProcessed() +{ + // Wait until all command objects have completed + while (!m_commandQueueLock.tryLock()) + { + processEvents(); + } + m_commandQueueLock.unlock(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaApplication::saveWinGeoAndDockToolBarLayout() +{ + if (m_mainPlotWindow) + { + m_mainPlotWindow->saveWinGeoAndDockToolBarLayout(); + } + + if (RiuMainWindow::instance()) + { + RiuMainWindow::instance()->saveWinGeoAndDockToolBarLayout(); + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1577,7 +1627,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu { m_workerProcess->close(); } - m_workerProcess = NULL; + m_workerProcess = nullptr; // Either the work process crashed or was aborted by the user if (exitStatus == QProcess::CrashExit) @@ -1617,7 +1667,7 @@ void RiaApplication::slotWorkerProcessFinished(int exitCode, QProcess::ExitStatu //-------------------------------------------------------------------------------------------------- bool RiaApplication::launchProcess(const QString& program, const QStringList& arguments) { - if (m_workerProcess == NULL) + if (m_workerProcess == nullptr) { // If multiple cases are present, pop the first case ID from the list and set as current case if (!m_currentCaseIds.empty()) @@ -1669,7 +1719,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar if (!m_workerProcess->waitForStarted(1000)) { m_workerProcess->close(); - m_workerProcess = NULL; + m_workerProcess = nullptr; m_runningWorkerProcess = false; RiuMainWindow::instance()->processMonitor()->stopMonitorWorkProcess(); @@ -1683,7 +1733,7 @@ bool RiaApplication::launchProcess(const QString& program, const QStringList& ar } else { - QMessageBox::warning(NULL, "Script execution", "An Octave process is still running. Please stop this process before executing a new script."); + QMessageBox::warning(nullptr, "Script execution", "An Octave process is still running. Please stop this process before executing a new script."); return false; } } @@ -1765,7 +1815,7 @@ void RiaApplication::applyPreferences() this->project()->setScriptDirectories(m_preferences->scriptDirectories()); this->project()->updateConnectedEditors(); - std::vector visibleViews; + std::vector visibleViews; this->project()->allVisibleViews(visibleViews); for (auto view : visibleViews) @@ -1793,7 +1843,7 @@ void RiaApplication::terminateProcess() } m_runningWorkerProcess = false; - m_workerProcess = NULL; + m_workerProcess = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -1872,7 +1922,7 @@ bool RiaApplication::openFile(const QString& fileName) } else if (fileName.contains(".egrid", Qt::CaseInsensitive) || fileName.contains(".grid", Qt::CaseInsensitive)) { - loadingSucceded = RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName); + loadingSucceded = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ fileName })); } else if (fileName.contains(".grdecl", Qt::CaseInsensitive)) { @@ -1884,19 +1934,11 @@ bool RiaApplication::openFile(const QString& fileName) } else if (fileName.contains(".smspec", Qt::CaseInsensitive)) { - loadingSucceded = RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(fileName); + loadingSucceded = RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(QStringList({ fileName })); if (loadingSucceded) { getOrCreateAndShowMainPlotWindow(); - std::vector cases; - m_project->allCases(cases); - - if (cases.size() == 0) - { - RiuMainWindow::instance()->close(); - } - m_project->updateConnectedEditors(); } } @@ -1937,267 +1979,6 @@ void RiaApplication::runMultiCaseSnapshots(const QString& templateProjectFileNam mainWnd->loadWinGeoAndDockToolBarLayout(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void removeDirectoryWithContent(QDir dirToDelete ) -{ - QStringList files = dirToDelete.entryList(); - for (int fIdx = 0; fIdx < files.size(); ++fIdx) - { - dirToDelete.remove(files[fIdx]); - } - dirToDelete.rmdir("."); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg) -{ - double timeRunning = time.elapsed() / 1000.0; - - QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1); - - RiaLogging::info(timeText + msg); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::runRegressionTest(const QString& testRootPath, QStringList* testFilter) -{ - m_runningRegressionTests = true; - - QString generatedFolderName = RegTestNames::generatedFolderName; - QString diffFolderName = RegTestNames::diffFolderName; - QString baseFolderName = RegTestNames::baseFolderName; - QString regTestProjectName = RegTestNames::testProjectName; - QString regTestFolderFilter = RegTestNames::testFolderFilter; - - // Find all sub folders - - QDir testDir(testRootPath); // If string is empty it will end up as cwd - testDir.setFilter(QDir::Dirs); - QStringList dirNameFilter; - dirNameFilter.append(regTestFolderFilter); - testDir.setNameFilters(dirNameFilter); - - QFileInfoList folderList = testDir.entryInfoList(); - - if (testFilter && testFilter->size() > 0) - { - QFileInfoList subset; - - for (auto fi : folderList) - { - QString path = fi.path(); - QString baseName = fi.baseName(); - - for (auto s : *testFilter) - { - QString trimmed = s.trimmed(); - if (baseName.contains(trimmed)) - { - subset.push_back(fi); - } - } - } - - folderList = subset; - } - - // delete diff and generated images - - - for (int i = 0; i < folderList.size(); ++i) - { - QDir testCaseFolder(folderList[i].filePath()); - - QDir genDir(testCaseFolder.filePath(generatedFolderName)); - removeDirectoryWithContent(genDir); - - QDir diffDir(testCaseFolder.filePath(diffFolderName)); - removeDirectoryWithContent(diffDir); - - QDir baseDir(testCaseFolder.filePath(baseFolderName)); - } - - // Generate html report - - RiaImageCompareReporter imageCompareReporter; - - // Minor workaround - // Use registry to define if interactive diff images should be created - // Defined by user in RiaRegressionTest - { - QSettings settings; - - bool useInteractiveDiff = settings.value("showInteractiveDiffImages").toBool(); - if (useInteractiveDiff) - { - imageCompareReporter.showInteractiveOnly(); - } - } - - QTime timeStamp; - timeStamp.start(); - - logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n"); - - for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) - { - QDir testCaseFolder(folderList[dirIdx].filePath()); - - QString testFolderName = testCaseFolder.dirName(); - QString reportBaseFolderName = testCaseFolder.filePath(baseFolderName); - QString reportGeneratedFolderName = testCaseFolder.filePath(generatedFolderName); - QString reportDiffFolderName = testCaseFolder.filePath(diffFolderName); - - imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), reportBaseFolderName.toStdString(), reportGeneratedFolderName.toStdString(), reportDiffFolderName.toStdString()); - } - - QString htmlReportFileName = testDir.filePath(RegTestNames::reportFileName); - imageCompareReporter.generateHTMLReport(htmlReportFileName.toStdString()); - - // Open HTML report - QDesktopServices::openUrl(htmlReportFileName); - - for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) - { - QDir testCaseFolder(folderList[dirIdx].filePath()); - - QString projectFileName; - - if (testCaseFolder.exists(regTestProjectName + ".rip")) - { - projectFileName = regTestProjectName + ".rip"; - } - - if (testCaseFolder.exists(regTestProjectName + ".rsp")) - { - projectFileName = regTestProjectName + ".rsp"; - } - - if (!projectFileName.isEmpty()) - { - logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath()); - - loadProject(testCaseFolder.filePath(projectFileName)); - - // Wait until all command objects have completed - while (!m_commandQueueLock.tryLock()) - { - processEvents(); - } - m_commandQueueLock.unlock(); - - regressionTestConfigureProject(); - - resizeMaximizedPlotWindows(); - - QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName); - RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(fullPathGeneratedFolder); - - RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder); - - QDir baseDir(testCaseFolder.filePath(baseFolderName)); - QDir genDir(testCaseFolder.filePath(generatedFolderName)); - QDir diffDir(testCaseFolder.filePath(diffFolderName)); - if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName); - baseDir.setFilter(QDir::Files); - QStringList baseImageFileNames = baseDir.entryList(); - - for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx) - { - QString fileName = baseImageFileNames[fIdx]; - RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName); - bool ok = imgComparator.runComparison(genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName)); - if (!ok) - { - qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails(); - } - } - - closeProject(); - - logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath()); - } - } - - RiaLogging::info("\n"); - logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests"); - - m_runningRegressionTests = false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::resizeMaximizedPlotWindows() -{ - std::vector viewWindows; - m_project->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows); - - for (auto viewWindow : viewWindows) - { - if (viewWindow->isMdiWindow()) - { - RimMdiWindowGeometry wndGeo = viewWindow->mdiWindowGeometry(); - if (wndGeo.isMaximized) - { - QWidget* viewWidget = viewWindow->viewWidget(); - - if (viewWidget) - { - QMdiSubWindow* mdiWindow = m_mainPlotWindow->findMdiSubWindow(viewWidget); - if (mdiWindow) - { - mdiWindow->showNormal(); - - viewWidget->resize(RiaApplication::regressionDefaultImageSize()); - } - } - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::updateRegressionTest(const QString& testRootPath) -{ - // Find all sub folders - - QDir testDir(testRootPath); // If string is empty it will end up as cwd - testDir.setFilter(QDir::Dirs); - QStringList dirNameFilter; - dirNameFilter.append(RegTestNames::testFolderFilter); - testDir.setNameFilters(dirNameFilter); - - QFileInfoList folderList = testDir.entryInfoList(); - - for (int i = 0; i < folderList.size(); ++i) - { - QDir testCaseFolder(folderList[i].filePath()); - - QDir baseDir(testCaseFolder.filePath(RegTestNames::baseFolderName)); - removeDirectoryWithContent(baseDir); - testCaseFolder.mkdir(RegTestNames::baseFolderName); - - QDir genDir(testCaseFolder.filePath(RegTestNames::generatedFolderName)); - - QStringList imageFileNames = genDir.entryList(); - - for (int fIdx = 0; fIdx < imageFileNames.size(); ++fIdx) - { - QString fileName = imageFileNames[fIdx]; - QFile::copy(genDir.filePath(fileName), baseDir.filePath(fileName)); - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2221,21 +2002,6 @@ cvf::Font* RiaApplication::customFont() return m_customFont.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::clearViewsScheduledForUpdate() -{ - if (m_resViewUpdateTimer) - { - while (m_resViewUpdateTimer->isActive()) - { - QCoreApplication::processEvents(); - } - } - m_resViewsToUpdate.clear(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2308,136 +2074,6 @@ 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(RimView* resViewToUpdate) -{ - m_resViewsToUpdate.push_back(resViewToUpdate); - - if (!m_resViewUpdateTimer) - { - m_resViewUpdateTimer = new QTimer(this); - connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateScheduledDisplayModels())); - } - - if (!m_resViewUpdateTimer->isActive()) - { - m_resViewUpdateTimer->setSingleShot(true); - m_resViewUpdateTimer->start(0); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleRecalculateCompletionTypeAndRedrawAllViews() -{ - for (RimEclipseCase* eclipseCase : project()->activeOilField()->analysisModels->cases()) - { - m_eclipseCasesToRecalculate.push_back(eclipseCase); - } - - if (!m_recalculateCompletionTypeTimer) - { - m_recalculateCompletionTypeTimer = new QTimer(this); - m_recalculateCompletionTypeTimer->setSingleShot(true); - connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); - } - - m_recalculateCompletionTypeTimer->start(1500); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase) -{ - m_eclipseCasesToRecalculate.push_back(eclipseCase); - - - if (!m_recalculateCompletionTypeTimer) - { - m_recalculateCompletionTypeTimer = new QTimer(this); - m_recalculateCompletionTypeTimer->setSingleShot(true); - connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); - } - - m_recalculateCompletionTypeTimer->start(500); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::slotUpdateScheduledDisplayModels() -{ - // Compress to remove duplicates - // and update dependent views after independent views - - std::set independent3DViewsToUpdate; - std::set dependent3DViewsToUpdate; - - for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i) - { - if (!m_resViewsToUpdate[i]) continue; - - if (m_resViewsToUpdate[i]->viewController()) - dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); - else - independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); - } - - for (std::set::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it ) - { - if (*it) - { - (*it)->createDisplayModelAndRedraw(); - } - } - - for (std::set::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it) - { - if (*it) - { - (*it)->createDisplayModelAndRedraw(); - } - } - - m_resViewsToUpdate.clear(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::slotRecalculateCompletionType() -{ - std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); - - RimView* activeView = RiaApplication::instance()->activeReservoirView(); - QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); - - for (RimEclipseCase* eclipseCase : uniqueCases) - { - eclipseCase->recalculateCompletionTypeAndRedrawAllViews(); - } - - m_eclipseCasesToRecalculate.clear(); - - // Recalculation of completion type causes active view to be set to potentially a different view - // Also current index in project tree is changed. Restore both to initial state. - - if (activeView && activeView->viewer()) - { - RiaApplication::instance()->setActiveReservoirView(activeView); - RiuMainWindow::instance()->setActiveViewer(activeView->viewer()->layoutWidget()); - } - - if (mi.isValid()) - { - RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex(mi); - } -} //-------------------------------------------------------------------------------------------------- /// @@ -2508,79 +2144,6 @@ void RiaApplication::executeCommandObjects() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiaApplication::isRunningRegressionTests() const -{ - return m_runningRegressionTests; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter) -{ - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (mainWnd) - { - mainWnd->hideAllDockWindows(); - - mainWnd->setDefaultWindowSize(); - runRegressionTest(regressionTestPath, testFilter); - - mainWnd->loadWinGeoAndDockToolBarLayout(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiaApplication::regressionTestConfigureProject() -{ - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (!mainWnd) return; - - if (m_project.isNull()) return; - - std::vector projectCases; - m_project->allCases(projectCases); - - for (size_t i = 0; i < projectCases.size(); i++) - { - RimCase* cas = projectCases[i]; - if (!cas) continue; - - std::vector views = cas->views(); - - for (size_t j = 0; j < views.size(); j++) - { - RimView* riv = views[j]; - - if (riv && riv->viewer()) - { - // Make sure all views are maximized for snapshotting - QMdiSubWindow* subWnd = mainWnd->findMdiSubWindow(riv->viewer()->layoutWidget()); - if (subWnd) - { - subWnd->showMaximized(); - } - - // This size is set to match the regression test reference images - riv->viewer()->setFixedSize(RiaApplication::regressionDefaultImageSize()); - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QSize RiaApplication::regressionDefaultImageSize() -{ - return QSize(1000, 745); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/RiaApplication.h b/ApplicationCode/Application/RiaApplication.h index 9c239d83f0..0d538520c8 100644 --- a/ApplicationCode/Application/RiaApplication.h +++ b/ApplicationCode/Application/RiaApplication.h @@ -48,15 +48,16 @@ class RigEclipseCaseData; class RimCommandObject; class RimEclipseCase; class RimEclipseView; +class RimGridView; class RimProject; class RimSummaryPlot; -class RimView; +class Rim3dView; class RimViewWindow; class RimWellLogPlot; class RimWellAllocationPlot; class RiuMainWindowBase; -class RiuMainPlotWindow; +class RiuPlotMainWindow; class RiuRecentFileActionProvider; class RiaArgumentParser; @@ -92,24 +93,20 @@ class RiaApplication : public QApplication public: RiaApplication(int& argc, char** argv); ~RiaApplication(); + static RiaApplication* instance(); - int parseArgumentsAndRunUnitTestsIfRequested(); - bool parseArguments(); - - void executeRegressionTests(const QString& regressionTestPath, QStringList* testFilter = nullptr); - - void setActiveReservoirView(RimView*); - RimView* activeReservoirView(); - const RimView* activeReservoirView() const; + int parseArgumentsAndRunUnitTestsIfRequested(); + bool parseArguments(); - RimViewWindow* activePlotWindow() const; + void setActiveReservoirView(Rim3dView*); + Rim3dView* activeReservoirView(); + const Rim3dView* activeReservoirView() const; + RimGridView* activeGridView(); - void scheduleDisplayModelUpdateAndRedraw(RimView* resViewToUpdate); - void scheduleRecalculateCompletionTypeAndRedrawAllViews(); - void scheduleRecalculateCompletionTypeAndRedrawEclipseCase(RimEclipseCase* eclipseCase); + RimViewWindow* activePlotWindow() const; - RimProject* project(); + RimProject* project(); void createMockModel(); void createResultsMockModel(); @@ -142,7 +139,6 @@ class RiaApplication : public QApplication void addWellLogsToModel(const QList& wellLogFilePaths); void runMultiCaseSnapshots(const QString& templateProjectFileName, std::vector gridFileNames, const QString& snapshotFolderName); - void runRegressionTest(const QString& testRootPath, QStringList* testFilter = nullptr); void processNonGuiEvents(); @@ -181,13 +177,11 @@ class RiaApplication : public QApplication void addCommandObject(RimCommandObject* commandObject); void executeCommandObjects(); - bool isRunningRegressionTests() const; - int launchUnitTests(); int launchUnitTestsWithConsole(); - RiuMainPlotWindow* getOrCreateAndShowMainPlotWindow(); - RiuMainPlotWindow* mainPlotWindow(); + RiuPlotMainWindow* getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow(); RiuMainWindowBase* mainWindowByID(int mainWindowID); static RimViewWindow* activeViewWindow(); @@ -205,10 +199,10 @@ class RiaApplication : public QApplication static std::vector readFileListFromTextFile(QString listFileName); - void clearViewsScheduledForUpdate(); + void waitUntilCommandObjectsHasBeenProcessed(); + void saveWinGeoAndDockToolBarLayout(); private: - void onProjectOpenedOrClosed(); void setWindowCaptionFromAppState(); @@ -219,35 +213,18 @@ class RiaApplication : public QApplication void storeTreeViewState(); - void resizeMaximizedPlotWindows(); - void updateRegressionTest(const QString& testRootPath); - void regressionTestConfigureProject(); - static QSize regressionDefaultImageSize(); - + friend RiaArgumentParser; void setHelpText(const QString& helpText); -private slots: - void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); - void slotUpdateScheduledDisplayModels(); - void slotRecalculateCompletionType(); + virtual bool notify(QObject *, QEvent *) override; - // Friend classes required to have access to slotUpdateScheduledDisplayModels - // As snapshots are produced fast in sequence, the feature must have access to force redraw - // of scheduled redraws - friend class RimView; - friend class RicExportMultipleSnapshotsFeature; - friend class RiaArgumentParser; +private slots: + void slotWorkerProcessFinished(int exitCode, QProcess::ExitStatus exitStatus); private: - caf::PdmPointer m_activeReservoirView; - + caf::PdmPointer m_activeReservoirView; caf::PdmPointer m_project; - std::vector > m_resViewsToUpdate; - QTimer* m_resViewUpdateTimer; - std::vector > m_eclipseCasesToRecalculate; - QTimer* m_recalculateCompletionTypeTimer; - RiaSocketServer* m_socketServer; caf::UiProcess* m_workerProcess; @@ -271,11 +248,10 @@ private slots: QMutex m_commandQueueLock; QString m_helpText; - bool m_runningRegressionTests; bool m_runningWorkerProcess; - RiuMainPlotWindow* m_mainPlotWindow; + RiuPlotMainWindow* m_mainPlotWindow; std::unique_ptr m_recentFileActionProvider; }; diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp new file mode 100644 index 0000000000..95bdb29e3e --- /dev/null +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.cpp @@ -0,0 +1,165 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaCompletionTypeCalculationScheduler.h" + +#include "RiaApplication.h" + +#include "RigEclipseCaseData.h" +#include "RigCaseCellResultsData.h" + +#include "RimEclipseCase.h" +#include "RimEclipseCaseCollection.h" +#include "RimEclipseView.h" +#include "RimOilField.h" +#include "RimProject.h" + +#include "RiuMainWindow.h" +#include "RiuViewer.h" + +#include "cafPdmUiTreeView.h" + +#include +#include + +#include +#include "cafProgressState.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaCompletionTypeCalculationScheduler* RiaCompletionTypeCalculationScheduler::instance() +{ + static RiaCompletionTypeCalculationScheduler theInstance; + + return &theInstance; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews() +{ + std::vector eclipseCases = + RiaApplication::instance()->project()->activeOilField()->analysisModels->cases().childObjects(); + + scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCases); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews(RimEclipseCase* eclipseCase) +{ + std::vector eclipseCases; + eclipseCases.push_back(eclipseCase); + + scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCases); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::scheduleRecalculateCompletionTypeAndRedrawAllViews( + const std::vector& eclipseCases) +{ + for (RimEclipseCase* eclipseCase : eclipseCases) + { + CVF_ASSERT(eclipseCase); + + if (eclipseCase->eclipseCaseData()) + { + eclipseCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); + + // Delete virtual perforation transmissibilities, as these are the basis for the computation of completion type + eclipseCase->eclipseCaseData()->setVirtualPerforationTransmissibilities(nullptr); + } + + m_eclipseCasesToRecalculate.push_back(eclipseCase); + } + + startTimer(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::slotRecalculateCompletionType() +{ + if ( caf::ProgressState::isActive() ) + { + startTimer(); + return; + } + + std::set uniqueCases(m_eclipseCasesToRecalculate.begin(), m_eclipseCasesToRecalculate.end()); + + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + QModelIndex mi = RiuMainWindow::instance()->projectTreeView()->treeView()->currentIndex(); + + for (RimEclipseCase* eclipseCase : uniqueCases) + { + for (const auto& w : eclipseCase->views()) + { + RimEclipseView* eclView = dynamic_cast(w); + if (eclView) + { + eclView->calculateCompletionTypeAndRedrawIfRequired(); + } + } + } + + m_eclipseCasesToRecalculate.clear(); + + // Recalculation of completion type causes active view to be set to potentially a different view + // Also current index in project tree is changed. Restore both to initial state. + + if (activeView && activeView->viewer()) + { + RiaApplication::instance()->setActiveReservoirView(activeView); + RiuMainWindow::instance()->setActiveViewer(activeView->viewer()->layoutWidget()); + } + + if (mi.isValid()) + { + RiuMainWindow::instance()->projectTreeView()->treeView()->setCurrentIndex(mi); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaCompletionTypeCalculationScheduler::~RiaCompletionTypeCalculationScheduler() +{ + delete m_recalculateCompletionTypeTimer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaCompletionTypeCalculationScheduler::startTimer() +{ + if (!m_recalculateCompletionTypeTimer) + { + m_recalculateCompletionTypeTimer = new QTimer(this); + m_recalculateCompletionTypeTimer->setSingleShot(true); + connect(m_recalculateCompletionTypeTimer, SIGNAL(timeout()), this, SLOT(slotRecalculateCompletionType())); + } + + m_recalculateCompletionTypeTimer->start(1500); +} diff --git a/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h new file mode 100644 index 0000000000..205f415f9f --- /dev/null +++ b/ApplicationCode/Application/RiaCompletionTypeCalculationScheduler.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmPointer.h" + +#include + +#include + +class QTimer; +class RimEclipseCase; + +class RiaCompletionTypeCalculationScheduler : public QObject +{ + Q_OBJECT; +public: + static RiaCompletionTypeCalculationScheduler* instance(); + void scheduleRecalculateCompletionTypeAndRedrawAllViews(); + void scheduleRecalculateCompletionTypeAndRedrawAllViews(RimEclipseCase* eclipseCase); + +private slots: + void slotRecalculateCompletionType(); + +private: + RiaCompletionTypeCalculationScheduler() : m_recalculateCompletionTypeTimer(nullptr) {} + ~RiaCompletionTypeCalculationScheduler(); + + RiaCompletionTypeCalculationScheduler(const RiaCompletionTypeCalculationScheduler& o) = delete; + void operator=(const RiaCompletionTypeCalculationScheduler& o) = delete; + + void scheduleRecalculateCompletionTypeAndRedrawAllViews(const std::vector& eclipseCases); + + void startTimer(); + +private: + std::vector > m_eclipseCasesToRecalculate; + QTimer* m_recalculateCompletionTypeTimer; +}; + + diff --git a/ApplicationCode/Application/RiaFractureDefines.cpp b/ApplicationCode/Application/RiaFractureDefines.cpp new file mode 100644 index 0000000000..74f3b87d49 --- /dev/null +++ b/ApplicationCode/Application/RiaFractureDefines.cpp @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaFractureDefines.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::conductivityResultName() +{ + return "CONDUCTIVITY"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaDefines::unitStringConductivity(RiaEclipseUnitTools::UnitSystem unitSystem) +{ + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return "md-m"; + case RiaEclipseUnitTools::UNITS_FIELD: return "md-ft"; + default: return ""; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaDefines::nonDarcyFlowAlpha(RiaEclipseUnitTools::UnitSystem unitSystem) +{ + switch (unitSystem) + { + case RiaEclipseUnitTools::UNITS_METRIC: return 2.24460e-10; + case RiaEclipseUnitTools::UNITS_FIELD: return 6.83352e-8; + default: return 0.0; + } +} diff --git a/ApplicationCode/Application/RiaFractureDefines.h b/ApplicationCode/Application/RiaFractureDefines.h new file mode 100644 index 0000000000..a87bbe5acf --- /dev/null +++ b/ApplicationCode/Application/RiaFractureDefines.h @@ -0,0 +1,31 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaEclipseUnitTools.h" + +#include + +namespace RiaDefines +{ +QString conductivityResultName(); +QString unitStringConductivity(RiaEclipseUnitTools::UnitSystem unitSystem); + +double nonDarcyFlowAlpha(RiaEclipseUnitTools::UnitSystem unitSystem); +}; diff --git a/ApplicationCode/Application/RiaMain.cpp b/ApplicationCode/Application/RiaMain.cpp index 0e6e55a784..0332149550 100644 --- a/ApplicationCode/Application/RiaMain.cpp +++ b/ApplicationCode/Application/RiaMain.cpp @@ -49,7 +49,22 @@ int main(int argc, char *argv[]) RiaLogging::setLoggerInstance(new RiuMessagePanelLogger(window.messagePanel())); RiaLogging::loggerInstance()->setLevel(RI_LL_DEBUG); - int exitCode = app.exec(); + int exitCode = 0; + try + { + exitCode = app.exec(); + } + catch (std::exception& exep ) + { + std::cout << "A standard c++ exception that terminated ResInsight caught in RiaMain.cpp: " << exep.what() << std::endl; + throw; + } + catch(...) + { + std::cout << "An unknown exception that terminated ResInsight caught in RiaMain.cpp. " << std::endl; + throw; + } + RiaLogging::deleteLoggerInstance(); return exitCode; diff --git a/ApplicationCode/Application/RiaPreferences.cpp b/ApplicationCode/Application/RiaPreferences.cpp index bfbba55707..7de821f1a7 100644 --- a/ApplicationCode/Application/RiaPreferences.cpp +++ b/ApplicationCode/Application/RiaPreferences.cpp @@ -27,6 +27,19 @@ #include "cafPdmUiFieldHandle.h" #include "cafPdmUiFilePathEditor.h" +namespace caf +{ + template<> + void RiaPreferences::SummaryRestartFilesImportModeType::setUp() + { + addItem(RiaPreferences::IMPORT, "IMPORT", "Unified"); + addItem(RiaPreferences::SEPARATE_CASES, "SEPARATE_CASES", "Separate Cases"); + addItem(RiaPreferences::NOT_IMPORT, "NOT_IMPORT", "Skip"); + setDefault(RiaPreferences::IMPORT); + } +} + + CAF_PDM_SOURCE_INIT(RiaPreferences, "RiaPreferences"); //-------------------------------------------------------------------------------------------------- /// @@ -72,9 +85,13 @@ RiaPreferences::RiaPreferences(void) appendClassNameToUiText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); CAF_PDM_InitField(&appendFieldKeywordToToolTipText, "appendFieldKeywordToToolTipText", false, "Show Field Keyword in ToolTip", "", "", ""); appendFieldKeywordToToolTipText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&showTestToolbar, "showTestToolbar", false, "Enable Test Toolbar", "", "", ""); + showTestToolbar.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); CAF_PDM_InitField(&includeFractureDebugInfoFile, "includeFractureDebugInfoFile", false, "Include Fracture Debug Info for Completion Export", "", "", ""); includeFractureDebugInfoFile.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitField(&showLegendBackground, "showLegendBackground", true, "Enable Legend Background", "", "", ""); + CAF_PDM_InitFieldNoDefault(&lastUsedProjectFileName,"lastUsedProjectFileName", "Last Used Project File", "", "", ""); lastUsedProjectFileName.uiCapability()->setUiHidden(true); @@ -84,6 +101,10 @@ RiaPreferences::RiaPreferences(void) CAF_PDM_InitField(&loadAndShowSoil, "loadAndShowSoil", true, "Load and Show SOIL", "", "", ""); loadAndShowSoil.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + CAF_PDM_InitFieldNoDefault(&summaryRestartFilesShowImportDialog, "summaryRestartFilesShowImportDialog", "Show Import Dialog", "", "", ""); + CAF_PDM_InitField(&summaryImportMode, "summaryImportMode", SummaryRestartFilesImportModeType(RiaPreferences::IMPORT), "Default Summary Import Option", "", "", ""); + CAF_PDM_InitField(&gridImportMode, "gridImportMode", SummaryRestartFilesImportModeType(RiaPreferences::NOT_IMPORT), "Default Grid Import Option", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_readerSettings, "readerSettings", "Reader Settings", "", "", ""); m_readerSettings = new RifReaderSettings; @@ -124,6 +145,7 @@ void RiaPreferences::defineEditorAttribute(const caf::PdmFieldHandle* field, QSt field == &showHud || field == &appendClassNameToUiText || field == &appendFieldKeywordToToolTipText || + field == &showTestToolbar || field == &includeFractureDebugInfoFile || field == &showLasCurveWithoutTvdWarning) { @@ -150,6 +172,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& defaultSettingsGroup->add(&defaultWellLabelColor); defaultSettingsGroup->add(&fontSizeInScene); defaultSettingsGroup->add(&defaultScaleFactorZ); + defaultSettingsGroup->add(&showLegendBackground); caf::PdmUiGroup* viewsGroup = uiOrdering.addNewGroup("3D Views"); viewsGroup->add(&navigationPolicy); @@ -169,6 +192,13 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& newCaseBehaviourGroup->add(&loadAndShowSoil); m_readerSettings->defineUiOrdering(uiConfigName, *newCaseBehaviourGroup); + + caf::PdmUiGroup* restartBehaviourGroup = uiOrdering.addNewGroup("Origin Files"); + restartBehaviourGroup->add(&summaryRestartFilesShowImportDialog); + caf::PdmUiGroup* summaryImportOptionGroup = restartBehaviourGroup->addNewGroup("Origin Summary Files"); + summaryImportOptionGroup->add(&summaryImportMode); + caf::PdmUiGroup* gridImportOptionGroup = restartBehaviourGroup->addNewGroup("Origin Grid Files"); + gridImportOptionGroup->add(&gridImportMode); } else if (uiConfigName == m_tabNames[2]) { @@ -184,6 +214,7 @@ void RiaPreferences::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& { uiOrdering.add(&appendClassNameToUiText); uiOrdering.add(&appendFieldKeywordToToolTipText); + uiOrdering.add(&showTestToolbar); uiOrdering.add(&includeFractureDebugInfoFile); } @@ -212,6 +243,15 @@ QList RiaPreferences::calculateValueOptions(const caf::P options.push_back(caf::PdmOptionItemInfo(fontSizes[oIdx], fontSizes[oIdx])); } } + else if (fieldNeedingOptions == &gridImportMode) + { + // Manual option handling in order to one only a subset of the enum values + SummaryRestartFilesImportModeType skip(RiaPreferences::NOT_IMPORT); + SummaryRestartFilesImportModeType separate(RiaPreferences::SEPARATE_CASES); + + options.push_back(caf::PdmOptionItemInfo(skip.uiText(), RiaPreferences::NOT_IMPORT)); + options.push_back(caf::PdmOptionItemInfo(separate.uiText(), RiaPreferences::SEPARATE_CASES)); + } return options; } diff --git a/ApplicationCode/Application/RiaPreferences.h b/ApplicationCode/Application/RiaPreferences.h index 4926c62a25..4b2f9c532b 100644 --- a/ApplicationCode/Application/RiaPreferences.h +++ b/ApplicationCode/Application/RiaPreferences.h @@ -37,6 +37,9 @@ class RiaPreferences : public caf::PdmObject CAF_PDM_HEADER_INIT; public: + enum SummaryRestartFilesImportMode { IMPORT, NOT_IMPORT, SEPARATE_CASES }; + typedef caf::AppEnum SummaryRestartFilesImportModeType; + RiaPreferences(void); virtual ~RiaPreferences(void); @@ -63,11 +66,13 @@ class RiaPreferences : public caf::PdmObject caf::PdmField defaultWellLabelColor; caf::PdmField showLasCurveWithoutTvdWarning; caf::PdmField fontSizeInScene; + caf::PdmField showLegendBackground; caf::PdmField useShaders; caf::PdmField showHud; caf::PdmField appendClassNameToUiText; caf::PdmField appendFieldKeywordToToolTipText; + caf::PdmField showTestToolbar; caf::PdmField includeFractureDebugInfoFile; caf::PdmField lastUsedProjectFileName; @@ -75,6 +80,10 @@ class RiaPreferences : public caf::PdmObject caf::PdmField autocomputeDepthRelatedProperties; caf::PdmField loadAndShowSoil; + caf::PdmField summaryRestartFilesShowImportDialog; + caf::PdmField summaryImportMode; + caf::PdmField gridImportMode; + protected: virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp index d6027a2d76..4ebc23a301 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.cpp @@ -20,13 +20,29 @@ #include "RifSummaryReaderInterface.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition() +: m_summaryCase(nullptr) +, m_ensemble(nullptr) + +{ +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress) +RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, + const RifEclipseSummaryAddress& summaryAddress, + RimSummaryCaseCollection* ensemble) + : m_summaryCase(summaryCase) + , m_ensemble(ensemble) + , m_summaryAddress(summaryAddress) { - m_curveDefinition = std::make_pair(summaryCase, summaryAddress); + } //-------------------------------------------------------------------------------------------------- @@ -34,7 +50,15 @@ RiaSummaryCurveDefinition::RiaSummaryCurveDefinition(RimSummaryCase* summaryCase //-------------------------------------------------------------------------------------------------- RimSummaryCase* RiaSummaryCurveDefinition::summaryCase() const { - return m_curveDefinition.first; + return m_summaryCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RiaSummaryCurveDefinition::ensemble() const +{ + return m_ensemble; } //-------------------------------------------------------------------------------------------------- @@ -42,9 +66,18 @@ RimSummaryCase* RiaSummaryCurveDefinition::summaryCase() const //-------------------------------------------------------------------------------------------------- const RifEclipseSummaryAddress& RiaSummaryCurveDefinition::summaryAddress() const { - return m_curveDefinition.second; + return m_summaryAddress; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaSummaryCurveDefinition::isEnsembleCurve() const +{ + return m_ensemble != nullptr; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -82,21 +115,22 @@ const std::vector& RiaSummaryCurveDefinition::timeSteps(const RiaSummary //-------------------------------------------------------------------------------------------------- QString RiaSummaryCurveDefinition::curveDefinitionText() const { - return RiaSummaryCurveDefinition::curveDefinitionText(summaryCase(), summaryAddress()); + QString caseName; + if (summaryCase() ) caseName = summaryCase()->caseName(); + else if (ensemble()) caseName = ensemble()->name(); + + return RiaSummaryCurveDefinition::curveDefinitionText(caseName, summaryAddress()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiaSummaryCurveDefinition::curveDefinitionText(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress) +QString RiaSummaryCurveDefinition::curveDefinitionText(const QString& caseName, const RifEclipseSummaryAddress& summaryAddress) { QString txt; - if (summaryCase) - { - txt += summaryCase->caseName(); - txt += ", "; - } + txt += caseName; + txt += ", "; txt += QString::fromStdString(summaryAddress.uiText()); @@ -108,11 +142,16 @@ QString RiaSummaryCurveDefinition::curveDefinitionText(RimSummaryCase* summaryCa //-------------------------------------------------------------------------------------------------- bool RiaSummaryCurveDefinition::operator<(const RiaSummaryCurveDefinition& other) const { - if (m_curveDefinition.first == other.summaryCase()) + if (m_summaryCase != other.summaryCase()) { - return (m_curveDefinition.second < other.summaryAddress()); + return m_summaryCase < other.summaryCase(); } - return (m_curveDefinition.first < other.summaryCase()); + if (m_ensemble != other.ensemble()) + { + return (m_ensemble < other.ensemble()); + } + + return (m_summaryAddress < other.summaryAddress()); } diff --git a/ApplicationCode/Application/RiaSummaryCurveDefinition.h b/ApplicationCode/Application/RiaSummaryCurveDefinition.h index 7978a90a02..3fd0940eb7 100644 --- a/ApplicationCode/Application/RiaSummaryCurveDefinition.h +++ b/ApplicationCode/Application/RiaSummaryCurveDefinition.h @@ -26,6 +26,7 @@ #include class RimSummaryCase; +class RimSummaryCaseCollection; //================================================================================================== /// @@ -33,10 +34,15 @@ class RimSummaryCase; class RiaSummaryCurveDefinition { public: - explicit RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress); + RiaSummaryCurveDefinition(); + explicit RiaSummaryCurveDefinition(RimSummaryCase* summaryCase, + const RifEclipseSummaryAddress& summaryAddress, + RimSummaryCaseCollection* emsemble = nullptr); RimSummaryCase* summaryCase() const; const RifEclipseSummaryAddress& summaryAddress() const; + RimSummaryCaseCollection* ensemble() const; + bool isEnsembleCurve() const; bool operator < (const RiaSummaryCurveDefinition& other) const; @@ -46,10 +52,12 @@ class RiaSummaryCurveDefinition QString curveDefinitionText() const; - static QString curveDefinitionText(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& summaryAddress); + static QString curveDefinitionText(const QString& caseName, const RifEclipseSummaryAddress& summaryAddress); private: private: - std::pair m_curveDefinition; + RimSummaryCase* m_summaryCase; + RifEclipseSummaryAddress m_summaryAddress; + RimSummaryCaseCollection* m_ensemble; }; diff --git a/ApplicationCode/Application/RiaViewRedrawScheduler.cpp b/ApplicationCode/Application/RiaViewRedrawScheduler.cpp new file mode 100644 index 0000000000..b1d31a499a --- /dev/null +++ b/ApplicationCode/Application/RiaViewRedrawScheduler.cpp @@ -0,0 +1,145 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaViewRedrawScheduler.h" +#include "Rim3dView.h" + +#include +#include + +#include +#include "cafProgressState.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaViewRedrawScheduler* RiaViewRedrawScheduler::instance() +{ + static RiaViewRedrawScheduler theInstance; + + return &theInstance; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::clearViewsScheduledForUpdate() +{ + if (m_resViewUpdateTimer) + { + while (m_resViewUpdateTimer->isActive()) + { + QCoreApplication::processEvents(); + } + } + m_resViewsToUpdate.clear(); +} + + +//-------------------------------------------------------------------------------------------------- +/// 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 RiaViewRedrawScheduler::scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate) +{ + m_resViewsToUpdate.push_back(resViewToUpdate); + + startTimer(0); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::startTimer(int msecs) +{ + if (!m_resViewUpdateTimer) + { + m_resViewUpdateTimer = new QTimer(this); + connect(m_resViewUpdateTimer, SIGNAL(timeout()), this, SLOT(slotUpdateAndRedrawScheduledViewsWhenReady())); + } + + if (!m_resViewUpdateTimer->isActive()) + { + m_resViewUpdateTimer->setSingleShot(true); + m_resViewUpdateTimer->start(msecs); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::updateAndRedrawScheduledViews() +{ + // Compress to remove duplicates + // and update dependent views after independent views + + std::set independent3DViewsToUpdate; + std::set dependent3DViewsToUpdate; + + for (size_t i = 0; i < m_resViewsToUpdate.size(); ++i) + { + if (!m_resViewsToUpdate[i]) continue; + + if (m_resViewsToUpdate[i]->viewController()) + dependent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); + else + independent3DViewsToUpdate.insert(m_resViewsToUpdate[i]); + } + + for (std::set::iterator it = independent3DViewsToUpdate.begin(); it != independent3DViewsToUpdate.end(); ++it ) + { + if (*it) + { + (*it)->createDisplayModelAndRedraw(); + } + } + + for (std::set::iterator it = dependent3DViewsToUpdate.begin(); it != dependent3DViewsToUpdate.end(); ++it) + { + if (*it) + { + (*it)->createDisplayModelAndRedraw(); + } + } + + m_resViewsToUpdate.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaViewRedrawScheduler::slotUpdateAndRedrawScheduledViewsWhenReady() +{ + if ( caf::ProgressState::isActive() ) + { + startTimer(100); + return; + } + + updateAndRedrawScheduledViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaViewRedrawScheduler::~RiaViewRedrawScheduler() +{ + delete m_resViewUpdateTimer; +} diff --git a/ApplicationCode/Application/RiaViewRedrawScheduler.h b/ApplicationCode/Application/RiaViewRedrawScheduler.h new file mode 100644 index 0000000000..9a228a571f --- /dev/null +++ b/ApplicationCode/Application/RiaViewRedrawScheduler.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include "cafPdmPointer.h" + +class QTimer; +class Rim3dView; + + +class RiaViewRedrawScheduler : public QObject +{ + Q_OBJECT; +public: + static RiaViewRedrawScheduler* instance(); + void scheduleDisplayModelUpdateAndRedraw(Rim3dView* resViewToUpdate); + void clearViewsScheduledForUpdate(); + void updateAndRedrawScheduledViews(); + +private slots: + void slotUpdateAndRedrawScheduledViewsWhenReady(); + +private: + void startTimer(int msecs); + + RiaViewRedrawScheduler() : m_resViewUpdateTimer(nullptr) {} + ~RiaViewRedrawScheduler(); + + RiaViewRedrawScheduler(const RiaViewRedrawScheduler& o) = delete; + void operator=(const RiaViewRedrawScheduler& o) = delete; + + std::vector > m_resViewsToUpdate; + QTimer* m_resViewUpdateTimer; +}; + + diff --git a/ApplicationCode/Application/Tools/CMakeLists_files.cmake b/ApplicationCode/Application/Tools/CMakeLists_files.cmake index 8a38c31b7a..06095bc398 100644 --- a/ApplicationCode/Application/Tools/CMakeLists_files.cmake +++ b/ApplicationCode/Application/Tools/CMakeLists_files.cmake @@ -1,52 +1,56 @@ -# 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}RiaArgumentParser.h -${CEE_CURRENT_LIST_DIR}RiaDateStringParser.h -${CEE_CURRENT_LIST_DIR}RiaColorTables.h -${CEE_CURRENT_LIST_DIR}RiaColorTools.h -${CEE_CURRENT_LIST_DIR}RiaEclipseUnitTools.h -${CEE_CURRENT_LIST_DIR}RiaImageCompareReporter.h -${CEE_CURRENT_LIST_DIR}RiaImageFileCompare.h -${CEE_CURRENT_LIST_DIR}RiaLogging.h -${CEE_CURRENT_LIST_DIR}RiaProjectModifier.h -${CEE_CURRENT_LIST_DIR}RiaRegressionTest.h -${CEE_CURRENT_LIST_DIR}RiaImportEclipseCaseTools.h -${CEE_CURRENT_LIST_DIR}RiaQDateTimeTools.h -${CEE_CURRENT_LIST_DIR}RiaSummaryTools.h -${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.h -${CEE_CURRENT_LIST_DIR}RiaStdStringTools.h -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveAnalyzer.h -${CEE_CURRENT_LIST_DIR}RiaSimWellBranchTools.h -${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools.h -${CEE_CURRENT_LIST_DIR}RiaStringEncodingTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaArgumentParser.h +${CMAKE_CURRENT_LIST_DIR}/RiaDateStringParser.h +${CMAKE_CURRENT_LIST_DIR}/RiaColorTables.h +${CMAKE_CURRENT_LIST_DIR}/RiaColorTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaImageCompareReporter.h +${CMAKE_CURRENT_LIST_DIR}/RiaImageFileCompare.h +${CMAKE_CURRENT_LIST_DIR}/RiaLogging.h +${CMAKE_CURRENT_LIST_DIR}/RiaProjectModifier.h +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTest.h +${CMAKE_CURRENT_LIST_DIR}/RiaImportEclipseCaseTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaQDateTimeTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaWellNameComparer.h +${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.h +${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.h +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.h +${CMAKE_CURRENT_LIST_DIR}/RiaExtractionTools.h +${CMAKE_CURRENT_LIST_DIR}/RiaFilePathTools.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RiaArgumentParser.cpp -${CEE_CURRENT_LIST_DIR}RiaDateStringParser.cpp -${CEE_CURRENT_LIST_DIR}RiaColorTables.cpp -${CEE_CURRENT_LIST_DIR}RiaColorTools.cpp -${CEE_CURRENT_LIST_DIR}RiaEclipseUnitTools.cpp -${CEE_CURRENT_LIST_DIR}RiaImageCompareReporter.cpp -${CEE_CURRENT_LIST_DIR}RiaImageFileCompare.cpp -${CEE_CURRENT_LIST_DIR}RiaLogging.cpp -${CEE_CURRENT_LIST_DIR}RiaProjectModifier.cpp -${CEE_CURRENT_LIST_DIR}RiaRegressionTest.cpp -${CEE_CURRENT_LIST_DIR}RiaImportEclipseCaseTools.cpp -${CEE_CURRENT_LIST_DIR}RiaQDateTimeTools.cpp -${CEE_CURRENT_LIST_DIR}RiaSummaryTools.cpp -${CEE_CURRENT_LIST_DIR}RiaWellNameComparer.cpp -${CEE_CURRENT_LIST_DIR}RiaStdStringTools.cpp -${CEE_CURRENT_LIST_DIR}RiaSummaryCurveAnalyzer.cpp -${CEE_CURRENT_LIST_DIR}RiaSimWellBranchTools.cpp -${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools.cpp -${CEE_CURRENT_LIST_DIR}RiaStringEncodingTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaArgumentParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaDateStringParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaColorTables.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaColorTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaImageCompareReporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaImageFileCompare.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaLogging.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaProjectModifier.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTest.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaImportEclipseCaseTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaQDateTimeTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaWellNameComparer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaStdStringTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveAnalyzer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaSimWellBranchTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaStringEncodingTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaTextStringTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaRegressionTestRunner.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaExtractionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaFilePathTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -62,4 +66,4 @@ ${QT_MOC_HEADERS} ) -source_group( "Application\\Tools" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "Application\\Tools" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp index 2f90a43c29..618544f9ac 100644 --- a/ApplicationCode/Application/Tools/RiaArgumentParser.cpp +++ b/ApplicationCode/Application/Tools/RiaArgumentParser.cpp @@ -18,16 +18,17 @@ #include "RiaArgumentParser.h" -#include "RiaProjectModifier.h" #include "RiaApplication.h" -#include "RiaPreferences.h" -#include "RiaImportEclipseCaseTools.h" #include "RiaBaseDefs.h" +#include "RiaImportEclipseCaseTools.h" +#include "RiaPreferences.h" +#include "RiaProjectModifier.h" +#include "RiaRegressionTestRunner.h" #include "RimProject.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicfMessages.h" #include "RicfCommandFileExecutor.h" @@ -70,6 +71,7 @@ bool RiaArgumentParser::parseArguments() progOpt.registerOption("regressiontest", "", "System command", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("updateregressiontestbase", "", "System command", cvf::ProgramOptions::SINGLE_VALUE); progOpt.registerOption("unittest", "", "System command"); + progOpt.registerOption("ignoreArgs", "", "Ignore all arguments. Mostly for testing purposes"); progOpt.setOptionPrefix(cvf::ProgramOptions::DOUBLE_DASH); @@ -104,11 +106,17 @@ bool RiaArgumentParser::parseArguments() // Handling of the actual command line options // -------------------------------------------------------- + + if (cvf::Option o = progOpt.option("ignoreArgs")) + { + return true; + } + if (cvf::Option o = progOpt.option("regressiontest")) { CVF_ASSERT(o.valueCount() == 1); QString regressionTestPath = cvfqt::Utils::toQString(o.value(0)); - RiaApplication::instance()->executeRegressionTests(regressionTestPath); + RiaRegressionTestRunner::instance()->executeRegressionTests(regressionTestPath, QStringList()); return false; } @@ -116,7 +124,7 @@ bool RiaArgumentParser::parseArguments() { CVF_ASSERT(o.valueCount() == 1); QString regressionTestPath = cvfqt::Utils::toQString(o.value(0)); - RiaApplication::instance()->updateRegressionTest(regressionTestPath); + RiaRegressionTestRunner::instance()->updateRegressionTest(regressionTestPath); return false; } @@ -264,21 +272,21 @@ bool RiaArgumentParser::parseArguments() if (caf::Utils::fileExists(caseName) && (fileExtension == "EGRID" || fileExtension == "GRID")) { - RiaImportEclipseCaseTools::openEclipseCaseFromFile(caseName); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseName }), nullptr, true); } else { QString caseFileNameWithExt = caseName + ".EGRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { - RiaImportEclipseCaseTools::openEclipseCaseFromFile(caseFileNameWithExt); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true); } else { caseFileNameWithExt = caseName + ".GRID"; if (caf::Utils::fileExists(caseFileNameWithExt)) { - RiaImportEclipseCaseTools::openEclipseCaseFromFile(caseFileNameWithExt); + RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({ caseFileNameWithExt }), nullptr, true); } } } diff --git a/ApplicationCode/Application/Tools/RiaColorTables.cpp b/ApplicationCode/Application/Tools/RiaColorTables.cpp index 0d10a3ede4..27b4d52408 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTables.cpp @@ -190,6 +190,51 @@ const caf::ColorTable& RiaColorTables::categoryPaletteColors() return colorTable; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::tensorWhiteGrayBlackPaletteColors() +{ + static std::vector colors{ + cvf::Color3ub::WHITE, + cvf::Color3ub::LIGHT_GRAY, + cvf::Color3ub::BLACK, + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + return colorTable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::tensorOrangeBlueWhitePaletteColors() +{ + static std::vector colors{ + cvf::Color3ub(236, 118, 0), // Orange + cvf::Color3ub(56, 56, 255), // Vivid Blue + cvf::Color3ub(210, 248, 250), // White Turquoiseish + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + return colorTable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::ColorTable& RiaColorTables::tensorsMagentaBrownGrayPaletteColors() +{ + static std::vector colors{ + cvf::Color3ub(248, 0, 170), // Magenta + cvf::Color3ub::BROWN, + cvf::Color3ub::LIGHT_GRAY, + }; + + static caf::ColorTable colorTable = caf::ColorTable(colors); + return colorTable; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -451,3 +496,23 @@ const caf::ColorTable& RiaColorTables::timestepsPaletteColors() return colorTable; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTables::undefinedCellColor() +{ + return cvf::Color3::GRAY; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTables::perforationLengthColor() +{ + // based on hwb ( 85, 9%, 67%) dark_olive_green + // added 10 to each component + cvf::Color3ub color(69, 94, 33); + + return cvf::Color3f(color); +} diff --git a/ApplicationCode/Application/Tools/RiaColorTables.h b/ApplicationCode/Application/Tools/RiaColorTables.h index 623ab8d6d9..ab1a3de8a1 100644 --- a/ApplicationCode/Application/Tools/RiaColorTables.h +++ b/ApplicationCode/Application/Tools/RiaColorTables.h @@ -37,6 +37,9 @@ class RiaColorTables static const caf::ColorTable& blueWhiteRedPaletteColors(); static const caf::ColorTable& redWhiteBluePaletteColors(); static const caf::ColorTable& categoryPaletteColors(); + static const caf::ColorTable& tensorWhiteGrayBlackPaletteColors(); + static const caf::ColorTable& tensorOrangeBlueWhitePaletteColors(); + static const caf::ColorTable& tensorsMagentaBrownGrayPaletteColors(); static const caf::ColorTable& angularPaletteColors(); static const caf::ColorTable& stimPlanPaletteColors(); static const caf::ColorTable& faultsPaletteColors(); @@ -51,4 +54,6 @@ class RiaColorTables static const caf::ColorTable& selectionPaletteColors(); static const caf::ColorTable& timestepsPaletteColors(); + static cvf::Color3f undefinedCellColor(); + static cvf::Color3f perforationLengthColor(); }; diff --git a/ApplicationCode/Application/Tools/RiaColorTools.cpp b/ApplicationCode/Application/Tools/RiaColorTools.cpp index c17f61e6c3..0d74ee9489 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.cpp +++ b/ApplicationCode/Application/Tools/RiaColorTools.cpp @@ -17,6 +17,8 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiaColorTools.h" +#include "cvfMath.h" +#include //-------------------------------------------------------------------------------------------------- /// @@ -31,6 +33,33 @@ bool RiaColorTools::isBrightnessAboveThreshold(cvf::Color3f backgroundColor) return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f RiaColorTools::computeOffsetColor(cvf::Color3f color, float offsetFactor) +{ + float gridR = 0.0; + float gridG = 0.0; + float gridB = 0.0; + + if (isBrightnessAboveThreshold(color)) + { + gridR = color.r() - (color.r() * offsetFactor); + gridG = color.g() - (color.g() * offsetFactor); + gridB = color.b() - (color.b() * offsetFactor); + } + else + { + gridR = color.r() + (1.0f - color.r()) * offsetFactor; + gridG = color.g() + (1.0f - color.g()) * offsetFactor; + gridB = color.b() + (1.0f - color.b()) * offsetFactor; + } + + return cvf::Color3f(cvf::Math::clamp(gridR, 0.0f, 1.0f), + cvf::Math::clamp(gridG, 0.0f, 1.0f), + cvf::Math::clamp(gridB, 0.0f, 1.0f)); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaColorTools.h b/ApplicationCode/Application/Tools/RiaColorTools.h index ff2141b566..8feb7a1d7c 100644 --- a/ApplicationCode/Application/Tools/RiaColorTools.h +++ b/ApplicationCode/Application/Tools/RiaColorTools.h @@ -30,7 +30,8 @@ class RiaColorTools { public: static bool isBrightnessAboveThreshold(cvf::Color3f backgroundColor); - + + static cvf::Color3f computeOffsetColor(cvf::Color3f color, float offsetFactor); static cvf::Color3f darkContrastColor(); static cvf::Color3f brightContrastColor(); static cvf::Color3f constrastColor(cvf::Color3f backgroundColor); diff --git a/ApplicationCode/Application/Tools/RiaDateStringParser.cpp b/ApplicationCode/Application/Tools/RiaDateStringParser.cpp index cd8d96fa21..c28575a548 100644 --- a/ApplicationCode/Application/Tools/RiaDateStringParser.cpp +++ b/ApplicationCode/Application/Tools/RiaDateStringParser.cpp @@ -139,7 +139,7 @@ bool RiaDateStringParser::tryParseMonthFirst(const std::string& s, int& year, in //-------------------------------------------------------------------------------------------------- bool RiaDateStringParser::tryParseYear(const std::string& s, int &year) { - if (containsAlphabetic(s)) return false; + if (RiaStdStringTools::containsAlphabetic(s)) return false; auto today = QDate::currentDate(); int y = RiaStdStringTools::toInt(s); @@ -158,7 +158,7 @@ bool RiaDateStringParser::tryParseYear(const std::string& s, int &year) //-------------------------------------------------------------------------------------------------- bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month) { - if (containsAlphabetic(s)) + if (RiaStdStringTools::containsAlphabetic(s)) { auto sMonth = s; sMonth = trimString(sMonth); @@ -190,7 +190,7 @@ bool RiaDateStringParser::tryParseMonth(const std::string& s, int &month) //-------------------------------------------------------------------------------------------------- bool RiaDateStringParser::tryParseDay(const std::string& s, int &day) { - if (containsAlphabetic(s)) return false; + if (RiaStdStringTools::containsAlphabetic(s)) return false; int d = RiaStdStringTools::toInt(s); if (d >= 1 && d <= 31) @@ -203,14 +203,6 @@ bool RiaDateStringParser::tryParseDay(const std::string& s, int &day) return false; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RiaDateStringParser::containsAlphabetic(const std::string& s) -{ - return std::find_if(s.begin(), s.end(), [](char c) { return isalpha(c); }) != s.end(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaDateStringParser.h b/ApplicationCode/Application/Tools/RiaDateStringParser.h index bd573078a8..4e23b44053 100644 --- a/ApplicationCode/Application/Tools/RiaDateStringParser.h +++ b/ApplicationCode/Application/Tools/RiaDateStringParser.h @@ -42,7 +42,6 @@ class RiaDateStringParser static bool tryParseMonth(const std::string& s, int &month); static bool tryParseDay(const std::string& s, int &day); - static bool containsAlphabetic(const std::string& s); static std::string trimString(const std::string& s); }; diff --git a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp index 315a739039..a0c4d36cf7 100644 --- a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp +++ b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.cpp @@ -124,3 +124,58 @@ QString RiaEclipseUnitTools::unitStringPressure(UnitSystem unitSystem) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaEclipseUnitTools::convertToMeter(double sourceValue, const QString& unitText) +{ + QString timmed = unitText.trimmed(); + + if (timmed.compare("m", Qt::CaseInsensitive) == 0) + { + return sourceValue; + } + else if (timmed.compare("cm", Qt::CaseInsensitive) == 0) + { + return sourceValue / 100.0; + } + else if (timmed.compare("in", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::inchToMeter(sourceValue); + } + else if (timmed.compare("ft", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::feetToMeter(sourceValue); + } + + return HUGE_VAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiaEclipseUnitTools::convertToFeet(double sourceValue, const QString& unitText) +{ + QString timmed = unitText.trimmed(); + + if (timmed.compare("ft", Qt::CaseInsensitive) == 0) + { + return sourceValue; + } + else if (timmed.compare("in", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::inchToFeet(sourceValue); + } + else if (timmed.compare("cm", Qt::CaseInsensitive) == 0) + { + double meter = sourceValue / 100.0; + return RiaEclipseUnitTools::meterToFeet(meter); + } + else if (timmed.compare("m", Qt::CaseInsensitive) == 0) + { + return RiaEclipseUnitTools::meterToFeet(sourceValue); + } + + return HUGE_VAL; +} + diff --git a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h index 0f43e97a7d..476970a941 100644 --- a/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h +++ b/ApplicationCode/Application/Tools/RiaEclipseUnitTools.h @@ -51,5 +51,8 @@ class RiaEclipseUnitTools static double convertSurfaceGasFlowRateToOilEquivalents(UnitSystem, double eclGasFlowRate); static QString unitStringPressure(UnitSystem unitSystem); + + static double convertToMeter(double sourceValue, const QString& unitText); + static double convertToFeet(double sourceValue, const QString& unitText); }; diff --git a/ApplicationCode/Application/Tools/RiaExtractionTools.cpp b/ApplicationCode/Application/Tools/RiaExtractionTools.cpp new file mode 100644 index 0000000000..a401c6b254 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaExtractionTools.cpp @@ -0,0 +1,92 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaExtractionTools.h" + +#include "RiaApplication.h" + +#include "RigWellPath.h" +#include "RimEclipseCase.h" +#include "RimMainPlotCollection.h" +#include "RimProject.h" +#include "RimSimWellInView.h" +#include "RimWellLogPlotCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEclipseWellLogExtractor* RiaExtractionTools::wellLogExtractorEclipseCase(RimWellPath* wellPath, RimEclipseCase* eclipseCase) +{ + auto wlPlotCollection = wellLogPlotCollection(); + if (!wlPlotCollection) return nullptr; + + return wlPlotCollection->findOrCreateExtractor(wellPath, eclipseCase); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGeoMechWellLogExtractor* RiaExtractionTools::wellLogExtractorGeoMechCase(RimWellPath* wellPath, RimGeoMechCase* geomCase) +{ + auto wlPlotCollection = wellLogPlotCollection(); + if (!wlPlotCollection) return nullptr; + + return wlPlotCollection->findOrCreateExtractor(wellPath, geomCase); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigEclipseWellLogExtractor* RiaExtractionTools::findOrCreateSimWellExtractor(const RimSimWellInView* simWell, + const RigWellPath* wellPathGeom) +{ + auto wlPlotCollection = wellLogPlotCollection(); + if (!wlPlotCollection) return nullptr; + + if (!(simWell && wellPathGeom)) + { + return nullptr; + } + + RimEclipseCase* eclipseCase = nullptr; + simWell->firstAncestorOrThisOfType(eclipseCase); + if (!(eclipseCase && eclipseCase->eclipseCaseData())) + { + return nullptr; + } + + QString caseUserDescription = eclipseCase->caseUserDescription(); + + return wlPlotCollection->findOrCreateSimWellExtractor( + simWell->name, caseUserDescription, wellPathGeom, eclipseCase->eclipseCaseData()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogPlotCollection* RiaExtractionTools::wellLogPlotCollection() +{ + auto proj = RiaApplication::instance()->project(); + if (!proj) return nullptr; + + auto plotCollection = proj->mainPlotCollection(); + if (!plotCollection) return nullptr; + + auto wellLogPlotCollection = plotCollection->wellLogPlotCollection(); + return wellLogPlotCollection; +} diff --git a/ApplicationCode/Application/Tools/RiaExtractionTools.h b/ApplicationCode/Application/Tools/RiaExtractionTools.h new file mode 100644 index 0000000000..6b1a3bee29 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaExtractionTools.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class RigEclipseWellLogExtractor; +class RigGeoMechWellLogExtractor; +class RigWellPath; +class RimEclipseCase; +class RimGeoMechCase; +class RimSimWellInView; +class RimWellLogPlotCollection; +class RimWellPath; + +class QString; + +//================================================================================================== +// +//================================================================================================== +namespace RiaExtractionTools +{ +RigEclipseWellLogExtractor* wellLogExtractorEclipseCase(RimWellPath* wellPath, RimEclipseCase* eclipseCase); +RigGeoMechWellLogExtractor* wellLogExtractorGeoMechCase(RimWellPath* wellPath, RimGeoMechCase* geomCase); + +RigEclipseWellLogExtractor* findOrCreateSimWellExtractor(const RimSimWellInView* simWell, const RigWellPath* wellPathGeom); + +RimWellLogPlotCollection* wellLogPlotCollection(); + +}; // namespace RiaExtractionTools diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.cpp b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp new file mode 100644 index 0000000000..2e844daf74 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.cpp @@ -0,0 +1,130 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaFilePathTools.h" +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QChar RiaFilePathTools::SEPARATOR = '/'; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::toInternalSeparator(const QString& path) +{ + QString currNativeSep = QDir::separator(); + + if (currNativeSep == "/") + { + // On Linux like system -> Do not convert separators + return path; + } + + // On other systems (i.e. Windows) -> Convert to internal separator (/) + QString output = path; + return output.replace(QString("\\"), SEPARATOR); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString& RiaFilePathTools::appendSeparatorIfNo(QString& path) +{ + if (!path.endsWith(SEPARATOR)) + { + path.append(SEPARATOR); + } + return path; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::relativePath(const QString& rootDir, const QString& dir) +{ + if (dir.startsWith(rootDir)) + { + QString relPath = dir; + relPath.remove(0, rootDir.size()); + + if (relPath.startsWith(SEPARATOR)) relPath.remove(0, 1); + return appendSeparatorIfNo(relPath); + } + else + { + return dir; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaFilePathTools::equalPaths(const QString& path1, const QString& path2) +{ + QString p1 = path1; + QString p2 = path2; + appendSeparatorIfNo(p1); + appendSeparatorIfNo(p2); + return p1 == p2; +} + +//-------------------------------------------------------------------------------------------------- +/// Own canonicalPath method since the QDir::canonicalPath seems to not work +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::canonicalPath(const QString& path) +{ + return QDir(path).absolutePath(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaFilePathTools::commonRootPath(const QStringList& paths) +{ + if (paths.size() < 2) return ""; + + int i = 0; + int iDir = 0; + for(i = 0; ; i++) + { + bool isCommon = true; + QChar ch = i < paths.front().size() ? paths.front()[i] : 0; + + // Remember last directory separator + if (i > 0 && (ch == '/' || ch == '\\')) iDir = i; + + // Compare characters at position i + for (const QString& path : paths) + { + if (ch == 0 || path[i] != ch) + { + isCommon = false; + break; + } + } + + if (!isCommon) break; + } + + return paths.front().left(iDir + 1); +} diff --git a/ApplicationCode/Application/Tools/RiaFilePathTools.h b/ApplicationCode/Application/Tools/RiaFilePathTools.h new file mode 100644 index 0000000000..255a93e6f6 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaFilePathTools.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +//================================================================================================== +// +// +// +//================================================================================================== +class RiaFilePathTools +{ +public: + static const QChar SEPARATOR; + + static QString toInternalSeparator(const QString& path); + static QString& appendSeparatorIfNo(QString& path); + static QString relativePath(const QString& rootDir, const QString& dir); + static bool equalPaths(const QString& path1, const QString& path2); + static QString canonicalPath(const QString& path); + static QString commonRootPath(const QStringList& paths); +}; diff --git a/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp b/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp index cf140fe3ab..f3afde6fdf 100644 --- a/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp +++ b/ApplicationCode/Application/Tools/RiaImageCompareReporter.cpp @@ -177,36 +177,36 @@ std::string RiaImageCompareReporter::cssString() const html += ""; html += ".image-slider {"; - html += "position:relative;"; - html += "display: inline-block;"; - html += "line-height: 0;"; + html += "position:relative;"; + html += "display: inline-block;"; + html += "line-height: 0;"; html += "}"; html += ".image-slider > div {"; - html += "position: absolute;"; - html += "top: 0; bottom: 0; left: 0;"; - html += "width: 25px;"; - html += "max-width: 100%;"; - html += "overflow: hidden;"; - html += "resize: horizontal;"; + html += "position: absolute;"; + html += "top: 0; bottom: 0; left: 0;"; + html += "width: 25px;"; + html += "max-width: 100%;"; + html += "overflow: hidden;"; + html += "resize: horizontal;"; html += "}"; html += ".image-slider > div:before {"; - html += "content: '';"; - html += "position: absolute;"; - html += "right: 0; bottom: 0;"; - html += "width: 23px; height: 23px;"; - html += "padding: 5px;"; - html += "background: linear-gradient(-45deg, gray 50%, transparent 0);"; - html += "background-clip: content-box;"; - html += "cursor: ew-resize;"; - html += "-webkit-filter: drop-shadow(0 0 6px black);"; - html += "filter: drop-shadow(0 0 6px black);"; + html += "content: '';"; + html += "position: absolute;"; + html += "right: 0; bottom: 0;"; + html += "width: 23px; height: 23px;"; + html += "padding: 5px;"; + html += "background: linear-gradient(-45deg, gray 50%, transparent 0);"; + html += "background-clip: content-box;"; + html += "cursor: ew-resize;"; + html += "-webkit-filter: drop-shadow(0 0 6px black);"; + html += "filter: drop-shadow(0 0 6px black);"; html += "}"; html += ".image-slider img {"; - html += "user-select: none;"; - html += "max-width: 1000px;"; + html += "user-select: none;"; + html += "max-width: 1000px;"; html += "}"; html += ""; diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp index d1b69a59d0..139741cb1d 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -21,8 +21,12 @@ #include "../SummaryPlotCommands/RicNewSummaryPlotFeature.h" #include "RiaApplication.h" +#include "RiaLogging.h" #include "RiaPreferences.h" +#include "RifEclipseSummaryTools.h" +#include "RifSummaryCaseRestartSelector.h" + #include "RigGridManager.h" #include "RimCaseCollection.h" @@ -30,25 +34,134 @@ #include "RimEclipseCellColors.h" #include "RimEclipseResultCase.h" #include "RimEclipseView.h" +#include "RimFileSummaryCase.h" +#include "RimGridSummaryCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" #include "RiuMainWindow.h" +#include "RiuPlotMainWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafUtils.h" #include "cafProgressInfo.h" #include +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaImportEclipseCaseTools::openEclipseCasesFromFile(const QStringList& fileNames, QStringList* openedFiles, bool noDialog) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); + + // Get list of files to import + RifSummaryCaseRestartSelector selector; + if(noDialog) selector.showDialog(false); + selector.determineFilesToImportFromGridFiles(fileNames); + std::vector summaryFileInfos = selector.summaryFileInfos(); + + // Import eclipse case files + for (const QString& gridCaseFile : selector.gridCaseFiles()) + { + if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(gridCaseFile)) + { + if(openedFiles) openedFiles->push_back(gridCaseFile); + } + } + + // Import summary cases + if (!summaryFileInfos.empty()) + { + RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; + if (sumCaseColl) + { + std::vector newSumCases = sumCaseColl->createSummaryCasesFromFileInfos(summaryFileInfos); + + for (RimSummaryCase* newSumCase : newSumCases) + { + RimSummaryCaseCollection* existingCollection = nullptr; + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(newSumCase->summaryHeaderFilename()); + RimEclipseCase* gridCase = project->eclipseCaseFromGridFileName(gridCaseFile); + if (gridCase) + { + RimSummaryCase* existingSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); + RimGridSummaryCase* existingGridSummaryCase = dynamic_cast(existingSummaryCase); + RimFileSummaryCase* existingFileSummaryCase = dynamic_cast(existingSummaryCase); + if (existingGridSummaryCase) + { + delete newSumCase; // No need to add anything new. Already have one. + continue; + } + else if (existingFileSummaryCase) + { + existingFileSummaryCase->firstAncestorOrThisOfType(existingCollection); + + // Replace all occurrences of file sum with ecl sum + + std::vector referringObjects; + existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); + + // UI settings of a curve filter is updated based + // on the new case association for the curves in the curve filter + // UI is updated by loadDataAndUpdate() + + for (caf::PdmObjectHandle* objHandle : referringObjects) + { + RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); + if (summaryCurve) + { + RimSummaryCurveCollection* parentCollection = nullptr; + summaryCurve->firstAncestorOrThisOfType(parentCollection); + if (parentCollection) + { + parentCollection->loadDataAndUpdate(true); + parentCollection->updateConnectedEditors(); + break; + } + } + } + + // Remove existing case + sumCaseColl->removeCase(existingFileSummaryCase); + delete existingFileSummaryCase; + } + } + if (existingCollection) + { + existingCollection->addCase(newSumCase); + } + else + { + sumCaseColl->addCase(newSumCase); + } + sumCaseColl->updateAllRequiredEditors(); + } + } + } + if (selector.foundErrors()) + { + QString errorMessage = selector.createCombinedErrorMessage(); + RiaLogging::error(errorMessage); + } + + RiuPlotMainWindowTools::refreshToolbars(); + + return true; +} //-------------------------------------------------------------------------------------------------- /// @@ -92,8 +205,12 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); - RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() : NULL; - if (analysisModels == NULL) return false; + RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() : nullptr; + if (analysisModels == nullptr) + { + delete rimResultReservoir; + return false; + } RiuMainWindow::instance()->show(); @@ -110,76 +227,8 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilterImpl(const QStr RimEclipseView* riv = rimResultReservoir->createAndAddReservoirView(); - // Select SOIL as default result variable - riv->cellResult()->setResultType(RiaDefines::DYNAMIC_NATIVE); - - if (app->preferences()->loadAndShowSoil) - { - riv->cellResult()->setResultVariable("SOIL"); - } - riv->hasUserRequestedAnimation = true; - riv->loadDataAndUpdate(); - // Add a corresponding summary case if it exists - { - RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : NULL; - if (sumCaseColl) - { - { - RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow(); - if (sumCaseColl->summaryCaseCount() == 0 && mainPlotWindow) - { - mainPlotWindow->hide(); - } - } - - if (!sumCaseColl->findSummaryCaseFromEclipseResultCase(rimResultReservoir)) - { - RimSummaryCase* newSumCase = sumCaseColl->createAndAddSummaryCaseFromEclipseResultCase(rimResultReservoir); - - if (newSumCase) - { - RimSummaryCase* existingFileSummaryCase = sumCaseColl->findSummaryCaseFromFileName(newSumCase->summaryHeaderFilename()); - if (existingFileSummaryCase) - { - // Replace all occurrences of file sum with ecl sum - - std::vector referringObjects; - existingFileSummaryCase->objectsWithReferringPtrFields(referringObjects); - - // UI settings of a curve filter is updated based - // on the new case association for the curves in the curve filter - // UI is updated by loadDataAndUpdate() - - for (caf::PdmObjectHandle* objHandle : referringObjects) - { - RimSummaryCurve* summaryCurve = dynamic_cast(objHandle); - if (summaryCurve) - { - RimSummaryCurveCollection* parentCollection = nullptr; - summaryCurve->firstAncestorOrThisOfType(parentCollection); - if (parentCollection) - { - parentCollection->loadDataAndUpdate(true); - parentCollection->updateConnectedEditors(); - break; - } - } - } - - sumCaseColl->removeCase(existingFileSummaryCase); - - delete existingFileSummaryCase; - - } - - sumCaseColl->updateAllRequiredEditors(); - } - } - } - } - if (!riv->cellResult()->hasResult()) { riv->cellResult()->setResultVariable(RiaDefines::undefinedResultName()); @@ -202,9 +251,9 @@ bool RiaImportEclipseCaseTools::addEclipseCases(const QStringList& fileNames) // First file is read completely including grid. // The main grid from the first case is reused directly in for the other cases. // When reading active cell info, only the total cell count is tested for consistency - RimEclipseResultCase* mainResultCase = NULL; + RimEclipseResultCase* mainResultCase = nullptr; std::vector< std::vector > mainCaseGridDimensions; - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; RiaApplication* app = RiaApplication::instance(); RimProject* project = app->project(); diff --git a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h index 34d9e3689a..90941a0ff2 100644 --- a/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h +++ b/ApplicationCode/Application/Tools/RiaImportEclipseCaseTools.h @@ -27,7 +27,7 @@ class QStringList; class RiaImportEclipseCaseTools { public: - static bool openEclipseCaseFromFile(const QString& fileName); + static bool openEclipseCasesFromFile(const QStringList& fileNames, QStringList* openedFiles = nullptr, bool noDialog = false); static bool openEclipseCaseShowTimeStepFilter(const QString& fileName); static bool openMockModel(const QString& name); @@ -35,6 +35,7 @@ class RiaImportEclipseCaseTools static bool addEclipseCases(const QStringList& fileNames); private: + static bool openEclipseCaseFromFile(const QString& fileName); static bool openEclipseCaseShowTimeStepFilterImpl(const QString& fileName, bool showTimeStepFilter); }; diff --git a/ApplicationCode/Application/Tools/RiaLogging.cpp b/ApplicationCode/Application/Tools/RiaLogging.cpp index ed0f5a6f06..cb1fa56ec2 100644 --- a/ApplicationCode/Application/Tools/RiaLogging.cpp +++ b/ApplicationCode/Application/Tools/RiaLogging.cpp @@ -157,7 +157,7 @@ void RiaDefaultConsoleLogger::writeToConsole(const std::string& str) DWORD stringLength = static_cast(str.length()); unsigned long iDum = 0; - WriteConsoleA(hStdOutputHandle, str.c_str(), stringLength, &iDum, NULL); + WriteConsoleA(hStdOutputHandle, str.c_str(), stringLength, &iDum, nullptr); } #else fputs(str.c_str(), stderr); @@ -192,7 +192,6 @@ void RiaLogging::setLoggerInstance(RiaLogger* loggerInstance) delete sm_logger; } -// VF_ASSERT(loggerInstance); sm_logger = loggerInstance; } @@ -203,7 +202,7 @@ void RiaLogging::setLoggerInstance(RiaLogger* loggerInstance) void RiaLogging::deleteLoggerInstance() { delete sm_logger; - sm_logger = NULL; + sm_logger = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -213,6 +212,7 @@ void RiaLogging::error(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_ERROR) { +#pragma omp critical sm_logger->error(message.toLatin1().constData()); } } @@ -224,6 +224,7 @@ void RiaLogging::warning(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_WARNING) { +#pragma omp critical sm_logger->warning(message.toLatin1().constData()); } } @@ -235,6 +236,7 @@ void RiaLogging::info(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_INFO) { +#pragma omp critical sm_logger->info(message.toLatin1().constData()); } } @@ -246,6 +248,7 @@ void RiaLogging::debug(const QString& message) { if (sm_logger && sm_logger->level() >= RI_LL_DEBUG) { +#pragma omp critical sm_logger->debug(message.toLatin1().constData()); } } diff --git a/ApplicationCode/Application/Tools/RiaProjectModifier.cpp b/ApplicationCode/Application/Tools/RiaProjectModifier.cpp index d922721315..82fae44ba2 100644 --- a/ApplicationCode/Application/Tools/RiaProjectModifier.cpp +++ b/ApplicationCode/Application/Tools/RiaProjectModifier.cpp @@ -125,7 +125,7 @@ void RiaProjectModifier::replaceSourceCases(RimProject* project) { for (RimOilField* oilField : project->oilFields()) { - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; if (analysisModels) { for (RimIdenticalGridCaseGroup* caseGroup : analysisModels->caseGroups) @@ -280,7 +280,7 @@ int RiaProjectModifier::firstGroupId(RimProject* project) for (size_t oilFieldIdx = 0; oilFieldIdx < project->oilFields().size(); oilFieldIdx++) { RimOilField* oilField = project->oilFields[oilFieldIdx]; - RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = oilField ? oilField->analysisModels() : nullptr; if (analysisModels) { if (analysisModels->caseGroups.size() > 0) diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp index f08fab4d4c..2d696c5f59 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.cpp +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.cpp @@ -18,6 +18,7 @@ #include "RiaRegressionTest.h" +#include "cafPdmSettings.h" #include "cafPdmUiFilePathEditor.h" #include "cafPdmUiTextEditor.h" @@ -29,9 +30,12 @@ CAF_PDM_SOURCE_INIT(RiaRegressionTest, "RiaRegressionTest"); //-------------------------------------------------------------------------------------------------- RiaRegressionTest::RiaRegressionTest(void) { - CAF_PDM_InitFieldNoDefault(&applicationWorkingFolder, "workingFolder", "Folder containing compare", "", "Location of compare tool from Image Magic suite", ""); - applicationWorkingFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(&folderContainingCompareTool, "workingFolder", "Folder containing compare", "", "Location of compare tool from Image Magic suite", ""); + folderContainingCompareTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(&folderContainingDiffTool, "folderContainingDiffTool", "Folder containing diff", "", "Location of diff tool used for text compare", ""); + folderContainingDiffTool.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); + CAF_PDM_InitFieldNoDefault(®ressionTestFolder, "regressionTestFolder", "Regression Test Folder", "", "", ""); regressionTestFolder.uiCapability()->setUiEditorTypeName(caf::PdmUiFilePathEditor::uiEditorTypeName()); @@ -49,12 +53,28 @@ RiaRegressionTest::~RiaRegressionTest(void) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTest::writeSettingsToApplicationStore() const +{ + caf::PdmSettings::writeFieldsToApplicationStore(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTest::readSettingsFromApplicationStore() +{ + caf::PdmSettings::readFieldsFromApplicationStore(this); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) { - if (field == &applicationWorkingFolder || field == ®ressionTestFolder) + if (field == &folderContainingDiffTool || field == &folderContainingCompareTool || field == ®ressionTestFolder) { caf::PdmUiFilePathEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -63,5 +83,3 @@ void RiaRegressionTest::defineEditorAttribute(const caf::PdmFieldHandle* field, } } } - - diff --git a/ApplicationCode/Application/Tools/RiaRegressionTest.h b/ApplicationCode/Application/Tools/RiaRegressionTest.h index 04eab1f83e..e4d815ed4f 100644 --- a/ApplicationCode/Application/Tools/RiaRegressionTest.h +++ b/ApplicationCode/Application/Tools/RiaRegressionTest.h @@ -32,8 +32,12 @@ class RiaRegressionTest : public caf::PdmObject RiaRegressionTest(void); virtual ~RiaRegressionTest(void); + void writeSettingsToApplicationStore() const; + void readSettingsFromApplicationStore(); + public: - caf::PdmField applicationWorkingFolder; + caf::PdmField folderContainingCompareTool; + caf::PdmField folderContainingDiffTool; caf::PdmField regressionTestFolder; caf::PdmField testFilter; caf::PdmField showInteractiveDiffImages; diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp new file mode 100644 index 0000000000..44d3631b17 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.cpp @@ -0,0 +1,548 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaRegressionTestRunner.h" + +#include "RiaApplication.h" +#include "RiaImageCompareReporter.h" +#include "RiaImageFileCompare.h" +#include "RiaLogging.h" +#include "RiaRegressionTest.h" +#include "RiaTextFileCompare.h" + +#include "RicfCommandFileExecutor.h" + +#include "Rim3dView.h" +#include "RimCase.h" +#include "RimMainPlotCollection.h" +#include "RimProject.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" +#include "RiuViewer.h" + +#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h" +#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace RegTestNames +{ +const QString generatedFilesFolderName = "RegTestGeneratedFiles"; +const QString baseFilesFolderName = "RegTestBaseFiles"; +const QString generatedFolderName = "RegTestGeneratedImages"; +const QString diffFolderName = "RegTestDiffImages"; +const QString baseFolderName = "RegTestBaseImages"; +const QString testProjectName = "RegressionTest"; +const QString testFolderFilter = "TestCase*"; +const QString imageCompareExeName = "compare"; +const QString reportFileName = "ResInsightRegressionTestReport.html"; +const QString commandFileFilter = "commandfile-*"; +}; // namespace RegTestNames + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void logInfoTextWithTimeInSeconds(const QTime& time, const QString& msg) +{ + double timeRunning = time.elapsed() / 1000.0; + + QString timeText = QString("(%1 s) ").arg(timeRunning, 0, 'f', 1); + + RiaLogging::info(timeText + msg); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaRegressionTestRunner::RiaRegressionTestRunner() + : m_runningRegressionTests(false) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaRegressionTestRunner* RiaRegressionTestRunner::instance() +{ + static RiaRegressionTestRunner* singleton = new RiaRegressionTestRunner; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::runRegressionTest(const QString& testRootPath, const QStringList& testFilter) +{ + m_runningRegressionTests = true; + + RiaRegressionTest regressionTestConfig; + regressionTestConfig.readSettingsFromApplicationStore(); + + QString currentApplicationPath = QDir::currentPath(); + if (!regressionTestConfig.folderContainingCompareTool().isEmpty()) + { + // Windows Only : The image compare tool requires current working directory to be at the folder + // containing the image compare tool + + QDir::setCurrent(regressionTestConfig.folderContainingCompareTool()); + } + + QString generatedFolderName = RegTestNames::generatedFolderName; + QString diffFolderName = RegTestNames::diffFolderName; + QString baseFolderName = RegTestNames::baseFolderName; + QString regTestProjectName = RegTestNames::testProjectName; + QString regTestFolderFilter = RegTestNames::testFolderFilter; + + QDir testDir(testRootPath); // If string is empty it will end up as cwd + testDir.setFilter(QDir::Dirs); + QStringList dirNameFilter; + dirNameFilter.append(regTestFolderFilter); + testDir.setNameFilters(dirNameFilter); + + QFileInfoList folderList = testDir.entryInfoList(); + + if (!testFilter.isEmpty()) + { + QFileInfoList subset; + + for (auto fi : folderList) + { + QString path = fi.path(); + QString baseName = fi.baseName(); + + for (auto s : testFilter) + { + QString trimmed = s.trimmed(); + if (baseName.contains(trimmed)) + { + subset.push_back(fi); + } + } + } + + folderList = subset; + } + + // delete diff and generated images + + for (int i = 0; i < folderList.size(); ++i) + { + QDir testCaseFolder(folderList[i].filePath()); + + QDir genDir(testCaseFolder.filePath(generatedFolderName)); + removeDirectoryWithContent(genDir); + + QDir diffDir(testCaseFolder.filePath(diffFolderName)); + removeDirectoryWithContent(diffDir); + + QDir baseDir(testCaseFolder.filePath(baseFolderName)); + } + + // Generate html report + + RiaImageCompareReporter imageCompareReporter; + + // Minor workaround + // Use registry to define if interactive diff images should be created + // Defined by user in RiaRegressionTest + { + QSettings settings; + + bool useInteractiveDiff = settings.value("showInteractiveDiffImages").toBool(); + if (useInteractiveDiff) + { + imageCompareReporter.showInteractiveOnly(); + } + } + + QTime timeStamp; + timeStamp.start(); + + logInfoTextWithTimeInSeconds(timeStamp, "Starting regression tests\n"); + + for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) + { + QDir testCaseFolder(folderList[dirIdx].filePath()); + + QString testFolderName = testCaseFolder.dirName(); + QString reportBaseFolderName = testCaseFolder.filePath(baseFolderName); + QString reportGeneratedFolderName = testCaseFolder.filePath(generatedFolderName); + QString reportDiffFolderName = testCaseFolder.filePath(diffFolderName); + + imageCompareReporter.addImageDirectoryComparisonSet(testFolderName.toStdString(), + reportBaseFolderName.toStdString(), + reportGeneratedFolderName.toStdString(), + reportDiffFolderName.toStdString()); + } + + QString htmlReportFileName = testDir.filePath(RegTestNames::reportFileName); + imageCompareReporter.generateHTMLReport(htmlReportFileName.toStdString()); + + // Open HTML report + QDesktopServices::openUrl(htmlReportFileName); + + for (int dirIdx = 0; dirIdx < folderList.size(); ++dirIdx) + { + QDir testCaseFolder(folderList[dirIdx].filePath()); + + // Detect any command files + QStringList filterList; + filterList << RegTestNames::commandFileFilter; + + QFileInfoList commandFileEntries = testCaseFolder.entryInfoList(filterList); + if (!commandFileEntries.empty()) + { + QString currentApplicationPath = QDir::current().absolutePath(); + + // Set current path to the folder containing the command file, as this is required when using file references + // in the command file + QDir::setCurrent(folderList[dirIdx].filePath()); + + for (const auto& fileInfo : commandFileEntries) + { + QString commandFile = fileInfo.absoluteFilePath(); + + QFile file(commandFile); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + RiaLogging::error("Failed to open command file : " + commandFile); + } + else + { + QTextStream in(&file); + RicfCommandFileExecutor::instance()->executeCommands(in); + } + } + + QDir::setCurrent(currentApplicationPath); + + // Create diff based on generated folders + { + QString html; + + RiaRegressionTest regressionTestConfig; + regressionTestConfig.readSettingsFromApplicationStore(); + + RiaTextFileCompare textFileCompare(regressionTestConfig.folderContainingDiffTool()); + + QString baseFilesFolderName = testCaseFolder.filePath(RegTestNames::baseFilesFolderName); + QString generatedFilesFolderName = testCaseFolder.filePath(RegTestNames::generatedFilesFolderName); + + QFileInfo fib(baseFilesFolderName); + QFileInfo fig(generatedFilesFolderName); + + if (fib.exists() && fig.exists()) + { + { + QString headerText = testCaseFolder.dirName(); + + html += "\n"; + html += " \n"; + html += " \n"; + html += " \n"; + + textFileCompare.runComparison(baseFilesFolderName, generatedFilesFolderName); + + QString diff = textFileCompare.diffOutput(); + if (diff.isEmpty()) + { + html += " \n"; + html += " \n"; + html += " \n"; + } + else + { + html += " \n"; + html += " \n"; + html += " \n"; + } + + // Table end + html += "
" + headerText + "
No text diff detected
Text diff detected - output from diff tool :
\n"; + + if (!diff.isEmpty()) + { + html += QString(" %1 ").arg(diff); + } + } + + QFile file(htmlReportFileName); + if (file.open(QIODevice::Append | QIODevice::Text)) + { + QTextStream stream(&file); + + stream << html; + } + } + } + } + + QString projectFileName; + + if (testCaseFolder.exists(regTestProjectName + ".rip")) + { + projectFileName = regTestProjectName + ".rip"; + } + + if (testCaseFolder.exists(regTestProjectName + ".rsp")) + { + projectFileName = regTestProjectName + ".rsp"; + } + + if (!projectFileName.isEmpty()) + { + logInfoTextWithTimeInSeconds(timeStamp, "Initializing test :" + testCaseFolder.absolutePath()); + + RiaApplication* app = RiaApplication::instance(); + + app->loadProject(testCaseFolder.filePath(projectFileName)); + + // Wait until all command objects have completed + app->waitUntilCommandObjectsHasBeenProcessed(); + + regressionTestConfigureProject(); + + resizeMaximizedPlotWindows(); + + QString fullPathGeneratedFolder = testCaseFolder.absoluteFilePath(generatedFolderName); + RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(fullPathGeneratedFolder); + + RicSnapshotAllPlotsToFileFeature::exportSnapshotOfAllPlotsIntoFolder(fullPathGeneratedFolder); + + QDir baseDir(testCaseFolder.filePath(baseFolderName)); + QDir genDir(testCaseFolder.filePath(generatedFolderName)); + QDir diffDir(testCaseFolder.filePath(diffFolderName)); + if (!diffDir.exists()) testCaseFolder.mkdir(diffFolderName); + baseDir.setFilter(QDir::Files); + QStringList baseImageFileNames = baseDir.entryList(); + + for (int fIdx = 0; fIdx < baseImageFileNames.size(); ++fIdx) + { + QString fileName = baseImageFileNames[fIdx]; + RiaImageFileCompare imgComparator(RegTestNames::imageCompareExeName); + bool ok = imgComparator.runComparison( + genDir.filePath(fileName), baseDir.filePath(fileName), diffDir.filePath(fileName)); + if (!ok) + { + qDebug() << "Error comparing :" << imgComparator.errorMessage() << "\n" << imgComparator.errorDetails(); + } + } + + app->closeProject(); + + logInfoTextWithTimeInSeconds(timeStamp, "Completed test :" + testCaseFolder.absolutePath()); + } + else + { + RiaLogging::error("Could not find a regression test file named : " + testCaseFolder.absolutePath() + "/" + + regTestProjectName + ".rsp"); + } + } + + RiaLogging::info("\n"); + logInfoTextWithTimeInSeconds(timeStamp, "Completed regression tests"); + + QDir::setCurrent(currentApplicationPath); + + m_runningRegressionTests = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::removeDirectoryWithContent(QDir& dirToDelete) +{ + QStringList files = dirToDelete.entryList(); + for (int fIdx = 0; fIdx < files.size(); ++fIdx) + { + dirToDelete.remove(files[fIdx]); + } + dirToDelete.rmdir("."); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::regressionTestConfigureProject() +{ + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + if (!mainWnd) return; + + RimProject* proj = RiaApplication::instance()->project(); + if (!proj) return; + + std::vector projectCases; + proj->allCases(projectCases); + + for (size_t i = 0; i < projectCases.size(); i++) + { + RimCase* cas = projectCases[i]; + if (!cas) continue; + + std::vector views = cas->views(); + + for (size_t j = 0; j < views.size(); j++) + { + Rim3dView* riv = views[j]; + + if (riv && riv->viewer()) + { + // Make sure all views are maximized for snapshotting + QMdiSubWindow* subWnd = mainWnd->findMdiSubWindow(riv->viewer()->layoutWidget()); + if (subWnd) + { + subWnd->showMaximized(); + } + + // This size is set to match the regression test reference images + riv->viewer()->setFixedSize(RiaRegressionTestRunner::regressionDefaultImageSize()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::resizeMaximizedPlotWindows() +{ + RimProject* proj = RiaApplication::instance()->project(); + if (!proj) return; + + RiuPlotMainWindow* plotMainWindow = RiaApplication::instance()->mainPlotWindow(); + if (!plotMainWindow) return; + + std::vector viewWindows; + + proj->mainPlotCollection()->descendantsIncludingThisOfType(viewWindows); + + for (auto viewWindow : viewWindows) + { + if (viewWindow->isMdiWindow()) + { + RimMdiWindowGeometry wndGeo = viewWindow->mdiWindowGeometry(); + if (wndGeo.isMaximized) + { + QWidget* viewWidget = viewWindow->viewWidget(); + + if (viewWidget) + { + QMdiSubWindow* mdiWindow = plotMainWindow->findMdiSubWindow(viewWidget); + if (mdiWindow) + { + mdiWindow->showNormal(); + + viewWidget->resize(RiaRegressionTestRunner::regressionDefaultImageSize()); + } + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiaRegressionTestRunner::regressionDefaultImageSize() +{ + return QSize(1000, 745); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::executeRegressionTests() +{ + RiaRegressionTest testConfig; + testConfig.readSettingsFromApplicationStore(); + + QString testPath = testConfig.regressionTestFolder(); + QStringList testFilter = testConfig.testFilter().split(";", QString::SkipEmptyParts); + + executeRegressionTests(testPath, testFilter); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::executeRegressionTests(const QString& regressionTestPath, const QStringList& testFilter) +{ + RiuMainWindow* mainWnd = RiuMainWindow::instance(); + if (mainWnd) + { + mainWnd->hideAllDockWindows(); + mainWnd->statusBar()->close(); + + mainWnd->setDefaultWindowSize(); + runRegressionTest(regressionTestPath, testFilter); + + mainWnd->loadWinGeoAndDockToolBarLayout(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaRegressionTestRunner::isRunningRegressionTests() const +{ + return m_runningRegressionTests; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaRegressionTestRunner::updateRegressionTest(const QString& testRootPath) +{ + // Find all sub folders + + QDir testDir(testRootPath); // If string is empty it will end up as cwd + testDir.setFilter(QDir::Dirs); + QStringList dirNameFilter; + dirNameFilter.append(RegTestNames::testFolderFilter); + testDir.setNameFilters(dirNameFilter); + + QFileInfoList folderList = testDir.entryInfoList(); + + for (int i = 0; i < folderList.size(); ++i) + { + QDir testCaseFolder(folderList[i].filePath()); + + QDir baseDir(testCaseFolder.filePath(RegTestNames::baseFolderName)); + removeDirectoryWithContent(baseDir); + testCaseFolder.mkdir(RegTestNames::baseFolderName); + + QDir genDir(testCaseFolder.filePath(RegTestNames::generatedFolderName)); + + QStringList imageFileNames = genDir.entryList(); + + for (int fIdx = 0; fIdx < imageFileNames.size(); ++fIdx) + { + QString fileName = imageFileNames[fIdx]; + QFile::copy(genDir.filePath(fileName), baseDir.filePath(fileName)); + } + } +} diff --git a/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h new file mode 100644 index 0000000000..40ec63cf9d --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaRegressionTestRunner.h @@ -0,0 +1,55 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +class QDir; + +//================================================================================================== +// +//================================================================================================== +class RiaRegressionTestRunner +{ +public: + static RiaRegressionTestRunner* instance(); + + void executeRegressionTests(const QString& regressionTestPath, const QStringList& testFilter); + void executeRegressionTests(); + + bool isRunningRegressionTests() const; + + static void updateRegressionTest(const QString& testRootPath); + +private: + RiaRegressionTestRunner(); + + void runRegressionTest(const QString& testRootPath, const QStringList& testFilter); + + static void removeDirectoryWithContent(QDir& dirToDelete); + static void regressionTestConfigureProject(); + static void resizeMaximizedPlotWindows(); + static QSize regressionDefaultImageSize(); + +private: + const QString m_rootPath; + const QStringList m_testFilter; + bool m_runningRegressionTests; +}; diff --git a/ApplicationCode/Application/Tools/RiaStdStringTools.cpp b/ApplicationCode/Application/Tools/RiaStdStringTools.cpp index a81e04068f..b144d8fc82 100644 --- a/ApplicationCode/Application/Tools/RiaStdStringTools.cpp +++ b/ApplicationCode/Application/Tools/RiaStdStringTools.cpp @@ -76,6 +76,24 @@ double RiaStdStringTools::toDouble(const std::string& s) return doubleValue; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaStdStringTools::containsAlphabetic(const std::string& s) +{ + return std::find_if(s.begin(), s.end(), [](char c) { return isalpha(c); }) != s.end(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaStdStringTools::startsWithAlphabetic(const std::string& s) +{ + if (s.empty()) return false; + + return isalpha(s[0]); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Application/Tools/RiaStdStringTools.h b/ApplicationCode/Application/Tools/RiaStdStringTools.h index 60788302f4..dd1f15e59d 100644 --- a/ApplicationCode/Application/Tools/RiaStdStringTools.h +++ b/ApplicationCode/Application/Tools/RiaStdStringTools.h @@ -35,6 +35,8 @@ class RiaStdStringTools static int toInt(const std::string& s); static double toDouble(const std::string& s); + static bool containsAlphabetic(const std::string& s); + static bool startsWithAlphabetic(const std::string& s); static std::vector splitStringBySpace(const std::string& s); diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp new file mode 100644 index 0000000000..a418d3187f --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.cpp @@ -0,0 +1,140 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaTextFileCompare.h" + +#include "cafUtils.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaTextFileCompare::RiaTextFileCompare(const QString& pathToDiffTool) + : m_pathToDiffTool(pathToDiffTool) +{ + reset(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaTextFileCompare::~RiaTextFileCompare() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaTextFileCompare::reset() +{ + m_lastError = IC_NO_ERROR; + m_errorMsg.clear(); + m_errorDetails.clear(); + m_diffOutput.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaTextFileCompare::runComparison(const QString& baseFolder, const QString& generatedFolder) +{ + reset(); + + QString fullFilePath = "diff"; + if (!m_pathToDiffTool.isEmpty()) + { + fullFilePath = m_pathToDiffTool + "/" + fullFilePath; + } + + // Command line arguments used when invoking 'diff' + // See https://docs.freebsd.org/info/diff/diff.info.diff_Options.html + QString args = "-r -u --strip-trailing-cr"; + + QString completeCommand = QString("\"%1\" %2 %3 %4").arg(fullFilePath).arg(baseFolder).arg(generatedFolder).arg(args); + + // Launch process and wait + QProcess proc; + proc.start(completeCommand); + proc.waitForFinished(30000); + + QProcess::ProcessError procError = proc.error(); + if (procError != QProcess::UnknownError) + { + m_lastError = SEVERE_ERROR; + m_errorMsg = "Error running 'diff' tool process"; + m_errorDetails = completeCommand; + return false; + } + + QByteArray stdErr = proc.readAllStandardError(); + int procExitCode = proc.exitCode(); + + if (procExitCode == 0) + { + return true; + } + else if (procExitCode == 1) + { + QByteArray stdOut = proc.readAllStandardOutput(); + m_diffOutput = stdOut; + + return false; + } + else + { + stdErr = stdErr.simplified(); + + // Report non-severe error + m_lastError = IC_ERROR; + m_errorMsg = "Error running 'diff' tool process"; + m_errorDetails = stdErr; + + return false; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaTextFileCompare::ErrorType RiaTextFileCompare::error() const +{ + return m_lastError; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaTextFileCompare::errorMessage() const +{ + return m_errorMsg; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaTextFileCompare::errorDetails() const +{ + return m_errorDetails; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaTextFileCompare::diffOutput() const +{ + return m_diffOutput; +} diff --git a/ApplicationCode/Application/Tools/RiaTextFileCompare.h b/ApplicationCode/Application/Tools/RiaTextFileCompare.h new file mode 100644 index 0000000000..ef05fe3f17 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextFileCompare.h @@ -0,0 +1,57 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +//================================================================================================== +// +// Execute text compare between to folders recursively using the external tool 'diff' +// +//================================================================================================== +class RiaTextFileCompare +{ +public: + enum ErrorType + { + IC_NO_ERROR, // No error occurred + IC_ERROR, // An error occurred + SEVERE_ERROR // Severe error occurred, it is likely that another call to compare() will also fail + }; + +public: + explicit RiaTextFileCompare(const QString& pathToDiffTool); + ~RiaTextFileCompare(); + + bool runComparison(const QString& baseFolder, const QString& generatedFolder); + ErrorType error() const; + QString errorMessage() const; + QString errorDetails() const; + QString diffOutput() const; + +private: + void reset(); + +private: + const QString m_pathToDiffTool; + ErrorType m_lastError; + QString m_errorMsg; + QString m_errorDetails; + QString m_diffOutput; +}; diff --git a/ApplicationCode/Application/Tools/RiaTextStringTools.cpp b/ApplicationCode/Application/Tools/RiaTextStringTools.cpp new file mode 100644 index 0000000000..2f3992b35d --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextStringTools.cpp @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiaTextStringTools.h" + +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaTextStringTools::compare(const QString& expected, const QString& actual) +{ + // Suggestions for improvement + // 1. report line number for first change + // 2. report line numbers for all changes + // 3. add support for compare with content of a text file on disk + + if (expected.compare(actual) == 0) + { + return true; + } + + return false; +} + diff --git a/ApplicationCode/Application/Tools/RiaTextStringTools.h b/ApplicationCode/Application/Tools/RiaTextStringTools.h new file mode 100644 index 0000000000..ee915087f2 --- /dev/null +++ b/ApplicationCode/Application/Tools/RiaTextStringTools.h @@ -0,0 +1,29 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QString; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +namespace RiaTextStringTools +{ +bool compare(const QString& expected, const QString& actual); +} diff --git a/ApplicationCode/CMakeLists.txt b/ApplicationCode/CMakeLists.txt index 3ad68a64f1..641863bcd1 100644 --- a/ApplicationCode/CMakeLists.txt +++ b/ApplicationCode/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (ApplicationCode) @@ -15,29 +15,10 @@ if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11)) endif() include_directories( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - ${cafProjectDataModel_SOURCE_DIR} - - ${cafCommand_SOURCE_DIR} - ${cafViewer_SOURCE_DIR} - ${cafAnimControl_SOURCE_DIR} - ${cafUserInterface_SOURCE_DIR} - ${cafPdmCvf_SOURCE_DIR} - ${CommonCode_SOURCE_DIR} - ${cafVizExtensions_SOURCE_DIR} - ${cafTensor_SOURCE_DIR} - - ${ResInsight_SOURCE_DIR}/ThirdParty - ${ResInsight_SOURCE_DIR}/ThirdParty/NRLib/nrlib/well - ${ResInsight_SOURCE_DIR}/ThirdParty/Qwt/src - - ${boost-Subset_SOURCE_DIR} - ${custom-opm-flowdiagnostics_SOURCE_DIR}/opm-flowdiagnostics/ - ${custom-opm-flowdiag-app_SOURCE_DIR}/opm-flowdiagnostics-applications/ - ${custom-opm-flowdiag-app_SOURCE_DIR}/opmCore + # required for compilation of gtest, should be refactored + ${ResInsight_SOURCE_DIR}/ThirdParty + ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/Adm ${CMAKE_CURRENT_SOURCE_DIR}/Application @@ -60,6 +41,7 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel + ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel/Completions ${CMAKE_CURRENT_SOURCE_DIR}/WellPathImportSsihub ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/OdbReader ${CMAKE_CURRENT_SOURCE_DIR}/GeoMech/GeoMechDataModel @@ -99,6 +81,7 @@ list( APPEND REFERENCED_CMAKE_FILES ReservoirDataModel/CMakeLists_files.cmake ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake + ReservoirDataModel/Completions/CMakeLists_files.cmake FileInterface/CMakeLists_files.cmake ProjectDataModel/CMakeLists_files.cmake @@ -111,18 +94,21 @@ list( APPEND REFERENCED_CMAKE_FILES ModelVisualization/CMakeLists_files.cmake ModelVisualization/GridBox/CMakeLists_files.cmake ModelVisualization/Intersections/CMakeLists_files.cmake + ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake UserInterface/CMakeLists_files.cmake - + Commands/CMakeLists_files.cmake Commands/ApplicationCommands/CMakeLists_files.cmake Commands/CompletionCommands/CMakeLists_files.cmake + Commands/CompletionExportCommands/CMakeLists_files.cmake Commands/CrossSectionCommands/CMakeLists_files.cmake Commands/EclipseCommands/CMakeLists_files.cmake Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake Commands/ExportCommands/CMakeLists_files.cmake Commands/FlowCommands/CMakeLists_files.cmake Commands/IntersectionBoxCommands/CMakeLists_files.cmake + Commands/IntersectionViewCommands/CMakeLists_files.cmake Commands/OctaveScriptCommands/CMakeLists_files.cmake Commands/OperationsUsingObjReferences/CMakeLists_files.cmake Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -133,18 +119,19 @@ list( APPEND REFERENCED_CMAKE_FILES CommandFileInterface/CMakeLists_files.cmake CommandFileInterface/Core/CMakeLists_files.cmake + Commands/FractureCommands/CMakeLists_files.cmake ) option (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS "Include ApplicationCode Unit Tests" OFF) if (RESINSIGHT_INCLUDE_APPLICATION_UNIT_TESTS) - add_definitions(-DUSE_UNIT_TESTS) + add_definitions(-DUSE_UNIT_TESTS) list( APPEND REFERENCED_CMAKE_FILES UnitTests/CMakeLists_files.cmake ) list( APPEND CPP_SOURCES - ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc + ${ResInsight_SOURCE_DIR}/ThirdParty/gtest/gtest-all.cc ) endif() @@ -166,18 +153,33 @@ list( APPEND CPP_SOURCES add_subdirectory(WellPathImportSsihub) add_subdirectory(ResultStatisticsCache) +set( RI_LIBRARIES + WellPathImportSsihub + ResultStatisticsCache +) + # # Odb api # set(RESINSIGHT_ODB_API_DIR "" CACHE PATH "Optional path to the ABAQUS ODB API from Simulia. Needed for support of geomechanical models") if(NOT ${RESINSIGHT_ODB_API_DIR} EQUAL "") - add_definitions(-DUSE_ODB_API) - add_subdirectory(GeoMech/OdbReader) - SET(RESINSIGHT_USE_ODB_API 1) - MESSAGE( STATUS "Using ODB-Api from : ${RESINSIGHT_ODB_API_DIR}" ) + add_definitions(-DUSE_ODB_API) + add_subdirectory(GeoMech/OdbReader) + SET(RESINSIGHT_USE_ODB_API 1) + MESSAGE( STATUS "Using ODB-Api from : ${RESINSIGHT_ODB_API_DIR}" ) endif() add_subdirectory(GeoMech/GeoMechDataModel) +list( APPEND RI_LIBRARIES + RigGeoMechDataModel +) + +if (RESINSIGHT_USE_ODB_API) + list( APPEND RI_LIBRARIES + RifOdbReader + ) +endif() + # # HDF5 @@ -190,7 +192,7 @@ if (RESINSIGHT_FOUND_HDF5) source_group( "FileInterface" FILES FileInterface/RifHdf5Reader.h FileInterface/RifHdf5Reader.cpp ) - add_definitions(-DUSE_HDF5) + add_definitions(-DUSE_HDF5) endif() if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_SOURING) @@ -198,11 +200,6 @@ if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_SOURING) endif() -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - add_definitions(-DUSE_PROTOTYPE_FEATURE_FRACTURES) -endif() - - ############################################################################# # Qt specifics: Moc, ui, resources ############################################################################# @@ -274,8 +271,9 @@ set( EXE_FILES ${QRC_FILES_CPP} ${WIN_RESOURCE} ${HEADER_FILES} - ${REFERENCED_CMAKE_FILES} + ${REFERENCED_CMAKE_FILES} ../ResInsightVersion.cmake + ../.clang-format ) add_executable( ResInsight ${EXE_FILES} ) @@ -307,10 +305,7 @@ endif () set( LINK_LIBRARIES ${OPM_LIBRARIES} - WellPathImportSsihub - - ResultStatisticsCache - RigGeoMechDataModel + ${RI_LIBRARIES} ${APP_FWK_LIBRARIES} ${VIZ_FWK_LIBRARIES} @@ -328,11 +323,6 @@ 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}) @@ -357,11 +347,14 @@ if(RESINSIGHT_ENABLE_COTIRE) ReservoirDataModel/RigTransmissibilityCondenser.cpp ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp ReservoirDataModel/RigCellGeometryTools.cpp + + # exclude test files due to cotire redefinition error report + UnitTests/RifCaseRealizationParametersReader-Test.cpp ) - foreach (fileToExclude ${COTIRE_EXCLUDE_FILES}) + foreach (fileToExclude ${COTIRE_EXCLUDE_FILES}) set_source_files_properties (${fileToExclude} PROPERTIES COTIRE_EXCLUDED TRUE) - endforeach(fileToExclude) + endforeach(fileToExclude) # disable precompiled headers set_target_properties(ResInsight PROPERTIES COTIRE_ENABLE_PRECOMPILED_HEADER FALSE) @@ -392,16 +385,16 @@ if (MSVC) # Odb Dlls if (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) - - foreach (aDLL ${RI_ODB_DLLS}) + # 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) + + foreach (aDLL ${RI_ODB_DLLS}) list(APPEND RI_DLL_FILENAMES ${RESINSIGHT_ODB_API_DIR}/lib/${aDLL}) endforeach() endif() @@ -420,13 +413,13 @@ endif(MSVC) foreach (FILE_TO_COPY ${RI_DLL_FILENAMES}) add_custom_command(TARGET ResInsight POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${FILE_TO_COPY}" - "${CMAKE_CURRENT_BINARY_DIR}/$") + "${FILE_TO_COPY}" + "${CMAKE_CURRENT_BINARY_DIR}/$") if (_unityTargetName) add_custom_command(TARGET ${_unityTargetName} POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different - "${FILE_TO_COPY}" - "${CMAKE_CURRENT_BINARY_DIR}/$") + "${FILE_TO_COPY}" + "${CMAKE_CURRENT_BINARY_DIR}/$") endif() endforeach() @@ -447,10 +440,10 @@ if (RESINSIGHT_PRIVATE_INSTALL) # tell binary to first attempt to load libraries from its own directory set(RESINSIGHT_INSTALL_RPATH "\$ORIGIN") - if (${RESINSIGHT_USE_ODB_API}) - # This is a "hack" to make ResInsight runtime find the ODB so files used when compiling. - # statoil wanted it this way, but we should probbly make a different installoptions that does things this way, - # and really do copy them when doing PRIVATE_INSTALL + if (${RESINSIGHT_USE_ODB_API}) + # This is a "hack" to make ResInsight runtime find the ODB so files used when compiling. + # statoil wanted it this way, but we should probbly make a different installoptions that does things this way, + # and really do copy them when doing PRIVATE_INSTALL set(RESINSIGHT_INSTALL_RPATH ${RESINSIGHT_INSTALL_RPATH} ${RESINSIGHT_ODB_API_DIR}/lib) endif() @@ -566,10 +559,6 @@ if(RESINSIGHT_FOUND_HDF5) set (RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_souring") endif() -if(RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - set (RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_fractures") -endif() - # Append el5 when compiled on RHEL5 and el6 if compiled on RHEL6 if (NOT "${RESINSIGHT_RHEL_SYSTEM_NAME}" STREQUAL "") set (RESINSIGHT_PACKAGE_NAME "${RESINSIGHT_PACKAGE_NAME}_${RESINSIGHT_RHEL_SYSTEM_NAME}") diff --git a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake index 17a4ec775b..e7230c0ae7 100644 --- a/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/CommandFileInterface/CMakeLists_files.cmake @@ -6,7 +6,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfComputeCaseGroupStatistics.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportMsw.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportMultiCaseSnapshots.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportProperty.h -${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellCompletions.h +${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellFractureCompletions.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.h ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.h ${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.h @@ -18,6 +18,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.h ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.h +${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.h +${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -27,7 +29,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfComputeCaseGroupStatistics.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportMsw.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportMultiCaseSnapshots.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportProperty.cpp -${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellCompletions.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfExportSimWellFractureCompletions.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportSnapshots.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfExportWellPathCompletions.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfLoadCase.cpp @@ -39,6 +41,8 @@ ${CMAKE_CURRENT_LIST_DIR}/RicfSetExportFolder.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetMainWindowSize.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetStartDir.cpp ${CMAKE_CURRENT_LIST_DIR}/RicfSetTimeStep.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfScaleFractureTemplate.cpp +${CMAKE_CURRENT_LIST_DIR}/RicfSetFractureContainment.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp b/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp index a3628113ba..c565e8d1e2 100644 --- a/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp +++ b/ApplicationCode/CommandFileInterface/Core/RicfMessages.cpp @@ -79,3 +79,12 @@ QChar RicfMessages::peekNextChar(QTextStream& inputStream) } return ch; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfMessages::skipLineWithLineNumberCount(QTextStream& inputStream) +{ + inputStream.readLine(); + m_currentLineNumber++; +} diff --git a/ApplicationCode/CommandFileInterface/Core/RicfMessages.h b/ApplicationCode/CommandFileInterface/Core/RicfMessages.h index 00bb4a3190..7085b0c348 100644 --- a/ApplicationCode/CommandFileInterface/Core/RicfMessages.h +++ b/ApplicationCode/CommandFileInterface/Core/RicfMessages.h @@ -37,6 +37,8 @@ class RicfMessages void addError(const QString& message); void skipWhiteSpaceWithLineNumberCount(QTextStream& inputStream); + void skipLineWithLineNumberCount(QTextStream& inputStream); + QChar readCharWithLineNumberCount(QTextStream& inputStream); QChar peekNextChar(QTextStream& inputStream); diff --git a/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp b/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp index 7a0cc81f14..d10f25dbd0 100644 --- a/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp +++ b/ApplicationCode/CommandFileInterface/Core/RifcCommandFileReader.cpp @@ -45,9 +45,15 @@ std::vector RicfCommandFileReader::readCommands(QTextStream& errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream); while ( !inputStream.atEnd() ) { - QChar currentChar; - currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream); - if ( currentChar.isSpace() ) + QChar currentChar = errorMessageContainer->readCharWithLineNumberCount(inputStream); + + if (currentChar == QChar('#')) + { + errorMessageContainer->skipLineWithLineNumberCount(inputStream); + errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream); + currentChar = QChar(); + } + else if ( currentChar.isSpace() ) { errorMessageContainer->skipWhiteSpaceWithLineNumberCount(inputStream); QChar isBracket('a'); @@ -65,7 +71,11 @@ std::vector RicfCommandFileReader::readCommands(QTextStream& { break; } - commandName += currentChar; + + if (!currentChar.isNull()) + { + commandName += currentChar; + } } } diff --git a/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp b/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp index 7754c52a89..115481cc78 100644 --- a/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp +++ b/ApplicationCode/CommandFileInterface/RicfComputeCaseGroupStatistics.cpp @@ -25,7 +25,7 @@ #include "RimEclipseStatisticsCase.h" #include "RimIdenticalGridCaseGroup.h" #include "RimCaseCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiaApplication.h" #include "RiaLogging.h" diff --git a/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp b/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp index 1c6489ebce..694d159006 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportMsw.cpp @@ -32,7 +32,7 @@ #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" -#include "CompletionCommands/RicExportFishbonesWellSegmentsFeature.h" +#include "CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h" CAF_PDM_SOURCE_INIT(RicfExportMsw, "exportMsw"); diff --git a/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp b/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp index 758f1a03b3..6b085884fa 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportProperty.cpp @@ -88,7 +88,7 @@ void RicfExportProperty::execute() // FIXME : Select correct view? RimEclipseView* view; - for (RimView* v : eclipseCase->views()) + for (Rim3dView* v : eclipseCase->views()) { view = dynamic_cast(v); if (view) break; @@ -104,9 +104,9 @@ void RicfExportProperty::execute() m_eclipseKeyword = m_propertyName; } - view->cellResult->setResultType(m_type()); - view->cellResult->setResultVariable(m_propertyName()); + view->cellResult()->setResultType(m_type()); + view->cellResult()->setResultVariable(m_propertyName()); view->loadDataAndUpdate(); - RifEclipseInputFileTools::writeBinaryResultToTextFile(filePath, eclipseCase->eclipseCaseData(), m_timeStepIndex, view->cellResult, m_eclipseKeyword, m_undefinedValue); + RifEclipseInputFileTools::writeBinaryResultToTextFile(filePath, eclipseCase->eclipseCaseData(), m_timeStepIndex, view->cellResult(), m_eclipseKeyword, m_undefinedValue); } diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp similarity index 53% rename from ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp rename to ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp index 362d9c6351..3310009243 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicfExportSimWellCompletions.h" +#include "RicfExportSimWellFractureCompletions.h" #include "RicfCommandFileExecutor.h" @@ -35,32 +35,32 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "CompletionCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" -CAF_PDM_SOURCE_INIT(RicfExportSimWellCompletions, "exportSimWellCompletions"); +CAF_PDM_SOURCE_INIT(RicfExportSimWellFractureCompletions, "exportSimWellFractureCompletions"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicfExportSimWellCompletions::RicfExportSimWellCompletions() +RicfExportSimWellFractureCompletions::RicfExportSimWellFractureCompletions() { - RICF_InitField(&m_caseId, "case", -1, "Case ID", "", "", ""); - RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); - RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", ""); - RICF_InitField(&m_wellSelection, "wellSelection", RicExportCompletionDataSettingsUi::WellSelectionType(), "Well Selection", "", "", ""); - RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); - RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", ""); + RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", ""); + RICF_InitField(&m_viewName, "viewName", QString(""), "View Name", "", "", ""); + RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); + RICF_InitField(&m_simWellNames, "simulationWellNames", std::vector(), "Simulation Well Names", "", "", ""); + RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); + RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", ""); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicfExportSimWellCompletions::execute() +void RicfExportSimWellFractureCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + exportSettings->timeStep = m_timeStep; - exportSettings->wellSelection = m_wellSelection; exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; @@ -89,43 +89,55 @@ void RicfExportSimWellCompletions::execute() } exportSettings->folder = exportFolder; - // FIXME : Select correct view? - RimEclipseView* view; - for (RimView* v : exportSettings->caseToApply->views()) + std::vector views; + for (Rim3dView* v : exportSettings->caseToApply->views()) { - view = dynamic_cast(v); - if (view) break; + RimEclipseView* eclipseView = dynamic_cast(v); + if (eclipseView && eclipseView->name() == m_viewName()) + { + views.push_back(eclipseView); + } } - if (!view) + if (views.empty()) { - RiaLogging::error(QString("exportSimWellCompletions: Could not find a view for case with ID %1").arg(m_caseId())); + RiaLogging::error(QString("exportSimWellCompletions: Could not find any views named \"%1\" in the case with ID %2").arg(m_viewName).arg(m_caseId())); return; } std::vector simWells; - if (m_wellPathNames().empty()) + if (m_simWellNames().empty()) { - std::copy(view->wellCollection->wells.begin(), - view->wellCollection->wells.end(), - std::back_inserter(simWells)); + for (RimEclipseView* view : views) + { + for (auto simWell : view->wellCollection()->wells) + { + if (simWell->showWell()) + { + simWells.push_back(simWell); + } + } + } } else { - for (const QString& wellPathName : m_wellPathNames()) + for (const QString& wellPathName : m_simWellNames()) { - RimSimWellInView* simWell = view->wellCollection->findWell(wellPathName); - if (simWell) - { - simWells.push_back(simWell); - } - else + for (RimEclipseView* view : views) { - RiaLogging::warning(QString("exportSimWellCompletions: Could not find well with name %1 on case with ID %2").arg(wellPathName).arg(m_caseId())); + RimSimWellInView* simWell = view->wellCollection()->findWell(wellPathName); + if (simWell) + { + simWells.push_back(simWell); + } + else + { + RiaLogging::warning(QString("exportSimWellCompletions: Could not find well with name %1 in view \"%2\" on case with ID %2").arg(wellPathName).arg(m_viewName).arg(m_caseId())); + } } } } std::vector wellPaths; - RicWellPathExportCompletionDataFeature::exportCompletions(wellPaths, simWells, *exportSettings); + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } diff --git a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h similarity index 83% rename from ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h rename to ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h index 3a28475a47..98bfb9fb0d 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportSimWellCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportSimWellFractureCompletions.h @@ -20,7 +20,7 @@ #include "RicfCommandObject.h" -#include "CompletionCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" #include "cafAppEnum.h" #include "cafPdmField.h" @@ -30,21 +30,21 @@ // // //================================================================================================== -class RicfExportSimWellCompletions : public RicfCommandObject +class RicfExportSimWellFractureCompletions : public RicfCommandObject { CAF_PDM_HEADER_INIT; public: - RicfExportSimWellCompletions(); + RicfExportSimWellFractureCompletions(); virtual void execute() override; private: - caf::PdmField m_caseId; + caf::PdmField m_viewName; caf::PdmField m_timeStep; - caf::PdmField< std::vector > m_wellPathNames; - caf::PdmField m_wellSelection; + caf::PdmField< std::vector > m_simWellNames; + caf::PdmField m_fileSplit; caf::PdmField m_compdatExport; }; diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp index ec8d8f5a94..a99148a1d7 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.cpp @@ -31,7 +31,7 @@ #include "RimWellPathCollection.h" #include "RimWellPath.h" -#include "CompletionCommands/RicWellPathExportCompletionDataFeature.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" CAF_PDM_SOURCE_INIT(RicfExportWellPathCompletions, "exportWellPathCompletions"); @@ -43,12 +43,17 @@ RicfExportWellPathCompletions::RicfExportWellPathCompletions() RICF_InitField(&m_caseId, "caseId", -1, "Case ID", "", "", ""); RICF_InitField(&m_timeStep, "timeStep", -1, "Time Step Index", "", "", ""); RICF_InitField(&m_wellPathNames, "wellPathNames", std::vector(), "Well Path Names", "", "", ""); - RICF_InitField(&m_wellSelection, "wellSelection", RicExportCompletionDataSettingsUi::WellSelectionType(), "Well Selection", "", "", ""); + RICF_InitField(&m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split", "", "", ""); RICF_InitField(&m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export", "", "", ""); - RICF_InitField(&m_includePerforations, "includePerforations", true, "Include Perforations", "", "", ""); - RICF_InitField(&m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", ""); - RICF_InitField(&m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, "Exclude Main Bore for Fishbones", "", "", ""); + RICF_InitField(&m_combinationMode, "combinationMode", RicExportCompletionDataSettingsUi::CombinationModeType(), "Combination Mode", "", "", ""); + + RICF_InitField(&m_useLateralNTG, "useNtgHorizontally", false, "Use NTG Horizontally", "", "", ""); + RICF_InitField(&m_includePerforations, "includePerforations", true, "Include Perforations", "", "", ""); + RICF_InitField(&m_includeFishbones, "includeFishbones", true, "Include Fishbones", "", "", ""); + RICF_InitField(&m_includeFractures, "includeFractures", true, "Include Fractures", "", "", ""); + + RICF_InitField(&m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, "Exclude Main Bore for Fishbones", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -57,14 +62,27 @@ RicfExportWellPathCompletions::RicfExportWellPathCompletions() void RicfExportWellPathCompletions::execute() { RimProject* project = RiaApplication::instance()->project(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(false); - exportSettings->timeStep = m_timeStep; - exportSettings->wellSelection = m_wellSelection; + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + + if (m_timeStep < 0) + { + exportSettings->timeStep = 0; + } + else + { + exportSettings->timeStep = m_timeStep; + } + exportSettings->fileSplit = m_fileSplit; exportSettings->compdatExport = m_compdatExport; + + exportSettings->useLateralNTG = m_useLateralNTG; exportSettings->includePerforations = m_includePerforations; exportSettings->includeFishbones = m_includeFishbones; exportSettings->excludeMainBoreForFishbones = m_excludeMainBoreForFishbones; + exportSettings->includeFractures = m_includeFractures; + + exportSettings->setCombinationMode(m_combinationMode()); { bool foundCase = false; @@ -94,9 +112,13 @@ void RicfExportWellPathCompletions::execute() std::vector wellPaths; if (m_wellPathNames().empty()) { - std::copy(RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths().begin(), - RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths().end(), - std::back_inserter(wellPaths)); + for (auto wellPath : RiaApplication::instance()->project()->activeOilField()->wellPathCollection->wellPaths()) + { + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } + } } else { @@ -116,5 +138,5 @@ void RicfExportWellPathCompletions::execute() std::vector simWells; - RicWellPathExportCompletionDataFeature::exportCompletions(wellPaths, simWells, *exportSettings); + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); } diff --git a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h index 3cbdfc9195..f7d5d57d3c 100644 --- a/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h +++ b/ApplicationCode/CommandFileInterface/RicfExportWellPathCompletions.h @@ -20,7 +20,7 @@ #include "RicfCommandObject.h" -#include "CompletionCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" #include "cafAppEnum.h" #include "cafPdmField.h" @@ -44,10 +44,14 @@ class RicfExportWellPathCompletions : public RicfCommandObject caf::PdmField m_caseId; caf::PdmField m_timeStep; caf::PdmField< std::vector > m_wellPathNames; - caf::PdmField m_wellSelection; + caf::PdmField m_fileSplit; caf::PdmField m_compdatExport; + caf::PdmField m_combinationMode; + + caf::PdmField m_useLateralNTG; caf::PdmField m_includePerforations; caf::PdmField m_includeFishbones; + caf::PdmField m_includeFractures; caf::PdmField m_excludeMainBoreForFishbones; }; diff --git a/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp b/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp index 09bb6ea5c4..fc80ad6a49 100644 --- a/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp +++ b/ApplicationCode/CommandFileInterface/RicfLoadCase.cpp @@ -22,6 +22,8 @@ #include "RiaLogging.h" +#include + CAF_PDM_SOURCE_INIT(RicfLoadCase, "loadCase"); //-------------------------------------------------------------------------------------------------- @@ -37,7 +39,7 @@ RicfLoadCase::RicfLoadCase() //-------------------------------------------------------------------------------------------------- void RicfLoadCase::execute() { - bool ok = RiaImportEclipseCaseTools::openEclipseCaseFromFile(m_path); + bool ok = RiaImportEclipseCaseTools::openEclipseCasesFromFile(QStringList({m_path()}), nullptr, true); if (!ok) { RiaLogging::error(QString("loadCase: Unable to load case from %1").arg(m_path())); diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp new file mode 100644 index 0000000000..ac79a28717 --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.cpp @@ -0,0 +1,73 @@ +#include "RicfSetExportFolder.h" +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicfScaleFractureTemplate.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimProject.h" +#include "RimFractureTemplate.h" +#include "RimFractureTemplateCollection.h" + +CAF_PDM_SOURCE_INIT(RicfScaleFractureTemplate, "scaleFractureTemplate"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicfScaleFractureTemplate::RicfScaleFractureTemplate() +{ + RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); + RICF_InitField(&m_widthScaleFactor, "width", 1.0, "WidthScaleFactor", "", "", ""); + RICF_InitField(&m_heightScaleFactor, "height", 1.0, "HeightScaleFactor", "", "", ""); + RICF_InitField(&m_dFactorScaleFactor, "dFactor", 1.0, "DFactorScaleFactor", "", "", ""); + RICF_InitField(&m_conductivityScaleFactor, "conductivity", 1.0, "ConductivityScaleFactor", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfScaleFractureTemplate::execute() +{ + if (m_id < 0) + { + RiaLogging::error("scaleFractureTemplate: Fracture template id not specified"); + return; + } + + RimProject* project = RiaApplication::instance()->project(); + + if (!project) + { + RiaLogging::error("scaleFractureTemplate: Project not found"); + return; + } + + RimFractureTemplateCollection* templColl = !project->allFractureTemplateCollections().empty() ? project->allFractureTemplateCollections()[0] : nullptr; + RimFractureTemplate* templ = templColl ? templColl->fractureTemplate(m_id) : nullptr; + + if (!templ) + { + RiaLogging::error(QString("scaleFractureTemplate: Fracture template not found. Id=%1").arg(m_id)); + return; + } + + templ->setScaleFactors(m_widthScaleFactor, m_heightScaleFactor, m_dFactorScaleFactor, m_conductivityScaleFactor); + templ->reload(); +} diff --git a/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h new file mode 100644 index 0000000000..bb78233215 --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfScaleFractureTemplate.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "RicfCommandFileExecutor.h" + +#include "cafPdmField.h" + +//================================================================================================== +// +// +// +//================================================================================================== +class RicfScaleFractureTemplate : public RicfCommandObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicfScaleFractureTemplate(); + + virtual void execute() override; + +private: + caf::PdmField m_id; + caf::PdmField m_widthScaleFactor; + caf::PdmField m_heightScaleFactor; + caf::PdmField m_dFactorScaleFactor; + caf::PdmField m_conductivityScaleFactor; +}; diff --git a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp new file mode 100644 index 0000000000..f5eaa7e81c --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.cpp @@ -0,0 +1,72 @@ +#include "RicfSetExportFolder.h" +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicfSetFractureContainment.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" + +#include "RimProject.h" +#include "RimFractureTemplate.h" +#include "RimFractureTemplateCollection.h" + +CAF_PDM_SOURCE_INIT(RicfSetFractureContainment, "setFractureContainment"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicfSetFractureContainment::RicfSetFractureContainment() +{ + RICF_InitField(&m_id, "id", -1, "Id", "", "", ""); + RICF_InitField(&m_topLayer, "topLayer", -1, "TopLayer", "", "", ""); + RICF_InitField(&m_baseLayer, "baseLayer", -1, "BaseLayer", "", "", ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicfSetFractureContainment::execute() +{ + if (m_id < 0 || m_topLayer < 0 || m_baseLayer < 0) + { + RiaLogging::error("setFractureContainment: Required argument missing"); + return; + } + + RimProject* project = RiaApplication::instance()->project(); + + if (!project) + { + RiaLogging::error("setFractureContainment: Project not found"); + return; + } + + RimFractureTemplateCollection* templColl = !project->allFractureTemplateCollections().empty() ? project->allFractureTemplateCollections()[0] : nullptr; + RimFractureTemplate* templ = templColl ? templColl->fractureTemplate(m_id) : nullptr; + + if (!templ) + { + RiaLogging::error(QString("setFractureContainment: Fracture template not found. Id=%1").arg(m_id)); + return; + } + + templ->setContainmentTopKLayer(m_topLayer); + templ->setContainmentBaseKLayer(m_baseLayer); + templ->reload(); +} diff --git a/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h new file mode 100644 index 0000000000..238fa6e37c --- /dev/null +++ b/ApplicationCode/CommandFileInterface/RicfSetFractureContainment.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicfCommandObject.h" + +#include "RicfCommandFileExecutor.h" + +#include "cafPdmField.h" + +//================================================================================================== +// +// +// +//================================================================================================== +class RicfSetFractureContainment : public RicfCommandObject +{ + CAF_PDM_HEADER_INIT; + +public: + RicfSetFractureContainment(); + + virtual void execute() override; + +private: + caf::PdmField m_id; + caf::PdmField m_topLayer; + caf::PdmField m_baseLayer; +}; diff --git a/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp b/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp index 12b5434bd5..07630d0cad 100644 --- a/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp +++ b/ApplicationCode/CommandFileInterface/RicfSetTimeStep.cpp @@ -22,7 +22,7 @@ #include "RimOilField.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseCase.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiaApplication.h" #include "RiaLogging.h" @@ -63,7 +63,7 @@ void RicfSetTimeStep::execute() } } - for (RimView* view : eclipseCase->views()) + for (Rim3dView* view : eclipseCase->views()) { view->setCurrentTimeStepAndUpdate(m_timeStepIndex); } diff --git a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake index 453af21c51..a104e060e6 100644 --- a/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ApplicationCommands/CMakeLists_files.cmake @@ -1,39 +1,38 @@ -# 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}RicLaunchUnitTestsFeature.h -${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.h -${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.h -${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.h -${CEE_CURRENT_LIST_DIR}RicOpenProjectFeature.h -${CEE_CURRENT_LIST_DIR}RicOpenLastUsedFileFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveProjectFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveProjectAsFeature.h -${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.h -${CEE_CURRENT_LIST_DIR}RicHelpFeatures.h -${CEE_CURRENT_LIST_DIR}RicEditPreferencesFeature.h -${CEE_CURRENT_LIST_DIR}RicShowPlotDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLaunchUnitTestsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotWindowFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowMainWindowFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicTileWindowsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicOpenProjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicOpenLastUsedFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectAsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExitApplicationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseProjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.h +${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRunCommandFileFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicLaunchUnitTestsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowPlotWindowFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowMainWindowFeature.cpp -${CEE_CURRENT_LIST_DIR}RicTileWindowsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicOpenProjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicOpenLastUsedFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveProjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveProjectAsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExitApplicationFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseProjectFeature.cpp -${CEE_CURRENT_LIST_DIR}RicHelpFeatures.cpp -${CEE_CURRENT_LIST_DIR}RicEditPreferencesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowPlotDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLaunchUnitTestsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotWindowFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowMainWindowFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicTileWindowsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicOpenProjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicOpenLastUsedFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveProjectAsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExitApplicationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseProjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHelpFeatures.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditPreferencesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowPlotDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLaunchRegressionTestsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRunCommandFileFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -49,4 +48,4 @@ ${QT_MOC_HEADERS} ) -source_group( "CommandFeature\\Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Application" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp index 28e668088b..08d5b8f875 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicEditPreferencesFeature.cpp @@ -47,7 +47,7 @@ void RicEditPreferencesFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QStringList tabNames = app->preferences()->tabNames(); - RiuPropertyViewTabWidget propertyDialog(NULL, app->preferences(), "Preferences", tabNames); + RiuPropertyViewTabWidget propertyDialog(nullptr, app->preferences(), "Preferences", tabNames); if (propertyDialog.exec() == QDialog::Accepted) { // Write preferences using QSettings and apply them to the application diff --git a/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp b/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp index 996a76054c..4dfa6058f8 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicHelpFeatures.cpp @@ -50,7 +50,7 @@ void RicHelpAboutFeature::onActionTriggered(bool isChecked) { this->disableModelChangeContribution(); - caf::AboutDialog dlg(NULL); + caf::AboutDialog dlg(nullptr); dlg.setApplicationName(RI_APPLICATION_NAME); dlg.setApplicationVersion(RiaApplication::getVersionStringApp(true)); @@ -71,9 +71,6 @@ void RicHelpAboutFeature::onActionTriggered(bool isChecked) #ifdef USE_HDF5 activeFeatures += " Souring"; #endif -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - activeFeatures += " Fractures"; -#endif if (!activeFeatures.isEmpty()) { diff --git a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp new file mode 100644 index 0000000000..3d405b3405 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.cpp @@ -0,0 +1,52 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicLaunchRegressionTestsFeature.h" + +#include "RiaRegressionTestRunner.h" + +#include "cafPdmSettings.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicLaunchRegressionTestsFeature, "RicLaunchRegressionTestsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicLaunchRegressionTestsFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestsFeature::onActionTriggered(bool isChecked) +{ + RiaRegressionTestRunner::instance()->executeRegressionTests(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicLaunchRegressionTestsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Launch Regression Tests"); +} diff --git a/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h new file mode 100644 index 0000000000..9948adbb55 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicLaunchRegressionTestsFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicLaunchRegressionTestsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp index 64f5da34df..6cd939a452 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicOpenProjectFeature.cpp @@ -46,7 +46,7 @@ void RicOpenProjectFeature::onActionTriggered(bool isChecked) if (!app->askUserToSaveModifiedProject()) return; QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QString fileName = QFileDialog::getOpenFileName(NULL, "Open ResInsight Project", defaultDir, "ResInsight project (*.rsp *.rip);;All files(*.*)"); + QString fileName = QFileDialog::getOpenFileName(nullptr, "Open ResInsight Project", defaultDir, "ResInsight project (*.rsp *.rip);;All files(*.*)"); if (fileName.isEmpty()) return; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp new file mode 100644 index 0000000000..a31c104c69 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.cpp @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicRunCommandFileFeature.h" + +#include "RiaApplication.h" +#include "RicfCommandFileExecutor.h" + +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicRunCommandFileFeature, "RicRunCommandFileFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRunCommandFileFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunCommandFileFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("COMMAND_FILE"); + + QString fileName = QFileDialog::getOpenFileName(nullptr, "Open ResInsight Command File", defaultDir, "ResInsight Command File (*.txt);;All files(*.*)"); + + if (!fileName.isEmpty()) + { + QFile file(fileName); + if (file.open(QIODevice::ReadOnly | QIODevice::Text)) + { + QTextStream in(&file); + + QString applicationPath = QDir::currentPath(); + + QFileInfo fi(fileName); + QDir::setCurrent(fi.absolutePath()); + + RicfCommandFileExecutor::instance()->executeCommands(in); + + QDir::setCurrent(applicationPath); + + app->setLastUsedDialogDirectory("COMMAND_FILE", QFileInfo(fileName).absolutePath()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunCommandFileFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Run Command File"); +} diff --git a/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h new file mode 100644 index 0000000000..be4ca628b1 --- /dev/null +++ b/ApplicationCode/Commands/ApplicationCommands/RicRunCommandFileFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicRunCommandFileFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp index d304712541..91f523f009 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicShowPlotDataFeature.cpp @@ -25,7 +25,7 @@ #include "RimSummaryPlot.h" #include "RimWellLogPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuTextDialog.h" #include "cafSelectionManagerTools.h" @@ -82,7 +82,7 @@ void RicShowPlotDataFeature::onActionTriggered(bool isChecked) return; } - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); CVF_ASSERT(plotwindow); for (RimSummaryPlot* summaryPlot : selectedSummaryPlots) @@ -117,7 +117,7 @@ void RicShowPlotDataFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- void RicShowPlotDataFeature::showTextWindow(const QString& title, const QString& text) { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); CVF_ASSERT(plotwindow); RiuTextDialog* textWiget = new RiuTextDialog(); diff --git a/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp b/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp index 2160d83258..ea57db2541 100644 --- a/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp +++ b/ApplicationCode/Commands/ApplicationCommands/RicTileWindowsFeature.cpp @@ -20,7 +20,7 @@ #include "RicTileWindowsFeature.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include #include @@ -74,7 +74,7 @@ CAF_CMD_SOURCE_INIT(RicTilePlotWindowsFeature, "RicTilePlotWindowsFeature"); //-------------------------------------------------------------------------------------------------- bool RicTilePlotWindowsFeature::isCommandEnabled() { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if (mainPlotWindow) { return mainPlotWindow->isAnyMdiSubWindowVisible(); @@ -88,7 +88,7 @@ bool RicTilePlotWindowsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicTilePlotWindowsFeature::onActionTriggered(bool isChecked) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if (mainPlotWindow) { mainPlotWindow->tileWindows(); diff --git a/ApplicationCode/Commands/CMakeLists_files.cmake b/ApplicationCode/Commands/CMakeLists_files.cmake index 9673c13eaa..ea1f4736cd 100644 --- a/ApplicationCode/Commands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CMakeLists_files.cmake @@ -1,160 +1,142 @@ -# 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}RicWellLogTools.h -${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicCloseObservedDataFeature.h -${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewInViewFeature.h -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicNewViewFeature.h -${CEE_CURRENT_LIST_DIR}RicPropertyFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterExecImpl.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertExec.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.h -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.h -${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.h -${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.h - -${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h - -${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.h -${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicImportObservedDataFeature.h -${CEE_CURRENT_LIST_DIR}RicImportObservedDataInMenuFeature.h -${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.h - -${CEE_CURRENT_LIST_DIR}RicSelectOrCreateViewFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogTools.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseInCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseObservedDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateSummaryCaseCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertExec.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewInViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicNewViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPropertyFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterExecImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertExec.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceIFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceJFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceKFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportFormationNamesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadFormationNamesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadWellPathFormationNamesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSliceRangeFilterFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.h + +${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.h + +${CMAKE_CURRENT_LIST_DIR}/RicTogglePerspectiveViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataInMenuFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.h + +${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.h # General delete of any object in a child array field -${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.h -${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.h -${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteSummaryCaseCollectionFeature.h - -${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubItemsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicCommandFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicReloadSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCommandFeature.h -${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.h -${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.h -) +${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.h -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.h - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.h - ${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.h - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.h - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.h - ${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.h - ) -endif() +${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.h +) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicWellLogTools.cpp -${CEE_CURRENT_LIST_DIR}RicCloseCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseSummaryCaseInCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseObservedDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCreateSummaryCaseCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterInsertExec.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewInViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicGeoMechPropertyFilterNewExec.cpp -${CEE_CURRENT_LIST_DIR}RicNewViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterExecImpl.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertExec.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterInsertFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewExec.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceIFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceJFeature.cpp -${CEE_CURRENT_LIST_DIR}RicRangeFilterNewSliceKFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportFormationNamesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadFormationNamesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadWellPathFormationNamesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSliceRangeFilterFeature.cpp -${CEE_CURRENT_LIST_DIR}RicHideIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicHideIntersectionBoxFeature.cpp - -${CEE_CURRENT_LIST_DIR}RicTogglePerspectiveViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportGeoMechCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportObservedDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportObservedDataInMenuFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportFeatureImpl.cpp - -${CEE_CURRENT_LIST_DIR}RicSelectOrCreateViewFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseSummaryCaseInCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseObservedDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateSummaryCaseCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterInsertExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewInViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterExecImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterInsertFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceIFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceJFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRangeFilterNewSliceKFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportFormationNamesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadFormationNamesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadWellPathFormationNamesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSliceRangeFilterFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicHideIntersectionBoxFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportElementPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSelectColorResult.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicTogglePerspectiveViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportObservedDataInMenuFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFeatureImpl.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicSelectOrCreateViewFeatureImpl.cpp # General delete of any object in a child array field -${CEE_CURRENT_LIST_DIR}RicDeleteItemExec.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteItemExecData.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteItemFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemExecData.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteItemFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteSubItemsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteSummaryCaseCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSubItemsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteSummaryCaseCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCloseSourSimDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCloseSourSimDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicReloadSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicFlyToObjectFeature.cpp - -${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.cpp -${CEE_CURRENT_LIST_DIR}RicShowGridStatisticsFeature.cpp -) +${CMAKE_CURRENT_LIST_DIR}/RicReloadCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicReloadSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFlyToObjectFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowGridStatisticsFeature.cpp -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewSimWellFractureAtPosFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewEllipseFractureTemplateFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewStimPlanFractureTemplateFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicNewWellPathFractureAtPosFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicConvertFractureTemplateUnitFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToMetricFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicConvertAllFractureTemplatesToFieldFeature.cpp - ${CEE_CURRENT_LIST_DIR}RicFractureNameGenerator.cpp - ) -endif() +${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEnsembleFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportSummaryGroupFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertGroupToEnsembleFeature.cpp +) list(APPEND CODE_HEADER_FILES @@ -166,7 +148,9 @@ ${SOURCE_GROUP_SOURCE_FILES} ) list(APPEND QT_MOC_HEADERS -${CEE_CURRENT_LIST_DIR}RicGridStatisticsDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicGridStatisticsDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicFileHierarchyDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCaseRestartDialog.h ) -source_group( "CommandFeature" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake index 88ee6e511f..85a8736fc5 100644 --- a/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CompletionCommands/CMakeLists_files.cmake @@ -1,54 +1,26 @@ -# 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}RicCaseAndFileExportSettingsUi.h -${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.h -${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.h -${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.h -${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.h -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.h -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.h -${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.h +${CMAKE_CURRENT_LIST_DIR}/RicEditPerforationCollectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesLateralsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsAtMeasuredDepthFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicCaseAndFileExportSettingsUi.cpp -${CEE_CURRENT_LIST_DIR}RicEditPerforationCollectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportCompletionDataSettingsUi.cpp -${CEE_CURRENT_LIST_DIR}RicExportFishbonesLateralsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportFishbonesWellSegmentsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsAtMeasuredDepthFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewFishbonesSubsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPerforationIntervalAtMeasuredDepthFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathExportCompletionDataFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathImportCompletionsFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathImportPerforationIntervalsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicFishbonesTransmissibilityCalculationFeatureImp.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditPerforationCollectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesLateralsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewFishbonesSubsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportCompletionsFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathImportPerforationIntervalsFeature.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RicExportFractureCompletionsImpl.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} @@ -58,4 +30,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Completion" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Completion" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h deleted file mode 100644 index c6566e3f9b..0000000000 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h +++ /dev/null @@ -1,78 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017 Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "cvfBase.h" -#include "cvfVector3.h" - -#include -#include -#include - -class RigCompletionData; -class RimWellPath; -class RicExportCompletionDataSettingsUi; - - -//================================================================================================== -/// -//================================================================================================== -struct WellBorePartForTransCalc { - WellBorePartForTransCalc(cvf::Vec3d lengthsInCell, - double wellRadius, - double skinFactor, - bool isMainBore, - QString metaData) - : lengthsInCell(lengthsInCell), - wellRadius(wellRadius), - skinFactor(skinFactor), - isMainBore(isMainBore), - metaData(metaData) - {} - - cvf::Vec3d lengthsInCell; - double wellRadius; - double skinFactor; - QString metaData; - bool isMainBore; -}; - -//================================================================================================== -/// -//================================================================================================== -class RicFishbonesTransmissibilityCalculationFeatureImp -{ -public: - static std::vector generateFishboneCompdatValuesUsingAdjustedCellVolume(const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); - - - -private: - static void findFishboneLateralsWellBoreParts(std::map >& wellBorePartsInCells, - const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); - static void findFishboneImportedLateralsWellBoreParts(std::map >& wellBorePartsInCells, - const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); - static void findMainWellBoreParts(std::map>& wellBorePartsInCells, - const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings); -}; - diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp index cd7fcc8dbe..218993877b 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsAtMeasuredDepthFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RimWellPath.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManager.h" @@ -58,7 +58,7 @@ void RicNewFishbonesSubsAtMeasuredDepthFeature::onActionTriggered(bool isChecked RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(wellPath->fishbonesCollection()); wellPath->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(obj); + Riu3DMainWindowTools::selectAsCurrentItem(obj); RimProject* proj; wellPath->firstAncestorOrThisOfTypeAsserted(proj); @@ -84,7 +84,7 @@ RiuWellPathSelectionItem* RicNewFishbonesSubsAtMeasuredDepthFeature::wellPathSel void RicNewFishbonesSubsAtMeasuredDepthFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setIcon(QIcon(":/FishBoneGroup16x16.png")); - actionToSetup->setText("New Fishbones Subs Definition"); + actionToSetup->setText("New Fishbones"); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp index 0032938466..ef7007617e 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewFishbonesSubsFeature.cpp @@ -28,7 +28,7 @@ #include "RimFishboneWellPathCollection.h" #include "RimFishbonesCollection.h" #include "RimFishbonesMultipleSubs.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -123,7 +123,7 @@ RimFishbonesCollection* RicNewFishbonesSubsFeature::selectedFishbonesCollection( void RicNewFishbonesSubsFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setIcon(QIcon(":/FishBoneGroup16x16.png")); - actionToSetup->setText("New Fishbones Subs Definition"); + actionToSetup->setText("New Fishbones"); } //-------------------------------------------------------------------------------------------------- @@ -150,7 +150,7 @@ void RicNewFishbonesSubsFeature::askUserToSetUsefulScaling(RimFishbonesCollectio fishboneCollection->firstAncestorOrThisOfTypeAsserted(wellPathColl); wellPathColl->wellPathRadiusScaleFactor = 0.01; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiaApplication* app = RiaApplication::instance(); diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp index 95a85c979f..eb61d16f4b 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalAtMeasuredDepthFeature.cpp @@ -27,7 +27,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManager.h" @@ -51,7 +51,7 @@ void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered(bool isC if (!RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(wellPath)) return; RimPerforationInterval* perforationInterval = new RimPerforationInterval; - int measuredDepth = wellPathSelItem->m_measuredDepth; + double measuredDepth = wellPathSelItem->m_measuredDepth; perforationInterval->setStartAndEndMD(measuredDepth, measuredDepth + 50); wellPath->perforationIntervalCollection()->appendPerforation(perforationInterval); @@ -62,7 +62,7 @@ void RicNewPerforationIntervalAtMeasuredDepthFeature::onActionTriggered(bool isC wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->scheduleRedrawAffectedViews(); - RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval); + Riu3DMainWindowTools::selectAsCurrentItem(perforationInterval); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp index cc55aaea97..6a66b7a196 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicNewPerforationIntervalFeature.cpp @@ -21,7 +21,7 @@ #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RimPerforationInterval.h" #include "RimPerforationCollection.h" @@ -66,7 +66,7 @@ void RicNewPerforationIntervalFeature::onActionTriggered(bool isChecked) wellPathCollection->uiCapability()->updateConnectedEditors(); wellPathCollection->scheduleRedrawAffectedViews(); - RiuMainWindow::instance()->selectAsCurrentItem(perforationInterval); + Riu3DMainWindowTools::selectAsCurrentItem(perforationInterval); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp deleted file mode 100644 index 5a79b164f3..0000000000 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ /dev/null @@ -1,1181 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017 Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RicWellPathExportCompletionDataFeature.h" - -#include "RiaApplication.h" -#include "RiaLogging.h" -#include "RiaPreferences.h" - -#include "RicExportCompletionDataSettingsUi.h" -#include "RicExportFeatureImpl.h" -#include "RicFishbonesTransmissibilityCalculationFeatureImp.h" -#include "RicExportFractureCompletionsImpl.h" - -#include "RigActiveCellInfo.h" -#include "RigCaseCellResultsData.h" -#include "RigEclipseCaseData.h" -#include "RigMainGrid.h" -#include "RigResultAccessorFactory.h" - -#include "RigTransmissibilityEquations.h" - -#include "RigWellLogExtractionTools.h" -#include "RigWellPath.h" -#include "RigWellPathIntersectionTools.h" - -#include "RimDialogData.h" -#include "RimSimWellInViewCollection.h" -#include "RimFishboneWellPath.h" -#include "RimFishboneWellPathCollection.h" -#include "RimFishbonesCollection.h" -#include "RimFishbonesMultipleSubs.h" -#include "RimPerforationCollection.h" -#include "RimPerforationInterval.h" -#include "RimProject.h" -#include "RimSimWellInView.h" -#include "RimWellPath.h" -#include "RimWellPathCollection.h" -#include "RimWellPathCompletions.h" - -#include "RiuMainWindow.h" - -#include "cafPdmUiPropertyViewDialog.h" -#include "cafProgressInfo.h" -#include "cafSelectionManager.h" - -#include "cvfPlane.h" - -#include -#include -#include -#include -#include "RigWellLogExtractor.h" - -CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature"); - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::isCommandEnabled() -{ - std::vector wellPaths = selectedWellPaths(); - std::vector simWells = selectedSimWells(); - - if (wellPaths.empty() && simWells.empty()) - { - return false; - } - - if (!wellPaths.empty() && !simWells.empty()) - { - return false; - } - - std::set eclipseCases; - for (auto simWell : simWells) - { - RimEclipseCase* eclipseCase; - simWell->firstAncestorOrThisOfType(eclipseCase); - eclipseCases.insert(eclipseCase); - } - if (eclipseCases.size() > 1) - { - return false; - } - - return true; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) -{ - std::vector wellPaths = selectedWellPaths(); - std::vector simWells = selectedSimWells(); - - CVF_ASSERT(wellPaths.size() > 0 || simWells.size() > 0); - - RiaApplication* app = RiaApplication::instance(); - RimProject* project = app->project(); - - QString projectFolder = app->currentProjectPath(); - QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); - - bool onlyWellPathCollectionSelected = noWellPathsSelectedDirectly(); - RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(onlyWellPathCollectionSelected); - - if (wellPaths.empty()) - { - exportSettings->showForSimWells(); - } - else - { - exportSettings->showForWellPath(); - } - - if (!exportSettings->caseToApply()) - { - std::vector cases; - app->project()->allCases(cases); - for (auto c : cases) - { - RimEclipseCase* eclipseCase = dynamic_cast(c); - if (eclipseCase != nullptr) - { - exportSettings->caseToApply = eclipseCase; - break; - } - } - } - - if(exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; - - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), exportSettings, "Export Completion Data", ""); - RicExportFeatureImpl::configureForExport(&propertyDialog); - - if (propertyDialog.exec() == QDialog::Accepted) - { - RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); - - exportCompletions(wellPaths, simWells, *exportSettings); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSetup) -{ - actionToSetup->setText("Export Completion Data"); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::selectedWellPaths() -{ - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType(&wellPaths); - - if (wellPaths.empty()) - { - std::vector wellPathCollections; - caf::SelectionManager::instance()->objectsByType(&wellPathCollections); - - for (auto wellPathCollection : wellPathCollections) - { - for (auto wellPath : wellPathCollection->wellPaths()) - { - wellPaths.push_back(wellPath); - } - } - } - - std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); - wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); - return wellPaths; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::noWellPathsSelectedDirectly() -{ - std::vector wellPaths; - caf::SelectionManager::instance()->objectsByType(&wellPaths); - - if (wellPaths.empty()) return true; - else return false; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::selectedSimWells() -{ - std::vector simWells; - caf::SelectionManager::instance()->objectsByType(&simWells); - - std::vector simWellCollections; - caf::SelectionManager::instance()->objectsByType(&simWellCollections); - - for (auto simWellCollection : simWellCollections) - { - for (auto simWell : simWellCollection->wells()) - { - simWells.push_back(simWell); - } - } - - std::set uniqueSimWells(simWells.begin(), simWells.end()); - simWells.assign(uniqueSimWells.begin(), uniqueSimWells.end()); - - return simWells; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::exportCompletions(const std::vector& wellPaths, - const std::vector& simWells, - const RicExportCompletionDataSettingsUi& exportSettings) -{ - if (exportSettings.caseToApply() == nullptr) - { - RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case"); - return; - } - - std::vector usedWellPaths; - if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::ALL_WELLS - || exportSettings.wellSelection == RicExportCompletionDataSettingsUi::SELECTED_WELLS) - { - usedWellPaths = wellPaths; - } - else if (exportSettings.wellSelection == RicExportCompletionDataSettingsUi::CHECKED_WELLS) - { - for (auto wellPath : wellPaths) - { - if (wellPath->showWellPath) - { - usedWellPaths.push_back(wellPath); - } - } - } - - { - bool unitSystemMismatch = false; - for (const RimWellPath* wellPath : usedWellPaths) - { - if (wellPath->unitSystem() != exportSettings.caseToApply->eclipseCaseData()->unitsType()) - { - unitSystemMismatch = true; - break; - } - } - - for (const RimSimWellInView* simWell : simWells) - { - RimEclipseCase* eclipseCase; - simWell->firstAncestorOrThisOfType(eclipseCase); - if (exportSettings.caseToApply->eclipseCaseData()->unitsType() != eclipseCase->eclipseCaseData()->unitsType()) - { - unitSystemMismatch = true; - break; - } - } - if (unitSystemMismatch) - { - RiaLogging::error("Well path unit systems must match unit system of chosen eclipse case."); - return; - } - } - - std::map > completionsPerEclipseCell; - - // FractureTransmissibilityExportInformation - std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; - - QString fractureTransmisibillityExportInformationPath = QDir(exportSettings.folder).filePath("FractureTransmissibilityExportInformation"); - QFile fractureTransmissibilityExportInformationFile(fractureTransmisibillityExportInformationPath); - - RiaPreferences* prefs = RiaApplication::instance()->preferences(); - if (prefs->includeFractureDebugInfoFile()) - { - if (!fractureTransmissibilityExportInformationFile.open(QIODevice::WriteOnly)) - { - RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(fractureTransmisibillityExportInformationPath)); - return; - } - - fractureTransmissibilityExportInformationStream = std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); - } - - size_t maxProgress = - usedWellPaths.size() * 3 + -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - simWells.size() + -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? usedWellPaths.size() : - exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE ? usedWellPaths.size() * 3 : 1) + - simWells.size(); - - caf::ProgressInfo progress(maxProgress, "Export Completions"); - - progress.setProgressDescription("Read Completion Data"); - for (auto wellPath : usedWellPaths) - { - // Generate completion data - - if (exportSettings.includePerforations) - { - std::vector perforationCompletionData = generatePerforationsCompdatValues(wellPath, exportSettings); - appendCompletionData(&completionsPerEclipseCell, perforationCompletionData); - } - progress.incrementProgress(); - - if (exportSettings.includeFishbones) - { - std::vector fishbonesCompletionData = RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume(wellPath, exportSettings); - appendCompletionData(&completionsPerEclipseCell, fishbonesCompletionData); - } - progress.incrementProgress(); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - if (exportSettings.includeFractures()) - { - std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); - appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); - } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - progress.incrementProgress(); - } - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - for (auto simWell : simWells) - { - std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell(exportSettings.caseToApply(), - simWell, - fractureTransmissibilityExportInformationStream.get()); - appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); - progress.incrementProgress(); - } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription(); - - progress.setProgressDescription("Write Export Files"); - if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE) - { - std::vector completions; - for (auto& data : completionsPerEclipseCell) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - - const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, completions, exportSettings.compdatExport); - progress.incrementProgress(); - } - else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL) - { - for (auto wellPath : usedWellPaths) - { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - std::vector wellCompletions; - for (auto completion : completions) - { - if (completion.wellName() == wellPath->completions()->wellNameForExport()) - { - wellCompletions.push_back(completion); - } - } - - if (wellCompletions.empty()) continue; - - QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); - progress.incrementProgress(); - } - } - else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) - { - for (auto wellPath : usedWellPaths) - { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, wellPath->completions()->wellNameForExport()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - { - std::vector fishbonesCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FISHBONES); - if (!fishbonesCompletions.empty()) - { - QString fileName = QString("%1_Fishbones_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, fishbonesCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - { - std::vector perforationCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::PERFORATION); - if (!perforationCompletions.empty()) - { - QString fileName = QString("%1_Perforations_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, perforationCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - { - std::vector fractureCompletions = getCompletionsForWellAndCompletionType(completions, wellPath->completions()->wellNameForExport(), RigCompletionData::FRACTURE); - if (!fractureCompletions.empty()) - { - QString fileName = QString("%1_Fractures_%2").arg(wellPath->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, fractureCompletions, exportSettings.compdatExport); - } - progress.incrementProgress(); - } - } - } - - // Export sim wells - if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || - exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) - { - for (auto simWell : simWells) - { - std::map > filteredWellCompletions = getCompletionsForWell(completionsPerEclipseCell, simWell->name()); - std::vector completions; - for (auto& data : filteredWellCompletions) - { - completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); - } - std::vector wellCompletions; - for (auto completion : completions) - { - if (completion.wellName() == simWell->name()) - { - wellCompletions.push_back(completion); - } - } - - if (wellCompletions.empty()) continue; - - QString fileName = exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL ? - QString("%1_unifiedCompletions_%2").arg(simWell->name()).arg(eclipseCaseName) : - QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); - printCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); - progress.incrementProgress(); - } - } - -} - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData RicWellPathExportCompletionDataFeature::combineEclipseCellCompletions(const std::vector& completions, - const RicExportCompletionDataSettingsUi& settings) -{ - CVF_ASSERT(!completions.empty()); - QString wellName = completions[0].wellName(); - IJKCellIndex cellIndexIJK = completions[0].cellIndex(); - RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid(); - size_t cellIndex = grid->cellIndexFromIJK(cellIndexIJK.i, cellIndexIJK.j, cellIndexIJK.k); - RigCompletionData::CompletionType completionType = completions[0].completionType(); - - //completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, - //if no main bore they are taken from first completion - double skinfactor = completions[0].skinFactor(); - double wellBoreDiameter = completions[0].diameter(); - CellDirection cellDirection = completions[0].direction(); - - for (const RigCompletionData& completion : completions) - { - if (completion.isMainBore()) - { - skinfactor = completion.skinFactor(); - wellBoreDiameter = completion.diameter(); - cellDirection = completion.direction(); - break; - } - } - - - RigCompletionData resultCompletion(wellName, cellIndexIJK); - - double totalTrans = 0.0; - - for (const RigCompletionData& completion : completions) - { - resultCompletion.m_metadata.reserve(resultCompletion.m_metadata.size() + completion.m_metadata.size()); - resultCompletion.m_metadata.insert(resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); - - if (completion.completionType() != completions[0].completionType()) - { - QString errorMessage = QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); - RiaLogging::error(errorMessage); - resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } - - if (completion.wellName() != completions[0].wellName()) - { - QString errorMessage = QString("Cannot combine completions from different wells in same cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); - RiaLogging::error(errorMessage); - resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } - - if (completion.transmissibility() == HUGE_VAL) - { - QString errorMessage = QString("Transmissibility calculation has failed for cell [%1, %2, %3]").arg(cellIndexIJK.i + 1).arg(cellIndexIJK.j + 1).arg(cellIndexIJK.k + 1); - RiaLogging::error(errorMessage); - resultCompletion.addMetadata("ERROR", errorMessage); - return resultCompletion; //Returning empty completion, should not be exported - } - - totalTrans = totalTrans + completion.transmissibility(); - } - - - if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) - { - resultCompletion.setCombinedValuesExplicitTrans(totalTrans, completionType); - } - else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) - { - //calculate trans for main bore - but as Eclipse will do it! - double transmissibilityEclipseCalculation = RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(settings.caseToApply(), - skinfactor, - wellBoreDiameter / 2, - cellIndex, - cellDirection); - - double wpimult = totalTrans / transmissibilityEclipseCalculation; - resultCompletion.setCombinedValuesImplicitTransWPImult(wpimult, cellDirection, skinfactor, wellBoreDiameter, completionType); - } - - return resultCompletion; -} - - - - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::printCompletionsToFile(const QString& folderName, - const QString& fileName, - std::vector& completions, - RicExportCompletionDataSettingsUi::CompdatExportType exportType) -{ - //TODO: Check that completion is ready for export - - QDir exportFolder = QDir(folderName); - - if (!exportFolder.exists()) - { - bool createdPath = exportFolder.mkpath(folderName); - if (createdPath) RiaLogging::info("Created export folder " + folderName); - else RiaLogging::error("Selected output folder does not exist, and could not be created."); - } - - QString filePath = exportFolder.filePath(fileName); - QFile exportFile(filePath); - if (!exportFile.open(QIODevice::WriteOnly)) - { - RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); - return; - } - - QTextStream stream(&exportFile); - RifEclipseDataTableFormatter formatter(stream); - - // Sort by well name / cell index - std::sort(completions.begin(), completions.end()); - - // Print completion data - generateCompdatTable(formatter, completions); - - - if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) - { - generateWpimultTable(formatter, completions); - } - - RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::getCompletionsForWellAndCompletionType(const std::vector& completions, - const QString& wellName, - RigCompletionData::CompletionType completionType) -{ - std::vector filteredCompletions; - for (auto completion : completions) - { - if (completion.wellName() == wellName && completion.completionType() == completionType) - { - filteredCompletions.push_back(completion); - } - } - return filteredCompletions; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::map > RicWellPathExportCompletionDataFeature::getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName) -{ - std::map > wellCompletions; - - for (const auto& it : cellToCompletionMap) - { - for (auto& completion : it.second) - { - if (completion.wellName() == wellName) - { - wellCompletions[it.first].push_back(completion); - } - } - } - - return wellCompletions; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData) -{ - std::vector header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K1"), - RifEclipseOutputTableColumn("K2"), - RifEclipseOutputTableColumn("Status"), - RifEclipseOutputTableColumn("SAT"), - RifEclipseOutputTableColumn("TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), - RifEclipseOutputTableColumn("DIAM"), - RifEclipseOutputTableColumn("KH"), - RifEclipseOutputTableColumn("S"), - RifEclipseOutputTableColumn("Df"), - RifEclipseOutputTableColumn("DIR"), - RifEclipseOutputTableColumn("r0") - }; - - formatter.keyword("COMPDAT"); - formatter.header(header); - - for (const RigCompletionData& data : completionData) - { - if (data.transmissibility() == 0.0 || data.wpimult()==0.0) - { - //Don't export completions without transmissibility - continue; - } - - for (const RigCompletionMetaData& metadata : data.metadata()) - { - formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); - } - formatter.add(data.wellName()); - formatter.addZeroBasedCellIndex(data.cellIndex().i).addZeroBasedCellIndex(data.cellIndex().j).addZeroBasedCellIndex(data.cellIndex().k).addZeroBasedCellIndex(data.cellIndex().k); - switch (data.connectionState()) - { - case OPEN: - formatter.add("OPEN"); - break; - case SHUT: - formatter.add("SHUT"); - break; - case AUTO: - formatter.add("AUTO"); - break; - } - if (RigCompletionData::isDefaultValue(data.saturation())) formatter.add("1*"); else formatter.add(data.saturation()); - if (RigCompletionData::isDefaultValue(data.transmissibility())) - { - formatter.add("1*"); // Transmissibility - - if (RigCompletionData::isDefaultValue(data.diameter())) formatter.add("1*"); else formatter.add(data.diameter()); - if (RigCompletionData::isDefaultValue(data.kh())) formatter.add("1*"); else formatter.add(data.kh()); - if (RigCompletionData::isDefaultValue(data.skinFactor())) formatter.add("1*"); else formatter.add(data.skinFactor()); - if (RigCompletionData::isDefaultValue(data.dFactor())) formatter.add("1*"); else formatter.add(data.dFactor()); - - switch (data.direction()) - { - case DIR_I: - formatter.add("'X'"); - break; - case DIR_J: - formatter.add("'Y'"); - break; - case DIR_K: - formatter.add("'Z'"); - break; - default: - formatter.add("'Z'"); - break; - } - } - else - { - formatter.add(data.transmissibility()); - } - - formatter.rowCompleted(); - } - formatter.tableCompleted(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData) -{ - std::vector header = { - RifEclipseOutputTableColumn("Well"), - RifEclipseOutputTableColumn("Mult"), - RifEclipseOutputTableColumn("I"), - RifEclipseOutputTableColumn("J"), - RifEclipseOutputTableColumn("K"), - }; - formatter.keyword("WPIMULT"); - formatter.header(header); - - for (auto& completion : completionData) - { - if (completion.wpimult() == 0.0 || completion.isDefaultValue(completion.wpimult())) - { - continue; - } - - formatter.add(completion.wellName()); - formatter.add(completion.wpimult()); - formatter.addZeroBasedCellIndex(completion.cellIndex().i).addZeroBasedCellIndex(completion.cellIndex().j).addZeroBasedCellIndex(completion.cellIndex().k); - formatter.rowCompleted(); - } - - formatter.tableCompleted(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) -{ - RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); - - std::vector completionData; - const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); - - - if (wellPath->perforationIntervalCollection()->isChecked()) - { - for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations()) - { - if (!interval->isChecked()) continue; - if (!interval->isActiveOnDate(settings.caseToApply->timeStepDates()[settings.timeStep])) continue; - - using namespace std; - pair, vector > perforationPointsAndMD = wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD()); - std::vector intersectedCells = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(settings.caseToApply->eclipseCaseData(), - perforationPointsAndMD.first, - perforationPointsAndMD.second); - for (auto& cell : intersectedCells) - { - bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); - if (!cellIsActive) continue; - - size_t i, j, k; - settings.caseToApply->eclipseCaseData()->mainGrid()->ijkFromCellIndex(cell.globCellIndex, &i, &j, &k); - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(i, j, k)); - CellDirection direction = calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); - - double transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, - wellPath, - cell.intersectionLengthsInCellCS, - interval->skinFactor(), - interval->diameter(unitSystem) / 2, - cell.globCellIndex, - settings.useLateralNTG); - - - - completion.setTransAndWPImultBackgroundDataFromPerforation(transmissibility, - interval->skinFactor(), - interval->diameter(unitSystem), - direction); - completion.addMetadata("Perforation", QString("StartMD: %1 - EndMD: %2").arg(interval->startMD()).arg(interval->endMD()) + QString(" : ") + QString::number(transmissibility)); - completionData.push_back(completion); - } - } - } - - return completionData; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::set RicWellPathExportCompletionDataFeature::findIntersectedCells(const RigEclipseCaseData* caseData, const std::vector& coords) -{ - std::set cells; - - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(caseData->mainGrid(), coords); - for (auto intersection : intersections) - { - cells.insert(intersection.m_hexIndex); - } - - return cells; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::markWellPathCells(const std::vector& wellPathCells, std::vector* locations) -{ - std::set wellPathCellSet(wellPathCells.begin(), wellPathCells.end()); - for (WellSegmentLocation& location : *locations) - { - for (WellSegmentLateral& lateral : location.laterals) - { - for (WellSegmentLateralIntersection& intersection : lateral.intersections) - { - if (wellPathCellSet.find(intersection.cellIndex) != wellPathCellSet.end()) - { - intersection.mainBoreCell = true; - } - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second) -{ - return first.measuredDepth < second.measuredDepth; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicWellPathExportCompletionDataFeature::isPointBetween(const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint, const cvf::Vec3d& pointToCheck) -{ - cvf::Plane plane; - plane.setFromPointAndNormal(pointToCheck, endPoint - startPoint); - return plane.side(startPoint) != plane.side(endPoint); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath) -{ - std::vector fishbonesSubs; - - if (wellPath->fishbonesCollection()->isChecked()) - { - for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs()) - { - if (subs->isActive()) - { - fishbonesSubs.push_back(subs); - } - } - } - - return findWellSegmentLocations(caseToApply, wellPath, fishbonesSubs); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RicWellPathExportCompletionDataFeature::findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs) -{ - std::vector wellSegmentLocations; - for (RimFishbonesMultipleSubs* subs : fishbonesSubs) - { - for (auto& sub : subs->installedLateralIndices()) - { - double measuredDepth = subs->measuredDepth(sub.subIndex); - cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth); - WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex); - for (size_t lateralIndex : sub.lateralIndices) - { - location.laterals.push_back(WellSegmentLateral(lateralIndex)); - } - wellSegmentLocations.push_back(location); - } - } - std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering); - - assignLateralIntersectionsAndBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations); - - return wellSegmentLocations; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::assignLateralIntersections(const RimEclipseCase* caseToApply, - WellSegmentLocation* location, - int* branchNum, - int* segmentNum) -{ - for (WellSegmentLateral& lateral : location->laterals) - { - ++(*branchNum); - lateral.branchNumber = (*branchNum); - - std::vector > lateralCoordMDPairs = location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); - - if ( !lateralCoordMDPairs.size() ) - { - continue; - } - - std::vector lateralCoords; - std::vector lateralMDs; - - lateralCoords.reserve(lateralCoordMDPairs.size()); - lateralMDs.reserve(lateralCoordMDPairs.size()); - - for (auto& coordMD : lateralCoordMDPairs) - { - lateralCoords.push_back(coordMD.first); - lateralMDs.push_back(coordMD.second); - } - - std::vector intersections = RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath(caseToApply->eclipseCaseData(), - lateralCoords, - lateralMDs); - double previousExitMD = lateralMDs.front(); - double previousExitTVD = lateralCoords.front().z(); - - int attachedSegmentNumber = location->icdSegmentNumber; - for (const auto& cellIntInfo: intersections) - { - ++(*segmentNum); - WellSegmentLateralIntersection lateralIntersection((*segmentNum), - attachedSegmentNumber, - cellIntInfo.globCellIndex, - cellIntInfo.endMD - previousExitMD, - cellIntInfo.endPoint.z() - previousExitTVD, - cellIntInfo.intersectionLengthsInCellCS); - - lateral.intersections.push_back(lateralIntersection); - - attachedSegmentNumber = (*segmentNum); - previousExitMD = cellIntInfo.endMD; - previousExitTVD = cellIntInfo.endPoint.z(); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) -{ - int segmentNumber = 1; - int branchNumber = 1; - - // First loop over the locations so that each segment on the main stem is an incremental number - for (WellSegmentLocation& location : *locations) - { - location.segmentNumber = ++segmentNumber; - location.icdBranchNumber = ++branchNumber; - location.icdSegmentNumber = ++segmentNumber; - } - - // Then assign branch and segment numbers to each lateral parts - for (WellSegmentLocation& location : *locations) - { - assignLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::appendCompletionData(std::map >* completionData, const std::vector& data) -{ - for (auto& completion : data) - { - auto it = completionData->find(completion.cellIndex()); - if (it != completionData->end()) - { - it->second.push_back(completion); - } - else - { - completionData->insert(std::pair >(completion.cellIndex(), std::vector {completion})); - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -CellDirection RicWellPathExportCompletionDataFeature::calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t cellIndex, const cvf::Vec3d& lengthsInCell) -{ - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - - double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(cellIndex)); - double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(cellIndex)); - double zLengthFraction = fabs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(cellIndex)); - - if (xLengthFraction > yLengthFraction && xLengthFraction > zLengthFraction) - { - return CellDirection::DIR_I; - } - else if (yLengthFraction > xLengthFraction && yLengthFraction > zLengthFraction) - { - return CellDirection::DIR_J; - } - else - { - return CellDirection::DIR_K; - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeature::calculateTransmissibility(RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - const cvf::Vec3d& internalCellLengths, - double skinFactor, - double wellRadius, - size_t cellIndex, - bool useLateralNTG, - size_t volumeScaleConstant, - CellDirection directionForVolumeScaling) -{ - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); - cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); - cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); - cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); - - double ntg = 1.0; - size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); - if (ntgResIdx != cvf::UNDEFINED_SIZE_T) - { - cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); - ntg = ntgAccessObject->cellScalarGlobIdx(cellIndex); - } - double latNtg = useLateralNTG ? ntg : 1.0; - - double dx = dxAccessObject->cellScalarGlobIdx(cellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(cellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(cellIndex); - double permx = permxAccessObject->cellScalarGlobIdx(cellIndex); - double permy = permyAccessObject->cellScalarGlobIdx(cellIndex); - double permz = permzAccessObject->cellScalarGlobIdx(cellIndex); - - double darcy = RiaEclipseUnitTools::darcysConstant(wellPath->unitSystem()); - - if (volumeScaleConstant != 1) - { - if (directionForVolumeScaling == CellDirection::DIR_I) dx = dx / volumeScaleConstant; - if (directionForVolumeScaling == CellDirection::DIR_J) dy = dy / volumeScaleConstant; - if (directionForVolumeScaling == CellDirection::DIR_K) dz = dz / volumeScaleConstant; - } - - double transx = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.x() * latNtg, permy, permz, dy, dz, wellRadius, skinFactor, darcy); - double transy = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.y() * latNtg, permx, permz, dx, dz, wellRadius, skinFactor, darcy); - double transz = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(internalCellLengths.z() * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); - - return RigTransmissibilityEquations::totalConnectionFactor(transx, transy, transz); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RicWellPathExportCompletionDataFeature::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, - double skinFactor, - double wellRadius, - size_t cellIndex, - CellDirection direction) -{ - RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); - cvf::ref dxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); - cvf::ref dyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); - cvf::ref dzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); - - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); - cvf::ref permxAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); - cvf::ref permyAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); - eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); - cvf::ref permzAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); - - double ntg = 1.0; - size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); - if (ntgResIdx != cvf::UNDEFINED_SIZE_T) - { - cvf::ref ntgAccessObject = RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); - ntg = ntgAccessObject->cellScalarGlobIdx(cellIndex); - } - - double dx = dxAccessObject->cellScalarGlobIdx(cellIndex); - double dy = dyAccessObject->cellScalarGlobIdx(cellIndex); - double dz = dzAccessObject->cellScalarGlobIdx(cellIndex); - double permx = permxAccessObject->cellScalarGlobIdx(cellIndex); - double permy = permyAccessObject->cellScalarGlobIdx(cellIndex); - double permz = permzAccessObject->cellScalarGlobIdx(cellIndex); - - RiaEclipseUnitTools::UnitSystem units = eclipseCaseData->unitsType(); - double darcy = RiaEclipseUnitTools::darcysConstant(units); - - double trans = cvf::UNDEFINED_DOUBLE; - if (direction == CellDirection::DIR_I) - { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dx, permy, permz, dy, dz, wellRadius, skinFactor, darcy); - } - else if (direction == CellDirection::DIR_J) - { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dy, permx, permz, dx, dz, wellRadius, skinFactor, darcy); - } - else if (direction == CellDirection::DIR_K) - { - trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent(dz * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); - } - - return trans; -} diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h deleted file mode 100644 index 6979e31443..0000000000 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ /dev/null @@ -1,187 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017 Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - -#include "RifEclipseDataTableFormatter.h" - -#include "RigWellLogExtractionTools.h" -#include "RigWellPathIntersectionTools.h" -#include "RigCompletionData.h" - -#include "RicExportCompletionDataSettingsUi.h" - -#include "cafCmdFeature.h" - -#include "cvfBoundingBox.h" - - -class RigCell; -class RigEclipseCaseData; -class RigMainGrid; -class RimEclipseCase; -class RimFishbonesMultipleSubs; -class RimSimWellInView; -class RimWellPath; - -//================================================================================================== -/// -//================================================================================================== -struct WellSegmentLateralIntersection { - WellSegmentLateralIntersection(int segmentNumber, - int attachedSegmentNumber, - size_t cellIndex, - double length, - double depth, - const cvf::Vec3d& lengthsInCell) - : segmentNumber(segmentNumber), - attachedSegmentNumber(attachedSegmentNumber), - cellIndex(cellIndex), - mdFromPreviousIntersection(length), - tvdChangeFromPreviousIntersection(depth), - lengthsInCell(lengthsInCell), - mainBoreCell(false) - {} - - int segmentNumber; - int attachedSegmentNumber; - size_t cellIndex; - bool mainBoreCell; - double mdFromPreviousIntersection; - double tvdChangeFromPreviousIntersection; - cvf::Vec3d lengthsInCell; -}; - -//================================================================================================== -/// -//================================================================================================== -struct WellSegmentLateral { - WellSegmentLateral(size_t lateralIndex) - : lateralIndex(lateralIndex), - branchNumber(0) - {} - - size_t lateralIndex; - int branchNumber; - std::vector intersections; -}; - -//================================================================================================== -/// -//================================================================================================== -struct WellSegmentLocation { - WellSegmentLocation(const RimFishbonesMultipleSubs* subs, double measuredDepth, double trueVerticalDepth, size_t subIndex, int segmentNumber = -1) - : fishbonesSubs(subs), - measuredDepth(measuredDepth), - trueVerticalDepth(trueVerticalDepth), - subIndex(subIndex), - segmentNumber(segmentNumber), - icdBranchNumber(-1), - icdSegmentNumber(-1) - { - } - - const RimFishbonesMultipleSubs* fishbonesSubs; - double measuredDepth; - double trueVerticalDepth; - size_t subIndex; - int segmentNumber; - int icdBranchNumber; - int icdSegmentNumber; - std::vector laterals; -}; - -//================================================================================================== -/// -//================================================================================================== -struct EclipseCellIndexRange { - size_t i; - size_t j; - size_t k1; - size_t k2; -}; - -//================================================================================================== -/// -//================================================================================================== -typedef std::tuple EclipseCellIndex; - -//================================================================================================== -/// -//================================================================================================== -class RicWellPathExportCompletionDataFeature : public caf::CmdFeature -{ - CAF_CMD_HEADER_INIT; -protected: - - // Overrides - virtual bool isCommandEnabled() override; - virtual void onActionTriggered(bool isChecked) override; - virtual void setupActionLook(QAction* actionToSetup) override; - - std::vector selectedWellPaths(); - std::vector selectedSimWells(); - - bool noWellPathsSelectedDirectly(); - -public: - static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath); - static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, const RimWellPath* wellPath, const std::vector& fishbonesSubs); - - //functions also used by RicFishbonesTransmissibilityCalculationFeatureImp - static std::set findIntersectedCells(const RigEclipseCaseData* grid, const std::vector& coords); - static void markWellPathCells(const std::vector& wellPathCells, std::vector* locations); - static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, size_t cellIndex, const cvf::Vec3d& lengthsInCell); - - static double calculateTransmissibility(RimEclipseCase* eclipseCase, - const RimWellPath* wellPath, - const cvf::Vec3d& internalCellLengths, - double skinFactor, - double wellRadius, - size_t cellIndex, - bool useLateralNTG, - size_t volumeScaleConstant = 1, - CellDirection directionForVolumeScaling = CellDirection::DIR_I); - static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, - double skinFactor, - double wellRadius, - size_t cellIndex, - CellDirection direction); - static void exportCompletions(const std::vector& wellPaths, const std::vector& simWells, const RicExportCompletionDataSettingsUi& exportSettings); - -private: - static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, - const RicExportCompletionDataSettingsUi& settings); - static void printCompletionsToFile(const QString& exportFolder, const QString& fileName, std::vector& completions, RicExportCompletionDataSettingsUi::CompdatExportType exportType); - static std::vector getCompletionsForWellAndCompletionType(const std::vector& completions, const QString& wellName, RigCompletionData::CompletionType completionType); - static std::map > getCompletionsForWell(const std::map>& cellToCompletionMap, const QString& wellName); - - static void generateCompdatTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); - static void generateWpimultTable(RifEclipseDataTableFormatter& formatter, const std::vector& completionData); - - static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings); - - static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second); - static bool isPointBetween(const cvf::Vec3d& pointA, const cvf::Vec3d& pointB, const cvf::Vec3d& needle); - static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); - static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); - - static void appendCompletionData(std::map >* completionData, const std::vector& data); - -}; - diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp index 4e4d06b8e0..2fbc001077 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportCompletionsFileFeature.cpp @@ -27,7 +27,7 @@ #include "RimWellPathCompletions.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -60,7 +60,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Completions", defaultDir, "Well Path Completions (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Fishbone Laterals", defaultDir, "Well Path Laterals (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; @@ -87,7 +87,7 @@ void RicWellPathImportCompletionsFileFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicWellPathImportCompletionsFileFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Import Completions from File"); + actionToSetup->setText("Import Fishbone Laterals"); actionToSetup->setIcon(QIcon(":/FishBoneGroupFromFile16x16.png")); } diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp index 79d225d22f..8b51f0c6df 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathImportPerforationIntervalsFeature.cpp @@ -29,7 +29,7 @@ #include "RifPerforationIntervalReader.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -62,7 +62,7 @@ void RicWellPathImportPerforationIntervalsFeature::onActionTriggered(bool isChec // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Path Perforation Intervals", defaultDir, "Well Path Perforation Intervals (*.ev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Path Perforation Intervals", defaultDir, "Well Path Perforation Intervals (*.ev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; @@ -109,7 +109,7 @@ void RicWellPathImportPerforationIntervalsFeature::onActionTriggered(bool isChec if (lastPerforationInterval) { - RiuMainWindow::instance()->selectAsCurrentItem(lastPerforationInterval); + Riu3DMainWindowTools::selectAsCurrentItem(lastPerforationInterval); } } diff --git a/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..e94144b290 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/CMakeLists_files.cmake @@ -0,0 +1,35 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleSimWellsFeature.h +) + + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionDataSettingsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathExportCompletionDataFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFishbonesWellSegmentsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCaseAndFileExportSettingsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFractureCompletionsImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleWellPathsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCompletionsForVisibleSimWellsFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\CompletionExport" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.cpp diff --git a/ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicCaseAndFileExportSettingsUi.h rename to ApplicationCode/Commands/CompletionExportCommands/RicCaseAndFileExportSettingsUi.h diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp similarity index 61% rename from ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp index 9100f61aa1..f0f59d47b8 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.cpp @@ -26,16 +26,7 @@ namespace caf addItem(RicExportCompletionDataSettingsUi::UNIFIED_FILE, "UNIFIED_FILE", "Unified File"); addItem(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL, "SPLIT_ON_WELL", "Split on Well"); addItem(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE, "SPLIT_ON_WELL_AND_COMPLETION_TYPE", "Split on Well and Completion Type"); - setDefault(RicExportCompletionDataSettingsUi::UNIFIED_FILE); - } - - template<> - void RicExportCompletionDataSettingsUi::WellSelectionType::setUp() - { - addItem(RicExportCompletionDataSettingsUi::ALL_WELLS, "ALL_WELLS", "All Wells"); - addItem(RicExportCompletionDataSettingsUi::CHECKED_WELLS, "CHECKED_WELLS", "Checked Wells"); - addItem(RicExportCompletionDataSettingsUi::SELECTED_WELLS, "SELECTED_WELLS", "Selected Wells"); - setDefault(RicExportCompletionDataSettingsUi::ALL_WELLS); + setDefault(RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE); } template<> @@ -45,6 +36,14 @@ namespace caf addItem(RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, "WPIMULT_AND_DEFAULT_CONNECTION_FACTORS", "Default Connection Factors and WPIMULT (Fractures Not Supported)"); setDefault(RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES); } + + template<> + void RicExportCompletionDataSettingsUi::CombinationModeType::setUp() + { + addItem(RicExportCompletionDataSettingsUi::INDIVIDUALLY, "INDIVIDUALLY", "Individually"); + addItem(RicExportCompletionDataSettingsUi::COMBINED, "COMBINED", "Combined"); + setDefault(RicExportCompletionDataSettingsUi::INDIVIDUALLY); + } } @@ -54,59 +53,86 @@ CAF_PDM_SOURCE_INIT(RicExportCompletionDataSettingsUi, "RicExportCompletionDataS /// //-------------------------------------------------------------------------------------------------- RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi() -{ -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RicExportCompletionDataSettingsUi::RicExportCompletionDataSettingsUi(bool onlyWellPathCollectionSelected) { CAF_PDM_InitObject("RimExportCompletionDataSettings", "", "", ""); CAF_PDM_InitFieldNoDefault(&fileSplit, "FileSplit", "File Split", "", "", ""); - CAF_PDM_InitFieldNoDefault(&wellSelection, "WellSelection", "Well Selection", "", "", ""); - wellSelection.uiCapability()->setAutoAddingOptionFromValue(false); CAF_PDM_InitFieldNoDefault(&compdatExport, "compdatExport", "Export", "", " ", ""); - CAF_PDM_InitField(&timeStep, "TimeStepIndex", 0, "Time Step", "", "", ""); - + CAF_PDM_InitField(&timeStep, "TimeStepIndex", 0, " Time Step", "", "", ""); + CAF_PDM_InitField(&useLateralNTG, "UseLateralNTG", false, "Use NTG Horizontally", "", "", ""); - CAF_PDM_InitField(&includePerforations, "IncludePerforations", true, "Include Perforations", "", "", ""); - CAF_PDM_InitField(&includeFishbones, "IncludeFishbones", true, "Include Fishbones", "", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Include Fractures", "", "", ""); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + CAF_PDM_InitField(&includePerforations, "IncludePerforations", true, "Perforations", "", "", ""); + CAF_PDM_InitField(&includeFishbones, "IncludeFishbones", true, "Fishbones", "", "", ""); + CAF_PDM_InitField(&includeFractures, "IncludeFractures", true, "Fractures", "", "", ""); + + CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, " Exclude Main Bore Transmissibility", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_reportCompletionTypesSeparately, "ReportCompletionTypesSeparately", "Export Completion Types", "", "", ""); + + m_displayForSimWell = true; + + m_fracturesEnabled = true; + m_perforationsEnabled = true; + m_fishbonesEnabled = true; +} - CAF_PDM_InitField(&excludeMainBoreForFishbones, "ExcludeMainBoreForFishbones", false, "Exclude Main Bore Transmissibility For Fishbones", "", "", ""); - m_onlyWellPathCollectionSelected = onlyWellPathCollectionSelected; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::showForSimWells() +{ m_displayForSimWell = true; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::setOnlyWellPathCollectionSelected(bool onlyWellPathCollectionSelected) +void RicExportCompletionDataSettingsUi::showForWellPath() { - m_onlyWellPathCollectionSelected = onlyWellPathCollectionSelected; + m_displayForSimWell = false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::showForSimWells() +void RicExportCompletionDataSettingsUi::setCombinationMode(CombinationMode combinationMode) { - m_displayForSimWell = true; + m_reportCompletionTypesSeparately = combinationMode; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportCompletionDataSettingsUi::showForWellPath() +void RicExportCompletionDataSettingsUi::showFractureInUi(bool enable) { - m_displayForSimWell = false; + m_fracturesEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::showPerforationsInUi(bool enable) +{ + m_perforationsEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionDataSettingsUi::showFishbonesInUi(bool enable) +{ + m_fishbonesEnabled = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionDataSettingsUi::reportCompletionsTypesIndividually() const +{ + return m_reportCompletionTypesSeparately() == INDIVIDUALLY; } //-------------------------------------------------------------------------------------------------- @@ -114,7 +140,6 @@ void RicExportCompletionDataSettingsUi::showForWellPath() //-------------------------------------------------------------------------------------------------- void RicExportCompletionDataSettingsUi::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (changedField == &compdatExport) { if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) @@ -128,7 +153,6 @@ void RicExportCompletionDataSettingsUi::fieldChangedByUi(const caf::PdmFieldHand includeFractures.uiCapability()->setUiReadOnly(false); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -151,18 +175,6 @@ QList RicExportCompletionDataSettingsUi::calculateValueO options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); } } - else if (fieldNeedingOptions == &wellSelection) - { - if (m_onlyWellPathCollectionSelected) - { - options.push_back(caf::PdmOptionItemInfo("All Wells", ALL_WELLS)); - options.push_back(caf::PdmOptionItemInfo("Checked Wells", CHECKED_WELLS)); - } - else - { - options.push_back(caf::PdmOptionItemInfo("Selected Wells", SELECTED_WELLS)); - } - } else { options = RicCaseAndFileExportSettingsUi::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); @@ -175,54 +187,63 @@ QList RicExportCompletionDataSettingsUi::calculateValueO //-------------------------------------------------------------------------------------------------- void RicExportCompletionDataSettingsUi::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - caf::PdmUiGroup* generalExportSettings = uiOrdering.addNewGroup("General Export Settings"); - generalExportSettings->add(&folder); - generalExportSettings->add(&caseToApply); - generalExportSettings->add(&compdatExport); - generalExportSettings->add(&useLateralNTG); - - generalExportSettings->add(&wellSelection); - if (!m_onlyWellPathCollectionSelected) { - wellSelection.setValue(SELECTED_WELLS); + caf::PdmUiGroup* group = uiOrdering.addNewGroup("File Settings"); + + group->add(&folder); + group->add(&fileSplit); + group->add(&m_reportCompletionTypesSeparately); } - else + { - if (wellSelection() != ALL_WELLS && wellSelection() != CHECKED_WELLS) - { - wellSelection.setValue(CHECKED_WELLS); - } - } + caf::PdmUiGroup* group = uiOrdering.addNewGroup("Settings"); - generalExportSettings->add(&fileSplit); + group->add(&caseToApply); + group->add(&compdatExport); + group->add(&useLateralNTG); + } - if (!m_displayForSimWell) { - caf::PdmUiGroup* fishboneGroup = uiOrdering.addNewGroup("Export of Fishbone Completions"); - fishboneGroup->add(&includeFishbones); - fishboneGroup->add(&excludeMainBoreForFishbones); - if (!includeFishbones) excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); - else excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); - - caf::PdmUiGroup* perfIntervalGroup = uiOrdering.addNewGroup("Export of Perforation Completions"); - perfIntervalGroup->add(&includePerforations); - perfIntervalGroup->add(&timeStep); - if (!includePerforations) timeStep.uiCapability()->setUiReadOnly(true); - else timeStep.uiCapability()->setUiReadOnly(false); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - caf::PdmUiGroup* fractureGroup = uiOrdering.addNewGroup("Export of Fracture Completions"); - fractureGroup->add(&includeFractures); - - if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + caf::PdmUiGroup* group = uiOrdering.addNewGroup("Visible Completions"); + if (!m_displayForSimWell) { - includeFractures.uiCapability()->setUiReadOnly(true); + if (m_perforationsEnabled) + { + group->add(&includePerforations); + group->add(&timeStep); + if (!includePerforations) + timeStep.uiCapability()->setUiReadOnly(true); + else + timeStep.uiCapability()->setUiReadOnly(false); + } } - else if (compdatExport == TRANSMISSIBILITIES) + + if (m_fracturesEnabled) { - includeFractures.uiCapability()->setUiReadOnly(false); + group->add(&includeFractures); + + if (compdatExport == WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + includeFractures.uiCapability()->setUiReadOnly(true); + } + else if (compdatExport == TRANSMISSIBILITIES) + { + includeFractures.uiCapability()->setUiReadOnly(false); + } + } + + if (!m_displayForSimWell) + { + if (m_fishbonesEnabled) + { + group->add(&includeFishbones); + group->add(&excludeMainBoreForFishbones); + if (!includeFishbones) + excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(true); + else + excludeMainBoreForFishbones.uiCapability()->setUiReadOnly(false); + } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } uiOrdering.skipRemainingFields(); diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h similarity index 76% rename from ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h rename to ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h index 1224b44435..2b35840844 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportCompletionDataSettingsUi.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionDataSettingsUi.h @@ -38,43 +38,43 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi }; typedef caf::AppEnum ExportSplitType; - enum WellSelection { - ALL_WELLS, - CHECKED_WELLS, - SELECTED_WELLS, - }; - typedef caf::AppEnum WellSelectionType; - enum CompdatExport { TRANSMISSIBILITIES, WPIMULT_AND_DEFAULT_CONNECTION_FACTORS, }; typedef caf::AppEnum CompdatExportType; + enum CombinationMode + { + INDIVIDUALLY, + COMBINED, + }; + typedef caf::AppEnum CombinationModeType; + RicExportCompletionDataSettingsUi(); - RicExportCompletionDataSettingsUi(bool onlyWellPathCollectionSelected); + + caf::PdmField timeStep; caf::PdmField fileSplit; - caf::PdmField wellSelection; caf::PdmField compdatExport; caf::PdmField useLateralNTG; caf::PdmField includePerforations; caf::PdmField includeFishbones; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - caf::PdmField includeFractures; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - caf::PdmField excludeMainBoreForFishbones; + caf::PdmField includeFractures; + + void showForSimWells(); + void showForWellPath(); - caf::PdmField timeStep; + void setCombinationMode(CombinationMode combinationMode); - void setOnlyWellPathCollectionSelected(bool onlyWellPathCollectionSelected); + void showFractureInUi(bool enable); + void showPerforationsInUi(bool enable); + void showFishbonesInUi(bool enable); - void showForSimWells(); - void showForWellPath(); + bool reportCompletionsTypesIndividually() const; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; @@ -83,6 +83,10 @@ class RicExportCompletionDataSettingsUi : public RicCaseAndFileExportSettingsUi virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; private: - bool m_onlyWellPathCollectionSelected; - bool m_displayForSimWell; + caf::PdmField m_reportCompletionTypesSeparately; + + bool m_displayForSimWell; + bool m_fracturesEnabled; + bool m_perforationsEnabled; + bool m_fishbonesEnabled; }; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp new file mode 100644 index 0000000000..fe82fa65b4 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.cpp @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportCompletionsForVisibleSimWellsFeature.h" + +#include "RicWellPathExportCompletionDataFeature.h" + +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleSimWellsFeature, "RicExportCompletionsForVisibleSimWellsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionsForVisibleSimWellsFeature::isCommandEnabled() +{ + std::vector simWells = visibleSimWells(); + + if (simWells.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleSimWellsFeature::onActionTriggered(bool isChecked) +{ + std::vector simWells = visibleSimWells(); + CVF_ASSERT(!simWells.empty()); + + std::vector wellPaths; + QString dialogTitle = "Export Completion Data for Visible Simulation Wells"; + + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleSimWellsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Completion Data for Visible Simulation Wells"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportCompletionsForVisibleSimWellsFeature::visibleSimWells() +{ + std::vector simWells; + + { + std::vector simWellCollection; + caf::SelectionManager::instance()->objectsByType(&simWellCollection); + + if (simWellCollection.empty()) + { + std::vector selectedSimWells; + caf::SelectionManager::instance()->objectsByType(&selectedSimWells); + + if (!selectedSimWells.empty()) + { + RimSimWellInViewCollection* parent = nullptr; + selectedSimWells[0]->firstAncestorOrThisOfType(parent); + if (parent) + { + simWellCollection.push_back(parent); + } + } + } + + for (auto coll : simWellCollection) + { + for (const auto& wellPath : coll->wells()) + { + if (wellPath->showWell()) + { + simWells.push_back(wellPath); + } + } + } + } + + std::set uniqueWellPaths(simWells.begin(), simWells.end()); + simWells.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); + + return simWells; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h new file mode 100644 index 0000000000..9e6a49ef0b --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleSimWellsFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSimWellInView; + +//================================================================================================== +/// +//================================================================================================== +class RicExportCompletionsForVisibleSimWellsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + std::vector visibleSimWells(); +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp new file mode 100644 index 0000000000..7c5fb9adff --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.cpp @@ -0,0 +1,154 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicExportCompletionsForVisibleWellPathsFeature.h" + +#include "RiaApplication.h" + +#include "RicWellPathExportCompletionDataFeature.h" + +#include "RiuPlotMainWindow.h" + +#include "RimWellPath.h" +#include "RimProject.h" +#include "RimWellPathCollection.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicExportCompletionsForVisibleWellPathsFeature, "RicExportCompletionsForVisibleWellPathsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicExportCompletionsForVisibleWellPathsFeature::isCommandEnabled() +{ + bool foundWellPathCollection = false; + std::vector selectedObjects; + caf::SelectionManager::instance()->objectsByType(&selectedObjects); + for (caf::PdmObject* object : selectedObjects) + { + RimWellPathCollection* wellPathCollection; + + object->firstAncestorOrThisOfType(wellPathCollection); + if (wellPathCollection) + { + foundWellPathCollection = true; + break; + } + } + + if (!foundWellPathCollection) + { + return false; + } + + std::vector wellPaths = visibleWellPaths(); + + if (wellPaths.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleWellPathsFeature::onActionTriggered(bool isChecked) +{ + std::vector wellPaths = visibleWellPaths(); + CVF_ASSERT(wellPaths.size() > 0); + + std::vector simWells; + QString dialogTitle = "Export Completion Data for Visible Well Paths"; + + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicExportCompletionsForVisibleWellPathsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Completion Data for Visible Well Paths"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicExportCompletionsForVisibleWellPathsFeature::visibleWellPaths() +{ + std::vector wellPaths; + + { + std::vector wellPathCollections; + caf::SelectionManager::instance()->objectsByType(&wellPathCollections); + + if (wellPathCollections.empty()) + { + std::vector selectedWellPaths; + caf::SelectionManager::instance()->objectsByType(&selectedWellPaths); + + if (!selectedWellPaths.empty()) + { + RimWellPathCollection* parent = nullptr; + selectedWellPaths[0]->firstAncestorOrThisOfType(parent); + if (parent) + { + wellPathCollections.push_back(parent); + } + } + } + + if (!wellPathCollections.empty()) + { + for (auto wellPathCollection : wellPathCollections) + { + for (const auto& wellPath : wellPathCollection->wellPaths()) + { + if (wellPath->showWellPath()) + { + wellPaths.push_back(wellPath); + } + } + } + } + else + { + // No well path or well path collection selected + + auto allWellPaths = RiaApplication::instance()->project()->allWellPaths(); + for (const auto& w : allWellPaths) + { + if (w->showWellPath()) + { + wellPaths.push_back(w); + } + } + + } + } + + std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); + wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); + + return wellPaths; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h new file mode 100644 index 0000000000..c80ba540ca --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportCompletionsForVisibleWellPathsFeature.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSimWellInView; +class RimWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RicExportCompletionsForVisibleWellPathsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + std::vector visibleWellPaths(); +}; diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp similarity index 98% rename from ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp index e7b206eb85..3b2de36453 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.cpp @@ -34,7 +34,7 @@ #include "RigEclipseCaseData.h" #include "RigWellPath.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" #include "cafPdmUiPropertyViewDialog.h" @@ -78,7 +78,7 @@ void RicExportFishbonesWellSegmentsFeature::onActionTriggered(bool isChecked) exportSettings.folder = defaultDir; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Well Segments", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Well Segments", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) @@ -174,7 +174,7 @@ void RicExportFishbonesWellSegmentsFeature::exportWellSegments(const RimWellPath return; } - std::vector locations = RicWellPathExportCompletionDataFeature::findWellSegmentLocations(settings.caseToApply, wellPath, fishbonesSubs); + std::vector locations = RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(settings.caseToApply, wellPath, fishbonesSubs); QTextStream stream(&exportFile); RifEclipseDataTableFormatter formatter(stream); @@ -364,7 +364,7 @@ void RicExportFishbonesWellSegmentsFeature::generateCompsegsTable(RifEclipseData for (const WellSegmentLateralIntersection& intersection : lateral.intersections) { size_t i, j, k; - grid->ijkFromCellIndex(intersection.cellIndex, &i, &j, &k); + grid->ijkFromCellIndex(intersection.globalCellIndex, &i, &j, &k); formatter.addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k); formatter.add(lateral.branchNumber); diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h similarity index 97% rename from ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.h rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h index 338ed30c3e..fe125abb2c 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.h +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFishbonesWellSegmentsFeature.h @@ -21,8 +21,8 @@ #include "RifEclipseDataTableFormatter.h" #include "RicCaseAndFileExportSettingsUi.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" -#include "RicWellPathExportCompletionDataFeature.h" #include "cafCmdFeature.h" diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp similarity index 83% rename from ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp index c121df89b7..e11e605814 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.cpp @@ -87,23 +87,10 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat { std::vector completionData; - std::vector< std::vector > pipeBranchesCLCoords; - std::vector< std::vector > pipeBranchesCellIds; - - RimEclipseView* view = nullptr; - well->firstAncestorOrThisOfTypeAsserted(view); - - size_t timeStep = view->currentTimeStep(); + auto branches = well->wellPipeBranches(); - well->calculateWellPipeDynamicCenterLine(timeStep, pipeBranchesCLCoords, pipeBranchesCellIds); - - for (size_t branchIndex = 0; branchIndex < pipeBranchesCLCoords.size(); ++branchIndex) + for (size_t branchIndex = 0; branchIndex < branches.size(); ++branchIndex) { - RigSimulationWellCoordsAndMD coordsAndMD(pipeBranchesCLCoords[branchIndex]); - RigWellPath wellPathGeometry; - wellPathGeometry.m_wellPathPoints = coordsAndMD.wellPathPoints(); - wellPathGeometry.m_measuredDepths = coordsAndMD.measuredDepths(); - std::vector fractures; for (RimSimWellFracture* fracture : well->simwellFractureCollection->simwellFractures()) { @@ -113,7 +100,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat } } - std::vector branchCompletions = generateCompdatValues(eclipseCase, well->name(), &wellPathGeometry, fractures, outputStreamForIntermediateResultsText); + std::vector branchCompletions = generateCompdatValues(eclipseCase, well->name(), branches[branchIndex], fractures, outputStreamForIntermediateResultsText); completionData.insert(completionData.end(), branchCompletions.begin(), branchCompletions.end()); } @@ -145,8 +132,10 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat if (!fracTemplate) continue; - bool useFiniteConductivityInFracture = (fracTemplate->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY); const RigFractureGrid* fractureGrid = fracTemplate->fractureGrid(); + if (!fractureGrid) continue; + + bool useFiniteConductivityInFracture = (fracTemplate->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY); //If finite cond chosen and conductivity not present in stimplan file, do not calculate trans for this fracture if (useFiniteConductivityInFracture) @@ -179,7 +168,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat RigEclipseToStimPlanCellTransmissibilityCalculator eclToFractureTransCalc(caseToApply, fracture->transformMatrix(), - fracture->fractureTemplate()->skinFactor, + fracture->fractureTemplate()->skinFactor(), cDarcyInCorrectUnit, fractureCell); @@ -278,21 +267,24 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat || fracture->fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { const RigFractureGrid* fracGrid = fracture->fractureTemplate()->fractureGrid(); - std::pair wellCellIJ = fracGrid->fractureCellAtWellCenter(); - size_t wellCellIndex = fracGrid->getGlobalIndexFromIJ(wellCellIJ.first, wellCellIJ.second); + if (fracGrid) + { + std::pair wellCellIJ = fracGrid->fractureCellAtWellCenter(); + size_t wellCellIndex = fracGrid->getGlobalIndexFromIJ(wellCellIJ.first, wellCellIJ.second); - const RigFractureCell& wellCell = fractureGrid->cellFromIndex(wellCellIndex); + const RigFractureCell& wellCell = fractureGrid->cellFromIndex(wellCellIndex); - double radialTrans = RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans(wellCell.getConductivtyValue(), - wellCell.cellSizeX(), - wellCell.cellSizeZ(), - fracture->wellRadius(caseToApply->eclipseCaseData()->unitsType()), - fracTemplate->skinFactor(), - cDarcyInCorrectUnit); + double radialTrans = RigFractureTransmissibilityEquations::fractureCellToWellRadialTrans(wellCell.getConductivtyValue(), + wellCell.cellSizeX(), + wellCell.cellSizeZ(), + fracture->wellRadius(), + fracTemplate->skinFactor(), + cDarcyInCorrectUnit); - transCondenser.addNeighborTransmissibility({ true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }, - { false, RigTransmissibilityCondenser::CellAddress::STIMPLAN, wellCellIndex }, - radialTrans); + transCondenser.addNeighborTransmissibility({ true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }, + { false, RigTransmissibilityCondenser::CellAddress::STIMPLAN, wellCellIndex }, + radialTrans); + } } else if (fracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { @@ -319,7 +311,7 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat fractureWellCell.cellSizeZ(), intersection.vlength, intersection.hlength, - fracture->perforationEfficiency, + fracture->perforationEfficiency(), fracTemplate->skinFactor(), cDarcyInCorrectUnit); } @@ -334,31 +326,57 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat ///// // Insert total transmissibility from eclipse-cell to well for this fracture into the map + std::vector allCompletionsForOneFracture; + std::set externalCells = transCondenser.externalCells(); for (RigTransmissibilityCondenser::CellAddress externalCell : externalCells) { if (externalCell.m_cellIndexSpace == RigTransmissibilityCondenser::CellAddress::ECLIPSE) { - if (externalCell.m_globalCellIdx > mainGrid->cellCount()) - { - RiaLogging::error(QString("LGR cells (not supported) found in export of COMPDAT values for fracture %1").arg(fracture->name())); - } - else - { - double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); + double trans = transCondenser.condensedTransmissibility(externalCell, { true, RigTransmissibilityCondenser::CellAddress::WELL, 1 }); - eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; - size_t i, j, k; - mainGrid->ijkFromCellIndex(externalCell.m_globalCellIdx, &i, &j, &k); - - RigCompletionData compDat(wellPathName, {i,j,k}); - compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor()); - compDat.addMetadata(fracture->name(), QString::number(trans)); - fractureCompletions.push_back(compDat); - } + eclCellIdxToTransPrFractureMap[externalCell.m_globalCellIdx][fracture] = trans; + + RigCompletionData compDat(wellPathName, + RigCompletionDataGridCell(externalCell.m_globalCellIdx, caseToApply->mainGrid()), + fracture->fractureMD()); + + double diameter = 2.0 * fracture->wellRadius(); + compDat.setFromFracture(trans, fracture->fractureTemplate()->skinFactor(), diameter); + compDat.addMetadata(fracture->name(), QString::number(trans)); + allCompletionsForOneFracture.push_back(compDat); } } + ///// + // Compute Non-Dracy Flow parameters + + if (fracture->fractureTemplate()->isNonDarcyFlowEnabled()) + { + double dFactorForFracture = fracture->fractureTemplate()->dFactor(); + double khForFracture = fracture->fractureTemplate()->kh(); + + double sumOfTransmissibilitiesInFracture = 0.0; + for (const auto& c : allCompletionsForOneFracture) + { + sumOfTransmissibilitiesInFracture += c.transmissibility(); + } + + for (auto& c : allCompletionsForOneFracture) + { + // NOTE : What is supposed to happen when the transmissibility is close to zero? + + double dFactorForOneConnection = dFactorForFracture * sumOfTransmissibilitiesInFracture / c.transmissibility(); + c.setDFactor(dFactorForOneConnection); + + double khForOneConnection = khForFracture * c.transmissibility() / sumOfTransmissibilitiesInFracture; + + c.setKh(khForOneConnection); + } + } + + std::copy(allCompletionsForOneFracture.begin(), allCompletionsForOneFracture.end(), std::back_inserter(fractureCompletions)); + if ( outputStreamForIntermediateResultsText ) { (*outputStreamForIntermediateResultsText) << "\n" << "\n" << "\n----------- All Transimissibilities " << fracture->name() << " -------------------- \n\n"; @@ -372,4 +390,3 @@ std::vector RicExportFractureCompletionsImpl::generateCompdat return fractureCompletions; } - diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h similarity index 100% rename from ApplicationCode/Commands/CompletionCommands/RicExportFractureCompletionsImpl.h rename to ApplicationCode/Commands/CompletionExportCommands/RicExportFractureCompletionsImpl.h diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp similarity index 82% rename from ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp rename to ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index f0279515b7..e4775e46c6 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -19,13 +19,14 @@ #include "RicFishbonesTransmissibilityCalculationFeatureImp.h" #include "RicExportCompletionDataSettingsUi.h" -#include "RicWellPathExportCompletionDataFeature.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" #include "RigActiveCellInfo.h" #include "RigCompletionData.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigWellPath.h" +#include "RigWellPathIntersectionTools.h" #include "RimFishboneWellPath.h" #include "RimFishboneWellPathCollection.h" @@ -35,6 +36,28 @@ #include "RimWellPathCompletions.h" #include "RigWellLogExtractor.h" +//================================================================================================== +/// +//================================================================================================== +struct WellBorePartForTransCalc +{ + WellBorePartForTransCalc(cvf::Vec3d lengthsInCell, double wellRadius, double skinFactor, bool isMainBore, QString metaData) + : lengthsInCell(lengthsInCell), wellRadius(wellRadius), skinFactor(skinFactor), isMainBore(isMainBore), metaData(metaData) + { + intersectionWithWellMeasuredDepth = HUGE_VAL; + lateralIndex = cvf::UNDEFINED_SIZE_T; + } + + cvf::Vec3d lengthsInCell; + double wellRadius; + double skinFactor; + QString metaData; + bool isMainBore; + + double intersectionWithWellMeasuredDepth; + size_t lateralIndex; +}; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -42,9 +65,11 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) { + if (!wellPath) return; + // Generate data const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData(); - std::vector locations = RicWellPathExportCompletionDataFeature::findWellSegmentLocations(settings.caseToApply, wellPath); + std::vector locations = RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(settings.caseToApply, wellPath); RiaEclipseUnitTools::UnitSystem unitSystem = caseData->unitsType(); bool isMainBore = false; @@ -63,7 +88,10 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell isMainBore, completionMetaData); - wellBorePartsInCells[intersection.cellIndex].push_back(wellBorePart); + wellBorePart.intersectionWithWellMeasuredDepth = location.measuredDepth; + wellBorePart.lateralIndex = lateral.lateralIndex; + + wellBorePartsInCells[intersection.globalCellIndex].push_back(wellBorePart); } } @@ -75,8 +103,15 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWell /// //-------------------------------------------------------------------------------------------------- std::vector RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume(const RimWellPath* wellPath, - const RicExportCompletionDataSettingsUi& settings) + const RicExportCompletionDataSettingsUi& settings) { + std::vector completionData; + + if (!wellPath || !wellPath->completions()) + { + return completionData; + } + std::map > wellBorePartsInCells; //wellBore = main bore or fishbone lateral findFishboneLateralsWellBoreParts(wellBorePartsInCells, wellPath, settings); findFishboneImportedLateralsWellBoreParts(wellBorePartsInCells, wellPath, settings); @@ -85,19 +120,14 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp findMainWellBoreParts(wellBorePartsInCells, wellPath, settings); } - std::vector completionData; - - RigMainGrid* grid = settings.caseToApply->eclipseCaseData()->mainGrid(); const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); for (const auto& cellAndWellBoreParts : wellBorePartsInCells) { - size_t cellIndex = cellAndWellBoreParts.first; + size_t globalCellIndex = cellAndWellBoreParts.first; const std::vector& wellBoreParts = cellAndWellBoreParts.second; - size_t i, j, k; - grid->ijkFromCellIndex(cellIndex, &i, &j, &k); - bool cellIsActive = activeCellInfo->isActive(cellIndex); + bool cellIsActive = activeCellInfo->isActive(globalCellIndex); if (!cellIsActive) continue; // Find main bore and number of laterals @@ -112,46 +142,47 @@ std::vector RicFishbonesTransmissibilityCalculationFeatureImp } else { - mainBoreDirection = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, - cellIndex, + mainBoreDirection = RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(settings.caseToApply, + globalCellIndex, wellBorePart.lengthsInCell); } } for (WellBorePartForTransCalc wellBorePart : wellBoreParts) { - RigCompletionData completion(wellPath->completions()->wellNameForExport(), IJKCellIndex(i, j, k)); + RigCompletionData completion(wellPath->completions()->wellNameForExport(), RigCompletionDataGridCell(globalCellIndex, settings.caseToApply->mainGrid()), wellBorePart.intersectionWithWellMeasuredDepth); + completion.setSecondOrderingValue(wellBorePart.lateralIndex); double transmissibility = 0.0; if (wellBorePart.isMainBore) { //No change in transmissibility for main bore - transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, + transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, wellPath, wellBorePart.lengthsInCell, wellBorePart.skinFactor, wellBorePart.wellRadius, - cellIndex, + globalCellIndex, settings.useLateralNTG); } else { //Adjust transmissibility for fishbone laterals - transmissibility = RicWellPathExportCompletionDataFeature::calculateTransmissibility(settings.caseToApply, + transmissibility = RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, wellPath, wellBorePart.lengthsInCell, wellBorePart.skinFactor, wellBorePart.wellRadius, - cellIndex, + globalCellIndex, settings.useLateralNTG, numberOfLaterals, mainBoreDirection); } - CellDirection direction = RicWellPathExportCompletionDataFeature::calculateDirectionInCell(settings.caseToApply, - cellIndex, + CellDirection direction = RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(settings.caseToApply, + globalCellIndex, wellBorePart.lengthsInCell); completion.setTransAndWPImultBackgroundDataFromFishbone(transmissibility, @@ -176,10 +207,14 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate const RicExportCompletionDataSettingsUi& settings) { RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); - std::set wellPathCells = RicWellPathExportCompletionDataFeature::findIntersectedCells(settings.caseToApply()->eclipseCaseData(), - wellPath->wellPathGeometry()->m_wellPathPoints); - bool isMainBore = false; + if (!wellPath) return; + if (!wellPath->wellPathGeometry()) return; + + std::set wellPathCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndicesForWellPath( + settings.caseToApply()->eclipseCaseData(), wellPath->wellPathGeometry()); + + bool isMainBore = false; double diameter = wellPath->fishbonesCollection()->wellPathCollection()->holeDiameter(unitSystem); for (const RimFishboneWellPath* fishbonesPath : wellPath->fishbonesCollection()->wellPathCollection()->wellPaths()) { @@ -197,6 +232,8 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneImportedLate skinFactor, isMainBore, completionMetaData); + wellBorePart.intersectionWithWellMeasuredDepth = cell.startMD; + wellBorePartsInCells[cell.globCellIndex].push_back(wellBorePart); } } @@ -209,6 +246,9 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) { + if (!wellPath) return; + if (!wellPath->wellPathGeometry()) return; + RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); bool isMainBore = true; double holeDiameter = wellPath->fishbonesCollection()->mainBoreDiameter(unitSystem); @@ -224,6 +264,8 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st fishbonePerfWellPathCoords.first, fishbonePerfWellPathCoords.second); + if (!wellPath->fishbonesCollection()) return; + for (auto& cell : intersectedCellsIntersectionInfo) { double skinFactor = wellPath->fishbonesCollection()->mainBoreSkinFactor(); @@ -234,6 +276,9 @@ void RicFishbonesTransmissibilityCalculationFeatureImp::findMainWellBoreParts(st isMainBore, completionMetaData); + wellBorePart.intersectionWithWellMeasuredDepth = cell.startMD; + wellBorePartsInCells[cell.globCellIndex].push_back(wellBorePart); } } + diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h new file mode 100644 index 0000000000..651a23f3e8 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicFishbonesTransmissibilityCalculationFeatureImp.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfVector3.h" + +#include +#include +#include + +class RigCompletionData; +class RimWellPath; +class RicExportCompletionDataSettingsUi; +class RigEclipseCaseData; + +struct WellBorePartForTransCalc; + + +//================================================================================================== +/// +//================================================================================================== +class RicFishbonesTransmissibilityCalculationFeatureImp +{ +public: + static std::vector generateFishboneCompdatValuesUsingAdjustedCellVolume(const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); + + +private: + static void findFishboneLateralsWellBoreParts(std::map>& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); + + static void findFishboneImportedLateralsWellBoreParts(std::map>& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); + + static void findMainWellBoreParts(std::map>& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp new file mode 100644 index 0000000000..ea34f91857 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicWellPathExportCompletionDataFeature.h" +#include "RicWellPathExportCompletionDataFeatureImpl.h" + +#include "RiaApplication.h" + +#include "RicExportFeatureImpl.h" + +#include "RimDialogData.h" +#include "RimFishbonesMultipleSubs.h" +#include "RimPerforationInterval.h" +#include "RimProject.h" +#include "RimSimWellFracture.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" +#include "RimWellPathFracture.h" + +#include "Riu3DMainWindowTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicWellPathExportCompletionDataFeature, "RicWellPathExportCompletionDataFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions( + const QString& dialogTitle, + const std::vector& wellPaths, + const std::vector& simWells) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* project = app->project(); + + QString projectFolder = app->currentProjectPath(); + QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("COMPLETIONS", projectFolder); + + RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData(); + + if (wellPaths.empty()) + { + exportSettings->showForSimWells(); + } + else + { + exportSettings->showForWellPath(); + } + + if (!exportSettings->caseToApply()) + { + std::vector cases; + app->project()->allCases(cases); + for (auto c : cases) + { + RimEclipseCase* eclipseCase = dynamic_cast(c); + if (eclipseCase != nullptr) + { + exportSettings->caseToApply = eclipseCase; + break; + } + } + } + + if (exportSettings->folder().isEmpty()) exportSettings->folder = defaultDir; + + std::vector simWellFractures; + std::vector wellPathFractures; + std::vector wellPathFishbones; + std::vector wellPathPerforations; + + for (auto s : simWells) + { + s->descendantsIncludingThisOfType(simWellFractures); + } + + for (auto w : wellPaths) + { + w->descendantsIncludingThisOfType(wellPathFractures); + w->descendantsIncludingThisOfType(wellPathFishbones); + w->descendantsIncludingThisOfType(wellPathPerforations); + } + + if ((!simWellFractures.empty()) || (!wellPathFractures.empty())) + { + exportSettings->showFractureInUi(true); + } + else + { + exportSettings->showFractureInUi(false); + } + + if (!wellPathFishbones.empty()) + { + exportSettings->showFishbonesInUi(true); + } + else + { + exportSettings->showFishbonesInUi(false); + } + + if (!wellPathPerforations.empty()) + { + exportSettings->showPerforationsInUi(true); + } + else + { + exportSettings->showPerforationsInUi(false); + } + + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), exportSettings, dialogTitle, ""); + RicExportFeatureImpl::configureForExport(&propertyDialog); + + if (propertyDialog.exec() == QDialog::Accepted) + { + RiaApplication::instance()->setLastUsedDialogDirectory("COMPLETIONS", exportSettings->folder); + + RicWellPathExportCompletionDataFeatureImpl::exportCompletions(wellPaths, simWells, *exportSettings); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathExportCompletionDataFeature::isCommandEnabled() +{ + std::vector wellPaths = selectedWellPaths(); + + if (wellPaths.empty()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::onActionTriggered(bool isChecked) +{ + std::vector wellPaths = selectedWellPaths(); + CVF_ASSERT(!wellPaths.empty()); + + std::vector simWells; + QString dialogTitle = "Export Completion Data for Selected Well Paths"; + + RicWellPathExportCompletionDataFeature::prepareExportSettingsAndExportCompletions(dialogTitle, wellPaths, simWells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Export Completion Data for Selected Well Paths"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeature::selectedWellPaths() +{ + std::vector wellPaths; + caf::SelectionManager::instance()->objectsByType(&wellPaths); + + std::set uniqueWellPaths(wellPaths.begin(), wellPaths.end()); + wellPaths.assign(uniqueWellPaths.begin(), uniqueWellPaths.end()); + + return wellPaths; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h new file mode 100644 index 0000000000..d5595e5b00 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimSimWellInView; +class RimWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RicWellPathExportCompletionDataFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static void prepareExportSettingsAndExportCompletions(const QString& dialogTitle, + const std::vector& wellPaths, + const std::vector& simWells); + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + std::vector selectedWellPaths(); +}; diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp new file mode 100644 index 0000000000..9398094783 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.cpp @@ -0,0 +1,1231 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicWellPathExportCompletionDataFeatureImpl.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" + +#include "RicExportCompletionDataSettingsUi.h" +#include "RicExportFeatureImpl.h" +#include "RicExportFractureCompletionsImpl.h" +#include "RicFishbonesTransmissibilityCalculationFeatureImp.h" + +#include "RifEclipseDataTableFormatter.h" + +#include "RigActiveCellInfo.h" +#include "RigCaseCellResultsData.h" +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" +#include "RigResultAccessorFactory.h" +#include "RigTransmissibilityEquations.h" +#include "RigWellLogExtractionTools.h" +#include "RigWellLogExtractor.h" +#include "RigWellPath.h" +#include "RigWellPathIntersectionTools.h" + +#include "RimFishbonesCollection.h" +#include "RimFishbonesMultipleSubs.h" +#include "RimPerforationCollection.h" +#include "RimPerforationInterval.h" +#include "RimSimWellInView.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" +#include "RimWellPathCompletions.h" + +#include "RiuMainWindow.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafProgressInfo.h" +#include "cafSelectionManager.h" + +#include "cvfPlane.h" + +#include "RigVirtualPerforationTransmissibilities.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::exportCompletions(const std::vector& wellPaths, + const std::vector& simWells, + const RicExportCompletionDataSettingsUi& exportSettings) +{ + if (exportSettings.caseToApply() == nullptr) + { + RiaLogging::error("Export Completions Data: Cannot export completions data without specified eclipse case"); + return; + } + + + std::vector usedWellPaths; + for (RimWellPath* wellPath : wellPaths) + { + if (wellPath->unitSystem() == exportSettings.caseToApply->eclipseCaseData()->unitsType()) + { + usedWellPaths.push_back(wellPath); + } + else + { + int caseId = exportSettings.caseToApply->caseId(); + QString format = QString("Unit systems for well path \"%1\" must match unit system of chosen eclipse case \"%2\""); + QString errMsg = format.arg(wellPath->name()).arg(caseId); + RiaLogging::error(errMsg); + } + } + + + // FractureTransmissibilityExportInformation + std::unique_ptr fractureTransmissibilityExportInformationStream = nullptr; + QFile fractureTransmissibilityExportInformationFile; + + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + if (prefs->includeFractureDebugInfoFile()) + { + QDir outputDir = QDir(exportSettings.folder); + outputDir.mkpath("."); + + QString fractureTransmisibillityExportInformationPath = + QDir(exportSettings.folder).absoluteFilePath("FractureTransmissibilityExportInformation"); + + fractureTransmissibilityExportInformationFile.setFileName(fractureTransmisibillityExportInformationPath); + if (!fractureTransmissibilityExportInformationFile.open(QIODevice::WriteOnly)) + { + RiaLogging::error(QString("Export Completions Data: Could not open the file: %1") + .arg(fractureTransmisibillityExportInformationPath)); + } + else + { + fractureTransmissibilityExportInformationStream = + std::unique_ptr(new QTextStream(&fractureTransmissibilityExportInformationFile)); + } + } + + size_t maxProgress = usedWellPaths.size() * 3 + simWells.size() + + (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL + ? usedWellPaths.size() + : exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE + ? usedWellPaths.size() * 3 + : 1) + + simWells.size(); + + caf::ProgressInfo progress(maxProgress, "Export Completions"); + + progress.setProgressDescription("Read Completion Data"); + + std::vector completions; + + for (auto wellPath : usedWellPaths) + { + std::map> completionsPerEclipseCellAllCompletionTypes; + std::map> completionsPerEclipseCellFishbones; + std::map> completionsPerEclipseCellFracture; + std::map> completionsPerEclipseCellPerforations; + + // Generate completion data + + if (exportSettings.includePerforations) + { + std::vector perforationCompletionData = + generatePerforationsCompdatValues(wellPath, exportSettings); + + appendCompletionData(&completionsPerEclipseCellAllCompletionTypes, perforationCompletionData); + appendCompletionData(&completionsPerEclipseCellPerforations, perforationCompletionData); + } + progress.incrementProgress(); + + if (exportSettings.includeFishbones) + { + std::vector fishbonesCompletionData = + RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( + wellPath, exportSettings); + + appendCompletionData(&completionsPerEclipseCellAllCompletionTypes, fishbonesCompletionData); + appendCompletionData(&completionsPerEclipseCellFishbones, fishbonesCompletionData); + } + progress.incrementProgress(); + + if (exportSettings.includeFractures()) + { + std::vector fractureCompletionData = + RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath( + wellPath, exportSettings, fractureTransmissibilityExportInformationStream.get()); + + appendCompletionData(&completionsPerEclipseCellAllCompletionTypes, fractureCompletionData); + appendCompletionData(&completionsPerEclipseCellFracture, fractureCompletionData); + } + + if (exportSettings.reportCompletionsTypesIndividually()) + { + for (auto& data : completionsPerEclipseCellFracture) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + + for (auto& data : completionsPerEclipseCellFishbones) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + + for (auto& data : completionsPerEclipseCellPerforations) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + } + else + { + for (auto& data : completionsPerEclipseCellAllCompletionTypes) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + } + + progress.incrementProgress(); + } + + for (auto simWell : simWells) + { + std::map> completionsPerEclipseCell; + + std::vector fractureCompletionData = RicExportFractureCompletionsImpl::generateCompdatValuesForSimWell( + exportSettings.caseToApply(), simWell, fractureTransmissibilityExportInformationStream.get()); + appendCompletionData(&completionsPerEclipseCell, fractureCompletionData); + + for (auto& data : completionsPerEclipseCell) + { + completions.push_back(combineEclipseCellCompletions(data.second, exportSettings)); + } + + progress.incrementProgress(); + } + + const QString eclipseCaseName = exportSettings.caseToApply->caseUserDescription(); + + progress.setProgressDescription("Write Export Files"); + if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::UNIFIED_FILE) + { + const QString fileName = QString("UnifiedCompletions_%1").arg(eclipseCaseName); + sortAndExportCompletionsToFile(exportSettings.folder, fileName, completions, exportSettings.compdatExport); + progress.incrementProgress(); + } + else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL) + { + for (auto wellPath : usedWellPaths) + { + std::vector wellCompletions; + for (const auto& completion : completions) + { + if (completion.wellName() == wellPath->completions()->wellNameForExport()) + { + wellCompletions.push_back(completion); + } + } + + if (wellCompletions.empty()) continue; + + QString fileName = QString("%1_unifiedCompletions_%2").arg(wellPath->name()).arg(eclipseCaseName); + sortAndExportCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + progress.incrementProgress(); + } + } + else if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) + { + std::vector completionTypes; + completionTypes.push_back(RigCompletionData::FISHBONES); + completionTypes.push_back(RigCompletionData::FRACTURE); + completionTypes.push_back(RigCompletionData::PERFORATION); + + for (const auto& completionType : completionTypes) + { + for (auto wellPath : usedWellPaths) + { + std::vector wellCompletions; + for (const auto& completion : completions) + { + if (completion.wellName() == wellPath->completions()->wellNameForExport() && + completionType == completion.completionType()) + { + wellCompletions.push_back(completion); + } + } + + if (wellCompletions.empty()) continue; + + { + QString completionTypeText; + if (completionType == RigCompletionData::FISHBONES) completionTypeText = "Fishbones"; + if (completionType == RigCompletionData::FRACTURE) completionTypeText = "Fracture"; + if (completionType == RigCompletionData::PERFORATION) completionTypeText = "Perforation"; + + QString fileName = QString("%1_%2_%3").arg(wellPath->name()).arg(completionTypeText).arg(eclipseCaseName); + sortAndExportCompletionsToFile( + exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + } + + progress.incrementProgress(); + } + } + } + + // Export sim wells + if (exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL || + exportSettings.fileSplit == RicExportCompletionDataSettingsUi::SPLIT_ON_WELL_AND_COMPLETION_TYPE) + { + for (auto simWell : simWells) + { + std::vector wellCompletions; + for (const auto& completion : completions) + { + if (completion.wellName() == simWell->name()) + { + wellCompletions.push_back(completion); + } + } + + if (wellCompletions.empty()) continue; + + QString fileName = QString("%1_Fractures_%2").arg(simWell->name()).arg(eclipseCaseName); + sortAndExportCompletionsToFile(exportSettings.folder, fileName, wellCompletions, exportSettings.compdatExport); + + progress.incrementProgress(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RicWellPathExportCompletionDataFeatureImpl::computeStaticCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase) +{ + std::vector completionsPerEclipseCell; + + if (eclipseCase && eclipseCase->eclipseCaseData()) + { + RicExportCompletionDataSettingsUi exportSettings; + exportSettings.caseToApply = eclipseCase; + exportSettings.timeStep = 0; + exportSettings.includeFishbones = true; + exportSettings.includePerforations = true; + exportSettings.includeFractures = true; + + { + std::vector completionData = + RicFishbonesTransmissibilityCalculationFeatureImp::generateFishboneCompdatValuesUsingAdjustedCellVolume( + wellPath, exportSettings); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + + { + std::vector completionData = + RicExportFractureCompletionsImpl::generateCompdatValuesForWellPath(wellPath, exportSettings, nullptr); + + std::copy(completionData.begin(), completionData.end(), std::back_inserter(completionsPerEclipseCell)); + } + } + + return completionsPerEclipseCell; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RicWellPathExportCompletionDataFeatureImpl::computeDynamicCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStepIndex) +{ + std::vector completionsPerEclipseCell; + + if (eclipseCase && eclipseCase->eclipseCaseData()) + { + RicExportCompletionDataSettingsUi exportSettings; + exportSettings.caseToApply = eclipseCase; + exportSettings.timeStep = static_cast(timeStepIndex); + exportSettings.includeFishbones = true; + exportSettings.includePerforations = true; + exportSettings.includeFractures = true; + + completionsPerEclipseCell = generatePerforationsCompdatValues(wellPath, exportSettings); + } + + return completionsPerEclipseCell; +} + +//================================================================================================== +/// +//================================================================================================== +RigCompletionData + RicWellPathExportCompletionDataFeatureImpl::combineEclipseCellCompletions(const std::vector& completions, + const RicExportCompletionDataSettingsUi& settings) +{ + CVF_ASSERT(!completions.empty()); + + const RigCompletionData& firstCompletion = completions[0]; + + const QString& wellName = firstCompletion.wellName(); + const RigCompletionDataGridCell& cellIndexIJK = firstCompletion.completionDataGridCell(); + RigCompletionData::CompletionType completionType = firstCompletion.completionType(); + + RigCompletionData resultCompletion(wellName, cellIndexIJK, firstCompletion.firstOrderingValue()); + resultCompletion.setSecondOrderingValue(firstCompletion.secondOrderingValue()); + + bool anyNonDarcyFlowPresent = false; + for (const auto& c : completions) + { + if (c.isNonDarcyFlow()) anyNonDarcyFlowPresent = true; + } + + if (anyNonDarcyFlowPresent && completions.size() > 1) + { + QString errorMessage = + QString("Cannot combine multiple completions when Non-Darcy Flow contribution is present in same cell %1") + .arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; // Returning empty completion, should not be exported + } + + if (firstCompletion.isNonDarcyFlow()) + { + return firstCompletion; + } + + // completion type, skin factor, well bore diameter and cell direction are taken from (first) main bore, + // if no main bore they are taken from first completion + double skinfactor = firstCompletion.skinFactor(); + double wellBoreDiameter = firstCompletion.diameter(); + CellDirection cellDirection = firstCompletion.direction(); + + for (const RigCompletionData& completion : completions) + { + // Use data from the completion with largest diameter + // This is more robust than checking for main bore flag + // See also https://github.com/OPM/ResInsight/issues/2765 + if (completion.diameter() > wellBoreDiameter) + { + skinfactor = completion.skinFactor(); + wellBoreDiameter = completion.diameter(); + cellDirection = completion.direction(); + break; + } + } + + double totalTrans = 0.0; + + for (const RigCompletionData& completion : completions) + { + resultCompletion.m_metadata.reserve(resultCompletion.m_metadata.size() + completion.m_metadata.size()); + resultCompletion.m_metadata.insert( + resultCompletion.m_metadata.end(), completion.m_metadata.begin(), completion.m_metadata.end()); + + if (completion.completionType() != firstCompletion.completionType()) + { + QString errorMessage = QString("Cannot combine completions of different types in same cell %1") + .arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; // Returning empty completion, should not be exported + } + + if (completion.wellName() != firstCompletion.wellName()) + { + QString errorMessage = QString("Cannot combine completions of different types in same cell %1") + .arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; // Returning empty completion, should not be exported + } + + if (completion.transmissibility() == HUGE_VAL) + { + QString errorMessage = + QString("Transmissibility calculation has failed for cell %1").arg(cellIndexIJK.oneBasedLocalCellIndexString()); + RiaLogging::error(errorMessage); + resultCompletion.addMetadata("ERROR", errorMessage); + return resultCompletion; // Returning empty completion, should not be exported + } + + totalTrans = totalTrans + completion.transmissibility(); + } + + if (settings.compdatExport == RicExportCompletionDataSettingsUi::TRANSMISSIBILITIES) + { + resultCompletion.setCombinedValuesExplicitTrans(totalTrans, skinfactor, wellBoreDiameter, cellDirection, completionType); + } + else if (settings.compdatExport == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + // calculate trans for main bore - but as Eclipse will do it! + double transmissibilityEclipseCalculation = + RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes( + settings.caseToApply(), skinfactor, wellBoreDiameter / 2, cellIndexIJK.globalCellIndex(), cellDirection); + + double wpimult = totalTrans / transmissibilityEclipseCalculation; + resultCompletion.setCombinedValuesImplicitTransWPImult( + wpimult, skinfactor, wellBoreDiameter, cellDirection, completionType); + } + + return resultCompletion; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::sortAndExportCompletionsToFile( + const QString& folderName, + const QString& fileName, + std::vector& completions, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) +{ + // Sort completions based on grid they belong to + std::vector completionsForMainGrid; + + std::map> completionsForSubGrids; + + for (const auto& completion : completions) + { + QString gridName = completion.completionDataGridCell().lgrName(); + if (gridName.isEmpty()) + { + completionsForMainGrid.push_back(completion); + } + else + { + auto it = completionsForSubGrids.find(gridName); + if (it == completionsForSubGrids.end()) + { + completionsForSubGrids.insert( + std::pair>(gridName, std::vector{completion})); + } + else + { + it->second.push_back(completion); + } + } + } + + if (!completionsForMainGrid.empty()) + { + std::map> completionsForGrid; + completionsForGrid.insert(std::pair>("", completionsForMainGrid)); + + exportCompdatAndWpimultTables(folderName, fileName, completionsForGrid, exportType); + } + + if (!completionsForSubGrids.empty()) + { + QString lgrFileName = fileName + "_LGR"; + exportCompdatAndWpimultTables(folderName, lgrFileName, completionsForSubGrids, exportType); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::exportCompdatAndWpimultTables( + const QString& folderName, + const QString& fileName, + const std::map>& completionsPerGrid, + RicExportCompletionDataSettingsUi::CompdatExportType exportType) +{ + if (completionsPerGrid.empty()) return; + + QDir exportFolder(folderName); + if (!exportFolder.exists()) + { + bool createdPath = exportFolder.mkpath("."); + if (createdPath) + RiaLogging::info("Created export folder " + folderName); + else + RiaLogging::error("Selected output folder does not exist, and could not be created."); + } + + QString filePath = exportFolder.filePath(fileName); + QFile exportFile(filePath); + if (!exportFile.open(QIODevice::WriteOnly)) + { + RiaLogging::error(QString("Export Completions Data: Could not open the file: %1").arg(filePath)); + return; + } + + QTextStream stream(&exportFile); + RifEclipseDataTableFormatter formatter(stream); + formatter.setColumnSpacing(3); + + for (const auto& gridCompletions : completionsPerGrid) + { + std::vector completions = gridCompletions.second; + + // Sort by well name / cell index + std::sort(completions.begin(), completions.end()); + + // Print completion data + QString gridName = gridCompletions.first; + exportCompdatTableUsingFormatter(formatter, gridName, completions); + + if (exportType == RicExportCompletionDataSettingsUi::WPIMULT_AND_DEFAULT_CONNECTION_FACTORS) + { + exportWpimultTableUsingFormatter(formatter, gridName, completions); + } + } + + RiaLogging::info(QString("Successfully exported completion data to %1").arg(filePath)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::exportCompdatTableUsingFormatter( + RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) +{ + std::vector header; + + if (gridName.isEmpty()) + { + header = {RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn( + "TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn( + "KH", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn( + "Df", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0")}; + + formatter.keyword("COMPDAT"); + } + else + { + header = {RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K1"), + RifEclipseOutputTableColumn("K2"), + RifEclipseOutputTableColumn("Status"), + RifEclipseOutputTableColumn("SAT"), + RifEclipseOutputTableColumn( + "TR", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIAM"), + RifEclipseOutputTableColumn( + "KH", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("S"), + RifEclipseOutputTableColumn( + "Df", RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC)), + RifEclipseOutputTableColumn("DIR"), + RifEclipseOutputTableColumn("r0")}; + + formatter.keyword("COMPDATL"); + } + formatter.header(header); + + RigCompletionData::CompletionType currentCompletionType = RigCompletionData::CT_UNDEFINED; + + for (const RigCompletionData& data : completionData) + { + if (data.transmissibility() == 0.0 || data.wpimult() == 0.0) + { + // Don't export completions without transmissibility + continue; + } + + if (currentCompletionType != data.completionType()) + { + // The completions are sorted by completion type, write out a heading when completion type changes + + QString txt; + if (data.completionType() == RigCompletionData::FISHBONES) txt = "Fishbones"; + if (data.completionType() == RigCompletionData::FRACTURE) txt = "Fracture"; + if (data.completionType() == RigCompletionData::PERFORATION) txt = "Perforation"; + + formatter.comment("---- Completions for completion type " + txt + " ----"); + + currentCompletionType = data.completionType(); + } + + for (const RigCompletionMetaData& metadata : data.metadata()) + { + formatter.comment(QString("%1 : %2").arg(metadata.name).arg(metadata.comment)); + } + formatter.add(data.wellName()); + + if (!gridName.isEmpty()) + { + formatter.add(gridName); + } + + formatter.addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexI()) + .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexJ()) + .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()) + .addZeroBasedCellIndex(data.completionDataGridCell().localCellIndexK()); + switch (data.connectionState()) + { + case OPEN: + formatter.add("OPEN"); + break; + case SHUT: + formatter.add("SHUT"); + break; + case AUTO: + formatter.add("AUTO"); + break; + } + + if (RigCompletionData::isDefaultValue(data.saturation())) + formatter.add("1*"); + else + formatter.add(data.saturation()); + + if (data.isNonDarcyFlow() || RigCompletionData::isDefaultValue(data.transmissibility())) + { + if (RigCompletionData::isDefaultValue(data.transmissibility())) + formatter.add("1*"); + else + formatter.add(data.transmissibility()); + + if (RigCompletionData::isDefaultValue(data.diameter())) + formatter.add("1*"); + else + formatter.add(data.diameter()); + if (RigCompletionData::isDefaultValue(data.kh())) + formatter.add("1*"); + else + formatter.add(data.kh()); + if (RigCompletionData::isDefaultValue(data.skinFactor())) + formatter.add("1*"); + else + formatter.add(data.skinFactor()); + if (RigCompletionData::isDefaultValue(data.dFactor())) + formatter.add("1*"); + else + formatter.add(-data.dFactor()); + + switch (data.direction()) + { + case DIR_I: + formatter.add("'X'"); + break; + case DIR_J: + formatter.add("'Y'"); + break; + case DIR_K: + formatter.add("'Z'"); + break; + default: + formatter.add("'Z'"); + break; + } + } + else + { + formatter.add(data.transmissibility()); + + // Based on feedback from Shunping for COMPDATL, hhgs required COMPDAT + // Always include diameter + // See https://github.com/OPM/ResInsight/issues/2517 + // See https://github.com/OPM/ResInsight/issues/2709 + if (RigCompletionData::isDefaultValue(data.diameter())) + formatter.add("1*"); + else + formatter.add(data.diameter()); + } + + formatter.rowCompleted(); + } + formatter.tableCompleted(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::exportWpimultTableUsingFormatter( + RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData) +{ + std::vector header; + + if (gridName.isEmpty()) + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("Mult"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + }; + formatter.keyword("WPIMULT"); + } + else + { + header = { + RifEclipseOutputTableColumn("Well"), + RifEclipseOutputTableColumn("LgrName"), + RifEclipseOutputTableColumn("Mult"), + RifEclipseOutputTableColumn("I"), + RifEclipseOutputTableColumn("J"), + RifEclipseOutputTableColumn("K"), + }; + formatter.keyword("WPIMULTL"); + } + formatter.header(header); + + for (auto& completion : completionData) + { + if (completion.wpimult() == 0.0 || completion.isDefaultValue(completion.wpimult())) + { + continue; + } + + formatter.add(completion.wellName()); + formatter.add(completion.wpimult()); + + if (!gridName.isEmpty()) + { + formatter.add(gridName); + } + + formatter.addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexI()) + .addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexJ()) + .addZeroBasedCellIndex(completion.completionDataGridCell().localCellIndexK()); + formatter.rowCompleted(); + } + + formatter.tableCompleted(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::generatePerforationsCompdatValues( + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings) +{ + RiaEclipseUnitTools::UnitSystem unitSystem = settings.caseToApply->eclipseCaseData()->unitsType(); + + std::vector completionData; + const RigActiveCellInfo* activeCellInfo = settings.caseToApply->eclipseCaseData()->activeCellInfo(RiaDefines::MATRIX_MODEL); + + if (wellPath->perforationIntervalCollection()->isChecked()) + { + for (const RimPerforationInterval* interval : wellPath->perforationIntervalCollection()->perforations()) + { + if (!interval->isChecked()) continue; + if (!interval->isActiveOnDate(settings.caseToApply->timeStepDates()[settings.timeStep])) continue; + + using namespace std; + pair, vector> perforationPointsAndMD = + wellPath->wellPathGeometry()->clippedPointSubset(interval->startMD(), interval->endMD()); + + std::vector intersectedCells = + RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( + settings.caseToApply->eclipseCaseData(), perforationPointsAndMD.first, perforationPointsAndMD.second); + + for (auto& cell : intersectedCells) + { + bool cellIsActive = activeCellInfo->isActive(cell.globCellIndex); + if (!cellIsActive) continue; + + RigCompletionData completion(wellPath->completions()->wellNameForExport(), + RigCompletionDataGridCell(cell.globCellIndex, settings.caseToApply->mainGrid()), + cell.startMD); + + CellDirection direction = + calculateDirectionInCell(settings.caseToApply, cell.globCellIndex, cell.intersectionLengthsInCellCS); + + double transmissibility = + RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(settings.caseToApply, + wellPath, + cell.intersectionLengthsInCellCS, + interval->skinFactor(), + interval->diameter(unitSystem) / 2, + cell.globCellIndex, + settings.useLateralNTG); + + completion.setTransAndWPImultBackgroundDataFromPerforation( + transmissibility, interval->skinFactor(), interval->diameter(unitSystem), direction); + completion.addMetadata("Perforation Completion", + QString("MD In: %1 - MD Out: %2").arg(cell.startMD).arg(cell.endMD) + + QString(" Transmissibility: ") + QString::number(transmissibility)); + completionData.push_back(completion); + } + } + } + + return completionData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicWellPathExportCompletionDataFeatureImpl::wellSegmentLocationOrdering(const WellSegmentLocation& first, + const WellSegmentLocation& second) +{ + return first.measuredDepth < second.measuredDepth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations(const RimEclipseCase* caseToApply, + const RimWellPath* wellPath) +{ + std::vector fishbonesSubs; + + if (wellPath->fishbonesCollection()->isChecked()) + { + for (RimFishbonesMultipleSubs* subs : wellPath->fishbonesCollection()->fishbonesSubs()) + { + if (subs->isActive()) + { + fishbonesSubs.push_back(subs); + } + } + } + + return findWellSegmentLocations(caseToApply, wellPath, fishbonesSubs); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RicWellPathExportCompletionDataFeatureImpl::findWellSegmentLocations( + const RimEclipseCase* caseToApply, + const RimWellPath* wellPath, + const std::vector& fishbonesSubs) +{ + std::vector wellSegmentLocations; + for (RimFishbonesMultipleSubs* subs : fishbonesSubs) + { + for (auto& sub : subs->installedLateralIndices()) + { + double measuredDepth = subs->measuredDepth(sub.subIndex); + cvf::Vec3d position = wellPath->wellPathGeometry()->interpolatedPointAlongWellPath(measuredDepth); + WellSegmentLocation location = WellSegmentLocation(subs, measuredDepth, -position.z(), sub.subIndex); + + for (size_t lateralIndex : sub.lateralIndices) + { + location.laterals.push_back(WellSegmentLateral(lateralIndex)); + } + wellSegmentLocations.push_back(location); + } + } + std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering); + + assignLateralIntersectionsAndBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations); + + return wellSegmentLocations; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersections(const RimEclipseCase* caseToApply, + WellSegmentLocation* location, + int* branchNum, + int* segmentNum) +{ + for (WellSegmentLateral& lateral : location->laterals) + { + ++(*branchNum); + lateral.branchNumber = (*branchNum); + + std::vector> lateralCoordMDPairs = + location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); + + if (lateralCoordMDPairs.empty()) + { + continue; + } + + std::vector lateralCoords; + std::vector lateralMDs; + + lateralCoords.reserve(lateralCoordMDPairs.size()); + lateralMDs.reserve(lateralCoordMDPairs.size()); + + for (auto& coordMD : lateralCoordMDPairs) + { + lateralCoords.push_back(coordMD.first); + lateralMDs.push_back(coordMD.second); + } + + std::vector intersections = + RigWellPathIntersectionTools::findCellIntersectionInfosAlongPath( + caseToApply->eclipseCaseData(), lateralCoords, lateralMDs); + double previousExitMD = lateralMDs.front(); + double previousExitTVD = lateralCoords.front().z(); + + int attachedSegmentNumber = location->icdSegmentNumber; + for (const auto& cellIntInfo : intersections) + { + ++(*segmentNum); + WellSegmentLateralIntersection lateralIntersection((*segmentNum), + attachedSegmentNumber, + cellIntInfo.globCellIndex, + cellIntInfo.endMD - previousExitMD, + cellIntInfo.endPoint.z() - previousExitTVD, + cellIntInfo.intersectionLengthsInCellCS); + + lateral.intersections.push_back(lateralIntersection); + + attachedSegmentNumber = (*segmentNum); + previousExitMD = cellIntInfo.endMD; + previousExitTVD = cellIntInfo.endPoint.z(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::assignLateralIntersectionsAndBranchAndSegmentNumbers( + const RimEclipseCase* caseToApply, + std::vector* locations) +{ + int segmentNumber = 1; + int branchNumber = 1; + + // First loop over the locations so that each segment on the main stem is an incremental number + for (WellSegmentLocation& location : *locations) + { + location.segmentNumber = ++segmentNumber; + location.icdBranchNumber = ++branchNumber; + location.icdSegmentNumber = ++segmentNumber; + } + + // Then assign branch and segment numbers to each lateral parts + for (WellSegmentLocation& location : *locations) + { + assignLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicWellPathExportCompletionDataFeatureImpl::appendCompletionData( + std::map>* completionData, + const std::vector& data) +{ + for (auto& completion : data) + { + auto it = completionData->find(completion.completionDataGridCell()); + if (it != completionData->end()) + { + it->second.push_back(completion); + } + else + { + completionData->insert(std::pair>( + completion.completionDataGridCell(), std::vector{completion})); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CellDirection RicWellPathExportCompletionDataFeatureImpl::calculateDirectionInCell(RimEclipseCase* eclipseCase, + size_t globalCellIndex, + const cvf::Vec3d& lengthsInCell) +{ + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); + cvf::ref dxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); + cvf::ref dyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); + cvf::ref dzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + + double xLengthFraction = fabs(lengthsInCell.x() / dxAccessObject->cellScalarGlobIdx(globalCellIndex)); + double yLengthFraction = fabs(lengthsInCell.y() / dyAccessObject->cellScalarGlobIdx(globalCellIndex)); + double zLengthFraction = fabs(lengthsInCell.z() / dzAccessObject->cellScalarGlobIdx(globalCellIndex)); + + if (xLengthFraction > yLengthFraction && xLengthFraction > zLengthFraction) + { + return CellDirection::DIR_I; + } + else if (yLengthFraction > xLengthFraction && yLengthFraction > zLengthFraction) + { + return CellDirection::DIR_J; + } + else + { + return CellDirection::DIR_K; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibility(RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + const cvf::Vec3d& internalCellLengths, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + bool useLateralNTG, + size_t volumeScaleConstant, + CellDirection directionForVolumeScaling) +{ + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); + cvf::ref dxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); + cvf::ref dyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); + cvf::ref dzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); + cvf::ref permxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); + cvf::ref permyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); + cvf::ref permzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); + + double ntg = 1.0; + size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + if (ntgResIdx != cvf::UNDEFINED_SIZE_T) + { + cvf::ref ntgAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); + ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); + } + double latNtg = useLateralNTG ? ntg : 1.0; + + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); + double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); + double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); + + double darcy = RiaEclipseUnitTools::darcysConstant(wellPath->unitSystem()); + + if (volumeScaleConstant != 1) + { + if (directionForVolumeScaling == CellDirection::DIR_I) dx = dx / volumeScaleConstant; + if (directionForVolumeScaling == CellDirection::DIR_J) dy = dy / volumeScaleConstant; + if (directionForVolumeScaling == CellDirection::DIR_K) dz = dz / volumeScaleConstant; + } + + double transx = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + internalCellLengths.x() * latNtg, permy, permz, dy, dz, wellRadius, skinFactor, darcy); + double transy = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + internalCellLengths.y() * latNtg, permx, permz, dx, dz, wellRadius, skinFactor, darcy); + double transz = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + internalCellLengths.z() * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); + + return RigTransmissibilityEquations::totalConnectionFactor(transx, transy, transz); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RicWellPathExportCompletionDataFeatureImpl::calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + CellDirection direction) +{ + RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DX"); + cvf::ref dxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DY"); + cvf::ref dyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "DZ"); + cvf::ref dzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "DZ"); + + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMX"); + cvf::ref permxAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMX"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMY"); + cvf::ref permyAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMY"); + eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "PERMZ"); + cvf::ref permzAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "PERMZ"); + + double ntg = 1.0; + size_t ntgResIdx = eclipseCase->results(RiaDefines::MATRIX_MODEL)->findOrLoadScalarResult(RiaDefines::STATIC_NATIVE, "NTG"); + if (ntgResIdx != cvf::UNDEFINED_SIZE_T) + { + cvf::ref ntgAccessObject = + RigResultAccessorFactory::createFromUiResultName(eclipseCaseData, 0, RiaDefines::MATRIX_MODEL, 0, "NTG"); + ntg = ntgAccessObject->cellScalarGlobIdx(globalCellIndex); + } + + double dx = dxAccessObject->cellScalarGlobIdx(globalCellIndex); + double dy = dyAccessObject->cellScalarGlobIdx(globalCellIndex); + double dz = dzAccessObject->cellScalarGlobIdx(globalCellIndex); + double permx = permxAccessObject->cellScalarGlobIdx(globalCellIndex); + double permy = permyAccessObject->cellScalarGlobIdx(globalCellIndex); + double permz = permzAccessObject->cellScalarGlobIdx(globalCellIndex); + + RiaEclipseUnitTools::UnitSystem units = eclipseCaseData->unitsType(); + double darcy = RiaEclipseUnitTools::darcysConstant(units); + + double trans = cvf::UNDEFINED_DOUBLE; + if (direction == CellDirection::DIR_I) + { + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + dx, permy, permz, dy, dz, wellRadius, skinFactor, darcy); + } + else if (direction == CellDirection::DIR_J) + { + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + dy, permx, permz, dx, dz, wellRadius, skinFactor, darcy); + } + else if (direction == CellDirection::DIR_K) + { + trans = RigTransmissibilityEquations::wellBoreTransmissibilityComponent( + dz * ntg, permy, permx, dy, dx, wellRadius, skinFactor, darcy); + } + + return trans; +} diff --git a/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h new file mode 100644 index 0000000000..0836e4c073 --- /dev/null +++ b/ApplicationCode/Commands/CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h @@ -0,0 +1,200 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RigCompletionData.h" + +#include "RicExportCompletionDataSettingsUi.h" + +#include "cvfBase.h" +#include "cvfVector3.h" + +#include + +class RigCell; +class RigEclipseCaseData; +class RigMainGrid; +class RimEclipseCase; +class RimFishbonesMultipleSubs; +class RimSimWellInView; +class RimWellPath; +class RifEclipseDataTableFormatter; +class RigVirtualPerforationTransmissibilities; + +//================================================================================================== +/// +//================================================================================================== +struct WellSegmentLateralIntersection +{ + WellSegmentLateralIntersection(int segmentNumber, + int attachedSegmentNumber, + size_t globalCellIndex, + double length, + double depth, + const cvf::Vec3d& lengthsInCell) + : segmentNumber(segmentNumber) + , attachedSegmentNumber(attachedSegmentNumber) + , globalCellIndex(globalCellIndex) + , mdFromPreviousIntersection(length) + , tvdChangeFromPreviousIntersection(depth) + , lengthsInCell(lengthsInCell) + , mainBoreCell(false) + { + } + + int segmentNumber; + int attachedSegmentNumber; + size_t globalCellIndex; + bool mainBoreCell; + double mdFromPreviousIntersection; + double tvdChangeFromPreviousIntersection; + cvf::Vec3d lengthsInCell; +}; + +//================================================================================================== +/// +//================================================================================================== +struct WellSegmentLateral +{ + WellSegmentLateral(size_t lateralIndex) + : lateralIndex(lateralIndex) + , branchNumber(0) + { + } + + size_t lateralIndex; + int branchNumber; + std::vector intersections; +}; + +//================================================================================================== +/// +//================================================================================================== +struct WellSegmentLocation +{ + WellSegmentLocation(const RimFishbonesMultipleSubs* subs, + double measuredDepth, + double trueVerticalDepth, + size_t subIndex, + int segmentNumber = -1) + : fishbonesSubs(subs) + , measuredDepth(measuredDepth) + , trueVerticalDepth(trueVerticalDepth) + , subIndex(subIndex) + , segmentNumber(segmentNumber) + , icdBranchNumber(-1) + , icdSegmentNumber(-1) + { + } + + const RimFishbonesMultipleSubs* fishbonesSubs; + double measuredDepth; + double trueVerticalDepth; + size_t subIndex; + int segmentNumber; + int icdBranchNumber; + int icdSegmentNumber; + std::vector laterals; +}; + +//================================================================================================== +/// +//================================================================================================== +class RicWellPathExportCompletionDataFeatureImpl +{ + +public: + static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, + const RimWellPath* wellPath); + + static std::vector findWellSegmentLocations(const RimEclipseCase* caseToApply, + const RimWellPath* wellPath, + const std::vector& fishbonesSubs); + + static CellDirection calculateDirectionInCell(RimEclipseCase* eclipseCase, + size_t globalCellIndex, + const cvf::Vec3d& lengthsInCell); + + static double calculateTransmissibility(RimEclipseCase* eclipseCase, + const RimWellPath* wellPath, + const cvf::Vec3d& internalCellLengths, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + bool useLateralNTG, + size_t volumeScaleConstant = 1, + CellDirection directionForVolumeScaling = CellDirection::DIR_I); + + + static void exportCompletions(const std::vector& wellPaths, + const std::vector& simWells, + const RicExportCompletionDataSettingsUi& exportSettings); + + static std::vector computeStaticCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase); + + static std::vector computeDynamicCompletionsForWellPath(RimWellPath* wellPath, + RimEclipseCase* eclipseCase, + size_t timeStepIndex); + +private: + static double calculateTransmissibilityAsEclipseDoes(RimEclipseCase* eclipseCase, + double skinFactor, + double wellRadius, + size_t globalCellIndex, + CellDirection direction); + + static RigCompletionData combineEclipseCellCompletions(const std::vector& completions, + const RicExportCompletionDataSettingsUi& settings); + + static void sortAndExportCompletionsToFile(const QString& exportFolder, + const QString& fileName, + std::vector& completions, + RicExportCompletionDataSettingsUi::CompdatExportType exportType); + + static void exportCompdatAndWpimultTables(const QString& folderName, + const QString& fileName, + const std::map>& completionsPerGrid, + RicExportCompletionDataSettingsUi::CompdatExportType exportType); + + static void exportCompdatTableUsingFormatter(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData); + + static void exportWpimultTableUsingFormatter(RifEclipseDataTableFormatter& formatter, + const QString& gridName, + const std::vector& completionData); + + static std::vector generatePerforationsCompdatValues(const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings); + + static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, + const WellSegmentLocation& second); + + static void assignLateralIntersections(const RimEclipseCase* caseToApply, + WellSegmentLocation* location, + int* branchNum, + int* segmentNum); + + static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, + std::vector* locations); + + static void appendCompletionData(std::map>* completionData, + const std::vector& data); +}; diff --git a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake index 9795ba6966..e13a41b661 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/CrossSectionCommands/CMakeLists_files.cmake @@ -1,23 +1,20 @@ -# 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}RicAppendIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSimWellIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellPathIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPolylineIntersectionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewAzimuthDipIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPolylineIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewAzimuthDipIntersectionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCopyIntersectionsToAllViewsInCaseFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -28,4 +25,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\CrossSection" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\CrossSection" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp index 0b463e7793..9d6f30a044 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicAppendIntersectionFeature.cpp @@ -19,9 +19,11 @@ #include "RicAppendIntersectionFeature.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimTensorResults.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -49,7 +51,7 @@ void RicAppendIntersectionFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&collection); CVF_ASSERT(collection.size() == 1); - RimIntersectionCollection* intersectionCollection = NULL; + RimIntersectionCollection* intersectionCollection = nullptr; collection[0]->firstAncestorOrThisOfType(intersectionCollection); CVF_ASSERT(intersectionCollection); @@ -71,7 +73,7 @@ void RicAppendIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicAppendIntersectionFeatureCmd::RicAppendIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection) { } @@ -102,11 +104,18 @@ void RicAppendIntersectionFeatureCmd::redo() intersection->name = QString("Intersection"); m_intersectionCollection->appendIntersectionAndUpdate(intersection); - RimView* view = nullptr; + RimGridView* view = nullptr; m_intersectionCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated property filter view->showGridCells(false); + + RimGeoMechView* geoMechView = nullptr; + geoMechView = dynamic_cast(view); + if (geoMechView) + { + geoMechView->tensorResults()->setShowTensors(false); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp new file mode 100644 index 0000000000..8d12763776 --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.cpp @@ -0,0 +1,237 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCopyIntersectionsToAllViewsInCaseFeature.h" + +#include "RimIntersection.h" +#include "RimIntersectionBox.h" +#include "RimIntersectionCollection.h" +#include "RimGridView.h" +#include "RimCase.h" +#include "RimGridView.h" +#include "RimEclipseCase.h" + +#include "cafCmdExecCommandManager.h" +#include "cafSelectionManagerTools.h" +#include "cafPdmUiItem.h" + +#include "cvfAssert.h" + +#include + +CAF_CMD_SOURCE_INIT(RicCopyIntersectionsToAllViewsInCaseFeature, "RicCopyIntersectionsToAllViewsInCaseFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// Internal definitions +//-------------------------------------------------------------------------------------------------- +enum SelectionComposition {SEL_INVALID, SEL_COLLECTION, SEL_INTERSECTIONS, SEL_INTERSECTION_BOXES, SEL_BOTH_INTERSECTION_TYPES }; + +static RimIntersectionCollection* selectedIntersectionCollection(); +static std::vector selectedIntersections(); +static std::vector selectedIntersectionBoxes(); +static SelectionComposition selectionComposition(); +static RimCase* commonGridCase(std::vector selectedItems); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCopyIntersectionsToAllViewsInCaseFeature::isCommandEnabled() +{ + return selectionComposition() != SEL_INVALID; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::onActionTriggered(bool isChecked) +{ + RimCase* gridCase = nullptr; + std::vector selItems; + caf::SelectionManager::instance()->selectedItems(selItems); + caf::PdmObjectHandle* objHandle = dynamic_cast(selItems.front()); + if (objHandle) objHandle->firstAncestorOrThisOfType(gridCase); + + if (gridCase) + { + SelectionComposition compostion = selectionComposition(); + if (compostion == SEL_COLLECTION) + { + RimIntersectionCollection* coll = selectedIntersectionCollection(); + copyIntersectionsToOtherViews(*gridCase, coll->intersections()); + copyIntersectionBoxesToOtherViews(*gridCase, coll->intersectionBoxes()); + } + + std::vector selIntersections = selectedIntersections(); + std::vector selIntersectionBoxes = selectedIntersectionBoxes(); + + if (compostion == SEL_INTERSECTIONS || compostion == SEL_BOTH_INTERSECTION_TYPES) + { + copyIntersectionsToOtherViews(*gridCase, selIntersections); + } + if (compostion == SEL_INTERSECTION_BOXES || compostion == SEL_BOTH_INTERSECTION_TYPES) + { + copyIntersectionBoxesToOtherViews(*gridCase, selIntersectionBoxes); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Copy.png")); + actionToSetup->setText("Copy intersections to all views in case"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionsToOtherViews(RimCase& gridCase, std::vector intersections) +{ + for (RimIntersection* intersection : intersections) + { + for (Rim3dView* const view : gridCase.views()) + { + RimGridView* currGridView = dynamic_cast(view); + RimGridView* parentView = nullptr; + intersection->firstAncestorOrThisOfType(parentView); + + if (currGridView && parentView != nullptr && parentView != currGridView) + { + RimIntersectionCollection* destCollection = currGridView->crossSectionCollection(); + + RimIntersection* copy = dynamic_cast(intersection->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(copy); + + destCollection->appendIntersectionAndUpdate(copy); + + // Resolve references after object has been inserted into the project data model + copy->resolveReferencesRecursively(); + copy->updateConnectedEditors(); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCopyIntersectionsToAllViewsInCaseFeature::copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector intersectionBoxes) +{ + for (RimIntersectionBox* intersectionBox : intersectionBoxes) + { + for (Rim3dView* const view : gridCase.views()) + { + RimGridView* currGridView = dynamic_cast(view); + RimGridView* parentView = nullptr; + intersectionBox->firstAncestorOrThisOfType(parentView); + + if (currGridView && parentView != nullptr && parentView != currGridView) + { + RimIntersectionCollection* destCollection = currGridView->crossSectionCollection(); + + RimIntersectionBox* copy = dynamic_cast(intersectionBox->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(copy); + + destCollection->appendIntersectionBoxAndUpdate(copy); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* selectedIntersectionCollection() +{ + std::vector selObjects = caf::selectedObjectsByType(); + return !selObjects.empty() ? selObjects[0] : nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector selectedIntersections() +{ + return caf::selectedObjectsByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector selectedIntersectionBoxes() +{ + return caf::selectedObjectsByType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +SelectionComposition selectionComposition() +{ + std::vector allSelectedObjects; + caf::SelectionManager::instance()->selectedItems(allSelectedObjects); + + RimCase* gridCase = commonGridCase(allSelectedObjects); + if (gridCase && gridCase->gridViews().size() > 1) + { + RimIntersectionCollection* selColl = selectedIntersectionCollection(); + std::vector selIntersections = selectedIntersections(); + std::vector selIntersectionBoxes = selectedIntersectionBoxes(); + + if (selColl) + { + if (allSelectedObjects.size() == 1) return SEL_COLLECTION; + } + else + { + if (!selIntersections.empty() && !selIntersectionBoxes.empty()) return SEL_BOTH_INTERSECTION_TYPES; + else if (!selIntersections.empty()) return SEL_INTERSECTIONS; + else if (!selIntersectionBoxes.empty()) return SEL_INTERSECTION_BOXES; + } + } + return SEL_INVALID; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* commonGridCase(std::vector selectedItems) +{ + RimCase* gridCase = nullptr; + + for (caf::PdmUiItem* item : selectedItems) + { + caf::PdmObjectHandle* obj = dynamic_cast(item); + if (!obj) + { + continue; + } + + RimCase* itemCase = nullptr; + obj->firstAncestorOrThisOfType(itemCase); + + if (gridCase == nullptr) gridCase = itemCase; + else if (gridCase != itemCase) return nullptr; + } + return gridCase; +} diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h new file mode 100644 index 0000000000..17de22fb44 --- /dev/null +++ b/ApplicationCode/Commands/CrossSectionCommands/RicCopyIntersectionsToAllViewsInCaseFeature.h @@ -0,0 +1,49 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafCmdExecuteCommand.h" +#include "cafPdmPointer.h" + +class RimCase; +class RimIntersection; +class RimIntersectionBox; +class RimIntersectionCollection; + + +//================================================================================================== +/// +//================================================================================================== +class RicCopyIntersectionsToAllViewsInCaseFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + + void copyIntersectionsToOtherViews(RimCase& gridCase, std::vector intersections); + void copyIntersectionBoxesToOtherViews(RimCase& gridCase, std::vector intersectionBoxes); +}; + + diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp index 6205e3d840..946c26fdae 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewAzimuthDipIntersectionFeature.cpp @@ -23,9 +23,9 @@ #include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -61,10 +61,10 @@ bool RicNewAzimuthDipIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewAzimuthDipIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; - RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection); + RicNewAzimuthDipIntersectionFeatureCmd* cmd = new RicNewAzimuthDipIntersectionFeatureCmd(activeView->crossSectionCollection()); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } @@ -81,7 +81,7 @@ void RicNewAzimuthDipIntersectionFeature::setupActionLook(QAction* actionToSetup /// //-------------------------------------------------------------------------------------------------- RicNewAzimuthDipIntersectionFeatureCmd::RicNewAzimuthDipIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection) { } @@ -125,7 +125,7 @@ void RicNewAzimuthDipIntersectionFeatureCmd::redo() m_intersectionCollection->appendIntersectionAndUpdate(intersection); RiuSelectionManager::instance()->deleteAllItems(); - RiuMainWindow::instance()->selectAsCurrentItem(intersection); + Riu3DMainWindowTools::selectAsCurrentItem(intersection); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp index ac7f045f5b..35c6ebfa72 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewPolylineIntersectionFeature.cpp @@ -24,9 +24,9 @@ #include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -60,10 +60,10 @@ bool RicNewPolylineIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewPolylineIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; - RicNewPolylineIntersectionFeatureCmd* cmd = new RicNewPolylineIntersectionFeatureCmd(activeView->crossSectionCollection); + RicNewPolylineIntersectionFeatureCmd* cmd = new RicNewPolylineIntersectionFeatureCmd(activeView->crossSectionCollection()); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } @@ -80,7 +80,7 @@ void RicNewPolylineIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicNewPolylineIntersectionFeatureCmd::RicNewPolylineIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection) { } @@ -116,7 +116,7 @@ void RicNewPolylineIntersectionFeatureCmd::redo() RiuSelectionManager::instance()->deleteAllItems(); - RiuMainWindow::instance()->selectAsCurrentItem(intersection); + Riu3DMainWindowTools::selectAsCurrentItem(intersection); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp index d20238f06b..f27011a7b6 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewSimWellIntersectionFeature.cpp @@ -52,11 +52,11 @@ void RicNewSimWellIntersectionFeature::onActionTriggered(bool isChecked) RimSimWellInView* simWell = collection[0]; - RimEclipseView* eclView = NULL; + RimEclipseView* eclView = nullptr; simWell->firstAncestorOrThisOfType(eclView); CVF_ASSERT(eclView); - RicNewSimWellIntersectionCmd* cmd = new RicNewSimWellIntersectionCmd(eclView->crossSectionCollection, simWell); + RicNewSimWellIntersectionCmd* cmd = new RicNewSimWellIntersectionCmd(eclView->crossSectionCollection(), simWell); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } @@ -73,7 +73,7 @@ void RicNewSimWellIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicNewSimWellIntersectionCmd::RicNewSimWellIntersectionCmd(RimIntersectionCollection* intersectionCollection, RimSimWellInView* simWell) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection), m_simWell(simWell) { diff --git a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp index a778aa82c6..b885afe50b 100644 --- a/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp +++ b/ApplicationCode/Commands/CrossSectionCommands/RicNewWellPathIntersectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimIntersection.h" #include "RimIntersectionCollection.h" #include "RimWellPath.h" -#include "RimView.h" +#include "RimGridView.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -56,7 +56,7 @@ bool RicNewWellPathIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicNewWellPathIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; std::vector collection; @@ -65,7 +65,7 @@ void RicNewWellPathIntersectionFeature::onActionTriggered(bool isChecked) RimWellPath* wellPath = collection[0]; - RicNewWellPathIntersectionFeatureCmd* cmd = new RicNewWellPathIntersectionFeatureCmd(activeView->crossSectionCollection, wellPath); + RicNewWellPathIntersectionFeatureCmd* cmd = new RicNewWellPathIntersectionFeatureCmd(activeView->crossSectionCollection(), wellPath); caf::CmdExecCommandManager::instance()->processExecuteCommand(cmd); } @@ -82,7 +82,7 @@ void RicNewWellPathIntersectionFeature::setupActionLook(QAction* actionToSetup) /// //-------------------------------------------------------------------------------------------------- RicNewWellPathIntersectionFeatureCmd::RicNewWellPathIntersectionFeatureCmd(RimIntersectionCollection* intersectionCollection, RimWellPath* wellPath) - : CmdExecuteCommand(NULL), + : CmdExecuteCommand(nullptr), m_intersectionCollection(intersectionCollection), m_wellPath(wellPath) { diff --git a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake index c0e17230fe..1bfbc3825f 100644 --- a/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/CMakeLists_files.cmake @@ -1,47 +1,46 @@ -# 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}RicAddEclipseInputPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.h -${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.h -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.h -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.h -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.h -${CEE_CURRENT_LIST_DIR}RicEclipseHideFaultFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddEclipseInputPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicComputeStatisticsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFromFilesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupExec.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertExec.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewExec.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportInputEclipseCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicApplyPropertyFilterAsCellResultFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseTimeStepFilterFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewInViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseHideFaultFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddEclipseInputPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicComputeStatisticsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCreateGridCaseGroupFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupExec.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseCaseNewGroupFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertExec.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterInsertFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewExec.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportInputEclipseCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewStatisticsCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicApplyPropertyFilterAsCellResultFeature.cpp -${CEE_CURRENT_LIST_DIR}RicImportEclipseCaseTimeStepFilterFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipsePropertyFilterNewInViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseHideFaultFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddEclipseInputPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicComputeStatisticsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateGridCaseGroupFromFilesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseCaseNewGroupFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterInsertFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportInputEclipseCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewStatisticsCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicApplyPropertyFilterAsCellResultFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicImportEclipseCaseTimeStepFilterFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipsePropertyFilterNewInViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseHideFaultFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -52,4 +51,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Eclipse" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Eclipse" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake b/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake index 27f3295bad..333d21e9ac 100644 --- a/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/EclipseCommands/EclipseWell/CMakeLists_files.cmake @@ -1,17 +1,13 @@ -# 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}RicEclipseWellFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicEclipseWellShowFeatures.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellShowFeatures.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicEclipseWellFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicEclipseWellShowFeatures.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellShowFeatures.cpp ) list(APPEND CODE_HEADER_FILES @@ -22,4 +18,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Eclipse\\Well" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Eclipse\\Well" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp index de61fc1a35..06e9b95963 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicAddEclipseInputPropertyFeature.cpp @@ -23,7 +23,7 @@ #include "RimEclipseInputCase.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicAddEclipseInputPropertyFeature, "RicAddEclipseInputProper //-------------------------------------------------------------------------------------------------- bool RicAddEclipseInputPropertyFeature::isCommandEnabled() { - return selectedInputPropertyCollection() != NULL; + return selectedInputPropertyCollection() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -49,7 +49,7 @@ void RicAddEclipseInputPropertyFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Select Eclipse Input Property Files", defaultDir, "All Files (*.* *)"); if (fileNames.isEmpty()) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp index 939b6aca65..242a471d54 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicComputeStatisticsFeature.cpp @@ -43,10 +43,10 @@ bool RicComputeStatisticsFeature::isCommandEnabled() RimEclipseStatisticsCase* statisticsCase = selection[0]; if (statisticsCase) { - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; statisticsCase->firstAncestorOrThisOfType(gridCaseGroup); - RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : NULL; + RimCaseCollection* caseCollection = gridCaseGroup ? gridCaseGroup->caseCollection() : nullptr; return caseCollection ? caseCollection->reservoirs.size() > 0 : false; } } diff --git a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp new file mode 100644 index 0000000000..567ae6c791 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.cpp @@ -0,0 +1,80 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicCreateGridCaseGroupFromFilesFeature.h" + +#include "RiaApplication.h" +#include "RiaImportEclipseCaseTools.h" + +#include "RicFileHierarchyDialog.h" + +#include "RimEclipseCaseCollection.h" +#include "RiuMultiCaseImportDialog.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicCreateGridCaseGroupFromFilesFeature, "RicCreateGridCaseGroupFromFilesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicCreateGridCaseGroupFromFilesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseGroupFromFilesFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::runRecursiveSearchDialog(nullptr, + "Create Grid Case Group from Files", + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList(".EGRID")); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if (result.ok) + { + // Remember the path to next time + app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); + + RiaImportEclipseCaseTools::addEclipseCases(result.files); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateGridCaseGroupFromFilesFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/CreateGridCaseGroup16x16.png")); + actionToSetup->setText("&Create Grid Case Group from Files Recursively"); +} diff --git a/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h new file mode 100644 index 0000000000..94ef8a8bb5 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicCreateGridCaseGroupFromFilesFeature.h @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicCreateGridCaseGroupFromFilesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + + RicCreateGridCaseGroupFromFilesFeature() : m_pathFilter("*"), m_fileNameFilter("*") {} + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + QString m_pathFilter; + QString m_fileNameFilter; + +}; + + diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp index 3f0fe88c35..134e5c4fbe 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipseCaseNewGroupExec.cpp @@ -27,13 +27,13 @@ #include "RimOilField.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RicEclipseCaseNewGroupExec::RicEclipseCaseNewGroupExec() - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { } @@ -60,7 +60,7 @@ void RicEclipseCaseNewGroupExec::redo() RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = proj->activeOilField() ? proj->activeOilField()->analysisModels() : nullptr; if (analysisModels) { @@ -73,8 +73,9 @@ void RicEclipseCaseNewGroupExec::redo() analysisModels->caseGroups().push_back(createdObject); analysisModels->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(createdObject); - RiuMainWindow::instance()->setExpanded(createdObject); + + Riu3DMainWindowTools::selectAsCurrentItem(createdObject); + Riu3DMainWindowTools::setExpanded(createdObject); } } diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp index 633d82576c..7d6396e101 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipseHideFaultFeature.cpp @@ -28,7 +28,7 @@ #include "RimEclipseView.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigFault.h" #include "RigMainGrid.h" @@ -45,7 +45,7 @@ CAF_CMD_SOURCE_INIT(RicEclipseHideFaultFeature, "RicEclipseHideFaultFeature"); //-------------------------------------------------------------------------------------------------- bool RicEclipseHideFaultFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimEclipseView* eclView = dynamic_cast(view); @@ -63,7 +63,7 @@ void RicEclipseHideFaultFeature::onActionTriggered(bool isChecked) if (!userData.isNull() && userData.type() == QVariant::List) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp index 193f16204c..1a63a39bc9 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterFeatureImpl.cpp @@ -29,7 +29,7 @@ #include "cafSelectionManager.h" #include "cvfAssert.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- /// @@ -66,7 +66,7 @@ void RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(RimEclipsePropertyFi propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } @@ -83,7 +83,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropert propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } //-------------------------------------------------------------------------------------------------- @@ -91,7 +91,7 @@ void RicEclipsePropertyFilterFeatureImpl::insertPropertyFilter(RimEclipsePropert //-------------------------------------------------------------------------------------------------- bool RicEclipsePropertyFilterFeatureImpl::isPropertyFilterCommandAvailable(caf::PdmObjectHandle* object) { - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; object->firstAncestorOrThisOfType(rimView); if (rimView) { @@ -119,7 +119,7 @@ void RicEclipsePropertyFilterFeatureImpl::setDefaults(RimEclipsePropertyFilter* propertyFilter->firstAncestorOrThisOfTypeAsserted(reservoirView); propertyFilter->resultDefinition->setEclipseCase(reservoirView->eclipseCase()); - propertyFilter->resultDefinition->simpleCopy(reservoirView->cellResult); + propertyFilter->resultDefinition->simpleCopy(reservoirView->cellResult()); propertyFilter->resultDefinition->loadResult(); propertyFilter->setToDefaultValues(); diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp index d15e954280..206977f750 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterInsertExec.cpp @@ -31,7 +31,7 @@ /// //-------------------------------------------------------------------------------------------------- RicEclipsePropertyFilterInsertExec::RicEclipsePropertyFilterInsertExec(RimEclipsePropertyFilter* propertyFilter) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(propertyFilter); m_propertyFilter = propertyFilter; diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp index d2e652c2eb..7a10247a95 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewExec.cpp @@ -23,14 +23,14 @@ #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" -#include "RimView.h" +#include "RimGridView.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RicEclipsePropertyFilterNewExec::RicEclipsePropertyFilterNewExec(RimEclipsePropertyFilterCollection* propertyFilterCollection) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { assert(propertyFilterCollection); m_propertyFilterCollection = propertyFilterCollection; @@ -58,7 +58,7 @@ void RicEclipsePropertyFilterNewExec::redo() { RicEclipsePropertyFilterFeatureImpl::addPropertyFilter(m_propertyFilterCollection); - RimView* view = nullptr; + RimGridView* view = nullptr; m_propertyFilterCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated property filter diff --git a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp index b601566289..48f4f6c1f3 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicEclipsePropertyFilterNewInViewFeature.cpp @@ -26,7 +26,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafCmdExecCommandManager.h" @@ -39,13 +39,13 @@ CAF_CMD_SOURCE_INIT(RicEclipsePropertyFilterNewInViewFeature, "RicEclipsePropert //-------------------------------------------------------------------------------------------------- bool RicEclipsePropertyFilterNewInViewFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return false; - RimEclipseCellColors* cellColors = eclView->cellResult().p(); + RimEclipseCellColors* cellColors = eclView->cellResult(); if (!cellColors) return false; if (RiaDefines::isPerCellFaceResult(cellColors->resultVariable())) return false; @@ -64,7 +64,7 @@ bool RicEclipsePropertyFilterNewInViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicEclipsePropertyFilterNewInViewFeature::onActionTriggered(bool isChecked) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp index b208bed484..5a21716256 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseFeature.cpp @@ -25,7 +25,7 @@ #include "RimEclipseCaseCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -50,22 +50,16 @@ void RicImportEclipseCaseFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); app->setLastUsedDialogDirectory("BINARY_GRID", defaultDir); - int i; - for (i = 0; i < fileNames.size(); i++) - { - QString fileName = fileNames[i]; + QStringList newCaseFiles; + RiaImportEclipseCaseTools::openEclipseCasesFromFile(fileNames, &newCaseFiles); - if (!fileNames.isEmpty()) - { - if (RiaImportEclipseCaseTools::openEclipseCaseFromFile(fileName)) - { - app->addToRecentFiles(fileName); - } - } + for (const auto newCaseFile : newCaseFiles) + { + RiaApplication::instance()->addToRecentFiles(newCaseFile); } } diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp index c174b6796e..26530278d4 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCaseTimeStepFilterFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RiaImportEclipseCaseTools.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -38,7 +38,7 @@ void RicImportEclipseCaseTimeStepFilterFeature::onActionTriggered(bool isChecked RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QString fileName = QFileDialog::getOpenFileName(RiuMainWindow::instance(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); + QString fileName = QFileDialog::getOpenFileName(Riu3DMainWindowTools::mainWindowWidget(), "Import Eclipse File", defaultDir, "Eclipse Grid Files (*.GRID *.EGRID)"); if (!fileName.isEmpty()) { defaultDir = QFileInfo(fileName).absolutePath(); diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp new file mode 100644 index 0000000000..39cbbec3b6 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.cpp @@ -0,0 +1,87 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportEclipseCasesFeature.h" + +#include "RiaImportEclipseCaseTools.h" + +#include "RiaApplication.h" + +#include "RicFileHierarchyDialog.h" + +#include "RimEclipseCaseCollection.h" + +#include "RiuMainWindow.h" + +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportEclipseCasesFeature, "RicImportEclipseCasesFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportEclipseCasesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEclipseCasesFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::runRecursiveSearchDialog(nullptr, + "Import Eclipse Cases", + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList() << ".EGRID" << ".GRID"); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if (!result.ok) return; + + // Remember the path to next time + app->setLastUsedDialogDirectory("BINARY_GRID", QFileInfo(result.rootDir).absoluteFilePath()); + + QStringList newCaseFiles; + RiaImportEclipseCaseTools::openEclipseCasesFromFile(result.files, &newCaseFiles); + + for (const auto newCaseFile : newCaseFiles) + { + RiaApplication::instance()->addToRecentFiles(newCaseFile); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEclipseCasesFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/Cases16x16.png")); + actionToSetup->setText("Import Eclipse Cases Recursively"); +} diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h new file mode 100644 index 0000000000..ac1c49f8c7 --- /dev/null +++ b/ApplicationCode/Commands/EclipseCommands/RicImportEclipseCasesFeature.h @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicImportEclipseCasesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + RicImportEclipseCasesFeature() : m_pathFilter("*"), m_fileNameFilter("*") {} + +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + QString m_pathFilter; + QString m_fileNameFilter; +}; + + diff --git a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp index 243311309e..f7e16bc27c 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicImportInputEclipseCaseFeature.cpp @@ -30,7 +30,7 @@ #include "RimOilField.h" #include "RimProject.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -66,7 +66,6 @@ bool RicImportInputEclipseCaseFeature::openInputEclipseCaseFromFileNames(const Q RimEclipseView* riv = rimInputReservoir->createAndAddReservoirView(); riv->cellResult()->setResultType(RiaDefines::INPUT_PROPERTY); - riv->hasUserRequestedAnimation = true; riv->loadDataAndUpdate(); @@ -77,7 +76,7 @@ bool RicImportInputEclipseCaseFeature::openInputEclipseCaseFromFileNames(const Q analysisModels->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(riv->cellResult()); + Riu3DMainWindowTools::selectAsCurrentItem(riv->cellResult()); if (fileNames.size() == 1) { @@ -102,7 +101,7 @@ void RicImportInputEclipseCaseFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties Eclipse Input Files (*.GRDECL);;All Files (*.*)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Eclipse Input Files", defaultDir, "Eclipse Input Files and Input Properties Eclipse Input Files (*.GRDECL);;All Files (*.*)"); if (fileNames.isEmpty()) return; diff --git a/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp b/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp index 6361893a40..c758e8ed7a 100644 --- a/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp +++ b/ApplicationCode/Commands/EclipseCommands/RicNewStatisticsCaseFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicNewStatisticsCaseFeature, "RicNewStatisticsCaseFeature"); //-------------------------------------------------------------------------------------------------- bool RicNewStatisticsCaseFeature::isCommandEnabled() { - return selectedValidUIItem() != NULL; + return selectedValidUIItem() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -53,7 +53,7 @@ void RicNewStatisticsCaseFeature::onActionTriggered(bool isChecked) RimEclipseStatisticsCase* newCase = addStatisticalCalculation(uiItem); if (newCase) { - RiuMainWindow::instance()->selectAsCurrentItem(newCase); + Riu3DMainWindowTools::selectAsCurrentItem(newCase); } } } @@ -90,7 +90,7 @@ caf::PdmUiItem* RicNewStatisticsCaseFeature::selectedValidUIItem() } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -98,7 +98,7 @@ caf::PdmUiItem* RicNewStatisticsCaseFeature::selectedValidUIItem() //-------------------------------------------------------------------------------------------------- RimEclipseStatisticsCase* RicNewStatisticsCaseFeature::addStatisticalCalculation(caf::PdmUiItem* uiItem) { - RimIdenticalGridCaseGroup* caseGroup = NULL; + RimIdenticalGridCaseGroup* caseGroup = nullptr; if (dynamic_cast(uiItem)) { @@ -122,6 +122,6 @@ RimEclipseStatisticsCase* RicNewStatisticsCaseFeature::addStatisticalCalculation } else { - return NULL; + return nullptr; } } diff --git a/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake index e667c58d71..5fdd3d1c04 100644 --- a/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ExportCommands/CMakeLists_files.cmake @@ -1,47 +1,42 @@ -# 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}RicCellRangeUi.h -${CEE_CURRENT_LIST_DIR}RicExportCarfin.h -${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.h -${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.h -${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.h -${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.h -${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsFeature.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsUi.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.h -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.h -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.h -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCellRangeUi.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfin.h +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinUi.h +${CMAKE_CURRENT_LIST_DIR}/RicExportFaultsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportMultipleSnapshotsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileResampleUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyExec.h +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllPlotsToFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllViewsToFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotFilenameGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToClipboardFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicCellRangeUi.cpp -${CEE_CURRENT_LIST_DIR}RicExportCarfin.cpp -${CEE_CURRENT_LIST_DIR}RicExportCarfinUi.cpp -${CEE_CURRENT_LIST_DIR}RicExportFaultsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportMultipleSnapshotsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportToLasFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExportToLasFileResampleUi.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseInputVisibleCellsUi.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyExec.cpp -${CEE_CURRENT_LIST_DIR}RicSaveEclipseResultAsInputPropertyFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotAllPlotsToFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotAllViewsToFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotFilenameGenerator.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToClipboardFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSnapshotViewToFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCellRangeUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfin.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportCarfinUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportFaultsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportMultipleSnapshotsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExportToLasFileResampleUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseInputVisibleCellsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyExec.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSaveEclipseResultAsInputPropertyFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllPlotsToFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotAllViewsToFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotFilenameGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToClipboardFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSnapshotViewToFileFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -52,4 +47,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Export" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Export" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp index 2a36d63a46..fb86a2eb9c 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportFaultsFeature.cpp @@ -69,7 +69,7 @@ void RicExportFaultsFeature::onActionTriggered(bool isChecked) QString projectFolder = app->currentProjectPath(); QString defaultDir = RiaApplication::instance()->lastUsedDialogDirectoryWithFallback("FAULTS", projectFolder); - QString selectedDir = QFileDialog::getExistingDirectory(NULL, tr("Select Directory"), defaultDir); + QString selectedDir = QFileDialog::getExistingDirectory(nullptr, tr("Select Directory"), defaultDir); if (selectedDir.isNull()) { // Stop if folder selection was cancelled. diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp index f035c88abc..b5a21c50eb 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.cpp @@ -19,6 +19,7 @@ #include "RicExportMultipleSnapshotsFeature.h" #include "RiaApplication.h" +#include "RiaViewRedrawScheduler.h" #include "RicSnapshotViewToFileFeature.h" @@ -36,7 +37,7 @@ #include "RimGeoMechView.h" #include "RimMultiSnapshotDefinition.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuExportMultipleSnapshotsWidget.h" #include "RiuViewer.h" @@ -79,7 +80,7 @@ void RicExportMultipleSnapshotsFeature::onActionTriggered(bool isChecked) RiuExportMultipleSnapshotsWidget dlg(nullptr, proj); - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && proj->multiSnapshotDefinitions.size() == 0) { dlg.addSnapshotItemFromActiveView(); @@ -116,7 +117,7 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f { if (!msd->isActive()) continue; - RimView* sourceView = msd->view(); + Rim3dView* sourceView = msd->view(); if (!sourceView) continue; if (!sourceView->viewer()) continue; @@ -178,7 +179,7 @@ void RicExportMultipleSnapshotsFeature::exportMultipleSnapshots(const QString& f //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportMultipleSnapshotsFeature::exportViewVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) +void RicExportMultipleSnapshotsFeature::exportViewVariations(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) { if (msd->selectedEclipseResults().size() > 0) { @@ -206,7 +207,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariations(RimView* rimView, R //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) +void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimGridView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder) { RimCase* rimCase = rimView->ownerCase(); CVF_ASSERT(rimCase); @@ -229,7 +230,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri // Force update of scheduled display models modifying the time step // This is required due to visualization structures updated by the update functions, // and this is not triggered by changing time step only - RiaApplication::instance()->slotUpdateScheduledDisplayModels(); + RiaViewRedrawScheduler::instance()->updateAndRedrawScheduledViews(); viewer->setCurrentFrame(i); viewer->animationControl()->setCurrentFrameOnly(i); @@ -293,7 +294,7 @@ void RicExportMultipleSnapshotsFeature::exportViewVariationsToFolder(RimView* ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicExportMultipleSnapshotsFeature::resultName(RimView* rimView) +QString RicExportMultipleSnapshotsFeature::resultName(Rim3dView* rimView) { if (dynamic_cast(rimView)) { diff --git a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h index 8073afbe0d..d241bd348c 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h +++ b/ApplicationCode/Commands/ExportCommands/RicExportMultipleSnapshotsFeature.h @@ -22,7 +22,8 @@ class RimMultiSnapshotDefinition; class RimProject; -class RimView; +class Rim3dView; +class RimGridView; //================================================================================================== /// @@ -39,10 +40,10 @@ class RicExportMultipleSnapshotsFeature : public caf::CmdFeature public: static void exportMultipleSnapshots(const QString& folder, RimProject* project); - static void exportViewVariations(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); + static void exportViewVariations(Rim3dView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); private: - static void exportViewVariationsToFolder(RimView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); - static QString resultName(RimView* rimView); + static void exportViewVariationsToFolder(RimGridView* rimView, RimMultiSnapshotDefinition* msd, const QString& folder); + static QString resultName(Rim3dView* rimView); }; diff --git a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp index 6449f4054c..98e563fd44 100644 --- a/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicExportToLasFileFeature.cpp @@ -79,7 +79,7 @@ void RicExportToLasFileFeature::onActionTriggered(bool isChecked) featureUi.setRkbDiffs(wellNames, rkbDiffs); } - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Export Curve Data to LAS file(s)", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); RicExportFeatureImpl::configureForExport(&propertyDialog); propertyDialog.resize(QSize(400, 200)); diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp index 02a866115a..a2db7490cd 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputPropertyFeature.cpp @@ -30,7 +30,7 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimExportInputPropertySettings.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" @@ -46,7 +46,7 @@ CAF_CMD_SOURCE_INIT(RicSaveEclipseInputPropertyFeature, "RicSaveEclipseInputProp //-------------------------------------------------------------------------------------------------- bool RicSaveEclipseInputPropertyFeature::isCommandEnabled() { - return selectedInputProperty() != NULL; + return selectedInputProperty() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -68,7 +68,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked) if (!isResolved) { - QMessageBox::warning(RiuMainWindow::instance(), "Export failure", "Property is not resolved, and then it is not possible to export the property."); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Export failure", "Property is not resolved, and then it is not possible to export the property."); return; } @@ -78,7 +78,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked) exportSettings.eclipseKeyword = inputProperty->eclipseKeyword; // Find input reservoir for this property - RimEclipseInputCase* inputReservoir = NULL; + RimEclipseInputCase* inputReservoir = nullptr; { RimEclipseInputPropertyCollection* inputPropertyCollection = dynamic_cast(inputProperty->parentField()->ownerObject()); if (!inputPropertyCollection) return; @@ -101,7 +101,7 @@ void RicSaveEclipseInputPropertyFeature::onActionTriggered(bool isChecked) exportSettings.fileName = outputFileName; } - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Eclipse Property to Text File", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Eclipse Property to Text File", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp index 5f4f31b112..d78730c50b 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseInputVisibleCellsFeature.cpp @@ -30,12 +30,12 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigActiveCellInfo.h" #include "RigEclipseCaseData.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafSelectionManager.h" @@ -54,7 +54,7 @@ void executeCommand(RimEclipseView* view) if (!view) return; RicSaveEclipseInputVisibleCellsUi exportSettings; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export FLUXNUM/MULTNUM", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export FLUXNUM/MULTNUM", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) @@ -173,7 +173,7 @@ void RicSaveEclipseInputActiveVisibleCellsFeature::setupActionLook(QAction* acti //-------------------------------------------------------------------------------------------------- RimEclipseView* RicSaveEclipseInputActiveVisibleCellsFeature::getEclipseActiveView() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); return dynamic_cast(activeView); } diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp index 209c13a23d..cf3c628f66 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyExec.cpp @@ -34,7 +34,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" #include "cafUtils.h" @@ -45,7 +45,7 @@ /// //-------------------------------------------------------------------------------------------------- RicSaveEclipseResultAsInputPropertyExec::RicSaveEclipseResultAsInputPropertyExec(RimEclipseCellColors* cellColors) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(cellColors); m_cellColors = cellColors; @@ -92,7 +92,7 @@ void RicSaveEclipseResultAsInputPropertyExec::redo() exportSettings.fileName = outputFileName; } - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &exportSettings, "Export Binary Eclipse Data to Text File", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &exportSettings, "Export Binary Eclipse Data to Text File", ""); RicExportFeatureImpl::configureForExport(&propertyDialog); if (propertyDialog.exec() == QDialog::Accepted) diff --git a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp index 52d4f4a443..6306931474 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSaveEclipseResultAsInputPropertyFeature.cpp @@ -22,7 +22,7 @@ #include "RicSaveEclipseResultAsInputPropertyExec.h" #include "RimEclipseCellColors.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafSelectionManager.h" #include "cafCmdExecCommandManager.h" diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp index b00dab064b..3572a5c125 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllPlotsToFileFeature.cpp @@ -28,7 +28,7 @@ #include "RicSnapshotViewToFileFeature.h" #include "RicSnapshotFilenameGenerator.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafUtils.h" @@ -50,7 +50,7 @@ void RicSnapshotAllPlotsToFileFeature::saveAllPlots() { RiaApplication* app = RiaApplication::instance(); - RiuMainPlotWindow* mainPlotWindow = app->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = app->mainPlotWindow(); if (!mainPlotWindow) return; RimProject* proj = app->project(); @@ -123,11 +123,7 @@ void RicSnapshotAllPlotsToFileFeature::onActionTriggered(bool isChecked) if (currentActiveWidget) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->setActiveViewer(currentActiveWidget); - } + RiuPlotMainWindowTools::setActiveViewer(currentActiveWidget); } } diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp index e516785cd0..46f51c874e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotAllViewsToFileFeature.cpp @@ -20,18 +20,19 @@ #include "RiaApplication.h" #include "RiaLogging.h" +#include "RiaViewRedrawScheduler.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimCase.h" #include "Rim3dOverlayInfoConfig.h" #include "RicSnapshotViewToFileFeature.h" #include "RicSnapshotFilenameGenerator.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuViewer.h" #include "RigFemResultPosEnum.h" @@ -71,9 +72,6 @@ void RicSnapshotAllViewsToFileFeature::saveAllViews() //-------------------------------------------------------------------------------------------------- void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QString snapshotFolderName) { - RiuMainWindow* mainWnd = RiuMainWindow::instance(); - if (!mainWnd) return; - RimProject* project = RiaApplication::instance()->project(); if (project == nullptr) return; @@ -96,20 +94,20 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin RimCase* cas = projectCases[i]; if (!cas) continue; - std::vector views = cas->views(); + std::vector views = cas->views(); for (size_t j = 0; j < views.size(); j++) { - RimView* riv = views[j]; + Rim3dView* riv = views[j]; if (riv && riv->viewer()) { RiaApplication::instance()->setActiveReservoirView(riv); RiuViewer* viewer = riv->viewer(); - mainWnd->setActiveViewer(viewer->layoutWidget()); + Riu3DMainWindowTools::setActiveViewer(viewer->layoutWidget()); - RiaApplication::instance()->clearViewsScheduledForUpdate(); + RiaViewRedrawScheduler::instance()->clearViewsScheduledForUpdate(); //riv->updateCurrentTimeStepAndRedraw(); riv->createDisplayModelAndRedraw(); @@ -122,9 +120,14 @@ void RicSnapshotAllViewsToFileFeature::exportSnapshotOfAllViewsIntoFolder(QStrin RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, riv); // Statistics dialog - QImage img = riv->overlayInfoConfig()->statisticsDialogScreenShotImage(); - absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName + "_Statistics", ".png"); - RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, img); + + RimGridView* rigv = dynamic_cast(riv); + if ( rigv ) + { + QImage img = rigv->overlayInfoConfig()->statisticsDialogScreenShotImage(); + absoluteFileName = caf::Utils::constructFullFileName(absSnapshotPath, fileName + "_Statistics", ".png"); + RicSnapshotViewToFileFeature::saveSnapshotAs(absoluteFileName, img); + } } } } @@ -153,11 +156,7 @@ void RicSnapshotAllViewsToFileFeature::onActionTriggered(bool isChecked) if (currentActiveWidget) { - RiuMainWindow* mainWindow = RiuMainWindow::instance(); - if (mainWindow) - { - mainWindow->setActiveViewer(currentActiveWidget); - } + Riu3DMainWindowTools::setActiveViewer(currentActiveWidget); } } diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp index 6db72f2815..6939dd7188 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.cpp @@ -19,7 +19,7 @@ #include "RicSnapshotFilenameGenerator.h" #include "RimViewWindow.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimEclipseView.h" #include "RimEclipseCellColors.h" @@ -35,7 +35,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* viewWindow) { { - RimView* view = dynamic_cast(viewWindow); + Rim3dView* view = dynamic_cast(viewWindow); if (view != nullptr) { return generateSnapshotFilenameForRimView(view); @@ -59,7 +59,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFileName(RimViewWindow* vi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(RimView* rimView) +QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(Rim3dView* rimView) { QStringList timeSteps = rimView->ownerCase()->timeStepStrings(); int timeStep = rimView->currentTimeStep(); @@ -79,7 +79,7 @@ QString RicSnapshotFilenameGenerator::generateSnapshotFilenameForRimView(RimView //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RicSnapshotFilenameGenerator::resultName(RimView * rimView) +QString RicSnapshotFilenameGenerator::resultName(Rim3dView * rimView) { if (dynamic_cast(rimView)) { diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h index 9532f6b37d..e5fc9c6838 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotFilenameGenerator.h @@ -21,7 +21,7 @@ #include class RimViewWindow; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -32,7 +32,7 @@ class RicSnapshotFilenameGenerator static QString generateSnapshotFileName(RimViewWindow* viewWindow); private: - static QString generateSnapshotFilenameForRimView(RimView* rimView); - static QString resultName(RimView* rimView); + static QString generateSnapshotFilenameForRimView(Rim3dView* rimView); + static QString resultName(Rim3dView* rimView); static QString makeValidFileName(const QString& filename); }; diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp index 499efe5ed5..79e7002aa0 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToClipboardFeature.cpp @@ -25,7 +25,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafUtils.h" diff --git a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp index dd4f5c114f..9404695d3e 100644 --- a/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp +++ b/ApplicationCode/Commands/ExportCommands/RicSnapshotViewToFileFeature.cpp @@ -24,7 +24,7 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimViewWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicSnapshotFilenameGenerator.h" @@ -90,7 +90,7 @@ void RicSnapshotViewToFileFeature::saveToFile(const QImage& image, const QString } QString defaultAbsFileName = caf::Utils::constructFullFileName(startPath, defaultFileBaseName, ".png"); - QString fileName = QFileDialog::getSaveFileName(NULL, tr("Export to File"), defaultAbsFileName); + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Export to File"), defaultAbsFileName); if (fileName.isEmpty()) { return; diff --git a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake index b1f7eeb979..08a748ed6b 100644 --- a/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/FlowCommands/CMakeLists_files.cmake @@ -1,33 +1,28 @@ -# 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}RicAddStoredFlowCharacteristicsPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowFlowCharacteristicsPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.h -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicPlotProductionRateFeature.h -${CEE_CURRENT_LIST_DIR}RicSelectViewUI.h -${CEE_CURRENT_LIST_DIR}RicShowTotalAllocationDataFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredFlowCharacteristicsPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowWellAllocationPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowFlowCharacteristicsPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredWellAllocationPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFromPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicPlotProductionRateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSelectViewUI.h +${CMAKE_CURRENT_LIST_DIR}/RicShowTotalAllocationDataFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddStoredFlowCharacteristicsPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowWellAllocationPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowFlowCharacteristicsPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicAddStoredWellAllocationPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFromPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowContributingWellsFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicPlotProductionRateFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSelectViewUI.cpp -${CEE_CURRENT_LIST_DIR}RicShowTotalAllocationDataFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredFlowCharacteristicsPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowWellAllocationPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowFlowCharacteristicsPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddStoredWellAllocationPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFromPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowContributingWellsFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPlotProductionRateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSelectViewUI.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowTotalAllocationDataFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -38,4 +33,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\FlowDiagnostics" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\FlowDiagnostics" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp index 92ddc0ae33..69dcb88081 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredFlowCharacteristicsPlotFeature.cpp @@ -25,7 +25,7 @@ #include "RimProject.h" #include "RimFlowCharacteristicsPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -79,12 +79,10 @@ void RicAddStoredFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecke flowPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(flowCharacteristicsPlot); - mainPlotWindow->setExpanded(flowCharacteristicsPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + + RiuPlotMainWindowTools::selectAsCurrentItem(flowCharacteristicsPlot); + RiuPlotMainWindowTools::setExpanded(flowCharacteristicsPlot); } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp index a04eb49619..5c0beac5d0 100644 --- a/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicAddStoredWellAllocationPlotFeature.cpp @@ -25,7 +25,7 @@ #include "RimProject.h" #include "RimWellAllocationPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -79,12 +79,8 @@ void RicAddStoredWellAllocationPlotFeature::onActionTriggered(bool isChecked) flowPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(wellAllocationPlot); - mainPlotWindow->setExpanded(wellAllocationPlot); - } + RiuPlotMainWindowTools::selectAsCurrentItem(wellAllocationPlot); + RiuPlotMainWindowTools::setExpanded(wellAllocationPlot); } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp index c25232e52e..c59a8b4e63 100644 --- a/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicPlotProductionRateFeature.cpp @@ -37,11 +37,10 @@ #include "RimSummaryCurveAppearanceCalculator.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiaSummaryTools.h" -#include "RiuMainPlotWindow.h" -#include "RiuMainWindow.h" +#include "RiuPlotMainWindow.h" #include "cafSelectionManager.h" @@ -185,7 +184,7 @@ void RicPlotProductionRateFeature::onActionTriggered(bool isChecked) if (summaryPlotToSelect) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); if (mainPlotWindow) { mainPlotWindow->selectAsCurrentItem(summaryPlotToSelect); @@ -238,7 +237,7 @@ bool RicPlotProductionRateFeature::isInjector(RimSimWellInView* well) RigSimWellData* wRes = well->simWellData(); if (wRes) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; well->firstAncestorOrThisOfTypeAsserted(rimView); int currentTimeStep = rimView->currentTimeStep(); diff --git a/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp b/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp index 158439567a..f645cd9625 100644 --- a/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicSelectViewUI.cpp @@ -94,7 +94,7 @@ QList RicSelectViewUI::calculateValueOptions(const caf:: { if (m_currentCase) { - for (RimView* v : m_currentCase->views()) + for (Rim3dView* v : m_currentCase->views()) { QIcon icon = v->uiCapability()->uiIcon(); QString displayName = v->name; diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp index 7c3ad6a965..19f30db1c7 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeature.cpp @@ -94,7 +94,7 @@ void RicShowContributingWellsFeature::onActionTriggered(bool isChecked) { modifiedView->createDisplayModelAndRedraw(); - std::vector viewsToUpdate; + std::vector viewsToUpdate; viewsToUpdate.push_back(modifiedView); RimViewManipulator::applySourceViewCameraOnDestinationViews(eclipseView, viewsToUpdate); diff --git a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp index b31672ee09..b5de57a139 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowContributingWellsFeatureImpl.cpp @@ -37,7 +37,7 @@ #include "RimSimWellInView.h" #include "RimViewManipulator.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" @@ -156,7 +156,7 @@ void RicShowContributingWellsFeatureImpl::modifyViewToShowContributingWells(RimE propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->setExpanded(propertyFilterCollection); + Riu3DMainWindowTools::setExpanded(propertyFilterCollection); viewToModify->faultCollection()->showFaultCollection = false; viewToModify->faultCollection()->updateConnectedEditors(); diff --git a/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp index c42777535e..5dd15fc659 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowFlowCharacteristicsPlotFeature.cpp @@ -30,9 +30,9 @@ #include "RimFlowPlotCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include @@ -40,7 +40,7 @@ CAF_CMD_SOURCE_INIT(RicShowFlowCharacteristicsPlotFeature, "RicShowFlowCharacter RimEclipseResultCase* activeEclipseResultCase() { - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); RimEclipseView* eclView = dynamic_cast(activeView); @@ -78,7 +78,7 @@ void RicShowFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecked) { // Make sure flow results for the the active timestep is calculated, to avoid an empty plot { - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && eclCase->defaultFlowDiagSolution()->flowDiagResults()) { // Trigger calculation @@ -91,13 +91,13 @@ void RicShowFlowCharacteristicsPlotFeature::onActionTriggered(bool isChecked) RimFlowPlotCollection* flowPlotColl = RiaApplication::instance()->project()->mainPlotCollection->flowPlotCollection(); if (flowPlotColl) { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); flowPlotColl->defaultFlowCharacteristicsPlot()->setFromFlowSolution(eclCase->defaultFlowDiagSolution()); flowPlotColl->defaultFlowCharacteristicsPlot()->updateConnectedEditors(); // Make sure the summary plot window is created and visible - plotwindow->selectAsCurrentItem(flowPlotColl->defaultFlowCharacteristicsPlot()); + RiuPlotMainWindowTools::selectAsCurrentItem(flowPlotColl->defaultFlowCharacteristicsPlot()); } } } diff --git a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp index 463242a504..856042ff5c 100644 --- a/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp +++ b/ApplicationCode/Commands/FlowCommands/RicShowWellAllocationPlotFeature.cpp @@ -25,10 +25,10 @@ #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellAllocationPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -57,12 +57,12 @@ bool RicShowWellAllocationPlotFeature::isCommandEnabled() if (wellPathCollection.empty()) return false; - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return false; - RimSimWellInView* simWellFromWellPath = eclView->wellCollection->findWell(wellPathCollection[0]->associatedSimulationWellName()); + RimSimWellInView* simWellFromWellPath = eclView->wellCollection()->findWell(wellPathCollection[0]->associatedSimulationWellName()); if (simWellFromWellPath) { @@ -91,12 +91,12 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) } else if (wellPathCollection.size() > 0) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimEclipseView* eclView = dynamic_cast(view); if (!eclView) return; - simWell = eclView->wellCollection->findWell(wellPathCollection[0]->associatedSimulationWellName()); + simWell = eclView->wellCollection()->findWell(wellPathCollection[0]->associatedSimulationWellName()); if (!simWell) return; } else return; @@ -110,8 +110,8 @@ void RicShowWellAllocationPlotFeature::onActionTriggered(bool isChecked) flowPlotColl->defaultWellAllocPlot()->updateConnectedEditors(); // Make sure the summary plot window is created and visible - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - plotwindow->selectAsCurrentItem(flowPlotColl->defaultWellAllocPlot()); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(flowPlotColl->defaultWellAllocPlot()); } } } diff --git a/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..9abc019ecd --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/CMakeLists_files.cmake @@ -0,0 +1,41 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicPasteEllipseFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteStimPlanFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToFieldFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToMetricFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicFractureNameGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RicNewEllipseFractureTemplateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanFractureTemplateFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureAtPosFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicPasteEllipseFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteStimPlanFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToFieldFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicConvertAllFractureTemplatesToMetricFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicFractureNameGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewEllipseFractureTemplateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureAtPosFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSimWellFractureFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewStimPlanFractureTemplateFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureAtPosFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellPathFractureFeature.cpp +) + + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\Fracture" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.cpp similarity index 94% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.cpp index f554dd318c..3b282b9378 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.cpp @@ -27,7 +27,7 @@ #include "RimFracture.h" #include "RimFractureExportSettings.h" #include "RimFractureTemplateCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -63,9 +63,11 @@ void RicConvertAllFractureTemplatesToFieldFeature::onActionTriggered(bool isChec for (auto ellipseFracTemplate : ellipseFracTemplates) { - if (ellipseFracTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (ellipseFracTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { ellipseFracTemplate->changeUnits(); + + ellipseFracTemplate->disconnectAllFracturesAndRedrawViews(); } } } diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.h b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.h similarity index 100% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToFieldFeature.h rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToFieldFeature.h diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.cpp similarity index 94% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.cpp index 62c6593472..6390b1140c 100644 --- a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.cpp @@ -27,7 +27,7 @@ #include "RimFracture.h" #include "RimFractureExportSettings.h" #include "RimFractureTemplateCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -63,9 +63,11 @@ void RicConvertAllFractureTemplatesToMetricFeature::onActionTriggered(bool isChe for (auto ellipseFracTemplate : ellipseFracTemplates) { - if (ellipseFracTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + if (ellipseFracTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { ellipseFracTemplate->changeUnits(); + + ellipseFracTemplate->disconnectAllFracturesAndRedrawViews(); } } diff --git a/ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.h b/ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.h similarity index 100% rename from ApplicationCode/Commands/RicConvertAllFractureTemplatesToMetricFeature.h rename to ApplicationCode/Commands/FractureCommands/RicConvertAllFractureTemplatesToMetricFeature.h diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp similarity index 52% rename from ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp index 8756fb11e6..4cacae58dd 100644 --- a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.cpp @@ -16,18 +16,21 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RicConvertFractureTemplateUnitFeature.h" +#include "RicCreateDuplicateTemplateInOtherUnitSystemFeature.h" #include "RiaApplication.h" #include "RiaEclipseUnitTools.h" +#include "RicNewEllipseFractureTemplateFeature.h" + +#include "Rim3dView.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFracture.h" #include "RimFractureExportSettings.h" -#include "RimView.h" +#include "RimFractureTemplateCollection.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -42,12 +45,12 @@ #include #include -CAF_CMD_SOURCE_INIT(RicConvertFractureTemplateUnitFeature, "RicConvertFractureTemplateUnitFeature"); +CAF_CMD_SOURCE_INIT(RicCreateDuplicateTemplateInOtherUnitSystemFeature, "RicConvertFractureTemplateUnitFeature"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) +void RicCreateDuplicateTemplateInOtherUnitSystemFeature::onActionTriggered(bool isChecked) { caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); if (!pdmUiItem) return; @@ -55,17 +58,43 @@ void RicConvertFractureTemplateUnitFeature::onActionTriggered(bool isChecked) caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); if (!objHandle) return; - RimEllipseFractureTemplate* ellipseFractureTemplate = nullptr; - objHandle->firstAncestorOrThisOfType(ellipseFractureTemplate); + RimFractureTemplate* fractureTemplate = nullptr; + objHandle->firstAncestorOrThisOfType(fractureTemplate); + + if (!fractureTemplate) return; + + RimFractureTemplateCollection* fractureTemplateCollection = nullptr; + fractureTemplate->firstAncestorOrThisOfType(fractureTemplateCollection); + + auto copyOfTemplate = dynamic_cast( + fractureTemplate->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + fractureTemplateCollection->addFractureTemplate(copyOfTemplate); + + auto currentUnit = copyOfTemplate->fractureTemplateUnit(); + if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + copyOfTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); + } + else + { + copyOfTemplate->convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); + } + + QString name = copyOfTemplate->name(); + name += " (copy)"; + copyOfTemplate->setName(name); - ellipseFractureTemplate->changeUnits(); + copyOfTemplate->loadDataAndUpdate(); + copyOfTemplate->updateConnectedEditors(); + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateCollection, copyOfTemplate); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSetup) +void RicCreateDuplicateTemplateInOtherUnitSystemFeature::setupActionLook(QAction* actionToSetup) { caf::PdmUiItem* pdmUiItem = caf::SelectionManager::instance()->selectedItem(); if (!pdmUiItem) return; @@ -73,22 +102,23 @@ void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSet caf::PdmObjectHandle* objHandle = dynamic_cast(pdmUiItem); if (!objHandle) return; - RimEllipseFractureTemplate* ellipseFractureTemplate = nullptr; - objHandle->firstAncestorOrThisOfType(ellipseFractureTemplate); - if (!ellipseFractureTemplate) return; + RimFractureTemplate* fractureTemplate = nullptr; + objHandle->firstAncestorOrThisOfType(fractureTemplate); + if (!fractureTemplate) return; - QString text = "Convert Values to "; - if (ellipseFractureTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + QString destinationUnit; + if (fractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - text += "Field"; + destinationUnit += "Field"; } - else if (ellipseFractureTemplate->fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (fractureTemplate->fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - text += "Metric"; + destinationUnit += "Metric"; } + + QString text = QString("Create %1 Units Duplicate").arg(destinationUnit); actionToSetup->setIcon(QIcon(":/FractureTemplate16x16.png")); - //TODO: Add unit to text actionToSetup->setText(text); } @@ -96,7 +126,7 @@ void RicConvertFractureTemplateUnitFeature::setupActionLook(QAction* actionToSet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicConvertFractureTemplateUnitFeature::isCommandEnabled() +bool RicCreateDuplicateTemplateInOtherUnitSystemFeature::isCommandEnabled() { return true; } diff --git a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.h b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h similarity index 93% rename from ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.h rename to ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h index 5b80c5d630..c7406382a1 100644 --- a/ApplicationCode/Commands/RicConvertFractureTemplateUnitFeature.h +++ b/ApplicationCode/Commands/FractureCommands/RicCreateDuplicateTemplateInOtherUnitSystemFeature.h @@ -26,7 +26,7 @@ //================================================================================================== /// //================================================================================================== -class RicConvertFractureTemplateUnitFeature : public caf::CmdFeature +class RicCreateDuplicateTemplateInOtherUnitSystemFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; protected: diff --git a/ApplicationCode/Commands/RicFractureNameGenerator.cpp b/ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.cpp similarity index 100% rename from ApplicationCode/Commands/RicFractureNameGenerator.cpp rename to ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.cpp diff --git a/ApplicationCode/Commands/RicFractureNameGenerator.h b/ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.h similarity index 100% rename from ApplicationCode/Commands/RicFractureNameGenerator.h rename to ApplicationCode/Commands/FractureCommands/RicFractureNameGenerator.h diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp similarity index 63% rename from ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp index 39d82aea1a..b23ecc84ab 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -20,13 +20,13 @@ #include "RiaApplication.h" -#include "RimOilField.h" #include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" +#include "RimOilField.h" #include "RimProject.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -34,11 +34,36 @@ #include - CAF_CMD_SOURCE_INIT(RicNewEllipseFractureTemplateFeature, "RicNewEllipseFractureTemplateFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection, + RimFractureTemplate* fractureTemplate) +{ + fractureTemplate->loadDataAndUpdate(); + + templateCollection->updateConnectedEditors(); + + RimProject* project = RiaApplication::instance()->project(); + + std::vector views; + project->allVisibleViews(views); + + for (Rim3dView* view : views) + { + if (dynamic_cast(view)) + { + view->updateConnectedEditors(); + } + } + + Riu3DMainWindowTools::selectAsCurrentItem(fractureTemplate); +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) { @@ -49,34 +74,22 @@ void RicNewEllipseFractureTemplateFeature::onActionTriggered(bool isChecked) if (oilfield == nullptr) return; RimFractureTemplateCollection* fracDefColl = oilfield->fractureDefinitionCollection(); - + if (fracDefColl) { - RimEllipseFractureTemplate* fractureDef = new RimEllipseFractureTemplate(); - fracDefColl->fractureDefinitions.push_back(fractureDef); - fractureDef->name = "Ellipse Fracture Template"; - fractureDef->fractureTemplateUnit = fracDefColl->defaultUnitsForFracTemplates(); - fractureDef->setDefaultWellDiameterFromUnit(); - - fracDefColl->updateConnectedEditors(); + RimEllipseFractureTemplate* ellipseFractureTemplate = new RimEllipseFractureTemplate(); - std::vector views; - project->allVisibleViews(views); - - for (RimView* view : views) - { - if (dynamic_cast(view)) - { - view->updateConnectedEditors(); - } - } + fracDefColl->addFractureTemplate(ellipseFractureTemplate); + ellipseFractureTemplate->setName("Ellipse Fracture Template"); + ellipseFractureTemplate->setFractureTemplateUnit(fracDefColl->defaultUnitSystemType()); + ellipseFractureTemplate->setDefaultValuesFromUnit(); - RiuMainWindow::instance()->selectAsCurrentItem(fractureDef); + selectFractureTemplateAndUpdate(fracDefColl, ellipseFractureTemplate); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicNewEllipseFractureTemplateFeature::setupActionLook(QAction* actionToSetup) { @@ -85,7 +98,7 @@ void RicNewEllipseFractureTemplateFeature::setupActionLook(QAction* actionToSetu } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicNewEllipseFractureTemplateFeature::isCommandEnabled() { diff --git a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.h similarity index 80% rename from ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.h index f8f6118c84..e6a45aa955 100644 --- a/ApplicationCode/Commands/RicNewEllipseFractureTemplateFeature.h +++ b/ApplicationCode/Commands/FractureCommands/RicNewEllipseFractureTemplateFeature.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -22,18 +22,22 @@ #include +class RimFractureTemplate; +class RimFractureTemplateCollection; //================================================================================================== -/// +/// //================================================================================================== class RicNewEllipseFractureTemplateFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; -protected: +public: + static void selectFractureTemplateAndUpdate(RimFractureTemplateCollection* templateCollection, + RimFractureTemplate* ellipseFractureTemplate); + +protected: virtual void onActionTriggered(bool isChecked) override; virtual void setupActionLook(QAction* actionToSetup) override; virtual bool isCommandEnabled() override; - - }; diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp similarity index 83% rename from ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp index 17549893e5..e4a31058d3 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.cpp @@ -21,8 +21,10 @@ #include "RiaApplication.h" #include "RigEclipseCaseData.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimEclipseResultCase.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" #include "RimOilField.h" @@ -30,9 +32,9 @@ #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "RimStimPlanColors.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RivSimWellPipeSourceInfo.h" @@ -52,7 +54,7 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) RimProject* proj = RiaApplication::instance()->project(); if (proj->allFractureTemplates().empty()) return; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); @@ -68,6 +70,15 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) if (!fractureCollection) return; RimSimWellFracture* fracture = new RimSimWellFracture(); + if (fractureCollection->simwellFractures.empty()) + { + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) + { + activeView->fractureColors()->setDefaultResultName(); + } + } + fractureCollection->simwellFractures.push_back(fracture); fracture->setClosestWellCoord(simWellItem->m_domainCoord, simWellItem->m_branchIndex); @@ -82,20 +93,23 @@ void RicNewSimWellFractureAtPosFeature::onActionTriggered(bool isChecked) fracture->setName(QString("Fracture_") + fracNum); + auto unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; { RimEclipseResultCase* eclipseCase = nullptr; simWell->firstAncestorOrThisOfType(eclipseCase); - fracture->setFractureUnit(eclipseCase->eclipseCaseData()->unitsType()); - } + if (eclipseCase) + { + unitSet = eclipseCase->eclipseCaseData()->unitsType(); + } - if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0) - { - RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0]; - fracture->setFractureTemplate(fracDef); + fracture->setFractureUnit(unitSet); } + + RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->firstFractureOfUnit(unitSet); + fracture->setFractureTemplate(fracDef); simWell->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fracture); + Riu3DMainWindowTools::selectAsCurrentItem(fracture); activeView->scheduleCreateDisplayModelAndRedraw(); diff --git a/ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewSimWellFractureAtPosFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureAtPosFeature.h diff --git a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp similarity index 84% rename from ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp index 789d212924..b6e83e4ef8 100644 --- a/ApplicationCode/Commands/RicNewSimWellFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.cpp @@ -32,10 +32,11 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimSimWellFracture.h" +#include "RimStimPlanColors.h" #include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -63,6 +64,15 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked) objHandle->firstAncestorOrThisOfType(eclipseWell); RimSimWellFracture* fracture = new RimSimWellFracture(); + if (eclipseWell->simwellFractureCollection()->simwellFractures.empty()) + { + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) + { + activeView->fractureColors()->setDefaultResultName(); + } + } + eclipseWell->simwellFractureCollection()->simwellFractures.push_back(fracture); RimOilField* oilfield = nullptr; @@ -71,22 +81,24 @@ void RicNewSimWellFractureFeature::onActionTriggered(bool isChecked) fracture->setName(RicFractureNameGenerator::nameForNewFracture()); + auto unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; { RimEclipseResultCase* eclipseCase = nullptr; objHandle->firstAncestorOrThisOfType(eclipseCase); - fracture->setFractureUnit(eclipseCase->eclipseCaseData()->unitsType()); + if (eclipseCase) + { + unitSet = eclipseCase->eclipseCaseData()->unitsType(); + } + fracture->setFractureUnit(unitSet); } - if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0) - { - RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0]; - fracture->setFractureTemplate(fracDef); - } + RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->firstFractureOfUnit(unitSet); + fracture->setFractureTemplate(fracDef); fracture->updateFracturePositionFromLocation(); eclipseWell->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fracture); + Riu3DMainWindowTools::selectAsCurrentItem(fracture); RimEclipseCase* eclipseCase = nullptr; objHandle->firstAncestorOrThisOfType(eclipseCase); diff --git a/ApplicationCode/Commands/RicNewSimWellFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewSimWellFractureFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewSimWellFractureFeature.h diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp similarity index 86% rename from ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp index c0f7114a60..b0905a59f8 100644 --- a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.cpp @@ -20,13 +20,13 @@ #include "RiaApplication.h" -#include "RimOilField.h" #include "RimEclipseView.h" #include "RimFractureTemplateCollection.h" +#include "RimOilField.h" #include "RimProject.h" #include "RimStimPlanFractureTemplate.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -60,19 +60,29 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) if (fracDefColl) { RimStimPlanFractureTemplate* fractureDef = new RimStimPlanFractureTemplate(); - fracDefColl->fractureDefinitions.push_back(fractureDef); - fractureDef->name = "StimPlan Fracture Template"; + fracDefColl->addFractureTemplate(fractureDef); + + QFileInfo stimplanfileFileInfo(fileName); + QString name = stimplanfileFileInfo.baseName(); + if (name.isEmpty()) + { + name = "StimPlan Fracture Template"; + } + + fractureDef->setName(name); + fractureDef->setFileName(fileName); fractureDef->loadDataAndUpdate(); fractureDef->setDefaultsBasedOnXMLfile(); fractureDef->setDefaultWellDiameterFromUnit(); + fractureDef->updateFractureGrid(); fracDefColl->updateConnectedEditors(); - std::vector views; + std::vector views; project->allVisibleViews(views); - for (RimView* view : views) + for (Rim3dView* view : views) { if (dynamic_cast(view)) { @@ -80,7 +90,7 @@ void RicNewStimPlanFractureTemplateFeature::onActionTriggered(bool isChecked) } } - RiuMainWindow::instance()->selectAsCurrentItem(fractureDef); + Riu3DMainWindowTools::selectAsCurrentItem(fractureDef); } } diff --git a/ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewStimPlanFractureTemplateFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewStimPlanFractureTemplateFeature.h diff --git a/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.cpp similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.cpp diff --git a/ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureAtPosFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureAtPosFeature.h diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp similarity index 89% rename from ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp index 4918c73bc1..36a3a18b0d 100644 --- a/ApplicationCode/Commands/RicNewWellPathFractureFeature.cpp +++ b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.cpp @@ -18,22 +18,25 @@ #include "RicNewWellPathFractureFeature.h" -#include "RicFractureNameGenerator.h" - #include "RiaApplication.h" +#include "RicFractureNameGenerator.h" + #include "RigWellPath.h" #include "RimCase.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" #include "RimFractureTemplateCollection.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimStimPlanColors.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" -#include "RiuMainWindow.h" + +#include "Riu3DMainWindowTools.h" #include "WellPathCommands/RicWellPathsUnitSystemSettingsImpl.h" @@ -58,6 +61,15 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me RimWellPathFractureCollection* fractureCollection = wellPath->fractureCollection(); CVF_ASSERT(fractureCollection); + if (fractureCollection->fractures.empty()) + { + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) + { + activeView->fractureColors()->setDefaultResultName(); + } + } + RimWellPathFracture* fracture = new RimWellPathFracture(); fractureCollection->fractures.push_back(fracture); @@ -74,14 +86,14 @@ void RicNewWellPathFractureFeature::addFracture(RimWellPath* wellPath, double me fracture->setName(RicFractureNameGenerator::nameForNewFracture()); - if (oilfield->fractureDefinitionCollection->fractureDefinitions.size() > 0) - { - RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->fractureDefinitions[0]; - fracture->setFractureTemplate(fracDef); - } + auto unitSet = wellPath->unitSystem(); + fracture->setFractureUnit(unitSet); + + RimFractureTemplate* fracDef = oilfield->fractureDefinitionCollection->firstFractureOfUnit(unitSet); + fracture->setFractureTemplate(fracDef); wellPath->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(fracture); + Riu3DMainWindowTools::selectAsCurrentItem(fracture); RimProject* project = nullptr; fractureCollection->firstAncestorOrThisOfType(project); diff --git a/ApplicationCode/Commands/RicNewWellPathFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h similarity index 100% rename from ApplicationCode/Commands/RicNewWellPathFractureFeature.h rename to ApplicationCode/Commands/FractureCommands/RicNewWellPathFractureFeature.h diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp new file mode 100644 index 0000000000..068b7bd101 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteEllipseFractureFeature.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RicNewEllipseFractureTemplateFeature.h" + +#include "RimEllipseFractureTemplate.h" +#include "RimFractureTemplateCollection.h" + +#include "cafPdmObjectGroup.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicPasteEllipseFractureFeature, "RicPasteEllipseFractureFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteEllipseFractureFeature::isCommandEnabled() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + if (typedObjects.size() == 0) + { + return false; + } + + if (fractureTemplateCollection()) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEllipseFractureFeature::onActionTriggered(bool isChecked) +{ + auto fractureTemplateColl = fractureTemplateCollection(); + if (!fractureTemplateColl) return; + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + for (const auto& source : typedObjects) + { + auto templ = dynamic_cast( + source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + fractureTemplateColl->addFractureTemplate(templ); + + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, templ); + } + + return; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEllipseFractureFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste (Ellipse Fracture)"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplateCollection* RicPasteEllipseFractureFeature::fractureTemplateCollection() +{ + RimFractureTemplateCollection* fractureTemplateColl = nullptr; + + auto destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (destinationObject) + { + destinationObject->firstAncestorOrThisOfType(fractureTemplateColl); + } + + return fractureTemplateColl; +} diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h new file mode 100644 index 0000000000..e3fe726421 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteEllipseFractureFeature.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimFractureTemplateCollection; + +namespace caf +{ +class PdmObjectGroup; +} + +//================================================================================================== +/// +//================================================================================================== +class RicPasteEllipseFractureFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static RimFractureTemplateCollection* fractureTemplateCollection(); +}; diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp new file mode 100644 index 0000000000..ed429b4219 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteStimPlanFractureFeature.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RicNewEllipseFractureTemplateFeature.h" + +#include "RimFractureTemplateCollection.h" +#include "RimStimPlanFractureTemplate.h" + +#include "cafPdmObjectGroup.h" +#include "cafSelectionManager.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicPasteStimPlanFractureFeature, "RicPasteStimPlanFractureFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteStimPlanFractureFeature::isCommandEnabled() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + if (typedObjects.size() == 0) + { + return false; + } + + if (fractureTemplateCollection()) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteStimPlanFractureFeature::onActionTriggered(bool isChecked) +{ + auto fractureTemplateColl = fractureTemplateCollection(); + if (!fractureTemplateColl) return; + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> typedObjects; + objectGroup.objectsByType(&typedObjects); + + for (const auto& source : typedObjects) + { + auto copyOfStimPlanTemplate = dynamic_cast( + source->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + fractureTemplateColl->addFractureTemplate(copyOfStimPlanTemplate); + + RicNewEllipseFractureTemplateFeature::selectFractureTemplateAndUpdate(fractureTemplateColl, copyOfStimPlanTemplate); + } + + return; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteStimPlanFractureFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste (StimPlan Fracture)"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplateCollection* RicPasteStimPlanFractureFeature::fractureTemplateCollection() +{ + RimFractureTemplateCollection* fractureTemplateColl = nullptr; + + auto destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (destinationObject) + { + destinationObject->firstAncestorOrThisOfType(fractureTemplateColl); + } + + return fractureTemplateColl; +} diff --git a/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h new file mode 100644 index 0000000000..982b51ec21 --- /dev/null +++ b/ApplicationCode/Commands/FractureCommands/RicPasteStimPlanFractureFeature.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +class RimFractureTemplateCollection; + +namespace caf +{ +class PdmObjectGroup; +} + +//================================================================================================== +/// +//================================================================================================== +class RicPasteStimPlanFractureFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static RimFractureTemplateCollection* fractureTemplateCollection(); +}; diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake index 8d4df6e2cb..d6a827a118 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/IntersectionBoxCommands/CMakeLists_files.cmake @@ -1,25 +1,20 @@ -# 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}RicBoxManipulatorEventHandler.h -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxZSliceFeature.h -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxAtPosFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxYSliceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxZSliceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxAtPosFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.cpp -${CEE_CURRENT_LIST_DIR}RicAppendIntersectionBoxFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxXSliceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxYSliceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxZSliceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionBoxAtPosFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAppendIntersectionBoxFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxXSliceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxYSliceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxZSliceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionBoxAtPosFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,8 +27,8 @@ ${SOURCE_GROUP_SOURCE_FILES} set (QT_MOC_HEADERS ${QT_MOC_HEADERS} -${CEE_CURRENT_LIST_DIR}RicBoxManipulatorEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicBoxManipulatorEventHandler.h ) -source_group( "CommandFeature\\IntersectionBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\IntersectionBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp index b5449d3dc7..34898705e6 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicAppendIntersectionBoxFeature.cpp @@ -21,8 +21,8 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" -#include "RiuMainWindow.h" +#include "RimGridView.h" +#include "Riu3DMainWindowTools.h" #include "cafCmdExecCommandManager.h" #include "cafSelectionManager.h" @@ -61,9 +61,9 @@ void RicAppendIntersectionBoxFeature::onActionTriggered(bool isChecked) intersectionBox->setToDefaultSizeBox(); coll->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); + Riu3DMainWindowTools::selectAsCurrentItem(intersectionBox); - RimView* rimView = nullptr; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfTypeAsserted(rimView); rimView->showGridCells(false); } diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp index d8b9cb928c..1f2b1838f4 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxAtPosFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxAtPosFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxAtPosFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp index 102971ae8b..980b68a69b 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxXSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxXSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxXSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp index abe6bff899..58908b5779 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxYSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxYSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -67,7 +67,7 @@ void RicIntersectionBoxYSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp index 0a73ce33b1..e568036c34 100644 --- a/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp +++ b/ApplicationCode/Commands/IntersectionBoxCommands/RicIntersectionBoxZSliceFeature.cpp @@ -23,7 +23,7 @@ #include "RimCase.h" #include "RimIntersectionBox.h" #include "RimIntersectionCollection.h" -#include "RimView.h" +#include "RimGridView.h" #include "RiuMainWindow.h" #include "RiuViewer.h" @@ -50,7 +50,7 @@ bool RicIntersectionBoxZSliceFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (activeView) { RimIntersectionCollection* coll = activeView->crossSectionCollection(); @@ -66,7 +66,7 @@ void RicIntersectionBoxZSliceFeature::onActionTriggered(bool isChecked) coll->updateConnectedEditors(); RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + RimGridView* rimView = nullptr; coll->firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake new file mode 100644 index 0000000000..9dc9020940 --- /dev/null +++ b/ApplicationCode/Commands/IntersectionViewCommands/CMakeLists_files.cmake @@ -0,0 +1,18 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RicNewIntersectionViewFeature.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RicNewIntersectionViewFeature.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "CommandFeature\\IntersectionView" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp new file mode 100644 index 0000000000..42d8e45ab0 --- /dev/null +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.cpp @@ -0,0 +1,131 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewIntersectionViewFeature.h" + +#include "Rim2dIntersectionView.h" +#include "RimCase.h" +#include "RimIntersection.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuSelectionManager.h" + +#include "cafSelectionManagerTools.h" + +#include +#include + +#include "RiuViewer.h" +#include "cvfCamera.h" + +CAF_CMD_SOURCE_INIT(RicNewIntersectionViewFeature, "RicNewIntersectionViewFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewIntersectionViewFeature::isCommandEnabled() +{ + std::set objects = selectedIntersections(); + + return !objects.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewIntersectionViewFeature::onActionTriggered(bool isChecked) +{ + std::set intersections = selectedIntersections(); + + Rim2dIntersectionView* objectToSelect = nullptr; + + for (auto intersection : intersections) + { + if (!intersection) continue; + + RimCase* rimCase = nullptr; + intersection->firstAncestorOrThisOfType(rimCase); + if (rimCase) + { + if (intersection->direction() != RimIntersection::CS_VERTICAL) + { + QString text = QString("The intersection view only supports vertical intersections.\n" + "The intersection '%1' is not vertical but a converted version will be shown in the view .").arg(intersection->name()); + + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "New Intersection View", text); + } + + Rim2dIntersectionView* intersectionView = intersection->correspondingIntersectionView(); + intersectionView->setVisible(true); + intersectionView->loadDataAndUpdate(); + + intersectionView->updateConnectedEditors(); + + objectToSelect = intersectionView; + } + } + + if (objectToSelect) + { + //RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewIntersectionViewFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Show 2D Intersection View"); + // actionToSetup->setIcon(QIcon(":/chain.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RicNewIntersectionViewFeature::selectedIntersections() +{ + std::set objects; + + RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); + RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); + + RiuGeneralSelectionItem* generalSelectionItem = static_cast(selItem); + if (generalSelectionItem) + { + RimIntersection* intersection = dynamic_cast(generalSelectionItem->m_object); + if (intersection) + { + objects.insert(intersection); + + // Return only the intersection the user clicked on + + return objects; + } + } + + { + std::vector selectedObjects = caf::selectedObjectsByType(); + for (auto obj : selectedObjects) + { + objects.insert(obj); + } + } + + return objects; +} diff --git a/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h new file mode 100644 index 0000000000..7f7a1af9d6 --- /dev/null +++ b/ApplicationCode/Commands/IntersectionViewCommands/RicNewIntersectionViewFeature.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimIntersection; + +//================================================================================================== +/// +//================================================================================================== +class RicNewIntersectionViewFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered(bool isChecked) override; + void setupActionLook(QAction* actionToSetup) override; + +private: + static std::set selectedIntersections(); +}; diff --git a/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake index a2fe983e05..dc59b75adc 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/OctaveScriptCommands/CMakeLists_files.cmake @@ -1,34 +1,29 @@ -# 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}RicAddScriptPathFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteScriptPathFeature.h -${CEE_CURRENT_LIST_DIR}RicEditScriptFeature.h -${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.h -${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicNewScriptFeature.h -${CEE_CURRENT_LIST_DIR}RicScriptFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicRefreshScriptsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddScriptPathFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteScriptPathFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditScriptFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptForCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewScriptFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicScriptFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicRefreshScriptsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddScriptPathFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteScriptPathFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditScriptFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExecuteScriptFeature.cpp -${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewScriptFeature.cpp -${CEE_CURRENT_LIST_DIR}RicScriptFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicRefreshScriptsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddScriptPathFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteScriptPathFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditScriptFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptForCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewScriptFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicScriptFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRefreshScriptsFeature.cpp ) set (QT_MOC_HEADERS ${QT_MOC_HEADERS} -${CEE_CURRENT_LIST_DIR}RicExecuteScriptForCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicExecuteScriptForCasesFeature.h ) list(APPEND CODE_HEADER_FILES @@ -39,4 +34,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\Script" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\Script" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp index b68fba9303..dbba4c0f2e 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicAddScriptPathFeature.cpp @@ -26,7 +26,7 @@ #include "RicScriptFeatureImpl.h" #include "RimScriptCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cvfAssert.h" @@ -49,7 +49,7 @@ bool RicAddScriptPathFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicAddScriptPathFeature::onActionTriggered(bool isChecked) { - QString selectedFolder = QFileDialog::getExistingDirectory(RiuMainWindow::instance(), "Select script folder"); + QString selectedFolder = QFileDialog::getExistingDirectory(Riu3DMainWindowTools::mainWindowWidget(), "Select script folder"); if (!selectedFolder.isEmpty()) { QString filePathString = RiaApplication::instance()->preferences()->scriptDirectories(); diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp index 7610e17792..fa21027efe 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicEditScriptFeature.cpp @@ -24,7 +24,7 @@ #include "RimCalcScript.h" #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" #include "cvfAssert.h" @@ -65,7 +65,7 @@ void RicEditScriptFeature::onActionTriggered(bool isChecked) if (!myProcess->waitForStarted(1000)) { - QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); } } } diff --git a/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp b/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp index 31b7e60011..c9a5e480e3 100644 --- a/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp +++ b/ApplicationCode/Commands/OctaveScriptCommands/RicNewScriptFeature.cpp @@ -27,7 +27,7 @@ #include "RimCalcScript.h" #include "RimScriptCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuTools.h" #include "cafUtils.h" @@ -86,7 +86,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) } bool ok; - fullPathFilenameNewScript = QInputDialog::getText(NULL, + fullPathFilenameNewScript = QInputDialog::getText(nullptr, "Specify new script file", "File name", QLineEdit::Normal, @@ -99,7 +99,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) QFile file(fullPathFilenameNewScript); if (!file.open(QIODevice::WriteOnly | QIODevice::Text)) { - QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to create file\n" + fullPathFilenameNewScript); return; } @@ -108,7 +108,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) if (calcScript) { - RiuMainWindow::instance()->selectAsCurrentItem(calcScript); + Riu3DMainWindowTools::selectAsCurrentItem(calcScript); } RiaApplication* app = RiaApplication::instance(); @@ -123,7 +123,7 @@ void RicNewScriptFeature::onActionTriggered(bool isChecked) if (!myProcess->waitForStarted(1000)) { - QMessageBox::warning(RiuMainWindow::instance(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Script editor", "Failed to start script editor executable\n" + scriptEditor); } } } diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake index 5a4634cd4e..9cd1e67568 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake @@ -1,27 +1,24 @@ -# 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}RicCopyReferencesToClipboardFeature.h -${CEE_CURRENT_LIST_DIR}RicCutReferencesToClipboardFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.h - -${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCopyReferencesToClipboardFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicCutReferencesToClipboardFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteFeatureImpl.h + +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseCasesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicCopyReferencesToClipboardFeature.cpp -${CEE_CURRENT_LIST_DIR}RicCutReferencesToClipboardFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteFeatureImpl.cpp - -${CEE_CURRENT_LIST_DIR}RicPasteEclipseCasesFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteEclipseViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteGeoMechViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCopyReferencesToClipboardFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicCutReferencesToClipboardFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteFeatureImpl.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseCasesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\ObjReferences" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\ObjReferences" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index 58ae9b9734..a09af8470a 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -21,7 +21,11 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" +#include "RimEnsembleCurveSet.h" +#include "RimFractureTemplate.h" #include "RimGeoMechView.h" +#include "RimIntersection.h" +#include "RimIntersectionBox.h" #include "RimMimeData.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" @@ -136,6 +140,14 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { return true; } + else if (dynamic_cast(pdmObject)) + { + return true; + } + else if (dynamic_cast(pdmObject)) + { + return true; + } else if (dynamic_cast(pdmObject)) { return true; @@ -152,6 +164,14 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported(caf::PdmObject { if (!wellAllocPlot && !rftPlot) return true; } + else if (dynamic_cast(pdmObject)) + { + return true; + } + else if (dynamic_cast(pdmObject)) + { + return true; + } return false; } diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp index 596c28adbc..971ccfae2b 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseCasesFeature.cpp @@ -126,7 +126,7 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(caf::PdmObjectGroup& o return; } - RimEclipseResultCase* mainResultCase = NULL; + RimEclipseResultCase* mainResultCase = nullptr; std::vector< std::vector > mainCaseGridDimensions; // Read out main grid and main grid dimensions if present in case group @@ -184,8 +184,8 @@ void RicPasteEclipseCasesFeature::addCasesToGridCaseGroup(caf::PdmObjectGroup& o } } - RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : nullptr; if (analysisModels) analysisModels->insertCaseInCaseGroup(gridCaseGroup, rimResultReservoir); caf::PdmDocument::updateUiIconStateRecursively(rimResultReservoir); diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp index 5dac65253a..95036187b7 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteEclipseViewsFeature.cpp @@ -21,13 +21,14 @@ #include "RiaApplication.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RicPasteFeatureImpl.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimSimWellInViewCollection.h" +#include "Rim2dIntersectionViewCollection.h" #include "cafPdmDocument.h" #include "cafPdmObjectGroup.h" @@ -102,6 +103,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked) rimReservoirView->resolveReferencesRecursively(); rimReservoirView->initAfterReadRecursively(); + eclipseCase->intersectionViewCollection()->syncFromExistingIntersections(false); rimReservoirView->loadDataAndUpdate(); caf::PdmDocument::updateUiIconStateRecursively(rimReservoirView); @@ -110,7 +112,7 @@ void RicPasteEclipseViewsFeature::onActionTriggered(bool isChecked) lastViewCopy = rimReservoirView; } - if (lastViewCopy) RiuMainWindow::instance()->selectAsCurrentItem(lastViewCopy); + if (lastViewCopy) Riu3DMainWindowTools::selectAsCurrentItem(lastViewCopy); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp index f35506c329..07e9b605ea 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteFeatureImpl.cpp @@ -95,13 +95,13 @@ RimIdenticalGridCaseGroup* RicPasteFeatureImpl::findGridCaseGroup(caf::PdmObject else if (dynamic_cast(objectHandle) || dynamic_cast(objectHandle)) { - RimIdenticalGridCaseGroup* gridCaseGroup = NULL; + RimIdenticalGridCaseGroup* gridCaseGroup = nullptr; objectHandle->firstAncestorOrThisOfType(gridCaseGroup); return gridCaseGroup; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ RimEclipseCase* RicPasteFeatureImpl::findEclipseCase(caf::PdmObjectHandle* objec return reservoirView->eclipseCase(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp index cf1b63151f..470373dffa 100644 --- a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteGeoMechViewsFeature.cpp @@ -21,7 +21,7 @@ #include "RicPasteFeatureImpl.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RimGeoMechView.h" #include "RimGeoMechCase.h" @@ -31,6 +31,7 @@ #include "cafSelectionManager.h" #include +#include "Rim2dIntersectionViewCollection.h" CAF_CMD_SOURCE_INIT(RicPasteGeoMechViewsFeature, "RicPasteGeoMechViewsFeature"); @@ -98,12 +99,13 @@ void RicPasteGeoMechViewsFeature::onActionTriggered(bool isChecked) rimReservoirView->loadDataAndUpdate(); + geomCase->intersectionViewCollection()->syncFromExistingIntersections(false); geomCase->updateConnectedEditors(); lastViewCopy = rimReservoirView; } - if (lastViewCopy) RiuMainWindow::instance()->selectAsCurrentItem(lastViewCopy); + if (lastViewCopy) Riu3DMainWindowTools::selectAsCurrentItem(lastViewCopy); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp new file mode 100644 index 0000000000..b7ed0e8e1c --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.cpp @@ -0,0 +1,163 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteIntersectionsFeature.h" + +#include "RicPasteFeatureImpl.h" + +#include "RimIntersection.h" +#include "RimIntersectionBox.h" +#include "RimIntersectionCollection.h" + +#include "RiuMainWindow.h" + +#include "cafPdmObjectGroup.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(RicPasteIntersectionsFeature, "RicPasteIntersectionsFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteIntersectionsFeature::isCommandEnabled() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector> intersectionObjects; + objectGroup.objectsByType(&intersectionObjects); + + std::vector> intersectionBoxObjects; + objectGroup.objectsByType(&intersectionBoxObjects); + + if (intersectionObjects.empty() && intersectionBoxObjects.empty()) + { + return false; + } + + caf::PdmObjectHandle* destinationObject = + dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + if (findIntersectionCollection(destinationObject)) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteIntersectionsFeature::onActionTriggered(bool isChecked) +{ + caf::PdmObjectHandle* destinationObject = + dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimIntersectionCollection* intersectionCollection = + RicPasteIntersectionsFeature::findIntersectionCollection(destinationObject); + + CAF_ASSERT(intersectionCollection); + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + if (objectGroup.objects.size() == 0) return; + + std::vector> intersectionObjects; + objectGroup.objectsByType(&intersectionObjects); + + for (size_t i = 0; i < intersectionObjects.size(); i++) + { + RimIntersection* intersection = dynamic_cast( + intersectionObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + QString nameOfCopy = QString("Copy of ") + intersection->name; + intersection->name = nameOfCopy; + + if (i == intersectionObjects.size() - 1) + { + intersectionCollection->appendIntersectionAndUpdate(intersection); + } + else + { + intersectionCollection->appendIntersectionNoUpdate(intersection); + } + } + + std::vector> intersectionBoxObjects; + objectGroup.objectsByType(&intersectionBoxObjects); + + for (size_t i = 0; i < intersectionBoxObjects.size(); i++) + { + RimIntersectionBox* intersectionBox = dynamic_cast( + intersectionBoxObjects[i]->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + QString nameOfCopy = QString("Copy of ") + intersectionBox->name; + intersectionBox->name = nameOfCopy; + + if (i == intersectionBoxObjects.size() - 1) + { + intersectionCollection->appendIntersectionBoxAndUpdate(intersectionBox); + } + else + { + intersectionCollection->appendIntersectionBoxNoUpdate(intersectionBox); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteIntersectionsFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste (Intersections)"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* RicPasteIntersectionsFeature::findIntersectionCollection(caf::PdmObjectHandle* objectHandle) +{ + RimIntersectionCollection* intersectionCollection = dynamic_cast(objectHandle); + if (intersectionCollection) + { + return intersectionCollection; + } + + RimIntersection* intersection = dynamic_cast(objectHandle); + if (intersection) + { + intersection->firstAncestorOrThisOfType(intersectionCollection); + return intersectionCollection; + } + + RimIntersectionBox* intersectionBox = dynamic_cast(objectHandle); + if (intersectionBox) + { + intersectionBox->firstAncestorOrThisOfType(intersectionCollection); + return intersectionCollection; + } + + return nullptr; +} diff --git a/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h new file mode 100644 index 0000000000..15a770b7b7 --- /dev/null +++ b/ApplicationCode/Commands/OperationsUsingObjReferences/RicPasteIntersectionsFeature.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmObjectHandle.h" + +class RimIntersectionCollection; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteIntersectionsFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; + +private: + static RimIntersectionCollection* findIntersectionCollection(caf::PdmObjectHandle* objectHandle); +}; diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.cpp b/ApplicationCode/Commands/RicCloseCaseFeature.cpp index aca46ec016..0fb3100b0c 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseCaseFeature.cpp @@ -23,6 +23,7 @@ #include "RimCaseCollection.h" #include "RimEclipseCase.h" +#include "RimEclipseResultCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimGeoMechCase.h" @@ -31,6 +32,8 @@ #include "RimOilField.h" #include "RimProject.h" #include "RimMainPlotCollection.h" +#include "RimGridSummaryCase.h" +#include "RimSummaryCaseMainCollection.h" #include "RimWellLogPlotCollection.h" #include "RiuMainWindow.h" @@ -49,7 +52,7 @@ CAF_CMD_SOURCE_INIT(RicCloseCaseFeature, "RicCloseCaseFeature"); //-------------------------------------------------------------------------------------------------- bool RicCloseCaseFeature::isCommandEnabled() { - return selectedEclipseCase() != NULL || selectedGeoMechCase() != NULL; + return !selectedCases().empty(); } //-------------------------------------------------------------------------------------------------- @@ -57,24 +60,44 @@ bool RicCloseCaseFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCloseCaseFeature::onActionTriggered(bool isChecked) { - RimEclipseCase* eclipseCase = selectedEclipseCase(); - RimGeoMechCase* geoMechCase = selectedGeoMechCase(); - if (eclipseCase) + std::vector rimCases = selectedCases(); + std::vector eclipseCases; + std::vector geoMechCases; + for (RimCase* rimCase : selectedCases()) { - std::vector casesToBeDeleted; - casesToBeDeleted.push_back(eclipseCase); - - if (userConfirmedGridCaseGroupChange(casesToBeDeleted)) + RimEclipseCase* eclipseCase = dynamic_cast(rimCase); + if (eclipseCase) { - deleteEclipseCase(eclipseCase); + eclipseCases.push_back(eclipseCase); + } + else + { + RimGeoMechCase* geoMechCase = dynamic_cast(rimCase); + if (geoMechCase) + { + geoMechCases.push_back(geoMechCase); + } + } + } + if (!eclipseCases.empty()) + { + if (userConfirmedGridCaseGroupChange(eclipseCases)) + { + for (RimEclipseCase* eclipseCase : eclipseCases) + { + deleteEclipseCase(eclipseCase); + } RiuMainWindow::instance()->cleanupGuiCaseClose(); } } - else if (geoMechCase) + + if (!geoMechCases.empty()) { - deleteGeoMechCase(geoMechCase); - + for (RimGeoMechCase* geoMechCase : geoMechCases) + { + deleteGeoMechCase(geoMechCase); + } RiuMainWindow::instance()->cleanupGuiCaseClose(); } } @@ -92,33 +115,11 @@ void RicCloseCaseFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEclipseCase* RicCloseCaseFeature::selectedEclipseCase() const -{ - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); - - if (selection.size() > 0) - { - return selection[0]; - } - - return NULL; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimGeoMechCase* RicCloseCaseFeature::selectedGeoMechCase() const +std::vector RicCloseCaseFeature::selectedCases() const { - std::vector selection; + std::vector selection; caf::SelectionManager::instance()->objectsByType(&selection); - - if (selection.size() > 0) - { - return selection[0]; - } - - return NULL; + return selection; } //-------------------------------------------------------------------------------------------------- @@ -129,8 +130,8 @@ void RicCloseCaseFeature::removeCaseFromAllGroups(RimEclipseCase* eclipseCase) CVF_ASSERT(eclipseCase); RimProject* proj = RiaApplication::instance()->project(); - RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : NULL; + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimEclipseCaseCollection* analysisModels = (activeOilField) ? activeOilField->analysisModels() : nullptr; if (analysisModels) { analysisModels->removeCaseFromAllGroups(eclipseCase); @@ -186,6 +187,22 @@ void RicCloseCaseFeature::deleteEclipseCase(RimEclipseCase* eclipseCase) removeCaseFromAllGroups(eclipseCase); } + RimEclipseResultCase* resultCase = dynamic_cast(eclipseCase); + if (resultCase) + { + RimProject* project = RiaApplication::instance()->project(); + RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; + if (sumCaseColl) + { + RimSummaryCase* summaryCase = sumCaseColl->findSummaryCaseFromEclipseResultCase(resultCase); + if (summaryCase) + { + RimGridSummaryCase* gridSummaryCase = dynamic_cast(summaryCase); + sumCaseColl->convertGridSummaryCasesToFileSummaryCases(gridSummaryCase); + } + } + } + delete eclipseCase; } @@ -197,8 +214,8 @@ void RicCloseCaseFeature::deleteGeoMechCase(RimGeoMechCase* geoMechCase) CVF_ASSERT(geoMechCase); RimProject* proj = RiaApplication::instance()->project(); - RimOilField* activeOilField = proj ? proj->activeOilField() : NULL; - RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : NULL; + RimOilField* activeOilField = proj ? proj->activeOilField() : nullptr; + RimGeoMechModels* models = (activeOilField) ? activeOilField->geoMechModels() : nullptr; if (models) { models->cases.removeChildObject(geoMechCase); @@ -240,7 +257,7 @@ bool RicCloseCaseFeature::userConfirmedGridCaseGroupChange(const std::vectorfirstAncestorOrThisOfType(gridCaseGroup); if (gridCaseGroup && hasAnyStatisticsResults(gridCaseGroup)) diff --git a/ApplicationCode/Commands/RicCloseCaseFeature.h b/ApplicationCode/Commands/RicCloseCaseFeature.h index 7e6199f9b1..fd8224dcb9 100644 --- a/ApplicationCode/Commands/RicCloseCaseFeature.h +++ b/ApplicationCode/Commands/RicCloseCaseFeature.h @@ -25,6 +25,7 @@ class RimEclipseCase; class RimGeoMechCase; +class RimCase; class RimIdenticalGridCaseGroup; //================================================================================================== @@ -45,8 +46,7 @@ class RicCloseCaseFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ); private: - RimEclipseCase* selectedEclipseCase() const; - RimGeoMechCase* selectedGeoMechCase() const; + std::vector selectedCases() const; void deleteGeoMechCase(RimGeoMechCase* geoMechCase); diff --git a/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp b/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp index 14862db423..4ec8d50ba2 100644 --- a/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp +++ b/ApplicationCode/Commands/RicCloseObservedDataFeature.cpp @@ -40,8 +40,8 @@ CAF_CMD_SOURCE_INIT(RicCloseObservedDataFeature, "RicCloseObservedDataFeature"); //-------------------------------------------------------------------------------------------------- void RicCloseObservedDataFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Close"); - actionToSetup->setIcon(QIcon(":/Erase.png")); + actionToSetup->setText("Close"); + actionToSetup->setIcon(QIcon(":/Erase.png")); } //-------------------------------------------------------------------------------------------------- @@ -96,8 +96,8 @@ bool RicCloseObservedDataFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCloseObservedDataFeature::onActionTriggered(bool isChecked) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); CVF_ASSERT(selection.size() > 0); RicCloseObservedDataFeature::deleteObservedData(selection); diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp index e25bc0861b..8471ef0cd7 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseFeature.cpp @@ -28,7 +28,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafSelectionManager.h" @@ -43,8 +43,8 @@ CAF_CMD_SOURCE_INIT(RicCloseSummaryCaseFeature, "RicCloseSummaryCaseFeature"); //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Close Summary Case"); - actionToSetup->setIcon(QIcon(":/Erase.png")); + actionToSetup->setText("Close Summary Case"); + actionToSetup->setIcon(QIcon(":/Erase.png")); } //-------------------------------------------------------------------------------------------------- @@ -71,7 +71,7 @@ void RicCloseSummaryCaseFeature::deleteSummaryCases(const std::vectorupdateAllRequiredEditors(); } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } @@ -103,8 +103,8 @@ bool RicCloseSummaryCaseFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicCloseSummaryCaseFeature::onActionTriggered(bool isChecked) { - std::vector selection; - caf::SelectionManager::instance()->objectsByType(&selection); + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); CVF_ASSERT(selection.size() > 0); RicCloseSummaryCaseFeature::deleteSummaryCases(selection); diff --git a/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp b/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp index b93d26675a..efe1de1016 100644 --- a/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCloseSummaryCaseInCollectionFeature.cpp @@ -30,7 +30,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafSelectionManager.h" @@ -86,7 +86,7 @@ void RicCloseSummaryCaseInCollectionFeature::onActionTriggered(bool isChecked) RicCloseSummaryCaseFeature::deleteSummaryCases(summaryCaseCollection->allSummaryCases()); } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp new file mode 100644 index 0000000000..628f42bdd4 --- /dev/null +++ b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.cpp @@ -0,0 +1,91 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicConvertGroupToEnsembleFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicImportEnsembleFeature.h" +#include "RicCreateSummaryCaseCollectionFeature.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include "cafSelectionManagerTools.h" + +#include +#include +#include +#include + + +CAF_CMD_SOURCE_INIT(RicConvertGroupToEnsembleFeature, "RicConvertGroupToEnsembleFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicConvertGroupToEnsembleFeature::isCommandEnabled() +{ + const auto& selGroups = caf::selectedObjectsByTypeStrict(); + if (selGroups.empty()) return false; + + for (const auto& group : selGroups) + { + if (!group->isEnsemble()) return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicConvertGroupToEnsembleFeature::onActionTriggered(bool isChecked) +{ + const auto& selGroups = caf::selectedObjectsByTypeStrict(); + + for (const auto& group : selGroups) + { + if (group->isEnsemble()) continue; + + RicImportEnsembleFeature::validateEnsembleCases(group->allSummaryCases()); + group->setAsEnsemble(true); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicConvertGroupToEnsembleFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); + actionToSetup->setText("Convert to Ensemble"); +} diff --git a/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h new file mode 100644 index 0000000000..f27f883ac0 --- /dev/null +++ b/ApplicationCode/Commands/RicConvertGroupToEnsembleFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimSummaryCase; + + +//================================================================================================== +/// +//================================================================================================== +class RicConvertGroupToEnsembleFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; + + diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp index 62789b362f..7e0ac8a2e0 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.cpp @@ -24,7 +24,7 @@ #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafPdmObject.h" #include "cafSelectionManager.h" @@ -33,6 +33,24 @@ CAF_CMD_SOURCE_INIT(RicCreateSummaryCaseCollectionFeature, "RicCreateSummaryCaseCollectionFeature"); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicCreateSummaryCaseCollectionFeature::groupSummaryCases(std::vector cases, const QString& groupName, bool isEnsemble) +{ + RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; + if (!cases.empty()) + { + cases[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); + + summaryCaseMainCollection->addCaseCollection(cases, groupName, isEnsemble); + summaryCaseMainCollection->updateConnectedEditors(); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(summaryCaseMainCollection->summaryCaseCollections().back()->allSummaryCases().front()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -65,13 +83,7 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&selection); if (selection.size() == 0) return; - RimSummaryCaseMainCollection* summaryCaseMainCollection = nullptr; - selection[0]->firstAncestorOrThisOfTypeAsserted(summaryCaseMainCollection); - - summaryCaseMainCollection->addCaseCollection(selection); - summaryCaseMainCollection->updateConnectedEditors(); - - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(summaryCaseMainCollection->summaryCaseCollections().back()->allSummaryCases().front()); + groupSummaryCases(selection, ""); } //-------------------------------------------------------------------------------------------------- @@ -80,5 +92,5 @@ void RicCreateSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) void RicCreateSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Group Summary Cases"); - actionToSetup->setIcon(QIcon(":/Folder.png")); + actionToSetup->setIcon(QIcon(":/SummaryGroup16x16.png")); } diff --git a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h index e39857e9a7..eb8a1fbb78 100644 --- a/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h +++ b/ApplicationCode/Commands/RicCreateSummaryCaseCollectionFeature.h @@ -22,6 +22,8 @@ #include +class RimSummaryCase; + //================================================================================================== /// //================================================================================================== @@ -29,6 +31,8 @@ class RicCreateSummaryCaseCollectionFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; + static void groupSummaryCases(std::vector cases, const QString& groupName, bool isEnsemble = false); + private: virtual bool isCommandEnabled() override; virtual void onActionTriggered(bool isChecked) override; diff --git a/ApplicationCode/Commands/RicDeleteItemExec.cpp b/ApplicationCode/Commands/RicDeleteItemExec.cpp index 1aab715e05..356955e036 100644 --- a/ApplicationCode/Commands/RicDeleteItemExec.cpp +++ b/ApplicationCode/Commands/RicDeleteItemExec.cpp @@ -23,18 +23,20 @@ #include "RiaApplication.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RimCellRangeFilterCollection.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimFormationNamesCollection.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimIntersectionCollection.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimSummaryPlotCollection.h" #include "RimSummaryCrossPlotCollection.h" -#include "RimView.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" #include "RimViewLinkerCollection.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -42,11 +44,9 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cafNotificationCenter.h" @@ -55,6 +55,7 @@ #include "cafPdmReferenceHelper.h" #include "cafPdmUiFieldHandle.h" #include "cafSelectionManager.h" +#include "Rim2dIntersectionViewCollection.h" //-------------------------------------------------------------------------------------------------- @@ -96,7 +97,7 @@ void RicDeleteItemExec::redo() caf::PdmObjectHandle* parentObj = listField->ownerObject(); parentObj->uiCapability()->updateConnectedEditors(); - RimView* view = NULL; + Rim3dView* view = nullptr; parentObj->firstAncestorOrThisOfType(view); // Range Filters @@ -106,7 +107,7 @@ void RicDeleteItemExec::redo() if (rangeFilterColl) { - rangeFilterColl->updateDisplayModeNotifyManagedViews(NULL); + rangeFilterColl->updateDisplayModeNotifyManagedViews(nullptr); } // Prop Filter @@ -129,8 +130,17 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(crossSectionColl); if (view && crossSectionColl) { + crossSectionColl->syncronize2dIntersectionViews(); view->scheduleCreateDisplayModelAndRedraw(); } + else + { + RimCase* parentCase = dynamic_cast(parentObj); + if ( parentCase ) // A view was deleted. Need to update the list of intersection views + { + parentCase->intersectionViewCollection()->syncFromExistingIntersections(true); + } + } // SimWell Fractures RimSimWellInView* simWell; @@ -140,7 +150,6 @@ void RicDeleteItemExec::redo() view->scheduleCreateDisplayModelAndRedraw(); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimFractureTemplateCollection* fracTemplateColl; parentObj->firstAncestorOrThisOfType(fracTemplateColl); if (fracTemplateColl) @@ -152,9 +161,9 @@ void RicDeleteItemExec::redo() proj->createDisplayModelAndRedrawAllViews(); } - std::vector views; + std::vector views; proj->allVisibleViews(views); - for (RimView* view : views) + for (Rim3dView* view : views) { if (dynamic_cast(view)) { @@ -162,7 +171,6 @@ void RicDeleteItemExec::redo() } } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES // Well paths @@ -209,7 +217,7 @@ void RicDeleteItemExec::redo() { if (wellLogPlotCollection->wellLogPlots.empty()) { - RimProject* project = NULL; + RimProject* project = nullptr; parentObj->firstAncestorOrThisOfType(project); if (project) { @@ -220,13 +228,13 @@ void RicDeleteItemExec::redo() // Linked views - RimViewLinkerCollection* viewLinkerCollection = NULL; + RimViewLinkerCollection* viewLinkerCollection = nullptr; parentObj->firstAncestorOrThisOfType(viewLinkerCollection); if (viewLinkerCollection) { viewLinkerCollection->uiCapability()->updateConnectedEditors(); - RimProject* project = NULL; + RimProject* project = nullptr; parentObj->firstAncestorOrThisOfType(project); if (project) { @@ -254,7 +262,8 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(summaryPlotCollection); if (summaryPlotCollection) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + summaryPlotCollection->updateSummaryNameHasChanged(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } @@ -262,9 +271,18 @@ void RicDeleteItemExec::redo() parentObj->firstAncestorOrThisOfType(summaryCrossPlotCollection); if (summaryCrossPlotCollection) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } + + RimEnsembleCurveSetCollection* ensembleCurveSetColl = nullptr; + parentObj->firstAncestorOrThisOfType(ensembleCurveSetColl); + if (ensembleCurveSetColl) + { + RimSummaryPlot* plot = nullptr; + ensembleCurveSetColl->firstAncestorOrThisOfType(plot); + if (plot) plot->updateConnectedEditors(); + } } } diff --git a/ApplicationCode/Commands/RicDeleteItemFeature.cpp b/ApplicationCode/Commands/RicDeleteItemFeature.cpp index 79e1893a6e..5f3b678afb 100644 --- a/ApplicationCode/Commands/RicDeleteItemFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteItemFeature.cpp @@ -25,6 +25,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipseView.h" +#include "RimEnsembleCurveSet.h" #include "RimFishbonesMultipleSubs.h" #include "RimFormationNames.h" #include "RimFormationNamesCollection.h" @@ -50,14 +51,12 @@ #include "RimWellLogRftCurve.h" #include "RimWellRftPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimEllipseFractureTemplate.h" #include "RimSimWellFracture.h" #include "RimSimWellFractureCollection.h" #include "RimStimPlanFractureTemplate.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cafCmdExecCommandManager.h" @@ -113,15 +112,13 @@ bool isDeletable(caf::PdmUiItem* uiItem) if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; if (dynamic_cast(uiItem)) return true; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + if (dynamic_cast(uiItem)) return true; return false; } diff --git a/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp b/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp index 5f5a22107f..3181e20f48 100644 --- a/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp +++ b/ApplicationCode/Commands/RicDeleteSummaryCaseCollectionFeature.cpp @@ -125,7 +125,7 @@ void RicDeleteSummaryCaseCollectionFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicDeleteSummaryCaseCollectionFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setText("Delete Summary Case Group"); + actionToSetup->setText("Delete Summary Case Group/Ensemble"); actionToSetup->setIcon(QIcon(":/Erase.png")); } diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.cpp b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp new file mode 100644 index 0000000000..f4dbe65eb9 --- /dev/null +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.cpp @@ -0,0 +1,855 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicFileHierarchyDialog.h" +#include "ExportCommands/RicSnapshotViewToClipboardFeature.h" +#include "ExportCommands/RicSnapshotViewToFileFeature.h" +#include "ExportCommands/RicSnapshotFilenameGenerator.h" + +#include "RiaApplication.h" +#include "RiaFilePathTools.h" + +#include "RimEclipseView.h" +#include "Rim3dOverlayInfoConfig.h" + +#include "RiuPlotMainWindow.h" +#include "RiuSummaryQwtPlot.h" +#include "RiuTools.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#define DEFAULT_DIALOG_WIDTH 750 +#define DEFAULT_DIALOG_INIT_HEIGHT 150 +#define DEFAULT_DIALOG_FIND_HEIGHT 350 +#define FIND_BUTTON_FIND_TEXT "Find" +#define FIND_BUTTON_CANCEL_TEXT "Cancel" +#define NO_FILES_FOUND_TEXT "No files found" +#define SCANNING_DIRS_TEXT "Scanning Directories" +#define FINDING_FILES_TEXT "Finding Files" + +//-------------------------------------------------------------------------------------------------- +/// Internal variables +//-------------------------------------------------------------------------------------------------- +static const QChar SEPARATOR = RiaFilePathTools::SEPARATOR; + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +static QStringList prefixStrings(const QStringList& strings, const QString& prefix); +static QStringList trimLeftStrings(const QStringList& strings, const QString& trimText); +static void sortStringsByLength(QStringList& strings, bool ascending = true); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialog::RicFileHierarchyDialog(QWidget* parent) + : QDialog(parent, RiuTools::defaultDialogFlags()) +{ + // Create widgets + m_rootDirLabel = new QLabel(); + m_rootDir = new QLineEdit(); + m_browseButton = new QPushButton(); + m_pathFilterLabel = new QLabel(); + m_pathFilter = new QLineEdit(); + m_fileFilterLabel = new QLabel(); + m_fileFilter = new QLineEdit(); + m_fileExtensionLabel = new QLabel(); + m_effectiveFilterLabel = new QLabel(); + m_effectiveFilter = new QLabel(); + m_fileListLabel = new QLabel(); + m_fileList = new QListWidget(); + m_findOrCancelButton = new QPushButton(); + + m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + + // Connect to signals + connect(m_rootDir, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_pathFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_fileFilter, SIGNAL(textChanged(const QString&)), this, SLOT(slotFilterChanged(const QString&))); + connect(m_fileList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotFileListCustomMenuRequested(const QPoint&))); + + connect(m_findOrCancelButton, SIGNAL(clicked()), this, SLOT(slotFindOrCancelButtonClicked())); + connect(m_buttons, SIGNAL(accepted()), this, SLOT(slotDialogOkClicked())); + connect(m_buttons, SIGNAL(rejected()), this, SLOT(slotDialogCancelClicked())); + connect(m_browseButton, SIGNAL(clicked()), this, SLOT(slotBrowseButtonClicked())); + + // Set widget properties + m_rootDirLabel->setText("Root folder"); + m_pathFilterLabel->setText("Path pattern"); + m_fileFilterLabel->setText("File pattern"); + m_effectiveFilterLabel->setText("Effective filter"); + m_effectiveFilter->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + m_fileListLabel->setText("Files found"); + m_fileListLabel->setVisible(false); + m_fileList->setSelectionMode(QAbstractItemView::ExtendedSelection); + m_fileList->setVisible(false); + m_fileList->setContextMenuPolicy(Qt::CustomContextMenu); + m_browseButton->setText("..."); + m_browseButton->setFixedWidth(25); + m_findOrCancelButton->setText(FIND_BUTTON_FIND_TEXT); + m_findOrCancelButton->setFixedWidth(75); + + // Define layout + QVBoxLayout* dialogLayout = new QVBoxLayout(); + + QGroupBox* inputGroup = new QGroupBox("Filter"); + QGridLayout* inputGridLayout = new QGridLayout(); + inputGridLayout->addWidget(m_rootDirLabel, 0, 0); + inputGridLayout->addWidget(m_rootDir, 0, 1); + inputGridLayout->addWidget(m_browseButton, 0, 2); + inputGridLayout->addWidget(m_pathFilterLabel, 1, 0); + inputGridLayout->addWidget(m_pathFilter, 1, 1); + inputGridLayout->addWidget(m_fileFilterLabel, 2, 0); + inputGridLayout->addWidget(m_fileFilter, 2, 1); + inputGridLayout->addWidget(m_fileExtensionLabel, 2, 2); + inputGroup->setLayout(inputGridLayout); + + QGroupBox* outputGroup = new QGroupBox("Files"); + QGridLayout* outputGridLayout = new QGridLayout(); + outputGridLayout->addWidget(m_effectiveFilterLabel, 0, 0); + outputGridLayout->addWidget(m_effectiveFilter, 0, 1); + outputGridLayout->addWidget(m_findOrCancelButton, 0, 2); + outputGridLayout->addWidget(m_fileListLabel, 1, 0); + outputGridLayout->addWidget(m_fileList, 1, 1, 1, 2); + outputGroup->setLayout(outputGridLayout); + + dialogLayout->addWidget(inputGroup); + dialogLayout->addWidget(outputGroup); + dialogLayout->addWidget(m_buttons); + + setLayout(dialogLayout); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialog::~RicFileHierarchyDialog() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicFileHierarchyDialogResult RicFileHierarchyDialog::runRecursiveSearchDialog(QWidget *parent /*= 0*/, + const QString &caption /*= QString()*/, + const QString &dir /*= QString()*/, + const QString &pathFilter /*= QString()*/, + const QString &fileNameFilter /*= QString()*/, + const QStringList &fileExtensions /*= QStringList()*/) +{ + QStringList files; + RicFileHierarchyDialog dialog(parent); + + dialog.setWindowTitle(caption); + + dialog.m_rootDir->setText(QDir::toNativeSeparators(dir)); + dialog.m_pathFilter->setText(pathFilter); + dialog.m_fileFilter->setText(fileNameFilter); + dialog.m_fileExtensions = trimLeftStrings(fileExtensions, "."); + + dialog.updateEffectiveFilter(); + dialog.clearFileList(); + dialog.setOkButtonEnabled(false); + + dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); + dialog.exec(); + + return RicFileHierarchyDialogResult(dialog.result() == QDialog::Accepted, dialog.files(), dialog.rootDir(), dialog.pathFilter(), dialog.fileNameFilter()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::files() const +{ + return m_files; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::rootDir() const +{ + QString rootDir = RiaFilePathTools::toInternalSeparator(m_rootDir->text()); + return RiaFilePathTools::appendSeparatorIfNo(rootDir); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::pathFilter() const +{ + return RiaFilePathTools::toInternalSeparator(m_pathFilter->text()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::fileNameFilter() const +{ + return m_fileFilter->text(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::fileExtensions() const +{ + QString extFromFilter = extensionFromFileNameFilter(); + if (!extFromFilter.isEmpty()) + { + return QStringList({ extFromFilter }); + } + + QStringList exts = m_fileExtensions; + sortStringsByLength(exts); + return exts; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::fileExtensionsText() const +{ + QString extFromFilter = extensionFromFileNameFilter(); + if (!extFromFilter.isEmpty()) return ""; + else return prefixStrings(fileExtensions(), ".").join(" | "); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::extensionFromFileNameFilter() const +{ + for (const QString& ext : m_fileExtensions) + { + if (m_fileFilter->text().endsWith(ext, Qt::CaseInsensitive)) + { + return ext; + } + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicFileHierarchyDialog::cancelPressed() const +{ + return m_cancelPressed; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::appendToFileList(const QString& fileName) +{ + QString itemText = fileName; + itemText.remove(0, rootDir().size()); + QListWidgetItem* item = new QListWidgetItem(itemText, m_fileList); + item->setFlags(item->flags() | Qt::ItemIsUserCheckable); + item->setCheckState(Qt::Checked); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::clearFileList() +{ + m_files.clear(); + m_fileList->clear(); + setOkButtonEnabled(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::updateStatus(Status status, const QString& extraText) +{ + static int progressLoopStep = 0; + static time_t lastStatusUpdate = 0; + time_t now = time(nullptr); + + QString newStatus; + if (status == SEARCHING_FOR_DIRS || status == SEARCHING_FOR_FILES ) + { + switch ( status ) + { + case SEARCHING_FOR_DIRS: newStatus = SCANNING_DIRS_TEXT; break; + case SEARCHING_FOR_FILES: newStatus = FINDING_FILES_TEXT; break; + } + + for (int progress = 0; progress < progressLoopStep; ++progress) + { + newStatus += " ."; + } + + if (now != lastStatusUpdate) progressLoopStep++; // If less than one second since last update, do not increment + + if (progressLoopStep >= 5) progressLoopStep = 0; + + if (!extraText.isEmpty()) newStatus += "\n" + extraText; + } + else if (status == NO_FILES_FOUND) + { + newStatus = NO_FILES_FOUND_TEXT; + } + + lastStatusUpdate = now; + + m_fileList->clear(); + new QListWidgetItem(newStatus, m_fileList); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicFileHierarchyDialog::currentStatus() const +{ + return m_fileList->item(0) ? m_fileList->item(0)->text() : ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::findMatchingFiles() +{ + if (m_rootDir->text().isEmpty()) return QStringList(); + + //const QStringList& dirs = buildDirectoryListRecursive(rootDir()); + + QStringList dirs; + + if ( this->pathFilter().isEmpty() ) dirs.append(this->rootDir()); + + buildDirectoryListRecursiveSimple(this->rootDir(), this->pathFilter(), &dirs); + + const QStringList& files = findFilesInDirs(dirs); + + this->clearFileList(); + + for (const auto& file : files) + { + appendToFileList(file); + } + return files; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::buildDirectoryListRecursive(const QString& currentDir, int level) +{ + QStringList allDirs; + + if (cancelPressed()) return allDirs; + + QString currPathFilter = pathFilter(); + bool subStringFilter = false; + + // Optimizing for speed by a refined match at first directory level + if (level == 1) + { + QString pathFilter = this->pathFilter(); + if (!pathFilter.startsWith("*")) + { + int wildcardIndex = pathFilter.indexOf(QRegExp(QString("[*%1]").arg(SEPARATOR))); + if (wildcardIndex >= 0) + { + currPathFilter = pathFilter.left(wildcardIndex + 1); + subStringFilter = true; + } + } + } + + QString currRelPath = RiaFilePathTools::relativePath(rootDir(), currentDir); + if (pathFilterMatch(currPathFilter, currRelPath)) + { + allDirs.push_back(currentDir); + } + else if(level == 1 && subStringFilter) + { + return QStringList(); + } + + QDir qdir(currentDir); + QStringList subDirs = qdir.entryList(QDir::Dirs | QDir::NoDotAndDotDot); + for (QString subDir : subDirs) + { + QString subDirFullPath = qdir.absoluteFilePath(subDir); + updateStatus(SEARCHING_FOR_DIRS, subDirFullPath); + QApplication::processEvents(); + allDirs += buildDirectoryListRecursive(subDirFullPath, level + 1); + } + return cancelPressed() ? QStringList() : allDirs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::buildDirectoryListRecursiveSimple(const QString& rootDir, + const QString& remainingPathFilter, + QStringList* accumulatedDirs) +{ + if (cancelPressed()) return; + + QString currentRemainingpathFilter = remainingPathFilter; + { + // Remove prefixing or trailing path separators from filter + + int pathSepIdx = currentRemainingpathFilter.indexOf(SEPARATOR); + while ( pathSepIdx == 0 ) + { + currentRemainingpathFilter.remove(pathSepIdx, 1); + pathSepIdx = currentRemainingpathFilter.indexOf(SEPARATOR); + } + + if ( currentRemainingpathFilter.endsWith(SEPARATOR) ) + { + currentRemainingpathFilter.chop(1); + } + } + + QString effectiveRootDir = rootDir; + { + // Remove trailing path separator from root + if ( effectiveRootDir.endsWith(SEPARATOR) ) + { + effectiveRootDir.chop(1); + } + } + + // Search pathfilter for the first wildcard. + // Use the path up to that directory directly, short-cutting the search + { + std::set sortedWildCardPositions; + sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("*")); + sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("?")); + sortedWildCardPositions.insert(currentRemainingpathFilter.indexOf("[")); + + int minWildCardPos = -1; + for ( int wildCardPos : sortedWildCardPositions ) + { + if ( wildCardPos == -1 ) continue; + + minWildCardPos = wildCardPos; + break; + } + + if ( minWildCardPos == -1 ) + { + effectiveRootDir += SEPARATOR + currentRemainingpathFilter; + currentRemainingpathFilter = ""; + } + else + { + int pathSepPos = currentRemainingpathFilter.indexOf(SEPARATOR); + while ( pathSepPos != -1 && pathSepPos < minWildCardPos ) + { + effectiveRootDir += SEPARATOR + currentRemainingpathFilter.left(pathSepPos); + currentRemainingpathFilter.remove(0, pathSepPos + 1); // include the separator + minWildCardPos -= (pathSepPos + 1); + pathSepPos = currentRemainingpathFilter.indexOf(SEPARATOR); + } + } + } + + // Find the filter to use for this directory level + // Assumes no prefixed path separator + + QStringList subDirsFullPath; + { + int pathSepIdx = currentRemainingpathFilter.indexOf(SEPARATOR); + QString currentDirNameFilter = currentRemainingpathFilter.left(pathSepIdx); + + if ( pathSepIdx == -1 ) + { + currentRemainingpathFilter = ""; + } + else + { + currentRemainingpathFilter.remove(0, pathSepIdx); + } + + if ( currentDirNameFilter.isEmpty() ) currentDirNameFilter = "*"; + + + + QDir qdir(effectiveRootDir, currentDirNameFilter, QDir::NoSort, QDir::Dirs | QDir::NoDotAndDotDot); + + // Add effectiveRoot if current dir name filter =""or"*" or "?" and currentRemainingpathFilter = "" + // and remainingPathFilter not empty + if ( (currentDirNameFilter == "*" || currentDirNameFilter == "?") + && currentRemainingpathFilter.isEmpty() + && !remainingPathFilter.isEmpty()) + { + (*accumulatedDirs) += qdir.absolutePath(); + } + + QStringList subDirs = qdir.entryList(); + + for ( const QString& subDir : subDirs ) + { + QString fullPath = qdir.absoluteFilePath(subDir); + subDirsFullPath += fullPath; + (*accumulatedDirs) += fullPath; + } + } + + for (const QString& subDir : subDirsFullPath) + { + updateStatus(SEARCHING_FOR_DIRS, subDir); + QApplication::processEvents(); + buildDirectoryListRecursiveSimple(subDir, currentRemainingpathFilter, accumulatedDirs); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::findFilesInDirs(const QStringList& dirs) +{ + QStringList allFiles; + QStringList filters = createNameFilterList(fileNameFilter(), fileExtensions()); + + for (const auto& dir : dirs) + { + QDir qdir(dir); + QStringList files = qdir.entryList(filters, QDir::Files); + + updateStatus(SEARCHING_FOR_FILES, qdir.absolutePath()); + QApplication::processEvents(); + + for (QString file : files) + { + QString absFilePath = qdir.absoluteFilePath(file); + allFiles.append(absFilePath); + } + } + return allFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicFileHierarchyDialog::createNameFilterList(const QString &fileNameFilter, const QStringList &fileExtensions) +{ + QStringList nameFilter; + QString effectiveFileNameFilter = !fileNameFilter.isEmpty() ? fileNameFilter : "*"; + + if (fileExtensions.size() == 0 || !extensionFromFileNameFilter().isEmpty()) + { + nameFilter.append(effectiveFileNameFilter); + } + else + { + for (QString fileExtension : fileExtensions) + { + nameFilter.append(effectiveFileNameFilter + "." + fileExtension); + } + } + return nameFilter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicFileHierarchyDialog::pathFilterMatch(const QString& pathFilter, const QString& relPath) +{ + QString pattern = pathFilter; + if (relPath.endsWith(SEPARATOR) && !pathFilter.endsWith(SEPARATOR)) pattern += SEPARATOR; + QRegExp regexp(pattern, Qt::CaseInsensitive, QRegExp::Wildcard); + return regexp.exactMatch(relPath); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::updateEffectiveFilter() +{ + QString effFilter = QString("%1/%2/%3%4") + .arg(m_rootDir->text()) + .arg(!m_pathFilter->text().isEmpty() ? m_pathFilter->text() : "*") + .arg(fileNameFilter()) + .arg(fileExtensionsText()); + + QString internalFilter(RiaFilePathTools::toInternalSeparator(effFilter)); + + // Remove duplicate separators + int len; + do + { + len = internalFilter.size(); + internalFilter.replace(QString("%1%1").arg(SEPARATOR), SEPARATOR); + } while (internalFilter.size() != len); + + // Present native separators to the user + m_effectiveFilter->setText(QDir::toNativeSeparators(internalFilter)); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::setOkButtonEnabled(bool enabled) +{ + m_buttons->button(QDialogButtonBox::Ok)->setEnabled(enabled); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotFilterChanged(const QString& text) +{ + clearFileList(); + updateEffectiveFilter(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotFileListCustomMenuRequested(const QPoint& point) +{ + QMenu menu; + QPoint globalPoint = point; + QAction* action; + + action = new QAction("On", this); + connect(action, SIGNAL(triggered()), SLOT(slotTurnOnFileListItems())); + menu.addAction(action); + + action = new QAction("Off", this); + connect(action, SIGNAL(triggered()), SLOT(slotTurnOffFileListItems())); + menu.addAction(action); + + action = new QAction("Toggle", this); + connect(action, SIGNAL(triggered()), SLOT(slotToggleFileListItems())); + menu.addAction(action); + + globalPoint = m_fileList->mapToGlobal(point); + menu.exec(globalPoint); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotToggleFileListItems() +{ + for (auto& item : m_fileList->selectedItems()) + { + if ((item->flags() & Qt::ItemIsUserCheckable) != 0) + { + item->setCheckState(item->checkState() == Qt::Checked ? Qt::Unchecked : Qt::Checked); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotTurnOffFileListItems() +{ + for (auto& item : m_fileList->selectedItems()) + { + if ((item->flags() & Qt::ItemIsUserCheckable) != 0) + { + item->setCheckState(Qt::Unchecked); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotTurnOnFileListItems() +{ + for (auto& item : m_fileList->selectedItems()) + { + if ((item->flags() & Qt::ItemIsUserCheckable) != 0) + { + item->setCheckState(Qt::Checked); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotFindOrCancelButtonClicked() +{ + if (m_findOrCancelButton->text() == FIND_BUTTON_FIND_TEXT) + { + clearFileList(); + + if(!m_fileList->isVisible()) + { + m_fileListLabel->setVisible(true); + m_fileList->setVisible(true); + + if(height() < DEFAULT_DIALOG_FIND_HEIGHT) resize(width(), DEFAULT_DIALOG_FIND_HEIGHT); + } + + m_findOrCancelButton->setText(FIND_BUTTON_CANCEL_TEXT); + + m_cancelPressed = false; + m_files = findMatchingFiles(); + + m_findOrCancelButton->setText(FIND_BUTTON_FIND_TEXT); + + if (m_cancelPressed) + { + clearFileList(); + } + else if(m_files.isEmpty()) + { + updateStatus(NO_FILES_FOUND); + } + + setOkButtonEnabled(!m_files.isEmpty()); + } + else + { + m_cancelPressed = true; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotDialogOkClicked() +{ + m_files.clear(); + + int itemCount = m_fileList->count(); + for (int i = 0; i < itemCount; i++) + { + const QListWidgetItem* item = m_fileList->item(i); + if ((item->flags() & Qt::ItemIsUserCheckable) != 0 && item->checkState()) + { + m_files.push_back(rootDir() + item->text()); + } + } + accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotDialogCancelClicked() +{ + m_files = QStringList(); + m_cancelPressed = true; + reject(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicFileHierarchyDialog::slotBrowseButtonClicked() +{ + QString folder = QFileDialog::getExistingDirectory(this, "Select root folder", m_rootDir->text()); + if(!folder.isEmpty()) m_rootDir->setText(folder); +} + + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList prefixStrings(const QStringList& strings, const QString& prefix) +{ + QStringList prefixedStrings; + for (auto string : strings) + { + if (!string.startsWith(prefix)) + { + prefixedStrings.append(prefix + string); + } + else + { + prefixedStrings.append(string); + } + } + return prefixedStrings; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList trimLeftStrings(const QStringList& strings, const QString& trimText) +{ + QStringList trimmedStrings; + for (const auto& string : strings) + { + QString trimmedString = string; + if (string.startsWith(trimText)) + { + trimmedString = string.right(string.size() - trimText.size()); + } + trimmedStrings.append(trimmedString); + } + return trimmedStrings; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void sortStringsByLength(QStringList& strings, bool ascending /*= true*/) +{ + QStringList sorted = strings; + int numItems = sorted.size(); + bool swapped; + do + { + swapped = false; + for (int i = 0; i < numItems - 1; i++) + { + int s0 = strings[i].size(); + int s1 = strings[i + 1].size(); + if (ascending && s0 > s1 || !ascending && s0 < s1) + { + const QString temp = strings[i]; + strings[i] = strings[i + 1]; + strings[i + 1] = temp; + swapped = true; + } + } + } while (swapped); + + +} diff --git a/ApplicationCode/Commands/RicFileHierarchyDialog.h b/ApplicationCode/Commands/RicFileHierarchyDialog.h new file mode 100644 index 0000000000..0e42e23b4c --- /dev/null +++ b/ApplicationCode/Commands/RicFileHierarchyDialog.h @@ -0,0 +1,147 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dOverlayInfoConfig.h" + +#include "cafPdmPointer.h" + +#include + +class QLabel; +class QLineEdit; +class QTextEdit; +class QDialogButtonBox; +class QPushButton; +class QMainWindow; +class QListWidget; +class RicFileHierarchyDialogResult; + +//================================================================================================== +/// +//================================================================================================== +class RicFileHierarchyDialog : public QDialog +{ + Q_OBJECT + + enum Status {SEARCHING_FOR_DIRS, SEARCHING_FOR_FILES, NO_FILES_FOUND}; + +public: + RicFileHierarchyDialog(QWidget* parent); + ~RicFileHierarchyDialog(); + + static RicFileHierarchyDialogResult runRecursiveSearchDialog(QWidget *parent = nullptr, + const QString& caption = QString(), + const QString& dir = QString(), + const QString& pathFilter = QString(), + const QString& fileNameFilter = QString(), + const QStringList& fileExtensions = QStringList()); + +private: + QStringList files() const; + QString rootDir() const; + QString pathFilter() const; + QString fileNameFilter() const; + QStringList fileExtensions() const; + QString fileExtensionsText() const; + QString extensionFromFileNameFilter() const; + + bool cancelPressed() const; + void appendToFileList(const QString& fileName); + void clearFileList(); + void updateStatus(Status status, const QString& extraText = ""); + QString currentStatus() const; + + QStringList findMatchingFiles(); + + QStringList buildDirectoryListRecursive(const QString& currentDir, int level = 0); + void buildDirectoryListRecursiveSimple(const QString& rootDir, + const QString& remainingPathFilter, + QStringList* accumulatedDirs); + + + QStringList findFilesInDirs(const QStringList& dirs); + + QStringList createNameFilterList(const QString& fileNameFilter, + const QStringList& fileExtensions); + + bool pathFilterMatch(const QString& pathFilter, const QString& relPath); + + void updateEffectiveFilter(); + + void setOkButtonEnabled(bool enabled); + +private slots: + void slotFilterChanged(const QString& text); + void slotFileListCustomMenuRequested(const QPoint& point); + void slotToggleFileListItems(); + void slotTurnOffFileListItems(); + void slotTurnOnFileListItems(); + void slotFindOrCancelButtonClicked(); + void slotDialogOkClicked(); + void slotDialogCancelClicked(); + void slotBrowseButtonClicked(); + +private: + QLabel* m_rootDirLabel; + QLineEdit* m_rootDir; + QPushButton* m_browseButton; + + QLabel* m_pathFilterLabel; + QLineEdit* m_pathFilter; + + QLabel* m_fileFilterLabel; + QLineEdit* m_fileFilter; + QLabel* m_fileExtensionLabel; + + QLabel* m_effectiveFilterLabel; + QLabel* m_effectiveFilter; + + QLabel* m_fileListLabel; + QListWidget* m_fileList; + + QPushButton* m_findOrCancelButton; + QDialogButtonBox* m_buttons; + + QStringList m_files; + QStringList m_fileExtensions; + + bool m_cancelPressed; +}; + + +//================================================================================================== +/// +//================================================================================================== +class RicFileHierarchyDialogResult +{ +public: + RicFileHierarchyDialogResult(bool ok, + const QStringList& files, + const QString& rootDir, + const QString& pathFilter, + const QString& fileNameFilter) : + ok(ok), files(files), rootDir(rootDir), pathFilter(pathFilter), fileNameFilter(fileNameFilter) {} + + bool ok; + QStringList files; + QString rootDir; + QString pathFilter; + QString fileNameFilter; +}; \ No newline at end of file diff --git a/ApplicationCode/Commands/RicFlyToObjectFeature.cpp b/ApplicationCode/Commands/RicFlyToObjectFeature.cpp index 885a65742b..12c16c2ca3 100644 --- a/ApplicationCode/Commands/RicFlyToObjectFeature.cpp +++ b/ApplicationCode/Commands/RicFlyToObjectFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "Rim3dPropertiesInterface.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuViewer.h" @@ -59,7 +59,7 @@ bool RicFlyToObjectFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicFlyToObjectFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuViewer* destinationViewer = activeView->viewer(); diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp index 4d99d5ed2b..5e01fee6c9 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterFeatureImpl.cpp @@ -25,7 +25,7 @@ #include "RimGeoMechView.h" #include "RimGeoMechResultDefinition.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -66,7 +66,7 @@ void RicGeoMechPropertyFilterFeatureImpl::addPropertyFilter(RimGeoMechPropertyFi propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } @@ -83,7 +83,7 @@ void RicGeoMechPropertyFilterFeatureImpl::insertPropertyFilter(RimGeoMechPropert propertyFilterCollection->reservoirView()->scheduleCreateDisplayModelAndRedraw(); propertyFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(propertyFilter); + Riu3DMainWindowTools::selectAsCurrentItem(propertyFilter); } diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp index 3058d31aa0..8ce09ed4d2 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterInsertExec.cpp @@ -31,7 +31,7 @@ /// //-------------------------------------------------------------------------------------------------- RicGeoMechPropertyFilterInsertExec::RicGeoMechPropertyFilterInsertExec(RimGeoMechPropertyFilter* propertyFilter) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(propertyFilter); m_propertyFilter = propertyFilter; diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp index e63ef16b06..fd5efd7035 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewExec.cpp @@ -29,7 +29,7 @@ /// //-------------------------------------------------------------------------------------------------- RicGeoMechPropertyFilterNewExec::RicGeoMechPropertyFilterNewExec(RimGeoMechPropertyFilterCollection* propertyFilterCollection) - : CmdExecuteCommand(NULL) + : CmdExecuteCommand(nullptr) { assert(propertyFilterCollection); m_propertyFilterCollection = propertyFilterCollection; diff --git a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp index 822555def3..fbcc9be75d 100644 --- a/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp +++ b/ApplicationCode/Commands/RicGeoMechPropertyFilterNewInViewFeature.cpp @@ -26,7 +26,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafCmdExecCommandManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicGeoMechPropertyFilterNewInViewFeature, "RicGeoMechPropert //-------------------------------------------------------------------------------------------------- bool RicGeoMechPropertyFilterNewInViewFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return false; RimGeoMechView* geoMechView = dynamic_cast(view); @@ -62,7 +62,7 @@ bool RicGeoMechPropertyFilterNewInViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicGeoMechPropertyFilterNewInViewFeature::onActionTriggered(bool isChecked) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (!view) return; RimGeoMechView* eclView = dynamic_cast(view); if (!eclView) return; diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp index 4264105495..69479cf6cb 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.cpp +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.cpp @@ -26,7 +26,7 @@ #include "RimEclipseView.h" #include "Rim3dOverlayInfoConfig.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuTools.h" @@ -115,7 +115,7 @@ void RicGridStatisticsDialog::setLabel(const QString& labelText) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::updateFromRimView(RimView* rimView) +void RicGridStatisticsDialog::updateFromRimView(RimGridView* rimView) { m_currentRimView = rimView; setInfoText(m_currentRimView); @@ -134,7 +134,7 @@ QImage RicGridStatisticsDialog::screenShotImage() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::setInfoText(RimView* view) +void RicGridStatisticsDialog::setInfoText(RimGridView* view) { Rim3dOverlayInfoConfig* overlayInfo = view->overlayInfoConfig(); if (view && overlayInfo) @@ -151,7 +151,7 @@ void RicGridStatisticsDialog::setInfoText(RimView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicGridStatisticsDialog::setHistogramData(RimView* view) +void RicGridStatisticsDialog::setHistogramData(RimGridView* view) { deletePlotItems(m_historgramPlot); deletePlotItems(m_aggregatedPlot); diff --git a/ApplicationCode/Commands/RicGridStatisticsDialog.h b/ApplicationCode/Commands/RicGridStatisticsDialog.h index 06b3c35456..b71d369845 100644 --- a/ApplicationCode/Commands/RicGridStatisticsDialog.h +++ b/ApplicationCode/Commands/RicGridStatisticsDialog.h @@ -32,6 +32,7 @@ class QwtPlotMarker; class QMainWindow; class QToolBar; class RimEclipseView; +class RimGridView; //================================================================================================== /// @@ -46,12 +47,12 @@ class RicGridStatisticsDialog : public QDialog ~RicGridStatisticsDialog(); void setLabel(const QString& labelText); - void updateFromRimView(RimView* rimView); + void updateFromRimView(RimGridView* rimView); QImage screenShotImage(); private: - void setInfoText(RimView* eclipseView); - void setHistogramData(RimView* eclipseView); + void setInfoText(RimGridView* eclipseView); + void setHistogramData(RimGridView* eclipseView); private: void createAndConnectToolbarActions(); @@ -74,5 +75,5 @@ private slots: QwtPlot* m_aggregatedPlot; QDialogButtonBox* m_buttons; - caf::PdmPointer m_currentRimView; + caf::PdmPointer m_currentRimView; }; diff --git a/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp b/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp index 7d3823c7b0..266c8376e6 100644 --- a/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp +++ b/ApplicationCode/Commands/RicHideIntersectionBoxFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimIntersectionBox.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuSelectionManager.h" @@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicHideIntersectionBoxFeature, "RicHideIntersectionBoxFeatur //-------------------------------------------------------------------------------------------------- bool RicHideIntersectionBoxFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); @@ -56,7 +56,7 @@ bool RicHideIntersectionBoxFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicHideIntersectionBoxFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); diff --git a/ApplicationCode/Commands/RicHideIntersectionFeature.cpp b/ApplicationCode/Commands/RicHideIntersectionFeature.cpp index 5dd9f968e1..845432a9f9 100644 --- a/ApplicationCode/Commands/RicHideIntersectionFeature.cpp +++ b/ApplicationCode/Commands/RicHideIntersectionFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimIntersection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuSelectionManager.h" @@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicHideIntersectionFeature, "RicHideIntersectionFeature"); //-------------------------------------------------------------------------------------------------- bool RicHideIntersectionFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); @@ -56,7 +56,7 @@ bool RicHideIntersectionFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicHideIntersectionFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp new file mode 100644 index 0000000000..6f33931e88 --- /dev/null +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.cpp @@ -0,0 +1,85 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportElementPropertyFeature.h" + +#include "RiaApplication.h" + +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechView.h" + +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportElementPropertyFeature, "RicImportElementPropertyFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportElementPropertyFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + + QString defaultDir = app->lastUsedDialogDirectory("ELM_PROPS"); + QStringList fileNames = + QFileDialog::getOpenFileNames(nullptr, "Import Element Property Table", defaultDir, "Property Table (*.inp)"); + + if (!fileNames.empty()) + { + defaultDir = QFileInfo(fileNames.last()).absolutePath(); + } + + std::vector filePaths; + for (QString filename : fileNames) + { + filePaths.push_back(caf::FilePath(filename)); + } + + app->setLastUsedDialogDirectory("ELM_PROPS", defaultDir); + + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + if (!activeView) return; + + RimGeoMechView* activeGmv = dynamic_cast(activeView); + if (!activeGmv) return; + + if (activeGmv->geoMechCase()) + { + activeGmv->geoMechCase()->addElementPropertyFiles(filePaths); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportElementPropertyFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/GeoMechCase48x48.png")); + actionToSetup->setText("Import &Element Property Table"); +} diff --git a/ApplicationCode/Commands/RicImportElementPropertyFeature.h b/ApplicationCode/Commands/RicImportElementPropertyFeature.h new file mode 100644 index 0000000000..781af3fc47 --- /dev/null +++ b/ApplicationCode/Commands/RicImportElementPropertyFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicImportElementPropertyFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.cpp b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp new file mode 100644 index 0000000000..f07f96d69d --- /dev/null +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.cpp @@ -0,0 +1,179 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportEnsembleFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicImportSummaryCasesFeature.h" +#include "RicCreateSummaryCaseCollectionFeature.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include +#include +#include +#include + + +CAF_CMD_SOURCE_INIT(RicImportEnsembleFeature, "RicImportEnsembleFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportEnsembleFeature::validateEnsembleCases(std::vector cases) +{ + // Validate ensemble parameters + try + { + QString errors; + std::hash paramsHasher; + size_t paramsHash = 0; + + for (RimSummaryCase* rimCase : cases) + { + if (rimCase->caseRealizationParameters() == nullptr || rimCase->caseRealizationParameters()->parameters().empty()) + { + errors.append(QString("The case %1 has no ensemble parameters\n").arg(QFileInfo(rimCase->summaryHeaderFilename()).fileName())); + } + else + { + QString paramNames; + for (std::pair paramPair : rimCase->caseRealizationParameters()->parameters()) + { + paramNames.append(paramPair.first); + } + + size_t currHash = paramsHasher(paramNames.toStdString()); + if (paramsHash == 0) + { + paramsHash = currHash; + } + else if (paramsHash != currHash) + { + throw QString("Ensemble parameters differ between cases"); + } + } + } + + if (!errors.isEmpty()) + { + throw errors; + } + return true; + } + catch (QString errorMessage) + { + QMessageBox mbox; + mbox.setIcon(QMessageBox::Icon::Warning); + mbox.setInformativeText(errorMessage); + mbox.exec(); + return false; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportEnsembleFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEnsembleFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Ensemble"); + + if (fileNames.isEmpty()) return; + + QString ensembleName = askForEnsembleName(); + if (ensembleName.isEmpty()) return; + + std::vector cases; + RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases); + + validateEnsembleCases(cases); + + RicImportSummaryCasesFeature::addSummaryCases(cases); + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, ensembleName, true); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + + std::vector allCases; + app->project()->allCases(allCases); + + if (allCases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportEnsembleFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryEnsemble16x16.png")); + actionToSetup->setText("Import Ensemble"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicImportEnsembleFeature::askForEnsembleName() +{ + RimProject* project = RiaApplication::instance()->project(); + std::vector groups = project->summaryGroups(); + int ensembleCount = std::count_if(groups.begin(), groups.end(), [](RimSummaryCaseCollection* group) { return group->isEnsemble(); }); + ensembleCount += 1; + + QInputDialog dialog; + dialog.setInputMode(QInputDialog::TextInput); + dialog.setWindowTitle("Ensemble Name"); + dialog.setLabelText("Ensemble Name"); + dialog.setTextValue(QString("Ensemble %1").arg(ensembleCount)); + dialog.resize(300, 50); + dialog.exec(); + return dialog.result() == QDialog::Accepted ? dialog.textValue() : QString(""); +} diff --git a/ApplicationCode/Commands/RicImportEnsembleFeature.h b/ApplicationCode/Commands/RicImportEnsembleFeature.h new file mode 100644 index 0000000000..62a7a80366 --- /dev/null +++ b/ApplicationCode/Commands/RicImportEnsembleFeature.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimSummaryCase; + + +//================================================================================================== +/// +//================================================================================================== +class RicImportEnsembleFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static bool validateEnsembleCases(std::vector cases); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; + + QString askForEnsembleName(); +}; + + diff --git a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp index aac802428e..90aae06f40 100644 --- a/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp +++ b/ApplicationCode/Commands/RicImportFormationNamesFeature.cpp @@ -27,13 +27,13 @@ #include "RimGeoMechCase.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigEclipseCaseData.h" #include "RigFemPartResultsCollection.h" #include "RigGeoMechCaseData.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -56,7 +56,7 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("BINARY_GRID"); - QStringList fileNames = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Formation Names", defaultDir, "Formation Names description File (*.lyr);;All Files (*.*)"); + QStringList fileNames = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Formation Names", defaultDir, "Formation Names description File (*.lyr);;All Files (*.*)"); if (fileNames.isEmpty()) return; @@ -83,12 +83,14 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) if (!cases.empty()) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); - RimCase* ownerCase = activeView->ownerCase(); - - if (ownerCase) + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + if (activeView) { - ownerCase->setFormationNames(formationName); + RimCase* ownerCase = activeView->ownerCase(); + if (ownerCase) + { + ownerCase->setFormationNames(formationName); + } } } @@ -96,7 +98,7 @@ void RicImportFormationNamesFeature::onActionTriggered(bool isChecked) if (formationName) { - RiuMainWindow::instance()->selectAsCurrentItem(formationName); + Riu3DMainWindowTools::selectAsCurrentItem(formationName); } } diff --git a/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp b/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp index ed28cec1f3..11ac6cd35a 100644 --- a/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportGeoMechCaseFeature.cpp @@ -41,7 +41,7 @@ void RicImportGeoMechCaseFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("GEOMECH_MODEL"); - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)"); + QStringList fileNames = QFileDialog::getOpenFileNames(nullptr, "Import Geo-Mechanical Model", defaultDir, "Abaqus results (*.odb)"); if (fileNames.size()) defaultDir = QFileInfo(fileNames.last()).absolutePath(); app->setLastUsedDialogDirectory("GEOMECH_MODEL", defaultDir); diff --git a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp index 672a278f42..3679c2c5b3 100644 --- a/ApplicationCode/Commands/RicImportObservedDataFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataFeature.cpp @@ -26,7 +26,7 @@ #include "RimProject.h" #include "RimSummaryObservedDataFile.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManager.h" @@ -100,7 +100,8 @@ void RicImportObservedDataFeature::selectObservedDataFileInDialog() } while (retryImport); } - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(observedData); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(observedData); } //-------------------------------------------------------------------------------------------------- @@ -130,6 +131,6 @@ void RicImportObservedDataFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportObservedDataFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/Default.png")); + actionToSetup->setIcon(QIcon(":/ObservedDataFile16x16.png")); actionToSetup->setText("Import Observed Time History Data"); } diff --git a/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp b/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp index 1893e13105..2c55ca6726 100644 --- a/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp +++ b/ApplicationCode/Commands/RicImportObservedDataInMenuFeature.cpp @@ -61,7 +61,7 @@ void RicImportObservedDataInMenuFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicImportObservedDataInMenuFeature::setupActionLook(QAction* actionToSetup) { - actionToSetup->setIcon(QIcon(":/Default.png")); + actionToSetup->setIcon(QIcon(":/ObservedDataFile16x16.png")); actionToSetup->setText("Import Observed Time History Data"); } diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp index e0f81aa00b..b7384398d2 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.cpp @@ -20,6 +20,9 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaFilePathTools.h" + +#include "RicImportSummaryCasesFeature.h" #include "RimGridSummaryCase.h" #include "RimMainPlotCollection.h" @@ -29,11 +32,9 @@ #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" -#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" - #include #include @@ -53,30 +54,33 @@ bool RicImportSummaryCaseFeature::isCommandEnabled() void RicImportSummaryCaseFeature::onActionTriggered(bool isChecked) { RiaApplication* app = RiaApplication::instance(); + RiaPreferences* prefs = app->preferences(); QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); - QStringList fileNames = QFileDialog::getOpenFileNames(NULL, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); - - if (fileNames.isEmpty()) return; - - // Remember the path to next time - app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath()); + QStringList fileNames_ = QFileDialog::getOpenFileNames(nullptr, "Import Summary Case", defaultDir, "Eclipse Summary File (*.SMSPEC);;All Files (*.*)"); - RimProject* proj = app->project(); + if (fileNames_.isEmpty()) return; - RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; - if (!sumCaseColl) return; + QStringList fileNames; - for (auto f : fileNames) + // Convert to internal path separator + for (QString s : fileNames_) { - RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(f); + fileNames.push_back(RiaFilePathTools::toInternalSeparator(s)); } - std::vector cases; - app->project()->allCases(cases); + // Remember the path to next time + app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(fileNames.last()).absolutePath()); + + if (fileNames.isEmpty()) return; - if (cases.size() == 0) + std::vector newCases; + if (RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(fileNames, &newCases)) { - RiuMainWindow::instance()->close(); + RicImportSummaryCasesFeature::addCasesToGroupIfRelevant(newCases); + for (const RimSummaryCase* newCase : newCases) + { + RiaApplication::instance()->addToRecentFiles(newCase->summaryHeaderFilename()); + } } } @@ -88,30 +92,3 @@ void RicImportSummaryCaseFeature::setupActionLook(QAction* actionToSetup) actionToSetup->setIcon(QIcon(":/SummaryCase48x48.png")); actionToSetup->setText("Import Summary Case"); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RicImportSummaryCaseFeature::createAndAddSummaryCaseFromFile(const QString& fileName) -{ - RiaApplication* app = RiaApplication::instance(); - RimProject* proj = app->project(); - RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; - if (!sumCaseColl) return false; - - RimSummaryCase* sumCase = sumCaseColl->createAndAddSummaryCaseFromFileName(fileName); - sumCaseColl->updateAllRequiredEditors(); - - RiuMainPlotWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(sumCase); - - mainPlotWindow->updateSummaryPlotToolBar(); - } - - app->addToRecentFiles(fileName); - - return true; -} - diff --git a/ApplicationCode/Commands/RicImportSummaryCaseFeature.h b/ApplicationCode/Commands/RicImportSummaryCaseFeature.h index c07c393a3b..22171cb8b9 100644 --- a/ApplicationCode/Commands/RicImportSummaryCaseFeature.h +++ b/ApplicationCode/Commands/RicImportSummaryCaseFeature.h @@ -29,9 +29,6 @@ class RicImportSummaryCaseFeature : public caf::CmdFeature { CAF_CMD_HEADER_INIT; -public: - static bool createAndAddSummaryCaseFromFile(const QString& fileName); - protected: // Overrides virtual bool isCommandEnabled() override; diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp new file mode 100644 index 0000000000..82f162376c --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.cpp @@ -0,0 +1,240 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportSummaryCasesFeature.h" + +#include "RiaApplication.h" +#include "RiaLogging.h" +#include "RiaPreferences.h" + +#include "RicFileHierarchyDialog.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include "cafProgressInfo.h" +#include "cafSelectionManagerTools.h" + +#include +#include +#include + +CAF_CMD_SOURCE_INIT(RicImportSummaryCasesFeature, "RicImportSummaryCasesFeature"); + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicImportSummaryCasesFeature::m_pathFilter = "*"; +QString RicImportSummaryCasesFeature::m_fileNameFilter = "*"; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QStringList fileNames = runRecursiveSummaryCaseFileSearchDialog("Import Summary Cases"); + + std::vector cases; + if (!fileNames.isEmpty()) createSummaryCasesFromFiles(fileNames, &cases); + + addSummaryCases(cases); + + addCasesToGroupIfRelevant(cases); + + for (const auto& rimCase : cases) RiaApplication::instance()->addToRecentFiles(rimCase->summaryHeaderFilename()); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + + std::vector allCases; + app->project()->allCases(allCases); + + if (allCases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryCases16x16.png")); + actionToSetup->setText("Import Summary Cases Recursively"); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createAndAddSummaryCasesFromFiles(const QStringList& fileNames, std::vector* newCases) +{ + RiaApplication* app = RiaApplication::instance(); + + std::vector temp; + std::vector* cases = newCases ? newCases : &temp; + if (createSummaryCasesFromFiles(fileNames, cases)) + { + addSummaryCases(*cases); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases->empty()) + { + mainPlotWindow->selectAsCurrentItem(cases->back()); + mainPlotWindow->updateSummaryPlotToolBar(); + + // Close main window if there are no eclipse cases imported + std::vector cases; + app->project()->allCases(cases); + + if (cases.size() == 0) + { + RiuMainWindow::instance()->close(); + } + } + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryCasesFeature::createSummaryCasesFromFiles(const QStringList& fileNames, + std::vector* newCases) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* proj = app->project(); + RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + + if (newCases) newCases->clear(); + if (!sumCaseColl) return false; + + RifSummaryCaseRestartSelector fileSelector; + fileSelector.determineFilesToImportFromSummaryFiles(fileNames); + + std::vector importFileInfos = fileSelector.summaryFileInfos(); + + if (!importFileInfos.empty()) + { + std::vector sumCases = sumCaseColl->createSummaryCasesFromFileInfos(importFileInfos, true); + if (newCases) newCases->insert(newCases->end(), sumCases.begin(), sumCases.end()); + } + + if (fileSelector.foundErrors()) + { + QString errorMessage = fileSelector.createCombinedErrorMessage(); + RiaLogging::error(errorMessage); + QMessageBox::warning(NULL, QString("Problem Importing Summary Case File(s)"), errorMessage); + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::addSummaryCases(const std::vector cases) +{ + RiaApplication* app = RiaApplication::instance(); + RimProject* proj = app->project(); + RimSummaryCaseMainCollection* sumCaseColl = proj->activeOilField() ? proj->activeOilField()->summaryCaseMainCollection() : nullptr; + sumCaseColl->addCases(cases); + sumCaseColl->updateAllRequiredEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryCasesFeature::addCasesToGroupIfRelevant(const std::vector cases) +{ + std::vector selectedColl = caf::selectedObjectsByTypeStrict(); + + if (selectedColl.size() == 1) + { + RimSummaryCaseCollection* coll = selectedColl.front(); + RimSummaryCaseMainCollection* mainColl; + coll->firstAncestorOrThisOfType(mainColl); + + if (mainColl) + { + for (const auto sumCase : cases) + { + mainColl->removeCase(sumCase); + selectedColl.front()->addCase(sumCase); + } + mainColl->updateConnectedEditors(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog(const QString& dialogTitle) +{ + RiaApplication* app = RiaApplication::instance(); + QString defaultDir = app->lastUsedDialogDirectory("INPUT_FILES"); + + RicFileHierarchyDialogResult result = RicFileHierarchyDialog::runRecursiveSearchDialog(nullptr, + dialogTitle, + defaultDir, + m_pathFilter, + m_fileNameFilter, + QStringList(".SMSPEC")); + + // Remember filters + m_pathFilter = result.pathFilter; + m_fileNameFilter = result.fileNameFilter; + + if (!result.ok) return QStringList(); + + // Remember the path to next time + app->setLastUsedDialogDirectory("INPUT_FILES", QFileInfo(result.rootDir).absoluteFilePath()); + + return result.files; +} diff --git a/ApplicationCode/Commands/RicImportSummaryCasesFeature.h b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h new file mode 100644 index 0000000000..15c6f18a00 --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryCasesFeature.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include +#include + +class RicSummaryCaseRestartDialogResult; +class RimSummaryCase; + +//================================================================================================== +/// +//================================================================================================== +class RicImportSummaryCasesFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + RicImportSummaryCasesFeature() { } + + static bool createAndAddSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases = nullptr); + static bool createSummaryCasesFromFiles(const QStringList& fileName, std::vector* newCases); + static void addSummaryCases(const std::vector cases); + static void addCasesToGroupIfRelevant(const std::vector cases); + + static QStringList runRecursiveSummaryCaseFileSearchDialog(const QString& dialogTitle); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; + +private: + static QString m_pathFilter; + static QString m_fileNameFilter; +}; + + diff --git a/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp new file mode 100644 index 0000000000..fb3c3f9647 --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryGroupFeature.cpp @@ -0,0 +1,98 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicImportSummaryGroupFeature.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "RicImportSummaryCasesFeature.h" +#include "RicCreateSummaryCaseCollectionFeature.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RimGridSummaryCase.h" +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryPlotCollection.h" + +#include "RiuPlotMainWindow.h" +#include "RiuMainWindow.h" + +#include "SummaryPlotCommands/RicNewSummaryPlotFeature.h" + +#include +#include +#include +#include + + +CAF_CMD_SOURCE_INIT(RicImportSummaryGroupFeature, "RicImportSummaryGroupFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicImportSummaryGroupFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryGroupFeature::onActionTriggered(bool isChecked) +{ + RiaApplication* app = RiaApplication::instance(); + QStringList fileNames = RicImportSummaryCasesFeature::runRecursiveSummaryCaseFileSearchDialog("Import Summary Case Group"); + + if (fileNames.isEmpty()) return; + + std::vector cases; + RicImportSummaryCasesFeature::createSummaryCasesFromFiles(fileNames, &cases); + + RicImportSummaryCasesFeature::addSummaryCases(cases); + RicCreateSummaryCaseCollectionFeature::groupSummaryCases(cases, "", false); + + RiuPlotMainWindow* mainPlotWindow = app->getOrCreateAndShowMainPlotWindow(); + if (mainPlotWindow && !cases.empty()) + { + mainPlotWindow->selectAsCurrentItem(cases.back()); + + mainPlotWindow->updateSummaryPlotToolBar(); + } + + std::vector allCases; + app->project()->allCases(allCases); + + if (allCases.size() == 0) + { + RiuMainWindow::instance()->close(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicImportSummaryGroupFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/SummaryGroup16x16.png")); + actionToSetup->setText("Import Summary Case Group"); +} diff --git a/ApplicationCode/Commands/RicImportSummaryGroupFeature.h b/ApplicationCode/Commands/RicImportSummaryGroupFeature.h new file mode 100644 index 0000000000..c75b1a89c2 --- /dev/null +++ b/ApplicationCode/Commands/RicImportSummaryGroupFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "cafCmdFeature.h" + +#include + + +class RimSummaryCase; + + +//================================================================================================== +/// +//================================================================================================== +class RicImportSummaryGroupFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; + + diff --git a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp index 13aac245b9..5efbbed1ee 100644 --- a/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp +++ b/ApplicationCode/Commands/RicNewSliceRangeFilterFeature.cpp @@ -23,7 +23,7 @@ #include "RicRangeFilterFeatureImpl.h" #include "RicRangeFilterNewExec.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "cafCmdExecCommandManager.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicNewSliceRangeFilterFeature, "RicNewSliceRangeFilterFeatur //-------------------------------------------------------------------------------------------------- bool RicNewSliceRangeFilterFeature::isCommandEnabled() { - RimView* view = RiaApplication::instance()->activeReservoirView(); + RimGridView* view = RiaApplication::instance()->activeGridView(); if (!view) return false; RimViewController* vc = view->viewController(); @@ -57,17 +57,19 @@ void RicNewSliceRangeFilterFeature::onActionTriggered(bool isChecked) if (!userData.isNull() && userData.type() == QVariant::List) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + RimGridView* view = RiaApplication::instance()->activeGridView(); RimCellRangeFilterCollection* rangeFilterCollection = view->rangeFilterCollection(); RicRangeFilterNewExec* filterExec = new RicRangeFilterNewExec(rangeFilterCollection); QVariantList list = userData.toList(); - CAF_ASSERT(list.size() == 2); + CAF_ASSERT(list.size() == 3); int direction = list[0].toInt(); int sliceStart = list[1].toInt(); + int gridIndex = list[2].toInt(); + filterExec->m_gridIndex = gridIndex; if (direction == 0) { filterExec->m_iSlice = true; diff --git a/ApplicationCode/Commands/RicNewViewFeature.cpp b/ApplicationCode/Commands/RicNewViewFeature.cpp index 0e0213579e..ad7410c283 100644 --- a/ApplicationCode/Commands/RicNewViewFeature.cpp +++ b/ApplicationCode/Commands/RicNewViewFeature.cpp @@ -23,9 +23,9 @@ #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechView.h" -#include "RimView.h" +#include "Rim3dView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiaLogging.h" #include "cafSelectionManager.h" @@ -39,11 +39,11 @@ CAF_CMD_SOURCE_INIT(RicNewViewFeature, "RicNewViewFeature"); //-------------------------------------------------------------------------------------------------- void RicNewViewFeature::addReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) { - RimView* newView = createReservoirView(eclipseCase, geomCase); + Rim3dView* newView = createReservoirView(eclipseCase, geomCase); if (newView) { - RiuMainWindow::instance()->setExpanded(newView); + Riu3DMainWindowTools::setExpanded(newView); } } @@ -52,10 +52,10 @@ void RicNewViewFeature::addReservoirView(RimEclipseCase* eclipseCase, RimGeoMech //-------------------------------------------------------------------------------------------------- bool RicNewViewFeature::isCommandEnabled() { - return selectedEclipseCase() != NULL - || selectedEclipseView() != NULL - || selectedGeoMechCase() != NULL - || selectedGeoMechView() != NULL; + return selectedEclipseCase() != nullptr + || selectedEclipseView() != nullptr + || selectedGeoMechCase() != nullptr + || selectedGeoMechView() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -89,9 +89,9 @@ void RicNewViewFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RicNewViewFeature::createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) +Rim3dView* RicNewViewFeature::createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase) { - RimView* insertedView = NULL; + Rim3dView* insertedView = nullptr; if (eclipseCase) { @@ -131,7 +131,7 @@ RimEclipseCase* RicNewViewFeature::selectedEclipseCase() return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -147,7 +147,7 @@ RimGeoMechCase* RicNewViewFeature::selectedGeoMechCase() return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -163,7 +163,7 @@ RimEclipseView* RicNewViewFeature::selectedEclipseView() return selection[0]; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -179,5 +179,5 @@ RimGeoMechView* RicNewViewFeature::selectedGeoMechView() return selection[0]; } - return NULL; + return nullptr; } diff --git a/ApplicationCode/Commands/RicNewViewFeature.h b/ApplicationCode/Commands/RicNewViewFeature.h index a8153086fe..b94dbc1dae 100644 --- a/ApplicationCode/Commands/RicNewViewFeature.h +++ b/ApplicationCode/Commands/RicNewViewFeature.h @@ -25,7 +25,7 @@ class RimEclipseCase; class RimEclipseView; class RimGeoMechCase; class RimGeoMechView; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -44,7 +44,7 @@ class RicNewViewFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ); private: - static RimView* createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase); + static Rim3dView* createReservoirView(RimEclipseCase* eclipseCase, RimGeoMechCase* geomCase); static RimEclipseCase* selectedEclipseCase(); static RimGeoMechCase* selectedGeoMechCase(); diff --git a/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp b/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp index 2816ba408c..6e1315ec3b 100644 --- a/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterExecImpl.cpp @@ -27,18 +27,20 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicRangeFilterExecImpl::RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter) - : CmdExecuteCommand(NULL) +RicRangeFilterExecImpl::RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, + RimCellRangeFilter* insertBeforeCellRangeFilter) + : CmdExecuteCommand(nullptr) { CVF_ASSERT(rangeFilterCollection); m_cellRangeFilterCollection = rangeFilterCollection; - m_cellRangeFilter = rangeFilter; + m_insertBeforeCellRangeFilter = insertBeforeCellRangeFilter; m_iSlice = false; m_jSlice = false; m_kSlice = false; + m_gridIndex = 0; m_iSliceStart = -1; m_jSliceStart = -1; m_kSliceStart = -1; @@ -61,6 +63,8 @@ RimCellRangeFilter* RicRangeFilterExecImpl::createRangeFilter() RimCellRangeFilter* rangeFilter = new RimCellRangeFilter(); size_t flterIndex = m_cellRangeFilterCollection->rangeFilters().size() + 1; + + rangeFilter->gridIndex = m_gridIndex; rangeFilter->name = QString("New Filter (%1)").arg(flterIndex); @@ -87,6 +91,7 @@ RimCellRangeFilter* RicRangeFilterExecImpl::createRangeFilter() //-------------------------------------------------------------------------------------------------- void RicRangeFilterExecImpl::applyCommandDataOnFilter(RimCellRangeFilter* rangeFilter) { + rangeFilter->gridIndex = m_gridIndex; if (m_iSlice) { rangeFilter->cellCountI = 1; diff --git a/ApplicationCode/Commands/RicRangeFilterExecImpl.h b/ApplicationCode/Commands/RicRangeFilterExecImpl.h index b7407922ab..c63a21edc0 100644 --- a/ApplicationCode/Commands/RicRangeFilterExecImpl.h +++ b/ApplicationCode/Commands/RicRangeFilterExecImpl.h @@ -31,7 +31,8 @@ class RimCellRangeFilterCollection; class RicRangeFilterExecImpl : public caf::CmdExecuteCommand { public: - RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = 0); + RicRangeFilterExecImpl(RimCellRangeFilterCollection* rangeFilterCollection, + RimCellRangeFilter* insertBeforeCellRangeFilter = nullptr); virtual ~RicRangeFilterExecImpl(); virtual QString name() = 0; @@ -43,6 +44,7 @@ class RicRangeFilterExecImpl : public caf::CmdExecuteCommand bool m_jSlice; bool m_kSlice; + int m_gridIndex; int m_iSliceStart; int m_jSliceStart; int m_kSliceStart; @@ -53,7 +55,7 @@ class RicRangeFilterExecImpl : public caf::CmdExecuteCommand protected: caf::PdmPointer m_cellRangeFilterCollection; - caf::PdmPointer m_cellRangeFilter; + caf::PdmPointer m_insertBeforeCellRangeFilter; }; diff --git a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp index bb10613c7a..92c19e2b09 100644 --- a/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicRangeFilterFeatureImpl.cpp @@ -25,7 +25,7 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "cafSelectionManager.h" @@ -40,7 +40,7 @@ bool RicRangeFilterFeatureImpl::isRangeFilterCommandAvailable() RimCellRangeFilterCollection* rangeFilterCollection = findRangeFilterCollection(); if (!rangeFilterCollection) return false; - RimView* view; + RimGridView* view; rangeFilterCollection->firstAncestorOrThisOfType(view); if (view) { @@ -86,7 +86,7 @@ RimCellRangeFilterCollection* RicRangeFilterFeatureImpl::findRangeFilterCollecti selectedRangeFilter[0]->firstAncestorOrThisOfType(rangeFilterCollection); } - RimView* view = RiaApplication::instance()->activeReservoirView(); + RimGridView* view = RiaApplication::instance()->activeGridView(); if (view) { rangeFilterCollection = view->rangeFilterCollection(); diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp index 1e06760071..224b4f4b13 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.cpp @@ -21,8 +21,8 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimView.h" -#include "RiuMainWindow.h" +#include "Rim3dView.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- @@ -57,7 +57,7 @@ void RicRangeFilterInsertExec::redo() RimCellRangeFilter* rangeFilter = createRangeFilter(); if (rangeFilter) { - size_t index = m_cellRangeFilterCollection->rangeFilters.index(m_cellRangeFilter); + size_t index = m_cellRangeFilterCollection->rangeFilters.index(m_insertBeforeCellRangeFilter); CVF_ASSERT(index < m_cellRangeFilterCollection->rangeFilters.size()); m_cellRangeFilterCollection->rangeFilters.insertAt(static_cast(index), rangeFilter); @@ -65,11 +65,11 @@ void RicRangeFilterInsertExec::redo() rangeFilter->setDefaultValues(); applyCommandDataOnFilter(rangeFilter); - m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(NULL); + m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(nullptr); m_cellRangeFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter); + Riu3DMainWindowTools::selectAsCurrentItem(rangeFilter); } } diff --git a/ApplicationCode/Commands/RicRangeFilterInsertExec.h b/ApplicationCode/Commands/RicRangeFilterInsertExec.h index db47dd8890..392cddd5fe 100644 --- a/ApplicationCode/Commands/RicRangeFilterInsertExec.h +++ b/ApplicationCode/Commands/RicRangeFilterInsertExec.h @@ -30,7 +30,7 @@ class RimCellRangeFilterCollection; class RicRangeFilterInsertExec : public RicRangeFilterExecImpl { public: - RicRangeFilterInsertExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = 0); + RicRangeFilterInsertExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = nullptr); virtual ~RicRangeFilterInsertExec(); virtual QString name(); diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp index f71d4d15ab..c116de9ec4 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.cpp +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.cpp @@ -23,9 +23,9 @@ #include "RimCellRangeFilter.h" #include "RimCellRangeFilterCollection.h" -#include "RimView.h" +#include "RimGridView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" //-------------------------------------------------------------------------------------------------- @@ -71,13 +71,13 @@ void RicRangeFilterNewExec::redo() rangeFilter->setDefaultValues(); applyCommandDataOnFilter(rangeFilter); - m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(NULL); + m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(nullptr); m_cellRangeFilterCollection->updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(rangeFilter); + Riu3DMainWindowTools::selectAsCurrentItem(rangeFilter); - RimView* view = nullptr; + RimGridView* view = nullptr; m_cellRangeFilterCollection->firstAncestorOrThisOfTypeAsserted(view); //Enable display of grid cells, to be able to show generated range filter @@ -94,7 +94,7 @@ void RicRangeFilterNewExec::undo() m_cellRangeFilterCollection->rangeFilters.erase(m_cellRangeFilterCollection->rangeFilters.size() - 1); - m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(NULL); + m_cellRangeFilterCollection->updateDisplayModeNotifyManagedViews(nullptr); m_cellRangeFilterCollection->updateConnectedEditors(); } \ No newline at end of file diff --git a/ApplicationCode/Commands/RicRangeFilterNewExec.h b/ApplicationCode/Commands/RicRangeFilterNewExec.h index 111fa81881..ee9c41a058 100644 --- a/ApplicationCode/Commands/RicRangeFilterNewExec.h +++ b/ApplicationCode/Commands/RicRangeFilterNewExec.h @@ -27,7 +27,7 @@ class RicRangeFilterNewExec : public RicRangeFilterExecImpl { public: - RicRangeFilterNewExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = 0); + RicRangeFilterNewExec(RimCellRangeFilterCollection* rangeFilterCollection, RimCellRangeFilter* rangeFilter = nullptr); virtual ~RicRangeFilterNewExec(); virtual QString name(); diff --git a/ApplicationCode/Commands/RicSelectColorResult.cpp b/ApplicationCode/Commands/RicSelectColorResult.cpp new file mode 100644 index 0000000000..891d4e0719 --- /dev/null +++ b/ApplicationCode/Commands/RicSelectColorResult.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSelectColorResult.h" + +#include "RiaApplication.h" +#include "RicWellLogTools.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicSelectColorResult, "RicSelectColorResult"); + +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +RimGridView* gridViewFrom2dIntersectionView(const Rim2dIntersectionView* int2dView) +{ + RimGridView* gridView = nullptr; + int2dView->intersection()->firstAncestorOrThisOfType(gridView); + return gridView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectColorResult::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Select Color Result"); + actionToSetup->setIcon(QIcon(":/CellResult.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSelectColorResult::isCommandEnabled() +{ + if (RicWellLogTools::isWellPathOrSimWellSelectedInView()) return false; + + return RiaApplication::instance()->activeReservoirView() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSelectColorResult::onActionTriggered(bool isChecked) +{ + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim2dIntersectionView* int2dView = dynamic_cast(activeView); + RimGridView* gridView = nullptr; + + if (int2dView) gridView = gridViewFrom2dIntersectionView(int2dView); + else gridView = dynamic_cast(activeView); + + RimEclipseView* eclView = dynamic_cast(gridView); + if (eclView) + { + Riu3DMainWindowTools::selectAsCurrentItem(eclView->cellResult(), int2dView == nullptr); + return; + } + + RimGeoMechView* geoMechView = dynamic_cast(gridView); + if (geoMechView) + { + Riu3DMainWindowTools::selectAsCurrentItem(geoMechView->cellResult(), int2dView== nullptr); + } +} diff --git a/ApplicationCode/Commands/RicSelectColorResult.h b/ApplicationCode/Commands/RicSelectColorResult.h new file mode 100644 index 0000000000..d46ec5e87e --- /dev/null +++ b/ApplicationCode/Commands/RicSelectColorResult.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicSelectColorResult : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +private: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp b/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp index ee22079dc9..629c067807 100644 --- a/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp +++ b/ApplicationCode/Commands/RicSelectOrCreateViewFeatureImpl.cpp @@ -47,7 +47,7 @@ RimEclipseView* RicSelectOrCreateViewFeatureImpl::showViewSelection(RimEclipseRe featureUi.setCase(resultCase); } - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, dialogTitle, ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, dialogTitle, ""); propertyDialog.resize(QSize(400, 200)); if (propertyDialog.exec() != QDialog::Accepted) return nullptr; diff --git a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp index d56a52e3df..64573af6aa 100644 --- a/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp +++ b/ApplicationCode/Commands/RicShowGridStatisticsFeature.cpp @@ -42,7 +42,7 @@ bool RicShowGridStatisticsFeature::isCommandEnabled() { if (RicWellLogTools::isWellPathOrSimWellSelectedInView()) return false; - return RiaApplication::instance()->activeReservoirView() != nullptr; + return RiaApplication::instance()->activeGridView() != nullptr; } //-------------------------------------------------------------------------------------------------- @@ -50,7 +50,7 @@ bool RicShowGridStatisticsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowGridStatisticsFeature::onActionTriggered(bool isChecked) { - RimView * activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView * activeView = RiaApplication::instance()->activeGridView(); if (activeView) { diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp new file mode 100644 index 0000000000..ecc1b08d56 --- /dev/null +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.cpp @@ -0,0 +1,644 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicSummaryCaseRestartDialog.h" +#include "ExportCommands/RicSnapshotViewToClipboardFeature.h" +#include "ExportCommands/RicSnapshotViewToFileFeature.h" +#include "ExportCommands/RicSnapshotFilenameGenerator.h" + +#include "RiaApplication.h" +#include "RiaFilePathTools.h" +#include "RiaLogging.h" + +#include "RifReaderEclipseSummary.h" +#include "RifEclipseSummaryTools.h" + +#include "RimEclipseView.h" +#include "Rim3dOverlayInfoConfig.h" +#include "RimTools.h" + +#include "RiuPlotMainWindow.h" +#include "RiuSummaryQwtPlot.h" +#include "RiuTools.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include +#include +#include + +#define DEFAULT_DIALOG_WIDTH 550 +#define DEFAULT_DIALOG_INIT_HEIGHT 150 + + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +std::vector>> removeCommonRootPath(const std::vector>& fileInfoLists) +{ + // Find common root path among all paths + QStringList allPaths; + for (const auto& fileInfoList : fileInfoLists) + { + for (const auto fi : fileInfoList) allPaths.push_back(fi.fileName); + } + QString commonRoot = RiaFilePathTools::commonRootPath(allPaths); + int commonRootSize = commonRoot.size(); + + // Build output lists + std::vector>> output; + for (const auto& fileInfoList : fileInfoLists) + { + std::vector> currList; + + for (auto& fi : fileInfoList) + { + std::pair newFi; + newFi = std::make_pair(fi, fi.fileName); + newFi.first.fileName.remove(0, commonRootSize); + currList.push_back(newFi); + } + output.push_back(currList); + } + return output; +} + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +std::vector>> makeShortPath(const std::vector>& fileInfoLists) +{ + // Build output lists + std::vector>> output; + + QString currentFilePath = QFileInfo(fileInfoLists[CURRENT_FILES_LIST_INDEX].front().fileName).absoluteDir().absolutePath(); + + for (const auto& fileInfoList : fileInfoLists) + { + std::vector> currList; + + for (auto& fi : fileInfoList) + { + std::pair newFi; + newFi = std::make_pair(fi, fi.fileName); + QFileInfo(fi.fileName).fileName(); + + QString absPath = QFileInfo(fi.fileName).absoluteDir().absolutePath(); + QString prefix = RiaFilePathTools::equalPaths(currentFilePath, absPath) ? "" : ".../"; + newFi.first.fileName = prefix + QFileInfo(fi.fileName).fileName(); + currList.push_back(newFi); + } + output.push_back(currList); + } + return output; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::RicSummaryCaseRestartDialog(QWidget* parent) + : QDialog(parent, RiuTools::defaultDialogFlags()) +{ + // Create widgets + m_currentFilesLayout = new QGridLayout(); + m_summaryReadAllBtn = new QRadioButton(this); + m_summarySeparateCasesBtn = new QRadioButton(this); + m_summaryNotReadBtn = new QRadioButton(this); + m_gridSeparateCasesBtn = new QRadioButton(this); + m_gridNotReadBtn = new QRadioButton(this); + m_warnings = new QListWidget(this); + m_showFullPathCheckBox = new QCheckBox(this); + m_buttons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel | QDialogButtonBox::Apply); + + // Connect to signals + connect(m_showFullPathCheckBox, SIGNAL(stateChanged(int)), this, SLOT(slotShowFullPathToggled(int))); + connect(m_buttons, SIGNAL(clicked(QAbstractButton*)), this, SLOT(slotDialogButtonClicked(QAbstractButton*))); + + // Set widget properties + m_summaryReadAllBtn->setText("Unified"); + m_summarySeparateCasesBtn->setText("Separate Cases"); + m_summaryNotReadBtn->setText("Skip"); + m_gridSeparateCasesBtn->setText("Separate Cases"); + m_gridNotReadBtn->setText("Skip"); + m_showFullPathCheckBox->setText("Show full paths"); + m_buttons->button(QDialogButtonBox::Apply)->setText("OK to All"); + + // Define layout + QVBoxLayout* dialogLayout = new QVBoxLayout(); + + m_currentFilesGroup = new QGroupBox("Current Summary File"); + m_currentFilesGroup->setStyleSheet("QGroupBox { font-weight: bold; }"); + m_currentFilesLayout = new QGridLayout(); + m_currentFilesGroup->setLayout(m_currentFilesLayout); + + // Summary files + QGroupBox* summaryFilesGroup = new QGroupBox("Origin Summary Files"); + { + summaryFilesGroup->setStyleSheet("QGroupBox { font-weight: bold; }"); + + QVBoxLayout* filesGroupLayout = new QVBoxLayout(); + summaryFilesGroup->setLayout(filesGroupLayout); + + m_summaryFilesLayout = new QGridLayout(); + filesGroupLayout->addLayout(m_summaryFilesLayout); + m_summaryFilesLayout->setContentsMargins(0, 0, 0, 5); + + QLabel* optionsLabel = new QLabel("Import Options"); + optionsLabel->setStyleSheet("font-weight: bold;"); + filesGroupLayout->addWidget(optionsLabel); + + QVBoxLayout* optionsLayout = new QVBoxLayout(); + optionsLayout->setSpacing(0); + optionsLayout->addWidget(m_summaryReadAllBtn); + optionsLayout->addWidget(m_summarySeparateCasesBtn); + optionsLayout->addWidget(m_summaryNotReadBtn); + filesGroupLayout->addLayout(optionsLayout); + } + + // Grid files + m_gridFilesGroup = new QGroupBox("Origin Grid Files"); + { + m_gridFilesGroup->setStyleSheet("QGroupBox { font-weight: bold; }"); + + QVBoxLayout* filesGroupLayout = new QVBoxLayout(); + m_gridFilesGroup->setLayout(filesGroupLayout); + + m_gridFilesLayout = new QGridLayout(); + filesGroupLayout->addLayout(m_gridFilesLayout); + m_gridFilesLayout->setContentsMargins(0, 0, 0, 5); + + QLabel* optionsLabel = new QLabel("Import Options"); + optionsLabel->setStyleSheet("font-weight: bold;"); + filesGroupLayout->addWidget(optionsLabel); + + QVBoxLayout* optionsLayout = new QVBoxLayout(); + optionsLayout->setSpacing(0); + optionsLayout->addWidget(m_gridSeparateCasesBtn); + optionsLayout->addWidget(m_gridNotReadBtn); + filesGroupLayout->addLayout(optionsLayout); + } + + // Apply to all checkbox and buttons + QHBoxLayout* buttonsLayout = new QHBoxLayout(); + buttonsLayout->addWidget(m_showFullPathCheckBox); + buttonsLayout->addStretch(1); + buttonsLayout->addWidget(m_buttons); + + QVBoxLayout* innerDialogLayout = new QVBoxLayout(); + innerDialogLayout->setSpacing(20); + innerDialogLayout->addWidget(m_currentFilesGroup); + innerDialogLayout->addWidget(summaryFilesGroup); + innerDialogLayout->addWidget(m_gridFilesGroup); + + dialogLayout->addLayout(innerDialogLayout); + dialogLayout->addWidget(m_warnings); + dialogLayout->addLayout(buttonsLayout); + + setLayout(dialogLayout); + + m_okToAllPressed = false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::~RicSummaryCaseRestartDialog() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialogResult RicSummaryCaseRestartDialog::openDialog(const QString& initialSummaryFile, + const QString& initialGridFile, + bool failOnSummaryImportError, + bool showApplyToAllWidget, + ImportOptions defaultSummaryImportOption, + ImportOptions defaultGridImportOption, + RicSummaryCaseRestartDialogResult* lastResult, + QWidget* parent) +{ + RicSummaryCaseRestartDialog dialog(parent); + bool handleSummaryFile = false; + + RifRestartFileInfo currentFileInfo; + if (!initialSummaryFile.isEmpty()) + { + currentFileInfo = dialog.getFileInfo(initialSummaryFile); + + if (!currentFileInfo.valid()) + { + if (failOnSummaryImportError) + { + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_ERROR); + } + } + else + { + handleSummaryFile = true; + } + } + + bool handleGridFile = !initialGridFile.isEmpty(); + + // If only grid file is present, return + if (!handleSummaryFile && !initialGridFile.isEmpty()) + { + RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK; + if (!initialSummaryFile.isEmpty()) + { + // We were meant to have a summary file but due to an error we don't. + status = RicSummaryCaseRestartDialogResult::SUMMARY_WARNING; + } + return RicSummaryCaseRestartDialogResult(status, + defaultSummaryImportOption, + defaultGridImportOption, + {}, + QStringList({ initialGridFile }), + lastResult && lastResult->applyToAll); + } + + + + RifReaderEclipseSummary reader; + bool hasWarnings = false; + std::vector originFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); + + // If no restart files are found and no warnings, do not show dialog + if (originFileInfos.empty() &&!hasWarnings) + { + return RicSummaryCaseRestartDialogResult(RicSummaryCaseRestartDialogResult::SUMMARY_OK, NOT_IMPORT, NOT_IMPORT, + QStringList({ initialSummaryFile }), + QStringList({ initialGridFile }), + lastResult->applyToAll); + } + + RicSummaryCaseRestartDialogResult dialogResult; + if (lastResult && lastResult->applyToAll) + { + dialogResult = *lastResult; + dialogResult.summaryFiles.clear(); + dialogResult.gridFiles.clear(); + + if (hasWarnings) + { + for (const QString& warning : reader.warnings()) RiaLogging::error(warning); + } + } + else + { + std::vector currentFileInfos; + std::vector originSummaryFileInfos; + std::vector originGridFileInfos; + + // Grid file + if (handleGridFile) + { + dialog.m_currentFilesGroup->setTitle("Current Grid and Summary Files"); + currentFileInfos.push_back(RifRestartFileInfo(initialGridFile, currentFileInfo.startDate, currentFileInfo.endDate)); + + for (const auto& ofi : originFileInfos) + { + QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); + if (QFileInfo(gridFile).exists()) + { + originGridFileInfos.push_back(RifRestartFileInfo(gridFile, ofi.startDate, ofi.endDate)); + } + } + } + + currentFileInfos.push_back(currentFileInfo); + for (const auto& ofi : originFileInfos) + { + originSummaryFileInfos.push_back(ofi); + } + + // Set default import options + switch (defaultSummaryImportOption) + { + case ImportOptions::IMPORT_ALL: dialog.m_summaryReadAllBtn->setChecked(true); break; + case ImportOptions::SEPARATE_CASES: dialog.m_summarySeparateCasesBtn->setChecked(true); break; + case ImportOptions::NOT_IMPORT: dialog.m_summaryNotReadBtn->setChecked(true); break; + } + + if (handleGridFile) + { + switch (defaultGridImportOption) + { + case ImportOptions::SEPARATE_CASES: dialog.m_gridSeparateCasesBtn->setChecked(true); break; + case ImportOptions::NOT_IMPORT: dialog.m_gridNotReadBtn->setChecked(true); break; + } + } + + // Remove common root path + std::vector>> fileInfosNoRoot = makeShortPath( + { + currentFileInfos, originSummaryFileInfos, originGridFileInfos + } + ); + + // Populate file list backing lists + dialog.m_fileLists.push_back(fileInfosNoRoot[CURRENT_FILES_LIST_INDEX]); + dialog.m_fileLists.push_back(fileInfosNoRoot[SUMMARY_FILES_LIST_INDEX]); + dialog.m_fileLists.push_back(fileInfosNoRoot[GRID_FILES_LIST_INDEX]); + + // Update file list widgets + dialog.updateFileListWidget(dialog.m_currentFilesLayout, CURRENT_FILES_LIST_INDEX); + dialog.updateFileListWidget(dialog.m_summaryFilesLayout, SUMMARY_FILES_LIST_INDEX); + dialog.updateFileListWidget(dialog.m_gridFilesLayout, GRID_FILES_LIST_INDEX); + + // Display warnings if any + dialog.displayWarningsIfAny(reader.warnings()); + + // Set properties and show dialog + dialog.setWindowTitle("Origin Files"); + dialog.m_buttons->button(QDialogButtonBox::Apply)->setVisible(showApplyToAllWidget); + dialog.resize(DEFAULT_DIALOG_WIDTH, DEFAULT_DIALOG_INIT_HEIGHT); + + QApplication::setOverrideCursor(QCursor(Qt::ArrowCursor)); + dialog.exec(); + QApplication::restoreOverrideCursor(); + + RicSummaryCaseRestartDialogResult::Status status = RicSummaryCaseRestartDialogResult::SUMMARY_OK; + + if (dialog.result() == QDialog::Rejected) + { + status = RicSummaryCaseRestartDialogResult::SUMMARY_CANCELLED; + } + + dialogResult = RicSummaryCaseRestartDialogResult(status, + dialog.selectedSummaryImportOption(), + dialog.selectedGridImportOption(), + {}, + {}, + dialog.okToAllSelected()); + } + + if (dialogResult.status != RicSummaryCaseRestartDialogResult::SUMMARY_OK) + { + return RicSummaryCaseRestartDialogResult(dialogResult.status, NOT_IMPORT, NOT_IMPORT, QStringList(), QStringList(), false); + } + + dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(initialSummaryFile)); + if (dialogResult.summaryImportOption == SEPARATE_CASES) + { + for (const auto& ofi : originFileInfos) + { + dialogResult.summaryFiles.push_back(RiaFilePathTools::toInternalSeparator(ofi.fileName)); + } + } + + if (handleGridFile) + { + dialogResult.gridFiles.push_back(initialGridFile); + + if (dialogResult.gridImportOption == SEPARATE_CASES) + { + for (const auto& ofi : originFileInfos) + { + QString gridFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(ofi.fileName); + if (handleGridFile) dialogResult.gridFiles.push_back(gridFile); + } + } + } + return dialogResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selectedSummaryImportOption() const +{ + return + m_summaryReadAllBtn->isChecked() ? IMPORT_ALL : + m_summarySeparateCasesBtn->isChecked() ? SEPARATE_CASES : + NOT_IMPORT; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::ImportOptions RicSummaryCaseRestartDialog::selectedGridImportOption() const +{ + return + m_gridSeparateCasesBtn->isChecked() ? SEPARATE_CASES : NOT_IMPORT; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicSummaryCaseRestartDialog::okToAllSelected() const +{ + return m_okToAllPressed; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::updateFileListWidget(QGridLayout* gridLayout, int listIndex) +{ + // Remove current items + QLayoutItem* item; + while (item = gridLayout->takeAt(0)) + { + gridLayout->removeItem(item); + delete item->widget(); + delete item; + } + + if (m_fileLists[listIndex].empty()) + { + QWidget* parent = gridLayout->parentWidget(); + if (parent) parent->setVisible(false); + } + + int maxFilesToDisplay = 4; + int currFiles = 0; + for (const auto& fileInfo : m_fileLists[listIndex]) + { + appendFileInfoToGridLayout(gridLayout, fileInfo.first, fileInfo.second); + if (++currFiles == maxFilesToDisplay) + { + size_t remainingFileCount = m_fileLists[listIndex].size() - maxFilesToDisplay; + appendTextToGridLayout(gridLayout, QString("+ %1 more files").arg(remainingFileCount)); + break; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName) +{ + CVF_ASSERT(gridLayout); + + QDateTime startDate = QDateTime::fromTime_t(fileInfo.startDate); + QString startDateString = startDate.toString(RimTools::dateFormatString()); + QDateTime endDate = QDateTime::fromTime_t(fileInfo.endDate); + QString endDateString = endDate.toString(RimTools::dateFormatString()); + int rowCount = gridLayout->rowCount(); + + QLabel* fileNameLabel = new QLabel(); + QLabel* dateLabel = new QLabel(); + fileNameLabel->setText(m_showFullPathCheckBox->isChecked() ? fullPathFileName : fileInfo.fileName); + dateLabel->setText(startDateString + " - " + endDateString); + + fileNameLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + gridLayout->addWidget(fileNameLabel, rowCount, 0); + gridLayout->addWidget(dateLabel, rowCount, 1); + + // File name copy context menu + fileNameLabel->setContextMenuPolicy(Qt::CustomContextMenu); + connect(fileNameLabel, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(slotFileNameCopyCustomMenuRequested(const QPoint&))); + + // Full path in tooltip + fileNameLabel->setToolTip(fullPathFileName); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::appendTextToGridLayout(QGridLayout* gridLayout, const QString& text) +{ + CVF_ASSERT(gridLayout); + + int rowCount = gridLayout->rowCount(); + + QLabel* textLabel = new QLabel(); + textLabel->setText(text); + + textLabel->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); + gridLayout->addWidget(textLabel, rowCount, 0, 1, 2); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifRestartFileInfo RicSummaryCaseRestartDialog::getFileInfo(const QString& summaryHeaderFile) +{ + RifReaderEclipseSummary reader; + return reader.getFileInfo(summaryHeaderFile); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::displayWarningsIfAny(const QStringList& warnings) +{ + m_warnings->setVisible(!warnings.isEmpty()); + for (const auto& warning : warnings) + { + QListWidgetItem* item = new QListWidgetItem(warning, m_warnings); + item->setForeground(Qt::red); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RicSummaryCaseRestartDialog::fullFileName(const QString& shortOrFullFileName) +{ + for (const auto& fileInfos : m_fileLists) + { + for (const auto& fileInfo : fileInfos) + { + if (fileInfo.first.fileName == shortOrFullFileName || fileInfo.second == shortOrFullFileName) + return fileInfo.second; + } + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotShowFullPathToggled(int state) +{ + // Update file list widgets + updateFileListWidget(m_currentFilesLayout, CURRENT_FILES_LIST_INDEX); + updateFileListWidget(m_summaryFilesLayout, SUMMARY_FILES_LIST_INDEX); + updateFileListWidget(m_gridFilesLayout, GRID_FILES_LIST_INDEX); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotDialogButtonClicked(QAbstractButton* button) +{ + bool okButtonClicked = m_buttons->button(QDialogButtonBox::Ok) == button; + bool cancelButtonClicked = m_buttons->button(QDialogButtonBox::Cancel) == button; + bool okToAllButtonClicked = m_buttons->button(QDialogButtonBox::Apply) == button; + + m_okToAllPressed = okToAllButtonClicked; + if (cancelButtonClicked) reject(); + else accept(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotFileNameCopyCustomMenuRequested(const QPoint& point) +{ + QMenu menu; + QPoint globalPoint = point; + QAction* action; + + QLabel* sourceLabel = dynamic_cast(sender()); + + action = new QAction("Copy file name", this); + action->setData(fullFileName(sourceLabel->text())); + connect(action, SIGNAL(triggered()), SLOT(slotCopyFileNameToClipboard())); + menu.addAction(action); + + globalPoint = sourceLabel->mapToGlobal(point); + menu.exec(globalPoint); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCaseRestartDialog::slotCopyFileNameToClipboard() +{ + QAction* a = dynamic_cast(sender()); + + QClipboard* cb = RiaApplication::clipboard(); + if (cb) + { + QString fullFileName = a->data().toString(); + cb->setText(QDir::toNativeSeparators(fullFileName)); + } +} diff --git a/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h new file mode 100644 index 0000000000..56ead54171 --- /dev/null +++ b/ApplicationCode/Commands/RicSummaryCaseRestartDialog.h @@ -0,0 +1,157 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dOverlayInfoConfig.h" + +#include "RifReaderEclipseSummary.h" + +#include "cafPdmPointer.h" + +#include +#include + +class QLabel; +class QRadioButton; +class QLineEdit; +class QTextEdit; +class QDialogButtonBox; +class QPushButton; +class QMainWindow; +class QListWidget; +class QGridLayout; +class QCheckBox; +class QGroupBox; +class RicSummaryCaseRestartDialogResult; +class QAbstractButton; + +//================================================================================================== +/// Constants +//================================================================================================== +#define CURRENT_FILES_LIST_INDEX 0 +#define SUMMARY_FILES_LIST_INDEX 1 +#define GRID_FILES_LIST_INDEX 2 + +//================================================================================================== +/// +//================================================================================================== +class RicSummaryCaseRestartDialog : public QDialog +{ + Q_OBJECT + +public: + enum ImportOptions { IMPORT_ALL, SEPARATE_CASES, NOT_IMPORT }; + + RicSummaryCaseRestartDialog(QWidget* parent); + ~RicSummaryCaseRestartDialog(); + + static RicSummaryCaseRestartDialogResult openDialog(const QString& initialSummaryFile, + const QString& initialGridFile, + bool failOnSummaryImportError, + bool showApplyToAllWidget, + ImportOptions defaultSummaryImportOption, + ImportOptions defaultGridImportOption, + RicSummaryCaseRestartDialogResult *lastResult = nullptr, + QWidget *parent = nullptr); + + ImportOptions selectedSummaryImportOption() const; + ImportOptions selectedGridImportOption() const; + bool okToAllSelected() const; + +private: + void updateFileListWidget(QGridLayout* gridLayout, int listIndex); + void appendFileInfoToGridLayout(QGridLayout* gridLayout, const RifRestartFileInfo& fileInfo, const QString& fullPathFileName); + void appendTextToGridLayout(QGridLayout* gridLayout, const QString& text); + RifRestartFileInfo getFileInfo(const QString& summaryHeaderFile); + void displayWarningsIfAny(const QStringList& warnings); + QString fullFileName(const QString& shortOrFullFileName); + +private slots: + void slotShowFullPathToggled(int state); + void slotDialogButtonClicked(QAbstractButton* button); + void slotFileNameCopyCustomMenuRequested(const QPoint& point); + void slotCopyFileNameToClipboard(); + +private: + QGroupBox* m_currentFilesGroup; + QGridLayout* m_currentFilesLayout; + + QGridLayout* m_summaryFilesLayout; + + QRadioButton* m_summaryReadAllBtn; + QRadioButton* m_summarySeparateCasesBtn; + QRadioButton* m_summaryNotReadBtn; + + QGroupBox* m_gridFilesGroup; + QGridLayout* m_gridFilesLayout; + + QRadioButton* m_gridNotReadBtn; + QRadioButton* m_gridSeparateCasesBtn; + + QCheckBox* m_showFullPathCheckBox; + QDialogButtonBox* m_buttons; + + bool m_okToAllPressed; + QListWidget* m_warnings; + + std::vector>> m_fileLists; +}; + + +//================================================================================================== +/// +//================================================================================================== +class RicSummaryCaseRestartDialogResult +{ +public: + enum Status + { + SUMMARY_OK = 0, + SUMMARY_CANCELLED, + SUMMARY_WARNING, + SUMMARY_ERROR + }; + RicSummaryCaseRestartDialogResult(Status _status = SUMMARY_ERROR) : + status(_status), + summaryImportOption(RicSummaryCaseRestartDialog::IMPORT_ALL), + gridImportOption(RicSummaryCaseRestartDialog::NOT_IMPORT), + applyToAll(false) {} + + RicSummaryCaseRestartDialogResult(Status _status, + RicSummaryCaseRestartDialog::ImportOptions _summaryImportOption, + RicSummaryCaseRestartDialog::ImportOptions _gridImportOption, + QStringList _summaryFiles, + QStringList _gridFiles, + bool _applyToAll) : + status(_status), + summaryImportOption(_summaryImportOption), + gridImportOption(_gridImportOption), + summaryFiles(_summaryFiles), + gridFiles(_gridFiles), + applyToAll(_applyToAll) + { + } + + Status status; + RicSummaryCaseRestartDialog::ImportOptions summaryImportOption; + RicSummaryCaseRestartDialog::ImportOptions gridImportOption; + QStringList summaryFiles; + QStringList gridFiles; + bool applyToAll; +}; diff --git a/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp b/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp index 28fff621b1..404c8a46bc 100644 --- a/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp +++ b/ApplicationCode/Commands/RicTogglePerspectiveViewFeature.cpp @@ -20,7 +20,7 @@ #include "RicTogglePerspectiveViewFeature.h" #include "RiuViewer.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuMainWindow.h" #include "RiaApplication.h" @@ -34,7 +34,7 @@ CAF_CMD_SOURCE_INIT(RicTogglePerspectiveViewFeature, "RicTogglePerspectiveViewFe bool RicTogglePerspectiveViewFeature::isCommandEnabled() { this->action(); // Retrieve the action to update the looks - return RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer(); + return RiaApplication::instance()->activeGridView() && RiaApplication::instance()->activeReservoirView()->viewer(); } //-------------------------------------------------------------------------------------------------- @@ -42,7 +42,7 @@ bool RicTogglePerspectiveViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicTogglePerspectiveViewFeature::onActionTriggered(bool isChecked) { - if(RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) + if(RiaApplication::instance()->activeGridView() && RiaApplication::instance()->activeReservoirView()->viewer()) { bool isPerspective = RiaApplication::instance()->activeReservoirView()->isPerspectiveView(); RiaApplication::instance()->activeReservoirView()->isPerspectiveView = !isPerspective; diff --git a/ApplicationCode/Commands/RicViewerEventInterface.h b/ApplicationCode/Commands/RicViewerEventInterface.h index 2e33707a7d..690597e7a5 100644 --- a/ApplicationCode/Commands/RicViewerEventInterface.h +++ b/ApplicationCode/Commands/RicViewerEventInterface.h @@ -25,29 +25,37 @@ #include "cvfObject.h" #include "cvfVector3.h" -namespace cvf { - class Part; -} +namespace cvf { + class Part; +} -class RicViewerEventInterface +class Rim3dView; + +//================================================================================================== +/// +//================================================================================================== +class RicViewerEventObject { public: - virtual bool handleEvent(cvf::Object* eventObject) = 0; + RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, const std::vector>& partAndTriangleIndexPairs, Rim3dView* view) + : m_globalIntersectionPoint(globalIntersectionPoint), + m_partAndTriangleIndexPairs(partAndTriangleIndexPairs), + m_view(view) + { + } + + cvf::Vec3d m_globalIntersectionPoint; + std::vector> m_partAndTriangleIndexPairs; + Rim3dView* m_view; }; -class RicViewerEventObject : public cvf::Object +//================================================================================================== +/// +//================================================================================================== +class RicViewerEventInterface { public: - RicViewerEventObject(cvf::Vec3d globalIntersectionPoint, cvf::Part* firstHitPart, cvf::uint firstPartTriangleIndex) - : globalIntersectionPoint(globalIntersectionPoint), - firstHitPart(firstHitPart), - firstPartTriangleIndex(firstPartTriangleIndex) - { - } - - cvf::Vec3d globalIntersectionPoint; - cvf::Part* firstHitPart; - cvf::uint firstPartTriangleIndex; + virtual bool handleEvent(const RicViewerEventObject& eventObject) = 0; }; diff --git a/ApplicationCode/Commands/RicWellLogTools.cpp b/ApplicationCode/Commands/RicWellLogTools.cpp index 32a95c6724..3eaa5e3c8e 100644 --- a/ApplicationCode/Commands/RicWellLogTools.cpp +++ b/ApplicationCode/Commands/RicWellLogTools.cpp @@ -24,7 +24,7 @@ #include "RimEclipseResultCase.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogFileChannel.h" #include "RimWellLogFileCurve.h" @@ -35,7 +35,7 @@ #include "RifReaderEclipseRft.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSelectionManager.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -84,6 +84,26 @@ RimWellPath* RicWellLogTools::selectedWellPath() return selection.size() > 0 ? selection[0] : nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath* RicWellLogTools::findWellPathFromSelection() +{ + std::vector selection; + caf::SelectionManager::instance()->objectsByType(&selection); + if (selection.size() > 0) + { + caf::PdmObject* firstSelection = selection[0]; + RimWellPath* wellPath; + firstSelection->firstAncestorOrThisOfType(wellPath); + if (wellPath) + { + return wellPath; + } + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -116,10 +136,10 @@ bool RicWellLogTools::isWellPathOrSimWellSelectedInView() RiuSelectionManager* riuSelManager = RiuSelectionManager::instance(); RiuSelectionItem* selItem = riuSelManager->selectedItem(RiuSelectionManager::RUI_TEMPORARY); - RiuSimWellSelectionItem* simWellSelectionItem = static_cast(selItem); + RiuSimWellSelectionItem* simWellSelectionItem = dynamic_cast(selItem); if (simWellSelectionItem) return true; - RiuWellPathSelectionItem* wellPathSelectionItem = static_cast(selItem); + RiuWellPathSelectionItem* wellPathSelectionItem = dynamic_cast(selItem); if (wellPathSelectionItem) return true; return false; @@ -173,7 +193,20 @@ RimWellPath* RicWellLogTools::selectedWellPathWithLogFile() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection) +RimWellPath* RicWellLogTools::findWellPathWithLogFileFromSelection() +{ + RimWellPath* wellPath = findWellPathFromSelection(); + if (wellPath->wellLogFiles().size() > 0) + { + return wellPath; + } + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack, Rim3dView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection) { CVF_ASSERT(plotTrack); RimWellLogExtractionCurve* curve = new RimWellLogExtractionCurve(); @@ -206,11 +239,11 @@ RimWellLogExtractionCurve* RicWellLogTools::addExtractionCurve(RimWellLogTrack* plotTrack->updateConnectedEditors(); // Make sure the summary plot window is created and visible - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); RiaApplication::instance()->project()->updateConnectedEditors(); - plotwindow->selectAsCurrentItem(curve); + RiuPlotMainWindowTools::selectAsCurrentItem(curve); return curve; } @@ -254,11 +287,11 @@ RimWellLogRftCurve* RicWellLogTools::addRftCurve(RimWellLogTrack* plotTrack, con plotTrack->setFormationTrajectoryType(RimWellLogTrack::SIMULATION_WELL); plotTrack->updateConnectedEditors(); - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); RiaApplication::instance()->project()->updateConnectedEditors(); - plotwindow->selectAsCurrentItem(curve); + RiuPlotMainWindowTools::selectAsCurrentItem(curve); return curve; } @@ -279,8 +312,8 @@ RimWellLogFileCurve* RicWellLogTools::addFileCurve(RimWellLogTrack* plotTrack) plotTrack->updateConnectedEditors(); - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - plotwindow->selectAsCurrentItem(curve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(curve); return curve; } diff --git a/ApplicationCode/Commands/RicWellLogTools.h b/ApplicationCode/Commands/RicWellLogTools.h index e3b3ea0fd6..e9f671288c 100644 --- a/ApplicationCode/Commands/RicWellLogTools.h +++ b/ApplicationCode/Commands/RicWellLogTools.h @@ -23,7 +23,8 @@ #include class RimSimWellInView; -class RimView; +class Rim3dView; +class Rim3dWellLogCurveCollection; class RimWellLogExtractionCurve; class RimWellLogFileChannel; class RimWellLogFileCurve; @@ -37,17 +38,19 @@ class RimWellPath; class RicWellLogTools { public: - static RimWellLogTrack* selectedWellLogPlotTrack(); - static RimSimWellInView* selectedSimulationWell(int* branchIndex); - static RimWellPath* selectedWellPath(); - static bool wellHasRftData(const QString& wellName); - static bool isWellPathOrSimWellSelectedInView(); - static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, + static RimWellLogTrack* selectedWellLogPlotTrack(); + static RimSimWellInView* selectedSimulationWell(int* branchIndex); + static RimWellPath* selectedWellPath(); + static RimWellPath* findWellPathFromSelection(); + static bool wellHasRftData(const QString& wellName); + static bool isWellPathOrSimWellSelectedInView(); + static void addWellLogChannelsToPlotTrack(RimWellLogTrack* plotTrack, const std::vector& wellLogFileChannels); - static RimWellPath* selectedWellPathWithLogFile(); - static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, RimView* view, RimWellPath* wellPath, + static RimWellPath* selectedWellPathWithLogFile(); + static RimWellPath* findWellPathWithLogFileFromSelection(); + static RimWellLogExtractionCurve* addExtractionCurve(RimWellLogTrack* plotTrack, Rim3dView* view, RimWellPath* wellPath, const RimSimWellInView* simWell, int branchIndex, bool useBranchDetection); - static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell); - static RimWellLogFileCurve* addFileCurve(RimWellLogTrack* plotTrack); + static RimWellLogRftCurve* addRftCurve(RimWellLogTrack* plotTrack, const RimSimWellInView* simWell); + static RimWellLogFileCurve* addFileCurve(RimWellLogTrack* plotTrack); }; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake index 841ee8017a..ff9d3e59fc 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/SummaryPlotCommands/CMakeLists_files.cmake @@ -1,78 +1,76 @@ -# 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}RicNewSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.h -${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.h -${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicSelectSummaryPlotUI.h -${CEE_CURRENT_LIST_DIR}RicPasteTimeHistoryCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicEditSummaryPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicEditSummaryCrossPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreator.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.h -${CEE_CURRENT_LIST_DIR}RicShowSummaryCurveCalculatorFeature.h -${CEE_CURRENT_LIST_DIR}RicEditSummaryCurveCalculationFeature.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorEditor.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculator.h -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeatureUi.h +${CMAKE_CURRENT_LIST_DIR}/RicViewZoomAllFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveSwitchAxisFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCaseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewGridTimeHistoryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSelectSummaryPlotUI.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteTimeHistoryCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCrossPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreator.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorSplitterUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicNewSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewSummaryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDuplicateSummaryCrossPlotCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataToSummaryPlotFeatureUi.cpp -${CEE_CURRENT_LIST_DIR}RicViewZoomAllFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveSwitchAxisFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCrossPlotCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteSummaryCaseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicAsciiExportSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewGridTimeHistoryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSelectSummaryPlotUI.cpp -${CEE_CURRENT_LIST_DIR}RicPasteTimeHistoryCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteAsciiDataCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditSummaryPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditSummaryCrossPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreator.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.cpp -${CEE_CURRENT_LIST_DIR}RicShowSummaryCurveCalculatorFeature.cpp -${CEE_CURRENT_LIST_DIR}RicEditSummaryCurveCalculationFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorEditor.cpp -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculator.cpp -${CEE_CURRENT_LIST_DIR}RicNewSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDuplicateSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataToSummaryPlotFeatureUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicViewZoomAllFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveSwitchAxisFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteSummaryCaseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewGridTimeHistoryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSelectSummaryPlotUI.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteTimeHistoryCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteAsciiDataCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCrossPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorSplitterUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowSummaryCurveCalculatorFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicEditSummaryCurveCalculationFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryCrossPlotCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewSummaryEnsembleCurveSetFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteEnsembleCurveSetFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -84,11 +82,10 @@ ${SOURCE_GROUP_SOURCE_FILES} ) list(APPEND QT_MOC_HEADERS -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorSplitterUi.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCreatorDialog.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorEditor.h -${CEE_CURRENT_LIST_DIR}RicSummaryCurveCalculatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorSplitterUi.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCreatorDialog.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorEditor.h +${CMAKE_CURRENT_LIST_DIR}/RicSummaryCurveCalculatorDialog.h ) - -source_group( "CommandFeature\\SummaryPlot" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\SummaryPlot" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp index f8496965b4..6e158dafb7 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotCurveFeature.cpp @@ -31,7 +31,7 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp index 994f6176c3..20d6e46b10 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCrossPlotFeature.cpp @@ -70,6 +70,6 @@ void RicDuplicateSummaryCrossPlotFeature::onActionTriggered(bool isChecked) void RicDuplicateSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Duplicate Summary Cross Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryXPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp index ad1e0b2cb3..addcac632a 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryCurveFeature.cpp @@ -31,7 +31,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -65,8 +65,8 @@ void RicDuplicateSummaryCurveFeature::onActionTriggered(bool isChecked) if (curve) { RimSummaryCurve* newCurve = RicPasteSummaryCurveFeature::copyCurveAndAddToPlot(curve); - - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(newCurve); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp index 0efdc162e0..747a698c86 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicDuplicateSummaryPlotFeature.cpp @@ -70,6 +70,6 @@ void RicDuplicateSummaryPlotFeature::onActionTriggered(bool isChecked) void RicDuplicateSummaryPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Duplicate Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp index 4723240255..38c67c532c 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryCrossPlotFeature.cpp @@ -108,7 +108,7 @@ void RicEditSummaryCrossPlotFeature::onActionTriggered(bool isChecked) void RicEditSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Edit Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryXPlotLight16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp index 0d795a4775..6b8c47a56b 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicEditSummaryPlotFeature.cpp @@ -110,7 +110,7 @@ void RicEditSummaryPlotFeature::onActionTriggered(bool isChecked) void RicEditSummaryPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Edit Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp index 9b1a683ea1..32ea6a52a3 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewGridTimeHistoryCurveFeature.cpp @@ -36,7 +36,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafPdmReferenceHelper.h" @@ -71,7 +71,8 @@ void RicNewGridTimeHistoryCurveFeature::createCurveFromSelectionItem(const RiuSe plot->updateConnectedEditors(); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(newCurve); } //-------------------------------------------------------------------------------------------------- @@ -112,7 +113,7 @@ RimSummaryPlot* RicNewGridTimeHistoryCurveFeature::userSelectedSummaryPlot() QString newPlotName = RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName(); featureUi.setSuggestedPlotName(newPlotName); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Select Destination Plot", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Select Destination Plot", ""); propertyDialog.resize(QSize(400, 200)); if (propertyDialog.exec() != QDialog::Accepted) return nullptr; @@ -147,7 +148,7 @@ QString RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName() QString resultName; { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); RimEclipseView* eclView = dynamic_cast(activeView); if (eclView) { @@ -177,6 +178,7 @@ QString RicNewGridTimeHistoryCurveFeature::suggestedNewPlotName() case RIG_NODAL: posName = "N"; break; case RIG_ELEMENT_NODAL: posName = "EN"; break; case RIG_INTEGRATION_POINT: posName = "IP"; break; + case RIG_ELEMENT: posName = "E"; break; } QString fieldUiName = resultDefinition->resultFieldUiName(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp index 3f39f73545..e61d1e9961 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotCurveFeature.cpp @@ -30,7 +30,7 @@ #include "RimSummaryCrossPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -78,7 +78,7 @@ void RicNewSummaryCrossPlotCurveFeature::onActionTriggered(bool isChecked) RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp index b4ed164d33..55803c2e12 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCrossPlotFeature.cpp @@ -20,6 +20,7 @@ #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaSummaryTools.h" #include "RicEditSummaryPlotFeature.h" #include "RicSummaryCurveCreator.h" @@ -30,8 +31,12 @@ #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" + +#include "cafSelectionManagerTools.h" #include "cvfAssert.h" @@ -45,6 +50,24 @@ CAF_CMD_SOURCE_INIT(RicNewSummaryCrossPlotFeature, "RicNewSummaryCrossPlotFeatur //-------------------------------------------------------------------------------------------------- bool RicNewSummaryCrossPlotFeature::isCommandEnabled() { + RimSummaryCrossPlotCollection* sumPlotColl = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlotColl = RiaSummaryTools::parentCrossPlotCollection(selObj); + } + + if (sumPlotColl) return true; + + // Multiple case selections + std::vector selectedItems = caf::selectedObjectsByTypeStrict(); + + for (auto item : selectedItems) + { + if (!dynamic_cast(item) && !dynamic_cast(item)) + return false; + } return true; } @@ -65,12 +88,9 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked) summaryCrossPlotColl->updateConnectedEditors(); summaryPlot->loadDataAndUpdate(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(summaryPlot); - mainPlotWindow->setExpanded(summaryPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(summaryPlot); + RiuPlotMainWindowTools::setExpanded(summaryPlot); } } @@ -80,6 +100,6 @@ void RicNewSummaryCrossPlotFeature::onActionTriggered(bool isChecked) void RicNewSummaryCrossPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New Summary Cross Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryXPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp index 9f0d2d8773..3d040f8929 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryCurveFeature.cpp @@ -29,7 +29,7 @@ #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" @@ -82,7 +82,7 @@ void RicNewSummaryCurveFeature::onActionTriggered(bool isChecked) RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(newCurve); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp new file mode 100644 index 0000000000..17c7954952 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.cpp @@ -0,0 +1,112 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicNewSummaryEnsembleCurveSetFeature.h" + +#include "RiaApplication.h" +#include "RiaColorTables.h" + +#include "RimMainPlotCollection.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RiaSummaryTools.h" +#include "RimSummaryCaseMainCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotCollection.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" + +#include "RiuPlotMainWindow.h" + +#include "WellLogCommands/RicWellLogPlotCurveFeatureImpl.h" + +#include "cafSelectionManager.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicNewSummaryEnsembleCurveSetFeature, "RicNewSummaryEnsembleCurveSetFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewSummaryEnsembleCurveSetFeature::isCommandEnabled() +{ + return (selectedSummaryPlot()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryEnsembleCurveSetFeature::onActionTriggered(bool isChecked) +{ + RimProject* project = RiaApplication::instance()->project(); + CVF_ASSERT(project); + + RimSummaryPlot* plot = selectedSummaryPlot(); + if (plot) + { + RimEnsembleCurveSet* curveSet = new RimEnsembleCurveSet(); + + size_t colorIndex = plot->ensembleCurveSetCollection()->curveSetCount(); + curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); + curveSet->legendConfig()->setColorRange(RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(static_cast(colorIndex))); + + if (!project->summaryGroups().empty()) + { + curveSet->setSummaryCaseCollection(project->summaryGroups().back()); + } + + plot->ensembleCurveSetCollection()->addCurveSet(curveSet); + plot->updateConnectedEditors(); + + RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(curveSet); + + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateSummaryPlotToolBar(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewSummaryEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("New Ensemble Curve Set"); + actionToSetup->setIcon(QIcon(":/EnsembleCurveSet16x16.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryPlot* RicNewSummaryEnsembleCurveSetFeature::selectedSummaryPlot() const +{ + RimSummaryPlot* sumPlot = nullptr; + + caf::PdmObject* selObj = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + if (selObj) + { + sumPlot = RiaSummaryTools::parentSummaryPlot(selObj); + } + + return sumPlot; +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h new file mode 100644 index 0000000000..23fd99166f --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryEnsembleCurveSetFeature.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +#include + +class RimSummaryPlot; + +//================================================================================================== +/// +//================================================================================================== +class RicNewSummaryEnsembleCurveSetFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; +protected: + // Overrides + virtual bool isCommandEnabled(); + virtual void onActionTriggered( bool isChecked ); + virtual void setupActionLook( QAction* actionToSetup ); + +private: + RimSummaryPlot* selectedSummaryPlot() const; +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp index 308b18f54e..6a95c1067e 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicNewSummaryPlotFeature.cpp @@ -29,11 +29,14 @@ #include "RimSummaryCurveFilter.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cvfAssert.h" -#include "cafSelectionManager.h" +#include "cafSelectionManagerTools.h" +//#include "cafPdmUiItem.h" #include @@ -55,7 +58,15 @@ bool RicNewSummaryPlotFeature::isCommandEnabled() if (sumPlotColl) return true; - return false; + // Multiple case selections + std::vector selectedItems = caf::selectedObjectsByTypeStrict(); + + for (auto item : selectedItems) + { + if (!dynamic_cast(item) && !dynamic_cast(item)) + return false; + } + return true; } //-------------------------------------------------------------------------------------------------- @@ -66,6 +77,16 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); + std::vector selectedCases = caf::selectedObjectsByType(); + std::vector selectedGroups = caf::selectedObjectsByType(); + + // Append grouped cases + for (auto group : selectedGroups) + { + auto groupCases = group->allSummaryCases(); + selectedCases.insert(selectedCases.end(), groupCases.begin(), groupCases.end()); + } + auto dialog = RicEditSummaryPlotFeature::curveCreatorDialog(); if (!dialog->isVisible()) @@ -77,7 +98,7 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) dialog->raise(); } - dialog->updateFromSummaryPlot(nullptr); + dialog->updateFromDefaultCases(selectedCases); } //-------------------------------------------------------------------------------------------------- @@ -86,6 +107,6 @@ void RicNewSummaryPlotFeature::onActionTriggered(bool isChecked) void RicNewSummaryPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New Summary Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/SummaryPlotLight16x16.png")); } diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp index d02e9bee02..94bd772344 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteAsciiDataToSummaryPlotFeature.cpp @@ -84,7 +84,7 @@ void RicPasteAsciiDataToSummaryPlotFeature::onActionTriggered(bool isChecked) if (!summaryPlot) pasteOptions.createNewPlot(); pasteOptions.setUiModePasteText(text); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &pasteOptions, "Set Paste Options", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &pasteOptions, "Set Paste Options", ""); if (propertyDialog.exec() != QDialog::Accepted) return; std::vector curves = parseCurves(text, pasteOptions); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp new file mode 100644 index 0000000000..5a8ef7a69e --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.cpp @@ -0,0 +1,128 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicPasteEnsembleCurveSetFeature.h" + +#include "RiaSummaryTools.h" + +#include "OperationsUsingObjReferences/RicPasteFeatureImpl.h" + +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +//#include "RimSummaryCurve.h" +//#include "RimSummaryCurveFilter.h" +#include "RimSummaryPlot.h" +//#include "RimSummaryCrossPlot.h" + +#include "cafPdmDefaultObjectFactory.h" +#include "cafPdmDocument.h" +#include "cafPdmObjectGroup.h" +#include "cafSelectionManagerTools.h" + +#include "cvfAssert.h" + +#include + + +CAF_CMD_SOURCE_INIT(RicPasteEnsembleCurveSetFeature, "RicPasteEnsembleCurveSetFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RicPasteEnsembleCurveSetFeature::copyCurveSetAndAddToCollection(RimEnsembleCurveSet *sourceCurveSet) +{ + RimSummaryPlot* plot = caf::firstAncestorOfTypeFromSelectedObject(); + RimEnsembleCurveSetCollection* coll = caf::firstAncestorOfTypeFromSelectedObject(); + + RimEnsembleCurveSet* newCurveSet = dynamic_cast(sourceCurveSet->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(newCurveSet); + + if (!coll) coll = plot->ensembleCurveSetCollection(); + + coll->addCurveSet(newCurveSet); + + // Resolve references after object has been inserted into the project data model + newCurveSet->resolveReferencesRecursively(); + newCurveSet->initAfterReadRecursively(); + newCurveSet->loadDataAndUpdate(true); + newCurveSet->updateConnectedEditors(); + + coll->updateConnectedEditors(); + + return newCurveSet; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteEnsembleCurveSetFeature::isCommandEnabled() +{ + caf::PdmObject* destinationObject = dynamic_cast(caf::SelectionManager::instance()->selectedItem()); + + RimSummaryPlot* plot; + RimEnsembleCurveSetCollection* coll = nullptr; + destinationObject->firstAncestorOrThisOfType(plot); + destinationObject->firstAncestorOrThisOfType(coll); + if(!coll && !plot) + { + return false; + } + + if (ensembleCurveSetsOnClipboard().size() == 0) + { + return false; + } + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEnsembleCurveSetFeature::onActionTriggered(bool isChecked) +{ + std::vector > sourceObjects = RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard(); + + for (size_t i = 0; i < sourceObjects.size(); i++) + { + copyCurveSetAndAddToCollection(sourceObjects[i]); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteEnsembleCurveSetFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Paste Ensemble Curve Set"); + + RicPasteFeatureImpl::setIconAndShortcuts(actionToSetup); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector > RicPasteEnsembleCurveSetFeature::ensembleCurveSetsOnClipboard() +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs(&objectGroup); + + std::vector > typedObjects; + objectGroup.objectsByType(&typedObjects); + + return typedObjects; +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h new file mode 100644 index 0000000000..c4511b0cc4 --- /dev/null +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicPasteEnsembleCurveSetFeature.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" +#include "cafPdmPointer.h" + +#include + +class RimEnsembleCurveSet; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteEnsembleCurveSetFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +public: + static RimEnsembleCurveSet* copyCurveSetAndAddToCollection(RimEnsembleCurveSet *sourceCurveSet); + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook(QAction* actionToSetup) override; + + static std::vector > ensembleCurveSetsOnClipboard(); +}; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp index 03a0a56d74..85b9898a96 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicShowSummaryCurveCalculatorFeature.cpp @@ -54,7 +54,10 @@ void RicShowSummaryCurveCalculatorFeature::hideCurveCalculatorDialog() //-------------------------------------------------------------------------------------------------- bool RicShowSummaryCurveCalculatorFeature::isCommandEnabled() { - return true; + RimProject* proj = RiaApplication::instance()->project(); + const auto& allSumCases = proj->allSummaryCases(); + + return !allSumCases.empty(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp index 2c1bd90cea..fba1f1dcdc 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,6 +19,7 @@ #include "RicSummaryCurveCreator.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaSummaryCurveDefinition.h" #include "RicSelectSummaryPlotUI.h" @@ -26,11 +27,15 @@ #include "RifReaderEclipseSummary.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" #include "RimMainPlotCollection.h" #include "RimObservedData.h" #include "RimObservedDataCollection.h" #include "RimOilField.h" #include "RimProject.h" +#include "RimSummaryCalculationCollection.h" #include "RimSummaryCase.h" #include "RimSummaryCaseCollection.h" #include "RimSummaryCaseMainCollection.h" @@ -39,9 +44,8 @@ #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" -#include "RimSummaryCalculationCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSummaryCurveDefSelection.h" #include "RiuSummaryQwtPlot.h" #include "RiuTools.h" @@ -50,15 +54,30 @@ #include "cafPdmUiPushButtonEditor.h" #include +#include #include #include - CAF_PDM_SOURCE_INIT(RicSummaryCurveCreator, "RicSummaryCurveCreator"); //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +const size_t ENSEMBLE_CURVE_COUNT_THRESHOLD = 600; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RicSummaryCurveCreator::CONFIGURATION_NAME = "CurveCreatorCfg"; + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +int ensembleCurveCount(const std::set& allCurveDefs); + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- RicSummaryCurveCreator::RicSummaryCurveCreator() { @@ -104,20 +123,18 @@ RicSummaryCurveCreator::RicSummaryCurveCreator() m_summaryCurveSelectionEditor.reset(new RiuSummaryCurveDefSelectionEditor()); - m_summaryCurveSelectionEditor->summaryAddressSelection()->setFieldChangedHandler([this]() { this->selectionEditorFieldChanged(); }); + m_summaryCurveSelectionEditor->summaryAddressSelection()->setFieldChangedHandler( + [this]() { this->selectionEditorFieldChanged(); }); m_summaryCurveSelectionEditor->summaryAddressSelection()->setMultiSelectionMode(true); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RicSummaryCurveCreator::~RicSummaryCurveCreator() -{ -} +RicSummaryCurveCreator::~RicSummaryCurveCreator() {} //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryPlot* RicSummaryCurveCreator::previewPlot() const { @@ -125,35 +142,37 @@ RimSummaryPlot* RicSummaryCurveCreator::previewPlot() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot) +void RicSummaryCurveCreator::updateFromSummaryPlot(RimSummaryPlot* targetPlot, const std::vector& defaultCases) { if (targetPlot == nullptr || m_targetPlot != targetPlot) { resetAllFields(); } - - m_targetPlot = targetPlot; + + m_targetPlot = targetPlot; m_useAutoAppearanceAssignment = true; if (m_targetPlot) { populateCurveCreator(*m_targetPlot); + syncPreviewCurvesFromUiSelection(); + setInitialCurveVisibility(targetPlot); + m_previewPlot->loadDataAndUpdate(); } else { - setDefaultCurveSelection(); + setDefaultCurveSelection(defaultCases); m_previewPlot->enableAutoPlotTitle(true); + syncPreviewCurvesFromUiSelection(); } - syncPreviewCurvesFromUiSelection(); - caf::PdmUiItem::updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QWidget* RicSummaryCurveCreator::addressSelectionWidget(QWidget* parent) { @@ -161,7 +180,7 @@ QWidget* RicSummaryCurveCreator::addressSelectionWidget(QWidget* parent) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicSummaryCurveCreator::isCloseButtonPressed() const { @@ -169,7 +188,7 @@ bool RicSummaryCurveCreator::isCloseButtonPressed() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::clearCloseButton() { @@ -177,9 +196,11 @@ void RicSummaryCurveCreator::clearCloseButton() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { if (changedField == &m_applyButtonField || changedField == &m_okButtonField) { @@ -193,13 +214,14 @@ void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changed if (changedField == &m_okButtonField) { m_closeButtonField = true; - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - mainPlotWindow->selectAsCurrentItem(m_targetPlot); - mainPlotWindow->setExpanded(m_targetPlot); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(m_targetPlot); + RiuPlotMainWindowTools::setExpanded(m_targetPlot); } m_applyButtonField = false; - m_okButtonField = false; + m_okButtonField = false; caf::PdmField* field = dynamic_cast*>(m_targetPlot->uiCapability()->objectToggleField()); field->setValueWithFieldChanged(true); @@ -223,16 +245,17 @@ void RicSummaryCurveCreator::fieldChangedByUi(const caf::PdmFieldHandle* changed } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RicSummaryCurveCreator::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +QList RicSummaryCurveCreator::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; if (fieldNeedingOptions == &m_targetPlot) { RimProject* proj = RiaApplication::instance()->project(); - + RimSummaryPlotCollection* summaryPlotColl = proj->mainPlotCollection()->summaryPlotCollection(); // Create New Plot item @@ -249,12 +272,13 @@ QList RicSummaryCurveCreator::calculateValueOptions(cons } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { // Appearance settings - caf::PdmUiGroup* appearanceGroup = uiOrdering.addNewGroupWithKeyword("Curve Appearance Assignment", RiuSummaryCurveDefinitionKeywords::appearance()); + caf::PdmUiGroup* appearanceGroup = + uiOrdering.addNewGroupWithKeyword("Curve Appearance Assignment", RiuSummaryCurveDefinitionKeywords::appearance()); caf::PdmUiGroup* appearanceSubGroup = appearanceGroup->addNewGroup("Appearance Type Assignment"); appearanceSubGroup->setCollapsedByDefault(true); @@ -278,7 +302,8 @@ void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOr } // Name config - caf::PdmUiGroup* autoNameGroup = uiOrdering.addNewGroupWithKeyword("Plot and Curve Name Configuration", RiuSummaryCurveDefinitionKeywords::nameConfig()); + caf::PdmUiGroup* autoNameGroup = + uiOrdering.addNewGroupWithKeyword("Plot and Curve Name Configuration", RiuSummaryCurveDefinitionKeywords::nameConfig()); autoNameGroup->setCollapsedByDefault(true); autoNameGroup->add(&m_useAutoPlotTitleProxy); @@ -303,41 +328,48 @@ void RicSummaryCurveCreator::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() { - std::vector allCurveDefinitionsVector = m_summaryCurveSelectionEditor->summaryAddressSelection()->selectedCurveDefinitions(); - std::set allCurveDefinitions = std::set(allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end()); + std::vector allCurveDefinitionsVector = + m_summaryCurveSelectionEditor->summaryAddressSelection()->allCurveDefinitionsFromSelection(); + std::set allCurveDefinitions = + std::set(allCurveDefinitionsVector.begin(), allCurveDefinitionsVector.end()); - std::vector currentCurvesInPreviewPlot = m_previewPlot->summaryCurves(); + std::vector currentCurvesInPreviewPlot = m_previewPlot->summaryAndEnsembleCurves(); if (allCurveDefinitions.size() != currentCurvesInPreviewPlot.size()) { std::set currentCurveDefs; std::set newCurveDefs; - std::set curvesToDelete; + std::set curvesToDelete; for (const auto& curve : currentCurvesInPreviewPlot) { - currentCurveDefs.insert(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); + RimSummaryCase* sumCase = curve->summaryCaseY(); + currentCurveDefs.insert(RiaSummaryCurveDefinition(sumCase, curve->summaryAddressY(), sumCase ? sumCase->ensemble() : nullptr)); } - + if (allCurveDefinitions.size() < currentCurvesInPreviewPlot.size()) { // Determine which curves to delete from plot std::set deleteCurveDefs; - std::set_difference(currentCurveDefs.begin(), currentCurveDefs.end(), - allCurveDefinitions.begin(), allCurveDefinitions.end(), + std::set_difference(currentCurveDefs.begin(), + currentCurveDefs.end(), + allCurveDefinitions.begin(), + allCurveDefinitions.end(), std::inserter(deleteCurveDefs, deleteCurveDefs.end())); for (const auto& curve : currentCurvesInPreviewPlot) { - RiaSummaryCurveDefinition curveDef = RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY()); - if (deleteCurveDefs.count(curveDef) > 0) - curvesToDelete.insert(curve); + RimSummaryCase* sumCase = curve->summaryCaseY(); + RiaSummaryCurveDefinition curveDef = RiaSummaryCurveDefinition(sumCase, curve->summaryAddressY(), sumCase ? sumCase->ensemble() : nullptr); + if (deleteCurveDefs.count(curveDef) > 0) curvesToDelete.insert(curve); } } else { // Determine which curves are new since last time - std::set_difference(allCurveDefinitions.begin(), allCurveDefinitions.end(), - currentCurveDefs.begin(), currentCurveDefs.end(), + std::set_difference(allCurveDefinitions.begin(), + allCurveDefinitions.end(), + currentCurveDefs.begin(), + currentCurveDefs.end(), std::inserter(newCurveDefs, newCurveDefs.end())); } @@ -346,15 +378,26 @@ void RicSummaryCurveCreator::syncPreviewCurvesFromUiSelection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std::set& allCurveDefsToDisplay, - const std::set& curveDefsToAdd, - const std::set& curvesToDelete) +void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions( + const std::set& allCurveDefsToDisplay, + const std::set& curveDefsToAdd, + const std::set& curvesToDelete) { - RimSummaryCase* prevCase = nullptr; - RimSummaryCurveAppearanceCalculator curveLookCalc(allCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); + static bool warningDisplayed = false; + + RimSummaryCase* prevCase = nullptr; + std::set summaryCurveDefsToDisplay; + // Ignore curve sets when assigning colors to singe summary curves + for (const auto& def : allCurveDefsToDisplay) + { + if (!def.isEnsembleCurve()) summaryCurveDefsToDisplay.insert(def); + } + + RimSummaryCurveAppearanceCalculator curveLookCalc( + summaryCurveDefsToDisplay, getAllSummaryCaseNames(), getAllSummaryWellNames()); initCurveAppearanceCalculator(curveLookCalc); // Delete curves @@ -363,16 +406,63 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: m_previewPlot->deleteCurve(curve); } + size_t ensembleCurveCnt = ensembleCurveCount(allCurveDefsToDisplay); + // Add new curves for (const auto& curveDef : curveDefsToAdd) { - RimSummaryCase* currentCase = curveDef.summaryCase(); - RimSummaryCurve* curve = new RimSummaryCurve(); + RimSummaryCase* currentCase = curveDef.summaryCase(); + RimSummaryCurve* curve = new RimSummaryCurve(); curve->setSummaryCaseY(currentCase); curve->setSummaryAddressY(curveDef.summaryAddress()); curve->applyCurveAutoNameSettings(*m_curveNameConfig()); - m_previewPlot->addCurveNoUpdate(curve); - curveLookCalc.setupCurveLook(curve); + + if (curveDef.isEnsembleCurve()) + { + // Find curveSet + RimEnsembleCurveSet* curveSet = nullptr; + for (const auto& cs : m_previewPlot->ensembleCurveSetCollection()->curveSets()) + { + if (cs->summaryCaseCollection() == curveDef.ensemble() && cs->summaryAddress() == curveDef.summaryAddress()) + { + curveSet = cs; + break; + } + } + if (!curveSet) + { + curveSet = new RimEnsembleCurveSet(); + curveSet->setSummaryCaseCollection(curveDef.ensemble()); + curveSet->setSummaryAddress(curveDef.summaryAddress()); + m_previewPlot->ensembleCurveSetCollection()->addCurveSet(curveSet); + + // Set single curve set color + size_t colorIndex = m_previewPlot->ensembleCurveSetCollection()->curveSetCount(); + curveSet->setColor(RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3f(colorIndex)); + + if (m_previewPlot->ensembleCurveSetCollection()->curveSets().size() > 1 && ensembleCurveCnt > ENSEMBLE_CURVE_COUNT_THRESHOLD) + { + // Toggle off new curve set and display warning + curveSet->showCurves(false); + + if (!warningDisplayed) + { + QMessageBox mbox; + mbox.setIcon(QMessageBox::Icon::Warning); + mbox.setInformativeText( + "The new curve set is hidden. Too many visible curve sets may lead to poor performance"); + mbox.exec(); + warningDisplayed = true; + } + } + } + curveSet->addCurve(curve); + } + else + { + m_previewPlot->addCurveNoUpdate(curve); + curveLookCalc.setupCurveLook(curve); + } } m_previewPlot->loadDataAndUpdate(); @@ -382,13 +472,13 @@ void RicSummaryCurveCreator::updatePreviewCurvesFromCurveDefinitions(const std:: } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RicSummaryCurveCreator::getAllSummaryCaseNames() { std::set summaryCaseHashes; - RimProject* proj = RiaApplication::instance()->project(); - + RimProject* proj = RiaApplication::instance()->project(); + std::vector cases = proj->allSummaryCases(); for (RimSummaryCase* rimCase : cases) { @@ -399,12 +489,12 @@ std::set RicSummaryCurveCreator::getAllSummaryCaseNames() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RicSummaryCurveCreator::getAllSummaryWellNames() { std::set summaryWellNames; - RimProject* proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); std::vector cases = proj->allSummaryCases(); for (RimSummaryCase* rimCase : cases) @@ -432,13 +522,15 @@ std::set RicSummaryCurveCreator::getAllSummaryWellNames() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) { if (&m_applyButtonField == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "Apply"; @@ -446,7 +538,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_closeButtonField == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "Cancel"; @@ -454,7 +546,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_okButtonField == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "OK"; @@ -462,7 +554,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_appearanceApplyButton == field) { - caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->m_buttonText = "Apply"; @@ -470,7 +562,7 @@ void RicSummaryCurveCreator::defineEditorAttribute(const caf::PdmFieldHandle* fi } else if (&m_targetPlot == field) { - caf::PdmUiComboBoxEditorAttribute* attrib = dynamic_cast (attribute); + caf::PdmUiComboBoxEditorAttribute* attrib = dynamic_cast(attribute); if (attrib) { attrib->adjustWidthToContents = true; @@ -486,28 +578,27 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu std::vector curveDefs; m_previewPlot->deleteAllSummaryCurves(); + m_previewPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); + for (const auto& curve : sourceSummaryPlot.summaryCurves()) { - bool isObservedDataCase = isObservedData(curve->summaryCaseY()); - curveDefs.push_back(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); // Copy curve object to the preview plot copyCurveAndAddToPlot(curve, m_previewPlot.get(), true); } - // Set visibility for imported curves which were not checked in source plot - std::set > sourceCurveDefs; - for (const auto& curve : sourceSummaryPlot.summaryCurves()) + RimEnsembleCurveSetCollection* previewCurveSetColl = m_previewPlot->ensembleCurveSetCollection(); + for (const auto& curveSet : sourceSummaryPlot.ensembleCurveSetCollection()->curveSets()) { - sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); - } + RimEnsembleCurveSet* newCurveSet = curveSet->clone(); + previewCurveSetColl->addCurveSet(newCurveSet); - for (const auto& curve : m_previewPlot->summaryCurves()) - { - auto curveDef = std::make_pair(curve->summaryCaseY(), curve->summaryAddressY()); - if (sourceCurveDefs.count(curveDef) == 0) - curve->setCurveVisiblity(false); + RimSummaryCaseCollection* ensemble = curveSet->summaryCaseCollection(); + for (const auto& curve : curveSet->curves()) + { + curveDefs.push_back(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY(), ensemble)); + } } m_previewPlot->copyAxisPropertiesFromOther(sourceSummaryPlot); @@ -525,9 +616,10 @@ void RicSummaryCurveCreator::populateCurveCreator(const RimSummaryPlot& sourceSu //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateTargetPlot() { - if (m_targetPlot == nullptr) m_targetPlot = new RimSummaryPlot(); + if (!m_targetPlot) return; m_targetPlot->deleteAllSummaryCurves(); + m_targetPlot->ensembleCurveSetCollection()->deleteAllCurveSets(); // Add edited curves to target plot for (const auto& editedCurve : m_previewPlot->summaryCurves()) @@ -539,29 +631,70 @@ void RicSummaryCurveCreator::updateTargetPlot() copyCurveAndAddToPlot(editedCurve, m_targetPlot); } + for (const auto& editedCurveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets()) + { + if (!editedCurveSet->isCurvesVisible()) + { + continue; + } + + RimEnsembleCurveSet* newCurveSet = editedCurveSet->clone(); + m_targetPlot->ensembleCurveSetCollection()->addCurveSet(newCurveSet); + for (const auto& editedCurve : newCurveSet->curves()) + { + copyEnsembleCurveAndAddToCurveSet(editedCurve, editedCurveSet); + } + + newCurveSet->setParentQwtPlotNoReplot(m_targetPlot->qwtPlot()); + } + m_targetPlot->enableAutoPlotTitle(m_useAutoPlotTitleProxy()); m_targetPlot->loadDataAndUpdate(); + + m_targetPlot->updatePlotTitle(); m_targetPlot->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible) +void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve* curve, RimSummaryPlot* plot, bool forceVisible) { - RimSummaryCurve* curveCopy = dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + RimSummaryCurve* curveCopy = + dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); CVF_ASSERT(curveCopy); - if (forceVisible) + if (forceVisible) { curveCopy->setCurveVisiblity(true); } plot->addCurveNoUpdate(curveCopy); - // Resolve references after object has been inserted into the project data model - curveCopy->resolveReferencesRecursively(); + // The curve creator is not a descendant of the project, and need to be set manually + curveCopy->setSummaryCaseY(curve->summaryCaseY()); + curveCopy->initAfterReadRecursively(); + curveCopy->loadDataAndUpdate(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::copyEnsembleCurveAndAddToCurveSet(const RimSummaryCurve* curve, + RimEnsembleCurveSet* curveSet, + bool forceVisible) +{ + RimSummaryCurve* curveCopy = + dynamic_cast(curve->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + CVF_ASSERT(curveCopy); + + if (forceVisible) + { + curveCopy->setCurveVisiblity(true); + } + + curveSet->addCurve(curveCopy); // The curve creator is not a descendant of the project, and need to be set manually curveCopy->setSummaryCaseY(curve->summaryCaseY()); @@ -570,15 +703,15 @@ void RicSummaryCurveCreator::copyCurveAndAddToPlot(const RimSummaryCurve *curve, } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RicSummaryCurveCreator::setDefaultCurveSelection() +void RicSummaryCurveCreator::setDefaultCurveSelection(const std::vector& defaultCases) { - m_summaryCurveSelectionEditor->summaryAddressSelection()->setDefaultSelection(); + m_summaryCurveSelectionEditor->summaryAddressSelection()->setDefaultSelection(defaultCases); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::resetAllFields() { @@ -590,7 +723,7 @@ void RicSummaryCurveCreator::resetAllFields() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::initCurveAppearanceCalculator(RimSummaryCurveAppearanceCalculator& curveAppearanceCalc) { @@ -610,27 +743,23 @@ void RicSummaryCurveCreator::initCurveAppearanceCalculator(RimSummaryCurveAppear RimSummaryCurveAppearanceCalculator::CurveAppearanceType gropAppearance; RimSummaryCurveAppearanceCalculator::CurveAppearanceType regiAppearance; - curveAppearanceCalc.getDimensions(&caseAppearance, - &variAppearance, - &wellAppearance, - &gropAppearance, - ®iAppearance); + curveAppearanceCalc.getDimensions(&caseAppearance, &variAppearance, &wellAppearance, &gropAppearance, ®iAppearance); - m_caseAppearanceType = caseAppearance; + m_caseAppearanceType = caseAppearance; m_variableAppearanceType = variAppearance; - m_wellAppearanceType = wellAppearance; - m_groupAppearanceType = gropAppearance; - m_regionAppearanceType = regiAppearance; + m_wellAppearanceType = wellAppearance; + m_groupAppearanceType = gropAppearance; + m_regionAppearanceType = regiAppearance; } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::applyAppearanceToAllPreviewCurves() { std::set allCurveDefs = allPreviewCurveDefs(); - + RimSummaryCurveAppearanceCalculator curveLookCalc(allCurveDefs, getAllSummaryCaseNames(), getAllSummaryWellNames()); initCurveAppearanceCalculator(curveLookCalc); @@ -642,7 +771,7 @@ void RicSummaryCurveCreator::applyAppearanceToAllPreviewCurves() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateAppearanceEditor() { @@ -653,13 +782,13 @@ void RicSummaryCurveCreator::updateAppearanceEditor() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RicSummaryCurveCreator::allPreviewCurveDefs() const { std::set allCurveDefs; - for (const auto& curve : m_previewPlot->summaryCurves()) + for (const auto& curve : m_previewPlot->summaryAndEnsembleCurves()) { allCurveDefs.insert(RiaSummaryCurveDefinition(curve->summaryCaseY(), curve->summaryAddressY())); } @@ -667,7 +796,7 @@ std::set RicSummaryCurveCreator::allPreviewCurveDefs( } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::createNewPlot() { @@ -686,17 +815,17 @@ void RicSummaryCurveCreator::createNewPlot() QString candidatePlotName; if (m_previewPlot) { - candidatePlotName = m_previewPlot->generatedPlotTitleFromVisibleCurves(); + candidatePlotName = m_previewPlot->generatedPlotTitleFromAllCurves(); } - { - bool ok = false; - candidatePlotName = QInputDialog::getText(NULL, - "New Summary Plot Name", "New Summary Plot Name", + bool ok = false; + candidatePlotName = QInputDialog::getText(nullptr, + "New Summary Plot Name", + "New Summary Plot Name", QLineEdit::Normal, - candidatePlotName, - &ok, + candidatePlotName, + &ok, RiuTools::defaultDialogFlags()); if (!ok) { @@ -720,7 +849,7 @@ void RicSummaryCurveCreator::createNewPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::updateCurveNames() { @@ -730,19 +859,19 @@ void RicSummaryCurveCreator::updateCurveNames() curve->updateCurveNameNoLegendUpdate(); } - if (m_previewPlot && m_previewPlot->qwtPlot()) m_previewPlot->qwtPlot()->updateLegend(); + if (m_previewPlot && m_previewPlot->qwtPlot()) m_previewPlot->qwtPlot()->updateLegend(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -bool RicSummaryCurveCreator::isObservedData(RimSummaryCase *sumCase) const +bool RicSummaryCurveCreator::isObservedData(RimSummaryCase* sumCase) const { return dynamic_cast(sumCase) != nullptr; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryCase* RicSummaryCurveCreator::calculatedSummaryCase() { @@ -752,7 +881,7 @@ RimSummaryCase* RicSummaryCurveCreator::calculatedSummaryCase() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::selectionEditorFieldChanged() { @@ -760,7 +889,7 @@ void RicSummaryCurveCreator::selectionEditorFieldChanged() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreator::proxyEnablePlotAutoTitle(const bool& enable) { @@ -771,9 +900,55 @@ void RicSummaryCurveCreator::proxyEnablePlotAutoTitle(const bool& enable) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicSummaryCurveCreator::proxyPlotAutoTitle() const { return m_previewPlot->autoPlotTitle(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreator::setInitialCurveVisibility(const RimSummaryPlot* targetPlot) +{ + // Set visibility for imported curves which were not checked in source plot + std::set> sourceCurveDefs; + for (const auto& curve : targetPlot->summaryCurves()) + { + sourceCurveDefs.insert(std::make_pair(curve->summaryCaseY(), curve->summaryAddressY())); + } + + for (const auto& curve : m_previewPlot->summaryCurves()) + { + auto curveDef = std::make_pair(curve->summaryCaseY(), curve->summaryAddressY()); + if (sourceCurveDefs.count(curveDef) == 0) + { + curve->setCurveVisiblity(false); + } + } + + std::set> sourceCurveSetDefs; + for (const auto& curveSet : targetPlot->ensembleCurveSetCollection()->curveSets()) + { + sourceCurveSetDefs.insert(std::make_pair(curveSet->summaryCaseCollection(), curveSet->summaryAddress())); + } + + for (const auto& curveSet : m_previewPlot->ensembleCurveSetCollection()->curveSets()) + { + auto curveDef = std::make_pair(curveSet->summaryCaseCollection(), curveSet->summaryAddress()); + if (sourceCurveSetDefs.count(curveDef) == 0) + { + curveSet->showCurves(false); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int ensembleCurveCount(const std::set& allCurveDefs) +{ + return std::count_if( + allCurveDefs.begin(), allCurveDefs.end(), [](const RiaSummaryCurveDefinition& def) { return def.isEnsembleCurve(); }); +} diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h index 1ca75b9d64..ff11e78fa5 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreator.h @@ -34,13 +34,13 @@ #include - #define OBSERVED_DATA_AVALUE_POSTFIX "_OBSDATA" class RimSummaryCase; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; +class RimEnsembleCurveSet; //================================================================================================== /// @@ -50,6 +50,9 @@ class RicSummaryCurveCreator : public caf::PdmObject { CAF_PDM_HEADER_INIT; +public: + static const QString CONFIGURATION_NAME; + private: typedef caf::AppEnum AppearanceTypeAppEnum; @@ -58,7 +61,8 @@ class RicSummaryCurveCreator : public caf::PdmObject virtual ~RicSummaryCurveCreator(); RimSummaryPlot* previewPlot() const; - void updateFromSummaryPlot(RimSummaryPlot* targetPlot); + void updateFromSummaryPlot(RimSummaryPlot* targetPlot, + const std::vector& defaultCases = std::vector()); QWidget* addressSelectionWidget(QWidget* parent); @@ -85,7 +89,8 @@ class RicSummaryCurveCreator : public caf::PdmObject void populateCurveCreator(const RimSummaryPlot& sourceSummaryPlot); void updateTargetPlot(); static void copyCurveAndAddToPlot(const RimSummaryCurve *curve, RimSummaryPlot *plot, bool forceVisible = false); - void setDefaultCurveSelection(); + static void copyEnsembleCurveAndAddToCurveSet(const RimSummaryCurve *curve, RimEnsembleCurveSet* curveSet, bool forceVisible = false); + void setDefaultCurveSelection(const std::vector& defaultCases); void resetAllFields(); void initCurveAppearanceCalculator(RimSummaryCurveAppearanceCalculator& curveAppearanceCalc); @@ -100,7 +105,8 @@ class RicSummaryCurveCreator : public caf::PdmObject void proxyEnablePlotAutoTitle(const bool& enable); bool proxyPlotAutoTitle() const; - + void setInitialCurveVisibility(const RimSummaryPlot* targetPlot); + private: caf::PdmPtrField m_targetPlot; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp index 2a7c5daec5..4ccfd05e8f 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.cpp @@ -23,7 +23,7 @@ #include "RicSummaryCurveCreator.h" #include "RicSummaryCurveCreatorSplitterUi.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuTools.h" #include @@ -65,12 +65,21 @@ void RicSummaryCurveCreatorDialog::updateFromSummaryPlot(RimSummaryPlot* summary m_curveCreatorSplitterUi->updateUi(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreatorDialog::updateFromDefaultCases(const std::vector defaultCases) +{ + m_curveCreatorSplitterUi->updateFromDefaultCases(defaultCases); + m_curveCreatorSplitterUi->updateUi(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RicSummaryCurveCreatorDialog::slotDialogFinished() { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* plotwindow = RiaApplication::instance()->mainPlotWindow(); if (plotwindow) { plotwindow->cleanUpTemporaryWidgets(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h index 75097a328f..7ffb7194f0 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorDialog.h @@ -22,6 +22,7 @@ class RicSummaryCurveCreatorSplitterUi; class RimSummaryPlot; +class RimSummaryCase; //================================================================================================== /// @@ -35,6 +36,7 @@ class RicSummaryCurveCreatorDialog : public QDialog ~RicSummaryCurveCreatorDialog(); void updateFromSummaryPlot(RimSummaryPlot* summaryPlot); + void updateFromDefaultCases(const std::vector defaultCases); private slots: void slotDialogFinished(); diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp index a9974dd82b..2f63189fd9 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.cpp @@ -19,6 +19,7 @@ #include "RicSummaryCurveCreatorSplitterUi.h" #include "RicSummaryCurveCreator.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" @@ -66,6 +67,14 @@ void RicSummaryCurveCreatorSplitterUi::updateFromSummaryPlot(RimSummaryPlot* sum m_summaryCurveCreator->updateFromSummaryPlot(summaryPlot); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicSummaryCurveCreatorSplitterUi::updateFromDefaultCases(const std::vector defaultCases) +{ + m_summaryCurveCreator->updateFromSummaryPlot(nullptr, defaultCases); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -186,8 +195,11 @@ QWidget* RicSummaryCurveCreatorSplitterUi::getOrCreateCurveTreeWidget() if (m_summaryCurveCreator) { - RimSummaryCurveCollection* sumColl = m_summaryCurveCreator->previewPlot()->summaryCurveCollection(); - m_curveTreeView->setPdmItem(sumColl); + RimSummaryPlot* previewPlot = m_summaryCurveCreator->previewPlot(); + m_curveTreeView->setPdmItem(previewPlot); + m_curveTreeView->setUiConfigurationName(RicSummaryCurveCreator::CONFIGURATION_NAME); + m_curveTreeView->setExpanded(previewPlot->summaryCurveCollection(), true); + m_curveTreeView->setExpanded(previewPlot->ensembleCurveSetCollection(), true); } return m_curvesPanel; diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h index cca921ccbf..b7872fbbc2 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicSummaryCurveCreatorSplitterUi.h @@ -24,6 +24,7 @@ #include class RimSummaryPlot; +class RimSummaryCase; class RicSummaryCurveCreator; class QMinimizePanel; @@ -52,6 +53,7 @@ class RicSummaryCurveCreatorSplitterUi : public caf::PdmUiWidgetBasedObjectEdito ~RicSummaryCurveCreatorSplitterUi(); void updateFromSummaryPlot(RimSummaryPlot* summaryPlot); + void updateFromDefaultCases(const std::vector defaultCases); private: virtual void recursivelyConfigureAndUpdateTopLevelUiItems(const std::vector& topLevelUiItems, diff --git a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp index 72aa5f52f6..5ec633e894 100644 --- a/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp +++ b/ApplicationCode/Commands/SummaryPlotCommands/RicViewZoomAllFeature.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -20,28 +20,20 @@ #include "RiaApplication.h" -#include "RimSummaryPlot.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewWindow.h" -#include "RimWellAllocationPlot.h" -#include "RimWellLogPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuInterfaceToViewWindow.h" #include "RiuMainWindow.h" -#include "RiuSummaryQwtPlot.h" -#include "RiuWellAllocationPlot.h" -#include "RiuWellLogPlot.h" +#include "RiuPlotMainWindow.h" #include -#include #include -#include "RiuFlowCharacteristicsPlot.h" -#include "RimFlowCharacteristicsPlot.h" CAF_CMD_SOURCE_INIT(RicViewZoomAllFeature, "RicViewZoomAllFeature"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RicViewZoomAllFeature::isCommandEnabled() { @@ -49,7 +41,7 @@ bool RicViewZoomAllFeature::isCommandEnabled() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicViewZoomAllFeature::onActionTriggered(bool isChecked) { @@ -60,13 +52,16 @@ void RicViewZoomAllFeature::onActionTriggered(bool isChecked) if (dynamic_cast(topLevelWidget)) { RimViewWindow* viewWindow = RiaApplication::instance()->activeReservoirView(); - viewWindow->zoomAll(); + if (viewWindow) + { + viewWindow->zoomAll(); + } } - else if (dynamic_cast(topLevelWidget)) + else if (dynamic_cast(topLevelWidget)) { - RiuMainPlotWindow* mainPlotWindow = dynamic_cast(topLevelWidget); - QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); - if (subwindows.size() > 0) + RiuPlotMainWindow* mainPlotWindow = dynamic_cast(topLevelWidget); + QList subwindows = mainPlotWindow->subWindowList(QMdiArea::StackingOrder); + if (!subwindows.empty()) { RimViewWindow* viewWindow = RiuInterfaceToViewWindow::viewWindowFromWidget(subwindows.back()->widget()); @@ -79,11 +74,10 @@ void RicViewZoomAllFeature::onActionTriggered(bool isChecked) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RicViewZoomAllFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("Zoom All"); actionToSetup->setIcon(QIcon(":/ZoomAll16x16.png")); } - diff --git a/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake index 7827ec4f56..ce811d143d 100644 --- a/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ToggleCommands/CMakeLists_files.cmake @@ -1,23 +1,18 @@ -# 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}RicToggleItemsFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnFeature.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsOffFeature.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeature.h -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnOthersOffFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOffFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnOthersOffFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnFeature.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsOffFeature.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicToggleItemsOnOthersOffFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOffFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicToggleItemsOnOthersOffFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -28,4 +23,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\ToggleItems" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\ToggleItems" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp index adcaa5b475..5b5ec4b58e 100644 --- a/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp +++ b/ApplicationCode/Commands/ToggleCommands/RicToggleItemsFeatureImpl.cpp @@ -20,7 +20,7 @@ #include "RicToggleItemsFeatureImpl.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiaApplication.h" #include "cafPdmUiFieldHandle.h" @@ -161,7 +161,7 @@ caf::PdmUiTreeOrdering* RicToggleItemsFeatureImpl::findTreeItemFromSelectedUiIte QModelIndex modIndex = RiuMainWindow::instance()->projectTreeView()->findModelIndex(uiItem); if(!modIndex.isValid()) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if(mainPlotWindow) { modIndex = mainPlotWindow->projectTreeView()->findModelIndex(uiItem); diff --git a/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake b/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake index 38cdeccec9..f709a38efc 100644 --- a/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/ViewLink/CMakeLists_files.cmake @@ -1,29 +1,24 @@ -# 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}RicLinkVisibleViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.h -${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.h -${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.h -${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.h -${CEE_CURRENT_LIST_DIR}RicSetMasterViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeatureUi.h +${CMAKE_CURRENT_LIST_DIR}/RicShowAllLinkedViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicLinkViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicUnLinkViewFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicShowLinkOptionsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteAllLinkedViewsFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicSetMasterViewFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicLinkVisibleViewsFeatureUi.cpp -${CEE_CURRENT_LIST_DIR}RicShowAllLinkedViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicLinkViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicUnLinkViewFeature.cpp -${CEE_CURRENT_LIST_DIR}RicShowLinkOptionsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteAllLinkedViewsFeature.cpp -${CEE_CURRENT_LIST_DIR}RicSetMasterViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLinkVisibleViewsFeatureUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowAllLinkedViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicLinkViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicUnLinkViewFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicShowLinkOptionsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteAllLinkedViewsFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicSetMasterViewFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -34,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\ViewLink" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\ViewLink" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp index bd866b10a8..4da5f3ca79 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkViewFeature.cpp @@ -24,7 +24,7 @@ #include "RicLinkVisibleViewsFeature.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinkerCollection.h" #include "RimViewLinker.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicLinkViewFeature, "RicLinkViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicLinkViewFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimProject* proj = RiaApplication::instance()->project(); @@ -71,10 +71,10 @@ bool RicLinkViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkViewFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; - std::vector views; + std::vector views; views.push_back(activeView); RicLinkVisibleViewsFeature::linkViews(views); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp index 3a2cf3e5df..8081f13df7 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.cpp @@ -25,11 +25,11 @@ #include "RimViewController.h" #include "RimProject.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" @@ -46,17 +46,24 @@ CAF_CMD_SOURCE_INIT(RicLinkVisibleViewsFeature, "RicLinkVisibleViewsFeature"); bool RicLinkVisibleViewsFeature::isCommandEnabled() { RimProject* proj = RiaApplication::instance()->project(); - std::vector visibleViews; - std::vector linkedviews; + std::vector visibleViews; + std::vector linkedviews; + std::vector visibleGridViews; proj->allVisibleViews(visibleViews); + for (Rim3dView* view : visibleViews) + { + RimGridView* gridView = dynamic_cast(view); + if (gridView) visibleGridViews.push_back(gridView); + } + if (proj->viewLinkerCollection() && proj->viewLinkerCollection()->viewLinker()) { proj->viewLinkerCollection()->viewLinker()->allViews(linkedviews); } - if (visibleViews.size() >= 2 && (linkedviews.size() < visibleViews.size())) return true; + if (visibleGridViews.size() >= 2 && (linkedviews.size() < visibleGridViews.size())) return true; return false; } @@ -66,7 +73,7 @@ bool RicLinkVisibleViewsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicLinkVisibleViewsFeature::onActionTriggered(bool isChecked) { - std::vector views; + std::vector views; findNotLinkedVisibleViews(views); linkViews(views); @@ -85,7 +92,7 @@ void RicLinkVisibleViewsFeature::setupActionLook(QAction* actionToSetup) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) +void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) { RimProject* proj = RiaApplication::instance()->project(); if (proj->viewLinkerCollection()->viewLinker()) @@ -97,15 +104,15 @@ void RicLinkVisibleViewsFeature::allLinkedViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) +void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector &views) { RimProject* proj = RiaApplication::instance()->project(); - std::vector alreadyLinkedViews; + std::vector alreadyLinkedViews; allLinkedViews(alreadyLinkedViews); - std::vector visibleViews; - proj->allVisibleViews(visibleViews); + std::vector visibleViews; + proj->allVisibleGridViews(visibleViews); for (size_t i = 0; i < visibleViews.size(); i++) { @@ -128,7 +135,7 @@ void RicLinkVisibleViewsFeature::findNotLinkedVisibleViews(std::vector //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeature::linkViews(std::vector& views) +void RicLinkVisibleViewsFeature::linkViews(std::vector& views) { RimProject* proj = RiaApplication::instance()->project(); RimViewLinker* viewLinker = proj->viewLinkerCollection->viewLinker(); @@ -145,11 +152,11 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) RicLinkVisibleViewsFeatureUi featureUi; featureUi.setViews(views); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &featureUi, "Select Master View", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &featureUi, "Select Master View", ""); propertyDialog.setWindowIcon(QIcon(":/chain.png")); if (propertyDialog.exec() != QDialog::Accepted) return; - RimView* masterView = featureUi.masterView(); + RimGridView* masterView = featureUi.masterView(); viewLinker = new RimViewLinker; proj->viewLinkerCollection()->viewLinker = viewLinker; viewLinker->setMasterView(masterView); @@ -157,7 +164,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) for (size_t i = 0; i < views.size(); i++) { - RimView* rimView = views[i]; + RimGridView* rimView = views[i]; if (rimView == viewLinker->masterView()) continue; viewLinker->addDependentView(rimView); @@ -170,7 +177,7 @@ void RicLinkVisibleViewsFeature::linkViews(std::vector& views) proj->viewLinkerCollection.uiCapability()->updateConnectedEditors(); proj->updateConnectedEditors(); - RiuMainWindow::instance()->setExpanded(proj->viewLinkerCollection()); + Riu3DMainWindowTools::setExpanded(proj->viewLinkerCollection()); } diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h index 07a1a954ff..255e86b837 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeature.h @@ -23,7 +23,7 @@ #include -class RimView; +class RimGridView; //================================================================================================== /// @@ -33,7 +33,7 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature CAF_CMD_HEADER_INIT; public: - static void linkViews(std::vector &views); + static void linkViews(std::vector &views); protected: // Overrides @@ -44,6 +44,6 @@ class RicLinkVisibleViewsFeature : public caf::CmdFeature virtual void setupActionLook(QAction* actionToSetup); private: - void findNotLinkedVisibleViews(std::vector &views); - void allLinkedViews(std::vector& views); + void findNotLinkedVisibleViews(std::vector &views); + void allLinkedViews(std::vector& views); }; diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp index 048e55811f..1862ec6021 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimCase.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewLinker.h" CAF_PDM_SOURCE_INIT(RicLinkVisibleViewsFeatureUi, "RicLinkVisibleViewsFeatureUi"); @@ -40,11 +40,11 @@ RicLinkVisibleViewsFeatureUi::RicLinkVisibleViewsFeatureUi(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allViews) +void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allViews) { m_allViews = allViews; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); // Set Active view as master view for (size_t i = 0; i < allViews.size(); i++) @@ -65,7 +65,7 @@ void RicLinkVisibleViewsFeatureUi::setViews(const std::vector& allView //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RicLinkVisibleViewsFeatureUi::masterView() +RimGridView* RicLinkVisibleViewsFeatureUi::masterView() { return m_masterView; } @@ -73,13 +73,14 @@ RimView* RicLinkVisibleViewsFeatureUi::masterView() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RicLinkVisibleViewsFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RicLinkVisibleViewsFeatureUi::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool * useOptionsOnly) { QList options; if (fieldNeedingOptions == &m_masterView) { - for (RimView* v : m_allViews) + for (RimGridView* v : m_allViews) { RimCase* rimCase = nullptr; v->firstAncestorOrThisOfType(rimCase); diff --git a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h index e7b84a20aa..5ba94f305f 100644 --- a/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h +++ b/ApplicationCode/Commands/ViewLink/RicLinkVisibleViewsFeatureUi.h @@ -25,7 +25,7 @@ #include -class RimView; +class RimGridView; //================================================================================================== /// @@ -37,14 +37,15 @@ class RicLinkVisibleViewsFeatureUi : public caf::PdmObject public: RicLinkVisibleViewsFeatureUi(void); - void setViews(const std::vector& allViews); - RimView* masterView(); + void setViews(const std::vector& allViews); + RimGridView* masterView(); protected: - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool * useOptionsOnly); private: - caf::PdmPtrField m_masterView; + caf::PdmPtrField m_masterView; - std::vector m_allViews; + std::vector m_allViews; }; diff --git a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp index 50814a3d45..1bed9c55c6 100644 --- a/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicSetMasterViewFeature.cpp @@ -22,12 +22,12 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicSetMasterViewFeature, "RicSetMasterViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicSetMasterViewFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return false; RimProject* proj = RiaApplication::instance()->project(); @@ -62,7 +62,7 @@ bool RicSetMasterViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicSetMasterViewFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); if (!activeView) return; RimProject* proj = RiaApplication::instance()->project(); @@ -70,7 +70,7 @@ void RicSetMasterViewFeature::onActionTriggered(bool isChecked) viewLinker->applyRangeFilterCollectionByUserChoice(); - RimView* previousMasterView = viewLinker->masterView(); + RimGridView* previousMasterView = viewLinker->masterView(); viewLinker->setMasterView(activeView); viewLinker->updateDependentViews(); @@ -81,8 +81,8 @@ void RicSetMasterViewFeature::onActionTriggered(bool isChecked) proj->updateConnectedEditors(); // Set managed view collection to selected and expanded in project tree - RiuMainWindow::instance()->selectAsCurrentItem(viewLinker); - RiuMainWindow::instance()->setExpanded(viewLinker); + Riu3DMainWindowTools::selectAsCurrentItem(viewLinker); + Riu3DMainWindowTools::setExpanded(viewLinker); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp index cfd8678b77..4d13a95255 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowAllLinkedViewsFeature.cpp @@ -20,7 +20,7 @@ #include "RicShowAllLinkedViewsFeature.h" #include "RimViewController.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewLinker.h" #include "cafSelectionManager.h" @@ -49,7 +49,7 @@ void RicShowAllLinkedViewsFeature::onActionTriggered(bool isChecked) caf::SelectionManager::instance()->objectsByType(&managedViews); for (size_t i = 0; i < managedViews.size(); i++) { - RimViewLinker* rimLinked = NULL; + RimViewLinker* rimLinked = nullptr; managedViews[i]->firstAncestorOrThisOfType(rimLinked); CVF_ASSERT(rimLinked); @@ -58,7 +58,7 @@ void RicShowAllLinkedViewsFeature::onActionTriggered(bool isChecked) for (size_t i = 0; i < linkedViews.size(); i++) { - std::vector views; + std::vector views; linkedViews[i]->allViews(views); for (size_t j = 0; j < views.size(); j++) diff --git a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp index 0c958d247c..eea54abb91 100644 --- a/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicShowLinkOptionsFeature.cpp @@ -21,10 +21,10 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafSelectionManager.h" @@ -38,7 +38,7 @@ CAF_CMD_SOURCE_INIT(RicShowLinkOptionsFeature, "RicShowLinkOptionsFeature"); //-------------------------------------------------------------------------------------------------- bool RicShowLinkOptionsFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimViewController* viewController = activeView->viewController(); @@ -56,12 +56,12 @@ bool RicShowLinkOptionsFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicShowLinkOptionsFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RimViewController* viewController = activeView->viewController(); - RiuMainWindow::instance()->selectAsCurrentItem(viewController); + Riu3DMainWindowTools::selectAsCurrentItem(viewController); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp index c56ba64971..38d46eba72 100644 --- a/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp +++ b/ApplicationCode/Commands/ViewLink/RicUnLinkViewFeature.cpp @@ -22,7 +22,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -39,7 +39,7 @@ CAF_CMD_SOURCE_INIT(RicUnLinkViewFeature, "RicUnLinkViewFeature"); //-------------------------------------------------------------------------------------------------- bool RicUnLinkViewFeature::isCommandEnabled() { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return false; RimViewController* viewController = activeView->viewController(); @@ -58,7 +58,7 @@ bool RicUnLinkViewFeature::isCommandEnabled() //-------------------------------------------------------------------------------------------------- void RicUnLinkViewFeature::onActionTriggered(bool isChecked) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (!activeView) return; RimViewController* viewController = activeView->viewController(); diff --git a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake index 05eb69c4d6..2d98f85c33 100644 --- a/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellLogCommands/CMakeLists_files.cmake @@ -1,59 +1,64 @@ -# 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}RicAddWellLogToPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogCurveExtractionFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogRftCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicNewRftPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteRftPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewPltPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicDeletePltPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogFileCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTrackFeature.h -${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.h -${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.h -${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.h -${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.h -${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.h -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.h -${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.h -${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.h -${CEE_CURRENT_LIST_DIR}RicMoveWellLogFilesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAddWellLogToPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogCurveExtractionFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogRftCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewRftPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteRftPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewPltPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeletePltPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogFileCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotTrackFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotCurveFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellLogPlotTrackFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotTrackFeatureImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogTrackFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.h +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.h +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.h +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveViewerEventHandler.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicAddWellLogToPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogCurveExtractionFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogRftCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewRftPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteRftPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewPltPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeletePltPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogFileCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicNewWellLogPlotTrackFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogPlotCurveFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogsImportFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicDeleteWellLogPlotTrackFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogPlotTrackFeatureImpl.cpp -${CEE_CURRENT_LIST_DIR}RicPasteWellLogCurveFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteWellLogTrackFeature.cpp -${CEE_CURRENT_LIST_DIR}RicPasteWellLogPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeature.cpp -${CEE_CURRENT_LIST_DIR}RicChangeDataSourceFeatureUi.cpp -${CEE_CURRENT_LIST_DIR}RicAsciiExportWellLogPlotFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellLogFileCloseFeature.cpp -${CEE_CURRENT_LIST_DIR}RicMoveWellLogFilesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAddWellLogToPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogCurveExtractionFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogRftCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewRftPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteRftPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewPltPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeletePltPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogFileCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicNewWellLogPlotTrackFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotCurveFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogsImportFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicDeleteWellLogPlotTrackFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogPlotTrackFeatureImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogTrackFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicPasteWellLogPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicChangeDataSourceFeatureUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAsciiExportWellLogPlotFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellLogFileCloseFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicMoveWellLogFilesFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogFileCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicAdd3dWellLogRftCurveFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveDeleteFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/Ric3dWellLogCurveViewerEventHandler.cpp ) list(APPEND CODE_HEADER_FILES @@ -64,4 +69,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\WellLog" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\WellLog" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp new file mode 100644 index 0000000000..866aceb212 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.cpp @@ -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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Ric3dWellLogCurveDeleteFeature.h" + +#include "RiaApplication.h" + +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" +#include "RimProject.h" + +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT(Ric3dWellLogCurveDeleteFeature, "Ric3dWellLogCurveDeleteFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Ric3dWellLogCurveDeleteFeature::isCommandEnabled() +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() > 0) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Ric3dWellLogCurveDeleteFeature::onActionTriggered(bool isChecked) +{ + std::vector objects; + caf::SelectionManager::instance()->objectsByType(&objects); + + if (objects.size() == 0) return; + + Rim3dWellLogCurve* firstCurve = objects[0]; + + Rim3dWellLogCurveCollection* curveCollection = nullptr; + firstCurve->firstAncestorOrThisOfType(curveCollection); + if (!curveCollection) return; + + for (Rim3dWellLogCurve* curve : objects) + { + curveCollection->remove3dWellLogCurve(curve); + delete curve; + } + curveCollection->redrawAffectedViewsAndEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Ric3dWellLogCurveDeleteFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setText("Delete 3D Well Log Curve(s)"); + actionToSetup->setIcon(QIcon(":/Erase.png")); +} diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h new file mode 100644 index 0000000000..6dc5bb9cec --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveDeleteFeature.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class Ric3dWellLogCurveDeleteFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + virtual bool isCommandEnabled() override; + virtual void onActionTriggered(bool isChecked) override; + virtual void setupActionLook(QAction* actionToSetup) override; +}; diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp new file mode 100644 index 0000000000..a9434787a6 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.cpp @@ -0,0 +1,85 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Ric3dWellLogCurveViewerEventHandler.h" + +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" +#include "RimWellPath.h" +#include "RiuMainWindow.h" +#include "RivObjectSourceInfo.h" + +#include "cvfPart.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Ric3dWellLogCurveViewerEventHandler* Ric3dWellLogCurveViewerEventHandler::instance() +{ + static Ric3dWellLogCurveViewerEventHandler* singleton = new Ric3dWellLogCurveViewerEventHandler; + return singleton; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Ric3dWellLogCurveViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject) +{ + if (eventObject.m_partAndTriangleIndexPairs.empty()) return false; + + cvf::uint triangleIndex = cvf::UNDEFINED_UINT; + + const auto& partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front(); + const cvf::Part* part = partAndTriangleIndexPair.first; + + const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); + if (sourceInfo) + { + Rim3dWellLogCurveCollection* curveCollection = dynamic_cast(sourceInfo->object()); + if (curveCollection) + { + RimWellPath* wellPath; + curveCollection->firstAncestorOrThisOfTypeAsserted(wellPath); + QString wellPathName = wellPath->name(); + cvf::Vec3d closestPoint; + double measuredDepthAtPoint; + double valueAtPoint; + Rim3dWellLogCurve* curve = curveCollection->checkForCurveIntersection( + eventObject.m_globalIntersectionPoint, &closestPoint, &measuredDepthAtPoint, &valueAtPoint); + if (curve) + { + RiuMainWindow::instance()->selectAsCurrentItem(curve); + + QString curveText; + curveText += QString("Curve name : %1\n").arg(curve->name());; + curveText += QString("Well path name: %1\n").arg(wellPathName); + curveText += QString("Measured depth: %1\n").arg(measuredDepthAtPoint); + curveText += QString("%1 at depth: %2\n").arg(curve->resultPropertyString()).arg(valueAtPoint); + + RiuMainWindow::instance()->setResultInfo(curveText); + } + else + { + RiuMainWindow::instance()->selectAsCurrentItem(curveCollection); + } + return true; + } + } + return false; +} diff --git a/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h new file mode 100644 index 0000000000..8299a191d7 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RicViewerEventInterface.h" + +//================================================================================================== +/// +//================================================================================================== +class Ric3dWellLogCurveViewerEventHandler : public RicViewerEventInterface +{ +public: + static Ric3dWellLogCurveViewerEventHandler* instance(); + + bool handleEvent(const RicViewerEventObject& eventObject) override; +}; diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp new file mode 100644 index 0000000000..af045fc8c4 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.cpp @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAdd3dWellLogCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicWellLogTools.h" + +#include "Rim3dWellLogExtractionCurve.h" +#include "RimCase.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAdd3dWellLogCurveFeature, "RicAdd3dWellLogCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAdd3dWellLogCurveFeature::isCommandEnabled() +{ + std::vector cases; + RiaApplication::instance()->project()->allCases(cases); + if (cases.empty()) return false; + + return RicWellLogTools::findWellPathFromSelection() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogCurveFeature::onActionTriggered(bool isChecked) +{ + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathFromSelection(); + if (!selectedWellPath) return; + + Rim3dWellLogExtractionCurve* rim3dWellLogExtractionCurve = new Rim3dWellLogExtractionCurve(); + + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + if (view) + { + rim3dWellLogExtractionCurve->setPropertiesFromView(view); + } + + selectedWellPath->add3dWellLogCurve(rim3dWellLogExtractionCurve); + + RiaApplication::instance()->project()->createDisplayModelAndRedrawAllViews(); + + RiaApplication::instance()->project()->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogExtractionCurve); + Riu3DMainWindowTools::setExpanded(selectedWellPath); + + selectedWellPath->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); + actionToSetup->setText("Add 3D Well Log Curve"); +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.h new file mode 100644 index 0000000000..ddc5cc4f4b --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogCurveFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicAdd3dWellLogCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp new file mode 100644 index 0000000000..00b1e8d1e9 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.cpp @@ -0,0 +1,76 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAdd3dWellLogFileCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicWellLogTools.h" + +#include "Rim3dWellLogFileCurve.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAdd3dWellLogFileCurveFeature, "RicAdd3dWellLogFileCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAdd3dWellLogFileCurveFeature::isCommandEnabled() +{ + std::vector cases; + RiaApplication::instance()->project()->allCases(cases); + if (cases.empty()) return false; + + return (RicWellLogTools::findWellPathWithLogFileFromSelection() != nullptr); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogFileCurveFeature::onActionTriggered(bool isChecked) +{ + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathWithLogFileFromSelection(); + if (!selectedWellPath) return; + + Rim3dWellLogFileCurve* rim3dWellLogFileCurve = new Rim3dWellLogFileCurve(); + selectedWellPath->add3dWellLogCurve(rim3dWellLogFileCurve); + + rim3dWellLogFileCurve->setDefaultFileCurveDataInfo(); + + RiaApplication::instance()->project()->createDisplayModelAndRedrawAllViews(); + RiaApplication::instance()->project()->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogFileCurve); + Riu3DMainWindowTools::setExpanded(selectedWellPath); + + selectedWellPath->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogFileCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); + actionToSetup->setText("Add 3D Well Log LAS Curve"); +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h new file mode 100644 index 0000000000..7251912f61 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogFileCurveFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicAdd3dWellLogFileCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp new file mode 100644 index 0000000000..a715d82fe7 --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RicAdd3dWellLogRftCurveFeature.h" + +#include "RiaApplication.h" + +#include "RicWellLogTools.h" + +#include "Rim3dWellLogRftCurve.h" +#include "RimProject.h" +#include "RimWellPath.h" + +#include "Riu3DMainWindowTools.h" + +#include + +CAF_CMD_SOURCE_INIT(RicAdd3dWellLogRftCurveFeature, "RicAdd3dWellLogRftCurveFeature"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicAdd3dWellLogRftCurveFeature::isCommandEnabled() +{ + std::vector cases; + RiaApplication::instance()->project()->allCases(cases); + if (cases.empty()) return false; + + RimWellPath* wellPath = RicWellLogTools::findWellPathFromSelection(); + if (wellPath) + { + return RicWellLogTools::wellHasRftData(wellPath->name()); + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogRftCurveFeature::onActionTriggered(bool isChecked) +{ + RimWellPath* selectedWellPath = RicWellLogTools::findWellPathFromSelection(); + if (!selectedWellPath) return; + + Rim3dWellLogRftCurve* rim3dWellLogRftCurve = new Rim3dWellLogRftCurve(); + selectedWellPath->add3dWellLogCurve(rim3dWellLogRftCurve); + + RiaApplication::instance()->project()->createDisplayModelAndRedrawAllViews(); + RiaApplication::instance()->project()->updateConnectedEditors(); + + Riu3DMainWindowTools::selectAsCurrentItem(rim3dWellLogRftCurve); + Riu3DMainWindowTools::setExpanded(selectedWellPath); + + selectedWellPath->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicAdd3dWellLogRftCurveFeature::setupActionLook(QAction* actionToSetup) +{ + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); + actionToSetup->setText("Add 3D Well Log RFT Curve"); +} diff --git a/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h new file mode 100644 index 0000000000..a953f315fc --- /dev/null +++ b/ApplicationCode/Commands/WellLogCommands/RicAdd3dWellLogRftCurveFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafCmdFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicAdd3dWellLogRftCurveFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + virtual bool isCommandEnabled() override; + virtual void onActionTriggered( bool isChecked ) override; + virtual void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp index 77bfe87e31..6523e0ea54 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicAddWellLogToPlotFeature.cpp @@ -32,7 +32,7 @@ #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RigWellLogFile.h" @@ -75,10 +75,10 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) { RimWellLogFileChannel* wellLog = selection[wlIdx]; - RimWellPath* wellPath = NULL; + RimWellPath* wellPath = nullptr; wellLog->firstAncestorOrThisOfType(wellPath); - RimWellLogFile* wellLogFile = NULL; + RimWellLogFile* wellLogFile = nullptr; wellLog->firstAncestorOrThisOfType(wellLogFile); if (wellLogFile) { @@ -109,8 +109,10 @@ void RicAddWellLogToPlotFeature::onActionTriggered(bool isChecked) plotTrack->viewer()->replot(); RiaApplication::instance()->project()->updateConnectedEditors(); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(plot); - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->setExpanded(plotTrack); + + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(plot); + RiuPlotMainWindowTools::setExpanded(plotTrack); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp index abb87fbefa..e83a591ea1 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicDeleteWellLogPlotTrackFeature.cpp @@ -43,7 +43,7 @@ bool RicDeleteWellLogPlotTrackFeature::isCommandEnabled() if (selection.size() > 0) { - RimWellLogPlot* wellLogPlot = NULL; + RimWellLogPlot* wellLogPlot = nullptr; selection[0]->firstAncestorOrThisOfType(wellLogPlot); if (wellLogPlot && wellLogPlot->trackCount() > 1) { @@ -68,7 +68,7 @@ void RicDeleteWellLogPlotTrackFeature::onActionTriggered(bool isChecked) { RimWellLogTrack* track = selection[i]; - RimWellLogPlot* wellLogPlot = NULL; + RimWellLogPlot* wellLogPlot = nullptr; track->firstAncestorOrThisOfType(wellLogPlot); if (wellLogPlot && wellLogPlot->trackCount() > 1) { diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp index 88224e2017..2e87c701c3 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.cpp @@ -28,7 +28,7 @@ #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogExtractionCurve.h" #include "RimWellPltPlot.h" #include "RimWellLogPlot.h" @@ -38,7 +38,7 @@ #include "RimMainPlotCollection.h" #include "RimEclipseResultCase.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSelectionManager.h" #include "cafSelectionManagerTools.h" @@ -123,12 +123,9 @@ void RicNewPltPlotFeature::onActionTriggered(bool isChecked) pltPlot->loadDataAndUpdate(); pltPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->setExpanded(plotTrack); - mainPlotWindow->selectAsCurrentItem(pltPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::setExpanded(plotTrack); + RiuPlotMainWindowTools::selectAsCurrentItem(pltPlot); } } @@ -138,7 +135,7 @@ void RicNewPltPlotFeature::onActionTriggered(bool isChecked) void RicNewPltPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New PLT Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/WellFlowPlot16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h index 140e7d5b78..28137d38a9 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewPltPlotFeature.h @@ -22,7 +22,7 @@ #include "cafCmdFeature.h" class RimSimWellInView; -class RimView; +class Rim3dView; class RimWellLogExtractionCurve; class RimWellLogTrack; class RimWellPath; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp index 11471315d5..4d0b01efe4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewRftPlotFeature.cpp @@ -29,7 +29,7 @@ #include "RimWellPath.h" #include "RimWellRftPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "cafSelectionManagerTools.h" @@ -84,12 +84,9 @@ void RicNewRftPlotFeature::onActionTriggered(bool isChecked) rftPlot->loadDataAndUpdate(); rftPlotColl->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->setExpanded(plotTrack); - mainPlotWindow->selectAsCurrentItem(rftPlot); - } + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::setExpanded(plotTrack); + RiuPlotMainWindowTools::selectAsCurrentItem(rftPlot); } } @@ -99,7 +96,7 @@ void RicNewRftPlotFeature::onActionTriggered(bool isChecked) void RicNewRftPlotFeature::setupActionLook(QAction* actionToSetup) { actionToSetup->setText("New RFT Plot"); - actionToSetup->setIcon(QIcon(":/SummaryPlot16x16.png")); + actionToSetup->setIcon(QIcon(":/FlowCharPlot16x16.png")); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp index df328acf3e..c75fe4711a 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogCurveExtractionFeature.cpp @@ -27,16 +27,17 @@ #include "RigWellLogCurveData.h" +#include "Rim3dView.h" #include "RimProject.h" #include "RimSimWellInView.h" -#include "RimView.h" +#include "RimSimWellInViewCollection.h" #include "RimWellLogExtractionCurve.h" #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSelectionManager.h" #include "cafSelectionManager.h" @@ -44,7 +45,6 @@ #include #include -#include "RimSimWellInViewCollection.h" CAF_CMD_SOURCE_INIT(RicNewWellLogCurveExtractionFeature, "RicNewWellLogCurveExtractionFeature"); @@ -125,5 +125,5 @@ bool RicNewWellLogCurveExtractionFeature::caseAvailable() std::vector cases; RiaApplication::instance()->project()->allCases(cases); - return cases.size() > 0; + return !cases.empty(); } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp index 344fd5632e..5aa90c4cd7 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.cpp @@ -32,7 +32,7 @@ #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicWellLogTools.h" @@ -87,13 +87,14 @@ void RicNewWellLogFileCurveFeature::onActionTriggered(bool isChecked) //-------------------------------------------------------------------------------------------------- void RicNewWellLogFileCurveFeature::setupActionLook(QAction* actionToSetup) { + actionToSetup->setIcon(QIcon(":/WellLogCurve16x16.png")); actionToSetup->setText("New Well Log LAS Curve"); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() const +bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() { RimProject* project = RiaApplication::instance()->project(); if (project->activeOilField()->wellPathCollection()) @@ -102,7 +103,7 @@ bool RicNewWellLogFileCurveFeature::wellLogFilesAvailable() const for (size_t i = 0; i < wellPaths.size(); i++) { - if (wellPaths[i]->wellLogFiles().size() > 0) + if (!wellPaths[i]->wellLogFiles().empty()) { return true; } diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h index d4ae4353a2..0a686babe4 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogFileCurveFeature.h @@ -36,5 +36,5 @@ class RicNewWellLogFileCurveFeature : public caf::CmdFeature virtual void setupActionLook( QAction* actionToSetup ) override; private: - bool wellLogFilesAvailable() const; + static bool wellLogFilesAvailable(); }; diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp index eb2b9f4e87..f8f94e7002 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogPlotTrackFeature.cpp @@ -44,7 +44,7 @@ bool RicNewWellLogPlotTrackFeature::isCommandEnabled() return false; } - return selectedWellLogPlot() != NULL; + return selectedWellLogPlot() != nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp index 16fa64deca..de127dd677 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicNewWellLogRftCurveFeature.cpp @@ -28,7 +28,7 @@ #include "RigWellLogCurveData.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RicNewWellLogPlotFeatureImpl.h" #include "RicWellLogPlotCurveFeatureImpl.h" diff --git a/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp b/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp index ff170dfbf2..ba56dc6fc6 100644 --- a/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellLogCommands/RicWellLogsImportFileFeature.cpp @@ -21,7 +21,7 @@ #include "RiaApplication.h" #include "RimProject.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiObjectEditorHandle.h" @@ -46,7 +46,7 @@ void RicWellLogsImportFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELL_LOGS_DIR"); - QStringList wellLogFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Logs", defaultDir, "Well Logs (*.las);;All Files (*.*)"); + QStringList wellLogFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Logs", defaultDir, "Well Logs (*.las);;All Files (*.*)"); if (wellLogFilePaths.size() < 1) return; diff --git a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake index d5bbb20c97..67a87c1d8c 100644 --- a/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake +++ b/ApplicationCode/Commands/WellPathCommands/CMakeLists_files.cmake @@ -1,29 +1,24 @@ -# 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}RicWellPathDeleteFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.h -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.h -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.h -${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.h -${CEE_CURRENT_LIST_DIR}RicIntersectionViewerEventHandler.h -${CEE_CURRENT_LIST_DIR}RicWellPathFormationsImportFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathDeleteFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportFileFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathViewerEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionViewerEventHandler.h +${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RicWellPathDeleteFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsImportFileFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsImportSsihubFeature.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsImpl.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathsUnitSystemSettingsUi.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathViewerEventHandler.cpp -${CEE_CURRENT_LIST_DIR}RicIntersectionViewerEventHandler.cpp -${CEE_CURRENT_LIST_DIR}RicWellPathFormationsImportFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathDeleteFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportFileFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsImportSsihubFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsImpl.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathsUnitSystemSettingsUi.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathViewerEventHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RicIntersectionViewerEventHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RicWellPathFormationsImportFileFeature.cpp ) list(APPEND CODE_HEADER_FILES @@ -34,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "CommandFeature\\WellPath" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "CommandFeature\\WellPath" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp index f7554d6e62..4c75202084 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.cpp @@ -18,7 +18,7 @@ #include "RicIntersectionViewerEventHandler.h" #include "RimIntersection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafDisplayCoordTransform.h" #include "cafSelectionManager.h" @@ -37,24 +37,22 @@ RicIntersectionViewerEventHandler* RicIntersectionViewerEventHandler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicIntersectionViewerEventHandler::handleEvent(cvf::Object* eventObject) +bool RicIntersectionViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject) { std::vector selection; caf::SelectionManager::instance()->objectsByType(&selection); if (selection.size() == 1) { - RicViewerEventObject* polylineUiEvent = dynamic_cast(eventObject); - if (polylineUiEvent) { RimIntersection* intersection = selection[0]; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; intersection->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); cvf::ref transForm = rimView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->transformToDomainCoord(polylineUiEvent->globalIntersectionPoint); + cvf::Vec3d domainCoord = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); if (intersection->inputPolyLineFromViewerEnabled()) { diff --git a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h index 6d7d3d0880..721d61b169 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h +++ b/ApplicationCode/Commands/WellPathCommands/RicIntersectionViewerEventHandler.h @@ -29,6 +29,6 @@ class RicIntersectionViewerEventHandler : public RicViewerEventInterface static RicIntersectionViewerEventHandler* instance(); protected: - virtual bool handleEvent(cvf::Object* eventObject) override; + virtual bool handleEvent(const RicViewerEventObject& eventObject) override; }; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp index 43bf2004ed..68225e2276 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathFormationsImportFileFeature.cpp @@ -26,7 +26,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -50,7 +50,7 @@ void RicWellPathFormationsImportFileFeature::onActionTriggered(bool isChecked) RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATHFORMATIONS_DIR"); QStringList wellPathFormationsFilePaths = - QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Picks", defaultDir, + QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Picks", defaultDir, "Well Picks (*.csv);;All Files (*.*)"); if (wellPathFormationsFilePaths.size() < 1) @@ -80,7 +80,7 @@ void RicWellPathFormationsImportFileFeature::onActionTriggered(bool isChecked) RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath(); if (wellPath) { - RiuMainWindow::instance()->selectAsCurrentItem(wellPath); + Riu3DMainWindowTools::selectAsCurrentItem(wellPath); } } } diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp index dd3b3adbe3..a1646279af 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.cpp @@ -21,17 +21,21 @@ #include "RiaApplication.h" -#include "RimView.h" +#include "Rim3dView.h" +#include "RimPerforationInterval.h" #include "RimWellPath.h" +#include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" +#include "RivObjectSourceInfo.h" #include "RivWellPathSourceInfo.h" #include "cafDisplayCoordTransform.h" #include "cvfPart.h" #include "cvfVector3.h" +#include "RivIntersectionPartMgr.h" //-------------------------------------------------------------------------------------------------- @@ -46,43 +50,96 @@ RicWellPathViewerEventHandler* RicWellPathViewerEventHandler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RicWellPathViewerEventHandler::handleEvent(cvf::Object* eventObject) +bool RicWellPathViewerEventHandler::handleEvent(const RicViewerEventObject& eventObject) { - RicViewerEventObject* uiEvent = dynamic_cast(eventObject); - if (!uiEvent) return false; + if (eventObject.m_partAndTriangleIndexPairs.empty()) return false; - if (uiEvent->firstHitPart && uiEvent->firstHitPart->sourceInfo()) + const caf::PdmObject* objectToSelect = nullptr; + + cvf::uint wellPathTriangleIndex = cvf::UNDEFINED_UINT; + const RivWellPathSourceInfo* wellPathSourceInfo = nullptr; + + if(!eventObject.m_partAndTriangleIndexPairs.empty()) { - const RivWellPathSourceInfo* wellPathSourceInfo = dynamic_cast(uiEvent->firstHitPart->sourceInfo()); - if (wellPathSourceInfo) + const auto & partAndTriangleIndexPair = eventObject.m_partAndTriangleIndexPairs.front(); + const cvf::Part* part = partAndTriangleIndexPair.first; + + const RivObjectSourceInfo* sourceInfo = dynamic_cast(part->sourceInfo()); + if (sourceInfo) { - RimView* rimView = RiaApplication::instance()->activeReservoirView(); - if (!rimView) return false; + if (dynamic_cast(sourceInfo->object())) + { + objectToSelect = sourceInfo->object(); + + if (eventObject.m_partAndTriangleIndexPairs.size() > 1) + { + const auto& secondPair = eventObject.m_partAndTriangleIndexPairs[1]; + const cvf::Part* secondPickedPart = secondPair.first; + if (secondPickedPart) + { + auto wellPathSourceCandidate = dynamic_cast(secondPickedPart->sourceInfo()); + if (wellPathSourceCandidate) + { + RimWellPath* perforationWellPath = nullptr; + objectToSelect->firstAncestorOrThisOfType(perforationWellPath); + if (perforationWellPath == wellPathSourceCandidate->wellPath()) + { + wellPathSourceInfo = dynamic_cast(secondPickedPart->sourceInfo()); + wellPathTriangleIndex = secondPair.second; + } + } + } + } + } + } - cvf::ref transForm = rimView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->transformToDomainCoord(uiEvent->globalIntersectionPoint); + if (part && dynamic_cast(part->sourceInfo())) + { + wellPathSourceInfo = dynamic_cast(part->sourceInfo()); + wellPathTriangleIndex = partAndTriangleIndexPair.second; + } + } - double measuredDepth = wellPathSourceInfo->measuredDepth(uiEvent->firstPartTriangleIndex, domainCoord); + if (wellPathSourceInfo) + { + Rim3dView* rimView = RiaApplication::instance()->activeReservoirView(); + if (!rimView) return false; - // NOTE: This computation was used to find the location for a fracture when clicking on a well path - // It turned out that the computation was a bit inaccurate - // Consider to use code in RigSimulationWellCoordsAndMD instead - cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(uiEvent->firstPartTriangleIndex, domainCoord); + cvf::ref transForm = rimView->displayCoordTransform(); + cvf::Vec3d pickedPositionInUTM = transForm->transformToDomainCoord(eventObject.m_globalIntersectionPoint); - QString wellPathText; - wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name()); - wellPathText += QString("Measured depth : %1\n").arg(measuredDepth); + if (auto intersectionView = dynamic_cast(rimView)) + { + pickedPositionInUTM = intersectionView->transformToUtm(pickedPositionInUTM); + } - QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z()); - wellPathText += formattedText; + double measuredDepth = wellPathSourceInfo->measuredDepth(wellPathTriangleIndex, pickedPositionInUTM); - RiuMainWindow::instance()->setResultInfo(wellPathText); + // NOTE: This computation was used to find the location for a fracture when clicking on a well path + // It turned out that the computation was a bit inaccurate + // Consider to use code in RigSimulationWellCoordsAndMD instead + cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->closestPointOnCenterLine(wellPathTriangleIndex, pickedPositionInUTM); - RiuMainWindow::instance()->selectAsCurrentItem(wellPathSourceInfo->wellPath()); + QString wellPathText; + wellPathText += QString("Well path name : %1\n").arg(wellPathSourceInfo->wellPath()->name()); + wellPathText += QString("Measured depth : %1\n").arg(measuredDepth); + + QString formattedText; + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", trueVerticalDepth.x(), trueVerticalDepth.y(), -trueVerticalDepth.z()); + wellPathText += formattedText; - return true; + RiuMainWindow::instance()->setResultInfo(wellPathText); + + if (objectToSelect) + { + RiuMainWindow::instance()->selectAsCurrentItem(objectToSelect); } + else + { + RiuMainWindow::instance()->selectAsCurrentItem(wellPathSourceInfo->wellPath()); + } + + return true; } return false; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h index 305e856ab8..a60d598229 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathViewerEventHandler.h @@ -30,6 +30,6 @@ class RicWellPathViewerEventHandler : public RicViewerEventInterface public: static RicWellPathViewerEventHandler* instance(); - virtual bool handleEvent(cvf::Object* eventObject); + bool handleEvent(const RicViewerEventObject& eventObject) override; }; diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp index 3168992c9c..b3a19f0721 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsImportFileFeature.cpp @@ -26,7 +26,7 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -50,7 +50,7 @@ void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked) // Open dialog box to select well path files RiaApplication* app = RiaApplication::instance(); QString defaultDir = app->lastUsedDialogDirectory("WELLPATH_DIR"); - QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(RiuMainWindow::instance(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); + QStringList wellPathFilePaths = QFileDialog::getOpenFileNames(Riu3DMainWindowTools::mainWindowWidget(), "Import Well Paths", defaultDir, "Well Paths (*.json *.asc *.asci *.ascii *.dev);;All Files (*.*)"); if (wellPathFilePaths.size() < 1) return; @@ -73,7 +73,7 @@ void RicWellPathsImportFileFeature::onActionTriggered(bool isChecked) RimWellPath* wellPath = oilField->wellPathCollection->mostRecentlyUpdatedWellPath(); if (wellPath) { - RiuMainWindow::instance()->selectAsCurrentItem(wellPath); + Riu3DMainWindowTools::selectAsCurrentItem(wellPath); } } } diff --git a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp index 997001bea6..b187155157 100644 --- a/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp +++ b/ApplicationCode/Commands/WellPathCommands/RicWellPathsUnitSystemSettingsImpl.cpp @@ -20,7 +20,7 @@ #include "RicWellPathsUnitSystemSettingsUi.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiPropertyViewDialog.h" @@ -35,7 +35,7 @@ bool RicWellPathsUnitSystemSettingsImpl::ensureHasUnitSystem(RimWellPath * wellP } RicWellPathsUnitSystemSettingsUi settings; - caf::PdmUiPropertyViewDialog propertyDialog(RiuMainWindow::instance(), &settings, "Select Unit System for Well Path", ""); + caf::PdmUiPropertyViewDialog propertyDialog(Riu3DMainWindowTools::mainWindowWidget(), &settings, "Select Unit System for Well Path", ""); if (propertyDialog.exec() == QDialog::Accepted) { wellPath->setUnitSystem(settings.unitSystem()); diff --git a/ApplicationCode/FileInterface/CMakeLists_files.cmake b/ApplicationCode/FileInterface/CMakeLists_files.cmake index e437ee7c5b..99a41a6bbe 100644 --- a/ApplicationCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationCode/FileInterface/CMakeLists_files.cmake @@ -1,100 +1,98 @@ -# 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}RifEclipseDataTableFormatter.h -${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.h -${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.h -${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.h -${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.h -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.h -${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.h -${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.h -${CEE_CURRENT_LIST_DIR}RifSummaryReaderInterface.h -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataParserTools.h -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserDataParser.h -${CEE_CURRENT_LIST_DIR}RifKeywordVectorParser.h -${CEE_CURRENT_LIST_DIR}RifReaderObservedData.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.h -${CEE_CURRENT_LIST_DIR}RifReaderEclipseRft.h -${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.h -${CEE_CURRENT_LIST_DIR}RifReaderInterface.h -${CEE_CURRENT_LIST_DIR}RifReaderMockModel.h -${CEE_CURRENT_LIST_DIR}RifReaderSettings.h -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.h -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddressQMetaType.h -${CEE_CURRENT_LIST_DIR}RifEclipseRftAddress.h -${CEE_CURRENT_LIST_DIR}RifWellPathImporter.h -${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.h -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserData.h -${CEE_CURRENT_LIST_DIR}RifKeywordVectorUserData.h -${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPlt.h -${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPltQMetaType.h -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.h -${CEE_CURRENT_LIST_DIR}RifCsvUserData.h -${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.h -${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.h -${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseDataTableFormatter.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseOutputFileTools.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartDataAccess.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartFilesetAccess.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryTools.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUnifiedRestartFileAccess.h +${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseInput.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput.h +${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderInterface.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataParserTools.h +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserDataParser.h +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorParser.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderObservedData.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseSummary.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseRft.h +${CMAKE_CURRENT_LIST_DIR}/RifJsonEncodeDecode.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderInterface.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderMockModel.h +${CMAKE_CURRENT_LIST_DIR}/RifReaderSettings.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddress.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddressQMetaType.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRftAddress.h +${CMAKE_CURRENT_LIST_DIR}/RifWellPathImporter.h +${CMAKE_CURRENT_LIST_DIR}/RifHdf5ReaderInterface.h +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserData.h +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorUserData.h +${CMAKE_CURRENT_LIST_DIR}/RifDataSourceForRftPlt.h +${CMAKE_CURRENT_LIST_DIR}/RifDataSourceForRftPltQMetaType.h +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataKeywordTools.h +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserData.h +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserDataParser.h +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationReader.h +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationsImporter.h +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.h +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.h +${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.h +${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.h +${CMAKE_CURRENT_LIST_DIR}/RifEnsembleParametersReader.h +${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.h +${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.h + # HDF5 file reader is directly included in ResInsight main CmakeList.txt -#${CEE_CURRENT_LIST_DIR}RifHdf5Reader.h +#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.h - ) -endif() - set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RifEclipseDataTableFormatter.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseOutputFileTools.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseRestartDataAccess.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseRestartFilesetAccess.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseUnifiedRestartFileAccess.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryTools.cpp -${CEE_CURRENT_LIST_DIR}RifPerforationIntervalReader.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseInput.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput.cpp -${CEE_CURRENT_LIST_DIR}RifSummaryReaderInterface.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataParserTools.cpp -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserDataParser.cpp -${CEE_CURRENT_LIST_DIR}RifKeywordVectorParser.cpp -${CEE_CURRENT_LIST_DIR}RifReaderObservedData.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseRft.cpp -${CEE_CURRENT_LIST_DIR}RifJsonEncodeDecode.cpp -${CEE_CURRENT_LIST_DIR}RifReaderInterface.cpp -${CEE_CURRENT_LIST_DIR}RifReaderMockModel.cpp -${CEE_CURRENT_LIST_DIR}RifReaderSettings.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseSummaryAddress.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseRftAddress.cpp -${CEE_CURRENT_LIST_DIR}RifWellPathImporter.cpp -${CEE_CURRENT_LIST_DIR}RifHdf5ReaderInterface.cpp -${CEE_CURRENT_LIST_DIR}RifColumnBasedUserData.cpp -${CEE_CURRENT_LIST_DIR}RifKeywordVectorUserData.cpp -${CEE_CURRENT_LIST_DIR}RifDataSourceForRftPlt.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseUserDataKeywordTools.cpp -${CEE_CURRENT_LIST_DIR}RifCsvUserData.cpp -${CEE_CURRENT_LIST_DIR}RifCsvUserDataParser.cpp -${CEE_CURRENT_LIST_DIR}RifWellPathFormationReader.cpp -${CEE_CURRENT_LIST_DIR}RifWellPathFormationsImporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseDataTableFormatter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseOutputFileTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartDataAccess.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRestartFilesetAccess.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUnifiedRestartFileAccess.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifPerforationIntervalReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseInput.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput.cpp +${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataParserTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserDataParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderObservedData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseSummary.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseRft.cpp +${CMAKE_CURRENT_LIST_DIR}/RifJsonEncodeDecode.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderMockModel.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseSummaryAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseRftAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RifWellPathImporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifHdf5ReaderInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RifColumnBasedUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifKeywordVectorUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifDataSourceForRftPlt.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseUserDataKeywordTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCsvUserDataParser.cpp +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifWellPathFormationsImporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifStimPlanXmlReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifSummaryCaseRestartSelector.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEnsembleParametersReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RifFileParseTools.cpp # HDF5 file reader is directly included in ResInsight main CmakeList.txt -#${CEE_CURRENT_LIST_DIR}RifHdf5Reader.cpp +#${CMAKE_CURRENT_LIST_DIR}/RifHdf5Reader.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RifStimPlanXmlReader.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) @@ -103,4 +101,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "FileInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp new file mode 100644 index 0000000000..8ef6f884a2 --- /dev/null +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.cpp @@ -0,0 +1,226 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifCaseRealizationParametersReader.h" +#include "RifFileParseTools.h" + +#include "RiaLogging.h" +#include "RiaStdStringTools.h" + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// Constants +//-------------------------------------------------------------------------------------------------- +#define PARAMETERS_FILE_NAME "parameters.txt" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifCaseRealizationParametersReader::RifCaseRealizationParametersReader(const QString& fileName) +{ + m_parameters = std::shared_ptr(new RigCaseRealizationParameters()); + m_fileName = fileName; + m_file = nullptr; + m_textStream = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifCaseRealizationParametersReader::RifCaseRealizationParametersReader() +{ + m_parameters = std::shared_ptr(new RigCaseRealizationParameters()); + m_fileName = ""; + m_file = nullptr; + m_textStream = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifCaseRealizationParametersReader::~RifCaseRealizationParametersReader() +{ + if (m_textStream) + { + delete m_textStream; + } + closeFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::setFileName(const QString& fileName) +{ + m_fileName = fileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::parse() +{ + int lineNo = 0; + QTextStream* dataStream = openDataStream(); + + try + { + while (!dataStream->atEnd()) + { + QString line = dataStream->readLine(); + + lineNo++; + QStringList cols = RifFileParseTools::splitLineAndTrim(line, " "); + + if (cols.size() != 2) + { + throw FileParseException(QString("RifEnsembleParametersReader: Invalid file format in line %1").arg(lineNo)); + } + + QString& name = cols[0]; + QString& strValue = cols[1]; + + if (RiaStdStringTools::startsWithAlphabetic(strValue.toStdString())) + { + m_parameters->addParameter(name, strValue); + } + else + { + if (!RiaStdStringTools::isNumber(strValue.toStdString(), QLocale::c().decimalPoint().toAscii())) + { + throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + bool parseOk = true; + double value = QLocale::c().toDouble(strValue, &parseOk); + if (!parseOk) + { + throw FileParseException(QString("RifEnsembleParametersReader: Invalid number format in line %1").arg(lineNo)); + } + + m_parameters->addParameter(name, value); + } + } + + closeDataStream(); + } + catch (...) + { + closeDataStream(); + throw; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream* RifCaseRealizationParametersReader::openDataStream() +{ + openFile(); + + m_textStream = new QTextStream(m_file); + return m_textStream; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::closeDataStream() +{ + if (m_textStream) + { + delete m_textStream; + m_textStream = nullptr; + } + closeFile(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::openFile() +{ + if (!m_file) + { + m_file = new QFile(m_fileName); + if (!m_file->open(QIODevice::ReadOnly | QIODevice::Text)) + { + closeFile(); + //delete m_file; + //m_file = nullptr; + throw FileParseException(QString("Failed to open %1").arg(m_fileName)); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifCaseRealizationParametersReader::closeFile() +{ + if (m_file) + { + m_file->close(); + delete m_file; + m_file = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::shared_ptr RifCaseRealizationParametersReader::parameters() const +{ + return m_parameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifCaseRealizationParametersFileLocator::locate(const QString& modelPath) +{ + int MAX_LEVELS_UP = 2; + int dirLevel = 0; + + QDir qdir(modelPath); + + const QFileInfo dir(modelPath); + if (dir.isFile()) qdir.cdUp(); + else if (!dir.isDir()) return ""; + + do + { + QStringList files = qdir.entryList(QDir::Files | QDir::NoDotAndDotDot); + for (const QString& file : files) + { + if (QString::compare(file, PARAMETERS_FILE_NAME, Qt::CaseInsensitive) == 0) + { + return qdir.absoluteFilePath(file); + } + } + qdir.cdUp(); + + } while (dirLevel++ < MAX_LEVELS_UP); + + return ""; +} diff --git a/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h new file mode 100644 index 0000000000..5b2c65da72 --- /dev/null +++ b/ApplicationCode/FileInterface/RifCaseRealizationParametersReader.h @@ -0,0 +1,76 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" + +#include "RifSummaryCaseRestartSelector.h" + +#include "RigCaseRealizationParameters.h" + +#include +#include + +#include +#include +#include +#include + +class QStringList; +class QTextStream; +class QFile; + +//================================================================================================== +// +// +//================================================================================================== +class RifCaseRealizationParametersReader +{ +public: + RifCaseRealizationParametersReader(); + RifCaseRealizationParametersReader(const QString& fileName); + ~RifCaseRealizationParametersReader(); + + void setFileName(const QString& fileName); + void parse(); + const std::shared_ptr parameters() const; + +private: + QTextStream* openDataStream(); + void closeDataStream(); + void openFile(); + void closeFile(); +private: + std::shared_ptr m_parameters; + + QString m_fileName; + QFile* m_file; + QTextStream* m_textStream; +}; + + +//================================================================================================== +// +// +//================================================================================================== +class RifCaseRealizationParametersFileLocator +{ +public: + static QString locate(const QString& modelPath); +}; diff --git a/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp b/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp index 7b0adfa5e6..4b8f283620 100644 --- a/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp +++ b/ApplicationCode/FileInterface/RifCsvUserDataParser.cpp @@ -20,6 +20,7 @@ #include "RifEclipseUserDataKeywordTools.h" #include "RifEclipseUserDataParserTools.h" +#include "RifFileParseTools.h" #include "RiaDateStringParser.h" #include "RiaLogging.h" @@ -136,7 +137,7 @@ QString RifCsvUserDataParser::previewText(int lineCount, const AsciiDataParseOpt outStream << ""; int iCol = 0; - QStringList cols = splitLineAndTrim(line, parseOptions.cellSeparator); + QStringList cols = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator); for (const QString& cellData : cols) { if (cellData == parseOptions.timeSeriesColumnName && header) @@ -187,7 +188,7 @@ bool RifCsvUserDataParser::parseColumnInfo(QTextStream* dataStream, const AsciiD QString line = dataStream->readLine(); if (line.trimmed().isEmpty()) continue; - QStringList lineColumns = splitLineAndTrim(line, parseOptions.cellSeparator); + QStringList lineColumns = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator); int colCount = lineColumns.size(); @@ -230,7 +231,7 @@ bool RifCsvUserDataParser::parseData(const AsciiDataParseOptions& parseOptions) QString line = dataStream->readLine(); if(line.trimmed().isEmpty()) continue; - QStringList lineColumns = splitLineAndTrim(line, parseOptions.cellSeparator); + QStringList lineColumns = RifFileParseTools::splitLineAndTrim(line, parseOptions.cellSeparator); if(lineColumns.size() != colCount) { @@ -339,19 +340,6 @@ bool RifCsvUserDataParser::parseData(const AsciiDataParseOptions& parseOptions) return !errors; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QStringList RifCsvUserDataParser::splitLineAndTrim(const QString& line, const QString& separator) -{ - QStringList cols = line.split(separator); - for (QString& col : cols) - { - col = col.trimmed(); - } - return cols; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -386,9 +374,9 @@ QString RifCsvUserDataParser::tryDetermineCellSeparator() for (const QString& line : lines) { - totColumnCountTab += splitLineAndTrim(line, "\t").size(); - totColumnCountSemicolon += splitLineAndTrim(line, ";").size(); - totColumnCountComma += splitLineAndTrim(line, ",").size(); + totColumnCountTab += RifFileParseTools::splitLineAndTrim(line, "\t").size(); + totColumnCountSemicolon += RifFileParseTools::splitLineAndTrim(line, ";").size(); + totColumnCountComma += RifFileParseTools::splitLineAndTrim(line, ",").size(); } double avgColumnCountTab = (double)totColumnCountTab / lines.size(); @@ -421,7 +409,7 @@ QString RifCsvUserDataParser::tryDetermineDecimalSeparator(const QString& cellSe QString line = dataStream->readLine(); if (line.isEmpty()) continue; - for (const QString& cellData : splitLineAndTrim(line, cellSeparator)) + for (const QString& cellData : RifFileParseTools::splitLineAndTrim(line, cellSeparator)) { bool parseOk; QLocale locale; diff --git a/ApplicationCode/FileInterface/RifCsvUserDataParser.h b/ApplicationCode/FileInterface/RifCsvUserDataParser.h index 1969c7bddd..3f88890975 100644 --- a/ApplicationCode/FileInterface/RifCsvUserDataParser.h +++ b/ApplicationCode/FileInterface/RifCsvUserDataParser.h @@ -66,7 +66,6 @@ class RifCsvUserDataParser const AsciiDataParseOptions& parseOptions, std::vector* columnInfoList); bool parseData(const AsciiDataParseOptions& parseOptions); - static QStringList splitLineAndTrim(const QString& line, const QString& separator); static QDateTime tryParseDateTime(const std::string& colData, const QString& format); private: diff --git a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp index 4ed1a6a699..368eb2267d 100644 --- a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp +++ b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -23,7 +23,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out) : m_out(out) +RifEclipseDataTableFormatter::RifEclipseDataTableFormatter(QTextStream& out) + : m_out(out) + , m_colSpacing(5) { } @@ -36,12 +38,20 @@ RifEclipseDataTableFormatter::~RifEclipseDataTableFormatter() CVF_ASSERT(m_columns.empty()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifEclipseDataTableFormatter::setColumnSpacing(int spacing) +{ + m_colSpacing = spacing; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RifEclipseDataTableFormatter::outputBuffer() { - if (m_columns.size() > 0) + if (!m_columns.empty()) { m_out << "-- "; for (RifEclipseOutputTableColumn& column : m_columns) @@ -64,7 +74,8 @@ void RifEclipseDataTableFormatter::outputBuffer() { m_out << formatColumn(line.data[i], m_columns[i]); } - m_out << " /" << "\n"; + m_out << " /" + << "\n"; } } m_columns.clear(); @@ -203,7 +214,7 @@ RifEclipseDataTableFormatter& RifEclipseDataTableFormatter::addZeroBasedCellInde void RifEclipseDataTableFormatter::rowCompleted() { RifEclipseOutputTableLine line; - line.data = m_lineBuffer; + line.data = m_lineBuffer; line.lineType = CONTENTS; m_buffer.push_back(line); m_lineBuffer.clear(); @@ -248,12 +259,12 @@ QString RifEclipseDataTableFormatter::format(double num, RifEclipseOutputTableDo { switch (doubleFormat.format) { - case RifEclipseOutputTableDoubleFormat::RIF_FLOAT: - return QString("%1").arg(num, 0, 'f', doubleFormat.width); - case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC: - return QString("%1").arg(num, 0, 'E'); - default: - return QString("%1"); + case RifEclipseOutputTableDoubleFormat::RIF_FLOAT: + return QString("%1").arg(num, 0, 'f', doubleFormat.width); + case RifEclipseOutputTableDoubleFormat::RIF_SCIENTIFIC: + return QString("%1").arg(num, 0, 'E'); + default: + return QString("%1"); } } diff --git a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h index dab0e8fd8a..2981149e8e 100644 --- a/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h +++ b/ApplicationCode/FileInterface/RifEclipseDataTableFormatter.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -56,7 +56,7 @@ enum RifEclipseOutputTableDoubleFormat struct RifEclipseOutputTableLine { RifEclipseOutputTableLineType lineType; - std::vector< QString > data; + std::vector data; }; //================================================================================================== @@ -65,13 +65,13 @@ struct RifEclipseOutputTableLine struct RifEclipseOutputTableDoubleFormatting { RifEclipseOutputTableDoubleFormatting(RifEclipseOutputTableDoubleFormat format = RIF_FLOAT, int width = 5) - : format(format), - width(width) - {} - + : format(format) + , width(width) + { + } RifEclipseOutputTableDoubleFormat format; - int width; + int width; }; //================================================================================================== @@ -79,14 +79,14 @@ struct RifEclipseOutputTableDoubleFormatting //================================================================================================== struct RifEclipseOutputTableColumn { - RifEclipseOutputTableColumn(const QString& title, + RifEclipseOutputTableColumn(const QString& title, RifEclipseOutputTableDoubleFormatting doubleFormat = RifEclipseOutputTableDoubleFormatting(), - RifEclipseOutputTableAlignment alignment = LEFT, - int width = -1) - : title(title), - doubleFormat(doubleFormat), - alignment(alignment), - width(width) + RifEclipseOutputTableAlignment alignment = LEFT, + int width = -1) + : title(title) + , doubleFormat(doubleFormat) + , alignment(alignment) + , width(width) { } @@ -96,7 +96,6 @@ struct RifEclipseOutputTableColumn int width; }; - //================================================================================================== // //================================================================================================== @@ -106,35 +105,37 @@ class RifEclipseDataTableFormatter RifEclipseDataTableFormatter(QTextStream& out); virtual ~RifEclipseDataTableFormatter(); - RifEclipseDataTableFormatter& keyword(const QString keyword); - RifEclipseDataTableFormatter& header(std::vector tableHeader); - RifEclipseDataTableFormatter& add(const QString str); - RifEclipseDataTableFormatter& add(double num); - RifEclipseDataTableFormatter& add(int num); - RifEclipseDataTableFormatter& add(size_t num); - RifEclipseDataTableFormatter& addZeroBasedCellIndex(size_t index); - RifEclipseDataTableFormatter& comment(const QString str); - void rowCompleted(); - void tableCompleted(); + void setColumnSpacing(int spacing); + + RifEclipseDataTableFormatter& keyword(const QString keyword); + RifEclipseDataTableFormatter& header(std::vector tableHeader); + RifEclipseDataTableFormatter& add(const QString str); + RifEclipseDataTableFormatter& add(double num); + RifEclipseDataTableFormatter& add(int num); + RifEclipseDataTableFormatter& add(size_t num); + RifEclipseDataTableFormatter& addZeroBasedCellIndex(size_t index); + RifEclipseDataTableFormatter& comment(const QString str); + void rowCompleted(); + void tableCompleted(); private: - int measure(const QString str); - int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); - int measure(int num); - int measure(size_t num); + int measure(const QString str); + int measure(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); + int measure(int num); + int measure(size_t num); - QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); - QString format(int num); - QString format(size_t num); - QString formatColumn(const QString str, RifEclipseOutputTableColumn column); + QString format(double num, RifEclipseOutputTableDoubleFormatting doubleFormat); + QString format(int num); + QString format(size_t num); + QString formatColumn(const QString str, RifEclipseOutputTableColumn column); - void outputBuffer(); - void outputComment(RifEclipseOutputTableLine& comment); + void outputBuffer(); + void outputComment(RifEclipseOutputTableLine& comment); private: std::vector m_columns; std::vector m_buffer; std::vector m_lineBuffer; QTextStream& m_out; - int m_colSpacing = 5; + int m_colSpacing; }; diff --git a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp index cdabcf0f1a..01f8597e08 100644 --- a/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseInputFileTools.cpp @@ -20,6 +20,8 @@ #include "RifEclipseInputFileTools.h" +#include "RiaLogging.h" + #include "RifReaderEclipseOutput.h" #include "RigActiveCellInfo.h" @@ -90,6 +92,25 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC if (coordPos < 0 || zcornPos < 0 || specgridPos < 0) { + QString errorText = QString("Failed to import grid file '%1'\n").arg(fileName); + + if (coordPos < 0) + { + errorText += " Missing required keyword COORD"; + } + + if (zcornPos < 0) + { + errorText += " Missing required keyword ZCORN"; + } + + if (specgridPos < 0) + { + errorText += " Missing required keyword SPECGRID"; + } + + RiaLogging::error(errorText); + return false; } @@ -107,11 +128,11 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC - ecl_kw_type* specGridKw = NULL; - ecl_kw_type* zCornKw = NULL; - ecl_kw_type* coordKw = NULL; - ecl_kw_type* actNumKw = NULL; - ecl_kw_type* mapAxesKw = NULL; + ecl_kw_type* specGridKw = nullptr; + ecl_kw_type* zCornKw = nullptr; + ecl_kw_type* coordKw = nullptr; + ecl_kw_type* actNumKw = nullptr; + ecl_kw_type* mapAxesKw = nullptr; // Try to read all the needed keywords. Early exit if some are not found caf::ProgressInfo progress(8, "Read Grid from Eclipse Input file"); @@ -121,22 +142,22 @@ bool RifEclipseInputFileTools::openGridFile(const QString& fileName, RigEclipseC bool allKwReadOk = true; fseek(gridFilePointer, specgridPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (specGridKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); progress.setProgress(1); fseek(gridFilePointer, zcornPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (zCornKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); progress.setProgress(2); fseek(gridFilePointer, coordPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (coordKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_FLOAT_TYPE))); progress.setProgress(3); // If ACTNUM is not defined, this pointer will be NULL, which is a valid condition if (actnumPos >= 0) { fseek(gridFilePointer, actnumPos, SEEK_SET); - allKwReadOk = allKwReadOk && NULL != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); + allKwReadOk = allKwReadOk && nullptr != (actNumKw = ecl_kw_fscanf_alloc_current_grdecl__(gridFilePointer, false , ecl_type_create_from_type(ECL_INT_TYPE))); progress.setProgress(4); } @@ -645,7 +666,7 @@ void RifEclipseInputFileTools::parseAndReadFaults(const QString& fileName, cvf:: while (filePos != -1) { - readFaults(data, filePos, faults, NULL); + readFaults(data, filePos, faults, nullptr); filePos = findKeyword(faultsKeyword, data, filePos); } } @@ -919,7 +940,7 @@ void RifEclipseInputFileTools::readFaults(QFile &data, qint64 filePos, cvf::Coll // qDebug() << "Reading faults from\n " << data.fileName(); - RigFault* fault = NULL; + RigFault* fault = nullptr; do { diff --git a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp index 898b003a4d..e36114342d 100644 --- a/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseOutputFileTools.cpp @@ -274,7 +274,7 @@ bool RifEclipseOutputFileTools::findSiblingFilesWithSameBaseName(const QString& QString filePath = QFileInfo(fullPathFileName).absoluteFilePath(); filePath = QFileInfo(filePath).path(); - QString fileNameBase = QFileInfo(fullPathFileName).baseName(); + QString fileNameBase = QFileInfo(fullPathFileName).completeBaseName(); stringlist_type* eclipseFiles = stringlist_alloc_new(); ecl_util_select_filelist(RiaStringEncodingTools::toNativeEncoded(filePath).data(), RiaStringEncodingTools::toNativeEncoded(fileNameBase).data(), ECL_OTHER_FILE, false, eclipseFiles); diff --git a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp index 6ea396a867..7dc6e8c0f2 100644 --- a/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseRestartFilesetAccess.cpp @@ -307,7 +307,7 @@ int RifEclipseRestartFilesetAccess::reportNumber(const ecl_file_type* ecl_file) //-------------------------------------------------------------------------------------------------- int RifEclipseRestartFilesetAccess::readUnitsType() { - ecl_file_type* ecl_file = NULL; + ecl_file_type* ecl_file = nullptr; if (m_ecl_files.size() > 0) { diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp index 685e7e94b5..3029884d03 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.cpp @@ -20,6 +20,8 @@ #include "RiaStdStringTools.h" +#include + #include "cvfAssert.h" //-------------------------------------------------------------------------------------------------- @@ -515,3 +517,22 @@ bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAdd } return false; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj) +{ + CVF_ASSERT(false); + return str; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj) +{ + CVF_ASSERT(false); + return str; +} + diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h index 6846cdedbf..6f0231eaf7 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryAddress.h @@ -20,6 +20,8 @@ #include #include +class QTextStream; + //================================================================================================== // // @@ -166,3 +168,7 @@ class RifEclipseSummaryAddress bool operator==(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second); bool operator<(const RifEclipseSummaryAddress& first, const RifEclipseSummaryAddress& second); + +QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj); + +QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj); diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp index c1d2bd76c1..bf4201a478 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.cpp @@ -21,11 +21,13 @@ #include "RiaSummaryCurveAnalyzer.h" #include "RifReaderEclipseSummary.h" #include "RiaStringEncodingTools.h" +#include "RiaFilePathTools.h" #include "cafAppEnum.h" #include "ert/ecl/ecl_util.h" +#include #include #include @@ -36,7 +38,7 @@ //-------------------------------------------------------------------------------------------------- void RifEclipseSummaryTools::findSummaryHeaderFile(const QString& inputFile, QString* headerFile, bool* isFormatted) { - findSummaryHeaderFileInfo(inputFile, headerFile, NULL, NULL, isFormatted); + findSummaryHeaderFileInfo(inputFile, headerFile, nullptr, nullptr, isFormatted); } //-------------------------------------------------------------------------------------------------- @@ -49,9 +51,9 @@ void RifEclipseSummaryTools::findSummaryFiles(const QString& inputFile, dataFiles->clear(); headerFile->clear(); - char* myPath = NULL; - char* myBase = NULL; - char* myExtention = NULL; + char* myPath = nullptr; + char* myBase = nullptr; + char* myExtention = nullptr; util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(inputFile).data(), &myPath, &myBase, &myExtention); @@ -61,7 +63,7 @@ void RifEclipseSummaryTools::findSummaryFiles(const QString& inputFile, if(path.isEmpty() || base.isEmpty()) return ; - char* myHeaderFile = NULL; + char* myHeaderFile = nullptr; stringlist_type* summary_file_list = stringlist_alloc_new(); ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), extention.data(), &myHeaderFile, summary_file_list); @@ -107,13 +109,13 @@ QStringList RifEclipseSummaryTools::findSummaryDataFiles(const QString& caseFile QString path; QString base; - findSummaryHeaderFileInfo(caseFile, NULL, &path, &base, NULL); + findSummaryHeaderFileInfo(caseFile, nullptr, &path, &base, nullptr); if (path.isEmpty() || base.isEmpty()) return fileNames; - char* header_file = NULL; + char* header_file = nullptr; stringlist_type* summary_file_list = stringlist_alloc_new(); - ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), NULL, &header_file, summary_file_list); + ecl_util_alloc_summary_files(RiaStringEncodingTools::toNativeEncoded(path).data(), RiaStringEncodingTools::toNativeEncoded(base).data(), nullptr, &header_file, summary_file_list); if (stringlist_get_size( summary_file_list ) > 0) { for (int i = 0; i < stringlist_get_size(summary_file_list); i++) @@ -128,6 +130,38 @@ QStringList RifEclipseSummaryTools::findSummaryDataFiles(const QString& caseFile return fileNames; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(const QString& summaryHeaderFile) +{ + char* myPath = nullptr; + char* myBase = nullptr; + bool formattedFile = true; + + util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(QDir::toNativeSeparators(summaryHeaderFile)).data(), &myPath, &myBase, nullptr); + + char* caseFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_EGRID_FILE, true, -1); + if (!caseFile) + { + caseFile= ecl_util_alloc_exfilename(myPath, myBase, ECL_EGRID_FILE, false, -1); + if (caseFile) + { + formattedFile = false; + } + } + + QString gridCaseFile; + + if (caseFile) gridCaseFile = caseFile; + + util_safe_free(caseFile); + util_safe_free(myBase); + util_safe_free(myPath); + + return RiaFilePathTools::toInternalSeparator(gridCaseFile); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -169,11 +203,11 @@ void RifEclipseSummaryTools::dumpMetaData(RifSummaryReaderInterface* readerEclip //-------------------------------------------------------------------------------------------------- void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const QString& inputFile, QString* headerFile, QString* path, QString* base, bool* isFormatted) { - char* myPath = NULL; - char* myBase = NULL; + char* myPath = nullptr; + char* myBase = nullptr; bool formattedFile = true; - util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(inputFile).data(), &myPath, &myBase, NULL); + util_alloc_file_components(RiaStringEncodingTools::toNativeEncoded(QDir::toNativeSeparators(inputFile)).data(), &myPath, &myBase, nullptr); char* myHeaderFile = ecl_util_alloc_exfilename(myPath, myBase, ECL_SUMMARY_HEADER_FILE, true, -1); if (!myHeaderFile) @@ -185,9 +219,9 @@ void RifEclipseSummaryTools::findSummaryHeaderFileInfo(const QString& inputFile, } } - if (myHeaderFile && headerFile) *headerFile = myHeaderFile; - if (myPath && path) *path = myPath; - if (myBase && base) *base = myBase; + if (myHeaderFile && headerFile) *headerFile = RiaFilePathTools::toInternalSeparator(myHeaderFile); + if (myPath && path) *path = RiaFilePathTools::toInternalSeparator(myPath); + if (myBase && base) *base = RiaFilePathTools::toInternalSeparator(myBase); if (isFormatted) *isFormatted = formattedFile; util_safe_free(myHeaderFile); diff --git a/ApplicationCode/FileInterface/RifEclipseSummaryTools.h b/ApplicationCode/FileInterface/RifEclipseSummaryTools.h index d2e99047e7..85957737b3 100644 --- a/ApplicationCode/FileInterface/RifEclipseSummaryTools.h +++ b/ApplicationCode/FileInterface/RifEclipseSummaryTools.h @@ -37,6 +37,7 @@ class RifEclipseSummaryTools public: static void findSummaryHeaderFile(const QString& inputFile, QString* headerFile, bool* isFormatted); static QStringList findSummaryDataFiles(const QString& caseFile); + static QString findGridCaseFileFromSummaryHeaderFile(const QString& summaryHeaderFile); static void findSummaryFiles(const QString& inputFile, QString* headerFile, QStringList* dataFiles); static bool hasSummaryFiles(const QString& gridFileName); diff --git a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp index a363924309..2961776e32 100644 --- a/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp +++ b/ApplicationCode/FileInterface/RifEclipseUnifiedRestartFileAccess.cpp @@ -44,7 +44,7 @@ RifEclipseUnifiedRestartFileAccess::RifEclipseUnifiedRestartFileAccess() : RifEclipseRestartDataAccess() { - m_ecl_file = NULL; + m_ecl_file = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp new file mode 100644 index 0000000000..f3a339308c --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.cpp @@ -0,0 +1,238 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifElementPropertyReader.h" + +#include "cvfAssert.h" + +#include + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifElementPropertyReader::RifElementPropertyReader(const std::vector& elementIdxToId) : m_elementIdxToId(elementIdxToId) {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifElementPropertyReader::~RifElementPropertyReader() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::addFile(const std::string& fileName) +{ + RifElementPropertyMetadata metaData = RifElementPropertyTableReader::readMetadata(QString::fromStdString(fileName)); + for (QString field : metaData.dataColumns) + { + m_fieldsMetaData[field.toStdString()] = metaData; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::removeFile(const std::string& fileName) +{ + std::map tempMetaData; + + for (std::pair metaData : m_fieldsMetaData) + { + if (metaData.second.fileName.toStdString() != fileName) + { + tempMetaData[metaData.first] = metaData.second; + } + } + + m_fieldsMetaData.swap(tempMetaData); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifElementPropertyReader::scalarElementFields() const +{ + std::vector fields; + + for (const std::pair& field : m_fieldsMetaData) + { + fields.push_back(field.first); + } + + return fields; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map> + RifElementPropertyReader::readAllElementPropertiesInFileContainingField(const std::string& fieldName) +{ + std::map> fieldAndData; + + if (m_fieldsMetaData.find(fieldName) == m_fieldsMetaData.end()) + { + return fieldAndData; + } + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&m_fieldsMetaData[fieldName], &table); + + CVF_ASSERT(m_fieldsMetaData[fieldName].dataColumns.size() == table.data.size()); + + for (size_t i = 0; i < table.data.size(); i++) + { + CVF_ASSERT(table.data[i].size() == table.elementIds.size()); + } + + const std::vector& elementIdsFromFile = table.elementIds; + + if (elementIdsFromFile == m_elementIdxToId) + { + for (size_t i = 0; i < table.data.size(); i++) + { + const std::string& currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); + + if (currentFieldFromFile == "MODULUS") + { + const std::vector& currentColumn = table.data[i]; + std::vector tempResult(currentColumn.size(), 0); + + for (float resultItem : currentColumn) + { + tempResult[i] = resultItem * 0.000000001; + } + + fieldAndData[currentFieldFromFile].swap(tempResult); + } + else + { + fieldAndData[currentFieldFromFile] = table.data[i]; + } + } + } + else if (elementIdsFromFile.size() > m_elementIdxToId.size() && elementIdsFromFile.size() > m_elementIdToIdx.size()) + { + RifElementPropertyReader::outputWarningAboutWrongFileData(); + return fieldAndData; + } + else + { + if (m_elementIdToIdx.empty()) + { + makeElementIdToIdxMap(); + } + + std::vector fileIdxToElementIdx; + fileIdxToElementIdx.reserve(elementIdsFromFile.size()); + + for (int elementId : elementIdsFromFile) + { + std::unordered_map::const_iterator it = m_elementIdToIdx.find(elementId); + if (it == m_elementIdToIdx.end()) + { + RifElementPropertyReader::outputWarningAboutWrongFileData(); + return fieldAndData; + } + + fileIdxToElementIdx.push_back(it->second); + } + + for (size_t i = 0; i < table.data.size(); i++) + { + std::string currentFieldFromFile = m_fieldsMetaData[fieldName].dataColumns[i].toStdString(); + + const std::vector& currentColumn = table.data[i]; + + std::vector tempResult(m_elementIdToIdx.size(), HUGE_VAL); + + if (currentFieldFromFile == "MODULUS") + { + for (size_t j = 0; j < currentColumn.size(); j++) + { + tempResult[fileIdxToElementIdx[j]] = currentColumn[j] * 0.000000001; + } + } + else + { + for (size_t j = 0; j < currentColumn.size(); j++) + { + tempResult[fileIdxToElementIdx[j]] = currentColumn[j]; + } + } + + fieldAndData[currentFieldFromFile].swap(tempResult); + } + } + + return fieldAndData; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifElementPropertyReader::fieldsInFile(const std::string& fileName) const +{ + std::vector fields; + + for (std::pair metaData : m_fieldsMetaData) + { + if (metaData.second.fileName.toStdString() == fileName) + { + for (const QString& column : metaData.second.dataColumns) + { + fields.push_back(column.toStdString()); + } + } + } + + return fields; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::makeElementIdToIdxMap() +{ + m_elementIdToIdx.reserve(m_elementIdxToId.size()); + + for (size_t i = 0; i < m_elementIdxToId.size(); i++) + { + m_elementIdToIdx[m_elementIdxToId[i]] = (int)i; + } + + std::vector tempVectorForDeletion; + m_elementIdxToId.swap(tempVectorForDeletion); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyReader::outputWarningAboutWrongFileData() +{ + QMessageBox msgBox; + msgBox.setIcon(QMessageBox::Warning); + QString warningText; + warningText = QString("The chosen result property does not fit the model"); + msgBox.setText(warningText); + msgBox.setStandardButtons(QMessageBox::Ok); + msgBox.exec(); +} diff --git a/ApplicationCode/FileInterface/RifElementPropertyReader.h b/ApplicationCode/FileInterface/RifElementPropertyReader.h new file mode 100644 index 0000000000..34b6508d2f --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyReader.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifElementPropertyTableReader.h" + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include +#include +#include +#include + +//================================================================================================== +// +// +//================================================================================================== +class RifElementPropertyReader : public cvf::Object +{ +public: + RifElementPropertyReader(const std::vector& elementIdxToId); + virtual ~RifElementPropertyReader(); + + void addFile(const std::string& fileName); + void removeFile(const std::string& fileName); + + std::vector scalarElementFields() const; + + std::map> readAllElementPropertiesInFileContainingField(const std::string& fieldName); + + std::vector fieldsInFile(const std::string& fileName) const; + +private: + void makeElementIdToIdxMap(); + static void outputWarningAboutWrongFileData(); + +private: + std::map m_fieldsMetaData; + std::vector m_elementIdxToId; + std::unordered_map m_elementIdToIdx; +}; diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp new file mode 100644 index 0000000000..7918406e4a --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.cpp @@ -0,0 +1,203 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifElementPropertyTableReader.h" +#include "RifFileParseTools.h" + +#include "RiaLogging.h" +#include "RiuMainWindow.h" + +#include +#include +#include +#include + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +static QFile* openFile(const QString &fileName); +static void closeFile(QFile *file); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifElementPropertyMetadata RifElementPropertyTableReader::readMetadata(const QString& fileName) +{ + RifElementPropertyMetadata metadata; + QFile* file = nullptr; + + try + { + file = openFile(fileName); + + if (file) + { + QTextStream stream(file); + bool metadataBlockFound = false; + int maxLinesToRead = 50; + int lineNo = 0; + + while (lineNo < maxLinesToRead) + { + QString line = stream.readLine(); + lineNo++; + + if (line.toUpper().startsWith("*DISTRIBUTION TABLE")) + { + metadataBlockFound = true; + continue; + } + + if (!metadataBlockFound) continue; + + QStringList cols = RifFileParseTools::splitLineAndTrim(line, ","); + + metadata.fileName = fileName; + for (QString s : cols) + { + metadata.dataColumns.push_back(s); + } + break; + } + + closeFile(file); + } + } + catch(...) + { + closeFile(file); + throw; + } + + return metadata; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifElementPropertyTableReader::readData(const RifElementPropertyMetadata *metadata, RifElementPropertyTable *table) +{ + CVF_ASSERT(metadata && table); + + int expectedColumnCount = (int)metadata->dataColumns.size() + 1; + QFile* file = nullptr; + + try + { + file = openFile(metadata->fileName); + + if (file && expectedColumnCount > 0) + { + QTextStream stream(file); + bool dataBlockFound = false; + int lineNo = 0; + + // Init data vectors + table->elementIds.clear(); + table->data = std::vector>(metadata->dataColumns.size()); + + while (!stream.atEnd()) + { + QString line = stream.readLine(); + QStringList cols = RifFileParseTools::splitLineAndTrim(line, ","); + lineNo++; + + if (!dataBlockFound) + { + if (!line.startsWith("*") && !line.startsWith(",") && cols.size() == expectedColumnCount) dataBlockFound = true; + else continue; + } + + if (cols.size() != expectedColumnCount) + { + throw FileParseException(QString("Number of columns mismatch at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + + for (int c = 0; c < expectedColumnCount; c++) + { + bool parseOk; + + if (c == 0) + { + // Remove elementId column prefix + QStringList parts = cols[0].split("."); + + int elementId = parts.last().toInt(&parseOk); + if (!parseOk) + { + throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + table->elementIds.push_back(elementId); + } + else + { + float value = cols[c].toFloat(&parseOk); + if (!parseOk) + { + throw FileParseException(QString("Parse failed at %1:%2").arg(metadata->fileName).arg(lineNo)); + } + table->data[c - 1].push_back(value); + } + } + } + + table->hasData = true; + } + + closeFile(file); + } + catch (...) + { + closeFile(file); + throw; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QFile* openFile(const QString &fileName) +{ + QFile *file; + file = new QFile(fileName); + if (!file->open(QIODevice::ReadOnly | QIODevice::Text)) + { + RiaLogging::error(QString("Failed to open %1").arg(fileName)); + + delete file; + return nullptr; + } + return file; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void closeFile(QFile *file) +{ + if (file) + { + file->close(); + delete file; + } +} diff --git a/ApplicationCode/FileInterface/RifElementPropertyTableReader.h b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h new file mode 100644 index 0000000000..619178f86b --- /dev/null +++ b/ApplicationCode/FileInterface/RifElementPropertyTableReader.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +class RifElementPropertyTable; +class RifElementPropertyMetadata; + +//================================================================================================== +/// +//================================================================================================== +class RifElementPropertyTableReader : cvf::Object +{ +public: + static RifElementPropertyMetadata readMetadata(const QString& filePath); + static void readData(const RifElementPropertyMetadata *metadata, RifElementPropertyTable *table); +}; + + +//================================================================================================== +/// +//================================================================================================== +class RifElementPropertyMetadata +{ +public: + QString fileName; + std::vector dataColumns; +}; + + +//================================================================================================== +/// +//================================================================================================== +class RifElementPropertyTable +{ +public: + RifElementPropertyTable() : hasData(false) {} + + RifElementPropertyMetadata metadata; + bool hasData; + std::vector elementIds; + std::vector> data; +}; + diff --git a/ApplicationCode/FileInterface/RifEnsembleParametersReader.cpp b/ApplicationCode/FileInterface/RifEnsembleParametersReader.cpp new file mode 100644 index 0000000000..b91be08d0b --- /dev/null +++ b/ApplicationCode/FileInterface/RifEnsembleParametersReader.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifEnsembleParametersReader.h" +#include "RifCaseRealizationParametersReader.h" +#include "RifFileParseTools.h" + +#include "RiaLogging.h" +#include "RiaStdStringTools.h" + +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEnsembleParametersReader::RifEnsembleParametersReader(const QString& modelDirectory) +{ + m_modelDirectory = modelDirectory; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEnsembleParametersReader::~RifEnsembleParametersReader() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +//RifEnsembleParameters RifEnsembleParametersReader::import() +//{ +// RifEnsembleParameters parameters; +// +// +// return ; +//} + diff --git a/ApplicationCode/FileInterface/RifEnsembleParametersReader.h b/ApplicationCode/FileInterface/RifEnsembleParametersReader.h new file mode 100644 index 0000000000..67c1f78c8d --- /dev/null +++ b/ApplicationCode/FileInterface/RifEnsembleParametersReader.h @@ -0,0 +1,45 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RifSummaryCaseRestartSelector.h" + +#include + + +class QStringList; +class QTextStream; +class QFile; + + +//================================================================================================== +// +// UNDER CONSTRUCTION +//================================================================================================== +class RifEnsembleParametersReader +{ +public: + RifEnsembleParametersReader(const QString& modelDirectory); + ~RifEnsembleParametersReader(); + + //RifEnsembleParameters import(); + +private: + QString m_modelDirectory; +}; diff --git a/ApplicationCode/FileInterface/RifFileParseTools.cpp b/ApplicationCode/FileInterface/RifFileParseTools.cpp new file mode 100644 index 0000000000..9f7e88c966 --- /dev/null +++ b/ApplicationCode/FileInterface/RifFileParseTools.cpp @@ -0,0 +1,33 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifFileParseTools.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RifFileParseTools::splitLineAndTrim(const QString& line, const QString& separator) +{ + QStringList cols = line.split(separator); + for (QString& col : cols) + { + col = col.trimmed(); + } + return cols; +} diff --git a/ApplicationCode/FileInterface/RifFileParseTools.h b/ApplicationCode/FileInterface/RifFileParseTools.h new file mode 100644 index 0000000000..1ad6b2724f --- /dev/null +++ b/ApplicationCode/FileInterface/RifFileParseTools.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + + +//================================================================================================== +/// +//================================================================================================== +class RifFileParseTools +{ +public: + static QStringList splitLineAndTrim(const QString& line, const QString& separator); +}; + +//================================================================================================== +/// +//================================================================================================== +class FileParseException +{ +public: + FileParseException(const QString &message) : message(message) {} + QString message; +}; diff --git a/ApplicationCode/FileInterface/RifHdf5Reader.cpp b/ApplicationCode/FileInterface/RifHdf5Reader.cpp index 050bd7b4bc..6e52a3d23f 100644 --- a/ApplicationCode/FileInterface/RifHdf5Reader.cpp +++ b/ApplicationCode/FileInterface/RifHdf5Reader.cpp @@ -461,7 +461,7 @@ void RifHdf5Reader::getElementResultValues(H5::H5File file, std::string groupNam hsize_t dims[2]; H5::DataSpace dataspace = dataset.getSpace(); - dataspace.getSimpleExtentDims(dims, NULL); + dataspace.getSimpleExtentDims(dims, nullptr); (*resultValues).resize(dims[0]); dataset.read(resultValues->data(), H5::PredType::NATIVE_DOUBLE); diff --git a/ApplicationCode/FileInterface/RifHdf5Reader.h b/ApplicationCode/FileInterface/RifHdf5Reader.h index 5018a0a5bd..f3af15f3f2 100644 --- a/ApplicationCode/FileInterface/RifHdf5Reader.h +++ b/ApplicationCode/FileInterface/RifHdf5Reader.h @@ -40,23 +40,23 @@ class RifHdf5Reader : public RifHdf5ReaderInterface bool dynamicResult(const QString& result, size_t stepIndex, std::vector* values) const override; private: - std::vector getSourSimTimeStepFileNames(const QString& fileName) const; - QDateTime sourSimDateTimeToQDateTime(std::string dateString) const; + std::vector getSourSimTimeStepFileNames(const QString& fileName) const; + QDateTime sourSimDateTimeToQDateTime(std::string dateString) const; - std::string getTimeStepNumberAs5DigitString(std::string fileName) const; - std::string IntTo5DigitString(int i) const; + std::string getTimeStepNumberAs5DigitString(std::string fileName) const; + std::string IntTo5DigitString(int i) const; - int getIntAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; - double getDoubleAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; - std::string getStringAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; + int getIntAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; + double getDoubleAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; + std::string getStringAttribute(H5::H5File file, std::string groupName, std::string attributeName) const; - std::vector getSubGroupNames(H5::H5File file, std::string baseGroupName) const; - std::vector getStepTimeValues(H5::H5File file, std::string baseGroupName) const; - std::vector getResultNames(H5::H5File file, std::string baseGroupName) const; - void getElementResultValues(H5::H5File file, std::string groupName, std::vector* resultValues) const; + std::vector getSubGroupNames(H5::H5File file, std::string baseGroupName) const; + std::vector getStepTimeValues(H5::H5File file, std::string baseGroupName) const; + std::vector getResultNames(H5::H5File file, std::string baseGroupName) const; + void getElementResultValues(H5::H5File file, std::string groupName, std::vector* resultValues) const; private: - QString m_fileName; // name of SourSimRL main file given by user - int m_fileStrategy; // SourSimRL file strategy, fileStrategy == 1 means one time step per file - std::vector m_timeStepFileNames; // files containing transient SourSimRL results, one time step per file + QString m_fileName; // name of SourSimRL main file given by user + int m_fileStrategy; // SourSimRL file strategy, fileStrategy == 1 means one time step per file + std::vector m_timeStepFileNames; // files containing transient SourSimRL results, one time step per file }; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 15743cdffc..35543a58c8 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -174,7 +174,7 @@ bool transferGridCellData(RigMainGrid* mainGrid, RigActiveCellInfo* activeCellIn // Sub grid in cell const ecl_grid_type* subGrid = ecl_grid_get_cell_lgr1(localEclGrid, gridLocalCellIndex); - if (subGrid != NULL) + if (subGrid != nullptr) { int subGridId = ecl_grid_get_lgr_nr(subGrid); CVF_ASSERT(subGridId > 0); @@ -208,10 +208,10 @@ RifReaderEclipseOutput::RifReaderEclipseOutput() m_fileName.clear(); m_filesWithSameBaseName.clear(); - m_eclipseCase = NULL; + m_eclipseCase = nullptr; - m_ecl_init_file = NULL; - m_dynamicResultsAccess = NULL; + m_ecl_init_file = nullptr; + m_dynamicResultsAccess = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -223,7 +223,7 @@ RifReaderEclipseOutput::~RifReaderEclipseOutput() { ecl_file_close(m_ecl_init_file); } - m_ecl_init_file = NULL; + m_ecl_init_file = nullptr; if (m_dynamicResultsAccess.notNull()) { @@ -1149,7 +1149,7 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa double oilRate = well_conn_get_oil_rate(ert_connection) ; double gasRate = well_conn_get_gas_rate(ert_connection); double waterRate = well_conn_get_water_rate(ert_connection); - + double connectionFactor = well_conn_get_connection_factor(ert_connection); RigWellResultPoint resultPoint; @@ -1167,6 +1167,8 @@ RigWellResultPoint RifReaderEclipseOutput::createWellResultPoint(const RigGridBa resultPoint.m_waterRate = waterRate; resultPoint.m_gasRate = RiaEclipseUnitTools::convertSurfaceGasFlowRateToOilEquivalents(m_eclipseCase->unitsType(), gasRate); + + resultPoint.m_connectionFactor = connectionFactor; } return resultPoint; @@ -1634,7 +1636,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo if (well_segment_get_outlet_id(segment) == -1) { - segment = NULL; + segment = nullptr; } else { @@ -1696,11 +1698,11 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo accLengthFromLastConnection += well_segment_get_length(outletSegment); segmentIdBelow = well_segment_get_id(outletSegment); - const well_segment_type* aboveOutletSegment = NULL; + const well_segment_type* aboveOutletSegment = nullptr; if (well_segment_get_outlet_id(outletSegment) == -1) { - aboveOutletSegment = NULL; + aboveOutletSegment = nullptr; } else { @@ -1740,7 +1742,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid, boo if (well_segment_get_outlet_id(aboveOutletSegment) == -1) { - aboveOutletSegment = NULL; + aboveOutletSegment = nullptr; } else { diff --git a/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp b/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp index 71e056ce54..639ed1cb05 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseRft.cpp @@ -53,7 +53,7 @@ void RifReaderEclipseRft::open() m_ecl_rft_file = ecl_rft_file_alloc_case(RiaStringEncodingTools::toNativeEncoded(m_fileName).data()); - if (m_ecl_rft_file == NULL) + if (m_ecl_rft_file == nullptr) { RiaLogging::warning(QString("Libecl could not find/open file '%'").arg( m_fileName)); return; diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp index 9d7b153f3d..37a2bda0a3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.cpp @@ -18,8 +18,9 @@ #include "RifReaderEclipseSummary.h" #include "RiaStringEncodingTools.h" - -#include "ert/ecl/ecl_sum.h" +#include "RiaFilePathTools.h" +#include "RifReaderEclipseOutput.h" +#include "RifEclipseSummaryTools.h" #include #include @@ -27,13 +28,70 @@ #include #include #include +#include + +#include "ert/ecl/ecl_sum.h" #include "ert/ecl/smspec_node.h" +#include "ert/ecl/ecl_file.h" +#include "ert/ecl/ecl_kw_magic.h" +#include "ert/ecl/ecl_kw.h" + +std::vector getTimeSteps(ecl_sum_type* ecl_sum) +{ + std::vector timeSteps; + + if (ecl_sum) + { + for (int time_index = 0; time_index < ecl_sum_get_data_length(ecl_sum); time_index++) + { + time_t sim_time = ecl_sum_iget_sim_time(ecl_sum, time_index); + timeSteps.push_back(sim_time); + } + } + return timeSteps; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +ecl_sum_type* openEclSum(const QString& inHeaderFileName, bool includeRestartFiles) +{ + QString headerFileName; + QStringList dataFileNames; + QString nativeHeaderFileName = QDir::toNativeSeparators(inHeaderFileName); + RifEclipseSummaryTools::findSummaryFiles(nativeHeaderFileName, &headerFileName, &dataFileNames); + + if (headerFileName.isEmpty() || dataFileNames.size() == 0) return nullptr; + + assert(!headerFileName.isEmpty()); + assert(dataFileNames.size() > 0); + + stringlist_type* dataFiles = stringlist_alloc_new(); + for (int i = 0; i < dataFileNames.size(); i++) + { + stringlist_append_copy(dataFiles, RiaStringEncodingTools::toNativeEncoded(dataFileNames[i]).data()); + } + + std::string itemSeparatorInVariableNames = ":"; + ecl_sum_type* ecl_sum = ecl_sum_fread_alloc(RiaStringEncodingTools::toNativeEncoded(headerFileName).data(), dataFiles, itemSeparatorInVariableNames.data(), includeRestartFiles); + + stringlist_free(dataFiles); + + return ecl_sum; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void closeEclSum(ecl_sum_type* ecl_sum) +{ + if(ecl_sum) ecl_sum_free(ecl_sum); +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RifReaderEclipseSummary::RifReaderEclipseSummary() - : m_ecl_sum(NULL), + : m_ecl_sum(nullptr), m_ecl_SmSpec(nullptr) { @@ -47,43 +105,24 @@ RifReaderEclipseSummary::~RifReaderEclipseSummary() if (m_ecl_sum) { ecl_sum_free(m_ecl_sum); - m_ecl_sum = NULL; + m_ecl_sum = nullptr; } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RifReaderEclipseSummary::open(const QString& headerFileName, const QStringList& dataFileNames) +bool RifReaderEclipseSummary::open(const QString& headerFileName, bool includeRestartFiles) { assert(m_ecl_sum == NULL); - if (headerFileName.isEmpty() || dataFileNames.size() == 0) return false; - - assert(!headerFileName.isEmpty()); - assert(dataFileNames.size() > 0); - - stringlist_type* dataFiles = stringlist_alloc_new(); - for (int i = 0; i < dataFileNames.size(); i++) - { - stringlist_append_copy(dataFiles, RiaStringEncodingTools::toNativeEncoded(dataFileNames[i]).data()); - } - - std::string itemSeparatorInVariableNames = ":"; - m_ecl_sum = ecl_sum_fread_alloc(RiaStringEncodingTools::toNativeEncoded(headerFileName).data(), dataFiles, itemSeparatorInVariableNames.data(), false); - - stringlist_free(dataFiles); + m_ecl_sum = openEclSum(headerFileName, includeRestartFiles); if (m_ecl_sum) { m_timeSteps.clear(); m_ecl_SmSpec = ecl_sum_get_smspec(m_ecl_sum); - - for ( int time_index = 0; time_index < timeStepCount(); time_index++ ) - { - time_t sim_time = ecl_sum_iget_sim_time(m_ecl_sum, time_index); - m_timeSteps.push_back(sim_time); - } + m_timeSteps = getTimeSteps(m_ecl_sum); buildMetaData(); @@ -93,6 +132,86 @@ bool RifReaderEclipseSummary::open(const QString& headerFileName, const QStringL return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifReaderEclipseSummary::getRestartFiles(const QString& headerFileName, bool* hasWarnings) +{ + CVF_ASSERT(hasWarnings); + + std::vector restartFiles; + m_warnings.clear(); + *hasWarnings = false; + + RifRestartFileInfo currFile; + currFile.fileName = headerFileName; + while(!currFile.fileName.isEmpty()) + { + // Due to a weakness in libecl regarding restart summary header file selection, + // do some extra checking + { + QString formattedHeaderExtension = ".FSMSPEC"; + QString nonformattedHeaderExtension = ".SMSPEC"; + QString formattedDataFileExtension = ".FUNSMRY"; + + if (currFile.fileName.endsWith(nonformattedHeaderExtension, Qt::CaseInsensitive)) + { + QString formattedHeaderFile = currFile.fileName; + formattedHeaderFile.replace(nonformattedHeaderExtension, formattedHeaderExtension, Qt::CaseInsensitive); + QString formattedDateFile = currFile.fileName; + formattedDateFile.replace(nonformattedHeaderExtension, formattedDataFileExtension, Qt::CaseInsensitive); + + QFileInfo nonformattedHeaderFileInfo = QFileInfo(currFile.fileName); + QFileInfo formattedHeaderFileInfo = QFileInfo(formattedHeaderFile); + QFileInfo formattedDateFileInfo = QFileInfo(formattedDateFile); + if (formattedHeaderFileInfo.lastModified() < nonformattedHeaderFileInfo.lastModified() && + formattedHeaderFileInfo.exists() && !formattedDateFileInfo.exists()) + { + m_warnings.push_back(QString("RifReaderEclipseSummary: Formatted summary header file without an\n") + + QString("associated data file detected.\n") + + QString("This may cause a failure reading summary origin data.\n") + + QString("To avoid this problem, please delete or rename the.FSMSPEC file.")); + *hasWarnings = true; + break; + } + } + QString prevFile = currFile.fileName; + currFile = getRestartFile(currFile.fileName); + + // Fix to stop potential infinite loop + if (currFile.fileName == prevFile) + { + m_warnings.push_back("RifReaderEclipseSummary: Restart file reference loop detected"); + *hasWarnings = true; + break; + } + + } + + if (!currFile.fileName.isEmpty()) + restartFiles.push_back(currFile); + } + return restartFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifRestartFileInfo RifReaderEclipseSummary::getFileInfo(const QString& headerFileName) +{ + RifRestartFileInfo fileInfo; + ecl_sum_type* ecl_sum = openEclSum(headerFileName, false); + std::vector timeSteps = getTimeSteps(ecl_sum); + if (timeSteps.size() > 0) + { + fileInfo.fileName = headerFileName; + fileInfo.startDate = timeSteps.front(); + fileInfo.endDate = timeSteps.back(); + } + closeEclSum(ecl_sum); + return fileInfo; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -326,6 +445,48 @@ void RifReaderEclipseSummary::buildMetaData() } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +time_t getStartDate(ecl_file_type * header) +{ + time_t startDate = 0; + ecl_kw_type *startdat = ecl_file_iget_named_kw(header, STARTDAT_KW, 0); + if (startdat) + { + int * date = ecl_kw_get_int_ptr(startdat); + startDate = ecl_util_make_date(date[STARTDAT_DAY_INDEX], + date[STARTDAT_MONTH_INDEX], + date[STARTDAT_YEAR_INDEX]); + } + return startDate; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifRestartFileInfo RifReaderEclipseSummary::getRestartFile(const QString& headerFileName) +{ + ecl_sum_type* ecl_sum = openEclSum(headerFileName, true); + + const ecl_smspec_type* smspec = ecl_sum ? ecl_sum_get_smspec(ecl_sum) : nullptr; + const char* rstCase = smspec ? ecl_smspec_get_restart_case(smspec) : nullptr; + QString restartCase = rstCase? RiaFilePathTools::canonicalPath(RiaStringEncodingTools::fromNativeEncoded(rstCase)) : ""; + closeEclSum(ecl_sum); + + if (!restartCase.isEmpty()) + { + QString path = QFileInfo(restartCase).dir().path(); + QString restartBase = QDir(restartCase).dirName(); + + char* smspec_header = ecl_util_alloc_exfilename(path.toStdString().data(), restartBase.toStdString().data(), ECL_SUMMARY_HEADER_FILE, false /*unformatted*/, 0); + QString restartFileName = RiaFilePathTools::toInternalSeparator(RiaStringEncodingTools::fromNativeEncoded(smspec_header)); + util_safe_free(smspec_header); + + return getFileInfo(restartFileName); + } + return RifRestartFileInfo(); +} //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h index 2162c38314..88f0cf228f 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseSummary.h +++ b/ApplicationCode/FileInterface/RifReaderEclipseSummary.h @@ -21,12 +21,30 @@ #include "RifEclipseSummaryAddress.h" #include "RifSummaryReaderInterface.h" +#include +#include + #include #include #include -class QString; -class QStringList; + +//================================================================================================== +// +// +//================================================================================================== +class RifRestartFileInfo +{ +public: + RifRestartFileInfo() : startDate(0), endDate(0) {} + RifRestartFileInfo(const QString& _fileName, time_t _startDate, time_t _endDate) : + fileName(_fileName), startDate(_startDate), endDate(_endDate) {} + bool valid() { return !fileName.isEmpty(); } + + QString fileName; + time_t startDate; + time_t endDate; +}; //================================================================================================== // @@ -38,17 +56,23 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface RifReaderEclipseSummary(); ~RifReaderEclipseSummary(); - bool open(const QString& headerFileName, const QStringList& dataFileNames); + bool open(const QString& headerFileName, bool includeRestartFiles); + + std::vector getRestartFiles(const QString& headerFileName, bool* hasWarnings); + RifRestartFileInfo getFileInfo(const QString& headerFileName); virtual const std::vector& timeSteps(const RifEclipseSummaryAddress& resultAddress) const override; virtual bool values(const RifEclipseSummaryAddress& resultAddress, std::vector* values) const override; virtual std::string unitName(const RifEclipseSummaryAddress& resultAddress) const override; + QStringList warnings() const { return m_warnings; } + private: int timeStepCount() const; int indexFromAddress(const RifEclipseSummaryAddress& resultAddress) const; void buildMetaData(); + RifRestartFileInfo getRestartFile(const QString& headerFileName); private: // Taken from ecl_sum.h @@ -60,5 +84,7 @@ class RifReaderEclipseSummary : public RifSummaryReaderInterface std::vector m_timeSteps; std::map m_resultAddressToErtNodeIdx; + + QStringList m_warnings; }; diff --git a/ApplicationCode/FileInterface/RifReaderMockModel.cpp b/ApplicationCode/FileInterface/RifReaderMockModel.cpp index 38e1bf2c2e..c46c629a51 100644 --- a/ApplicationCode/FileInterface/RifReaderMockModel.cpp +++ b/ApplicationCode/FileInterface/RifReaderMockModel.cpp @@ -124,7 +124,7 @@ bool RifReaderMockModel::dynamicResult(const QString& result, RiaDefines::Porosi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderMockModel::RifReaderMockModel() : m_reservoir(NULL) +RifReaderMockModel::RifReaderMockModel() : m_reservoir(nullptr) { /* m_cellResults.push_back("Dummy results"); diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp index 13587f0f3b..edff203d97 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.cpp @@ -19,26 +19,36 @@ #include "RifStimPlanXmlReader.h" #include "RiaEclipseUnitTools.h" -#include "RigStimPlanFractureDefinition.h" +#include "RiaFractureDefines.h" #include "RiaLogging.h" +#include "RigStimPlanFractureDefinition.h" #include #include #include // Needed for HUGE_VAL on Linux + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +bool hasNegativeValues(std::vector xs); + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::ref RifStimPlanXmlReader::readStimPlanXMLFile(const QString& stimPlanFileName, - double conductivityScalingFactor, + double conductivityScalingFactor, + double xScaleFactor, + double yScaleFactor, + double wellPathInterationY, + MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit, QString * errorMessage) { RiaLogging::info(QString("Starting to open StimPlan XML file: '%1'").arg(stimPlanFileName)); - RiaEclipseUnitTools::UnitSystemType unitSystem = RiaEclipseUnitTools::UNITS_UNKNOWN; cvf::ref stimPlanFileData = new RigStimPlanFractureDefinition; - size_t startingNegXsValues = 0; { QFile dataFile(stimPlanFileName); if (!dataFile.open(QFile::ReadOnly)) @@ -50,9 +60,13 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil QXmlStreamReader xmlStream; xmlStream.setDevice(&dataFile); xmlStream.readNext(); - startingNegXsValues = readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), unitSystem); + readStimplanGridAndTimesteps(xmlStream, stimPlanFileData.p(), mirrorMode, requiredUnit); + + if(xScaleFactor != 1.0) stimPlanFileData->scaleXs(xScaleFactor); + if(yScaleFactor != 1.0) stimPlanFileData->scaleYs(yScaleFactor, wellPathInterationY); + + RiaEclipseUnitTools::UnitSystemType unitSystem = stimPlanFileData->unitSet(); - stimPlanFileData->setUnitSet(unitSystem); if (unitSystem != RiaEclipseUnitTools::UNITS_UNKNOWN) RiaLogging::info(QString("Setting unit system for StimPlan fracture template %1 to %2").arg(stimPlanFileName).arg(unitSystem.uiText())); else @@ -68,9 +82,9 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil } - size_t numberOfDepthValues = stimPlanFileData->depthCount(); - RiaLogging::debug(QString("Grid size X: %1, Y: %2").arg(QString::number(stimPlanFileData->gridXCount()), - QString::number(numberOfDepthValues))); + size_t numberOfYValues = stimPlanFileData->yCount(); + RiaLogging::debug(QString("Grid size X: %1, Y: %2").arg(QString::number(stimPlanFileData->xCount()), + QString::number(numberOfYValues))); size_t numberOfTimeSteps = stimPlanFileData->timeSteps().size(); RiaLogging::debug(QString("Number of time-steps: %1").arg(numberOfTimeSteps)); @@ -108,8 +122,9 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil { double timeStepValue = getAttributeValueDouble(xmlStream2, "value"); - std::vector> propertyValuesAtTimestep = getAllDepthDataAtTimeStep(xmlStream2, startingNegXsValues); - + std::vector> propertyValuesAtTimestep = + stimPlanFileData->generateDataLayoutFromFileDataLayout(getAllDepthDataAtTimeStep(xmlStream2)); + bool valuesOK = stimPlanFileData->numberOfParameterValuesOK(propertyValuesAtTimestep); if (!valuesOK) { @@ -117,8 +132,20 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil return nullptr; } - stimPlanFileData->setDataAtTimeValue(parameter, unit, propertyValuesAtTimestep, timeStepValue, conductivityScalingFactor); - + if (parameter.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) + { + // Scale all parameters containing conductivity + + for (auto& dataAtDepth : propertyValuesAtTimestep) + { + for (auto& dataValue : dataAtDepth) + { + dataValue *= conductivityScalingFactor; + } + } + } + + stimPlanFileData->setDataAtTimeValue(parameter, unit, propertyValuesAtTimestep, timeStepValue); } } } @@ -140,17 +167,17 @@ cvf::ref RifStimPlanXmlReader::readStimPlanXMLFil RiaLogging::info(QString("Successfully read XML file: '%1'").arg(stimPlanFileName)); } - return stimPlanFileData; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData, RiaEclipseUnitTools::UnitSystemType& unit) +void RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, + RigStimPlanFractureDefinition* stimPlanFileData, + MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit) { - - size_t startNegValuesXs = 0; size_t startNegValuesYs = 0; QString gridunit = "unknown"; @@ -163,25 +190,65 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS if (xmlStream.isStartElement()) { + RiaEclipseUnitTools::UnitSystem destinationUnit = requiredUnit; + if (xmlStream.name() == "grid") { gridunit = getAttributeValueString(xmlStream, "uom"); + + if (gridunit == "m") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_METRIC; + else if (gridunit == "ft") stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_FIELD; + else stimPlanFileData->m_unitSet = RiaEclipseUnitTools::UNITS_UNKNOWN; + + if (destinationUnit == RiaEclipseUnitTools::UNITS_UNKNOWN) + { + // Use file unit set if requested unit is unknown + destinationUnit = stimPlanFileData->m_unitSet; + } + + double tvdToTopPerfFt = getAttributeValueDouble(xmlStream, "TVDToTopPerfFt"); + double tvdToBotPerfFt = getAttributeValueDouble(xmlStream, "TVDToBottomPerfFt"); + + double tvdToTopPerfRequestedUnit = RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UNITS_FIELD, destinationUnit, tvdToTopPerfFt); + double tvdToBotPerfRequestedUnit = RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UNITS_FIELD, destinationUnit, tvdToBotPerfFt); + + stimPlanFileData->setTvdToTopPerf(tvdToTopPerfRequestedUnit); + stimPlanFileData->setTvdToBottomPerf(tvdToBotPerfRequestedUnit); } if (xmlStream.name() == "xs") { - std::vector gridValues; - getGriddingValues(xmlStream, gridValues, startNegValuesXs); - stimPlanFileData->setGridXs(gridValues); + std::vector gridValuesXs; + { + size_t dummy; + std::vector gridValues; + getGriddingValues(xmlStream, gridValues, dummy); + + gridValuesXs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues); + } + + stimPlanFileData->m_fileXs = gridValuesXs; + + stimPlanFileData->generateXsFromFileXs(mirrorMode == MIRROR_AUTO ? !hasNegativeValues(gridValuesXs) : (bool)mirrorMode); } else if (xmlStream.name() == "ys") { - std::vector gridValues; - getGriddingValues(xmlStream, gridValues, startNegValuesYs); - stimPlanFileData->setGridYs(gridValues); + std::vector gridValuesYs; + { + std::vector gridValues; + getGriddingValues(xmlStream, gridValues, startNegValuesYs); + + gridValuesYs = RifStimPlanXmlReader::valuesInRequiredUnitSystem(stimPlanFileData->m_unitSet, destinationUnit, gridValues); + } - stimPlanFileData->reorderYgridToDepths(); + // Reorder and change sign + std::vector ys; + for (double y : gridValuesYs) + { + ys.insert(ys.begin(), -y); + } + stimPlanFileData->m_Ys = ys; } else if (xmlStream.name() == "time") @@ -192,21 +259,16 @@ size_t RifStimPlanXmlReader::readStimplanGridAndTimesteps(QXmlStreamReader &xmlS } } - if (gridunit == "m") unit = RiaEclipseUnitTools::UNITS_METRIC; - else if (gridunit == "ft") unit = RiaEclipseUnitTools::UNITS_FIELD; - else unit = RiaEclipseUnitTools::UNITS_UNKNOWN; - if (startNegValuesYs > 0) { RiaLogging::error(QString("Negative depth values detected in XML file")); } - return startNegValuesXs; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream, size_t startingNegValuesXs) +std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream) { std::vector> propertyValuesAtTimestep; @@ -227,14 +289,10 @@ std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeSte QStringList splitted = depthDataStr.split(' '); for (int i = 0; i < splitted.size(); i++) { - if (i < static_cast(startingNegValuesXs)) continue; - else + QString value = splitted[i]; + if ( value != "") { - QString value = splitted[i]; - if ( value != "") - { - propertyValuesAtDepth.push_back(value.toDouble()); - } + propertyValuesAtDepth.push_back(value.toDouble()); } } } @@ -245,6 +303,56 @@ std::vector> RifStimPlanXmlReader::getAllDepthDataAtTimeSte } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifStimPlanXmlReader::valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + const std::vector& values) +{ + if (sourceUnit == RiaEclipseUnitTools::UNITS_FIELD && requiredUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + std::vector convertedValues; + for (const auto &valueInFeet : values) + { + convertedValues.push_back(RiaEclipseUnitTools::feetToMeter(valueInFeet)); + } + + return convertedValues; + } + else if (sourceUnit == RiaEclipseUnitTools::UNITS_METRIC && requiredUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + std::vector convertedValues; + for (const auto &valueInMeter : values) + { + convertedValues.push_back(RiaEclipseUnitTools::meterToFeet(valueInMeter)); + } + + return convertedValues; + } + + return values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RifStimPlanXmlReader::valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + double value) +{ + if (sourceUnit == RiaEclipseUnitTools::UNITS_FIELD && requiredUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + return RiaEclipseUnitTools::feetToMeter(value); + } + else if (sourceUnit == RiaEclipseUnitTools::UNITS_METRIC && requiredUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + return RiaEclipseUnitTools::meterToFeet(value); + } + + return value; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -256,11 +364,8 @@ void RifStimPlanXmlReader::getGriddingValues(QXmlStreamReader &xmlStream, std::v if (value.size() > 0) { double gridValue = value.toDouble(); - if (gridValue > -1e-5) //tolerance of 1e-5 - { - gridValues.push_back(gridValue); - } - else startNegValues++; + gridValues.push_back(gridValue); + if(gridValue < -RigStimPlanFractureDefinition::THRESHOLD_VALUE) startNegValues++; } } } @@ -297,6 +402,10 @@ QString RifStimPlanXmlReader::getAttributeValueString(QXmlStreamReader &xmlStrea return parameterValue; } - - - +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +bool hasNegativeValues(std::vector xs) +{ + return xs[0] < -RigStimPlanFractureDefinition::THRESHOLD_VALUE; +} diff --git a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h index 0f0c54b5dd..3489930d2e 100644 --- a/ApplicationCode/FileInterface/RifStimPlanXmlReader.h +++ b/ApplicationCode/FileInterface/RifStimPlanXmlReader.h @@ -33,17 +33,34 @@ class QXmlStreamReader; class RifStimPlanXmlReader { public: - static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, double conductivityScalingFactor, QString * errorMessage); + enum MirrorMode { MIRROR_OFF = 0, MIRROR_ON = 1, MIRROR_AUTO = 2}; + + static cvf::ref readStimPlanXMLFile(const QString& stimPlanFileName, + double conductivityScalingFactor, + double xScaleFactor, + double yScaleFactor, + double wellPathIntersectionY, + MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit, + QString * errorMessage); private: - static size_t readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, RigStimPlanFractureDefinition* stimPlanFileData, RiaEclipseUnitTools::UnitSystemType& unit); + static void readStimplanGridAndTimesteps(QXmlStreamReader &xmlStream, + RigStimPlanFractureDefinition* stimPlanFileData, + MirrorMode mirrorMode, + RiaEclipseUnitTools::UnitSystem requiredUnit); static double getAttributeValueDouble(QXmlStreamReader &xmlStream, QString parameterName); static QString getAttributeValueString(QXmlStreamReader &xmlStream, QString parameterName); static void getGriddingValues(QXmlStreamReader &xmlStream, std::vector& gridValues, size_t& startNegValues); - static std::vector> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream, size_t startingNegValuesXs); - -}; + static std::vector> getAllDepthDataAtTimeStep(QXmlStreamReader &xmlStream); + static std::vector valuesInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + const std::vector& values); + static double valueInRequiredUnitSystem(RiaEclipseUnitTools::UnitSystem sourceUnit, + RiaEclipseUnitTools::UnitSystem requiredUnit, + double value); +}; diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp new file mode 100644 index 0000000000..9cb9c54d82 --- /dev/null +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.cpp @@ -0,0 +1,477 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RifSummaryCaseRestartSelector.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" +#include "RiaFilePathTools.h" +#include "RiaLogging.h" + +#include "RicSummaryCaseRestartDialog.h" + +#include "RifEclipseSummaryTools.h" +#include "RifReaderEclipseSummary.h" + +#include "cafProgressInfo.h" + +#include +#include + +#include +#include +#include +#include + + +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +template +bool vectorContains(const std::vector& vector, T item) +{ + for (const auto& i : vector) + { + if (i == item) return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// INternal function +//-------------------------------------------------------------------------------------------------- +RicSummaryCaseRestartDialog::ImportOptions mapReadOption(RiaPreferences::SummaryRestartFilesImportMode mode) +{ + return + mode == RiaPreferences::SummaryRestartFilesImportMode::NOT_IMPORT ? RicSummaryCaseRestartDialog::ImportOptions::NOT_IMPORT : + mode == RiaPreferences::SummaryRestartFilesImportMode::SEPARATE_CASES ? RicSummaryCaseRestartDialog::ImportOptions::SEPARATE_CASES : + RicSummaryCaseRestartDialog::ImportOptions::IMPORT_ALL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseRestartSelector::RifSummaryCaseRestartSelector() +{ + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + m_showDialog = prefs->summaryRestartFilesShowImportDialog(); + m_defaultSummaryImportMode = mapReadOption(prefs->summaryImportMode()); + m_defaultGridImportMode = mapReadOption(prefs->gridImportMode()); + + //m_buildGridFileList = false; + m_gridFiles.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseRestartSelector::~RifSummaryCaseRestartSelector() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::determineFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles) +{ + std::vector files; + for (QString f : initialSummaryFiles) + { + RifSummaryCaseFileImportInfo importInfo(f, ""); + importInfo.setFailOnSummaryFileError(true); + files.push_back(importInfo); + + } + determineFilesToImport(files); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::determineFilesToImportFromGridFiles(const QStringList& initialGridFiles) +{ + std::vector files; + for (QString f : initialGridFiles) + { + RifSummaryCaseFileImportInfo importInfo(getSummaryFileFromGridFile(f), f); + importInfo.setFailOnSummaryFileError(false); + files.push_back(importInfo); + } + determineFilesToImport(files); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::showDialog(bool show) +{ + m_showDialog = show; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RifSummaryCaseRestartSelector::summaryFileInfos() const +{ + return m_summaryFileInfos; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RifSummaryCaseRestartSelector::gridCaseFiles() const +{ + return m_gridFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::determineFilesToImport(const std::vector& initialFiles) +{ + std::vector fileInfos; + if (m_showDialog) + { + bool enableApplyToAllField = initialFiles.size() > 1; + determineFilesToImportByAskingUser(initialFiles, enableApplyToAllField); + } + else + { + determineFilesToImportUsingPrefs(initialFiles); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::determineFilesToImportByAskingUser(const std::vector& initialFiles, + bool enableApplyToAllField) +{ + RicSummaryCaseRestartDialogResult lastResult; + + m_summaryFileInfos.clear(); + m_gridFiles.clear(); + m_summaryFileErrors.clear(); + + caf::ProgressInfo progress(initialFiles.size(), QString("Importing files")); + for (const RifSummaryCaseFileImportInfo& initialFile : initialFiles) + { + RicSummaryCaseRestartDialogResult result = RicSummaryCaseRestartDialog::openDialog(initialFile.summaryFileName(), + initialFile.gridFileName(), + initialFile.failOnSummaryFileError(), + enableApplyToAllField, + m_defaultSummaryImportMode, + m_defaultGridImportMode, + &lastResult); + + if (result.status == RicSummaryCaseRestartDialogResult::SUMMARY_CANCELLED) + { + // Cancel pressed, cancel everything and return early + m_summaryFileInfos.clear(); + m_gridFiles.clear(); + m_summaryFileErrors.clear(); + return; + } + + if (result.status == RicSummaryCaseRestartDialogResult::SUMMARY_ERROR || + result.status == RicSummaryCaseRestartDialogResult::SUMMARY_WARNING) + { + // A summary import failure occurred with one of the files. The others may still have worked. + m_summaryFileErrors.push_back(initialFile.summaryFileName()); + } + else + { + for (const QString& file : result.summaryFiles) + { + RifSummaryCaseFileResultInfo resultFileInfo(file, result.summaryImportOption == RicSummaryCaseRestartDialog::IMPORT_ALL); + if (!vectorContains(m_summaryFileInfos, resultFileInfo)) + { + m_summaryFileInfos.push_back(resultFileInfo); + } + } + } + + if (result.status != RicSummaryCaseRestartDialogResult::SUMMARY_ERROR) + { + lastResult = result; + + for (const QString& gridFile : result.gridFiles) + { + m_gridFiles.push_back(gridFile); + } + } + + progress.incrementProgress(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseRestartSelector::determineFilesToImportUsingPrefs(const std::vector& initialFiles) +{ + RicSummaryCaseRestartDialogResult lastResult; + + m_summaryFileInfos.clear(); + m_gridFiles.clear(); + m_summaryFileErrors.clear(); + + caf::ProgressInfo progress(initialFiles.size(), QString("Importing files")); + for (const RifSummaryCaseFileImportInfo& initialFile : initialFiles) + { + QString initialSummaryFile = RiaFilePathTools::toInternalSeparator(initialFile.summaryFileName()); + QString initialGridFile = RiaFilePathTools::toInternalSeparator(initialFile.gridFileName()); + bool handleSummaryFile = false; + bool handleGridFile = !initialGridFile.isEmpty(); + + RifReaderEclipseSummary reader; + if (!initialSummaryFile.isEmpty()) + { + RifRestartFileInfo fileInfo = reader.getFileInfo(initialSummaryFile); + if (!fileInfo.valid()) + { + m_summaryFileErrors.push_back(initialSummaryFile); + if (initialFile.failOnSummaryFileError()) + { + handleGridFile = false; + } + } + else + { + handleSummaryFile = true; + } + } + + if (handleSummaryFile) + { + if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::IMPORT_ALL) + { + m_summaryFileInfos.push_back(RifSummaryCaseFileResultInfo(initialSummaryFile, true)); + } + else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::NOT_IMPORT) + { + m_summaryFileInfos.push_back(RifSummaryCaseFileResultInfo(initialSummaryFile, false)); + } + else if (m_defaultSummaryImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) + { + m_summaryFileInfos.push_back(RifSummaryCaseFileResultInfo(initialSummaryFile, false)); + bool hasWarnings = false; + std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); + for (const auto& rfi : restartFileInfos) + { + RifSummaryCaseFileResultInfo resultFileInfo(RiaFilePathTools::toInternalSeparator(rfi.fileName), false); + if (!vectorContains(m_summaryFileInfos, resultFileInfo)) + { + m_summaryFileInfos.push_back(resultFileInfo); + } + } + } + } + + if (handleGridFile) + { + m_gridFiles.push_back(initialGridFile); + + if (m_defaultGridImportMode == RicSummaryCaseRestartDialog::SEPARATE_CASES) + { + RifReaderEclipseSummary reader; + bool hasWarnings = false; + std::vector restartFileInfos = reader.getRestartFiles(initialSummaryFile, &hasWarnings); + for (const auto& rfi : restartFileInfos) + { + QString gridFileName = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(rfi.fileName); + if (!m_gridFiles.contains(gridFileName) && QFileInfo(gridFileName).exists()) + { + m_gridFiles.push_back(gridFileName); + } + } + + if (hasWarnings) + { + for (const QString& warning : reader.warnings()) RiaLogging::error(warning); + } + } + } + + progress.incrementProgress(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseRestartSelector::foundErrors() const +{ + return !m_summaryFileErrors.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QStringList& RifSummaryCaseRestartSelector::summaryFilesWithErrors() const +{ + return m_summaryFileErrors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifSummaryCaseRestartSelector::createCombinedErrorMessage() const +{ + QString errorMessage; + if (!m_summaryFileErrors.empty()) + { + errorMessage = QString("Failed to import the following summary file"); + if (m_summaryFileErrors.size() > 1) + { + errorMessage += QString("s"); + } + errorMessage += QString(":\n"); + for (const QString& fileWarning : m_summaryFileErrors) + { + errorMessage += fileWarning + QString("\n"); + } + } + return errorMessage; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RifSummaryCaseRestartSelector::getSummaryFilesFromGridFiles(const QStringList& gridFiles) +{ + QStringList summaryFiles; + + // Find summary header file names from eclipse case file names + for (const auto& gridFile : gridFiles) + { + QString sumFile = getSummaryFileFromGridFile(gridFile); + if (!sumFile.isEmpty()) + { + summaryFiles.push_back(sumFile); + } + } + return summaryFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RifSummaryCaseRestartSelector::getSummaryFileFromGridFile(const QString& gridFile) +{ + // Find summary header file names from eclipse case file names + if (!gridFile.isEmpty()) + { + QString summaryHeaderFile; + bool formatted; + + RifEclipseSummaryTools::findSummaryHeaderFile(gridFile, &summaryHeaderFile, &formatted); + + if (!summaryHeaderFile.isEmpty()) + { + return summaryHeaderFile; + } + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseFileImportInfo::RifSummaryCaseFileImportInfo(const QString& summaryFileName, + const QString& gridFileName) + : m_summaryFileName(summaryFileName) + , m_gridFileName(gridFileName) + , m_failOnSummaryFileImportError(false) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileImportInfo::summaryFileName() const +{ + return m_summaryFileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileImportInfo::gridFileName() const +{ + return m_gridFileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileImportInfo::failOnSummaryFileError() const +{ + return m_failOnSummaryFileImportError; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RifSummaryCaseFileImportInfo::setFailOnSummaryFileError(bool failOnSummaryFileImportError) +{ + m_failOnSummaryFileImportError = failOnSummaryFileImportError; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifSummaryCaseFileResultInfo::RifSummaryCaseFileResultInfo(const QString& summaryFileName, bool includeRestartFiles) + : m_summaryFileName(summaryFileName) + , m_includeRestartFiles(includeRestartFiles) +{ + CVF_ASSERT(!m_summaryFileName.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RifSummaryCaseFileResultInfo::summaryFileName() const +{ + return m_summaryFileName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileResultInfo::includeRestartFiles() const +{ + return m_includeRestartFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileResultInfo::operator<(const RifSummaryCaseFileResultInfo& other) const +{ + return m_summaryFileName < other.summaryFileName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifSummaryCaseFileResultInfo::operator==(const RifSummaryCaseFileResultInfo& other) const +{ + return m_summaryFileName == other.summaryFileName(); +} diff --git a/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h new file mode 100644 index 0000000000..bf6d1a69ff --- /dev/null +++ b/ApplicationCode/FileInterface/RifSummaryCaseRestartSelector.h @@ -0,0 +1,109 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RiaPreferences.h" +#include "RicSummaryCaseRestartDialog.h" + +#include +#include + +#include +#include + +class RifSummaryCaseFileImportInfo; +class RifSummaryCaseFileResultInfo; + +//================================================================================================== +// +// +//================================================================================================== +class RifSummaryCaseRestartSelector +{ +public: + RifSummaryCaseRestartSelector(); + ~RifSummaryCaseRestartSelector(); + + void determineFilesToImportFromSummaryFiles(const QStringList& initialSummaryFiles); + void determineFilesToImportFromGridFiles(const QStringList& initialGridFiles); + + void showDialog(bool show); + std::vector summaryFileInfos() const; + QStringList gridCaseFiles() const; + bool foundErrors() const; + const QStringList& summaryFilesWithErrors() const; + QString createCombinedErrorMessage() const; + + static QStringList getSummaryFilesFromGridFiles(const QStringList& gridFiles); + static QString getSummaryFileFromGridFile(const QString& gridFile); + +private: + void determineFilesToImport(const std::vector& initialFiles); + void determineFilesToImportByAskingUser(const std::vector& initialFiles, bool enableApplyToAllField); + void determineFilesToImportUsingPrefs(const std::vector& initialFiles); + + bool m_showDialog; + RicSummaryCaseRestartDialog::ImportOptions m_defaultSummaryImportMode; + RicSummaryCaseRestartDialog::ImportOptions m_defaultGridImportMode; + + std::vector m_summaryFileInfos; + QStringList m_gridFiles; + QStringList m_summaryFileErrors; +}; + +//================================================================================================== +/// +//================================================================================================== +class RifSummaryCaseFileImportInfo +{ +public: + RifSummaryCaseFileImportInfo(const QString& summaryFileName, + const QString& gridFileName); + + const QString& summaryFileName() const; + const QString& gridFileName() const; + bool failOnSummaryFileError() const; + void setFailOnSummaryFileError(bool failOnSummaryFileImportError); + +private: + QString m_summaryFileName; + QString m_gridFileName; + bool m_failOnSummaryFileImportError; +}; + +//================================================================================================== +/// +//================================================================================================== +class RifSummaryCaseFileResultInfo +{ +public: + RifSummaryCaseFileResultInfo(const QString& summaryFileName, + bool includeRestartFiles); + + const QString& summaryFileName() const; + bool includeRestartFiles() const; + + bool operator<(const RifSummaryCaseFileResultInfo& other) const; + bool operator==(const RifSummaryCaseFileResultInfo& other) const; + +private: + QString m_summaryFileName; + bool m_includeRestartFiles; +}; + diff --git a/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp b/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp index 4c6e31b760..f4c7a99f7c 100644 --- a/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp +++ b/ApplicationCode/FileInterface/RifWellPathFormationReader.cpp @@ -19,7 +19,7 @@ #include "RifWellPathFormationReader.h" #include "RiaLogging.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include #include @@ -63,7 +63,7 @@ std::map> if (wellNames.empty() || formationNames.empty()) { - QMessageBox::warning(RiuMainWindow::instance(), "Import failure", + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Import failure", QString("Failed to parse %1 as a well pick file").arg(filePath)); RiaLogging::error(QString("Failed to parse %1 as a well pick file").arg(filePath)); @@ -71,7 +71,7 @@ std::map> } else if (!(mdIsPresent || tvdIsPresent)) { - QMessageBox::warning(RiuMainWindow::instance(), "Import failure", + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Import failure", QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath)); RiaLogging::error(QString("Failed to parse %1 as a well pick file. Neither MD or TVD is present.").arg(filePath)); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt index 2201832c4c..ed56edb9f3 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt +++ b/ApplicationCode/GeoMech/GeoMechDataModel/CMakeLists.txt @@ -1,15 +1,7 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (RigGeoMechDataModel) -include_directories( - ${LibCore_SOURCE_DIR} - ${cafTensor_SOURCE_DIR} - ../../ResultStatisticsCache - ../OdbReader -) - - add_library( ${PROJECT_NAME} RigFemPart.h RigFemPart.cpp @@ -38,4 +30,24 @@ add_library( ${PROJECT_NAME} RimGeoMechGeometrySelectionItem.cpp ) -target_link_libraries( ${PROJECT_NAME} LibCore cafTensor ResultStatisticsCache) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set( LINK_LIBRARIES + LibCore + + cafPdmCvf + cafTensor + cafUserInterface + CommonCode + + ResultStatisticsCache +) + +target_link_libraries( ${PROJECT_NAME} + ${LINK_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h index 794f2681a3..baf4a1f97f 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemFaceComparator.h @@ -26,12 +26,12 @@ class RigFemFaceComparator { public: - RigFemFaceComparator() : m_minMainFaceNodeIdx(INT_MAX), m_faceIdxToMinMainFaceNodeIdx(0) {} + RigFemFaceComparator() : m_minMainFaceNodeIdx(std::numeric_limits::max()), m_faceIdxToMinMainFaceNodeIdx(0) {} void setMainFace(const int* elmNodes, const int * localFaceIndices, int faceNodeCount) { m_canonizedMainFaceIdxes.resize(faceNodeCount); - m_minMainFaceNodeIdx = INT_MAX; + m_minMainFaceNodeIdx = std::numeric_limits::max(); m_faceIdxToMinMainFaceNodeIdx = 0; for(int fnIdx = 0; fnIdx < faceNodeCount; ++fnIdx) @@ -51,7 +51,7 @@ class RigFemFaceComparator if (faceNodeCount != static_cast(m_canonizedMainFaceIdxes.size())) return false; // Find min node index in face - int minNodeIdx = INT_MAX; + int minNodeIdx = std::numeric_limits::max(); int faceIdxToMinNodeIdx = 0; for (int fnIdx = 0; fnIdx < faceNodeCount; ++fnIdx) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h index bcc7c05df9..8653d2a7be 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemNativeVisibleCellsStatCalc.h @@ -93,6 +93,22 @@ class RigFemNativeVisibleCellsStatCalc : public RigStatisticsCalculator } } } + else if (m_resVarAddr.resultPosType == RIG_ELEMENT) + { + for (int pIdx = 0; pIdx < partCount; ++pIdx) + { + RigFemPart* part = m_caseData->femParts()->part(pIdx); + const std::vector& values = m_resultsData->resultValues(m_resVarAddr, pIdx, (int)timeStepIndex); + int elmCount = part->elementCount(); + + for (int elmIdx = 0; elmIdx < elmCount; ++elmIdx) + { + if (!(*m_cellVisibilities)[elmIdx]) continue; + + accumulator.addValue(values[elmIdx]); + } + } + } else { for (int pIdx = 0; pIdx < partCount; ++pIdx) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp index e4a5ba220a..2fb9b568f7 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.cpp @@ -365,7 +365,7 @@ void RigFemPart::findIntersectingCells(const cvf::BoundingBox& inputBB, std::vec } m_elementSearchTree = new cvf::BoundingBoxTree; - m_elementSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, NULL); + m_elementSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, nullptr); } m_elementSearchTree->findIntersections(inputBB, elementIndices); diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h index 5c856f5e45..09ae8d8dc6 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPart.h @@ -85,6 +85,7 @@ class RigFemPart : public cvf::Object cvf::Vec3f faceNormal(int elmentIndex, int faceIndex) const; const RigFemPartGrid* structGrid() const; + const std::vector& elementIdxToId() const { return m_elementId; } private: int m_elementPartId; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp index 372b7f2078..49c10dcc59 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.cpp @@ -22,6 +22,7 @@ #include "RigFemPart.h" #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -182,6 +183,28 @@ void RigFemPartGrid::generateStructGridData() cvf::Vec3i ijk = m_ijkPrElement[elmIdx]; m_elmIdxPrIJK.at(ijk[0], ijk[1], ijk[2]) = elmIdx; } + + // IJK bounding box + m_reservoirIJKBoundingBox.first = cvf::Vec3st(INT_MAX, INT_MAX, INT_MAX); + m_reservoirIJKBoundingBox.second = cvf::Vec3st(0, 0, 0); + cvf::Vec3st& min = m_reservoirIJKBoundingBox.first; + cvf::Vec3st& max = m_reservoirIJKBoundingBox.second; + + for (int elmIdx = 0; elmIdx < m_femPart->elementCount(); ++elmIdx) + { + RigElementType elementType = m_femPart->elementType(elmIdx); + size_t i, j, k; + if (elementType == HEX8P && ijkFromCellIndex(elmIdx, &i, &j, &k)) + { + if (i < min.x()) min.x() = i; + if (j < min.y()) min.y() = j; + if (k < min.z()) min.z() = k; + if (i > max.x()) max.x() = i; + if (j > max.y()) max.y() = j; + if (k > max.z()) max.z() = k; + } + } + } //-------------------------------------------------------------------------------------------------- @@ -287,6 +310,14 @@ cvf::Vec3i RigFemPartGrid::findMainIJKFaces(int elementIndex) const return ijkMainFaceIndices; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RigFemPartGrid::reservoirIJKBoundingBox() const +{ + return m_reservoirIJKBoundingBox; +} + //-------------------------------------------------------------------------------------------------- /// Find the face that is not perpFaceIdx or its opposite, and has normal closest to direction //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h index 20e511c569..810f66015d 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartGrid.h @@ -38,6 +38,8 @@ class RigFemPartGrid : public cvf::StructGridInterface virtual size_t gridPointCountK() const; cvf::Vec3i findMainIJKFaces(int elementIndex) const; + + std::pair reservoirIJKBoundingBox() const; private: void generateStructGridData(); @@ -93,7 +95,7 @@ class RigFemPartGrid : public cvf::StructGridInterface }; IJKArray m_elmIdxPrIJK; - + std::pair m_reservoirIJKBoundingBox; }; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 45a5088a6f..ece1c4d4cc 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -19,6 +19,7 @@ #include "RigFemPartResultsCollection.h" +#include "RifElementPropertyReader.h" #include "RifGeoMechReaderInterface.h" #ifdef USE_ODB_API @@ -33,6 +34,7 @@ #include "RigFemPartResults.h" #include "RigFemScalarResultFrames.h" #include "RigFormationNames.h" +#include "RigHexIntersectionTools.h" #include "RigStatisticsDataCache.h" #include "RimMainPlotCollection.h" @@ -57,18 +59,42 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection) +const std::string RigFemPartResultsCollection::FIELD_NAME_COMPACTION = "COMPACTION"; + +//-------------------------------------------------------------------------------------------------- +/// Internal definitions +//-------------------------------------------------------------------------------------------------- +class RefElement +{ +public: + size_t elementIdx; + float intersectionPointToCurrentNodeDistance; + cvf::Vec3f intersectionPoint; + std::vector elementFaceNodeIdxs; +}; + +static std::vector coordsFromNodeIndices(const RigFemPart& part, const std::vector& nodeIdxs); +static std::vector nodesForElement(const RigFemPart& part, size_t elementIdx); +static float horizontalDistance(const cvf::Vec3f& p1, const cvf::Vec3f& p2); +static void findReferenceElementForNode(const RigFemPart& part, size_t nodeIdx, size_t kRefLayer, RefElement *refElement); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartResultsCollection::RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, RifElementPropertyReader* elementPropertyReader, const RigFemPartCollection* femPartCollection) { CVF_ASSERT(readerInterface); + CVF_ASSERT(elementPropertyReader); m_readerInterface = readerInterface; + m_elementPropertyReader = elementPropertyReader; m_femParts = femPartCollection; m_femPartResults.resize(m_femParts->partCount()); std::vector stepNames = m_readerInterface->stepNames(); - for (int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx) + for (auto & femPartResult : m_femPartResults) { - m_femPartResults[pIdx] = new RigFemPartResults; - m_femPartResults[pIdx]->initResultSteps(stepNames); + femPartResult = new RigFemPartResults; + femPartResult->initResultSteps(stepNames); } m_cohesion = 10.0; @@ -118,6 +144,44 @@ RigFormationNames* RigFemPartResultsCollection::activeFormationNames() return m_activeFormationNamesData.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::addElementPropertyFiles(const std::vector& filenames) +{ + for (const QString& filename : filenames) + { + m_elementPropertyReader->addFile(filename.toStdString()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFemPartResultsCollection::removeElementPropertyFiles(const std::vector& filenames) +{ + std::vector addressesToRemove; + + for (const QString& filename : filenames) + { + std::vector fields = m_elementPropertyReader->fieldsInFile(filename.toStdString()); + + for (const std::string& field : fields) + { + addressesToRemove.push_back(RigFemResultAddress(RIG_ELEMENT, field, "")); + } + + m_elementPropertyReader->removeFile(filename.toStdString()); + } + + for (const RigFemResultAddress& address : addressesToRemove) + { + this->deleteResult(address); + } + + return addressesToRemove; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -133,7 +197,6 @@ void RigFemPartResultsCollection::setCalculationParameters(double cohesion, doub this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "DSM", RigFemResultAddress::ALL_TIME_LAPSES)); this->deleteResult(RigFemResultAddress(RIG_ELEMENT_NODAL, "SE", "FOS", RigFemResultAddress::ALL_TIME_LAPSES)); this->deleteResult(RigFemResultAddress(RIG_INTEGRATION_POINT, "SE", "FOS", RigFemResultAddress::ALL_TIME_LAPSES)); - } //-------------------------------------------------------------------------------------------------- @@ -155,16 +218,40 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in frames = calculateDerivedResult(partIndex, resVarAddr); if (frames) return frames; + if (resVarAddr.resultPosType == RIG_ELEMENT) + { + std::map> elementProperties = m_elementPropertyReader->readAllElementPropertiesInFileContainingField(resVarAddr.fieldName); + + std::vector resultsForEachComponent; + for (std::pair< std::string, std::vector> elem : elementProperties) + { + RigFemResultAddress addressForElement(RIG_ELEMENT, elem.first, ""); + RigFemScalarResultFrames* currentFrames = m_femPartResults[partIndex]->createScalarResult(addressForElement); + currentFrames->enableAsSingleFrameResult(); + currentFrames->frameData(0).swap(elem.second); + } + + frames = m_femPartResults[partIndex]->findScalarResult(resVarAddr); + if (frames) + { + return frames; + } + else + { + return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + } + } + // We need to read the data as bulk fields, and populate the correct scalar caches std::vector< RigFemResultAddress> resultAddressOfComponents = this->getResAddrToComponentsToRead(resVarAddr); - if (resultAddressOfComponents.size()) + if (!resultAddressOfComponents.empty()) { std::vector resultsForEachComponent; - for (size_t cIdx = 0; cIdx < resultAddressOfComponents.size(); ++cIdx) + for (const auto & resultAddressOfComponent : resultAddressOfComponents) { - resultsForEachComponent.push_back(m_femPartResults[partIndex]->createScalarResult(resultAddressOfComponents[cIdx])); + resultsForEachComponent.push_back(m_femPartResults[partIndex]->createScalarResult(resultAddressOfComponent)); } int frameCount = this->frameCount(); @@ -178,9 +265,9 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in for (int fIdx = 1; (size_t)fIdx < frameTimes.size() && fIdx < 2 ; ++fIdx) // Read only the second frame { std::vector*> componentDataVectors; - for (size_t cIdx = 0; cIdx < resultsForEachComponent.size(); ++cIdx) + for (auto & componentResult : resultsForEachComponent) { - componentDataVectors.push_back(&(resultsForEachComponent[cIdx]->frameData(stepIndex))); + componentDataVectors.push_back(&(componentResult->frameData(stepIndex))); } switch (resVarAddr.resultPosType) @@ -194,6 +281,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::findOrLoadScalarResult(in case RIG_INTEGRATION_POINT: m_readerInterface->readIntegrationPointField(resVarAddr.fieldName, partIndex, stepIndex, fIdx, &componentDataVectors); break; + default: + break; } } @@ -231,6 +320,7 @@ std::map > RigFemPartResultsCollection::sc { fieldCompNames = m_readerInterface->scalarNodeFieldAndComponentNames(); fieldCompNames["POR-Bar"]; + fieldCompNames[FIELD_NAME_COMPACTION]; } else if (resPos == RIG_ELEMENT_NODAL) { @@ -384,7 +474,13 @@ std::map > RigFemPartResultsCollection::sc fieldCompNames["ST"].push_back("TPQV"); fieldCompNames["ST"].push_back("FAULTMOB"); fieldCompNames["ST"].push_back("PCRIT"); - + } + else if (resPos == RIG_ELEMENT) + { + for (const std::string& field : m_elementPropertyReader->scalarElementFields()) + { + fieldCompNames[field]; + } } } @@ -413,7 +509,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateBarConvertedResu size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = 1.0e-5*srcFrameData[vIdx]; } @@ -447,20 +544,21 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateEnIpPorBarResult const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - if (!srcFrameData.size()) continue; // Create empty results if we have no POR result. + if (srcFrameData.empty()) continue; // Create empty results if we have no POR result. size_t valCount = femPart->elementNodeResultCount(); dstFrameData.resize(valCount, inf); int elementCount = femPart->elementCount(); + +#pragma omp parallel for schedule(dynamic) for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); - int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); - if (elmType == HEX8P) { + int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); @@ -489,7 +587,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult( frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName); + RigFemResultAddress resVarNative(resVarAddr.resultPosType, resVarAddr.fieldName, resVarAddr.componentName, RigFemResultAddress::NO_TIME_LAPSE, resVarAddr.refKLayerIndex); RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, resVarNative); RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); @@ -507,7 +605,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult( size_t valCount = srcFrameData.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx ) { dstFrameData[vIdx] = srcFrameData[vIdx] - baseFrameData[vIdx]; } @@ -583,7 +682,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSEM(in size_t valCount = sa11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = (sa11Data[vIdx] + sa22Data[vIdx] + sa33Data[vIdx])/3.0f; } @@ -625,7 +725,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSFI(int partInde size_t valCount = se1Data.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { float se1 = se1Data[vIdx]; float se3 = se3Data[vIdx]; @@ -678,16 +779,10 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDSM(int partInde size_t valCount = se1Data.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { - float se1 = se1Data[vIdx]; - float se3 = se3Data[vIdx]; - float pi_4 = 0.785398163397448309616f; - float rho = 2.0f * ( atan( sqrt(( se1 + cohPrTanFricAngle)/(se3 + cohPrTanFricAngle)) ) - pi_4); - - { - dstFrameData[vIdx] = tan(rho)/tanFricAng; - } + dstFrameData[vIdx] = dsm(se1Data[vIdx], se3Data[vIdx], tanFricAng, cohPrTanFricAngle); } frameCountProgress.incrementProgress(); @@ -722,7 +817,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateFOS(int partInde size_t valCount = dsmData.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { float dsm = dsmData[vIdx]; dstFrameData[vIdx] = 1.0f/dsm; @@ -766,7 +862,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateMeanStressSTM(in size_t valCount = st11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = (st11Data[vIdx] + st22Data[vIdx] + st33Data[vIdx])/3.0f; } @@ -814,7 +911,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDeviatoricStress size_t valCount = st11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { float stmVal = stmData[vIdx]; float st11Corr = st11Data[vIdx] - stmVal; @@ -868,7 +966,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateVolumetricStrain size_t valCount = ea11Data.size(); dstFrameData.resize(valCount); - for(size_t vIdx = 0; vIdx < valCount; ++vIdx) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = (ea11Data[vIdx] + ea22Data[vIdx] + ea33Data[vIdx]); } @@ -912,7 +1011,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDeviatoricStrain size_t valCount = ea11Data.size(); dstFrameData.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { dstFrameData[vIdx] = 0.666666666666667f*(ea11Data[vIdx] - ea33Data[vIdx]); } @@ -1004,6 +1104,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAlignedSt PCRITDat.resize(valCount); int elementCount = femPart->elementCount(); + +#pragma omp parallel for for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); @@ -1116,6 +1218,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSurfaceAngles(in Pinc.resize(valCount); int elementCount = femPart->elementCount(); +#pragma omp parallel for for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { RigElementType elmType = femPart->elementType(elmIdx); @@ -1235,7 +1338,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV s3inc.resize(valCount); s3azi.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for schedule(dynamic) + for ( long vIdx = 0; vIdx < static_cast(valCount); ++vIdx ) { caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); cvf::Vec3f principalDirs[3]; @@ -1253,7 +1357,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV else { s1inc[vIdx] = std::numeric_limits::infinity(); - s1azi[vIdx] = std::numeric_limits::infinity(); + s1azi[vIdx] = std::numeric_limits::infinity(); } if ( principals[1] != std::numeric_limits::infinity() ) @@ -1265,7 +1369,7 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStressV else { s2inc[vIdx] = std::numeric_limits::infinity(); - s2azi[vIdx] = std::numeric_limits::infinity(); + s2azi[vIdx] = std::numeric_limits::infinity(); } if ( principals[2] != std::numeric_limits::infinity() ) @@ -1339,7 +1443,8 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStrainV s2.resize(valCount); s3.resize(valCount); - for ( size_t vIdx = 0; vIdx < valCount; ++vIdx ) +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) { caf::Ten3f T(s11[vIdx], s22[vIdx], s33[vIdx], s12[vIdx], s23[vIdx], s13[vIdx]); cvf::Vec3f principalDirs[3]; @@ -1360,393 +1465,354 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculatePrincipalStrainV //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr) +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateCompactionValues(int partIndex, const RigFemResultAddress &resVarAddr) { - if (resVarAddr.isTimeLapse()) - { - return calculateTimeLapseResult(partIndex, resVarAddr); - } + CVF_ASSERT(resVarAddr.fieldName == FIELD_NAME_COMPACTION); - if(resVarAddr.resultPosType == RIG_ELEMENT_NODAL_FACE ) + caf::ProgressInfo frameCountProgress(this->frameCount() + 1, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName)); + + RigFemScalarResultFrames * u3Frames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "U", "U3")); + frameCountProgress.incrementProgress(); + + RigFemScalarResultFrames* compactionFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + + const RigFemPart* part = m_femParts->part(partIndex); + for (int t = 0; t < u3Frames->frameCount(); t++) { - if (resVarAddr.componentName == "Pazi" || resVarAddr.componentName == "Pinc") - { - return calculateSurfaceAngles(partIndex, resVarAddr); - } - else if (resVarAddr.componentName.empty()) - { - return nullptr; - } - else + std::vector& compactionFrame = compactionFrames->frameData(t); + size_t nodeCount = part->nodes().nodeIds.size(); + + frameCountProgress.incrementProgress(); + + compactionFrame.resize(nodeCount); + { - return calculateSurfaceAlignedStress(partIndex, resVarAddr); - } - } + // Make sure the AABB-tree is created before using OpenMP + cvf::BoundingBox bb; + std::vector refElementCandidates; - if (resVarAddr.fieldName == "SE" && resVarAddr.componentName == "SFI") - { - return calculateSFI(partIndex, resVarAddr); - } + part->findIntersectingCells(bb, &refElementCandidates); - if ( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "DSM" ) - { - return calculateDSM(partIndex, resVarAddr); - } + // Also make sure the struct grid is created, as this is required before using OpenMP + part->structGrid(); + } - if ( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "FOS" ) - { - return calculateFOS(partIndex, resVarAddr); - } +#pragma omp parallel for + for (long n = 0; n < static_cast(nodeCount); n++) + { + RefElement refElement; + findReferenceElementForNode(*part, n, resVarAddr.refKLayerIndex, &refElement); - if(resVarAddr.fieldName == "NE" && resVarAddr.componentName == "EV") - { - return calculateVolumetricStrain(partIndex, resVarAddr); - } + if (refElement.elementIdx != cvf::UNDEFINED_SIZE_T) + { + float shortestDist = std::numeric_limits::infinity(); + size_t closestRefNodeIdx = cvf::UNDEFINED_SIZE_T; - if ( resVarAddr.fieldName == "NE" && resVarAddr.componentName == "ED" ) - { - return calculateDeviatoricStrain(partIndex, resVarAddr); - } + for (size_t nodeIdx : refElement.elementFaceNodeIdxs) + { + float dist = horizontalDistance(refElement.intersectionPoint, part->nodes().coordinates[nodeIdx]); + if (dist < shortestDist) + { + shortestDist = dist; + closestRefNodeIdx = nodeIdx; + } + } - if(resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" ) - { - return calculateDeviatoricStress(partIndex, resVarAddr); + cvf::Vec3f currentNodeCoord = part->nodes().coordinates[n]; + if(currentNodeCoord.z() >= refElement.intersectionPoint.z()) + compactionFrame[n] = -(u3Frames->frameData(t)[n] - u3Frames->frameData(t)[closestRefNodeIdx]); + else + compactionFrame[n] = -(u3Frames->frameData(t)[closestRefNodeIdx] - u3Frames->frameData(t)[n]); + } + else + { + compactionFrame[n] = HUGE_VAL; + } + } } - if(resVarAddr.fieldName == "ST" && resVarAddr.componentName == "STM") - { - return calculateMeanStressSTM(partIndex, resVarAddr); - } + RigFemScalarResultFrames* requestedPrincipal = this->findOrLoadScalarResult(partIndex, resVarAddr); + return requestedPrincipal; +} - if(resVarAddr.fieldName == "SE" && resVarAddr.componentName == "SEM") - { - return calculateMeanStressSEM(partIndex, resVarAddr); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateNE(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - if (resVarAddr.fieldName == "S-Bar") - { - return calculateBarConvertedResult(partIndex, resVarAddr, "S"); - } + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "E", resVarAddr.componentName)); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - if (resVarAddr.fieldName == "POR-Bar") - { - if (resVarAddr.resultPosType == RIG_NODAL) - return calculateBarConvertedResult(partIndex, resVarAddr, "POR"); - else - return calculateEnIpPorBarResult(partIndex, resVarAddr); - } + frameCountProgress.incrementProgress(); - if((resVarAddr.fieldName == "NE") - && ( resVarAddr.componentName == "E11" - || resVarAddr.componentName == "E22" - || resVarAddr.componentName == "E33" - || resVarAddr.componentName == "E12" - || resVarAddr.componentName == "E13" - || resVarAddr.componentName == "E23")) + int frameCount = srcDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); + const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = srcFrameData.size(); + dstFrameData.resize(valCount); + +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) + { + dstFrameData[vIdx] = -srcFrameData[vIdx]; + } - RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "E", resVarAddr.componentName)); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - frameCountProgress.incrementProgress(); + } - int frameCount = srcDataFrames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcFrameData = srcDataFrames->frameData(fIdx); - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - size_t valCount = srcFrameData.size(); - dstFrameData.resize(valCount); + return dstDataFrames; +} - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) - { - dstFrameData[vIdx] = -srcFrameData[vIdx]; - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSE(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - frameCountProgress.incrementProgress(); - } + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); + frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - return dstDataFrames; - } + frameCountProgress.incrementProgress(); - if ( (resVarAddr.fieldName == "NE") - && ( resVarAddr.componentName == "E1" - || resVarAddr.componentName == "E2" - || resVarAddr.componentName == "E3") ) - { - return calculatePrincipalStrainValues(partIndex, resVarAddr); - } + const RigFemPart * femPart = m_femParts->part(partIndex); + float inf = std::numeric_limits::infinity(); - if ((resVarAddr.fieldName == "SE") - && ( resVarAddr.componentName == "S11" - || resVarAddr.componentName == "S22" - || resVarAddr.componentName == "S33" - || resVarAddr.componentName == "S12" - || resVarAddr.componentName == "S13" - || resVarAddr.componentName == "S23" )) + int frameCount = srcDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) { - caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); - - RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); - frameCountProgress.incrementProgress(); frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + const std::vector& srcSFrameData = srcDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize(valCount); - frameCountProgress.incrementProgress(); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); - const RigFemPart * femPart = m_femParts->part(partIndex); - float inf = std::numeric_limits::infinity(); + int elementCount = femPart->elementCount(); - int frameCount = srcDataFrames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) +#pragma omp parallel for + for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { - const std::vector& srcSFrameData = srcDataFrames->frameData(fIdx); - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize(valCount); + RigElementType elmType = femPart->elementType(elmIdx); - const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); + int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); - int elementCount = femPart->elementCount(); - for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + if (elmType == HEX8P) { - RigElementType elmType = femPart->elementType(elmIdx); - - int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); - - if (elmType == HEX8P) + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; - } + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; } - else + } + else + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - dstFrameData[elmNodResIdx] = inf; - } + dstFrameData[elmNodResIdx] = inf; } } - - frameCountProgress.incrementProgress(); } - return dstDataFrames; + frameCountProgress.incrementProgress(); } - if ( (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST" ) - && ( resVarAddr.componentName == "S1" - || resVarAddr.componentName == "S2" - || resVarAddr.componentName == "S3" - || resVarAddr.componentName == "S1inc" - || resVarAddr.componentName == "S1azi" - || resVarAddr.componentName == "S2inc" - || resVarAddr.componentName == "S2azi" - || resVarAddr.componentName == "S3inc" - || resVarAddr.componentName == "S3azi" ) - ) - { - return calculatePrincipalStressValues(partIndex, resVarAddr); - } + return dstDataFrames; +} - if ( resVarAddr.fieldName == "ST" - && ( resVarAddr.componentName == "S11" - || resVarAddr.componentName == "S22" - || resVarAddr.componentName == "S33" )) - { - caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateST_11_22_33(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); + frameCountProgress.incrementProgress(); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - const RigFemPart * femPart = m_femParts->part(partIndex); - int frameCount = srcSDataFrames->frameCount(); - - frameCountProgress.incrementProgress(); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + const RigFemPart * femPart = m_femParts->part(partIndex); + int frameCount = srcSDataFrames->frameCount(); - const float inf = std::numeric_limits::infinity(); + frameCountProgress.incrementProgress(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); - const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); - - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + const float inf = std::numeric_limits::infinity(); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize(valCount); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); + const std::vector& srcPORFrameData = srcPORDataFrames->frameData(fIdx); - int elementCount = femPart->elementCount(); - for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) - { - RigElementType elmType = femPart->elementType(elmIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + + size_t valCount = srcSFrameData.size(); + dstFrameData.resize(valCount); + + int elementCount = femPart->elementCount(); + +#pragma omp parallel for + for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + { + RigElementType elmType = femPart->elementType(elmIdx); - int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); + int elmNodeCount = RigFemTypes::elmentNodeCount(femPart->elementType(elmIdx)); - if (elmType == HEX8P) + if (elmType == HEX8P) + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx); + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx); - float por = srcPORFrameData[nodeIdx]; - if (por == inf) por = 0.0f; + float por = srcPORFrameData[nodeIdx]; + if (por == inf) por = 0.0f; - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx] + por; - } + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx] + por; } - else + } + else + { + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { - for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) - { - size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); - dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; - } + size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); + dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx]; } } - - frameCountProgress.incrementProgress(); } - return dstDataFrames; + + frameCountProgress.incrementProgress(); } - if ( resVarAddr.fieldName == "ST" - && ( resVarAddr.componentName == "S12" - || resVarAddr.componentName == "S13" - || resVarAddr.componentName == "S23" )) - { - caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); + return dstDataFrames; +} - RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateST_12_13_23(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 2, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - frameCountProgress.incrementProgress(); + RigFemScalarResultFrames * srcSDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(resVarAddr.resultPosType, "S-Bar", resVarAddr.componentName)); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - int frameCount = srcSDataFrames->frameCount(); - for (int fIdx = 0; fIdx < frameCount; ++fIdx) - { - const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); - std::vector& dstFrameData = dstDataFrames->frameData(fIdx); + frameCountProgress.incrementProgress(); - size_t valCount = srcSFrameData.size(); - dstFrameData.resize(valCount); - for (size_t vIdx = 0; vIdx < valCount; ++vIdx) - { - dstFrameData[vIdx] = -srcSFrameData[vIdx]; - } + int frameCount = srcSDataFrames->frameCount(); + for (int fIdx = 0; fIdx < frameCount; ++fIdx) + { + const std::vector& srcSFrameData = srcSDataFrames->frameData(fIdx); + std::vector& dstFrameData = dstDataFrames->frameData(fIdx); - frameCountProgress.incrementProgress(); + size_t valCount = srcSFrameData.size(); + dstFrameData.resize(valCount); + +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) + { + dstFrameData[vIdx] = -srcSFrameData[vIdx]; } - return dstDataFrames; - } - if (resVarAddr.fieldName == "ST" && resVarAddr.componentName == "") - { - // Create and return an empty result - return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + frameCountProgress.incrementProgress(); } + return dstDataFrames; +} - if (resVarAddr.fieldName == "Gamma" - && ( resVarAddr.componentName == "Gamma1" - || resVarAddr.componentName == "Gamma2" - || resVarAddr.componentName == "Gamma3" - || resVarAddr.componentName == "Gamma11" - || resVarAddr.componentName == "Gamma22" - || resVarAddr.componentName == "Gamma33" - )) - { - caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - frameCountProgress.setNextProgressIncrement(this->frameCount()); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateGamma(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(this->frameCount() * 3, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - RigFemResultAddress totStressCompAddr(resVarAddr.resultPosType, "ST", ""); - { - std::string scomp; - std::string gcomp = resVarAddr.componentName; - if ( gcomp == "Gamma1" ) scomp = "S1"; - else if ( gcomp == "Gamma2" ) scomp = "S2"; - else if ( gcomp == "Gamma3" ) scomp = "S3"; - else if ( gcomp == "Gamma11" ) scomp = "S11"; - else if ( gcomp == "Gamma22" ) scomp = "S22"; - else if ( gcomp == "Gamma33" ) scomp = "S33"; - totStressCompAddr.componentName = scomp; - } + RigFemResultAddress totStressCompAddr(resVarAddr.resultPosType, "ST", ""); + { + std::string scomp; + std::string gcomp = resVarAddr.componentName; + if (gcomp == "Gamma1") scomp = "S1"; + else if (gcomp == "Gamma2") scomp = "S2"; + else if (gcomp == "Gamma3") scomp = "S3"; + else if (gcomp == "Gamma11") scomp = "S11"; + else if (gcomp == "Gamma22") scomp = "S22"; + else if (gcomp == "Gamma33") scomp = "S33"; + totStressCompAddr.componentName = scomp; + } - RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, totStressCompAddr); - - frameCountProgress.incrementProgress(); - frameCountProgress.setNextProgressIncrement(this->frameCount()); + RigFemScalarResultFrames * srcDataFrames = this->findOrLoadScalarResult(partIndex, totStressCompAddr); - RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); - RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + frameCountProgress.incrementProgress(); + frameCountProgress.setNextProgressIncrement(this->frameCount()); - frameCountProgress.incrementProgress(); + RigFemScalarResultFrames * srcPORDataFrames = this->findOrLoadScalarResult(partIndex, RigFemResultAddress(RIG_NODAL, "POR-Bar", "")); + RigFemScalarResultFrames * dstDataFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - calculateGammaFromFrames(partIndex, srcDataFrames, srcPORDataFrames, dstDataFrames, &frameCountProgress); + frameCountProgress.incrementProgress(); - return dstDataFrames; - } + calculateGammaFromFrames(partIndex, srcDataFrames, srcPORDataFrames, dstDataFrames, &frameCountProgress); - if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName == "") - { - // Create and return an empty result - return m_femPartResults[partIndex]->createScalarResult(resVarAddr); - } + return dstDataFrames; +} - if (resVarAddr.resultPosType == RIG_FORMATION_NAMES) - { - caf::ProgressInfo frameCountProgress(2, ""); - frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateFormationIndices(int partIndex, const RigFemResultAddress &resVarAddr) +{ + caf::ProgressInfo frameCountProgress(2, ""); + frameCountProgress.setProgressDescription("Calculating " + QString::fromStdString(resVarAddr.fieldName + ": " + resVarAddr.componentName)); - RigFemScalarResultFrames* resFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); - resFrames->enableAsSingleFrameResult(); + RigFemScalarResultFrames* resFrames = m_femPartResults[partIndex]->createScalarResult(resVarAddr); + resFrames->enableAsSingleFrameResult(); - const RigFemPart * femPart = m_femParts->part(partIndex); - std::vector& dstFrameData = resFrames->frameData(0); + const RigFemPart * femPart = m_femParts->part(partIndex); + std::vector& dstFrameData = resFrames->frameData(0); - size_t valCount = femPart->elementNodeResultCount(); - float inf = std::numeric_limits::infinity(); - dstFrameData.resize(valCount, inf); + size_t valCount = femPart->elementNodeResultCount(); + float inf = std::numeric_limits::infinity(); + dstFrameData.resize(valCount, inf); - RigFormationNames* activeFormNames = m_activeFormationNamesData.p(); + RigFormationNames* activeFormNames = m_activeFormationNamesData.p(); - frameCountProgress.incrementProgress(); + frameCountProgress.incrementProgress(); + if (activeFormNames) + { int elementCount = femPart->elementCount(); - for(int elmIdx = 0; elmIdx < elementCount; ++elmIdx) + +#pragma omp parallel for + for (int elmIdx = 0; elmIdx < elementCount; ++elmIdx) { RigElementType elmType = femPart->elementType(elmIdx); int elmNodeCount = RigFemTypes::elmentNodeCount(elmType); size_t i, j, k; femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k); - int formNameIdx = -1; - if (activeFormNames) - { - formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k); - } + int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k); - for(int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) + for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx) { size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx); @@ -1760,10 +1826,187 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(in } } } + } + + return resFrames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemScalarResultFrames* RigFemPartResultsCollection::calculateDerivedResult(int partIndex, const RigFemResultAddress& resVarAddr) +{ + if (resVarAddr.isTimeLapse()) + { + return calculateTimeLapseResult(partIndex, resVarAddr); + } + + if(resVarAddr.resultPosType == RIG_ELEMENT_NODAL_FACE ) + { + if (resVarAddr.componentName == "Pazi" || resVarAddr.componentName == "Pinc") + { + return calculateSurfaceAngles(partIndex, resVarAddr); + } + else if (resVarAddr.componentName.empty()) + { + return nullptr; + } + else + { + return calculateSurfaceAlignedStress(partIndex, resVarAddr); + } + } - return resFrames; + if (resVarAddr.fieldName == FIELD_NAME_COMPACTION) + { + return calculateCompactionValues(partIndex, resVarAddr); + } + + if (resVarAddr.fieldName == "SE" && resVarAddr.componentName == "SFI") + { + return calculateSFI(partIndex, resVarAddr); } - return NULL; + + if ( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "DSM" ) + { + return calculateDSM(partIndex, resVarAddr); + } + + if ( resVarAddr.fieldName == "SE" && resVarAddr.componentName == "FOS" ) + { + return calculateFOS(partIndex, resVarAddr); + } + + if(resVarAddr.fieldName == "NE" && resVarAddr.componentName == "EV") + { + return calculateVolumetricStrain(partIndex, resVarAddr); + } + + if ( resVarAddr.fieldName == "NE" && resVarAddr.componentName == "ED" ) + { + return calculateDeviatoricStrain(partIndex, resVarAddr); + } + + if(resVarAddr.fieldName == "ST" && resVarAddr.componentName == "Q" ) + { + return calculateDeviatoricStress(partIndex, resVarAddr); + } + + if(resVarAddr.fieldName == "ST" && resVarAddr.componentName == "STM") + { + return calculateMeanStressSTM(partIndex, resVarAddr); + } + + if(resVarAddr.fieldName == "SE" && resVarAddr.componentName == "SEM") + { + return calculateMeanStressSEM(partIndex, resVarAddr); + } + + if (resVarAddr.fieldName == "S-Bar") + { + return calculateBarConvertedResult(partIndex, resVarAddr, "S"); + } + + if (resVarAddr.fieldName == "POR-Bar") + { + if (resVarAddr.resultPosType == RIG_NODAL) + return calculateBarConvertedResult(partIndex, resVarAddr, "POR"); + else + return calculateEnIpPorBarResult(partIndex, resVarAddr); + } + + if((resVarAddr.fieldName == "NE") + && ( resVarAddr.componentName == "E11" + || resVarAddr.componentName == "E22" + || resVarAddr.componentName == "E33" + || resVarAddr.componentName == "E12" + || resVarAddr.componentName == "E13" + || resVarAddr.componentName == "E23")) + { + return calculateNE(partIndex, resVarAddr); + } + + if ( (resVarAddr.fieldName == "NE") + && ( resVarAddr.componentName == "E1" + || resVarAddr.componentName == "E2" + || resVarAddr.componentName == "E3") ) + { + return calculatePrincipalStrainValues(partIndex, resVarAddr); + } + + if ((resVarAddr.fieldName == "SE") + && ( resVarAddr.componentName == "S11" + || resVarAddr.componentName == "S22" + || resVarAddr.componentName == "S33" + || resVarAddr.componentName == "S12" + || resVarAddr.componentName == "S13" + || resVarAddr.componentName == "S23" )) + { + return calculateSE(partIndex, resVarAddr); + } + + if ( (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST" ) + && ( resVarAddr.componentName == "S1" + || resVarAddr.componentName == "S2" + || resVarAddr.componentName == "S3" + || resVarAddr.componentName == "S1inc" + || resVarAddr.componentName == "S1azi" + || resVarAddr.componentName == "S2inc" + || resVarAddr.componentName == "S2azi" + || resVarAddr.componentName == "S3inc" + || resVarAddr.componentName == "S3azi" ) + ) + { + return calculatePrincipalStressValues(partIndex, resVarAddr); + } + + if ( resVarAddr.fieldName == "ST" + && ( resVarAddr.componentName == "S11" + || resVarAddr.componentName == "S22" + || resVarAddr.componentName == "S33" )) + { + return calculateST_11_22_33(partIndex, resVarAddr); + } + + if ( resVarAddr.fieldName == "ST" + && ( resVarAddr.componentName == "S12" + || resVarAddr.componentName == "S13" + || resVarAddr.componentName == "S23" )) + { + return calculateST_12_13_23(partIndex, resVarAddr); + } + + if (resVarAddr.fieldName == "ST" && resVarAddr.componentName.empty()) + { + // Create and return an empty result + return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + } + + + if (resVarAddr.fieldName == "Gamma" + && ( resVarAddr.componentName == "Gamma1" + || resVarAddr.componentName == "Gamma2" + || resVarAddr.componentName == "Gamma3" + || resVarAddr.componentName == "Gamma11" + || resVarAddr.componentName == "Gamma22" + || resVarAddr.componentName == "Gamma33" + )) + { + return calculateGamma(partIndex, resVarAddr); + } + + if (resVarAddr.fieldName == "Gamma" && resVarAddr.componentName.empty()) + { + // Create and return an empty result + return m_femPartResults[partIndex]->createScalarResult(resVarAddr); + } + + if (resVarAddr.resultPosType == RIG_FORMATION_NAMES) + { + return calculateFormationIndices(partIndex, resVarAddr); + } + + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -1790,6 +2033,8 @@ void RigFemPartResultsCollection::calculateGammaFromFrames(int partIndex, dstFrameData.resize(valCount); int elementCount = femPart->elementCount(); + +#pragma omp parallel for for ( int elmIdx = 0; elmIdx < elementCount; ++elmIdx ) { RigElementType elmType = femPart->elementType(elmIdx); @@ -1842,6 +2087,8 @@ std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToCompo case RIG_INTEGRATION_POINT: fieldAndComponentNames = m_readerInterface->scalarIntegrationPointFieldAndComponentNames(); break; + default: + break; } std::vector< RigFemResultAddress> resAddressToComponents; @@ -1851,15 +2098,15 @@ std::vector< RigFemResultAddress> RigFemPartResultsCollection::getResAddrToCompo if (fcIt != fieldAndComponentNames.end()) { std::vector compNames = fcIt->second; - if (resVarAddr.componentName != "") // If we did not request a particular component, do not add the components + if (!resVarAddr.componentName.empty()) // If we did not request a particular component, do not add the components { - for (size_t cIdx = 0; cIdx < compNames.size(); ++cIdx) + for (const auto & compName : compNames) { - resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compNames[cIdx])); + resAddressToComponents.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, compName)); } } - if (compNames.size() == 0) // This is a scalar field. Add one component named "" + if (compNames.empty()) // This is a scalar field. Add one component named "" { CVF_ASSERT(resVarAddr.componentName == ""); resAddressToComponents.push_back(resVarAddr); @@ -1889,6 +2136,24 @@ int RigFemPartResultsCollection::frameCount() return static_cast(stepNames().size()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RigFemPartResultsCollection::dsm(float p1, float p3, float tanFricAng, float cohPrTanFricAngle) +{ + if (p1 == HUGE_VAL || p3 == HUGE_VAL) + { + return std::nan(""); + } + + CVF_ASSERT(p1 > p3); + + float pi_4 = 0.785398163397448309616f; + float rho = 2.0f * (atan(sqrt((p1 + cohPrTanFricAngle) / (p3 + cohPrTanFricAngle))) - pi_4); + + return tan(rho) / tanFricAng; +} + //-------------------------------------------------------------------------------------------------- /// Returns whether any of the parts actually had any of the requested results //-------------------------------------------------------------------------------------------------- @@ -1905,7 +2170,7 @@ bool RigFemPartResultsCollection::assertResultsLoaded(const RigFemResultAddress& RigFemScalarResultFrames* scalarResults = findOrLoadScalarResult(pIdx, resVarAddr); for (int fIdx = 0; fIdx < scalarResults->frameCount(); ++fIdx) { - foundResults = foundResults || scalarResults->frameData(fIdx).size(); + foundResults = foundResults || !scalarResults->frameData(fIdx).empty(); } } } @@ -1920,11 +2185,11 @@ void RigFemPartResultsCollection::deleteResult(const RigFemResultAddress& resVar { CVF_ASSERT ( resVarAddr.isValid() ); - for ( int pIdx = 0; pIdx < static_cast(m_femPartResults.size()); ++pIdx ) + for (auto & femPartResult : m_femPartResults) { - if ( m_femPartResults[pIdx].notNull() ) + if ( femPartResult.notNull() ) { - m_femPartResults[pIdx]->deleteScalarResult(resVarAddr); + femPartResult->deleteScalarResult(resVarAddr); } } @@ -1961,6 +2226,63 @@ const std::vector& RigFemPartResultsCollection::resultValues(const RigFem return scalarResults->frameData(frameIndex); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigFemPartResultsCollection::tensors(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex) +{ + CVF_ASSERT(resVarAddr.resultPosType == RIG_ELEMENT_NODAL || resVarAddr.resultPosType == RIG_INTEGRATION_POINT); + + std::vector outputTensors; + + RigFemResultAddress address11(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address22(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address33(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address12(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address13(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + RigFemResultAddress address23(resVarAddr.resultPosType, resVarAddr.fieldName, ""); + + if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST") + { + address11.componentName = "S11"; + address22.componentName = "S22"; + address33.componentName = "S33"; + address12.componentName = "S12"; + address13.componentName = "S13"; + address23.componentName = "S23"; + } + else if (resVarAddr.fieldName == "NE") + { + address11.componentName = "E11"; + address22.componentName = "E22"; + address33.componentName = "E33"; + address12.componentName = "E12"; + address13.componentName = "E13"; + address23.componentName = "E23"; + } + else + return outputTensors; + + const std::vector& v11 = resultValues(address11, partIndex, frameIndex); + const std::vector& v22 = resultValues(address22, partIndex, frameIndex); + const std::vector& v33 = resultValues(address33, partIndex, frameIndex); + const std::vector& v12 = resultValues(address12, partIndex, frameIndex); + const std::vector& v13 = resultValues(address13, partIndex, frameIndex); + const std::vector& v23 = resultValues(address23, partIndex, frameIndex); + + size_t valCount = v11.size(); + outputTensors.resize(valCount); + +#pragma omp parallel for + for (long vIdx = 0; vIdx < static_cast(valCount); ++vIdx) + { + caf::Ten3f tensor(v11[vIdx], v22[vIdx], v33[vIdx], v12[vIdx], v23[vIdx], v13[vIdx]); + outputTensors[vIdx] = tensor; + } + + return outputTensors; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2081,6 +2403,143 @@ const std::vector& RigFemPartResultsCollection::scalarValuesHistogram(co return this->statistics(resVarAddr)->cellScalarValuesHistogram(frameIndex); } +std::vector RigFemPartResultsCollection::tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr) +{ + std::vector addresses; + + for (size_t i = 0; i < 3; ++i) + { + addresses.push_back(RigFemResultAddress(resVarAddr.resultPosType, resVarAddr.fieldName, "")); + } + + if (resVarAddr.fieldName == "SE" || resVarAddr.fieldName == "ST") + { + addresses[0].componentName = "S1"; + addresses[1].componentName = "S2"; + addresses[2].componentName = "S3"; + } + else if (resVarAddr.fieldName == "NE") + { + addresses[0].componentName = "E1"; + addresses[1].componentName = "E2"; + addresses[2].componentName = "E3"; + } + else + { + addresses.clear(); + } + + return addresses; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax) +{ + double currentMin = HUGE_VAL; + double currentMax = -HUGE_VAL; + + double min, max; + + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->minMaxCellScalarValues(frameIndex, min, max); + if (min < currentMin) + { + currentMin = min; + } + if (max > currentMax) + { + currentMax = max; + } + } + + *localMin = currentMin; + *localMax = currentMax; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax) +{ + double currentMin = HUGE_VAL; + double currentMax = -HUGE_VAL; + + double min, max; + + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->minMaxCellScalarValues(min, max); + if (min < currentMin) + { + currentMin = min; + } + if (max > currentMax) + { + currentMax = max; + } + } + + *globalMin = currentMin; + *globalMax = currentMax; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero) +{ + double currentPosClosestToZero = HUGE_VAL; + double currentNegClosestToZero = -HUGE_VAL; + + double pos, neg; + + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->posNegClosestToZero(frameIndex, pos, neg); + if (pos < currentPosClosestToZero) + { + currentPosClosestToZero = pos; + } + if (neg > currentNegClosestToZero) + { + currentNegClosestToZero = neg; + } + } + + *localPosClosestToZero = currentPosClosestToZero; + *localNegClosestToZero = currentNegClosestToZero; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFemPartResultsCollection::posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero) +{ + double currentPosClosestToZero = HUGE_VAL; + double currentNegClosestToZero = -HUGE_VAL; + + double pos, neg; + + for (const auto& address : tensorPrincipalComponentAdresses(resVarAddr)) + { + this->statistics(address)->posNegClosestToZero(pos, neg); + if (pos < currentPosClosestToZero) + { + currentPosClosestToZero = pos; + } + if (neg > currentNegClosestToZero) + { + currentNegClosestToZero = neg; + } + } + + *globalPosClosestToZero = currentPosClosestToZero; + *globalNegClosestToZero = currentNegClosestToZero; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -2137,6 +2596,10 @@ RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPar { m_resultIndexToClosestResult = -1; } + else if (resultPosition == RIG_ELEMENT) + { + m_resultIndexToClosestResult = elementIndex; + } else { m_resultIndexToClosestResult = m_closestElementNodeResIdx; @@ -2187,4 +2650,95 @@ RigFemClosestResultIndexCalculator::RigFemClosestResultIndexCalculator(RigFemPar m_resultIndexToClosestResult = elmNodFaceResIdx; m_closestNodeId = femPart->nodes().nodeIds[closestNodeIdx]; } -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector coordsFromNodeIndices(const RigFemPart& part, const std::vector& nodeIdxs) +{ + std::vector out; + for (const auto& nodeIdx : nodeIdxs) out.push_back(cvf::Vec3d(part.nodes().coordinates[nodeIdx])); + return out; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector nodesForElement(const RigFemPart& part, size_t elementIdx) +{ + std::vector nodeIdxs; + const int* nodeConn = part.connectivities(elementIdx); + for (int n = 0; n < 8; n++) nodeIdxs.push_back(nodeConn[n]); + return nodeIdxs; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float horizontalDistance(const cvf::Vec3f& p1, const cvf::Vec3f& p2) +{ + cvf::Vec3f p1_ = p1; + cvf::Vec3f p2_ = p2; + p1_.z() = p2_.z() = 0; + return p1_.pointDistance(p2_); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void findReferenceElementForNode(const RigFemPart& part, size_t nodeIdx, size_t kRefLayer, RefElement *refElement) +{ + static const double zMin = -1e6, zMax = 1e6; + + cvf::BoundingBox bb; + cvf::Vec3f currentNodeCoord = part.nodes().coordinates[nodeIdx]; + cvf::Vec3f p1 = cvf::Vec3f(currentNodeCoord.x(), currentNodeCoord.y(), zMin); + cvf::Vec3f p2 = cvf::Vec3f(currentNodeCoord.x(), currentNodeCoord.y(), zMax); + bb.add(p1); + bb.add(p2); + + std::vector refElementCandidates; + part.findIntersectingCells(bb, &refElementCandidates); + + const RigFemPartGrid* grid = part.structGrid(); + const std::vector& nodeCoords = part.nodes().coordinates; + + refElement->elementIdx = cvf::UNDEFINED_SIZE_T; + refElement->intersectionPointToCurrentNodeDistance = std::numeric_limits::infinity(); + size_t i, j, k; + for (const size_t elemIdx : refElementCandidates) + { + grid->ijkFromCellIndex(elemIdx, &i, &j, &k); + if (k == kRefLayer) + { + const std::vector nodeIndices = nodesForElement(part, elemIdx); + CVF_ASSERT(nodeIndices.size() == 8); + + std::vector intersections; + RigHexIntersectionTools::lineHexCellIntersection(cvf::Vec3d(p1), cvf::Vec3d(p2), coordsFromNodeIndices(part, nodeIndices).data(), elemIdx, &intersections); + + for (const auto& intersection : intersections) + { + cvf::Vec3f intersectionPoint = cvf::Vec3f(intersection.m_intersectionPoint); + + float nodeToIntersectionDistance = currentNodeCoord.pointDistance(intersectionPoint); + if (nodeToIntersectionDistance < refElement->intersectionPointToCurrentNodeDistance) + { + cvf::ubyte faceNodes[4]; + grid->cellFaceVertexIndices(intersection.m_face, faceNodes); + std::vector topFaceCoords({ nodeIndices[faceNodes[0]], nodeIndices[faceNodes[1]], nodeIndices[faceNodes[2]], nodeIndices[faceNodes[3]] }); + + refElement->elementIdx = elemIdx; + refElement->intersectionPointToCurrentNodeDistance = nodeToIntersectionDistance; + refElement->intersectionPoint = intersectionPoint; + refElement->elementFaceNodeIdxs = topFaceCoords; + } + } + } + } +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index cf6e82620e..63c601c009 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -21,18 +21,25 @@ #include "RigFemResultAddress.h" +#include "cafTensor3.h" + #include "cvfCollection.h" #include "cvfObject.h" + +#include + #include #include class RifGeoMechReaderInterface; +class RifElementPropertyReader; class RigFemScalarResultFrames; class RigFemPartResultsCollection; class RigFemPartResults; class RigStatisticsDataCache; class RigFemPartCollection; class RigFormationNames; + namespace caf { class ProgressInfo; @@ -41,11 +48,17 @@ namespace caf class RigFemPartResultsCollection: public cvf::Object { public: - RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, const RigFemPartCollection * femPartCollection); + static const std::string FIELD_NAME_COMPACTION; + + RigFemPartResultsCollection(RifGeoMechReaderInterface* readerInterface, RifElementPropertyReader* elementPropertyReader, const RigFemPartCollection * femPartCollection); ~RigFemPartResultsCollection(); void setActiveFormationNames(RigFormationNames* activeFormationNames); RigFormationNames* activeFormationNames(); + + void addElementPropertyFiles(const std::vector& filenames); + std::vector removeElementPropertyFiles(const std::vector& filenames); + void setCalculationParameters(double cohesion, double frictionAngleRad); double parameterCohesion() const { return m_cohesion;} double parameterFrictionAngleRad() const { return m_frictionAngleRad; } @@ -55,10 +68,12 @@ class RigFemPartResultsCollection: public cvf::Object bool assertResultsLoaded(const RigFemResultAddress& resVarAddr); void deleteResult(const RigFemResultAddress& resVarAddr); - const std::vector& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); + const std::vector& resultValues(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); + std::vector tensors(const RigFemResultAddress& resVarAddr, int partIndex, int frameIndex); int partCount() const; int frameCount(); + static float dsm(float p1, float p3, float tanFricAng, float cohPrTanFricAngle); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); void minMaxScalarValues (const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax); @@ -73,6 +88,10 @@ class RigFemPartResultsCollection: public cvf::Object const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr); const std::vector& scalarValuesHistogram(const RigFemResultAddress& resVarAddr, int frameIndex); + void minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localMin, double* localMax); + void minMaxScalarValuesOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalMin, double* globalMax); + void posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, int frameIndex, double* localPosClosestToZero, double* localNegClosestToZero); + void posNegClosestToZeroOverAllTensorComponents(const RigFemResultAddress& resVarAddr, double* globalPosClosestToZero, double* globalNegClosestToZero); private: RigFemScalarResultFrames* findOrLoadScalarResult(int partIndex, const RigFemResultAddress& resVarAddr); @@ -101,9 +120,20 @@ class RigFemPartResultsCollection: public cvf::Object RigFemScalarResultFrames* calculateSurfaceAngles(int partIndex, const RigFemResultAddress& resVarAddr); RigFemScalarResultFrames* calculatePrincipalStressValues(int partIndex, const RigFemResultAddress &resVarAddr); RigFemScalarResultFrames* calculatePrincipalStrainValues(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateCompactionValues(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateNE(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateSE(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateST_11_22_33(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateST_12_13_23(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateGamma(int partIndex, const RigFemResultAddress &resVarAddr); + RigFemScalarResultFrames* calculateFormationIndices(int partIndex, const RigFemResultAddress &resVarAddr); + static std::vector tensorPrincipalComponentAdresses(const RigFemResultAddress& resVarAddr); + +private: cvf::Collection m_femPartResults; cvf::ref m_readerInterface; + cvf::ref m_elementPropertyReader; cvf::cref m_femParts; cvf::ref m_activeFormationNamesData; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h index 02dd5372b0..c2717d5a9e 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultAddress.h @@ -29,24 +29,23 @@ class RigFemResultAddress { public: - RigFemResultAddress(RigFemResultPosEnum resPosType, - const std::string& aFieldName, - const std::string& aComponentName) - : resultPosType(resPosType), - fieldName(aFieldName), - componentName(aComponentName), - timeLapseBaseFrameIdx(-1) + RigFemResultAddress() { + resultPosType = RIG_NODAL; + fieldName = ""; + componentName = ""; } RigFemResultAddress(RigFemResultPosEnum resPosType, const std::string& aFieldName, const std::string& aComponentName, - int aTimeLapseBaseFrame) + int timeLapseBaseFrameIdx = NO_TIME_LAPSE, + int refKLayerIndex = NO_COMPACTION) : resultPosType(resPosType), fieldName(aFieldName), componentName(aComponentName), - timeLapseBaseFrameIdx(aTimeLapseBaseFrame) + timeLapseBaseFrameIdx(timeLapseBaseFrameIdx), + refKLayerIndex(refKLayerIndex) { } @@ -54,10 +53,13 @@ class RigFemResultAddress std::string fieldName; std::string componentName; int timeLapseBaseFrameIdx; + int refKLayerIndex; static const int ALL_TIME_LAPSES = -2; + static const int NO_TIME_LAPSE = -1; + static const int NO_COMPACTION = -1; - bool isTimeLapse() const { return timeLapseBaseFrameIdx >= 0;} + bool isTimeLapse() const { return timeLapseBaseFrameIdx > NO_TIME_LAPSE;} bool representsAllTimeLapses() const { return timeLapseBaseFrameIdx == ALL_TIME_LAPSES;} bool isValid() const @@ -66,7 +68,8 @@ class RigFemResultAddress || resultPosType == RIG_ELEMENT_NODAL || resultPosType == RIG_INTEGRATION_POINT || resultPosType == RIG_ELEMENT_NODAL_FACE - || resultPosType == RIG_FORMATION_NAMES; + || resultPosType == RIG_FORMATION_NAMES + || resultPosType == RIG_ELEMENT; bool isFieldValid = fieldName != ""; return isTypeValid && isFieldValid; @@ -89,7 +92,25 @@ class RigFemResultAddress return (fieldName < other.fieldName); } + if (refKLayerIndex != other.refKLayerIndex) + { + return refKLayerIndex < other.refKLayerIndex; + } + return (componentName < other.componentName); + } + + bool operator== (const RigFemResultAddress& other) const + { + if ( resultPosType != other.resultPosType + || fieldName != other.fieldName + || componentName != other.componentName + || timeLapseBaseFrameIdx != other.timeLapseBaseFrameIdx) + { + return false; + } + + return true; } }; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h index 5120601f82..242535f750 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemResultPosEnum.h @@ -24,5 +24,6 @@ enum RigFemResultPosEnum { RIG_ELEMENT_NODAL, RIG_INTEGRATION_POINT, RIG_ELEMENT_NODAL_FACE, - RIG_FORMATION_NAMES + RIG_FORMATION_NAMES, + RIG_ELEMENT }; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp index 566d09f74c..e3233be517 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.cpp @@ -2,63 +2,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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigFemTypes.h" +#include - +#include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RigFemTypes::elmentNodeCount(RigElementType elmType) { - static int elementTypeCounts[3] ={ 8, 8, 4 }; + static int elementTypeCounts[3] = {8, 8, 4}; return elementTypeCounts[elmType]; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RigFemTypes::elmentFaceCount(RigElementType elmType) { - const static int elementFaceCounts[3] ={ 6, 6, 1 }; + const static int elementFaceCounts[3] = {6, 6, 1}; return elementFaceCounts[elmType]; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- // HEX8 // 7---------6 Increased k -> Increased depth : 4 5 6 7 is the deepest quad -// /| /| |k -// / | / | | /j -// 4---------5 | |/ -// | 3------|--2 *---i -// | / | / -// |/ |/ -// 0---------1 +// /| /| |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 }; + 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) { @@ -81,8 +82,8 @@ const int* RigFemTypes::localElmNodeIndicesForFace(RigElementType elmType, int f int RigFemTypes::oppositeFace(RigElementType elmType, int faceIdx) { - static const int HEX8_OppositeFaces[6]={ 1, 0, 3, 2, 5, 4}; - + static const int HEX8_OppositeFaces[6] = {1, 0, 3, 2, 5, 4}; + switch (elmType) { case HEX8: @@ -101,12 +102,12 @@ int RigFemTypes::oppositeFace(RigElementType elmType, int faceIdx) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const int* RigFemTypes::localElmNodeToIntegrationPointMapping(RigElementType elmType) { - static const int HEX8_Mapping[8] ={ 0, 1, 3, 2, 4, 5, 7, 6 }; + static const int HEX8_Mapping[8] = {0, 1, 3, 2, 4, 5, 7, 6}; switch (elmType) { @@ -124,3 +125,30 @@ const int* RigFemTypes::localElmNodeToIntegrationPointMapping(RigElementType elm return HEX8_Mapping; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigFemTypes::elementTypeText(RigElementType elemType) +{ + QString txt = "UNKNOWN_ELM_TYPE"; + + switch (elemType) + { + case HEX8: + txt = "HEX8"; + break; + case HEX8P: + txt = "HEX8P"; + break; + case CAX4: + txt = "CAX4"; + break; + case UNKNOWN_ELM_TYPE: + break; + default: + break; + } + + return txt; +} diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h index eb9a70dfcb..723685fd68 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemTypes.h @@ -2,23 +2,24 @@ // // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include + +class QString; enum RigElementType { @@ -31,9 +32,10 @@ enum RigElementType class RigFemTypes { public: - static int elmentNodeCount(RigElementType elmType); - static int elmentFaceCount(RigElementType elmType); + static int elmentNodeCount(RigElementType elmType); + static int elmentFaceCount(RigElementType elmType); static const int* localElmNodeIndicesForFace(RigElementType elmType, int faceIdx, int* faceNodeCount); - static int oppositeFace(RigElementType elmType, int faceIdx); + static int oppositeFace(RigElementType elmType, int faceIdx); static const int* localElmNodeToIntegrationPointMapping(RigElementType elmType); + static QString elementTypeText(RigElementType elemType); }; diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp index 6cc6ef6f70..a354b73ad0 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.cpp @@ -19,20 +19,24 @@ #include +#include "RifElementPropertyReader.h" +#include "RifGeoMechReaderInterface.h" +#include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.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 -#include "cvfBoundingBox.h" + #include "cafProgressInfo.h" +#include "cvfBoundingBox.h" + #include +#include //-------------------------------------------------------------------------------------------------- /// @@ -104,8 +108,9 @@ bool RigGeoMechCaseData::openAndReadFemParts(std::string* errorMessage) progress.incrementProgress(); progress.setProgressDescription("Calculating element neighbors"); + m_elementPropertyReader = new RifElementPropertyReader(m_femParts->part(0)->elementIdxToId()); // Initialize results containers - m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_femParts.p()); + m_femPartResultsColl = new RigFemPartResultsCollection(m_readerInterface.p(), m_elementPropertyReader.p(), m_femParts.p()); // Calculate derived Fem data for (int pIdx = 0; pIdx < m_femParts->partCount(); ++pIdx) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h index 52f23a37ff..c76749e029 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigGeoMechCaseData.h @@ -31,6 +31,7 @@ class RifGeoMechReaderInterface; class RigFemPartCollection; class RigFemScalarResultFrames; class RigFemPartResultsCollection; +class RifElementPropertyReader; class RigGeoMechCaseData: public cvf::Object { @@ -47,8 +48,9 @@ class RigGeoMechCaseData: public cvf::Object const RigFemPartResultsCollection* femPartResults() const; private: - std::string m_geoMechCaseFileName; - cvf::ref m_femParts; - cvf::ref m_femPartResultsColl; - cvf::ref m_readerInterface; + std::string m_geoMechCaseFileName; + cvf::ref m_femParts; + cvf::ref m_femPartResultsColl; + cvf::ref m_readerInterface; + cvf::ref m_elementPropertyReader; }; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake b/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake index adb8e6856c..8db4eb3e1a 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/GeoMech/GeoMechVisualization/CMakeLists_files.cmake @@ -1,28 +1,23 @@ -# 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 -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgrCache.h -${CEE_CURRENT_LIST_DIR}RivGeoMechVizLogic.h -${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivFemElmVisibilityCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RivFemPartGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivFemPartPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgrCache.h +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechVizLogic.h +${CMAKE_CURRENT_LIST_DIR}/RivFemPickSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivFemElmVisibilityCalculator.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivFemPartGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivFemPartPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivGeoMechPartMgrCache.cpp -${CEE_CURRENT_LIST_DIR}RivGeoMechVizLogic.cpp -${CEE_CURRENT_LIST_DIR}RivFemPickSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivFemElmVisibilityCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemPartGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemPartPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechPartMgrCache.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGeoMechVizLogic.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemPickSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFemElmVisibilityCalculator.cpp ) @@ -34,4 +29,4 @@ 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 ) +source_group( "GeoMechViz" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp index 564d2ffd58..7b79840584 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.cpp @@ -96,9 +96,9 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(rangeFilterVisibility != NULL); - CVF_ASSERT(propFilterColl != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(rangeFilterVisibility != nullptr); + CVF_ASSERT(propFilterColl != nullptr); CVF_ASSERT(grid->elementCount() > 0); CVF_ASSERT(rangeFilterVisibility->size() == static_cast(grid->elementCount())); @@ -107,143 +107,147 @@ void RivFemElmVisibilityCalculator::computePropertyVisibility(cvf::UByteArray* c if (cellVisibility != rangeFilterVisibility ) (*cellVisibility) = *rangeFilterVisibility; const int elementCount = grid->elementCount(); - if (propFilterColl->hasActiveFilters()) + if (!propFilterColl->hasActiveFilters()) return; + + for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) { - for (size_t i = 0; i < propFilterColl->propertyFilters().size(); i++) - { - RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; - if (!propertyFilter->isActiveAndHasResult()) continue; + RimGeoMechPropertyFilter* propertyFilter = propFilterColl->propertyFilters()[i]; + + if (!propertyFilter->isActiveAndHasResult()) continue; + + const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); + + RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); + + RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress(); - const RimCellFilter::FilterModeType filterType = propertyFilter->filterMode(); + // Do a "Hack" to use elm nodal and not nodal POR results + if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL; - RigGeoMechCaseData* caseData = propFilterColl->reservoirView()->geoMechCase()->geoMechData(); + const std::vector& resVals = caseData->femPartResults()->resultValues(resVarAddress, + grid->elementPartId(), + timeStepIndex); - RigFemResultAddress resVarAddress = propertyFilter->resultDefinition->resultAddress(); + if (!propertyFilter->isActive()) continue; + if (!propertyFilter->resultDefinition->hasResult()) continue; - // Do a "Hack" to use elm nodal and not nodal POR results - if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL; + const double lowerBound = propertyFilter->lowerBound(); + const double upperBound = propertyFilter->upperBound(); - const std::vector& resVals = caseData->femPartResults()->resultValues(resVarAddress, - grid->elementPartId(), - timeStepIndex); + if (propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES) + { + std::vector integerVector = propertyFilter->selectedCategoryValues(); + std::set integerSet; + for (auto val : integerVector) + { + integerSet.insert(val); + } - if (propertyFilter->isActive() && propertyFilter->resultDefinition->hasResult()) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) { - if (propertyFilter->resultDefinition->resultAddress().resultPosType == RIG_FORMATION_NAMES) + if (!(*cellVisibility)[cellIndex]) continue; + + size_t resultValueIndex = grid->elementNodeResultIdx(cellIndex, 0); + double scalarValue = resVals[resultValueIndex]; + int intValue = nearbyint(scalarValue); + if (integerSet.find(intValue) != integerSet.end()) { - std::vector integerVector = propertyFilter->selectedCategoryValues(); - std::set integerSet; - for (auto val : integerVector) + if (filterType == RimCellFilter::EXCLUDE) { - integerSet.insert(val); + (*cellVisibility)[cellIndex] = false; } - - for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + } + else + { + if (filterType == RimCellFilter::INCLUDE) { - if ((*cellVisibility)[cellIndex]) - { - size_t resultValueIndex = grid->elementNodeResultIdx(cellIndex, 0); - double scalarValue = resVals[resultValueIndex]; - int intValue = nearbyint(scalarValue); - if (integerSet.find(intValue) != integerSet.end()) - { - if (filterType == RimCellFilter::EXCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - else - { - if (filterType == RimCellFilter::INCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - } + (*cellVisibility)[cellIndex] = false; } } - else + } + } + else if (resVarAddress.resultPosType == RIG_ELEMENT) + { + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if (!(*cellVisibility)[cellIndex]) continue; + + double scalarValue = resVals[cellIndex]; + evaluateAndSetCellVisibiliy(cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility); + } + } + else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) + { + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if (!(*cellVisibility)[cellIndex]) continue; + + for (int fpIdx = 0; fpIdx < 24; ++fpIdx) { - const double lowerBound = propertyFilter->lowerBound(); - const double upperBound = propertyFilter->upperBound(); + double scalarValue = resVals[cellIndex * 24 + fpIdx]; + evaluateAndSetCellVisibiliy(cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility); + } + } + } + else + { + #pragma omp parallel for schedule(dynamic) + for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) + { + if (!(*cellVisibility)[cellIndex]) continue; - - if (resVarAddress.resultPosType != RIG_ELEMENT_NODAL_FACE) + RigElementType eType = grid->elementType(cellIndex); + int elmNodeCount = RigFemTypes::elmentNodeCount(eType); + + const int* elmNodeIndices = grid->connectivities(cellIndex); + for (int enIdx = 0; enIdx < elmNodeCount; ++enIdx) + { + size_t resultValueIndex = cvf::UNDEFINED_SIZE_T; + if (resVarAddress.resultPosType == RIG_NODAL) { - #pragma omp parallel for schedule(dynamic) - for (int cellIndex = 0; cellIndex < elementCount; cellIndex++) - { - if ( (*cellVisibility)[cellIndex] ) - { - RigElementType eType = grid->elementType(cellIndex); - int elmNodeCount = RigFemTypes::elmentNodeCount(eType); - - const int* elmNodeIndices = grid->connectivities(cellIndex); - for(int enIdx = 0; enIdx < elmNodeCount; ++enIdx) - { - size_t resultValueIndex = cvf::UNDEFINED_SIZE_T; - if (resVarAddress.resultPosType == RIG_NODAL) - { - resultValueIndex = elmNodeIndices[enIdx]; - } - else - { - resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx); - } - - double scalarValue = resVals[resultValueIndex]; - if (lowerBound <= scalarValue && scalarValue <= upperBound) - { - if (filterType == RimCellFilter::EXCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - else - { - if (filterType == RimCellFilter::INCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - } - } - } + resultValueIndex = elmNodeIndices[enIdx]; } else { - #pragma omp parallel for schedule(dynamic) - for(int cellIndex = 0; cellIndex < elementCount; cellIndex++) - { - if((*cellVisibility)[cellIndex]) - { - for(int fpIdx = 0; fpIdx < 24; ++fpIdx) - { - double scalarValue = resVals[cellIndex*24 + fpIdx]; - if(lowerBound <= scalarValue && scalarValue <= upperBound) - { - if(filterType == RimCellFilter::EXCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - else - { - if(filterType == RimCellFilter::INCLUDE) - { - (*cellVisibility)[cellIndex] = false; - } - } - } - } - } + resultValueIndex = grid->elementNodeResultIdx(cellIndex, enIdx); } + + double scalarValue = resVals[resultValueIndex]; + evaluateAndSetCellVisibiliy(cellIndex, scalarValue, lowerBound, upperBound, filterType, cellVisibility); } } } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivFemElmVisibilityCalculator::evaluateAndSetCellVisibiliy(int cellIndex, + double scalarValue, + double lowerBound, + double upperBound, + const RimCellFilter::FilterModeType filterType, + cvf::UByteArray* cellVisibility) +{ + if (lowerBound <= scalarValue && scalarValue <= upperBound) + { + if (filterType == RimCellFilter::EXCLUDE) + { + (*cellVisibility)[cellIndex] = false; + } + } + else + { + if (filterType == RimCellFilter::INCLUDE) + { + (*cellVisibility)[cellIndex] = false; + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -251,10 +255,10 @@ void RivFemElmVisibilityCalculator::computeOverriddenCellVisibility(cvf::UByteAr const RigFemPart* femPart, RimViewController* masterViewLink) { - CVF_ASSERT(elmVisibilities != NULL); - CVF_ASSERT(femPart != NULL); + CVF_ASSERT(elmVisibilities != nullptr); + CVF_ASSERT(femPart != nullptr); - RimView* masterView = masterViewLink->ownerViewLinker()->masterView(); + RimGridView* masterView = masterViewLink->ownerViewLinker()->masterView(); cvf::ref totCellVisibility = masterView->currentTotalCellVisibility(); int elmCount = femPart->elementCount(); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h index adda2db74b..659661ac41 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemElmVisibilityCalculator.h @@ -18,9 +18,12 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once + #include "cvfBase.h" #include "cvfArray.h" +#include "RimCellFilter.h" + namespace cvf { class CellRangeFilter; @@ -43,10 +46,16 @@ class RivFemElmVisibilityCalculator const cvf::UByteArray* rangeFilterVisibility, RimGeoMechPropertyFilterCollection* propFilterColl); + static void evaluateAndSetCellVisibiliy(int cellIndex, + double scalarValue, + double lowerBound, + double upperBound, + const RimCellFilter::FilterModeType filterType, + cvf::UByteArray* cellVisibility); + static void computeOverriddenCellVisibility(cvf::UByteArray* elmVisibilities, const RigFemPart* femPart , RimViewController* masterViewLink); - }; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp index 63058ce4ae..c6545d675d 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.cpp @@ -69,7 +69,7 @@ ref RivFemPartGeometryGenerator::generateSurface() CVF_ASSERT(m_quadVertices.notNull()); - if (m_quadVertices->size() == 0) return NULL; + if (m_quadVertices->size() == 0) return nullptr; ref geo = new DrawableGeo; geo->setFromQuadVertexArray(m_quadVertices.p()); @@ -85,7 +85,7 @@ ref RivFemPartGeometryGenerator::generateSurface() //-------------------------------------------------------------------------------------------------- ref RivFemPartGeometryGenerator::createMeshDrawable() { - if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL; + if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(m_quadVertices.p()); @@ -105,7 +105,7 @@ ref RivFemPartGeometryGenerator::createMeshDrawable() //-------------------------------------------------------------------------------------------------- ref RivFemPartGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) { - if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return NULL; + if (!(m_quadVertices.notNull() && m_quadVertices->size() != 0)) return nullptr; cvf::OutlineEdgeExtractor ee(creaseAngle, *m_quadVertices); @@ -115,7 +115,7 @@ ref RivFemPartGeometryGenerator::createOutlineMeshDrawable(double c ref lineIndices = ee.lineIndices(); if (lineIndices->size() == 0) { - return NULL; + return nullptr; } ref prim = new PrimitiveSetIndexedUInt(PT_LINES); @@ -175,6 +175,7 @@ void RivFemPartGeometryGenerator::computeArrays() m_quadVerticesToNodeIdx.clear(); m_quadVerticesToGlobalElmNodeIdx.clear(); m_quadVerticesToGlobalElmFaceNodeIdx.clear(); + m_quadVerticesToGlobalElmIdx.clear(); trianglesToElements.clear(); trianglesToElementFaces.clear(); @@ -183,10 +184,11 @@ void RivFemPartGeometryGenerator::computeArrays() vertices.reserve(estimatedQuadVxCount); m_quadVerticesToNodeIdx.reserve(estimatedQuadVxCount); m_quadVerticesToGlobalElmNodeIdx.reserve(estimatedQuadVxCount); + m_quadVerticesToGlobalElmIdx.reserve(estimatedQuadVxCount); trianglesToElements.reserve(estimatedQuadVxCount/2); trianglesToElementFaces.reserve(estimatedQuadVxCount/2); - cvf::Vec3d offset = Vec3d::ZERO; //m_part->displayModelOffset(); + cvf::Vec3d displayOffset = m_part->boundingBox().min(); const std::vector& nodeCoordinates = m_part->nodes().coordinates; #pragma omp parallel for schedule(dynamic) @@ -215,12 +217,10 @@ void RivFemPartGeometryGenerator::computeArrays() if (faceNodeCount == 4) { - 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]] ]); + cvf::Vec3f quadVxs0 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[0]] ]) - displayOffset); + cvf::Vec3f quadVxs1 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[1]] ]) - displayOffset); + cvf::Vec3f quadVxs2 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[2]] ]) - displayOffset); + cvf::Vec3f quadVxs3 ( cvf::Vec3d(nodeCoordinates[ elmNodeIndices[localElmNodeIndicesForFace[3]] ]) - displayOffset); int qNodeIdx[4]; qNodeIdx[0] = elmNodeIndices[localElmNodeIndicesForFace[0]]; @@ -236,10 +236,10 @@ void RivFemPartGeometryGenerator::computeArrays() #pragma omp critical { - vertices.push_back(*quadVxs[0]); - vertices.push_back(*quadVxs[1]); - vertices.push_back(*quadVxs[2]); - vertices.push_back(*quadVxs[3]); + vertices.push_back(quadVxs0); + vertices.push_back(quadVxs1); + vertices.push_back(quadVxs2); + vertices.push_back(quadVxs3); m_quadVerticesToNodeIdx.push_back(qNodeIdx[0]); m_quadVerticesToNodeIdx.push_back(qNodeIdx[1]); @@ -258,6 +258,11 @@ void RivFemPartGeometryGenerator::computeArrays() m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 2); m_quadVerticesToGlobalElmFaceNodeIdx.push_back(elmNodFaceResIdxFaceStart + 3); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + m_quadVerticesToGlobalElmIdx.push_back(elmIdx); + trianglesToElements.push_back(elmIdx); trianglesToElements.push_back(elmIdx); trianglesToElementFaces.push_back(lfIdx); @@ -305,16 +310,18 @@ cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSi const int* elmNodeIndices = part->connectivities(elmIdx); + cvf::Vec3d displayOffset = part->boundingBox().min(); + for (int lfIdx = 0; lfIdx < faceCount; ++lfIdx) { int faceNodeCount = 0; const int* localElmNodeIndicesForFace = RigFemTypes::localElmNodeIndicesForFace(eType, lfIdx, &faceNodeCount); if (faceNodeCount == 4) { - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]]); - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]]); - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]]); - vertices.push_back(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]]); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[0]]]) - displayOffset)); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[1]]]) - displayOffset)); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[2]]]) - displayOffset)); + vertices.push_back(cvf::Vec3f(cvf::Vec3d(nodeCoordinates[elmNodeIndices[localElmNodeIndicesForFace[3]]]) - displayOffset)); } else { @@ -326,7 +333,7 @@ cvf::ref RivFemPartGeometryGenerator::createMeshDrawableFromSi quadVertices->assign(vertices); } - if (!(quadVertices.notNull() && quadVertices->size() != 0)) return NULL; + if (!(quadVertices.notNull() && quadVertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(quadVertices.p()); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h index 2d6edab282..c123ad8bbd 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartGeometryGenerator.h @@ -86,6 +86,7 @@ class RivFemPartGeometryGenerator : public cvf::Object const std::vector& quadVerticesToNodeIdxMapping() const { return m_quadVerticesToNodeIdx;} const std::vector& quadVerticesToGlobalElmNodeIdx() const { return m_quadVerticesToGlobalElmNodeIdx;} const std::vector& quadVerticesToGlobalElmFaceNodeIdx() const { return m_quadVerticesToGlobalElmFaceNodeIdx; } + const std::vector& quadVerticesToGlobalElmIdx() const { return m_quadVerticesToGlobalElmIdx; } RivFemPartTriangleToElmMapper* triangleToElementMapper() { return m_triangleMapper.p();} @@ -107,6 +108,7 @@ class RivFemPartGeometryGenerator : public cvf::Object std::vector m_quadVerticesToNodeIdx; std::vector m_quadVerticesToGlobalElmNodeIdx; std::vector m_quadVerticesToGlobalElmFaceNodeIdx; + std::vector m_quadVerticesToGlobalElmIdx; // Mappings cvf::ref m_triangleMapper; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp index ac119ce1c7..2db16ba7a8 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.cpp @@ -33,7 +33,7 @@ #include "RimEclipseView.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RivFemPickSourceInfo.h" #include "RivPartPriority.h" @@ -104,7 +104,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui bool useBufferObjects = true; // Surface geometry { - m_surfaceFaces = NULL; // To possibly free memory before adding the new stuff + m_surfaceFaces = nullptr; // To possibly free memory before adding the new stuff cvf::ref geo = geoBuilder.generateSurface(); if (geo.notNull()) @@ -139,7 +139,7 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui // Mesh geometry { - m_surfaceGridLines = NULL; // To possibly free memory before adding the new stuff + m_surfaceGridLines = nullptr; // To possibly free memory before adding the new stuff cvf::ref geoMesh = geoBuilder.createMeshDrawable(); if (geoMesh.notNull()) @@ -176,12 +176,20 @@ void RivFemPartPartMgr::generatePartGeometry(RivFemPartGeometryGenerator& geoBui //-------------------------------------------------------------------------------------------------- void RivFemPartPartMgr::appendPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() ); if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RivFemPartGeometryGenerator* RivFemPartPartMgr::surfaceGenerator() const +{ + return &m_surfaceGenerator; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -242,7 +250,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, m_gridIdx, (int)timeStepIndex); - const std::vector* vxToResultMapping = NULL; + const std::vector* vxToResultMapping = nullptr; int vxCount = 0; if (resVarAddress.resultPosType == RIG_NODAL) @@ -259,7 +267,13 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe { vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmFaceNodeIdx()); } - + else if (resVarAddress.resultPosType == RIG_ELEMENT) + { + vxToResultMapping = &(m_surfaceGenerator.quadVerticesToGlobalElmIdx()); + } + + if (!vxToResultMapping) return; + vxCount = static_cast(vxToResultMapping->size()); m_surfaceFacesTextureCoords->resize(vxCount); @@ -299,7 +313,7 @@ void RivFemPartPartMgr::updateCellResultColor(size_t timeStepIndex, RimGeoMechCe } } - RimView* view = NULL; + Rim3dView* view = nullptr; cellResultColors->firstAncestorOrThisOfType(view); CVF_ASSERT(view); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h index bdb1a7ad22..9d49715cc5 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivFemPartPartMgr.h @@ -57,6 +57,8 @@ class RivFemPartPartMgr: public cvf::Object void updateCellResultColor(size_t timeStepIndex, RimGeoMechCellColors* cellResultColors); void appendPartsToModel(cvf::ModelBasicList* model); + + const RivFemPartGeometryGenerator* surfaceGenerator() const; private: void generatePartGeometry(RivFemPartGeometryGenerator& geoBuilder); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp index 25f3920c0a..3d5401af6f 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.cpp @@ -139,3 +139,11 @@ void RivGeoMechPartMgr::appendGridPartsToModel(cvf::ModelBasicList* model, const } } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::Collection RivGeoMechPartMgr::femPartMgrs() const +{ + return m_femPartPartMgrs; +} diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h index bfdcc552c0..ddaad50a0c 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechPartMgr.h @@ -61,6 +61,7 @@ class RivGeoMechPartMgr: public cvf::Object void appendGridPartsToModel(cvf::ModelBasicList* model, const std::vector& partIndices); void appendGridPartsToModel(cvf::ModelBasicList* model); + const cvf::Collection femPartMgrs() const; private: cvf::Collection m_femPartPartMgrs; diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp index 72c32a601e..33c489f26c 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.cpp @@ -28,7 +28,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RivCellSetEnum.h" @@ -140,29 +140,39 @@ void RivGeoMechVizLogic::scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex) +std::vector RivGeoMechVizLogic::keysToVisiblePartMgrs(int timeStepIndex) const { std::vector visiblePartMgrs; if (m_geomechView->viewController() && m_geomechView->viewController()->isVisibleCellsOveridden()) { visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(OVERRIDDEN_CELL_VISIBILITY, -1)); } - else if (timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters()) + else if ( m_geomechView->isGridVisualizationMode() ) { - visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex)); - } - else if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) - { - visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); - } - else - { - visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); + if ( timeStepIndex >= 0 && m_geomechView->geoMechPropertyFilterCollection()->hasActiveFilters() ) + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(PROPERTY_FILTERED, timeStepIndex)); + } + else if ( m_geomechView->rangeFilterCollection()->hasActiveFilters() ) + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); + } + else + { + visiblePartMgrs.push_back(RivGeoMechPartMgrCache::Key(ALL_CELLS, -1)); + } } - return visiblePartMgrs; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::ref RivGeoMechVizLogic::partMgrCache() const +{ + return m_partMgrCache; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -174,8 +184,13 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache: } RivGeoMechPartMgr* partMgrToUpdate = m_partMgrCache->partMgr(pMgrKey); - RigGeoMechCaseData* caseData = m_geomechView->geoMechCase()->geoMechData(); - int partCount = caseData->femParts()->partCount(); + int partCount = 0; + RigGeoMechCaseData* caseData = nullptr; + if ( m_geomechView->geoMechCase() ) + { + caseData = m_geomechView->geoMechCase()->geoMechData(); + partCount = caseData->femParts()->partCount(); + } if (partMgrToUpdate->initializedFemPartCount() != partCount) { @@ -197,7 +212,7 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache: } else if (pMgrKey.geometryType() == PROPERTY_FILTERED) { - RivGeoMechPartMgr* rangefiltered = NULL; + RivGeoMechPartMgr* rangefiltered = nullptr; if (m_geomechView->rangeFilterCollection()->hasActiveFilters()) { rangefiltered = getUpdatedPartMgr(RivGeoMechPartMgrCache::Key(RANGE_FILTERED, -1)); @@ -244,11 +259,13 @@ RivGeoMechPartMgr* RivGeoMechVizLogic::getUpdatedPartMgr(RivGeoMechPartMgrCache: //-------------------------------------------------------------------------------------------------- void RivGeoMechVizLogic::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex) { - size_t gridCount = m_geomechView->geoMechCase()->geoMechData()->femParts()->partCount(); + if (!m_geomechView->geoMechCase()) return; + + size_t gridCount = m_geomechView->femParts()->partCount(); if (gridCount == 0) return; - RigFemPart* part = m_geomechView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* part = m_geomechView->femParts()->part(0); int elmCount = part->elementCount(); totalVisibility->resize(elmCount); diff --git a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h index 2d0dde9af8..189838fe69 100644 --- a/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h +++ b/ApplicationCode/GeoMech/GeoMechVisualization/RivGeoMechVizLogic.h @@ -43,17 +43,18 @@ class RivGeoMechVizLogic : public cvf::Object explicit RivGeoMechVizLogic(RimGeoMechView * geomView); virtual ~RivGeoMechVizLogic(); - void appendNoAnimPartsToModel(cvf::ModelBasicList* model); - void appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model); - void updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors); - void updateStaticCellColors(int timeStepIndex); - void scheduleGeometryRegen(RivCellSetEnum geometryType); - void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex); + void appendNoAnimPartsToModel(cvf::ModelBasicList* model); + void appendPartsToModel(int timeStepIndex, cvf::ModelBasicList* model); + void updateCellResultColor(int timeStepIndex, RimGeoMechCellColors* cellResultColors); + void updateStaticCellColors(int timeStepIndex); + void scheduleGeometryRegen(RivCellSetEnum geometryType); + void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStepIndex); + std::vector keysToVisiblePartMgrs(int timeStepIndex) const; + const cvf::ref partMgrCache() const; private: - std::vector keysToVisiblePartMgrs(int timeStepIndex); - RivGeoMechPartMgr* getUpdatedPartMgr(RivGeoMechPartMgrCache::Key partMgrKey); - void scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum geometryType); + RivGeoMechPartMgr* getUpdatedPartMgr(RivGeoMechPartMgrCache::Key partMgrKey); + void scheduleRegenOfDirectlyDependentGeometry(RivCellSetEnum geometryType); cvf::ref m_partMgrCache; RimGeoMechView* m_geomechView; diff --git a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt index 75078fa037..57719f104f 100644 --- a/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt +++ b/ApplicationCode/GeoMech/OdbReader/CMakeLists.txt @@ -36,8 +36,6 @@ endif(MSVC) include_directories( ${RESINSIGHT_ODB_API_DIR}/include - ${RigGeoMechDataModel_SOURCE_DIR} - ${LibCore_SOURCE_DIR} ) add_library( ${PROJECT_NAME} @@ -86,4 +84,11 @@ else() ) endif(MSVC) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries(${PROJECT_NAME} ${RI_ODB_LIBS} RigGeoMechDataModel LibCore) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake index 8f5abe05ac..16b6117694 100644 --- a/ApplicationCode/ModelVisualization/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/CMakeLists_files.cmake @@ -1,91 +1,93 @@ -# 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}RivCellEdgeEffectGenerator.h -${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.h -${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivGridPartMgr.h -${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.h -${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.h -${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.h -${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivReservoirFaultsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivReservoirSimWellsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.h -${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.h -${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.h -${CEE_CURRENT_LIST_DIR}RivResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivCompletionTypeResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivDefaultResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivTernaryResultToTextureMapper.h -${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.h -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.h -${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.h -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.h -${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.h -${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.h -${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.h -${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.h -${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.h -${CEE_CURRENT_LIST_DIR}RivPartPriority.h -${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.h -${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeEffectGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivFaultPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivFaultGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivNNCGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivGridPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivTernarySaturationOverlayItem.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirViewPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivPipeGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirFaultsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivReservoirSimWellsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellPathSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellPathPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellPathsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipesPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellHeadPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivCompletionTypeResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivDefaultResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryResultToTextureMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivTextureCoordsCreator.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryTextureCoordsCreator.h +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapperEffectGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivScalarMapperUtils.h +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeGeometryUtils.h +${CMAKE_CURRENT_LIST_DIR}/RivPipeQuadToSegmentMapper.h +${CMAKE_CURRENT_LIST_DIR}/RivSingleCellPartGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipeSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellSpheresPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivPartPriority.h +${CMAKE_CURRENT_LIST_DIR}/RivObjectSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogDrawSurfaceGenerator.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivCellEdgeEffectGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivFaultPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivNNCGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivFaultGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivGridPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivTernarySaturationOverlayItem.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirFaultsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirViewPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivReservoirSimWellsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellPathSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellPathPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivSimWellPipesPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivWellHeadPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivTextureCoordsCreator.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryTextureCoordsCreator.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapperEffectGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivScalarMapperUtils.cpp -${CEE_CURRENT_LIST_DIR}RivCellEdgeGeometryUtils.cpp -${CEE_CURRENT_LIST_DIR}RivPipeQuadToSegmentMapper.cpp -${CEE_CURRENT_LIST_DIR}RivSingleCellPartGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivSimWellPipeSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellSpheresPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivObjectSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivWellConnectionsPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivFishbonesSubsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeEffectGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFaultPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivNNCGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFaultGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGridPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernarySaturationOverlayItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirFaultsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirViewPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPipeGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivReservoirSimWellsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellPathSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellPathPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellPathsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipesPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellHeadPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTextureCoordsCreator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapper.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryTextureCoordsCreator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapperEffectGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivScalarMapperUtils.cpp +${CMAKE_CURRENT_LIST_DIR}/RivCellEdgeGeometryUtils.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPipeQuadToSegmentMapper.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSingleCellPartGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSimWellPipeSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellSpheresPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivObjectSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivFishbonesSubsPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTensorResultPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellFracturePartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogPlanePartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogCurveGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionFactorGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivWellConnectionSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSimWellConnectionSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/Riv3dWellLogDrawSurfaceGenerator.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RivWellFracturePartMgr.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) @@ -94,4 +96,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake index 0049fdae70..3406423cc9 100644 --- a/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/GridBox/CMakeLists_files.cmake @@ -1,17 +1,12 @@ -# 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}RivPatchGenerator.h -${CEE_CURRENT_LIST_DIR}RivGridBoxGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivPatchGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivGridBoxGenerator.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivPatchGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivGridBoxGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPatchGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivGridBoxGenerator.cpp ) @@ -23,4 +18,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization\\GridBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization\\GridBox" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp index 1f7f650fb1..b818027b04 100644 --- a/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp +++ b/ApplicationCode/ModelVisualization/GridBox/RivGridBoxGenerator.cpp @@ -535,8 +535,8 @@ void RivGridBoxGenerator::createLegend(EdgeType edge, cvf::Collection break; } - std::vector* displayCoordsTickValues = NULL; - std::vector* domainCoordsTickValues = NULL; + std::vector* displayCoordsTickValues = nullptr; + std::vector* domainCoordsTickValues = nullptr; if (axis == X_AXIS) { @@ -734,30 +734,8 @@ cvf::Vec3f RivGridBoxGenerator::cornerDirection(FaceType face1, FaceType face2) //-------------------------------------------------------------------------------------------------- void RivGridBoxGenerator::updateFromBackgroundColor(const cvf::Color3f& backgroundColor) { - double adjustmentFactor = 0.3; - - float gridR = 0.0; - float gridG = 0.0; - float gridB = 0.0; - - if (RiaColorTools::isBrightnessAboveThreshold(backgroundColor)) - { - gridR = backgroundColor.r() - (backgroundColor.r() * adjustmentFactor); - gridG = backgroundColor.g() - (backgroundColor.g() * adjustmentFactor); - gridB = backgroundColor.b() - (backgroundColor.b() * adjustmentFactor); - - m_gridLegendColor = RiaColorTools::darkContrastColor(); - } - else - { - gridR = backgroundColor.r() + (1.0 - backgroundColor.r()) * adjustmentFactor; - gridG = backgroundColor.g() + (1.0 - backgroundColor.g()) * adjustmentFactor; - gridB = backgroundColor.b() + (1.0 - backgroundColor.b()) * adjustmentFactor; - - m_gridLegendColor = RiaColorTools::brightContrastColor(); - } - - m_gridColor.set(gridR, gridG, gridB); + m_gridColor = RiaColorTools::computeOffsetColor(backgroundColor, 0.3f); + m_gridLegendColor = RiaColorTools::constrastColor(backgroundColor); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake index c76e7125bd..1b0684cc7c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake +++ b/ApplicationCode/ModelVisualization/Intersections/CMakeLists_files.cmake @@ -1,27 +1,24 @@ -# 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}RivIntersectionGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivIntersectionPartMgr.h -${CEE_CURRENT_LIST_DIR}RivIntersectionSourceInfo.h -${CEE_CURRENT_LIST_DIR}RivHexGridIntersectionTools.h -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxGeometryGenerator.h -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxPartMgr.h -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.h +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxSourceInfo.h +${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattner.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RivIntersectionGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionSourceInfo.cpp -${CEE_CURRENT_LIST_DIR}RivHexGridIntersectionTools.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxGeometryGenerator.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxPartMgr.cpp -${CEE_CURRENT_LIST_DIR}RivIntersectionBoxSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivHexGridIntersectionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxGeometryGenerator.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxPartMgr.cpp +${CMAKE_CURRENT_LIST_DIR}/RivIntersectionBoxSourceInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RivSectionFlattner.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,4 +29,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ModelVisualization\\Intersections" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ModelVisualization\\Intersections" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp index 37bc797ef7..778d5df51c 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.cpp @@ -67,9 +67,9 @@ bool RivEclipseIntersectionGrid::useCell(size_t cellIndex) const { const RigCell& cell = m_mainGrid->globalCellArray()[cellIndex]; if (m_showInactiveCells) - return !(cell.isInvalid() || (cell.subGrid() != NULL)); + return !(cell.isInvalid() || (cell.subGrid() != nullptr)); else - return m_activeCellInfo->isActive(cellIndex) && (cell.subGrid() == NULL); + return m_activeCellInfo->isActive(cellIndex) && (cell.subGrid() == nullptr); } //-------------------------------------------------------------------------------------------------- @@ -89,6 +89,15 @@ void RivEclipseIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t corn memcpy(cornerIndices, cornerIndicesSource.data(), 8); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivEclipseIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const +{ + return m_mainGrid->findFaultFromCellIndexAndCellFace(reservoirCellIndex, face); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -102,7 +111,7 @@ RivFemIntersectionGrid::RivFemIntersectionGrid(const RigFemPart * femPart) : m_f //-------------------------------------------------------------------------------------------------- cvf::Vec3d RivFemIntersectionGrid::displayOffset() const { - return cvf::Vec3d::ZERO; + return m_femPart->boundingBox().min(); } //-------------------------------------------------------------------------------------------------- @@ -172,3 +181,12 @@ void RivFemIntersectionGrid::cellCornerIndices(size_t cellIndex, size_t cornerIn cornerIndices[7] = m_femPart->elementNodeResultIdx(elmIdx, 7); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFault* RivFemIntersectionGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const +{ + return nullptr; +} + diff --git a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h index 0cc00291d5..5d9b147e27 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivHexGridIntersectionTools.h @@ -24,11 +24,12 @@ #include "cvfBoundingBox.h" #include +#include "cvfStructGrid.h" class RigActiveCellInfo; class RigFemPart; class RigMainGrid; - +class RigFault; //-------------------------------------------------------------------------------------------------- /// Interface definition used to compute the geometry for planes intersecting a grid @@ -42,6 +43,8 @@ class RivIntersectionHexGridInterface : public cvf::Object virtual bool useCell(size_t cellIndex) const = 0; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const = 0; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const = 0; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const = 0; }; //-------------------------------------------------------------------------------------------------- @@ -58,6 +61,8 @@ class RivEclipseIntersectionGrid : public RivIntersectionHexGridInterface virtual bool useCell(size_t cellIndex) const; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const override; private: cvf::cref m_mainGrid; @@ -79,6 +84,8 @@ class RivFemIntersectionGrid : public RivIntersectionHexGridInterface virtual bool useCell(size_t cellIndex) const; virtual void cellCornerVertices(size_t cellIndex, cvf::Vec3d cellCorners[8]) const; virtual void cellCornerIndices(size_t cellIndex, size_t cornerIndices[8]) const; + virtual const RigFault* findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, + cvf::StructGridInterface::FaceType face) const override; private: cvf::cref m_femPart; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp index d805946b92..5a634fd745 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxGeometryGenerator.cpp @@ -283,8 +283,8 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays() std::vector hexPlaneCutTriangleVxes; hexPlaneCutTriangleVxes.reserve(5*3); - std::vector isTriangleEdgeCellContour; - isTriangleEdgeCellContour.reserve(5*3); + std::vector cellFaceForEachTriangleEdge; + cellFaceForEachTriangleEdge.reserve(5*3); cvf::Vec3d cellCorners[8]; size_t cornerIndices[8]; @@ -302,20 +302,20 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays() cellCorners, cornerIndices, &hexPlaneCutTriangleVxes, - &isTriangleEdgeCellContour); + &cellFaceForEachTriangleEdge); std::vector clippedTriangleVxes_once; - std::vector isClippedTriEdgeCellContour_once; - caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, - &clippedTriangleVxes_once, &isClippedTriEdgeCellContour_once); + std::vector cellFaceForEachClippedTriangleEdge_once; + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, cellFaceForEachTriangleEdge, p1Plane, p2Plane, + &clippedTriangleVxes_once, &cellFaceForEachClippedTriangleEdge_once); for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes_once) if (!clvx.isVxIdsNative) clvx.derivedVxLevel = 0; std::vector clippedTriangleVxes; - std::vector isClippedTriEdgeCellContour; + std::vector cellFaceForEachClippedTriangleEdge; - caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, isClippedTriEdgeCellContour_once, p3Plane, p4Plane, - &clippedTriangleVxes, &isClippedTriEdgeCellContour); + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(clippedTriangleVxes_once, cellFaceForEachClippedTriangleEdge_once, p3Plane, p4Plane, + &clippedTriangleVxes, &cellFaceForEachClippedTriangleEdge); for (caf::HexGridIntersectionTools::ClipVx& clvx : clippedTriangleVxes) if (!clvx.isVxIdsNative && clvx.derivedVxLevel == -1) clvx.derivedVxLevel = 1; size_t clippedTriangleCount = clippedTriangleVxes.size()/3; @@ -336,18 +336,20 @@ void RivIntersectionBoxGeometryGenerator::calculateArrays() // Accumulate mesh lines + + #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) - if(isClippedTriEdgeCellContour[triVxIdx]) + if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx])) { cellBorderLineVxes.push_back(p0); cellBorderLineVxes.push_back(p1); } - if(isClippedTriEdgeCellContour[triVxIdx+1]) + if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+1])) { cellBorderLineVxes.push_back(p1); cellBorderLineVxes.push_back(p2); } - if(isClippedTriEdgeCellContour[triVxIdx+2]) + if(isFace(cellFaceForEachClippedTriangleEdge[triVxIdx+2])) { cellBorderLineVxes.push_back(p2); cellBorderLineVxes.push_back(p0); diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp index bff87fafa9..000d5decf3 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionBoxPartMgr.cpp @@ -32,7 +32,7 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimIntersectionBox.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivIntersectionBoxSourceInfo.h" @@ -101,7 +101,9 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) { if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); + RivTernaryTextureCoordsCreator texturer(cellResultColors, + cellResultColors->ternaryLegendConfig()->scalarMapper(), + timeStepIndex); texturer.createTextureCoords(m_intersectionBoxFacesTextureCoords.p(), m_intersectionBoxGenerator->triangleToCellIndex()); @@ -160,31 +162,24 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); - const std::vector &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); + const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - if (!(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) ) + if (resVarAddress.resultPosType == RIG_ELEMENT) { - // Do a "Hack" to show elm nodal and not nodal POR results - if ( resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar" ) resVarAddress.resultPosType = RIG_ELEMENT_NODAL; - - const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); - RigFemPart* femPart = caseData->femParts()->part(0); - bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); - - RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), - vertexWeights, - resultValues, - isElementNodalResult, - femPart, - mapper); + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + const std::vector& triangleToCellIdx = m_intersectionBoxGenerator->triangleToCellIndex(); + + RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), + resultValues, + triangleToCellIdx, + mapper); } - else + else if (resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) { // Special direction sensitive result calculation const cvf::Vec3fArray* triangelVxes = m_intersectionBoxGenerator->triangleVxes(); - if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" ) + if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc") { RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_intersectionBoxFacesTextureCoords.p(), triangelVxes, @@ -193,15 +188,34 @@ void RivIntersectionBoxPartMgr::updateCellResultColor(size_t timeStepIndex) } else { + const std::vector &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); + RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_intersectionBoxFacesTextureCoords.p(), - triangelVxes, - vertexWeights, - caseData, - resVarAddress, - (int)timeStepIndex, - mapper); + triangelVxes, + vertexWeights, + caseData, + resVarAddress, + (int)timeStepIndex, + mapper); } } + else + { + // Do a "Hack" to show elm nodal and not nodal POR results + if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; + + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + RigFemPart* femPart = caseData->femParts()->part(0); + bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); + const std::vector &vertexWeights = m_intersectionBoxGenerator->triangleVxToCellCornerInterpolationWeights(); + + RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_intersectionBoxFacesTextureCoords.p(), + vertexWeights, + resultValues, + isElementNodalResult, + femPart, + mapper); + } RivScalarMapperUtils::applyTextureResultsToPart(m_intersectionBoxFaces.p(), m_intersectionBoxFacesTextureCoords.p(), @@ -241,7 +255,7 @@ void RivIntersectionBoxPartMgr::generatePartGeometry() part->setSourceInfo(si.p()); part->updateBoundingBox(); - part->setEnableMask(faultBit); + part->setEnableMask(intersectionCellFaceBit); part->setPriority(RivPartPriority::PartType::Intersection); m_intersectionBoxFaces = part; @@ -263,7 +277,7 @@ void RivIntersectionBoxPartMgr::generatePartGeometry() part->setDrawable(geoMesh.p()); part->updateBoundingBox(); - part->setEnableMask(meshFaultBit); + part->setEnableMask(intersectionCellMeshBit); part->setPriority(RivPartPriority::PartType::MeshLines); m_intersectionBoxGridLines = part; @@ -357,7 +371,7 @@ cvf::ref RivIntersectionBoxPartMgr::createHexGr m_rimIntersectionBox->firstAncestorOrThisOfType(geoView); if (geoView) { - RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geoView->femParts()->part(0); return new RivFemIntersectionGrid(femPart); } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp index f6ff7b167d..b1ed7216d2 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.cpp @@ -23,10 +23,13 @@ #include "RigResultAccessor.h" #include "RimIntersection.h" +#include "Rim3dView.h" #include "RivHexGridIntersectionTools.h" +#include "RivIntersectionPartMgr.h" #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" +#include "cafDisplayCoordTransform.h" #include "cvfDrawableGeo.h" #include "cvfGeometryTools.h" @@ -34,22 +37,43 @@ #include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetIndexedUInt.h" #include "cvfScalarMapper.h" +#include "cvfRay.h" +#include "RivSectionFlattner.h" + + +cvf::ref displayCoordTransform(const RimIntersection* intersection) +{ + Rim3dView* rimView = nullptr; + intersection->firstAncestorOrThisOfType(rimView); + CVF_ASSERT(rimView); + + cvf::ref transForm = rimView->displayCoordTransform(); + return transForm; +} //-------------------------------------------------------------------------------------------------- -/// +/// isFlattened means to transform each flat section of the intersection onto the XZ plane +/// placed adjacent to each other as if they were rotated around the common extrusion line like a hinge //-------------------------------------------------------------------------------------------------- RivIntersectionGeometryGenerator::RivIntersectionGeometryGenerator( RimIntersection* crossSection, std::vector > &polylines, const cvf::Vec3d& extrusionDirection, - const RivIntersectionHexGridInterface* grid) + const RivIntersectionHexGridInterface* grid, + bool isFlattened, + const cvf::Vec3d& flattenedPolylineStartPoint) : m_crossSection(crossSection), m_polyLines(polylines), m_extrusionDirection(extrusionDirection), - m_hexGrid(grid) + m_hexGrid(grid), + m_isFlattened(isFlattened), + m_flattenedPolylineStartPoint(flattenedPolylineStartPoint) { m_triangleVxes = new cvf::Vec3fArray; m_cellBorderLineVxes = new cvf::Vec3fArray; + m_faultCellBorderLineVxes = new cvf::Vec3fArray; + + if (m_isFlattened) m_extrusionDirection = -cvf::Vec3d::Z_AXIS; } //-------------------------------------------------------------------------------------------------- @@ -60,6 +84,120 @@ RivIntersectionGeometryGenerator::~RivIntersectionGeometryGenerator() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionGeometryGenerator::calculateSegementTransformPrLinePoint() +{ + if ( m_isFlattened ) + { + if ( !(m_polyLines.size() && m_polyLines.back().size()) ) return; + + cvf::Vec3d startOffset = m_flattenedPolylineStartPoint; + + for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) + { + const std::vector& polyLine = m_polyLines[pLineIdx]; + startOffset.z() = polyLine[0].z(); + m_segementTransformPrLinePoint.emplace_back(RivSectionFlattner::calculateFlatteningCSsForPolyline(polyLine, + m_extrusionDirection, + startOffset, + &startOffset)); + } + } + else + { + m_segementTransformPrLinePoint.clear(); + + cvf::Mat4d invSectionCS = cvf::Mat4d::fromTranslation(-m_hexGrid->displayOffset()); + + for ( const auto & polyLine : m_polyLines ) + { + m_segementTransformPrLinePoint.emplace_back(); + std::vector& segmentTransforms = m_segementTransformPrLinePoint.back(); + for ( size_t lIdx = 0; lIdx < polyLine.size(); ++lIdx ) + { + segmentTransforms.push_back(invSectionCS); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionGeometryGenerator::calculateFlattenedOrOffsetedPolyline() +{ + CVF_ASSERT(m_segementTransformPrLinePoint.size() == m_polyLines.size()); + + for ( size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx ) + { + m_flattenedOrOffsettedPolyLines.emplace_back(); + const std::vector& polyLine = m_polyLines[pLineIdx]; + + CVF_ASSERT(polyLine.size() == m_polyLines[pLineIdx].size()); + + for ( size_t pIdx = 0; pIdx < polyLine.size(); ++pIdx ) + { + m_flattenedOrOffsettedPolyLines.back().push_back(polyLine[pIdx].getTransformedPoint(m_segementTransformPrLinePoint[pLineIdx][pIdx])); + } + } +} + + +class MeshLinesAccumulator +{ +public: + MeshLinesAccumulator(const RivIntersectionHexGridInterface* hexGrid) + : m_hexGrid(hexGrid) + {} + + std::vector cellBorderLineVxes; + std::vector faultCellBorderLineVxes; + std::map faultToHighestFaultMeshVxMap; + + void accumulateMeshLines(const std::vector& cellFaceForEachClippedTriangleEdge, + uint triVxIdx, + size_t globalCellIdx, + const cvf::Vec3d& p0, + const cvf::Vec3d& p1) + { + #define isFace( faceEnum ) (0 <= faceEnum && faceEnum <= 5 ) + using FaceType = cvf::StructGridInterface::FaceType; + + if ( isFace(cellFaceForEachClippedTriangleEdge[triVxIdx]) ) + { + const RigFault * fault = m_hexGrid->findFaultFromCellIndexAndCellFace(globalCellIdx, + (FaceType)cellFaceForEachClippedTriangleEdge[triVxIdx]); + if ( fault ) + { + cvf::Vec3d highestVx = p0.z() > p1.z() ? p0 : p1; + + auto itIsInsertedPair = faultToHighestFaultMeshVxMap.insert({fault, highestVx}); + if (!itIsInsertedPair.second) + { + if (itIsInsertedPair.first->second.z() < highestVx.z()) + { + itIsInsertedPair.first->second = highestVx; + } + } + + faultCellBorderLineVxes.emplace_back(p0); + faultCellBorderLineVxes.emplace_back(p1); + } + else + { + cellBorderLineVxes.emplace_back(p0); + cellBorderLineVxes.emplace_back(p1); + } + } + } + +private: + cvf::cref m_hexGrid; +}; + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -69,24 +207,32 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_extrusionDirection.normalize(); std::vector triangleVertices; - std::vector cellBorderLineVxes; + + MeshLinesAccumulator meshAcc(m_hexGrid.p()); + cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); cvf::BoundingBox gridBBox = m_hexGrid->boundingBox(); + + calculateSegementTransformPrLinePoint(); + calculateFlattenedOrOffsetedPolyline(); for (size_t pLineIdx = 0; pLineIdx < m_polyLines.size(); ++pLineIdx) { - const std::vector& m_polyLine = m_polyLines[pLineIdx]; - - if (m_polyLine.size() < 2) continue; + const std::vector& polyLine = m_polyLines[pLineIdx]; - std::vector m_adjustedPolyline; - adjustPolyline(m_polyLine, m_extrusionDirection, &m_adjustedPolyline); + if (polyLine.size() < 2) continue; - size_t lineCount = m_adjustedPolyline.size(); - for (size_t lIdx = 0; lIdx < lineCount - 1; ++lIdx) + size_t lineCount = polyLine.size(); + size_t lIdx = 0; + while ( lIdx < lineCount - 1) { - cvf::Vec3d p1 = m_adjustedPolyline[lIdx]; - cvf::Vec3d p2 = m_adjustedPolyline[lIdx+1]; + size_t idxToNextP = RivSectionFlattner::indexToNextValidPoint(polyLine, m_extrusionDirection, lIdx); + + if (idxToNextP == size_t(-1)) break; + + cvf::Vec3d p1 = polyLine[lIdx]; + cvf::Vec3d p2 = polyLine[idxToNextP]; + cvf::BoundingBox sectionBBox; sectionBBox.add(p1); @@ -141,11 +287,13 @@ void RivIntersectionGeometryGenerator::calculateArrays() std::vector hexPlaneCutTriangleVxes; hexPlaneCutTriangleVxes.reserve(5*3); - std::vector isTriangleEdgeCellContour; - isTriangleEdgeCellContour.reserve(5*3); + std::vector cellFaceForEachTriangleEdge; + cellFaceForEachTriangleEdge.reserve(5*3); cvf::Vec3d cellCorners[8]; size_t cornerIndices[8]; + cvf::Mat4d invSectionCS = m_segementTransformPrLinePoint[pLineIdx][lIdx]; + for (size_t cccIdx = 0; cccIdx < columnCellCandidates.size(); ++cccIdx) { size_t globalCellIdx = columnCellCandidates[cccIdx]; @@ -157,10 +305,10 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_hexGrid->cellCornerIndices(globalCellIdx, cornerIndices); caf::HexGridIntersectionTools::planeHexIntersectionMC(plane, - cellCorners, - cornerIndices, - &hexPlaneCutTriangleVxes, - &isTriangleEdgeCellContour); + cellCorners, + cornerIndices, + &hexPlaneCutTriangleVxes, + &cellFaceForEachTriangleEdge); if (m_crossSection->type == RimIntersection::CS_AZIMUTHLINE) { @@ -194,10 +342,14 @@ void RivIntersectionGeometryGenerator::calculateArrays() } std::vector clippedTriangleVxes; - std::vector isClippedTriEdgeCellContour; + std::vector cellFaceForEachClippedTriangleEdge; - caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, isTriangleEdgeCellContour, p1Plane, p2Plane, - &clippedTriangleVxes, &isClippedTriEdgeCellContour); + caf::HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(hexPlaneCutTriangleVxes, + cellFaceForEachTriangleEdge, + p1Plane, + p2Plane, + &clippedTriangleVxes, + &cellFaceForEachClippedTriangleEdge); size_t clippedTriangleCount = clippedTriangleVxes.size()/3; @@ -207,33 +359,26 @@ void RivIntersectionGeometryGenerator::calculateArrays() // Accumulate triangle vertices - cvf::Vec3f p0(clippedTriangleVxes[triVxIdx+0].vx - displayOffset); - cvf::Vec3f p1(clippedTriangleVxes[triVxIdx+1].vx - displayOffset); - cvf::Vec3f p2(clippedTriangleVxes[triVxIdx+2].vx - displayOffset); + cvf::Vec3d p0(clippedTriangleVxes[triVxIdx+0].vx); + cvf::Vec3d p1(clippedTriangleVxes[triVxIdx+1].vx); + cvf::Vec3d p2(clippedTriangleVxes[triVxIdx+2].vx); - triangleVertices.push_back(p0); - triangleVertices.push_back(p1); - triangleVertices.push_back(p2); + p0 = p0.getTransformedPoint(invSectionCS); + p1 = p1.getTransformedPoint(invSectionCS); + p2 = p2.getTransformedPoint(invSectionCS); + triangleVertices.emplace_back(p0); + triangleVertices.emplace_back(p1); + triangleVertices.emplace_back(p2); - // Accumulate mesh lines - if (isClippedTriEdgeCellContour[triVxIdx]) - { - cellBorderLineVxes.push_back(p0); - cellBorderLineVxes.push_back(p1); - } - if (isClippedTriEdgeCellContour[triVxIdx+1]) - { - cellBorderLineVxes.push_back(p1); - cellBorderLineVxes.push_back(p2); - } - if (isClippedTriEdgeCellContour[triVxIdx+2]) - { - cellBorderLineVxes.push_back(p2); - cellBorderLineVxes.push_back(p0); - } + // Accumulate mesh lines + meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 0, globalCellIdx, p0, p1); + meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 1, globalCellIdx, p1, p2); + meshAcc.accumulateMeshLines(cellFaceForEachClippedTriangleEdge, triVxIdx + 2, globalCellIdx, p2, p0); + + // Mapping to cell index m_triangleToCellIdxMap.push_back(globalCellIdx); @@ -254,17 +399,24 @@ void RivIntersectionGeometryGenerator::calculateArrays() m_triVxToCellCornerWeights.push_back( RivIntersectionVertexWeights(cvx1.clippedEdgeVx1Id, cvx1.clippedEdgeVx2Id, cvx1.normDistFromEdgeVx1, - cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, - cvx.normDistFromEdgeVx1)); - + cvx2.clippedEdgeVx1Id, cvx2.clippedEdgeVx2Id, cvx2.normDistFromEdgeVx1, + cvx.normDistFromEdgeVx1)); } } } } + lIdx = idxToNextP; } } + m_triangleVxes->assign(triangleVertices); - m_cellBorderLineVxes->assign(cellBorderLineVxes); + m_cellBorderLineVxes->assign(meshAcc.cellBorderLineVxes); + m_faultCellBorderLineVxes->assign(meshAcc.faultCellBorderLineVxes); + + for (const auto& it : meshAcc.faultToHighestFaultMeshVxMap) + { + m_faultMeshLabelAndAnchorPositions.push_back( { it.first->name(), it.second } ); + } } @@ -306,12 +458,46 @@ cvf::ref RivIntersectionGeometryGenerator::createMeshDrawable( } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createFaultMeshDrawable() +{ + if (!(m_faultCellBorderLineVxes.notNull() && m_faultCellBorderLineVxes->size() != 0)) return nullptr; + + cvf::ref geo = new cvf::DrawableGeo; + geo->setVertexArray(m_faultCellBorderLineVxes.p()); + + + cvf::ref prim = new cvf::PrimitiveSetDirect(cvf::PT_LINES); + prim->setIndexCount(m_faultCellBorderLineVxes->size()); + + geo->addPrimitiveSet(prim.p()); + return geo; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::ref RivIntersectionGeometryGenerator::createLineAlongPolylineDrawable() { - return createLineAlongPolylineDrawable(m_polyLines); + return createLineAlongPolylineDrawable(m_flattenedOrOffsettedPolyLines); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createLineAlongExtrusionLineDrawable(const std::vector& extrusionLine) +{ + cvf::ref transform = displayCoordTransform(crossSection()); + std::vector displayCoords; + + for (const auto& pt : extrusionLine) + { + displayCoords.push_back(transform->translateToDisplayCoord(pt)); + } + + return createLineAlongPolylineDrawable(std::vector>({ displayCoords })); } //-------------------------------------------------------------------------------------------------- @@ -322,8 +508,6 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly std::vector lineIndices; std::vector vertices; - cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); - for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx) { const std::vector& polyLine = polyLines[pLineIdx]; @@ -331,7 +515,7 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly for (size_t i = 0; i < polyLine.size(); ++i) { - vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset)); + vertices.push_back(cvf::Vec3f(polyLine[i])); if (i < polyLine.size() - 1) { lineIndices.push_back(static_cast(i)); @@ -362,9 +546,24 @@ cvf::ref RivIntersectionGeometryGenerator::createLineAlongPoly //-------------------------------------------------------------------------------------------------- cvf::ref RivIntersectionGeometryGenerator::createPointsFromPolylineDrawable() { - return createPointsFromPolylineDrawable(m_polyLines); + return createPointsFromPolylineDrawable(m_flattenedOrOffsettedPolyLines); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivIntersectionGeometryGenerator::createPointsFromExtrusionLineDrawable(const std::vector& extrusionLine) +{ + cvf::ref transform = displayCoordTransform(crossSection()); + std::vector displayCoords; + + for (const auto& pt : extrusionLine) + { + displayCoords.push_back(transform->translateToDisplayCoord(pt)); + } + + return createPointsFromPolylineDrawable(std::vector>({displayCoords})); +} //-------------------------------------------------------------------------------------------------- /// @@ -373,14 +572,12 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol { std::vector vertices; - cvf::Vec3d displayOffset = m_hexGrid->displayOffset(); - for (size_t pLineIdx = 0; pLineIdx < polyLines.size(); ++pLineIdx) { const std::vector& polyLine = polyLines[pLineIdx]; for (size_t i = 0; i < polyLine.size(); ++i) { - vertices.push_back(cvf::Vec3f(polyLine[i] - displayOffset)); + vertices.push_back(cvf::Vec3f(polyLine[i])); } } @@ -400,32 +597,6 @@ cvf::ref RivIntersectionGeometryGenerator::createPointsFromPol } -//-------------------------------------------------------------------------------------------------- -/// Remove the lines from the polyline that is nearly parallel to the extrusion direction -//-------------------------------------------------------------------------------------------------- -void RivIntersectionGeometryGenerator::adjustPolyline(const std::vector& polyLine, - const cvf::Vec3d extrDir, - std::vector* adjustedPolyline) -{ - size_t lineCount = polyLine.size(); - if (!polyLine.size()) return; - - adjustedPolyline->push_back(polyLine[0]); - cvf::Vec3d p1 = polyLine[0]; - - for (size_t lIdx = 1; lIdx < lineCount; ++lIdx) - { - cvf::Vec3d p2 = polyLine[lIdx]; - cvf::Vec3d p1p2 = p2 - p1; - - if ((p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) - { - adjustedPolyline->push_back(p2); - p1 = p2; - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -461,6 +632,34 @@ RimIntersection* RivIntersectionGeometryGenerator::crossSection() const return m_crossSection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivIntersectionGeometryGenerator::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat) +{ + cvf::Mat4d flattenMx = cvf::Mat4d::IDENTITY; + + for ( size_t pLineIdx = 0; pLineIdx < m_flattenedOrOffsettedPolyLines.size(); pLineIdx++ ) + { + const std::vector& polyLine = m_flattenedOrOffsettedPolyLines[pLineIdx]; + for(size_t pIdx = 0; pIdx < polyLine.size(); pIdx++) + { + if (polyLine[pIdx].x() >= intersectionPointFlat.x() ) + { + size_t csIdx = pIdx > 0 ? pIdx - 1: 0; + flattenMx = m_segementTransformPrLinePoint[pLineIdx][csIdx]; + break; + } + else if (pIdx == polyLine.size() - 1) + { + flattenMx = m_segementTransformPrLinePoint[pLineIdx][pIdx]; + } + } + } + + return flattenMx.getInverted(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h index 28b8cdbdbd..5c8a08fcea 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionGeometryGenerator.h @@ -29,6 +29,8 @@ #include +#include + class RigMainGrid; class RigActiveCellInfo; class RigResultAccessor; @@ -49,7 +51,9 @@ class RivIntersectionGeometryGenerator : public cvf::Object RivIntersectionGeometryGenerator(RimIntersection* crossSection, std::vector > &polylines, const cvf::Vec3d& extrusionDirection, - const RivIntersectionHexGridInterface* grid ); + const RivIntersectionHexGridInterface* grid, + bool isFlattened, + const cvf::Vec3d& flattenedPolylineStartPoint); ~RivIntersectionGeometryGenerator(); @@ -58,12 +62,16 @@ class RivIntersectionGeometryGenerator : public cvf::Object // Generate geometry cvf::ref generateSurface(); cvf::ref createMeshDrawable(); + cvf::ref createFaultMeshDrawable(); + cvf::ref createLineAlongPolylineDrawable(); + cvf::ref createLineAlongExtrusionLineDrawable(const std::vector& extrusionLine); cvf::ref createPointsFromPolylineDrawable(); + cvf::ref createPointsFromExtrusionLineDrawable(const std::vector& extrusionLine); - cvf::ref createLineAlongPolylineDrawable(const std::vector >& polyLines); - cvf::ref createPointsFromPolylineDrawable(const std::vector >& polyLines); - + const std::vector >& flattenedOrOffsettedPolyLines() { return m_flattenedOrOffsettedPolyLines; } + const std::vector > & faultMeshLabelAndAnchorPositions() { return m_faultMeshLabelAndAnchorPositions; } + // Mapping between cells and geometry const std::vector& triangleToCellIndex() const; @@ -72,22 +80,36 @@ class RivIntersectionGeometryGenerator : public cvf::Object RimIntersection* crossSection() const; -private: - void calculateArrays(); - static void adjustPolyline(const std::vector& polyLine, - const cvf::Vec3d extrDir, - std::vector* adjustedPolyline); - - cvf::cref m_hexGrid; - const std::vector > m_polyLines; - cvf::Vec3d m_extrusionDirection; + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); - // Output arrays - cvf::ref m_triangleVxes; - cvf::ref m_cellBorderLineVxes; - std::vector m_triangleToCellIdxMap; - std::vector m_triVxToCellCornerWeights; +private: + cvf::ref createLineAlongPolylineDrawable(const std::vector >& polyLines); + cvf::ref createPointsFromPolylineDrawable(const std::vector >& polyLines); - RimIntersection* m_crossSection; + void calculateArrays(); + void calculateSegementTransformPrLinePoint(); + void calculateFlattenedOrOffsetedPolyline(); + + //static size_t indexToNextValidPoint(const std::vector& polyLine, + // const cvf::Vec3d extrDir, + // size_t idxToStartOfLineSegment); + + RimIntersection* m_crossSection; + cvf::cref m_hexGrid; + const std::vector > m_polyLines; + cvf::Vec3d m_extrusionDirection; + bool m_isFlattened; + cvf::Vec3d m_flattenedPolylineStartPoint; + + // Output arrays + cvf::ref m_triangleVxes; + cvf::ref m_cellBorderLineVxes; + cvf::ref m_faultCellBorderLineVxes; + std::vector m_triangleToCellIdxMap; + std::vector m_triVxToCellCornerWeights; + std::vector > m_flattenedOrOffsettedPolyLines; + std::vector > m_segementTransformPrLinePoint; + + std::vector > m_faultMeshLabelAndAnchorPositions; }; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp index f873631b24..4f11900fd8 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.cpp @@ -26,52 +26,83 @@ #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" +#include "Rim2dIntersectionView.h" #include "RimIntersection.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" +#include "RimSimWellInView.h" +#include "RimSimWellInViewCollection.h" #include "RimTernaryLegendConfig.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" #include "RivHexGridIntersectionTools.h" #include "RivIntersectionGeometryGenerator.h" +#include "RivObjectSourceInfo.h" #include "RivIntersectionSourceInfo.h" #include "RivPartPriority.h" +#include "RivPipeGeometryGenerator.h" #include "RivResultToTextureMapper.h" #include "RivScalarMapperUtils.h" +#include "RivSimWellPipeSourceInfo.h" #include "RivTernaryScalarMapper.h" #include "RivTernaryTextureCoordsCreator.h" +#include "RivWellPathSourceInfo.h" #include "RiuGeoMechXfTensorResultAccessor.h" #include "cafTensor3.h" #include "cvfDrawableGeo.h" +#include "cvfDrawableText.h" #include "cvfGeometryTools.h" #include "cvfModelBasicList.h" #include "cvfPart.h" +#include "cvfqtUtils.h" #include "cvfPrimitiveSetDirect.h" #include "cvfRenderState_FF.h" #include "cvfRenderStateDepth.h" #include "cvfRenderStatePoint.h" #include "cvfStructGridGeometryGenerator.h" +#include "cvfTransform.h" + +#include +#include "RiaApplication.h" +#include "RiaPreferences.h" +#include "RimFaultInView.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection) +RivIntersectionPartMgr::RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened) : m_rimCrossSection(rimCrossSection), - m_defaultColor(cvf::Color3::WHITE) + m_isFlattened(isFlattened) { CVF_ASSERT(m_rimCrossSection); m_crossSectionFacesTextureCoords = new cvf::Vec2fArray; + + cvf::Vec3d flattenedPolylineStartPoint; - computeData(); + std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(&flattenedPolylineStartPoint); + if (polyLines.size() > 0) + { + cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); + cvf::ref hexGrid = createHexGridInterface(); + m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, + polyLines, + direction, + hexGrid.p(), + m_isFlattened, + flattenedPolylineStartPoint); + } } //-------------------------------------------------------------------------------------------------- @@ -81,15 +112,46 @@ void RivIntersectionPartMgr::applySingleColorEffect() { if (m_crossSectionGenerator.isNull()) return; - m_defaultColor = cvf::Color3f::OLIVE;//m_rimCrossSection->CrossSectionColor(); - this->updatePartEffect(); + caf::SurfaceEffectGenerator geometryEffgen(cvf::Color3f::OLIVE, caf::PO_1); + + cvf::ref geometryOnlyEffect = geometryEffgen.generateCachedEffect(); + + if (m_crossSectionFaces.notNull()) + { + m_crossSectionFaces->setEffect(geometryOnlyEffect.p()); + } + + // Update mesh colors as well, in case of change + RiaPreferences* prefs = RiaApplication::instance()->preferences(); + + if (m_crossSectionGridLines.notNull()) + { + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + + m_crossSectionGridLines->setEffect(eff.p()); + } + + if (m_crossSectionFaultGridLines.notNull()) + { + cvf::ref eff; + caf::MeshEffectGenerator CrossSectionEffGen(prefs->defaultFaultGridLineColors()); + eff = CrossSectionEffGen.generateCachedEffect(); + + m_crossSectionFaultGridLines->setEffect(eff.p()); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) +void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper) { + CVF_ASSERT(scalarColorMapper); + if (m_crossSectionGenerator.isNull()) return; if (!m_crossSectionGenerator->isAnyGeometryPresent()) return; @@ -101,6 +163,7 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { RimEclipseCellColors* cellResultColors = eclipseView->cellResult(); CVF_ASSERT(cellResultColors); + CVF_ASSERT(ternaryColorMapper); RigEclipseCaseData* eclipseCase = eclipseView->eclipseCase()->eclipseCaseData(); @@ -109,14 +172,13 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { if (cellResultColors->isTernarySaturationSelected()) { - RivTernaryTextureCoordsCreator texturer(cellResultColors, cellResultColors->ternaryLegendConfig(), timeStepIndex); + RivTernaryTextureCoordsCreator texturer(cellResultColors, ternaryColorMapper, timeStepIndex); texturer.createTextureCoords(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex()); - const RivTernaryScalarMapper* mapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); RivScalarMapperUtils::applyTernaryTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + ternaryColorMapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); @@ -125,7 +187,6 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) { CVF_ASSERT(m_crossSectionGenerator.notNull()); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); cvf::ref resultAccessor; if (RiaDefines::isPerCellFaceResult(cellResultColors->resultVariable())) @@ -143,12 +204,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RivIntersectionPartMgr::calculateEclipseTextureCoordinates(m_crossSectionFacesTextureCoords.p(), m_crossSectionGenerator->triangleToCellIndex(), resultAccessor.p(), - mapper); + scalarColorMapper); RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + scalarColorMapper, 1.0, caf::FC_NONE, eclipseView->isLightingDisabled()); @@ -168,52 +229,63 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) RigFemResultAddress resVarAddress = cellResultColors->resultAddress(); - const std::vector &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); - const cvf::ScalarMapper* mapper = cellResultColors->legendConfig()->scalarMapper(); - - if(!(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) ) + if (resVarAddress.resultPosType == RIG_ELEMENT) { - // Do a "Hack" to show elm nodal and not nodal POR results - if(resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; - - const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); - RigFemPart* femPart = caseData->femParts()->part(0); - bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); - - RivIntersectionPartMgr::calculateGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), - vertexWeights, - resultValues, - isElementNodalResult, - femPart, - mapper); + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + const std::vector& triangleToCellIdx = m_crossSectionGenerator->triangleToCellIndex(); + + RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), + resultValues, + triangleToCellIdx, + scalarColorMapper); + } - else + else if(resVarAddress.resultPosType == RIG_ELEMENT_NODAL_FACE) { // Special direction sensitive result calculation const cvf::Vec3fArray* triangelVxes = m_crossSectionGenerator->triangleVxes(); - if ( resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc" ) + if (resVarAddress.componentName == "Pazi" || resVarAddress.componentName == "Pinc") { RivIntersectionPartMgr::calculatePlaneAngleTextureCoords(m_crossSectionFacesTextureCoords.p(), - triangelVxes, + triangelVxes, resVarAddress, - mapper); + scalarColorMapper); } else { + const std::vector &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); + RivIntersectionPartMgr::calculateGeoMechTensorXfTextureCoords(m_crossSectionFacesTextureCoords.p(), triangelVxes, vertexWeights, caseData, resVarAddress, (int)timeStepIndex, - mapper); + scalarColorMapper); } } + else + { + // Do a "Hack" to show elm nodal and not nodal POR results + if (resVarAddress.resultPosType == RIG_NODAL && resVarAddress.fieldName == "POR-Bar") resVarAddress.resultPosType = RIG_ELEMENT_NODAL; + + const std::vector& resultValues = caseData->femPartResults()->resultValues(resVarAddress, 0, (int)timeStepIndex); + RigFemPart* femPart = caseData->femParts()->part(0); + bool isElementNodalResult = !(resVarAddress.resultPosType == RIG_NODAL); + const std::vector &vertexWeights = m_crossSectionGenerator->triangleVxToCellCornerInterpolationWeights(); + + RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(m_crossSectionFacesTextureCoords.p(), + vertexWeights, + resultValues, + isElementNodalResult, + femPart, + scalarColorMapper); + } RivScalarMapperUtils::applyTextureResultsToPart(m_crossSectionFaces.p(), m_crossSectionFacesTextureCoords.p(), - mapper, + scalarColorMapper, 1.0, caf::FC_NONE, geoView->isLightingDisabled()); @@ -224,12 +296,12 @@ void RivIntersectionPartMgr::updateCellResultColor(size_t timeStepIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector &vertexWeights, - const std::vector &resultValues, - bool isElementNodalResult, - const RigFemPart* femPart, - const cvf::ScalarMapper* mapper) +void RivIntersectionPartMgr::calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &vertexWeights, + const std::vector &resultValues, + bool isElementNodalResult, + const RigFemPart* femPart, + const cvf::ScalarMapper* mapper) { textureCoords->resize(vertexWeights.size()); @@ -250,8 +322,16 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text int weightCount = vertexWeights[triangleVxIdx].size(); for (int wIdx = 0; wIdx < weightCount; ++wIdx) { - size_t resIdx = isElementNodalResult ? vertexWeights[triangleVxIdx].vxId(wIdx) : - femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx)); + size_t resIdx; + if (isElementNodalResult) + { + resIdx = vertexWeights[triangleVxIdx].vxId(wIdx); + } + else + { + resIdx = femPart->nodeIdxFromElementNodeResultIdx(vertexWeights[triangleVxIdx].vxId(wIdx)); + } + resValue += resultValues[resIdx] * vertexWeights[triangleVxIdx].weight(wIdx); } @@ -267,6 +347,47 @@ void RivIntersectionPartMgr::calculateGeoMechTextureCoords(cvf::Vec2fArray* text } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionPartMgr::calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &resultValues, + const std::vector& triangleToCellIdx, + const cvf::ScalarMapper* mapper) +{ + textureCoords->resize(triangleToCellIdx.size()*3); + + if (resultValues.size() == 0) + { + textureCoords->setAll(cvf::Vec2f(0.0, 1.0f)); + } + else + { + cvf::Vec2f* rawPtr = textureCoords->ptr(); + + for (size_t triangleIdx = 0; triangleIdx < triangleToCellIdx.size(); triangleIdx++) + { + size_t resIdx = triangleToCellIdx[triangleIdx]; + float resValue = resultValues[resIdx]; + + size_t triangleVxIdx = triangleIdx * 3; + + if (resValue == HUGE_VAL || resValue != resValue) // a != a is true for NAN's + { + rawPtr[triangleVxIdx][1] = 1.0f; + rawPtr[triangleVxIdx + 1][1] = 1.0f; + rawPtr[triangleVxIdx + 2][1] = 1.0f; + } + else + { + rawPtr[triangleVxIdx] = mapper->mapToTextureCoord(resValue); + rawPtr[triangleVxIdx + 1] = mapper->mapToTextureCoord(resValue); + rawPtr[triangleVxIdx + 2] = mapper->mapToTextureCoord(resValue); + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -411,14 +532,14 @@ void RivIntersectionPartMgr::generatePartGeometry() part->setSourceInfo(si.p()); part->updateBoundingBox(); - part->setEnableMask(faultBit); + part->setEnableMask(intersectionCellFaceBit); part->setPriority(RivPartPriority::PartType::Intersection); m_crossSectionFaces = part; } } - // Mesh geometry + // Cell Mesh geometry { cvf::ref geoMesh = m_crossSectionGenerator->createMeshDrawable(); if (geoMesh.notNull()) @@ -433,20 +554,138 @@ void RivIntersectionPartMgr::generatePartGeometry() part->setDrawable(geoMesh.p()); part->updateBoundingBox(); - part->setEnableMask(meshFaultBit); + part->setEnableMask(intersectionCellMeshBit); part->setPriority(RivPartPriority::PartType::MeshLines); m_crossSectionGridLines = part; } } + // Fault Mesh geometry + { + cvf::ref geoMesh = m_crossSectionGenerator->createFaultMeshDrawable(); + if (geoMesh.notNull()) + { + if (useBufferObjects) + { + geoMesh->setRenderMode(cvf::DrawableGeo::BUFFER_OBJECT); + } + + cvf::ref part = new cvf::Part; + part->setName("Cross Section faultmesh"); + part->setDrawable(geoMesh.p()); + + part->updateBoundingBox(); + part->setEnableMask(intersectionFaultMeshBit); + part->setPriority(RivPartPriority::PartType::FaultMeshLines); + + m_crossSectionFaultGridLines = part; + } + } createPolyLineParts(useBufferObjects); createExtrusionDirParts(useBufferObjects); - updatePartEffect(); + if (m_isFlattened) createFaultLabelParts(m_crossSectionGenerator->faultMeshLabelAndAnchorPositions()); + + applySingleColorEffect(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivIntersectionPartMgr::createFaultLabelParts(const std::vector >& labelAndAnchors) +{ + m_faultMeshLabels = nullptr; + m_faultMeshLabelLines = nullptr; + + if (!labelAndAnchors.size()) return; + + RimEclipseView* eclipseView = nullptr; + m_rimCrossSection->firstAncestorOrThisOfType(eclipseView); + RimFaultInViewCollection* faultInViewColl = eclipseView->faultCollection(); + + if (!(eclipseView && faultInViewColl->showFaultLabel())) return; + + cvf::Color3f defWellLabelColor = faultInViewColl->faultLabelColor(); + cvf::Font* font = RiaApplication::instance()->customFont(); + + std::vector lineVertices; + + cvf::ref drawableText = new cvf::DrawableText; + { + drawableText->setFont(font); + drawableText->setCheckPosVisible(false); + drawableText->setDrawBorder(false); + drawableText->setDrawBackground(false); + drawableText->setVerticalAlignment(cvf::TextDrawer::BASELINE); + drawableText->setTextColor(defWellLabelColor); + } + + cvf::BoundingBox bb = m_crossSectionFaces->boundingBox(); + double labelZOffset = bb.extent().z() / 10; + int visibleFaultNameCount = 0; + + for (const auto& labelAndAnchorPair : labelAndAnchors) + { + RimFaultInView* fault = faultInViewColl->findFaultByName(labelAndAnchorPair.first); + + if (!(fault && fault->showFault())) continue; + + cvf::String cvfString = cvfqt::Utils::toString(labelAndAnchorPair.first); + cvf::Vec3f textCoord(labelAndAnchorPair.second); + + textCoord.z() += labelZOffset; + drawableText->addText(cvfString, textCoord); + + lineVertices.push_back(cvf::Vec3f(labelAndAnchorPair.second)); + lineVertices.push_back(textCoord); + visibleFaultNameCount++; + } + + if (visibleFaultNameCount == 0) return; + + // Labels part + { + cvf::ref part = new cvf::Part; + part->setName("Fault mesh label : text "); + part->setDrawable(drawableText.p()); + + cvf::ref eff = new cvf::Effect; + + part->setEffect(eff.p()); + part->setPriority(RivPartPriority::PartType::Text); + part->updateBoundingBox(); + + m_faultMeshLabels = part; + } + + // Lines to labels part + { + cvf::ref vertices = new cvf::Vec3fArray; + vertices->assign(lineVertices); + cvf::ref geo = new cvf::DrawableGeo; + geo->setVertexArray(vertices.p()); + + cvf::ref primSet = new cvf::PrimitiveSetDirect(cvf::PT_LINES); + primSet->setStartIndex(0); + primSet->setIndexCount(vertices->size()); + geo->addPrimitiveSet(primSet.p()); + + cvf::ref part = new cvf::Part; + part->setName("Anchor lines for fault mesh labels"); + part->setDrawable(geo.p()); + + part->updateBoundingBox(); + + caf::MeshEffectGenerator gen(RiaApplication::instance()->preferences()->defaultFaultGridLineColors()); + cvf::ref eff = gen.generateCachedEffect(); + + part->setEffect(eff.p()); + m_faultMeshLabelLines = part; + } + +} //-------------------------------------------------------------------------------------------------- /// @@ -541,7 +780,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) if (m_rimCrossSection->direction() == RimIntersection::CS_TWO_POINTS) { { - cvf::ref polylineGeo = m_crossSectionGenerator->createLineAlongPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); + cvf::ref polylineGeo = m_crossSectionGenerator->createLineAlongExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); if (polylineGeo.notNull()) { if (useBufferObjects) @@ -573,7 +812,7 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) } } - cvf::ref polylinePointsGeo = m_crossSectionGenerator->createPointsFromPolylineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); + cvf::ref polylinePointsGeo = m_crossSectionGenerator->createPointsFromExtrusionLineDrawable(m_rimCrossSection->polyLinesForExtrusionDirection()); if (polylinePointsGeo.notNull()) { if (useBufferObjects) @@ -613,32 +852,48 @@ void RivIntersectionPartMgr::createExtrusionDirParts(bool useBufferObjects) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::updatePartEffect() +cvf::ref createStdSurfacePart(cvf::DrawableGeo* geometry, + const cvf::Color3f& color, + cvf::String name, + cvf::Object* sourceInfo) { - if (m_crossSectionGenerator.isNull()) return; + if (!geometry) return nullptr; - // Set deCrossSection effect - caf::SurfaceEffectGenerator geometryEffgen(m_defaultColor, caf::PO_1); - - cvf::ref geometryOnlyEffect = geometryEffgen.generateCachedEffect(); + cvf::ref part = new cvf::Part; + part->setName(name); + part->setDrawable(geometry); - if (m_crossSectionFaces.notNull()) - { - m_crossSectionFaces->setEffect(geometryOnlyEffect.p()); - } + caf::SurfaceEffectGenerator surfaceGen(color, caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); + part->setEffect(eff.p()); - // Update mesh colors as well, in case of change - //RiaPreferences* prefs = RiaApplication::instance()->preferences(); + part->setSourceInfo(sourceInfo); + part->updateBoundingBox(); - cvf::ref eff; - caf::MeshEffectGenerator CrossSectionEffGen(cvf::Color3::WHITE);//prefs->defaultCrossSectionGridLineColors()); - eff = CrossSectionEffGen.generateCachedEffect(); + return part; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref createStdLinePart(cvf::DrawableGeo* geometry, + const cvf::Color3f& color, + cvf::String name) +{ + if ( !geometry ) return nullptr; - if (m_crossSectionGridLines.notNull()) - { - m_crossSectionGridLines->setEffect(eff.p()); - } + cvf::ref part = new cvf::Part; + part->setName(name); + part->setDrawable(geometry); + + caf::MeshEffectGenerator gen(color); + cvf::ref eff = gen.generateCachedEffect(); + + part->setEffect(eff.p()); + part->updateBoundingBox(); + + return part; } //-------------------------------------------------------------------------------------------------- @@ -674,15 +929,36 @@ void RivIntersectionPartMgr::appendMeshLinePartsToModel(cvf::ModelBasicList* mod m_crossSectionGridLines->setTransform(scaleTransform); model->addPart(m_crossSectionGridLines.p()); } + + if (m_crossSectionFaultGridLines.notNull()) + { + m_crossSectionFaultGridLines->setTransform(scaleTransform); + model->addPart(m_crossSectionFaultGridLines.p()); + } + + if (m_faultMeshLabelLines.notNull()) + { + m_faultMeshLabelLines->setTransform(scaleTransform); + model->addPart(m_faultMeshLabelLines.p()); + } + + if (m_faultMeshLabels.notNull()) + { + m_faultMeshLabels->setTransform(scaleTransform); + model->addPart(m_faultMeshLabels.p()); + } + } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) +void RivIntersectionPartMgr::appendPolylinePartsToModel(Rim3dView &view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform) { - if (m_rimCrossSection->inputPolyLineFromViewerEnabled) + Rim2dIntersectionView* curr2dView = dynamic_cast(&view); + + if (m_rimCrossSection->inputPolyLineFromViewerEnabled || (curr2dView && curr2dView->showDefiningPoints())) { if (m_highlightLineAlongPolyline.notNull()) { @@ -712,7 +988,7 @@ void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* mod } } - if (m_rimCrossSection->inputTwoAzimuthPointsFromViewerEnabled) + if (m_rimCrossSection->inputTwoAzimuthPointsFromViewerEnabled || (curr2dView && curr2dView->showDefiningPoints())) { if (m_highlightLineAlongPolyline.notNull()) { @@ -731,15 +1007,17 @@ void RivIntersectionPartMgr::appendPolylinePartsToModel(cvf::ModelBasicList* mod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivIntersectionPartMgr::computeData() +const RimIntersection* RivIntersectionPartMgr::intersection() const { - std::vector< std::vector > polyLines = m_rimCrossSection->polyLines(); - if (polyLines.size() > 0) - { - cvf::Vec3d direction = m_rimCrossSection->extrusionDirection(); - cvf::ref hexGrid = createHexGridInterface(); - m_crossSectionGenerator = new RivIntersectionGeometryGenerator(m_rimCrossSection, polyLines, direction, hexGrid.p()); - } + return m_rimCrossSection.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivIntersectionPartMgr::unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat) +{ + return m_crossSectionGenerator->unflattenTransformMatrix(intersectionPointFlat); } //-------------------------------------------------------------------------------------------------- @@ -759,7 +1037,7 @@ cvf::ref RivIntersectionPartMgr::createHexGridI m_rimCrossSection->firstAncestorOrThisOfType(geoView); if (geoView) { - RigFemPart* femPart = geoView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geoView->femParts()->part(0); return new RivFemIntersectionGrid(femPart); } diff --git a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h index b585178447..1e422ec737 100644 --- a/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h +++ b/ApplicationCode/ModelVisualization/Intersections/RivIntersectionPartMgr.h @@ -24,7 +24,14 @@ #include "cvfColor4.h" #include "cvfVector3.h" #include "cvfArray.h" +#include "cvfMatrix4.h" +#include "cafPdmPointer.h" + +#include + +#include +#include namespace cvf { @@ -32,6 +39,7 @@ namespace cvf class Transform; class Part; class ScalarMapper; + class DrawableGeo; } class RigFemPart; @@ -39,13 +47,15 @@ class RigFemResultAddress; class RigGeoMechCaseData; class RigMainGrid; class RigResultAccessor; +class Rim3dView; class RimCellEdgeColors; class RimEclipseCellColors; class RimIntersection; +class RivTernaryScalarMapper; class RivIntersectionGeometryGenerator; class RivIntersectionHexGridInterface; class RivIntersectionVertexWeights; - +class RivPipeGeometryGenerator; //================================================================================================== /// @@ -55,24 +65,21 @@ class RivIntersectionVertexWeights; class RivIntersectionPartMgr : public cvf::Object { public: - explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection); + explicit RivIntersectionPartMgr(RimIntersection* rimCrossSection, bool isFlattened = false); void applySingleColorEffect(); - void updateCellResultColor(size_t timeStepIndex); + void updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper); void appendNativeCrossSectionFacesToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); void appendMeshLinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - void appendPolylinePartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - -private: - void updatePartEffect(); - void generatePartGeometry(); + void appendPolylinePartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform); - void createPolyLineParts(bool useBufferObjects); - void createExtrusionDirParts(bool useBufferObjects); + const RimIntersection* intersection() const; - void computeData(); + cvf::Mat4d unflattenTransformMatrix(const cvf::Vec3d& intersectionPointFlat); public: static void calculateEclipseTextureCoordinates(cvf::Vec2fArray* textureCoords, @@ -80,12 +87,17 @@ class RivIntersectionPartMgr : public cvf::Object const RigResultAccessor* resultAccessor, const cvf::ScalarMapper* mapper); - static void calculateGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, - const std::vector &vertexWeights, - const std::vector &resultValues, - bool isElementNodalResult, - const RigFemPart* femPart, - const cvf::ScalarMapper* mapper); + static void calculateNodeOrElementNodeBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &vertexWeights, + const std::vector &resultValues, + bool isElementNodalResult, + const RigFemPart* femPart, + const cvf::ScalarMapper* mapper); + + static void calculateElementBasedGeoMechTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector &resultValues, + const std::vector& triangleToCellIdx, + const cvf::ScalarMapper* mapper); static void calculateGeoMechTensorXfTextureCoords(cvf::Vec2fArray* textureCoords, const cvf::Vec3fArray* triangelVertices, @@ -99,17 +111,25 @@ class RivIntersectionPartMgr : public cvf::Object const cvf::Vec3fArray* triangelVertices, const RigFemResultAddress& resVarAddress, const cvf::ScalarMapper* mapper); - - cvf::ref createHexGridInterface(); private: + void generatePartGeometry(); + void createFaultLabelParts(const std::vector >& labelAndAnchors); + void createPolyLineParts(bool useBufferObjects); + void createExtrusionDirParts(bool useBufferObjects); - RimIntersection* m_rimCrossSection; + cvf::ref createHexGridInterface(); - cvf::Color3f m_defaultColor; +private: + caf::PdmPointer m_rimCrossSection; cvf::ref m_crossSectionGenerator; cvf::ref m_crossSectionFaces; cvf::ref m_crossSectionGridLines; + cvf::ref m_crossSectionFaultGridLines; + cvf::ref m_faultMeshLabels; + cvf::ref m_faultMeshLabelLines; + + cvf::ref m_crossSectionFacesTextureCoords; cvf::ref m_highlightLineAlongPolyline; @@ -117,5 +137,15 @@ class RivIntersectionPartMgr : public cvf::Object cvf::ref m_highlightLineAlongExtrusionDir; cvf::ref m_highlightPointsForExtrusionDir; + + struct RivPipeBranchData + { + cvf::ref m_pipeGeomGenerator; + cvf::ref m_surfacePart; + cvf::ref m_centerLinePart; + }; + std::list m_wellBranches; + + bool m_isFlattened; }; diff --git a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp new file mode 100644 index 0000000000..de45bd2f07 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.cpp @@ -0,0 +1,155 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivSectionFlattner.h" +#include "cvfGeometryTools.h" + + +//-------------------------------------------------------------------------------------------------- +/// Returns the next index higher than idxToStartOfLineSegment that makes the line +// polyline[idxToStartOfLineSegment] .. polyline[nextIdx] not parallel to extrDir +/// +/// Returns size_t(-1) if no point is found +//-------------------------------------------------------------------------------------------------- +size_t RivSectionFlattner::indexToNextValidPoint(const std::vector& polyLine, + const cvf::Vec3d extrDir, + size_t idxToStartOfLineSegment) +{ + size_t lineCount = polyLine.size(); + if ( !(idxToStartOfLineSegment + 1 < lineCount) ) return -1; + + + cvf::Vec3d p1 = polyLine[idxToStartOfLineSegment]; + + for ( size_t lIdx = idxToStartOfLineSegment+1; lIdx < lineCount; ++lIdx ) + { + cvf::Vec3d p2 = polyLine[lIdx]; + cvf::Vec3d p1p2 = p2 - p1; + + if ( (p1p2 - (p1p2 * extrDir)*extrDir).length() > 0.1 ) + { + return lIdx; + } + } + + return -1; +} + +//-------------------------------------------------------------------------------------------------- +/// Returns one CS pr point, valid for the next segment +//-------------------------------------------------------------------------------------------------- +std::vector RivSectionFlattner::calculateFlatteningCSsForPolyline(const std::vector & polyLine, + const cvf::Vec3d& extrusionDir, + const cvf::Vec3d& startOffset, + cvf::Vec3d* endOffset) +{ + CVF_ASSERT(endOffset); + size_t pointCount = polyLine.size(); + CVF_ASSERT(pointCount > 1); + + std::vector segmentTransforms; + segmentTransforms.reserve(pointCount); + + // Find initial transform, used if all is vertical + + cvf::Mat4d invSectionCS; + { + cvf::Vec3d p1 = polyLine[0]; + cvf::Vec3d p2 = polyLine[1]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); + cvf::Mat4d invSectionCS = sectionLocalCS.getInverted(); + invSectionCS.setTranslation(invSectionCS.translation() + startOffset); + } + + cvf::Vec3d previousFlattenedSectionEndPoint = startOffset; + + size_t lIdx = 0; + while ( lIdx < pointCount ) + { + size_t idxToNextP = indexToNextValidPoint(polyLine, extrusionDir, lIdx); + + // If the rest is nearly parallel to extrusionDir, use the current inverse matrix for the rest of the points + + if ( idxToNextP == size_t(-1) ) + { + size_t inc = 0; + while ( (lIdx + inc) < pointCount ) + { + segmentTransforms.push_back(invSectionCS); + ++inc; + } + break; + } + + cvf::Vec3d p1 = polyLine[lIdx]; + cvf::Vec3d p2 = polyLine[idxToNextP]; + + cvf::Mat4d sectionLocalCS = calculateSectionLocalFlatteningCS(p1, p2, extrusionDir); + invSectionCS = sectionLocalCS.getInverted(); + cvf::Vec3d flattenedSectionEndPoint = p2.getTransformedPoint(invSectionCS); + + invSectionCS.setTranslation(invSectionCS.translation() + previousFlattenedSectionEndPoint); + + previousFlattenedSectionEndPoint += flattenedSectionEndPoint; + + // Assign the matrix to the points in between + + size_t inc = 0; + while ( (lIdx + inc) < idxToNextP ) + { + segmentTransforms.push_back(invSectionCS); + inc++; + } + + lIdx = idxToNextP; + } + + *endOffset = previousFlattenedSectionEndPoint; + return segmentTransforms; +} + +//-------------------------------------------------------------------------------------------------- +/// Origo in P1 +/// Ez in upwards extrusionDir +/// Ey normal to the section plane +/// Ex in plane along p1-p2 +//-------------------------------------------------------------------------------------------------- +cvf::Mat4d RivSectionFlattner::calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& extrusionDir) +{ + using namespace cvf; + + Vec3d Ez = extrusionDir.z() > 0.0 ? extrusionDir: -extrusionDir; + + Vec3d sectionLineDir = p2 - p1; + + if ( cvf::GeometryTools::getAngle(sectionLineDir, extrusionDir) < 0.01 ) + { + sectionLineDir = Ez.perpendicularVector(); + } + + Vec3d Ey = Ez ^ sectionLineDir; + Ey.normalize(); + Vec3d Ex = Ey ^ Ez; + Ex.normalize(); + + return Mat4d(Ex[0], Ey[0], Ez[0], p1[0], + Ex[1], Ey[1], Ez[1], p1[1], + Ex[2], Ey[2], Ez[2], p1[2], + 0.0, 0.0, 0.0, 1.0); +} diff --git a/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h new file mode 100644 index 0000000000..6d3a9288ae --- /dev/null +++ b/ApplicationCode/ModelVisualization/Intersections/RivSectionFlattner.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfMatrix4.h" + +#include + + +class RivSectionFlattner +{ +public: + static size_t indexToNextValidPoint(const std::vector& polyLine, + const cvf::Vec3d extrDir, + size_t idxToStartOfLineSegment); + + static std::vector calculateFlatteningCSsForPolyline(const std::vector & polyLine, + const cvf::Vec3d& extrusionDir, + const cvf::Vec3d& startOffset, + cvf::Vec3d* endOffset); + +private: + + static cvf::Mat4d calculateSectionLocalFlatteningCS(const cvf::Vec3d& p1, + const cvf::Vec3d& p2, + const cvf::Vec3d& extrusionDir); + + +}; + + diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp new file mode 100644 index 0000000000..26385a699e --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.cpp @@ -0,0 +1,463 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riv3dWellLogCurveGeometryGenerator.h" + +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "RigCurveDataTools.h" +#include "RigWellPath.h" +#include "RigWellPathGeometryTools.h" + +#include "cafLine.h" +#include "cafDisplayCoordTransform.h" +#include "cvfPrimitiveSetIndexedUInt.h" + +#include "cvfBoundingBox.h" +#include "cvfMath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riv3dWellLogCurveGeometryGenerator::Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath) + : m_wellPath(wellPath) + , m_planeWidth(0.0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve* rim3dWellLogCurve, + double planeOffsetFromWellPathCenter, + double planeWidth, + const std::vector& drawSurfaceVertices) +{ + CVF_ASSERT(rim3dWellLogCurve); + + // Make sure all drawables are cleared in case we return early to avoid a + // previous drawable being "stuck" when changing result type. + clearCurvePointsAndGeometry(); + + float curveUIRange = rim3dWellLogCurve->maxCurveUIValue() - rim3dWellLogCurve->minCurveUIValue(); + if (curveUIRange < 1.0e-6f) + { + return; + } + + + std::vector resultValues; + std::vector resultMds; + rim3dWellLogCurve->curveValuesAndMds(&resultValues, &resultMds); + + m_planeWidth = planeWidth; + + if (!wellPathGeometry()) return; + if (wellPathGeometry()->m_wellPathPoints.empty()) return; + if (!wellPathClipBoundingBox.isValid()) return; + + if (resultValues.empty()) return; + CVF_ASSERT(resultValues.size() == resultMds.size()); + + RimWellPathCollection* wellPathCollection = nullptr; + m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); + + cvf::Vec3d clipLocation = wellPathGeometry()->m_wellPathPoints.front(); + if (wellPathCollection->wellPathClip) + { + double clipZDistance = wellPathCollection->wellPathClipZDistance; + clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); + } + clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation); + + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; + for (cvf::Vec3d& wellPathPoint : wellPathPoints) + { + wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); + } + + std::vector wellPathCurveNormals = + RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, rim3dWellLogCurve->drawPlaneAngle()); + + std::vector interpolatedWellPathPoints; + std::vector interpolatedCurveNormals; + // Iterate from bottom of well path and up to be able to stop at given Z max clipping height + for (auto md = resultMds.rbegin(); md != resultMds.rend(); md++) + { + cvf::Vec3d point = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathPoints, *md); + cvf::Vec3d normal = wellPathGeometry()->interpolatedVectorAlongWellPath(wellPathCurveNormals, *md); + if (point.z() > clipLocation.z()) break; + + interpolatedWellPathPoints.push_back(point); + interpolatedCurveNormals.push_back(normal.getNormalized()); + } + if (interpolatedWellPathPoints.empty()) return; + + // Reverse list, since it was filled in the opposite order + std::reverse(interpolatedWellPathPoints.begin(), interpolatedWellPathPoints.end()); + std::reverse(interpolatedCurveNormals.begin(), interpolatedCurveNormals.end()); + + // The result values for the part of the well which is not clipped off, matching interpolatedWellPathPoints size + m_curveValues = std::vector(resultValues.end() - interpolatedWellPathPoints.size(), resultValues.end()); + m_curveMeasuredDepths = std::vector(resultMds.end() - interpolatedWellPathPoints.size(), resultMds.end()); + + double maxVisibleResult = -std::numeric_limits::max(); + double minVisibleResult = std::numeric_limits::max(); + + double minCurveValue = rim3dWellLogCurve->minCurveUIValue(); + double maxCurveValue = rim3dWellLogCurve->maxCurveUIValue(); + + double curveEpsilon = 1.0e-6; + + for (double& result : m_curveValues) + { + if (!RigCurveDataTools::isValidValue(result, false)) continue; + + if ((minCurveValue - result) > curveEpsilon * curveUIRange) + { + result = minCurveValue - curveEpsilon; + } + else if ((result - maxCurveValue) > curveEpsilon * curveUIRange) + { + result = maxCurveValue + curveEpsilon; + } + else + { + maxVisibleResult = std::max(result, maxVisibleResult); + minVisibleResult = std::min(result, minVisibleResult); + } + } + + if (minVisibleResult > maxVisibleResult) + { + return; + } + + double plotRangeToResultRangeFactor = planeWidth / curveUIRange; + + m_curveVertices.reserve(interpolatedWellPathPoints.size()); + for (size_t i = 0; i < interpolatedWellPathPoints.size(); i++) + { + double scaledResult = 0; + + if (RigCurveDataTools::isValidValue(m_curveValues[i], false)) + { + scaledResult = planeOffsetFromWellPathCenter + (m_curveValues[i] - minCurveValue) * plotRangeToResultRangeFactor; + } + cvf::Vec3d curvePoint(interpolatedWellPathPoints[i] + scaledResult * interpolatedCurveNormals[i]); + m_curveVertices.push_back(curvePoint); + } + m_curveVertices = projectVerticesOntoTriangles(m_curveVertices, drawSurfaceVertices); + + createNewVerticesAlongTriangleEdges(drawSurfaceVertices); + + { + std::vector indices; + indices.reserve(m_curveVertices.size() * 2); + for (size_t i = 0; i < m_curveVertices.size() - 1; ++i) + { + if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) + { + if (cvf::Math::valueInRange(m_curveValues[i], minCurveValue, maxCurveValue) || + cvf::Math::valueInRange(m_curveValues[i + 1], minCurveValue, maxCurveValue)) + { + indices.push_back(cvf::uint(i)); + indices.push_back(cvf::uint(i + 1)); + } + } + } + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + m_curveDrawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + m_curveDrawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(m_curveVertices.size()); + for (size_t i = 0; i < m_curveVertices.size(); ++i) + { + (*vertexArray)[i] = cvf::Vec3f(m_curveVertices[i]); + } + m_curveDrawable->setVertexArray(vertexArray.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::clearCurvePointsAndGeometry() +{ + m_curveDrawable = nullptr; + m_curveVertices.clear(); + m_curveMeasuredDepths.clear(); + m_curveValues.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogCurveGeometryGenerator::curveDrawable() +{ + return m_curveDrawable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigWellPath* Riv3dWellLogCurveGeometryGenerator::wellPathGeometry() const +{ + return m_wellPath->wellPathGeometry(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Riv3dWellLogCurveGeometryGenerator::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtClosestPoint) const +{ + double closestDistance = m_planeWidth * 0.1; + *closestPoint = cvf::Vec3d::UNDEFINED; + *measuredDepthAtPoint = cvf::UNDEFINED_DOUBLE; + *valueAtClosestPoint = cvf::UNDEFINED_DOUBLE; + if (m_curveVertices.size() < 2u) false; + CVF_ASSERT(m_curveVertices.size() == m_curveValues.size()); + for (size_t i = 1; i < m_curveVertices.size(); ++i) + { + bool validCurveSegment = RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i - 1], false); + if (validCurveSegment) + { + cvf::Vec3d a = m_curveVertices[i - 1]; + cvf::Vec3d b = m_curveVertices[i]; + cvf::Vec3d ap = globalIntersection - a; + cvf::Vec3d ab = b - a; + // Projected point is clamped to one of the end points of the segment. + double distanceToProjectedPointAlongAB = ap * ab / (ab * ab); + double clampedDistance = cvf::Math::clamp(distanceToProjectedPointAlongAB, 0.0, 1.0); + cvf::Vec3d projectionOfGlobalIntersection = a + clampedDistance * ab; + double distance = (projectionOfGlobalIntersection - globalIntersection).length(); + if (distance < closestDistance) + { + *closestPoint = cvf::Vec3d(projectionOfGlobalIntersection); + closestDistance = distance; + *measuredDepthAtPoint = + m_curveMeasuredDepths[i - 1] * (1.0 - clampedDistance) + m_curveMeasuredDepths[i] * clampedDistance; + *valueAtClosestPoint = m_curveValues[i - 1] * (1.0 - clampedDistance) + m_curveValues[i] * clampedDistance; + } + } + } + + if (closestPoint->isUndefined()) return false; + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices) +{ + std::vector expandedCurveVertices; + std::vector expandedMeasuredDepths; + std::vector expandedValues; + size_t estimatedNumberOfPoints = m_curveVertices.size() + drawSurfaceVertices.size(); + expandedCurveVertices.reserve(estimatedNumberOfPoints); + expandedMeasuredDepths.reserve(estimatedNumberOfPoints); + expandedValues.reserve(estimatedNumberOfPoints); + + for (size_t i = 0; i < m_curveVertices.size() - 1; i += 2) + { + if (RigCurveDataTools::isValidValue(m_curveValues[i], false) && + RigCurveDataTools::isValidValue(m_curveValues[i + 1], false)) + { + cvf::Vec3d lastVertex = m_curveVertices[i]; + cvf::Vec3d fullSegmentVector = m_curveVertices[i + 1] - m_curveVertices[i]; + + std::vector extraVertices; + + createNewVerticesAlongSegment(m_curveVertices[i], + m_curveVertices[i + 1], + drawSurfaceVertices, + &extraVertices); + + for (const cvf::Vec3d& extraVertex : extraVertices) + { + cvf::Vec3d newSegmentVector = extraVertex - lastVertex; + // Scalar projection (a * b / |b|) divided by full segment length to become (a * b / |b|^2) + double dotProduct = newSegmentVector * fullSegmentVector; + double fractionAlongFullSegment = dotProduct / fullSegmentVector.lengthSquared(); + double measuredDepth = m_curveMeasuredDepths[i] * (1 - fractionAlongFullSegment) + + m_curveMeasuredDepths[i + 1] * fractionAlongFullSegment; + double valueAtPoint = + m_curveValues[i] * (1 - fractionAlongFullSegment) + m_curveValues[i + 1] * fractionAlongFullSegment; + expandedCurveVertices.push_back(extraVertex); + expandedMeasuredDepths.push_back(measuredDepth); + expandedValues.push_back(valueAtPoint); + lastVertex = extraVertex; + } + } + else + { + // Add the invalid points and values. + expandedCurveVertices.push_back(m_curveVertices[i]); + expandedMeasuredDepths.push_back(m_curveMeasuredDepths[i]); + expandedValues.push_back(m_curveValues[i]); + + } + } + + m_curveVertices.swap(expandedCurveVertices); + m_curveMeasuredDepths.swap(expandedMeasuredDepths); + m_curveValues.swap(expandedValues); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogCurveGeometryGenerator::createNewVerticesAlongSegment(const cvf::Vec3d& ptStart, + const cvf::Vec3d& ptEnd, + const std::vector& drawSurfaceVertices, + std::vector* extraVertices) +{ + cvf::Vec3d fullSegmentVector = ptEnd - ptStart; + extraVertices->push_back(ptStart); + + // Find segments that intersects the triangle edges + for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) + { + caf::Line triangleEdge1 = caf::Line(drawSurfaceVertices[j], drawSurfaceVertices[j + 1]); + caf::Line triangleEdge2 = caf::Line(drawSurfaceVertices[j + 2], drawSurfaceVertices[j + 1]); + cvf::Vec3d triangleNormal = + (triangleEdge1.vector().getNormalized() ^ triangleEdge2.vector().getNormalized()).getNormalized(); + + cvf::Vec3d currentSubSegment = ptEnd - extraVertices->back(); + cvf::Vec3d projectedSegmentVector = currentSubSegment - (currentSubSegment * triangleNormal) * triangleNormal; + caf::Line projectedCurveLine(extraVertices->back(), extraVertices->back() + projectedSegmentVector); + + // Only attempt to find intersections with the first edge. The other edge is handled with the next triangle. + bool withinSegments = false; + caf::Line connectingLine = projectedCurveLine.findLineBetweenNearestPoints(triangleEdge1, &withinSegments); + + cvf::Vec3d newVertex = connectingLine.end(); + cvf::Vec3d newSegmentVector = newVertex - extraVertices->back(); + if (withinSegments && newSegmentVector.lengthSquared() < currentSubSegment.lengthSquared()) + { + extraVertices->push_back(newVertex); + } + } + extraVertices->push_back(ptEnd); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector + Riv3dWellLogCurveGeometryGenerator::projectVerticesOntoTriangles(const std::vector& originalVertices, + const std::vector& drawSurfaceVertices) +{ + std::vector projectedVertices; + projectedVertices.reserve(originalVertices.size()); + for (size_t i = 0; i < originalVertices.size(); ++i) + { + // Sort projections onto triangle by the distance of the projection. + std::map projectionsInsideTriangle; + for (size_t j = 0; j < drawSurfaceVertices.size() - 2; j += 1) + { + cvf::Vec3d triangleVertex1, triangleVertex2, triangleVertex3; + if (j % 2 == 0) + { + triangleVertex1 = drawSurfaceVertices[j]; + triangleVertex2 = drawSurfaceVertices[j + 1]; + triangleVertex3 = drawSurfaceVertices[j + 2]; + } + else + { + triangleVertex1 = drawSurfaceVertices[j]; + triangleVertex2 = drawSurfaceVertices[j + 2]; + triangleVertex3 = drawSurfaceVertices[j + 1]; + } + + bool wasInsideTriangle = false; + cvf::Vec3d projectedPoint = projectPointOntoTriangle( + originalVertices[i], triangleVertex1, triangleVertex2, triangleVertex3, &wasInsideTriangle); + if (wasInsideTriangle) + { + projectionsInsideTriangle.insert( + std::make_pair((projectedPoint - originalVertices[i]).lengthSquared(), projectedPoint)); + } + } + + // Take the closest projection + if (!projectionsInsideTriangle.empty()) + { + projectedVertices.push_back(projectionsInsideTriangle.begin()->second); + } + else + { + projectedVertices.push_back(originalVertices[i]); + } + } + return projectedVertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d Riv3dWellLogCurveGeometryGenerator::projectPointOntoTriangle(const cvf::Vec3d& point, + const cvf::Vec3d& triangleVertex1, + const cvf::Vec3d& triangleVertex2, + const cvf::Vec3d& triangleVertex3, + bool* wasInsideTriangle) +{ + *wasInsideTriangle = false; + cvf::Vec3d e1 = triangleVertex2 - triangleVertex1; + cvf::Vec3d e2 = triangleVertex3 - triangleVertex1; + cvf::Vec3d n = (e1.getNormalized() ^ e2.getNormalized()).getNormalized(); + + // Project vertex onto triangle plane + cvf::Vec3d av = point - triangleVertex1; + cvf::Vec3d projectedAv = av - (av * n) * n; + cvf::Vec3d projectedPoint = projectedAv + triangleVertex1; + + // Calculate barycentric coordinates + double areaABC = n * (e1 ^ e2); + double areaPBC = n * ((triangleVertex2 - projectedPoint) ^ (triangleVertex3 - projectedPoint)); + double areaPCA = n * ((triangleVertex3 - projectedPoint) ^ (triangleVertex1 - projectedPoint)); + double u = areaPBC / areaABC; + double v = areaPCA / areaABC; + double w = 1.0 - u - v; + + if (u >= -1.0e-6 && v >= -1.0e-6 && w >= -1.0e-6) + { + *wasInsideTriangle = true; + // Clamp to ensure it is inside the triangle + u = cvf::Math::clamp(u, 0.0, 1.0); + v = cvf::Math::clamp(v, 0.0, 1.0); + w = cvf::Math::clamp(w, 0.0, 1.0); + projectedPoint = triangleVertex1 * u + triangleVertex2 * v + triangleVertex3 * w; + } + return projectedPoint; +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h new file mode 100644 index 0000000000..d53d078640 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogCurveGeometryGenerator.h @@ -0,0 +1,89 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfDrawableGeo.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cafPdmPointer.h" + +#include + +namespace caf +{ +class DisplayCoordTransform; +} + +namespace cvf +{ +class BoundingBox; +} + +class RigWellPath; +class RimWellPath; +class Rim3dWellLogCurve; + +class Riv3dWellLogCurveGeometryGenerator : public cvf::Object +{ +public: + typedef std::pair PointValuePair; + Riv3dWellLogCurveGeometryGenerator(RimWellPath* wellPath); + + void createCurveDrawables(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve* rim3dWellLogCurve, + double planeOffsetFromWellPathCenter, + double planeWidth, + const std::vector& drawSurfaceVertices); + + void clearCurvePointsAndGeometry(); + + const RigWellPath* wellPathGeometry() const; + + cvf::ref curveDrawable(); + + bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtClosestPoint) const; + +private: + void createNewVerticesAlongTriangleEdges(const std::vector& drawSurfaceVertices); + static void createNewVerticesAlongSegment(const cvf::Vec3d& ptStart, + const cvf::Vec3d& ptEnd, + const std::vector& drawSurfaceVertices, + std::vector* extraVertices); + + static std::vector projectVerticesOntoTriangles(const std::vector& originalVertices, const std::vector& drawSurfaceVertices); + static cvf::Vec3d projectPointOntoTriangle(const cvf::Vec3d& point, + const cvf::Vec3d& triangleVertex1, + const cvf::Vec3d& triangleVertex2, + const cvf::Vec3d& triangleVertex3, + bool* wasInsideTriangle); + caf::PdmPointer m_wellPath; + double m_planeWidth; + + cvf::ref m_curveDrawable; + std::vector m_curveVertices; + + std::vector m_curveMeasuredDepths; + std::vector m_curveValues; +}; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp new file mode 100644 index 0000000000..b42245c2de --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.cpp @@ -0,0 +1,313 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riv3dWellLogDrawSurfaceGenerator.h" + +#include "RimWellPath.h" +#include "RimWellPathCollection.h" + +#include "RigWellPath.h" +#include "RigWellPathGeometryTools.h" + +#include "cafDisplayCoordTransform.h" + +#include "cvfObject.h" +#include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfBoundingBox.h" +#include "cvfGeometryBuilderTriangles.h" +#include "cvfArrowGenerator.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riv3dWellLogDrawSurfaceGenerator::Riv3dWellLogDrawSurfaceGenerator(RimWellPath* wellPath) + : m_wellPath(wellPath) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool +Riv3dWellLogDrawSurfaceGenerator::createDrawSurface(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize) +{ + CVF_ASSERT(samplingIntervalSize > 0); + + clearGeometry(); + + if (!wellPathGeometry() || wellPathGeometry()->m_measuredDepths.empty()) + { + return false; + } + + if (!wellPathClipBoundingBox.isValid()) + { + return false; + } + + + RimWellPathCollection* wellPathCollection = nullptr; + m_wellPath->firstAncestorOrThisOfTypeAsserted(wellPathCollection); + + std::vector wellPathPoints = wellPathGeometry()->m_wellPathPoints; + if (wellPathPoints.size() < (size_t)2) + { + // Need at least two well path points to create a valid path. + return false; + } + + for (cvf::Vec3d& wellPathPoint : wellPathPoints) + { + wellPathPoint = displayCoordTransform->transformToDisplayCoord(wellPathPoint); + } + + std::vector wellPathSegmentNormals = + RigWellPathGeometryTools::calculateLineSegmentNormals(wellPathPoints, planeAngle); + + size_t indexToFirstVisibleSegment = 0u; + if (wellPathCollection->wellPathClip) + { + double clipZDistance = wellPathCollection->wellPathClipZDistance; + cvf::Vec3d clipLocation = wellPathClipBoundingBox.max() + clipZDistance * cvf::Vec3d(0, 0, 1); + clipLocation = displayCoordTransform->transformToDisplayCoord(clipLocation); + double horizontalLengthAlongWellToClipPoint; + + wellPathPoints = RigWellPath::clipPolylineStartAboveZ( + wellPathPoints, clipLocation.z(), &horizontalLengthAlongWellToClipPoint, &indexToFirstVisibleSegment); + } + + // Create curve normal vectors using the unclipped well path points and normals. + createCurveNormalVectors(displayCoordTransform, indexToFirstVisibleSegment, planeOffsetFromWellPathCenter, planeWidth, samplingIntervalSize, wellPathSegmentNormals); + + // Note that normals are calculated on the full non-clipped well path. So we need to clip the start here. + wellPathSegmentNormals.erase(wellPathSegmentNormals.begin(), wellPathSegmentNormals.end() - wellPathPoints.size()); + + if (wellPathPoints.size() < (size_t)2) + { + // Need at least two well path points to create a valid path. + return false; + } + + m_vertices.reserve(wellPathPoints.size() * 2); + for (size_t i = 0; i < wellPathPoints.size(); i++) + { + m_vertices.push_back(wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter - 0.025*planeWidth)); + m_vertices.push_back(wellPathPoints[i] + wellPathSegmentNormals[i] * (planeOffsetFromWellPathCenter + 1.025*planeWidth)); + } + + cvf::ref vertexArray = new cvf::Vec3fArray(m_vertices.size()); + for (size_t i = 0; i < m_vertices.size(); ++i) + { + (*vertexArray)[i] = cvf::Vec3f(m_vertices[i]); + } + createBackground(vertexArray.p()); + createBorder(vertexArray.p()); + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::clearGeometry() +{ + m_background = nullptr; + m_border = nullptr; + m_curveNormalVectors = nullptr; + m_vertices.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogDrawSurfaceGenerator::background() const +{ + return m_background; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogDrawSurfaceGenerator::border() const +{ + return m_border; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogDrawSurfaceGenerator::curveNormalVectors() const +{ + return m_curveNormalVectors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& Riv3dWellLogDrawSurfaceGenerator::vertices() const +{ + return m_vertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::createCurveNormalVectors(const caf::DisplayCoordTransform* displayCoordTransform, + size_t clipStartIndex, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize, + const std::vector& segmentNormals) +{ + std::vector interpolatedWellPathPoints; + std::vector interpolatedWellPathNormals; + + double firstMd = wellPathGeometry()->m_measuredDepths.at(clipStartIndex); + double lastMd = wellPathGeometry()->m_measuredDepths.back(); + + double md = lastMd; + while (md >= firstMd) + { + cvf::Vec3d point = wellPathGeometry()->interpolatedPointAlongWellPath(md); + point = displayCoordTransform->transformToDisplayCoord(point); + cvf::Vec3d curveNormal = wellPathGeometry()->interpolatedVectorAlongWellPath(segmentNormals, md); + interpolatedWellPathPoints.push_back(point); + interpolatedWellPathNormals.push_back(curveNormal.getNormalized()); + md -= samplingIntervalSize; + } + + std::vector arrowVertices; + std::vector arrowVectors; + arrowVertices.reserve(interpolatedWellPathPoints.size()); + arrowVectors.reserve(interpolatedWellPathPoints.size()); + + double shaftRelativeRadius = 0.0125f; + double arrowHeadRelativeRadius = shaftRelativeRadius * 3; + double arrowHeadRelativeLength = arrowHeadRelativeRadius * 3; + double totalArrowScaling = 1.0 / (1.0 - arrowHeadRelativeLength); + // Normal lines. Start from one to avoid drawing at surface edge. + for (size_t i = 1; i < interpolatedWellPathNormals.size(); i++) + { + arrowVertices.push_back(cvf::Vec3f(interpolatedWellPathPoints[i] + interpolatedWellPathNormals[i] * planeOffsetFromWellPathCenter)); + + arrowVectors.push_back(cvf::Vec3f(interpolatedWellPathNormals[i] * planeWidth * totalArrowScaling)); + } + + if (arrowVertices.empty() || arrowVectors.empty()) + { + return; + } + + m_curveNormalVectors = new cvf::DrawableVectors(); + + cvf::ref vertexArray = new cvf::Vec3fArray(arrowVertices); + cvf::ref vectorArray = new cvf::Vec3fArray(arrowVectors); + + // Create the arrow glyph for the vector drawer + cvf::GeometryBuilderTriangles arrowBuilder; + cvf::ArrowGenerator gen; + gen.setShaftRelativeRadius(shaftRelativeRadius); + gen.setHeadRelativeRadius(arrowHeadRelativeRadius); + gen.setHeadRelativeLength(arrowHeadRelativeLength); + gen.setNumSlices(4); + gen.generate(&arrowBuilder); + + m_curveNormalVectors->setGlyph(arrowBuilder.trianglesUShort().p(), arrowBuilder.vertices().p()); + m_curveNormalVectors->setVectors(vertexArray.p(), vectorArray.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::createBackground(cvf::Vec3fArray* vertexArray) +{ + std::vector backgroundIndices; + backgroundIndices.reserve(vertexArray->size()); + for (size_t i = 0; i < vertexArray->size(); ++i) + { + backgroundIndices.push_back((cvf::uint) (i)); + } + + // Background specific + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_TRIANGLE_STRIP); + cvf::ref indexArray = new cvf::UIntArray(backgroundIndices); + indexedUInt->setIndices(indexArray.p()); + + m_background = new cvf::DrawableGeo(); + m_background->addPrimitiveSet(indexedUInt.p()); + m_background->setVertexArray(vertexArray); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogDrawSurfaceGenerator::createBorder(cvf::Vec3fArray* vertexArray) +{ + std::vector borderIndices; + borderIndices.reserve(m_vertices.size()); + + int secondLastEvenVertex = (int)vertexArray->size() - 4; + + // Border close to the well. All even indices. + for (int i = 0; i <= secondLastEvenVertex; i += 2) + { + borderIndices.push_back((cvf::uint) i); + borderIndices.push_back((cvf::uint) i + 2); + } + + // Connect to border away from well + borderIndices.push_back((cvf::uint) (vertexArray->size() - 2)); + borderIndices.push_back((cvf::uint) (vertexArray->size() - 1)); + + int secondOddVertex = 3; + int lastOddVertex = (int)vertexArray->size() - 1; + + // Border away from from well are odd indices in reverse order to create a closed surface. + for (int i = lastOddVertex; i >= secondOddVertex; i -= 2) + { + borderIndices.push_back((cvf::uint) i); + borderIndices.push_back((cvf::uint) i - 2); + } + // Close border + borderIndices.push_back(1u); + borderIndices.push_back(0u); + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(borderIndices); + indexedUInt->setIndices(indexArray.p()); + + m_border = new cvf::DrawableGeo(); + m_border->addPrimitiveSet(indexedUInt.p()); + m_border->setVertexArray(vertexArray); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigWellPath* Riv3dWellLogDrawSurfaceGenerator::wellPathGeometry() const +{ + return m_wellPath->wellPathGeometry(); +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h new file mode 100644 index 0000000000..8b7922c28b --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogDrawSurfaceGenerator.h @@ -0,0 +1,83 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfDrawableGeo.h" +#include "cvfDrawableVectors.h" +#include "cvfObject.h" + +#include "cafPdmPointer.h" + +#include + +namespace caf +{ +class DisplayCoordTransform; +} + +namespace cvf +{ +class BoundingBox; +} + +class RigWellPath; +class RimWellPath; + +class Riv3dWellLogDrawSurfaceGenerator : public cvf::Object +{ +public: + Riv3dWellLogDrawSurfaceGenerator(RimWellPath* wellPath); + + bool createDrawSurface(const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + double planeAngle, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize); + + void clearGeometry(); + + cvf::ref background() const; + cvf::ref border() const; + cvf::ref curveNormalVectors() const; + + const std::vector& vertices() const; + +private: + void createCurveNormalVectors(const caf::DisplayCoordTransform* displayCoordTransform, + size_t clipStartIndex, + double planeOffsetFromWellPathCenter, + double planeWidth, + double samplingIntervalSize, + const std::vector& wellPathSegmentNormals); + + void createBackground(cvf::Vec3fArray* vertexArray); + void createBorder(cvf::Vec3fArray* vertexArray); + + const RigWellPath* wellPathGeometry() const; + +private: + caf::PdmPointer m_wellPath; + cvf::ref m_background; + cvf::ref m_border; + cvf::ref m_curveNormalVectors; + + std::vector m_vertices; +}; diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp new file mode 100644 index 0000000000..8eb5f33f26 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.cpp @@ -0,0 +1,259 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riv3dWellLogPlanePartMgr.h" + +#include "RiaApplication.h" + +#include "RiuViewer.h" +#include "Rim3dView.h" +#include "Rim3dWellLogCurveCollection.h" +#include "RimCase.h" +#include "RimGridView.h" +#include "RimWellPath.h" + +#include "Riv3dWellLogCurveGeometryGenerator.h" +#include "Riv3dWellLogDrawSurfaceGenerator.h" +#include "RivObjectSourceInfo.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" + +#include "cvfBoundingBox.h" +#include "cvfColor3.h" +#include "cvfDrawableGeo.h" +#include "cvfModelBasicList.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfPart.h" +#include "cvfShaderProgram.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riv3dWellLogPlanePartMgr::Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView) + : m_wellPath(wellPath) + , m_gridView(gridView) +{ + CVF_ASSERT(m_wellPath.notNull()); + m_3dWellLogDrawSurfaceGeometryGenerator = new Riv3dWellLogDrawSurfaceGenerator(m_wellPath.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::appendPlaneToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (m_wellPath.isNull()) return; + + if (!m_wellPath->rim3dWellLogCurveCollection()) return; + + if (!m_wellPath->rim3dWellLogCurveCollection()->isShowingPlot()) return; + + if (m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves().empty()) return; + + for (Rim3dWellLogCurve* rim3dWellLogCurve : m_wellPath->rim3dWellLogCurveCollection()->vectorOf3dWellLogCurves()) + { + if (rim3dWellLogCurve->isShowingCurve()) + { + appendDrawSurfaceToModel(model, displayCoordTransform, wellPathClipBoundingBox, rim3dWellLogCurve, planeWidth()); + append3dWellLogCurveToModel(model, + displayCoordTransform, + wellPathClipBoundingBox, + rim3dWellLogCurve, + m_3dWellLogDrawSurfaceGeometryGenerator->vertices()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::append3dWellLogCurveToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + Rim3dWellLogCurve* rim3dWellLogCurve, + const std::vector& drawSurfaceVertices) +{ + CVF_ASSERT(rim3dWellLogCurve); + + cvf::ref generator = rim3dWellLogCurve->geometryGenerator(); + if (generator.isNull()) + { + generator = new Riv3dWellLogCurveGeometryGenerator(m_wellPath.p()); + rim3dWellLogCurve->setGeometryGenerator(generator.p()); + } + + generator->createCurveDrawables(displayCoordTransform, + wellPathClipBoundingBox, + rim3dWellLogCurve, + wellPathCenterToPlotStartOffset(rim3dWellLogCurve), + planeWidth(), + drawSurfaceVertices); + + + cvf::ref curveDrawable = generator->curveDrawable(); + if (curveDrawable.notNull() && curveDrawable->boundingBox().isValid()) + { + caf::MeshEffectGenerator meshEffectGen(rim3dWellLogCurve->color()); + meshEffectGen.setLineWidth(3.0f); + cvf::ref effect = meshEffectGen.generateCachedEffect(); + + cvf::ref part = new cvf::Part; + part->setDrawable(curveDrawable.p()); + part->setEffect(effect.p()); + + if (part.notNull()) + { + model->addPart(part.p()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Riv3dWellLogPlanePartMgr::createPart(cvf::Drawable* drawable, cvf::Effect* effect) +{ + cvf::ref part = new cvf::Part; + + if (drawable && drawable->boundingBox().isValid()) + { + part->setDrawable(drawable); + part->setEffect(effect); + } + + return part; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogPlanePartMgr::wellPathCenterToPlotStartOffset(const Rim3dWellLogCurve* curve) const +{ + if (curve->drawPlane() == Rim3dWellLogCurve::HORIZONTAL_CENTER || + curve->drawPlane() == Rim3dWellLogCurve::VERTICAL_CENTER) + { + return -0.5*planeWidth(); + } + else + { + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + double wellPathOffset = std::min(m_wellPath->wellPathRadius(cellSize), 0.1 * planeWidth()); + return m_wellPath->wellPathRadius(cellSize) + wellPathOffset; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Riv3dWellLogPlanePartMgr::planeWidth() const +{ + if (!m_gridView) return 0; + + double cellSize = m_gridView->ownerCase()->characteristicCellSize(); + const Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + return cellSize * curveCollection->planeWidthScaling(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riv3dWellLogPlanePartMgr::appendDrawSurfaceToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve* rim3dWellLogCurve, + double samplingInterval) +{ + Rim3dWellLogCurveCollection* curveCollection = m_wellPath->rim3dWellLogCurveCollection(); + cvf::ref sourceInfo = new RivObjectSourceInfo(curveCollection); + + bool showCoordinateSystemMesh = curveCollection->isShowingGrid(); + bool showBackground = curveCollection->isShowingBackground(); + + cvf::Color3f borderColor(0.4f, 0.4f, 0.4f); + caf::SurfaceEffectGenerator backgroundEffectGen(cvf::Color4f(1.0, 1.0, 1.0, 1.0), caf::PO_2); + caf::MeshEffectGenerator borderEffectGen(borderColor); + caf::VectorEffectGenerator curveNormalsEffectGen; + backgroundEffectGen.enableLighting(false); + + if (!showBackground) + { + // Make the background invisible but still present for picking. + backgroundEffectGen.enableColorMask(false); + backgroundEffectGen.enableDepthTest(false); + backgroundEffectGen.enableDepthWrite(false); + } + + bool drawSurfaceCreated = m_3dWellLogDrawSurfaceGeometryGenerator->createDrawSurface(displayCoordTransform, + wellPathClipBoundingBox, + rim3dWellLogCurve->drawPlaneAngle(), + wellPathCenterToPlotStartOffset(rim3dWellLogCurve), + planeWidth(), + samplingInterval); + if (!drawSurfaceCreated) return; + + cvf::ref backgroundEffect = backgroundEffectGen.generateCachedEffect(); + cvf::ref borderEffect = borderEffectGen.generateCachedEffect(); + cvf::ref curveNormalsEffect = curveNormalsEffectGen.generateCachedEffect(); + + cvf::ref background = m_3dWellLogDrawSurfaceGeometryGenerator->background(); + + if (background.notNull()) + { + cvf::ref part = createPart(background.p(), backgroundEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + part->setSourceInfo(sourceInfo.p()); + } + } + + if (showCoordinateSystemMesh) + { + cvf::ref border = m_3dWellLogDrawSurfaceGeometryGenerator->border(); + if (border.notNull()) + { + cvf::ref part = createPart(border.p(), borderEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + } + } + + cvf::ref normals = m_3dWellLogDrawSurfaceGeometryGenerator->curveNormalVectors(); + if (normals.notNull()) + { + normals->setSingleColor(borderColor); + if (RiaApplication::instance()->useShaders()) + { + normals->setUniformNames("u_transformationMatrix", "u_color"); + } + + cvf::ref part = createPart(normals.p(), curveNormalsEffect.p()); + if (part.notNull()) + { + model->addPart(part.p()); + part->setSourceInfo(sourceInfo.p()); + } + } + } +} diff --git a/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h new file mode 100644 index 0000000000..bed7b20347 --- /dev/null +++ b/ApplicationCode/ModelVisualization/Riv3dWellLogPlanePartMgr.h @@ -0,0 +1,81 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" + +#include "cafPdmPointer.h" + + +namespace cvf +{ +class ModelBasicList; +class Drawable; +class Effect; +class Part; +class BoundingBox; +class Color3f; +} + +namespace caf +{ +class DisplayCoordTransform; +} + +class RimGridView; +class RimWellPath; +class Riv3dWellLogDrawSurfaceGenerator; + +class Riv3dWellLogPlanePartMgr : public cvf::Object +{ +public: + Riv3dWellLogPlanePartMgr(RimWellPath* wellPath, RimGridView* gridView); + + void appendPlaneToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox); +private: + void append3dWellLogCurveToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + Rim3dWellLogCurve* rim3dWellLogCurve, + const std::vector& drawSurfaceVertices); + + void appendDrawSurfaceToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + const cvf::BoundingBox& wellPathClipBoundingBox, + const Rim3dWellLogCurve* rim3dWellLogCurve, + double samplingInterval); + + cvf::ref createPart(cvf::Drawable* drawable, cvf::Effect* effect); + + double wellPathCenterToPlotStartOffset(const Rim3dWellLogCurve* curve) const; + double planeWidth() const; + +private: + cvf::ref m_3dWellLogDrawSurfaceGeometryGenerator; + + caf::PdmPointer m_wellPath; + caf::PdmPointer m_gridView; +}; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp index 9bd7e9074c..5af982f9ef 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeEffectGenerator.cpp @@ -43,7 +43,7 @@ //-------------------------------------------------------------------------------------------------- CellEdgeEffectGenerator::CellEdgeEffectGenerator(const cvf::ScalarMapper* edgeScalarMapper) { - CVF_ASSERT(edgeScalarMapper != NULL); + CVF_ASSERT(edgeScalarMapper != nullptr); m_edgeScalarMapper = edgeScalarMapper; diff --git a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp index 64a1605fb3..0b6cf69ba0 100644 --- a/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivCellEdgeGeometryUtils.cpp @@ -32,7 +32,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimSimWellInViewCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivTernaryTextureCoordsCreator.h" @@ -56,7 +56,7 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( float opacityLevel) { RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); - CVF_ASSERT(eclipseCase != NULL); + CVF_ASSERT(eclipseCase != nullptr); // Create result access objects @@ -90,7 +90,7 @@ void RivCellEdgeGeometryUtils::addCellEdgeResultsToDrawableGeo( double ignoredScalarValue = cellEdgeResultColors->ignoredScalarValue(); - const std::vector* isWellPipeVisible = NULL; + const std::vector* isWellPipeVisible = nullptr; cvf::cref gridCellToWellindexMap; if (opacityLevel < 1.0f) @@ -200,7 +200,7 @@ void RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(size_t tim cvf::DrawableGeo* geo, size_t gridIndex, float opacityLevel) { RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); - CVF_ASSERT(eclipseCase != NULL); + CVF_ASSERT(eclipseCase != nullptr); cvf::ref cellEdgeResultAccessor = createCellEdgeResultAccessor(cellResultColors, cellEdgeResultColors, timeStepIndex, eclipseCase, eclipseCase->grid(gridIndex)); @@ -339,7 +339,7 @@ cvf::ref RivCellEdgeGeometryUtils::createCellEdgeResultAccess //-------------------------------------------------------------------------------------------------- cvf::ref RivCellEdgeGeometryUtils::createCellCenterResultAccessor(RimEclipseCellColors* cellResultColors, size_t timeStepIndex, RigEclipseCaseData* eclipseCase, const RigGridBase* grid) { - cvf::ref resultAccessor = NULL; + cvf::ref resultAccessor = nullptr; if (cellResultColors->hasResult()) { diff --git a/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp index 4a7c73a8c0..b46d76b969 100644 --- a/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultGeometryGenerator.cpp @@ -60,7 +60,7 @@ cvf::ref RivFaultGeometryGenerator::generateSurface() CVF_ASSERT(m_vertices.notNull()); - if (m_vertices->size() == 0) return NULL; + if (m_vertices->size() == 0) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setFromQuadVertexArray(m_vertices.p()); @@ -75,7 +75,7 @@ cvf::ref RivFaultGeometryGenerator::generateSurface() cvf::ref RivFaultGeometryGenerator::createMeshDrawable() { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setVertexArray(m_vertices.p()); @@ -93,7 +93,7 @@ cvf::ref RivFaultGeometryGenerator::createMeshDrawable() //-------------------------------------------------------------------------------------------------- cvf::ref RivFaultGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::OutlineEdgeExtractor ee(creaseAngle, *m_vertices); @@ -103,7 +103,7 @@ cvf::ref RivFaultGeometryGenerator::createOutlineMeshDrawable( cvf::ref lineIndices = ee.lineIndices(); if (lineIndices->size() == 0) { - return NULL; + return nullptr; } cvf::ref prim = new cvf::PrimitiveSetIndexedUInt(cvf::PT_LINES); diff --git a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp index 3f14a0b11b..f2a06238fa 100644 --- a/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivFaultPartMgr.cpp @@ -31,7 +31,7 @@ #include "RimEclipseView.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivFaultGeometryGenerator.h" @@ -374,7 +374,7 @@ void RivFaultPartMgr::updatePartEffect() m_oppositeFaultFaces->setEffect(geometryOnlyEffect.p()); } - updateNNCColors(0, NULL); + updateNNCColors(0, nullptr); // Update mesh colors as well, in case of change RiaPreferences* prefs = RiaApplication::instance()->preferences(); @@ -417,8 +417,8 @@ void RivFaultPartMgr::updatePartEffect() //-------------------------------------------------------------------------------------------------- void RivFaultPartMgr::createLabelWithAnchorLine(const cvf::Part* part) { - m_faultLabelPart = NULL; - m_faultLabelLinePart = NULL; + m_faultLabelPart = nullptr; + m_faultLabelLinePart = nullptr; if (!part) return; @@ -705,8 +705,9 @@ void RivFaultPartMgr::updateNNCColors(size_t timeStepIndex, RimEclipseCellColors cvf::Color3f nncColor = m_defaultColor; nncColor.r() += (1.0 - nncColor.r()) * 0.2; nncColor.g() += (1.0 - nncColor.g()) * 0.2; - nncColor.g() += (1.0 - nncColor.b()) * 0.2; + nncColor.b() += (1.0 - nncColor.b()) * 0.2; + CVF_ASSERT(nncColor.isValid()); cvf::ref nncEffect; if (m_rimFaultCollection->showFaultFaces || m_rimFaultCollection->showOppositeFaultFaces) diff --git a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp index 9f2796dfbf..b4a178c60c 100644 --- a/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivGridPartMgr.cpp @@ -32,7 +32,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimSimWellInViewCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "RimTernaryLegendConfig.h" @@ -189,7 +189,7 @@ void RivGridPartMgr::generatePartGeometry(cvf::StructGridGeometryGenerator& geoB //-------------------------------------------------------------------------------------------------- void RivGridPartMgr::appendPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); if(m_surfaceFaces.notNull() ) model->addPart(m_surfaceFaces.p() ); if(m_surfaceGridLines.notNull()) model->addPart(m_surfaceGridLines.p()); diff --git a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp index 4a7d88c9d1..9a275428e5 100644 --- a/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivNNCGeometryGenerator.cpp @@ -56,7 +56,7 @@ cvf::ref RivNNCGeometryGenerator::generateSurface() CVF_ASSERT(m_vertices.notNull()); - if (m_vertices->size() == 0) return NULL; + if (m_vertices->size() == 0) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setFromTriangleVertexArray(m_vertices.p()); @@ -76,7 +76,7 @@ void RivNNCGeometryGenerator::computeArrays() long long numConnections = static_cast(m_nncIndexes.isNull()? m_nncData->connections().size(): m_nncIndexes->size()); bool isVisibilityCalcActive = m_cellVisibility.notNull() && m_grid.notNull(); - std::vector* allCells = NULL; + std::vector* allCells = nullptr; if (isVisibilityCalcActive) { allCells = &(m_grid->mainGrid()->globalCellArray()); diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp index c5d3b5f5ee..6abefded1b 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.cpp @@ -108,7 +108,7 @@ cvf::ref RivPipeGeometryGenerator::createPipeSurface() { if (m_radius == 0.0) { - return NULL; + return nullptr; } updateFilteredPipeCenterCoords(); @@ -212,9 +212,9 @@ void RivPipeGeometryGenerator::computeCircle(double radius, size_t tesselationCo //-------------------------------------------------------------------------------------------------- cvf::ref RivPipeGeometryGenerator::generateLine(const cvf::Vec3dArray* coords) { - CVF_ASSERT(coords != NULL); + CVF_ASSERT(coords != nullptr); - if (coords->size() < 2 ) return NULL; + if (coords->size() < 2 ) return nullptr; size_t duplicateVertexCount = 2 * (coords->size() - 1); @@ -259,9 +259,9 @@ cvf::ref RivPipeGeometryGenerator::generateLine(const cvf::Vec //-------------------------------------------------------------------------------------------------- cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(double radius, size_t crossSectionNodeCount, const cvf::Vec3dArray* cylinderCenterCoords) { - CVF_ASSERT(cylinderCenterCoords != NULL); + CVF_ASSERT(cylinderCenterCoords != nullptr); - if (cylinderCenterCoords->size() < 2) return NULL; + if (cylinderCenterCoords->size() < 2) return nullptr; std::vector crossSectionVertices; std::vector cylinderSegmentNormals; @@ -300,7 +300,7 @@ cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(do } } - if (i >= cylinderCenterCoords->size()-1) return NULL; // The pipe coordinates is all the same point + if (i >= cylinderCenterCoords->size()-1) return nullptr; // The pipe coordinates is all the same point // Loop along the cylinder center coords and calculate the cross section vertexes in each center vertex @@ -346,7 +346,7 @@ cvf::ref RivPipeGeometryGenerator::generateExtrudedCylinder(do size_t crossSectionCount = crossSectionVertices.size() / crossSectionNodeCount; - if (crossSectionCount < 2) return NULL; + if (crossSectionCount < 2) return nullptr; CVF_ASSERT(crossSectionVertices.size() - crossSectionNodeCount == cylinderSegmentNormals.size()); @@ -474,7 +474,7 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords() const size_t lastOriginalCoordIdx = m_originalPipeCenterCoords->size() - 1; - size_t firstSegmentWithLength = findFirstSegmentWithLenght(squareDistanceTolerance); + size_t firstSegmentWithLength = findFirstSegmentWithLength(squareDistanceTolerance); // Return if we have only zero-length segments @@ -562,7 +562,7 @@ void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RivPipeGeometryGenerator::findFirstSegmentWithLenght(double squareDistanceTolerance) +size_t RivPipeGeometryGenerator::findFirstSegmentWithLength(double squareDistanceTolerance) { size_t segIdx; for ( segIdx = 0; segIdx < m_originalPipeCenterCoords->size() - 1; segIdx++ ) diff --git a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h index 82e685a509..f4fe97922c 100644 --- a/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h +++ b/ApplicationCode/ModelVisualization/RivPipeGeometryGenerator.h @@ -54,7 +54,6 @@ class RivPipeGeometryGenerator : public cvf::Object // Appearance void setRadius(double radius); void setCrossSectionVertexCount(size_t vertexCount); - void setPipeColor(cvf::Color3f val) { m_pipeColor = val; } cvf::ref createPipeSurface(); cvf::ref createCenterLine(); @@ -70,7 +69,7 @@ class RivPipeGeometryGenerator : public cvf::Object void clearComputedData(); void updateFilteredPipeCenterCoords(); - size_t findFirstSegmentWithLenght(double squareDistanceTolerance); + size_t findFirstSegmentWithLength(double squareDistanceTolerance); static void computeCircle(double radius, size_t tesselationCount, const cvf::Vec3d& center, const cvf::Vec3d& orient1, const cvf::Vec3d& orient2, std::vector* nodes); @@ -100,5 +99,4 @@ class RivPipeGeometryGenerator : public cvf::Object double m_minimumBendAngle; double m_bendScalingFactor; size_t m_crossSectionNodeCount; - cvf::Color3f m_pipeColor; }; diff --git a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp index 5adf827c07..1b61952eab 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirFaultsPartMgr.cpp @@ -95,7 +95,7 @@ void RivReservoirFaultsPartMgr::setCellVisibility(cvf::UByteArray* cellVisibilit //-------------------------------------------------------------------------------------------------- void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection(); if (!faultCollection) return; @@ -109,7 +109,7 @@ void RivReservoirFaultsPartMgr::appendPartsToModel(cvf::ModelBasicList* model) // Parts that is overridden by the grid settings bool forceDisplayOfFault = false; - if (!faultCollection->showFaultsOutsideFilters()) + if (!faultCollection->isShowingFaultsAndFaultsOutsideFilters()) { forceDisplayOfFault = isShowingGrid; } @@ -243,7 +243,7 @@ void RivReservoirFaultsPartMgr::updateCellEdgeResultColor(size_t timeStepIndex, //-------------------------------------------------------------------------------------------------- void RivReservoirFaultsPartMgr::appendLabelPartsToModel(cvf::ModelBasicList* model) { - CVF_ASSERT(model != NULL); + CVF_ASSERT(model != nullptr); if (!m_reservoirView) return; RimFaultInViewCollection* faultCollection = m_reservoirView->faultCollection(); diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp index 4a47e2c857..e83e869107 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.cpp @@ -29,15 +29,16 @@ #include "RimSimWellInViewCollection.h" #include "RimSimWellInView.h" -#include "RivWellHeadPartMgr.h" #include "RivSimWellPipesPartMgr.h" +#include "RivWellConnectionsPartMgr.h" +#include "RivWellHeadPartMgr.h" +#include "RivWellSpheresPartMgr.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" +#include "cafDisplayCoordTransform.h" #include "cvfTransform.h" -#include "RivWellSpheresPartMgr.h" -#include "RivWellConnectionsPartMgr.h" //-------------------------------------------------------------------------------------------------- /// @@ -73,16 +74,6 @@ void RivReservoirSimWellsPartMgr::clearGeometryCache() //-------------------------------------------------------------------------------------------------- void RivReservoirSimWellsPartMgr::scheduleGeometryRegen() { - for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) - { - m_wellPipesPartMgrs[wIdx]->scheduleGeometryRegen(); - } - - for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) - { - //m_wellHeadPartMgrs[wIdx]->scheduleGeometryRegen(scaleTransform); - } - m_wellSpheresPartMgrs.clear(); } @@ -92,16 +83,6 @@ void RivReservoirSimWellsPartMgr::scheduleGeometryRegen() void RivReservoirSimWellsPartMgr::setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; - - for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) - { - m_wellPipesPartMgrs[wIdx]->setScaleTransform(scaleTransform); - } - - for (size_t wIdx = 0; wIdx != m_wellHeadPartMgrs.size(); ++ wIdx) - { - m_wellHeadPartMgrs[wIdx]->setScaleTransform(scaleTransform); - } } //-------------------------------------------------------------------------------------------------- @@ -117,20 +98,23 @@ void RivReservoirSimWellsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBa for (size_t i = 0; i < m_reservoirView->wellCollection()->wells.size(); ++i) { - RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); + RivSimWellPipesPartMgr * wppmgr = new RivSimWellPipesPartMgr( m_reservoirView->wellCollection()->wells[i]); m_wellPipesPartMgrs.push_back(wppmgr); - wppmgr->setScaleTransform(m_scaleTransform.p()); - RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView, m_reservoirView->wellCollection()->wells[i]); + RivWellHeadPartMgr* wellHeadMgr = new RivWellHeadPartMgr(m_reservoirView->wellCollection()->wells[i]); m_wellHeadPartMgrs.push_back(wellHeadMgr); - wellHeadMgr->setScaleTransform(m_scaleTransform.p()); + } } for (size_t wIdx = 0; wIdx != m_wellPipesPartMgrs.size(); ++ wIdx) { - m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); - m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, frameIndex); + m_wellPipesPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, + frameIndex, + m_reservoirView->displayCoordTransform().p()); + m_wellHeadPartMgrs[wIdx]->appendDynamicGeometryPartsToModel(model, + frameIndex, + m_reservoirView->displayCoordTransform().p()); } // Well spheres @@ -176,16 +160,3 @@ void RivReservoirSimWellsPartMgr::updatePipeResultColor(size_t frameIndex) } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const std::vector< std::vector >* RivReservoirSimWellsPartMgr::centerLineOfWellBranches(int wellIdx) -{ - if (wellIdx < static_cast(m_wellPipesPartMgrs.size())) - { - return &(m_wellPipesPartMgrs[wellIdx]->centerLineOfWellBranches()); - } - - return NULL; -} - diff --git a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h index 459b77ab0b..71bcaac087 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirSimWellsPartMgr.h @@ -1,24 +1,23 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2011-2012 Statoil ASA, Ceetron AS -// +// // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. -// +// // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. -// -// See the GNU General Public License at +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once - #include "cvfBase.h" #include "cvfCollection.h" #include "cvfVector3.h" @@ -27,9 +26,9 @@ namespace cvf { - class Transform; - class ModelBasicList; -} +class Transform; +class ModelBasicList; +} // namespace cvf class RimEclipseView; class RivSimWellPipesPartMgr; @@ -37,6 +36,9 @@ class RivWellHeadPartMgr; class RivWellSpheresPartMgr; class RivWellConnectionsPartMgr; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RivReservoirSimWellsPartMgr : public cvf::Object { public: @@ -51,15 +53,12 @@ class RivReservoirSimWellsPartMgr : public cvf::Object void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); void updatePipeResultColor(size_t frameIndex); - const std::vector< std::vector >* centerLineOfWellBranches(int wellIdx); - private: - caf::PdmPointer m_reservoirView; - cvf::ref m_scaleTransform; - - cvf::Collection< RivSimWellPipesPartMgr > m_wellPipesPartMgrs; - cvf::Collection< RivWellHeadPartMgr > m_wellHeadPartMgrs; - cvf::Collection< RivWellSpheresPartMgr > m_wellSpheresPartMgrs; - cvf::Collection< RivWellConnectionsPartMgr > m_wellConnPartMgrs; + caf::PdmPointer m_reservoirView; + cvf::ref m_scaleTransform; + cvf::Collection m_wellPipesPartMgrs; + cvf::Collection m_wellHeadPartMgrs; + cvf::Collection m_wellSpheresPartMgrs; + cvf::Collection m_wellConnPartMgrs; }; diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp index 254a9bae3f..74317e8ca0 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.cpp @@ -150,8 +150,8 @@ void RivReservoirViewPartMgr::scheduleGeometryRegen(RivCellSetEnum geometryType) //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::clearGeometryCache(RivCellSetEnum geomType) { - RigEclipseCaseData* eclipseCase = NULL; - if (m_reservoirView != NULL && m_reservoirView->eclipseCase()) + RigEclipseCaseData* eclipseCase = nullptr; + if (m_reservoirView != nullptr && m_reservoirView->eclipseCase()) { eclipseCase = m_reservoirView->eclipseCase()->eclipseCaseData(); } @@ -214,11 +214,20 @@ void RivReservoirViewPartMgr::clearGeometryCache() void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector& gridIndices) { - if (m_geometriesNeedsRegen[geometryType]) + ensureStaticGeometryPartsCreated(geometryType); + + m_geometries[geometryType].appendGridPartsToModel(model, gridIndices); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivReservoirViewPartMgr::ensureStaticGeometryPartsCreated(RivCellSetEnum geometryType) +{ + if (geometryType < PROPERTY_FILTERED && m_geometriesNeedsRegen[geometryType]) { createGeometry( geometryType); } - m_geometries[geometryType].appendGridPartsToModel(model, gridIndices); } //-------------------------------------------------------------------------------------------------- @@ -226,6 +235,23 @@ void RivReservoirViewPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicLi //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector& gridIndices) +{ + ensureDynamicGeometryPartsCreated(geometryType, frameIndex); + + if (geometryType == PROPERTY_FILTERED) + { + m_propFilteredGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); + } + else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) + { + m_propFilteredWellGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivReservoirViewPartMgr::ensureDynamicGeometryPartsCreated(RivCellSetEnum geometryType, size_t frameIndex) { if (geometryType == PROPERTY_FILTERED) { @@ -233,7 +259,6 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL { createPropertyFilteredNoneWellCellGeometry(frameIndex); } - m_propFilteredGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); } else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) { @@ -241,7 +266,6 @@ void RivReservoirViewPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicL { createPropertyFilteredWellGeometry(frameIndex); } - m_propFilteredWellGeometryFrames[frameIndex]->appendGridPartsToModel(model, gridIndices); } } @@ -290,7 +314,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case VISIBLE_WELL_CELLS: { cvf::ref allWellCellsVisibility; - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); allWellCellsVisibility = m_geometries[ALL_WELL_CELLS].cellVisibility(gridIdx); @@ -306,7 +330,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case VISIBLE_WELL_FENCE_CELLS: { cvf::ref allWellCellsVisibility; - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); allWellCellsVisibility = m_geometries[ALL_WELL_CELLS].cellVisibility(gridIdx); @@ -325,7 +349,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case RANGE_FILTERED: { cvf::ref nativeVisibility; - if (m_geometriesNeedsRegen[ACTIVE]) createGeometry(ACTIVE); + ensureStaticGeometryPartsCreated(ACTIVE); nativeVisibility = m_geometries[ACTIVE].cellVisibility(gridIdx); computeRangeVisibility(geometryType, cellVisibility, grid, nativeVisibility.p(), m_reservoirView->rangeFilterCollection()); @@ -334,7 +358,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case RANGE_FILTERED_INACTIVE: { cvf::ref nativeVisibility; - if (m_geometriesNeedsRegen[INACTIVE]) createGeometry(INACTIVE); + ensureStaticGeometryPartsCreated(INACTIVE); nativeVisibility = m_geometries[INACTIVE].cellVisibility(gridIdx); computeRangeVisibility(geometryType, cellVisibility, grid, nativeVisibility.p(), m_reservoirView->rangeFilterCollection()); @@ -343,7 +367,7 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, case RANGE_FILTERED_WELL_CELLS: { cvf::ref nativeVisibility; - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); nativeVisibility = m_geometries[ALL_WELL_CELLS].cellVisibility(gridIdx); computeRangeVisibility(geometryType, cellVisibility, grid, nativeVisibility.p(), m_reservoirView->rangeFilterCollection()); @@ -354,8 +378,8 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, cvf::ref visibleWellCells; cvf::ref rangeFilteredWellCells; - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS]) createGeometry(VISIBLE_WELL_CELLS); - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED_WELL_CELLS); visibleWellCells = m_geometries[VISIBLE_WELL_CELLS].cellVisibility(gridIdx); rangeFilteredWellCells = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gridIdx); @@ -374,8 +398,8 @@ void RivReservoirViewPartMgr::computeVisibility(cvf::UByteArray* cellVisibility, cvf::ref visibleWellCells; cvf::ref rangeFilteredWellCells; - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED); visibleWellCells = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gridIdx); rangeFilteredWellCells = m_geometries[RANGE_FILTERED].cellVisibility(gridIdx); @@ -427,29 +451,29 @@ void RivReservoirViewPartMgr::createPropertyFilteredNoneWellCellGeometry(size_t if (hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + ensureStaticGeometryPartsCreated(RANGE_FILTERED); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); } else if (hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED]) createGeometry(RANGE_FILTERED); + ensureStaticGeometryPartsCreated(RANGE_FILTERED); rangeVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); fenceVisibility = m_geometries[RANGE_FILTERED].cellVisibility(gIdx); } else if (!hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS); rangeVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); fenceVisibility = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); } else if (!hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[ACTIVE]) createGeometry(ACTIVE); + ensureStaticGeometryPartsCreated(ACTIVE); rangeVisibility = m_geometries[ACTIVE].cellVisibility(gIdx); fenceVisibility = m_geometries[ACTIVE].cellVisibility(gIdx); @@ -504,36 +528,36 @@ void RivReservoirViewPartMgr::createPropertyFilteredWellGeometry(size_t frameInd if (hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED_WELL_CELLS); rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER); wellCellsOutsideRange = m_geometries[VISIBLE_WELL_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER]) createGeometry(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER); wellFenceCells = m_geometries[VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER].cellVisibility(gIdx); } else if (hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[RANGE_FILTERED_WELL_CELLS]) createGeometry(RANGE_FILTERED_WELL_CELLS); + ensureStaticGeometryPartsCreated(RANGE_FILTERED_WELL_CELLS); rangeVisibility = m_geometries[RANGE_FILTERED_WELL_CELLS].cellVisibility(gIdx); wellCellsOutsideRange = rangeVisibility; wellFenceCells = rangeVisibility; } else if (!hasActiveRangeFilters && hasVisibleWellCells) { - if (m_geometriesNeedsRegen[VISIBLE_WELL_CELLS]) createGeometry(VISIBLE_WELL_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_CELLS); wellCellsOutsideRange = m_geometries[VISIBLE_WELL_CELLS].cellVisibility(gIdx); - if (m_geometriesNeedsRegen[VISIBLE_WELL_FENCE_CELLS]) createGeometry(VISIBLE_WELL_FENCE_CELLS); + ensureStaticGeometryPartsCreated(VISIBLE_WELL_FENCE_CELLS); wellFenceCells = m_geometries[VISIBLE_WELL_FENCE_CELLS].cellVisibility(gIdx); rangeVisibility = wellCellsOutsideRange; } else if (!hasActiveRangeFilters && !hasVisibleWellCells) { - if (m_geometriesNeedsRegen[ALL_WELL_CELLS]) createGeometry(ALL_WELL_CELLS); + ensureStaticGeometryPartsCreated(ALL_WELL_CELLS); wellFenceCells = m_geometries[ALL_WELL_CELLS].cellVisibility(gIdx); wellCellsOutsideRange = wellFenceCells; rangeVisibility = wellFenceCells; @@ -564,10 +588,10 @@ void RivReservoirViewPartMgr::computeNativeVisibility(cvf::UByteArray* cellVisib bool activeCellsIsVisible, bool mainGridIsVisible) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(grid != NULL); - CVF_ASSERT(activeCellInfo != NULL); - CVF_ASSERT(cellIsInWellStatuses != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(grid != nullptr); + CVF_ASSERT(activeCellInfo != nullptr); + CVF_ASSERT(cellIsInWellStatuses != nullptr); CVF_ASSERT(cellIsInWellStatuses->size() >= grid->cellCount()); cellVisibility->resize(grid->cellCount()); @@ -604,7 +628,7 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c CVF_ASSERT(masterViewLink); - RimView* masterView = masterViewLink->ownerViewLinker()->masterView(); + RimGridView* masterView = masterViewLink->ownerViewLinker()->masterView(); // get cell visibility #if 1 @@ -614,8 +638,8 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c std::vector > gridsWithCellSetVisibility = masterView->getAllGridsCurrentCellSetsCellVisibility(); #endif - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(grid != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(grid != nullptr); size_t gridCellCount = grid->cellCount(); cellVisibility->resize(gridCellCount); @@ -660,8 +684,8 @@ void RivReservoirViewPartMgr::computeOverriddenCellVisibility(cvf::UByteArray* c //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::copyByteArray(cvf::UByteArray* destination, const cvf::UByteArray* source ) { - CVF_ASSERT(destination != NULL); - CVF_ASSERT(source != NULL); + CVF_ASSERT(destination != nullptr); + CVF_ASSERT(source != nullptr); if (destination->size() != source->size()) { @@ -685,11 +709,11 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(nativeVisibility != NULL); - CVF_ASSERT(rangeFilterColl != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(nativeVisibility != nullptr); + CVF_ASSERT(rangeFilterColl != nullptr); - CVF_ASSERT(grid != NULL); + CVF_ASSERT(grid != nullptr); CVF_ASSERT(nativeVisibility->size() == grid->cellCount()); // Initialize range filter with native visibility @@ -701,7 +725,7 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType cvf::CellRangeFilter gridCellRangeFilter; rangeFilterColl->compoundCellRangeFilter(&gridCellRangeFilter, grid->gridIndex()); - const RigLocalGrid* lgr = NULL; + const RigLocalGrid* lgr = nullptr; cvf::ref parentGridVisibilities; if (!grid->isMainGrid()) @@ -741,7 +765,7 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType size_t mainGridJ; size_t mainGridK; - bool isInSubGridArea = cell.subGrid() != NULL; + bool isInSubGridArea = cell.subGrid() != nullptr; grid->ijkFromCellIndex(cellIndex, &mainGridI, &mainGridJ, &mainGridK); bool nativeRangeVisibility = false; @@ -769,9 +793,9 @@ void RivReservoirViewPartMgr::computeRangeVisibility(RivCellSetEnum geometryType void RivReservoirViewPartMgr::computePropertyVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl) { - CVF_ASSERT(cellVisibility != NULL); - CVF_ASSERT(rangeFilterVisibility != NULL); - CVF_ASSERT(propFilterColl != NULL); + CVF_ASSERT(cellVisibility != nullptr); + CVF_ASSERT(rangeFilterVisibility != nullptr); + CVF_ASSERT(propFilterColl != nullptr); CVF_ASSERT(grid->cellCount() > 0); CVF_ASSERT(rangeFilterVisibility->size() == grid->cellCount()); @@ -904,28 +928,11 @@ void RivReservoirViewPartMgr::updateFaultCellEdgeResultColor(RivCellSetEnum geom //-------------------------------------------------------------------------------------------------- const cvf::UByteArray* RivReservoirViewPartMgr::cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t timeStepIndex) { - if (geometryType == PROPERTY_FILTERED) - { - if (timeStepIndex >= m_propFilteredGeometryFramesNeedsRegen.size() || m_propFilteredGeometryFramesNeedsRegen[timeStepIndex]) - { - createPropertyFilteredNoneWellCellGeometry(timeStepIndex); - } - } - else if (geometryType == PROPERTY_FILTERED_WELL_CELLS) - { - if (timeStepIndex >= m_propFilteredWellGeometryFramesNeedsRegen.size() || m_propFilteredWellGeometryFramesNeedsRegen[timeStepIndex]) - { - createPropertyFilteredWellGeometry(timeStepIndex); - } - } - else - { - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } - } + ensureDynamicGeometryPartsCreated(geometryType, timeStepIndex); + ensureStaticGeometryPartsCreated(geometryType); + RivReservoirPartMgr * pmgr = (const_cast(this))->reservoirPartManager( geometryType, timeStepIndex ); + return pmgr->cellVisibility(gridIndex).p(); } @@ -972,13 +979,9 @@ void RivReservoirViewPartMgr::updateFaultColors(RivCellSetEnum geometryType, siz //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType) { - //CVF_ASSERT(geometryType < PROPERTY_FILTERED); if (geometryType >= PROPERTY_FILTERED) return; - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } + ensureStaticGeometryPartsCreated(geometryType); /* QString text; @@ -1084,10 +1087,7 @@ RivCellSetEnum RivReservoirViewPartMgr::geometryTypeForFaultLabels(const std::se //-------------------------------------------------------------------------------------------------- void RivReservoirViewPartMgr::appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType) { - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } + ensureStaticGeometryPartsCreated(geometryType); m_geometries[geometryType].appendFaultLabelPartsToModel(model); } @@ -1120,10 +1120,7 @@ void RivReservoirViewPartMgr::forceWatertightGeometryOnForType(RivCellSetEnum ge } else { - if (m_geometriesNeedsRegen[geometryType]) - { - createGeometry(geometryType); - } + ensureStaticGeometryPartsCreated(geometryType); m_geometries[geometryType].forceWatertightGeometryOn(); } } diff --git a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h index ad27f02dfb..8a2b5acc36 100644 --- a/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivReservoirViewPartMgr.h @@ -54,36 +54,60 @@ class RivReservoirViewPartMgr: public cvf::Object void scheduleGeometryRegen(RivCellSetEnum geometryType); const cvf::UByteArray* cellVisibility(RivCellSetEnum geometryType, size_t gridIndex, size_t frameIndex); - void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, RivCellSetEnum geometryType, const std::vector& gridIndices); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex, const std::vector& gridIndices); - - void updateCellColor (RivCellSetEnum geometryType, size_t timeStepIndex, + void appendStaticGeometryPartsToModel (cvf::ModelBasicList* model, + RivCellSetEnum geometryType, + const std::vector& gridIndices); + void ensureStaticGeometryPartsCreated ( RivCellSetEnum geometryType ); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType, + size_t frameIndex, + const std::vector& gridIndices); + void ensureDynamicGeometryPartsCreated(RivCellSetEnum geometryType, + size_t frameIndex); + + void updateCellColor (RivCellSetEnum geometryType, + size_t timeStepIndex, cvf::Color4f color); - void updateCellResultColor (RivCellSetEnum geometryType, size_t timeStepIndex, + void updateCellResultColor (RivCellSetEnum geometryType, + size_t timeStepIndex, RimEclipseCellColors* cellResultColors); - void updateCellEdgeResultColor(RivCellSetEnum geometryType, size_t timeStepIndex, + void updateCellEdgeResultColor(RivCellSetEnum geometryType, + size_t timeStepIndex, RimEclipseCellColors* cellResultColors, RimCellEdgeColors* cellEdgeResultColors); // Faults - void appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType); - void appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex); - void updateFaultColors(RivCellSetEnum geometryType, size_t timeStepIndex, RimEclipseCellColors* cellResultColors); - void updateFaultCellEdgeResultColor( RivCellSetEnum geometryType, size_t timeStepIndex, - RimEclipseCellColors* cellResultColors, - RimCellEdgeColors* cellEdgeResultColors); + void appendFaultsStaticGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType); + void appendFaultsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType, + size_t frameIndex); + void updateFaultColors(RivCellSetEnum geometryType, + size_t timeStepIndex, + RimEclipseCellColors* cellResultColors); + void updateFaultCellEdgeResultColor(RivCellSetEnum geometryType, + size_t timeStepIndex, + RimEclipseCellColors* cellResultColors, + RimCellEdgeColors* cellEdgeResultColors); // Fault labels - RivCellSetEnum geometryTypeForFaultLabels(const std::set& geometryTypes, bool showFaultsOutsideFilters) const; - void appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType); - void appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, RivCellSetEnum geometryType, size_t frameIndex); + RivCellSetEnum geometryTypeForFaultLabels(const std::set& geometryTypes, + bool showFaultsOutsideFilters) const; + void appendFaultLabelsStaticGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType); + void appendFaultLabelsDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + RivCellSetEnum geometryType, size_t frameIndex); void forceWatertightGeometryOnForType(RivCellSetEnum geometryType); void clearWatertightGeometryFlags(); private: void createGeometry(RivCellSetEnum geometryType); - void computeVisibility(cvf::UByteArray* cellVisibility, RivCellSetEnum geometryType, RigGridBase* grid, size_t gridIdx); + void computeVisibility(cvf::UByteArray* cellVisibility, + RivCellSetEnum geometryType, + RigGridBase* grid, + size_t gridIdx); void createPropertyFilteredNoneWellCellGeometry(size_t frameIndex); void createPropertyFilteredWellGeometry(size_t frameIndex); @@ -91,10 +115,26 @@ class RivReservoirViewPartMgr: public cvf::Object void clearGeometryCache(RivCellSetEnum geomType); - static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const RigActiveCellInfo* activeCellInfo, const cvf::UByteArray* cellIsInWellStatuses, bool invalidCellsIsVisible, bool inactiveCellsIsVisible, bool activeCellsIsVisible, bool mainGridIsVisible); - void computeRangeVisibility (RivCellSetEnum geometryType, cvf::UByteArray* cellVisibilities, const RigGridBase* grid, const cvf::UByteArray* nativeVisibility, const RimCellRangeFilterCollection* rangeFilterColl); - static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, const RigGridBase* grid, size_t timeStepIndex, const cvf::UByteArray* rangeFilterVisibility, RimEclipsePropertyFilterCollection* propFilterColl); - void computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, const RigGridBase* grid); + static void computeNativeVisibility (cvf::UByteArray* cellVisibilities, + const RigGridBase* grid, + const RigActiveCellInfo* activeCellInfo, + const cvf::UByteArray* cellIsInWellStatuses, + bool invalidCellsIsVisible, + bool inactiveCellsIsVisible, + bool activeCellsIsVisible, + bool mainGridIsVisible); + void computeRangeVisibility (RivCellSetEnum geometryType, + cvf::UByteArray* cellVisibilities, + const RigGridBase* grid, + const cvf::UByteArray* nativeVisibility, + const RimCellRangeFilterCollection* rangeFilterColl); + static void computePropertyVisibility(cvf::UByteArray* cellVisibilities, + const RigGridBase* grid, + size_t timeStepIndex, + const cvf::UByteArray* rangeFilterVisibility, + RimEclipsePropertyFilterCollection* propFilterColl); + void computeOverriddenCellVisibility(cvf::UByteArray* cellVisibility, + const RigGridBase* grid); static void copyByteArray(cvf::UByteArray* dest, const cvf::UByteArray* source ); diff --git a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp index 11ff995deb..36f83ac76e 100644 --- a/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp +++ b/ApplicationCode/ModelVisualization/RivScalarMapperUtils.cpp @@ -19,10 +19,12 @@ #include "RivScalarMapperUtils.h" +#include "RiaColorTables.h" + #include "RimCellEdgeColors.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimTernaryLegendConfig.h" #include "RivCellEdgeEffectGenerator.h" @@ -85,7 +87,7 @@ cvf::ref RivScalarMapperUtils::createCellEdgeEffect(cvf::DrawableGe RivCellEdgeGeometryUtils::addTernaryCellEdgeResultsToDrawableGeo(timeStepIndex, cellResultColors, cellEdgeResultColors, quadToCellFaceMapper, dg, gridIndex, opacityLevel); - RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); + const RivTernaryScalarMapper* ternaryCellScalarMapper = cellResultColors->ternaryLegendConfig()->scalarMapper(); cellFaceEffectGen.setTernaryScalarMapper(ternaryCellScalarMapper); } else @@ -128,6 +130,7 @@ cvf::ref RivScalarMapperUtils::createScalarMapperEffect(const cvf:: caf::ScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.setUndefinedColor(RiaColorTables::undefinedCellColor()); scalarEffgen.disableLighting(disableLighting); cvf::ref scalarEffect = scalarEffgen.generateCachedEffect(); @@ -146,7 +149,9 @@ cvf::ref RivScalarMapperUtils::createTernaryScalarMapperEffect(cons RivTernaryScalarMapperEffectGenerator scalarEffgen(mapper, polygonOffset); scalarEffgen.setOpacityLevel(opacityLevel); scalarEffgen.setFaceCulling(faceCulling); + scalarEffgen.setUndefinedColor(RiaColorTables::undefinedCellColor()); scalarEffgen.disableLighting(disableLighting); + cvf::ref scalarEffect = scalarEffgen.generateCachedEffect(); return scalarEffect; diff --git a/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp new file mode 100644 index 0000000000..0018a16497 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivSimWellConnectionSourceInfo.h" + +#include "RimSimWellInView.h" +#include "RivWellConnectionFactorGeometryGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivSimWellConnectionSourceInfo::RivSimWellConnectionSourceInfo(RimSimWellInView* simWellInView, + RivWellConnectionFactorGeometryGenerator* geometryGenerator) + : m_simWellInView(simWellInView) + , m_geometryGenerator(geometryGenerator) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSimWellInView* RivSimWellConnectionSourceInfo::simWellInView() const +{ + return m_simWellInView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivSimWellConnectionSourceInfo::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0; + + return m_geometryGenerator->globalCellIndexFromTriangleIndex(triangleIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivSimWellConnectionSourceInfo::connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0.0; + + return m_geometryGenerator->connectionFactor(triangleIndex); +} diff --git a/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h new file mode 100644 index 0000000000..464e90a81b --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivSimWellConnectionSourceInfo.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmPointer.h" + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +class RimSimWellInView; +class RivWellConnectionFactorGeometryGenerator; + +//================================================================================================== +/// +//================================================================================================== +class RivSimWellConnectionSourceInfo : public cvf::Object +{ +public: + explicit RivSimWellConnectionSourceInfo(RimSimWellInView* simWellInView, RivWellConnectionFactorGeometryGenerator* geometryGenerator); + + RimSimWellInView* simWellInView() const; + + size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; + double connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const; + +private: + caf::PdmPointer m_simWellInView; + cvf::ref m_geometryGenerator; +}; diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp index 8632baf474..29dfef3c0d 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.cpp @@ -20,46 +20,42 @@ #include "RivSimWellPipesPartMgr.h" -#include "RigEclipseCaseData.h" -#include "RigCell.h" -#include "RigMainGrid.h" -#include "RigSimulationWellCenterLineCalculator.h" - -#include "Rim3dOverlayInfoConfig.h" -#include "RimCellEdgeColors.h" -#include "RimCellRangeFilterCollection.h" -#include "RimEclipseCase.h" -#include "RimEclipseCellColors.h" -#include "RimEclipsePropertyFilterCollection.h" +#include "RiaColorTables.h" +#include "RiaExtractionTools.h" + +#include "RigEclipseWellLogExtractor.h" +#include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellLogExtractor.h" +#include "RigWellPath.h" + +#include "Rim3dView.h" #include "RimEclipseView.h" -#include "RimReservoirCellResultsStorage.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" +#include "RimVirtualPerforationResults.h" #include "RivPipeGeometryGenerator.h" -#include "RivWellPathSourceInfo.h" +#include "RivSectionFlattner.h" +#include "RivSimWellConnectionSourceInfo.h" #include "RivSimWellPipeSourceInfo.h" +#include "RivWellConnectionFactorGeometryGenerator.h" +#include "RivWellConnectionSourceInfo.h" +#include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" #include "cvfDrawableGeo.h" #include "cvfModelBasicList.h" #include "cvfPart.h" -#include "cvfRay.h" #include "cvfScalarMapperDiscreteLinear.h" -#include "cvfTransform.h" - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well) +RivSimWellPipesPartMgr::RivSimWellPipesPartMgr(RimSimWellInView* well) + : m_simWellInView(well) { - m_rimReservoirView = reservoirView; - m_rimWell = well; - m_needsTransformUpdate = true; } //-------------------------------------------------------------------------------------------------- @@ -73,22 +69,119 @@ RivSimWellPipesPartMgr::~RivSimWellPipesPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::buildWellPipeParts() +Rim3dView* RivSimWellPipesPartMgr::viewWithSettings() { - if (m_rimReservoirView.isNull()) return; + Rim3dView* view = nullptr; + if (m_simWellInView) m_simWellInView->firstAncestorOrThisOfType(view); + + return view; +} - m_wellBranches.clear(); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf) +{ + if (!viewWithSettings()) return; + + if (!m_simWellInView->isWellPipeVisible(frameIndex)) return; + + buildWellPipeParts(displayXf, false, 0.0, -1, frameIndex); + + std::list::iterator it; + for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) + { + if (it->m_surfacePart.notNull()) + { + model->addPart(it->m_surfacePart.p()); + } + if (it->m_centerLinePart.notNull()) + { + model->addPart(it->m_centerLinePart.p()); + } + + if (it->m_connectionFactorsPart.notNull()) + { + model->addPart(it->m_connectionFactorsPart.p()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf, + double flattenedIntersectionExtentLength, + int branchIndex) +{ + if (!viewWithSettings()) return; + + if (!m_simWellInView->isWellPipeVisible(frameIndex)) return; + + buildWellPipeParts(displayXf, true, flattenedIntersectionExtentLength, branchIndex, frameIndex); + + std::list::iterator it; + for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) + { + if (it->m_surfacePart.notNull()) + { + model->addPart(it->m_surfacePart.p()); + } + + if (it->m_centerLinePart.notNull()) + { + model->addPart(it->m_centerLinePart.p()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivSimWellPipesPartMgr::buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, + bool doFlatten, + double flattenedIntersectionExtentLength, + int branchIndex, + size_t frameIndex) +{ + if (!this->viewWithSettings()) return; + + m_wellBranches.clear(); + m_flattenedBranchWellHeadOffsets.clear(); m_pipeBranchesCLCoords.clear(); std::vector< std::vector > pipeBranchesCellIds; - m_rimWell->calculateWellPipeStaticCenterLine(m_pipeBranchesCLCoords, pipeBranchesCellIds); + m_simWellInView->calculateWellPipeStaticCenterLine(m_pipeBranchesCLCoords, pipeBranchesCellIds); + + double pipeRadius = m_simWellInView->pipeRadius(); + int crossSectionVertexCount = m_simWellInView->pipeCrossSectionVertexCount(); - double pipeRadius = m_rimWell->pipeRadius(); + // Take branch selection into account + size_t branchIdxStart = 0; + size_t branchIdxStop = pipeBranchesCellIds.size(); + if (m_pipeBranchesCLCoords.size() > 1) + { + if (branchIndex >= 0 && branchIndex < static_cast(branchIdxStop)) + { + branchIdxStart = branchIndex; + branchIdxStop = branchIdxStart + 1; + } + } - for (size_t brIdx = 0; brIdx < pipeBranchesCellIds.size(); ++brIdx) + cvf::Vec3d flattenedStartOffset = cvf::Vec3d::ZERO; + if ( m_pipeBranchesCLCoords.size() > branchIdxStart && m_pipeBranchesCLCoords[branchIdxStart].size() ) { - cvf::ref sourceInfo = new RivSimWellPipeSourceInfo(m_rimWell, brIdx); + flattenedStartOffset = { 0.0, 0.0, m_pipeBranchesCLCoords[branchIdxStart][0].z() }; + } + + for (size_t brIdx = branchIdxStart; brIdx sourceInfo = new RivSimWellPipeSourceInfo(m_simWellInView, brIdx); m_wellBranches.push_back(RivPipeBranchData()); RivPipeBranchData& pbd = m_wellBranches.back(); @@ -98,21 +191,35 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator; pbd.m_pipeGeomGenerator->setRadius(pipeRadius); - pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); - pbd.m_pipeGeomGenerator->setPipeColor( m_rimWell->wellPipeColor()); + pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(crossSectionVertexCount); cvf::ref cvfCoords = new cvf::Vec3dArray; cvfCoords->assign(m_pipeBranchesCLCoords[brIdx]); - // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - const RigMainGrid* mainGrid = m_rimReservoirView->mainGrid(); - - for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) + flattenedStartOffset.z() = m_pipeBranchesCLCoords[brIdx][0].z(); + + m_flattenedBranchWellHeadOffsets.push_back(flattenedStartOffset.x()); + + if (doFlatten) + { + std::vector flatningCSs = RivSectionFlattner::calculateFlatteningCSsForPolyline(m_pipeBranchesCLCoords[brIdx], + cvf::Vec3d::Z_AXIS, + flattenedStartOffset, + &flattenedStartOffset); + for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) + { + (*cvfCoords)[cIdx] = ((*cvfCoords)[cIdx]).getTransformedPoint(flatningCSs[cIdx]); + (*cvfCoords)[cIdx] = displayXf->scaleToDisplaySize((*cvfCoords)[cIdx]); + } + } + else { - cvf::Vec4d transfCoord = m_scaleTransform->worldTransform()* cvf::Vec4d((*cvfCoords)[cIdx] - mainGrid->displayModelOffset(), 1); - (*cvfCoords)[cIdx][0] = transfCoord[0]; - (*cvfCoords)[cIdx][1] = transfCoord[1]; - (*cvfCoords)[cIdx][2] = transfCoord[2]; + // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. + + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) + { + (*cvfCoords)[cIdx] = displayXf->transformToDisplayCoord((*cvfCoords)[cIdx]); + } } pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); @@ -121,10 +228,10 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() if (pbd.m_surfaceDrawable.notNull()) { - pbd.m_surfacePart = new cvf::Part; + pbd.m_surfacePart = new cvf::Part(0,"SimWellPipeSurface"); pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWell->wellPipeColor()), caf::PO_1); + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_simWellInView->wellPipeColor()), caf::PO_1); cvf::ref eff = surfaceGen.generateCachedEffect(); pbd.m_surfacePart->setEffect(eff.p()); @@ -134,10 +241,10 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() if (pbd.m_centerLineDrawable.notNull()) { - pbd.m_centerLinePart = new cvf::Part; + pbd.m_centerLinePart = new cvf::Part(0,"SimWellPipeCenterLine"); pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p()); - caf::MeshEffectGenerator gen(m_rimWell->wellPipeColor()); + caf::MeshEffectGenerator gen(m_simWellInView->wellPipeColor()); cvf::ref eff = gen.generateCachedEffect(); pbd.m_centerLinePart->setEffect(eff.p()); @@ -149,56 +256,93 @@ void RivSimWellPipesPartMgr::buildWellPipeParts() pbd.m_pipeGeomGenerator->setRadius(pipeRadius * 1.1); pbd.m_largeSurfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); } - } - m_needsTransformUpdate = false; -} + pbd.m_connectionFactorGeometryGenerator = nullptr; + pbd.m_connectionFactorsPart = nullptr; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivSimWellPipesPartMgr::RivPipeBranchData* RivSimWellPipesPartMgr::pipeBranchData(size_t branchIndex) -{ - if (branchIndex < m_wellBranches.size()) - { - size_t i = 0; + RimEclipseView* eclipseView = nullptr; + m_simWellInView->firstAncestorOrThisOfType(eclipseView); - auto brIt = m_wellBranches.begin(); - while (i < branchIndex) + if (eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible()) { - brIt++; - i++; - } + RigSimWellData* simWellData = m_simWellInView->simWellData(); - return &(*brIt); - } + if (simWellData && simWellData->hasWellResult(frameIndex)) + { + const RigWellResultFrame& wResFrame = simWellData->wellResultFrame(frameIndex); - return nullptr; -} + std::vector completionVizDataItems; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) -{ - if (m_rimReservoirView.isNull()) return; - if (m_rimWell.isNull()) return; - if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + RimVirtualPerforationResults* virtualPerforationResult = eclipseView->virtualPerforationResult(); + { + auto wellPaths = m_simWellInView->wellPipeBranches(); - if (m_needsTransformUpdate) buildWellPipeParts(); + const RigWellPath* wellPath = wellPaths[brIdx]; - std::list::iterator it; - for (it = m_wellBranches.begin(); it != m_wellBranches.end(); ++it) - { - if (it->m_surfacePart.notNull()) - { - model->addPart(it->m_surfacePart.p()); - } + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::findOrCreateSimWellExtractor(m_simWellInView, wellPath); + if (extractor) + { + std::vector wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); - if (it->m_centerLinePart.notNull()) - { - model->addPart(it->m_centerLinePart.p()); + for (const auto& intersectionInfo : wellPathCellIntersections) + { + size_t globalCellIndex = intersectionInfo.globCellIndex; + const RigWellResultPoint* wResCell = wResFrame.findResultCell(0, globalCellIndex); + + if (!wResCell || !wResCell->isValid()) + { + continue; + } + + if (!virtualPerforationResult->showConnectionFactorsOnClosedConnections() && !wResCell->m_isOpen) + { + continue; + } + + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; + + double middleMD = (startMD + endMD) / 2.0; + + cvf::Vec3d domainCoord = wellPath->interpolatedPointAlongWellPath(middleMD); + + cvf::Vec3d p1; + cvf::Vec3d p2; + wellPath->twoClosestPoints(domainCoord, &p1, &p2); + + cvf::Vec3d direction = (p2 - p1).getNormalized(); + + cvf::Vec3d anchor = displayXf->transformToDisplayCoord(domainCoord); + { + CompletionVizData data(anchor, direction, wResCell->connectionFactor(), globalCellIndex); + + completionVizDataItems.push_back(data); + } + } + } + } + + if (!completionVizDataItems.empty()) + { + double radius = pipeRadius * virtualPerforationResult->geometryScaleFactor(); + radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry scale factor is set to 1.0 + + pbd.m_connectionFactorGeometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); + + cvf::ScalarMapper* scalarMapper = virtualPerforationResult->legendConfig()->scalarMapper(); + cvf::ref part = pbd.m_connectionFactorGeometryGenerator->createSurfacePart(scalarMapper, eclipseView->isLightingDisabled()); + if (part.notNull()) + { + cvf::ref sourceInfo = new RivSimWellConnectionSourceInfo(m_simWellInView, pbd.m_connectionFactorGeometryGenerator.p()); + part->setSourceInfo(sourceInfo.p()); + } + + pbd.m_connectionFactorsPart = part; + } + } } + + if (doFlatten) flattenedStartOffset += { 2*flattenedIntersectionExtentLength, 0.0, 0.0}; } } @@ -207,37 +351,40 @@ void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicLi //-------------------------------------------------------------------------------------------------- void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) { - if (m_rimWell == NULL) return; + if (m_simWellInView == nullptr) return; - RigSimWellData* simWellData = m_rimWell->simWellData(); - if (simWellData == NULL) return; + RigSimWellData* simWellData = m_simWellInView->simWellData(); + if (simWellData == nullptr) return; if (!simWellData->hasWellResult(frameIndex)) return; // Or reset colors or something - const double closed = -0.1, producing = 1.5, water = 2.5, hcInjection = 3.5; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper. + const double defaultState = -0.1; // Closed set to -0.1 instead of 0.5 to workaround bug in the scalar mapper. + const double producerState = 1.5; + const double waterInjectorState = 2.5; + const double hcInjectorState = 3.5; + const double closedState = 4.5; - std::list::iterator brIt; const RigWellResultFrame& wResFrame = simWellData->wellResultFrame(frameIndex); - std::vector wellCellStates; // Setup a scalar mapper cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; { cvf::Color3ubArray legendColors; - legendColors.resize(4); - legendColors[0] = cvf::Color3ub(m_rimWell->wellPipeColor()); + legendColors.resize(5); + legendColors[0] = cvf::Color3ub(m_simWellInView->wellPipeColor()); legendColors[1] = cvf::Color3::GREEN; legendColors[2] = cvf::Color3::BLUE; legendColors[3] = cvf::Color3::RED; + legendColors[4] = cvf::Color3ub(RiaColorTables::undefinedCellColor()); scalarMapper->setColors(legendColors); - scalarMapper->setRange(0.0, 4.0); - scalarMapper->setLevelCount(4, true); + scalarMapper->setRange(0.0, 5.0); + scalarMapper->setLevelCount(5, true); } caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); - if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + if (viewWithSettings() && viewWithSettings()->isLightingDisabled()) { surfEffGen.disableLighting(true); } @@ -247,60 +394,59 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p()); cvf::ref scalarMapperMeshEffect = meshEffGen.generateUnCachedEffect(); - for (brIt = m_wellBranches.begin(); brIt != m_wellBranches.end(); ++brIt) + for (auto& wellBranch : m_wellBranches) { - // Initialize well states to "closed" state - wellCellStates.clear(); - wellCellStates.resize(brIt->m_cellIds.size(), closed); + std::vector wellCellStates; + wellCellStates.resize(wellBranch.m_cellIds.size(), defaultState); RimSimWellInViewCollection* wellColl = nullptr; - if (m_rimWell) + if (m_simWellInView) { - m_rimWell->firstAncestorOrThisOfType(wellColl); + m_simWellInView->firstAncestorOrThisOfType(wellColl); } if (wellColl && wellColl->showConnectionStatusColors()) { - const std::vector & cellIds = brIt->m_cellIds; + const std::vector & cellIds = wellBranch.m_cellIds; for (size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx) { // we need a faster lookup, I guess - const RigWellResultPoint* wResCell = NULL; + const RigWellResultPoint* wResCell = nullptr; if (cellIds[wcIdx].isCell()) { wResCell = wResFrame.findResultCell(cellIds[wcIdx].m_gridIndex, cellIds[wcIdx].m_gridCellIndex); } - if (wResCell == NULL) - { - // We cant find any state. This well cell is closed. - } - else + if (wResCell) { - double cellState = closed; + double cellState = defaultState; if (wResCell->m_isOpen) { switch (wResFrame.m_productionType) { case RigWellResultFrame::PRODUCER: - cellState = producing; + cellState = producerState; break; case RigWellResultFrame::OIL_INJECTOR: - cellState = hcInjection; + cellState = hcInjectorState; break; case RigWellResultFrame::GAS_INJECTOR: - cellState = hcInjection; + cellState = hcInjectorState; break; case RigWellResultFrame::WATER_INJECTOR: - cellState = water; + cellState = waterInjectorState; break; case RigWellResultFrame::UNDEFINED_PRODUCTION_TYPE: - cellState = closed; + cellState = defaultState; break; } } + else + { + cellState = closedState; + } wellCellStates[wcIdx] = cellState; } @@ -309,37 +455,37 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) // Find or create texture coords array for pipe surface - if (brIt->m_surfaceDrawable.notNull()) + if (wellBranch.m_surfaceDrawable.notNull()) { - cvf::ref surfTexCoords = const_cast(brIt->m_surfaceDrawable->textureCoordArray()); + cvf::ref surfTexCoords = const_cast(wellBranch.m_surfaceDrawable->textureCoordArray()); if (surfTexCoords.isNull()) { surfTexCoords = new cvf::Vec2fArray; } - brIt->m_pipeGeomGenerator->pipeSurfaceTextureCoords(surfTexCoords.p(), wellCellStates, scalarMapper.p()); + wellBranch.m_pipeGeomGenerator->pipeSurfaceTextureCoords(surfTexCoords.p(), wellCellStates, scalarMapper.p()); - brIt->m_surfaceDrawable->setTextureCoordArray(surfTexCoords.p()); - brIt->m_largeSurfaceDrawable->setTextureCoordArray(surfTexCoords.p()); + wellBranch.m_surfaceDrawable->setTextureCoordArray(surfTexCoords.p()); + wellBranch.m_largeSurfaceDrawable->setTextureCoordArray(surfTexCoords.p()); if (wResFrame.m_isOpen) { // Use slightly larger geometry for open wells to avoid z-fighting when two wells are located at the same position - brIt->m_surfacePart->setDrawable(brIt->m_largeSurfaceDrawable.p()); + wellBranch.m_surfacePart->setDrawable(wellBranch.m_largeSurfaceDrawable.p()); } else { - brIt->m_surfacePart->setDrawable(brIt->m_surfaceDrawable.p()); + wellBranch.m_surfacePart->setDrawable(wellBranch.m_surfaceDrawable.p()); } - brIt->m_surfacePart->setEffect(scalarMapperSurfaceEffect.p()); + wellBranch.m_surfacePart->setEffect(scalarMapperSurfaceEffect.p()); } // Find or create texture coords array for pipe center line - if (brIt->m_centerLineDrawable.notNull()) + if (wellBranch.m_centerLineDrawable.notNull()) { - cvf::ref lineTexCoords = const_cast(brIt->m_centerLineDrawable->textureCoordArray()); + cvf::ref lineTexCoords = const_cast(wellBranch.m_centerLineDrawable->textureCoordArray()); if (lineTexCoords.isNull()) { @@ -347,16 +493,24 @@ void RivSimWellPipesPartMgr::updatePipeResultColor(size_t frameIndex) } // Calculate new texture coordinates - brIt->m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, scalarMapper.p()); + wellBranch.m_pipeGeomGenerator->centerlineTextureCoords( lineTexCoords.p(), wellCellStates, scalarMapper.p()); // Set the new texture coordinates - brIt->m_centerLineDrawable->setTextureCoordArray( lineTexCoords.p()); + wellBranch.m_centerLineDrawable->setTextureCoordArray( lineTexCoords.p()); // Set effects - brIt->m_centerLinePart->setEffect(scalarMapperMeshEffect.p()); + wellBranch.m_centerLinePart->setEffect(scalarMapperMeshEffect.p()); } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RivSimWellPipesPartMgr::flattenedBranchWellHeadOffsets() +{ + return m_flattenedBranchWellHeadOffsets; +} + diff --git a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h index 8917981163..fbe1a485a1 100644 --- a/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivSimWellPipesPartMgr.h @@ -32,42 +32,53 @@ namespace cvf { class Part; class ModelBasicList; - class Transform; - class Effect; class DrawableGeo; } +namespace caf +{ + class DisplayCoordTransform; +} + class RivPipeGeometryGenerator; -class RimEclipseView; +class Rim3dView; class RimSimWellInView; +class RivWellConnectionFactorGeometryGenerator; class RivSimWellPipesPartMgr : public cvf::Object { public: - RivSimWellPipesPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well); - ~RivSimWellPipesPartMgr(); - - void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform; scheduleGeometryRegen();} + RivSimWellPipesPartMgr(RimSimWellInView* well); - void scheduleGeometryRegen() { m_needsTransformUpdate = true; } + ~RivSimWellPipesPartMgr(); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); - void updatePipeResultColor(size_t frameIndex); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf); + + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform* displayXf, + double flattenedIntersectionExtentLength, + int branchIndex); + + void updatePipeResultColor(size_t frameIndex); - const std::vector< std::vector >& centerLineOfWellBranches() { return m_pipeBranchesCLCoords;} + std::vector flattenedBranchWellHeadOffsets(); private: - caf::PdmPointer m_rimReservoirView; - caf::PdmPointer m_rimWell; - - cvf::ref m_scaleTransform; - bool m_needsTransformUpdate; + Rim3dView* viewWithSettings(); + void buildWellPipeParts(const caf::DisplayCoordTransform* displayXf, + bool doFlatten, + double flattenedIntersectionExtentLength, + int branchIndex, + size_t frameIndex); - void buildWellPipeParts(); + caf::PdmPointer m_simWellInView; struct RivPipeBranchData { - std::vector m_cellIds; + std::vector m_cellIds; cvf::ref m_pipeGeomGenerator; cvf::ref m_surfacePart; @@ -76,11 +87,12 @@ class RivSimWellPipesPartMgr : public cvf::Object cvf::ref m_centerLinePart; cvf::ref m_centerLineDrawable; + cvf::ref m_connectionFactorGeometryGenerator; + cvf::ref m_connectionFactorsPart; }; - RivPipeBranchData* pipeBranchData(size_t branchIndex); - - std::list m_wellBranches; + std::list m_wellBranches; std::vector< std::vector > m_pipeBranchesCLCoords; + std::vector m_flattenedBranchWellHeadOffsets; }; diff --git a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp index 5819cbfa89..96039adb24 100644 --- a/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivSingleCellPartGenerator.cpp @@ -42,7 +42,7 @@ RivSingleCellPartGenerator::RivSingleCellPartGenerator(RigEclipseCaseData* rigCa : m_rigCaseData(rigCaseData), m_gridIndex(gridIndex), m_cellIndex(cellIndex), - m_geoMechCase(NULL) + m_geoMechCase(nullptr) { } @@ -53,7 +53,7 @@ RivSingleCellPartGenerator::RivSingleCellPartGenerator(RimGeoMechCase* rimGeoMec : m_geoMechCase(rimGeoMechCase), m_gridIndex(gridIndex), m_cellIndex(cellIndex), - m_rigCaseData(NULL) + m_rigCaseData(nullptr) { } @@ -101,5 +101,5 @@ cvf::ref RivSingleCellPartGenerator::createMeshDrawable() return RivFemPartGeometryGenerator::createMeshDrawableFromSingleElement(femPart, m_cellIndex); } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp new file mode 100644 index 0000000000..bd301d520c --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.cpp @@ -0,0 +1,589 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivTensorResultPartMgr.h" + +#include "RiaColorTables.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechView.h" +#include "RimRegularLegendConfig.h" +#include "RimTensorResults.h" + +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" +#include "RigFemPartResultsCollection.h" +#include "RigFemResultAddress.h" +#include "RigFemTypes.h" +#include "RigGeoMechCaseData.h" + +#include "RivFemPartGeometryGenerator.h" +#include "RivGeoMechPartMgr.h" +#include "RivGeoMechPartMgrCache.h" +#include "RivGeoMechVizLogic.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" +#include "cafTensor3.h" + +#include "cvfDrawableGeo.h" +#include "cvfModelBasicList.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfPart.h" +#include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfScalarMapperDiscreteLinear.h" +#include "cvfShaderProgram.h" +#include "cvfStructGridGeometryGenerator.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivTensorResultPartMgr::RivTensorResultPartMgr(RimGeoMechView* reservoirView) +{ + m_rimReservoirView = reservoirView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivTensorResultPartMgr::~RivTensorResultPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) const +{ + CVF_ASSERT(model); + + if (m_rimReservoirView.isNull()) return; + if (!m_rimReservoirView->geoMechCase()) return; + if (!m_rimReservoirView->geoMechCase()->geoMechData()) return; + + if (!m_rimReservoirView->tensorResults()->showTensors()) return; + + RigFemPartCollection* femParts = m_rimReservoirView->femParts(); + if (!femParts) return; + + std::vector tensorVisualizations; + + RigFemResultAddress address = m_rimReservoirView->tensorResults()->selectedTensorResult(); + if (!isTensorAddress(address)) return; + + RigFemPartResultsCollection* resultCollection = m_rimReservoirView->geoMechCase()->geoMechData()->femPartResults(); + if (!resultCollection) return; + + for (int partIdx = 0; partIdx < femParts->partCount(); partIdx++) + { + std::vector vertexTensors = resultCollection->tensors(address, partIdx, (int)frameIndex); + + const RigFemPart* part = femParts->part(partIdx); + std::vector elmTensors; + + calculateElementTensors(*part, vertexTensors, &elmTensors); + + std::array, 3> elmPrincipals; + std::vector> elmPrincipalDirections; + + calculatePrincipalsAndDirections(elmTensors, &elmPrincipals, &elmPrincipalDirections); + + std::vector partKeys = + m_rimReservoirView->vizLogic()->keysToVisiblePartMgrs((int)frameIndex); + + RigFemPartNodes nodes = part->nodes(); + + float arrowConstantScaling = 0.5 * m_rimReservoirView->tensorResults()->sizeScale() * part->characteristicElementSize(); + + double min, max; + m_rimReservoirView->tensorResults()->mappingRange(&min, &max); + + double maxAbsResult = 1.0; + if (min != cvf::UNDEFINED_DOUBLE && max != cvf::UNDEFINED_DOUBLE) + { + maxAbsResult = std::max(cvf::Math::abs(max), cvf::Math::abs(min)); + } + + float arrowResultScaling = arrowConstantScaling / maxAbsResult; + + cvf::ref partMgrCache = m_rimReservoirView->vizLogic()->partMgrCache(); + + for (const RivGeoMechPartMgrCache::Key& partKey : partKeys) + { + const RivGeoMechPartMgr* partMgr = partMgrCache->partMgr(partKey); + for (auto mgr : partMgr->femPartMgrs()) + { + const RivFemPartGeometryGenerator* surfaceGenerator = mgr->surfaceGenerator(); + const std::vector& quadVerticesToNodeIdxMapping = surfaceGenerator->quadVerticesToNodeIdxMapping(); + const std::vector& quadVerticesToElmIdx = surfaceGenerator->quadVerticesToGlobalElmIdx(); + + for (int quadVertex = 0; quadVertex < static_cast(quadVerticesToNodeIdxMapping.size()); quadVertex += 4) + { + cvf::Vec3f center = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex]) + + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 2]); + + cvf::Vec3d displayCoord = + m_rimReservoirView->displayCoordTransform()->transformToDisplayCoord(cvf::Vec3d(center / 2)); + + cvf::Vec3f faceNormal = calculateFaceNormal(nodes, quadVerticesToNodeIdxMapping, quadVertex); + + size_t elmIdx = quadVerticesToElmIdx[quadVertex]; + + cvf::Vec3f result1, result2, result3; + + if (m_rimReservoirView->tensorResults()->scaleMethod() == RimTensorResults::RESULT) + { + result1.set(elmPrincipalDirections[elmIdx][0] * arrowResultScaling * elmPrincipals[0][elmIdx]); + result2.set(elmPrincipalDirections[elmIdx][1] * arrowResultScaling * elmPrincipals[1][elmIdx]); + result3.set(elmPrincipalDirections[elmIdx][2] * arrowResultScaling * elmPrincipals[2][elmIdx]); + } + else + { + result1.set(elmPrincipalDirections[elmIdx][0] * arrowConstantScaling); + result2.set(elmPrincipalDirections[elmIdx][1] * arrowConstantScaling); + result3.set(elmPrincipalDirections[elmIdx][2] * arrowConstantScaling); + } + + if (isDrawable(result1, m_rimReservoirView->tensorResults()->showPrincipal1())) + { + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1, elmPrincipals[0][elmIdx])); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result1, faceNormal, isPressure(elmPrincipals[0][elmIdx]), 1, elmPrincipals[0][elmIdx])); + } + + if (isDrawable(result2, m_rimReservoirView->tensorResults()->showPrincipal2())) + { + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2, elmPrincipals[1][elmIdx])); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result2, faceNormal, isPressure(elmPrincipals[1][elmIdx]), 2, elmPrincipals[1][elmIdx])); + } + + if (isDrawable(result3, m_rimReservoirView->tensorResults()->showPrincipal3())) + { + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3, elmPrincipals[2][elmIdx])); + tensorVisualizations.push_back(TensorVisualization( + cvf::Vec3f(displayCoord), -result3, faceNormal, isPressure(elmPrincipals[2][elmIdx]), 3, elmPrincipals[2][elmIdx])); + } + } + } + } + } + + if (!tensorVisualizations.empty()) + { + cvf::ref partIdx = createPart(tensorVisualizations); + model->addPart(partIdx.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::calculateElementTensors(const RigFemPart& part, + const std::vector& vertexTensors, + std::vector* elmTensors) +{ + CVF_ASSERT(elmTensors); + + size_t elmCount = part.elementCount(); + elmTensors->resize(elmCount); + + for (int elmIdx = 0; elmIdx < static_cast(elmCount); elmIdx++) + { + if (RigFemTypes::elmentNodeCount(part.elementType(elmIdx)) == 8) + { + caf::Ten3f tensorSumOfElmNodes = vertexTensors[part.elementNodeResultIdx(elmIdx, 0)]; + for (int i = 1; i < 8; i++) + { + tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[part.elementNodeResultIdx(elmIdx, i)]; + } + + (*elmTensors)[elmIdx] = tensorSumOfElmNodes * (1.0 / 8.0); + } + } + + std::array, 3> elmPrincipals; + std::vector> elmPrincipalDirections; + + elmPrincipals[0].resize(elmCount); + elmPrincipals[1].resize(elmCount); + elmPrincipals[2].resize(elmCount); + + elmPrincipalDirections.resize(elmCount); + + for (size_t nIdx = 0; nIdx < elmCount; ++nIdx) + { + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principalValues = (*elmTensors)[nIdx].calculatePrincipals(principalDirs); + + elmPrincipals[0][nIdx] = principalValues[0]; + elmPrincipals[1][nIdx] = principalValues[1]; + elmPrincipals[2][nIdx] = principalValues[2]; + + elmPrincipalDirections[nIdx][0] = principalDirs[0]; + elmPrincipalDirections[nIdx][1] = principalDirs[1]; + elmPrincipalDirections[nIdx][2] = principalDirs[2]; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::calculatePrincipalsAndDirections(const std::vector& tensors, + std::array, 3>* principals, + std::vector>* principalDirections) +{ + CVF_ASSERT(principals); + CVF_ASSERT(principalDirections); + + size_t elmCount = tensors.size(); + + (*principals)[0].resize(elmCount); + (*principals)[1].resize(elmCount); + (*principals)[2].resize(elmCount); + + (*principalDirections).resize(elmCount); + + for (size_t nIdx = 0; nIdx < elmCount; ++nIdx) + { + cvf::Vec3f principalDirs[3]; + cvf::Vec3f principalValues = tensors[nIdx].calculatePrincipals(principalDirs); + + (*principals)[0][nIdx] = principalValues[0]; + (*principals)[1][nIdx] = principalValues[1]; + (*principals)[2][nIdx] = principalValues[2]; + + (*principalDirections)[nIdx][0] = principalDirs[0]; + (*principalDirections)[nIdx][1] = principalDirs[1]; + (*principalDirections)[nIdx][2] = principalDirs[2]; + } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3f RivTensorResultPartMgr::calculateFaceNormal(const RigFemPartNodes& nodes, + const std::vector& quadVerticesToNodeIdxMapping, + int quadVertex) +{ + cvf::Vec3f diag1 = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex]) - + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 2]); + + cvf::Vec3f diag2 = nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 1]) - + nodes.coordinates.at(quadVerticesToNodeIdxMapping[quadVertex + 3]); + + return (diag1 ^ diag2).getNormalized(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivTensorResultPartMgr::createPart(const std::vector& tensorVisualizations) const +{ + std::vector indices; + indices.reserve(tensorVisualizations.size() * 5); + + std::vector vertices; + vertices.reserve(tensorVisualizations.size() * 5); + + uint counter = 0; + for (TensorVisualization tensor : tensorVisualizations) + { + for (const cvf::Vec3f& vertex : createArrowVertices(tensor)) + { + vertices.push_back(vertex); + } + + for (const uint& index : createArrowIndices(counter)) + { + indices.push_back(index); + } + + counter += 5; + } + + cvf::ref indexedUInt = new cvf::PrimitiveSetIndexedUInt(cvf::PrimitiveType::PT_LINES); + cvf::ref indexArray = new cvf::UIntArray(indices); + + cvf::ref drawable = new cvf::DrawableGeo(); + + indexedUInt->setIndices(indexArray.p()); + drawable->addPrimitiveSet(indexedUInt.p()); + + cvf::ref vertexArray = new cvf::Vec3fArray(vertices); + drawable->setVertexArray(vertexArray.p()); + + cvf::ref lineTexCoords = const_cast(drawable->textureCoordArray()); + + if (lineTexCoords.isNull()) + { + lineTexCoords = new cvf::Vec2fArray; + } + + cvf::ScalarMapper* activeScalerMapper = nullptr; + + cvf::ref discreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; + auto vectorColors = m_rimReservoirView->tensorResults()->vectorColors(); + if (vectorColors == RimTensorResults::RESULT_COLORS) + { + activeScalerMapper = m_rimReservoirView->tensorResults()->arrowColorLegendConfig()->scalarMapper(); + + createResultColorTextureCoords(lineTexCoords.p(), tensorVisualizations, activeScalerMapper); + } + else + { + activeScalerMapper = discreteScalarMapper.p(); + + createOneColorPerPrincipalScalarMapper(vectorColors, discreteScalarMapper.p()); + createOneColorPerPrincipalTextureCoords(lineTexCoords.p(), tensorVisualizations, discreteScalarMapper.p()); + } + + caf::ScalarMapperEffectGenerator surfEffGen(activeScalerMapper, caf::PO_1); + + if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + { + surfEffGen.disableLighting(true); + } + + caf::ScalarMapperMeshEffectGenerator meshEffGen(activeScalerMapper); + cvf::ref scalarMapperMeshEffect = meshEffGen.generateUnCachedEffect(); + + drawable->setTextureCoordArray(lineTexCoords.p()); + + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + part->setEffect(scalarMapperMeshEffect.p()); + + return part; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::createOneColorPerPrincipalScalarMapper(const RimTensorResults::TensorColors& colorSet, + cvf::ScalarMapperDiscreteLinear* scalarMapper) +{ + CVF_ASSERT(scalarMapper); + + cvf::Color3ubArray arrowColors; + arrowColors.resize(3); + + if (colorSet == RimTensorResults::WHITE_GRAY_BLACK) + { + arrowColors = RiaColorTables::tensorWhiteGrayBlackPaletteColors().color3ubArray(); + } + else if (colorSet == RimTensorResults::ORANGE_BLUE_WHITE) + { + arrowColors = RiaColorTables::tensorOrangeBlueWhitePaletteColors().color3ubArray(); + } + else if (colorSet == RimTensorResults::MAGENTA_BROWN_GRAY) + { + arrowColors = RiaColorTables::tensorsMagentaBrownGrayPaletteColors().color3ubArray(); + } + + scalarMapper->setColors(arrowColors); + + // Using a linear color mapper to set colors for three discrete principal numbers (1, 2, 3) + // by setting the 3 + 1 interval levels so the principal numbers match the center of the intervals. + std::set levelValues = { 0.5, 1.5, 2.5, 3.5 }; + scalarMapper->setLevelsFromValues(levelValues); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::createOneColorPerPrincipalTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper) +{ + CVF_ASSERT(textureCoords); + CVF_ASSERT(mapper); + + size_t vertexCount = tensorVisualizations.size() * 5; + if (textureCoords->size() != vertexCount) textureCoords->reserve(vertexCount); + + for (auto tensor : tensorVisualizations) + { + for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) + { + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.principalNumber); + textureCoords->add(texCoord); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivTensorResultPartMgr::createResultColorTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper) +{ + CVF_ASSERT(textureCoords); + CVF_ASSERT(mapper); + + size_t vertexCount = tensorVisualizations.size() * 5; + if (textureCoords->size() != vertexCount) textureCoords->reserve(vertexCount); + + for (auto tensor : tensorVisualizations) + { + for (size_t vxIdx = 0; vxIdx < 5; ++vxIdx) + { + cvf::Vec2f texCoord = mapper->mapToTextureCoord(tensor.principalValue); + textureCoords->add(texCoord); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivTensorResultPartMgr::isTensorAddress(RigFemResultAddress address) +{ + if (!(address.resultPosType == RIG_ELEMENT_NODAL || address.resultPosType == RIG_INTEGRATION_POINT)) + { + return false; + } + if (!(address.fieldName == "SE" || address.fieldName == "ST" || address.fieldName == "NE")) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivTensorResultPartMgr::isValid(cvf::Vec3f resultVector) +{ + // nan + if (resultVector.x() != resultVector.x() || resultVector.y() != resultVector.y() || resultVector.z() != resultVector.z()) + { + return false; + } + + // inf + if (resultVector.x() == HUGE_VAL || resultVector.y() == HUGE_VAL || resultVector.z() == HUGE_VAL || + resultVector.x() == -HUGE_VAL || resultVector.y() == -HUGE_VAL || resultVector.z() == -HUGE_VAL) + { + return false; + } + + // zero + if (resultVector == cvf::Vec3f::ZERO) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivTensorResultPartMgr::isPressure(float principalValue) +{ + if (principalValue >= 0) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivTensorResultPartMgr::isDrawable(cvf::Vec3f resultVector, bool showPrincipal) const +{ + if (!showPrincipal) + { + return false; + } + + if (!isValid(resultVector)) + { + return false; + } + + if (resultVector.length() <= m_rimReservoirView->tensorResults()->threshold()) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RivTensorResultPartMgr::createArrowVertices(const TensorVisualization& tensorVisualization) const +{ + std::array vertices; + + cvf::Vec3f headTop; + cvf::Vec3f shaftStart; + + if (tensorVisualization.isPressure) + { + headTop = tensorVisualization.vertex; + shaftStart = tensorVisualization.vertex + tensorVisualization.result; + } + else + { + headTop = tensorVisualization.vertex + tensorVisualization.result; + shaftStart = tensorVisualization.vertex; + } + + float headWidth = 0.05 * tensorVisualization.result.length(); + + cvf::Vec3f headBottom = headTop - (headTop - shaftStart) * 0.2f; + + cvf::Vec3f headBottomDirection = tensorVisualization.result ^ tensorVisualization.faceNormal; + cvf::Vec3f arrowBottomSegment = headBottomDirection.getNormalized() * headWidth; + + vertices[0] = shaftStart; + vertices[1] = headBottom; + vertices[2] = headBottom + arrowBottomSegment; + vertices[3] = headBottom - arrowBottomSegment; + vertices[4] = headTop; + + return vertices; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RivTensorResultPartMgr::createArrowIndices(uint startIndex) const +{ + std::array indices; + + indices[0] = startIndex; + indices[1] = startIndex + 1; + indices[2] = startIndex + 2; + indices[3] = startIndex + 3; + indices[4] = startIndex + 3; + indices[5] = startIndex + 4; + indices[6] = startIndex + 4; + indices[7] = startIndex + 2; + + return indices; +} diff --git a/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h new file mode 100644 index 0000000000..7418de6441 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivTensorResultPartMgr.h @@ -0,0 +1,109 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfArray.h" +#include "cvfColor3.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "cafPdmPointer.h" +#include "cafTensor3.h" + +#include "RimTensorResults.h" + +#include +#include + +namespace cvf +{ +class ModelBasicList; +class Part; +class ScalarMapper; +class ScalarMapperDiscreteLinear; +} // namespace cvf + +class RigFemResultAddress; +class RimGeoMechView; +class RigFemPartNodes; +class RigFemPart; + +class RivTensorResultPartMgr : public cvf::Object +{ +public: + RivTensorResultPartMgr(RimGeoMechView* reservoirView); + ~RivTensorResultPartMgr(); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) const; + +private: + struct TensorVisualization + { + TensorVisualization(cvf::Vec3f vertex, cvf::Vec3f result, cvf::Vec3f faceNormal, bool isPressure, int princial, float principalValue) + : vertex(vertex) + , result(result) + , faceNormal(faceNormal) + , isPressure(isPressure) + , principalNumber(princial) + , principalValue(principalValue) {}; + + cvf::Vec3f vertex; + cvf::Vec3f result; + cvf::Vec3f faceNormal; + bool isPressure; + int principalNumber; + float principalValue; + }; + +private: + static void calculateElementTensors(const RigFemPart& part, + const std::vector& vertexTensors, + std::vector* elmTensors); + + static void calculatePrincipalsAndDirections(const std::vector& tensors, + std::array, 3>* principals, + std::vector>* principalDirections); + + static cvf::Vec3f calculateFaceNormal(const RigFemPartNodes& nodes, + const std::vector& quadVerticesToNodeIdxMapping, + int quadVertex); + + cvf::ref createPart(const std::vector& tensorVisualizations) const; + + static void createOneColorPerPrincipalScalarMapper(const RimTensorResults::TensorColors& colorSet, cvf::ScalarMapperDiscreteLinear* scalarMapper); + static void createOneColorPerPrincipalTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper); + + static void createResultColorTextureCoords(cvf::Vec2fArray* textureCoords, + const std::vector& tensorVisualizations, + const cvf::ScalarMapper* mapper); + + static bool isTensorAddress(RigFemResultAddress address); + static bool isValid(cvf::Vec3f resultVector); + static bool isPressure(float principalValue); + bool isDrawable(cvf::Vec3f resultVector, bool showPrincipal) const; + + std::array createArrowVertices(const TensorVisualization &tensorVisualization) const; + std::array createArrowIndices(uint startIndex) const; + +private: + caf::PdmPointer m_rimReservoirView; +}; diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp index b01401826f..c057098303 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.cpp @@ -33,6 +33,7 @@ #include "cvfRenderState_FF.h" #include "cvfRenderStateDepth.h" #include "cvfRenderStatePolygonOffset.h" +#include "cafInternalLegendRenderTools.h" @@ -40,13 +41,11 @@ /// //-------------------------------------------------------------------------------------------------- RivTernarySaturationOverlayItem::RivTernarySaturationOverlayItem(cvf::Font* font) - : m_textColor(cvf::Color3::BLACK), - m_font(font), - m_size(100, 140) + : TitledOverlayFrame(font, 120, 150) { + } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -55,115 +54,121 @@ RivTernarySaturationOverlayItem::~RivTernarySaturationOverlayItem() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } - - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::setAxisLabelsColor(const cvf::Color3f& color) { - m_textColor = color; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec2ui RivTernarySaturationOverlayItem::sizeHint() -{ - return m_size; -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::setSize(const cvf::Vec2ui& size) -{ - m_size = size; + this->setTextColor(color); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) { - render(oglContext, position, size, false); + renderGeneric(oglContext, position, size, false); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RivTernarySaturationOverlayItem::renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) { - render(oglContext, position, size, true); + renderGeneric(oglContext, position, size, true); } - //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software) +void RivTernarySaturationOverlayItem::renderGeneric(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size, + bool software) { if (size.x() <= 0 || size.y() <= 0) { return; } + float border = 0.0f; + + cvf::Vec2ui sizeFrameBox = size; + cvf::Camera camera; - camera.setViewport(position.x(), position.y(), size.x(), size.y()); + camera.setViewport(position.x(), position.y(), sizeFrameBox.x(), sizeFrameBox.y()); camera.setProjectionAsPixelExact2D(); camera.setViewMatrix(cvf::Mat4d::IDENTITY); camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, cvf::Viewport::CLEAR_DEPTH); - cvf::TextDrawer textDrawer(m_font.p()); - textDrawer.setTextColor(m_textColor); + if ( this->backgroundEnabled() ) + { + if ( software ) + { + caf::InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + cvf::Vec2f(sizeFrameBox), + this->backgroundColor(), + this->backgroundFrameColor()); + } + else + { + const cvf::MatrixState matrixState(camera); + + caf::InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + matrixState, + cvf::Vec2f(sizeFrameBox), + this->backgroundColor(), + this->backgroundFrameColor()); + } + border = 8.0f; + } + + cvf::TextDrawer textDrawer(this->font()); + textDrawer.setTextColor(this->textColor()); - float lineHeightInPixels = 10; + float lineHeightInPixels = (float)(this->font()->textExtent("SWAT").y() + 2); - float textPosY = static_cast(size.y() - 10); - for (size_t it = 0; it < m_titleStrings.size(); it++) + float textPosY = static_cast(size.y() - lineHeightInPixels - border); + for (size_t it = 0; it < this->titleStrings().size(); it++) { - cvf::Vec2f pos(5, textPosY); - textDrawer.addText(m_titleStrings[it], pos); + cvf::Vec2f pos(border, textPosY); + textDrawer.addText(this->titleStrings()[it], pos); textPosY -= lineHeightInPixels; } - cvf::Vec2f pos(5, textPosY); + cvf::Vec2f pos(border, textPosY); textDrawer.addText("TERNARY", pos); textPosY -= lineHeightInPixels; - textPosY -= 2; + textPosY -= border; { - cvf::uint sgasTextWidth = m_font->textExtent("SGAS").x(); + cvf::uint sgasTextWidth = this->font()->textExtent("SGAS").x(); textDrawer.addText("SGAS", cvf::Vec2f(static_cast( (size.x() / 2) - sgasTextWidth / 2 ), textPosY)); - cvf::uint sgasRangeTextWidth = m_font->textExtent(m_sgasRange).x(); + cvf::uint sgasRangeTextWidth = this->font()->textExtent(m_sgasRange).x(); textPosY -= lineHeightInPixels; textDrawer.addText(m_sgasRange, cvf::Vec2f(static_cast( (size.x() / 2) - sgasRangeTextWidth / 2 ), textPosY)); } - textDrawer.addText("SWAT", cvf::Vec2f(0.0, 10.0)); - textDrawer.addText(m_swatRange, cvf::Vec2f(0.0, 0.0)); + textDrawer.addText("SWAT", cvf::Vec2f((float)border, (float)(lineHeightInPixels + border))); + textDrawer.addText(m_swatRange, cvf::Vec2f((float)border, (float)border)); { - cvf::uint soilTextWidth = m_font->textExtent("SOIL").x(); - textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth), 10.0)); + cvf::uint soilTextWidth = this->font()->textExtent("SOIL").x(); + textDrawer.addText("SOIL", cvf::Vec2f(static_cast(size.x() - soilTextWidth - border), lineHeightInPixels + border)); - cvf::uint soilRangeTextWidth = m_font->textExtent(m_soilRange).x(); - float soilRangePos = static_cast(size.x()) - soilRangeTextWidth; + cvf::uint soilRangeTextWidth = this->font()->textExtent(m_soilRange).x(); + float soilRangePos = static_cast(size.x()) - soilRangeTextWidth - border; - textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, 0.0)); + textDrawer.addText(m_soilRange, cvf::Vec2f(soilRangePos, (float)border)); } textDrawer.renderSoftware(oglContext, camera); textPosY -= 3; - renderAxisImmediateMode(textPosY, oglContext); + renderAxisImmediateMode(textPosY, 2*lineHeightInPixels + border, border, sizeFrameBox.x(), oglContext); CVF_CHECK_OGL(oglContext); } @@ -173,7 +178,11 @@ void RivTernarySaturationOverlayItem::render(cvf::OpenGLContext* oglContext, con //-------------------------------------------------------------------------------------------------- /// Draw the axis using immediate mode OpenGL //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, cvf::OpenGLContext* oglContext) +void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, + float lowerBoundY, + float border, + unsigned int totalWidth, + cvf::OpenGLContext* oglContext) { #ifdef CVF_OPENGL_ES CVF_UNUSED(layout); @@ -190,12 +199,11 @@ void RivTernarySaturationOverlayItem::renderAxisImmediateMode(float upperBoundY, cvf::Color3ub colB(cvf::Color3::GREEN); cvf::Color3ub colC(cvf::Color3::RED); - float lowerBoundY = 20; - //float upperBoundY = static_cast(m_size.y() - 20); + //float upperBoundY = static_cast(this->sizeHint().y() - 20); - cvf::Vec3f a(0, lowerBoundY, 0); - cvf::Vec3f b(static_cast(m_size.x()), lowerBoundY, 0); - cvf::Vec3f c(static_cast(m_size.x() / 2), upperBoundY, 0); + cvf::Vec3f a(float(border), lowerBoundY, 0); + cvf::Vec3f b(static_cast(totalWidth - border), lowerBoundY, 0); + cvf::Vec3f c(static_cast(totalWidth / 2), upperBoundY, 0); // Draw filled rectangle elements @@ -247,17 +255,7 @@ void RivTernarySaturationOverlayItem::setRangeText(const cvf::String& soilRange, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivTernarySaturationOverlayItem::setTitle(const cvf::String& title) +cvf::Vec2ui RivTernarySaturationOverlayItem::preferredSize() { - // Title - if (title.isEmpty()) - { - m_titleStrings.clear(); - } - else - { - m_titleStrings = title.split("\n"); - } + return {140, 180}; // Could do more elaborate text width checks. } - - diff --git a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h index 23a1c29133..af5db4772e 100644 --- a/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h +++ b/ApplicationCode/ModelVisualization/RivTernarySaturationOverlayItem.h @@ -19,9 +19,10 @@ #pragma once -#include "cvfOverlayItem.h" +#include "cafTitledOverlayFrame.h" #include "cvfMatrix4.h" #include "cvfColor3.h" +#include "cvfColor4.h" #include "cvfString.h" namespace cvf { @@ -35,7 +36,7 @@ class Font; // // //================================================================================================== -class RivTernarySaturationOverlayItem : public cvf::OverlayItem +class RivTernarySaturationOverlayItem : public caf::TitledOverlayFrame { public: explicit RivTernarySaturationOverlayItem(cvf::Font* font); @@ -43,30 +44,30 @@ class RivTernarySaturationOverlayItem : public cvf::OverlayItem void setRangeText(const cvf::String& soilRange, const cvf::String& sgasRange, const cvf::String& swatRange); - virtual cvf::Vec2ui sizeHint(); - - virtual void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - virtual void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - - void setSize(const cvf::Vec2ui& size); void setAxisLabelsColor(const cvf::Color3f& color); - void setTitle(const cvf::String& title); - + cvf::Vec2ui preferredSize() override; private: - void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); - void renderAxisImmediateMode(float upperY, cvf::OpenGLContext* oglContext); + void render(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size) override; + void renderSoftware(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size) override; + + void renderGeneric(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size, + bool software); + void renderAxisImmediateMode(float upperY, + float lowerBoundY, + float border, + unsigned int totalWidth, + cvf::OpenGLContext* oglContext); private: - cvf::Color3f m_textColor; // Text color - cvf::ref m_font; - cvf::String m_soilRange; cvf::String m_sgasRange; cvf::String m_swatRange; - - cvf::Vec2ui m_size; // Pixel size of draw area - - std::vector m_titleStrings; }; diff --git a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp index e1d09b88cb..49206e74d4 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryScalarMapperEffectGenerator.cpp @@ -19,6 +19,8 @@ #include "RivTernaryScalarMapperEffectGenerator.h" +#include "RiaColorTables.h" + #include "RivTernaryScalarMapper.h" #include "cvfRenderStateBlending.h" @@ -48,7 +50,7 @@ /// //-------------------------------------------------------------------------------------------------- RivTernaryScalarMapperEffectGenerator::RivTernaryScalarMapperEffectGenerator(const RivTernaryScalarMapper* scalarMapper, caf::PolygonOffset polygonOffset) - : m_undefinedColor(cvf::Color3::GRAY) + : m_undefinedColor(RiaColorTables::undefinedCellColor()) { m_scalarMapper = scalarMapper; m_polygonOffset = polygonOffset; @@ -239,9 +241,9 @@ caf::EffectGenerator* RivTernaryScalarMapperEffectGenerator::copy() const //-------------------------------------------------------------------------------------------------- bool RivTernaryScalarMapperEffectGenerator::isImagesEqual(const cvf::TextureImage* texImg1, const cvf::TextureImage* texImg2) { - if (texImg1 == NULL && texImg2 == NULL) return true; + if (texImg1 == nullptr && texImg2 == nullptr) return true; - if (texImg1 != NULL && texImg2 != NULL + if (texImg1 != nullptr && texImg2 != nullptr && texImg1->height() == texImg2->height() && texImg1->width() == texImg2->width() && texImg1->width() > 0 && texImg1->height() > 0 diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp index 37d6c3434f..43e54aa833 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.cpp @@ -79,9 +79,9 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( //-------------------------------------------------------------------------------------------------- RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, - RimTernaryLegendConfig* ternaryLegendConfig, + const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex) - : m_quadMapper(NULL) + : m_quadMapper(nullptr) { RigEclipseCaseData* eclipseCase = cellResultColors->reservoirView()->eclipseCase()->eclipseCaseData(); @@ -99,10 +99,8 @@ RivTernaryTextureCoordsCreator::RivTernaryTextureCoordsCreator( m_resultAccessor = new RigTernaryResultAccessor(); m_resultAccessor->setTernaryResultAccessors(soil.p(), sgas.p(), swat.p()); - const RivTernaryScalarMapper* mapper = ternaryLegendConfig->scalarMapper(); - // Create a texture mapper without detecting transparency using RigPipeInCellEvaluator - m_texMapper = new RivTernaryResultToTextureMapper(mapper, NULL); + m_texMapper = new RivTernaryResultToTextureMapper(ternaryColorMapper, nullptr); CVF_ASSERT(m_texMapper.notNull()); } diff --git a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h index d9e767ab0c..b85ea520c0 100644 --- a/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h +++ b/ApplicationCode/ModelVisualization/RivTernaryTextureCoordsCreator.h @@ -48,7 +48,7 @@ class RivTernaryTextureCoordsCreator const cvf::StructGridQuadToCellFaceMapper* quadMapper); RivTernaryTextureCoordsCreator( RimEclipseCellColors* cellResultColors, - RimTernaryLegendConfig* ternaryLegendConfig, + const RivTernaryScalarMapper* ternaryColorMapper, size_t timeStepIndex); void createTextureCoords(cvf::Vec2fArray* quadTextureCoords); diff --git a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp index 1db9149f92..185f9b7bc3 100644 --- a/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp +++ b/ApplicationCode/ModelVisualization/RivTextureCoordsCreator.cpp @@ -27,7 +27,7 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInViewCollection.h" #include "RivResultToTextureMapper.h" diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp new file mode 100644 index 0000000000..c28f0b8a3b --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.cpp @@ -0,0 +1,358 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellConnectionFactorGeometryGenerator.h" + +#include "cafEffectGenerator.h" +#include "cvfArray.h" +#include "cvfDrawableGeo.h" +#include "cvfPart.h" +#include "cvfPrimitiveSetIndexedUInt.h" +#include "cvfScalarMapper.h" + +#include // Needed for HUGE_VAL on Linux + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorGeometryGenerator::RivWellConnectionFactorGeometryGenerator( + std::vector& completionVizData, + float radius) + : m_completionVizData(completionVizData) + , m_radius(radius) + , m_trianglesPerConnection(0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorGeometryGenerator::~RivWellConnectionFactorGeometryGenerator() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfacePart(const cvf::ScalarMapper* scalarMapper, bool disableLighting) +{ + if (!scalarMapper) return nullptr; + + cvf::ref drawable = createSurfaceGeometry(); + if (drawable.notNull()) + { + cvf::ref part = new cvf::Part; + part->setDrawable(drawable.p()); + + // Compute texture coords + cvf::ref textureCoords = new cvf::Vec2fArray(); + { + textureCoords->reserve(drawable->vertexArray()->size()); + size_t verticesPerItem = drawable->vertexArray()->size() / m_completionVizData.size(); + + textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); + + for (const auto& item : m_completionVizData) + { + cvf::Vec2f textureCoord = cvf::Vec2f(0.5f, 1.0f); + if (item.m_connectionFactor != HUGE_VAL) + { + textureCoord = scalarMapper->mapToTextureCoord(item.m_connectionFactor); + } + + for (size_t i = 0; i < verticesPerItem; i++) + { + textureCoords->add(textureCoord); + } + } + } + + drawable->setTextureCoordArray(textureCoords.p()); + + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + effGen.disableLighting(disableLighting); + + cvf::ref eff = effGen.generateCachedEffect(); + part->setEffect(eff.p()); + + return part; + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellConnectionFactorGeometryGenerator::createSurfaceGeometry() +{ + std::vector verticesForOneObject; + std::vector indicesForOneObject; + + RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry( + &verticesForOneObject, &indicesForOneObject, m_radius, m_radius * 0.3f); + + m_trianglesPerConnection = indicesForOneObject.size() / 3; + + cvf::ref vertices = new cvf::Vec3fArray; + cvf::ref indices = new cvf::UIntArray; + + auto indexCount = m_completionVizData.size() * indicesForOneObject.size(); + auto vertexCount = m_completionVizData.size() * verticesForOneObject.size(); + indices->reserve(indexCount); + vertices->reserve(vertexCount); + + for (const auto& item : m_completionVizData) + { + auto rotMatrix = rotationMatrixBetweenVectors(cvf::Vec3d::Y_AXIS, item.m_direction); + + cvf::uint indexOffset = static_cast(vertices->size()); + + for (const auto& v : verticesForOneObject) + { + auto rotatedPoint = v.getTransformedPoint(rotMatrix); + + vertices->add(cvf::Vec3f(item.m_anchor) + rotatedPoint); + } + + for (const auto& i : indicesForOneObject) + { + indices->add(i + indexOffset); + } + } + + cvf::ref drawable = new cvf::DrawableGeo(); + drawable->setVertexArray(vertices.p()); + + drawable->addPrimitiveSet(new cvf::PrimitiveSetIndexedUInt(cvf::PT_TRIANGLES, indices.p())); + drawable->computeNormals(); + + return drawable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivWellConnectionFactorGeometryGenerator::connectionFactor(cvf::uint triangleIndex) const +{ + size_t connectionIndex = mapFromTriangleToConnectionIndex(triangleIndex); + + return m_completionVizData[connectionIndex].m_connectionFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionFactorGeometryGenerator::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + size_t connectionIndex = mapFromTriangleToConnectionIndex(triangleIndex); + + return m_completionVizData[connectionIndex].m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionFactorGeometryGenerator::mapFromTriangleToConnectionIndex(cvf::uint triangleIndex) const +{ + if (m_trianglesPerConnection == 0) return 0; + + size_t connectionIndex = triangleIndex / m_trianglesPerConnection; + + return connectionIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// Taken from OverlayNavigationCube::computeNewUpVector +/// Consider move to geometry util class +//-------------------------------------------------------------------------------------------------- +cvf::Mat4f RivWellConnectionFactorGeometryGenerator::rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2) +{ + using namespace cvf; + + Vec3d rotAxis = v1 ^ v2; + rotAxis.normalize(); + + // Guard acos against out-of-domain input + const double dotProduct = Math::clamp(v1 * v2, -1.0, 1.0); + const double angle = Math::acos(dotProduct); + Mat4d rotMat = Mat4d::fromRotation(rotAxis, angle); + + Mat4f myMat(rotMat); + + return myMat; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellConnectionFactorGeometryGenerator::createStarGeometry(std::vector* vertices, + std::vector* indices, + float radius, + float thickness) +{ + auto p0 = cvf::Vec3f::Z_AXIS * radius; + auto p2 = cvf::Vec3f::X_AXIS * -radius; + auto p4 = -p0; + auto p6 = -p2; + + float innerFactor = 5.0f; + + auto p1 = (p0 + p2) / innerFactor; + auto p3 = (p2 + p4) / innerFactor; + + auto p5 = -p1; + auto p7 = -p3; + + auto p8 = cvf::Vec3f::Y_AXIS * thickness; + auto p9 = -p8; + + vertices->push_back(p0); + vertices->push_back(p1); + vertices->push_back(p2); + vertices->push_back(p3); + vertices->push_back(p4); + vertices->push_back(p5); + vertices->push_back(p6); + vertices->push_back(p7); + vertices->push_back(p8); + vertices->push_back(p9); + + // Top + indices->push_back(0); + indices->push_back(1); + indices->push_back(8); + + indices->push_back(0); + indices->push_back(8); + indices->push_back(7); + + indices->push_back(0); + indices->push_back(9); + indices->push_back(1); + + indices->push_back(0); + indices->push_back(7); + indices->push_back(9); + + // Left + indices->push_back(2); + indices->push_back(3); + indices->push_back(8); + + indices->push_back(2); + indices->push_back(8); + indices->push_back(1); + + indices->push_back(2); + indices->push_back(9); + indices->push_back(3); + + indices->push_back(2); + indices->push_back(1); + indices->push_back(9); + + // Bottom + indices->push_back(4); + indices->push_back(5); + indices->push_back(8); + + indices->push_back(4); + indices->push_back(8); + indices->push_back(3); + + indices->push_back(4); + indices->push_back(9); + indices->push_back(5); + + indices->push_back(4); + indices->push_back(3); + indices->push_back(9); + + // Right + indices->push_back(6); + indices->push_back(7); + indices->push_back(8); + + indices->push_back(6); + indices->push_back(8); + indices->push_back(5); + + indices->push_back(6); + indices->push_back(9); + indices->push_back(7); + + indices->push_back(6); + indices->push_back(5); + indices->push_back(9); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellConnectionFactorGeometryGenerator::createSimplifiedStarGeometry(std::vector* vertices, + std::vector* indices, + float radius, + float thickness) +{ + // Suggested improvement + // As the nodes are duplicated, it will be possible create only vertices and then use DrawableGeo::setFromTriangleVertexArray + + auto p0 = cvf::Vec3f::Y_AXIS * thickness; + auto p1 = -p0; + auto p2 = cvf::Vec3f::Z_AXIS * radius; + + auto p3 = p0; + auto p4 = p1; + auto p5 = cvf::Vec3f::X_AXIS * radius; + + auto p6 = p0; + auto p7 = p1; + auto p8 = -p2; + + auto p9 = p0; + auto p10 = p1; + auto p11 = -p5; + + vertices->push_back(p0); + vertices->push_back(p1); + vertices->push_back(p2); + vertices->push_back(p3); + vertices->push_back(p4); + vertices->push_back(p5); + vertices->push_back(p6); + vertices->push_back(p7); + vertices->push_back(p8); + vertices->push_back(p9); + vertices->push_back(p10); + vertices->push_back(p11); + + indices->push_back(0); + indices->push_back(1); + indices->push_back(2); + + indices->push_back(3); + indices->push_back(4); + indices->push_back(5); + + indices->push_back(6); + indices->push_back(7); + indices->push_back(8); + + indices->push_back(9); + indices->push_back(10); + indices->push_back(11); +} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h new file mode 100644 index 0000000000..9e9535f2cd --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorGeometryGenerator.h @@ -0,0 +1,85 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfMatrix4.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include + +namespace cvf +{ +class DrawableGeo; +class Part; +class ScalarMapper; +} // namespace cvf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +struct CompletionVizData +{ + CompletionVizData(const cvf::Vec3d& anchor, const cvf::Vec3d& direction, double connectionFactor, size_t globalCellIndex) + : m_anchor(anchor) + , m_direction(direction) + , m_connectionFactor(connectionFactor) + , m_globalCellIndex(globalCellIndex) + { + } + + cvf::Vec3d m_anchor; + cvf::Vec3d m_direction; + double m_connectionFactor; + size_t m_globalCellIndex; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RivWellConnectionFactorGeometryGenerator : public cvf::Object +{ +public: + RivWellConnectionFactorGeometryGenerator(std::vector& completionVizData, float radius); + ~RivWellConnectionFactorGeometryGenerator(); + + cvf::ref createSurfacePart(const cvf::ScalarMapper* scalarMapper, bool disableLighting); + + double connectionFactor(cvf::uint triangleIndex) const; + size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; + +private: + size_t mapFromTriangleToConnectionIndex(cvf::uint triangleIndex) const; + cvf::ref createSurfaceGeometry(); + + static cvf::Mat4f rotationMatrixBetweenVectors(const cvf::Vec3d& v1, const cvf::Vec3d& v2); + static void + createStarGeometry(std::vector* vertices, std::vector* indices, float radius, float thickness); + + static void createSimplifiedStarGeometry(std::vector* vertices, + std::vector* indices, + float radius, + float thickness); + +private: + std::vector m_completionVizData; + float m_radius; + size_t m_trianglesPerConnection; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp new file mode 100644 index 0000000000..a2f8d3d269 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.cpp @@ -0,0 +1,192 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellConnectionFactorPartMgr.h" + +#include "RiaApplication.h" +#include "RiaExtractionTools.h" + +#include "RigEclipseWellLogExtractor.h" +#include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellLogExtractor.h" +#include "RigWellPath.h" + +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimRegularLegendConfig.h" +#include "RimSimWellInViewCollection.h" +#include "RimVirtualPerforationResults.h" +#include "RimWellPath.h" + +#include "RiuViewer.h" + +#include "RivWellConnectionFactorGeometryGenerator.h" +#include "RivWellConnectionSourceInfo.h" + +#include "cafDisplayCoordTransform.h" +#include "cafEffectGenerator.h" +#include "cvfDrawableGeo.h" +#include "cvfModelBasicList.h" +#include "cvfPart.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorPartMgr::RivWellConnectionFactorPartMgr(RimWellPath* well, + RimVirtualPerforationResults* virtualPerforationResult) + : m_rimWellPath(well) + , m_virtualPerforationResult(virtualPerforationResult) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionFactorPartMgr::~RivWellConnectionFactorPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellConnectionFactorPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +{ + m_geometryGenerator = nullptr; + + RimEclipseView* eclView = nullptr; + m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclView); + + auto coordTransform = eclView->displayCoordTransform(); + + RimEclipseCase* eclipseCase = nullptr; + m_virtualPerforationResult->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + const RigMainGrid* mainGrid = eclipseCase->mainGrid(); + + const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (!trans) return; + + auto completionsForWellPath = trans->multipleCompletionsPerEclipseCell(m_rimWellPath, frameIndex); + + // Remove connection factors for parent grid, they are not supposed to be visualized, but are relevant for export + for (auto it = completionsForWellPath.begin(); it != completionsForWellPath.end();) + { + size_t gridIndex = it->first.globalCellIndex(); + + const RigCell& rigCell = mainGrid->cell(gridIndex); + if (rigCell.subGrid()) + { + it = completionsForWellPath.erase(it); + } + else + { + ++it; + } + } + + std::vector wellPathCellIntersections; + { + RigEclipseWellLogExtractor* extractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_rimWellPath, eclipseCase); + if (extractor) + { + wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath(); + } + } + + std::vector completionVizDataItems; + for (const auto& completionsForCell : completionsForWellPath) + { + if (!m_virtualPerforationResult->showConnectionFactorsOnClosedConnections()) + { + for (const auto& completion : completionsForCell.second) + { + if (completion.connectionState() == SHUT) + { + continue; + } + } + } + + size_t gridIndex = completionsForCell.first.globalCellIndex(); + + const RigCell& rigCell = mainGrid->cell(gridIndex); + + cvf::Vec3d locationInDomainCoord = rigCell.center(); + cvf::Vec3d direction = cvf::Vec3d::X_AXIS; + bool foundLocation = false; + + size_t i = 0; + while (!foundLocation && (i < wellPathCellIntersections.size())) + { + const WellPathCellIntersectionInfo& intersectionInfo = wellPathCellIntersections[i]; + + if (intersectionInfo.globCellIndex == completionsForCell.first.globalCellIndex()) + { + double startMD = intersectionInfo.startMD; + double endMD = intersectionInfo.endMD; + + double middleMD = (startMD + endMD) / 2.0; + + locationInDomainCoord = m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath(middleMD); + + cvf::Vec3d p1; + cvf::Vec3d p2; + m_rimWellPath->wellPathGeometry()->twoClosestPoints(locationInDomainCoord, &p1, &p2); + + direction = (p2 - p1).getNormalized(); + + foundLocation = true; + } + + i++; + } + + cvf::Vec3d displayCoord = coordTransform->transformToDisplayCoord(locationInDomainCoord); + + for (size_t i = 0; i < completionsForCell.second.size(); i++) + { + const RigCompletionData& completionData = completionsForCell.second[i]; + + double transmissibility = completionData.transmissibility(); + + completionVizDataItems.push_back( + CompletionVizData(displayCoord, direction, transmissibility, completionsForCell.first.globalCellIndex())); + } + } + + if (!completionVizDataItems.empty()) + { + double characteristicCellSize = eclView->ownerCase()->characteristicCellSize(); + + double radius = m_rimWellPath->wellPathRadius(characteristicCellSize) * m_virtualPerforationResult->geometryScaleFactor(); + radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry scale factor is set to 1.0 + + m_geometryGenerator = new RivWellConnectionFactorGeometryGenerator(completionVizDataItems, radius); + + auto scalarMapper = m_virtualPerforationResult->legendConfig()->scalarMapper(); + + cvf::ref part = m_geometryGenerator->createSurfacePart(scalarMapper, eclView->isLightingDisabled()); + if (part.notNull()) + { + cvf::ref sourceInfo = + new RivWellConnectionSourceInfo(m_rimWellPath, m_geometryGenerator.p()); + part->setSourceInfo(sourceInfo.p()); + + model->addPart(part.p()); + } + } +} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h new file mode 100644 index 0000000000..659c9093f3 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionFactorPartMgr.h @@ -0,0 +1,53 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" + +#include "cafPdmPointer.h" + +#include + +namespace cvf +{ +class ModelBasicList; +} // namespace cvf + +class RimWellPath; +class RimVirtualPerforationResults; +class RivWellConnectionFactorGeometryGenerator; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RivWellConnectionFactorPartMgr : public cvf::Object +{ +public: + RivWellConnectionFactorPartMgr(RimWellPath* well, RimVirtualPerforationResults* virtualPerforationResult); + ~RivWellConnectionFactorPartMgr(); + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); + +private: + caf::PdmPointer m_rimWellPath; + caf::PdmPointer m_virtualPerforationResult; + + cvf::ref m_geometryGenerator; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp new file mode 100644 index 0000000000..6d534fb247 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.cpp @@ -0,0 +1,60 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellConnectionSourceInfo.h" + +#include "RimWellPath.h" +#include "RivWellConnectionFactorGeometryGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellConnectionSourceInfo::RivWellConnectionSourceInfo(RimWellPath* wellPath, + RivWellConnectionFactorGeometryGenerator* geometryGenerator) + : m_wellPath(wellPath) + , m_geometryGenerator(geometryGenerator) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPath* RivWellConnectionSourceInfo::wellPath() const +{ + return m_wellPath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RivWellConnectionSourceInfo::globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0; + + return m_geometryGenerator->globalCellIndexFromTriangleIndex(triangleIndex); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RivWellConnectionSourceInfo::connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const +{ + if (m_geometryGenerator.isNull()) return 0.0; + + return m_geometryGenerator->connectionFactor(triangleIndex); +} diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h new file mode 100644 index 0000000000..b37bf837c0 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellConnectionSourceInfo.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmPointer.h" + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +class RimWellPath; +class RivWellConnectionFactorGeometryGenerator; + +//================================================================================================== +/// +//================================================================================================== +class RivWellConnectionSourceInfo : public cvf::Object +{ +public: + explicit RivWellConnectionSourceInfo(RimWellPath* wellPath, RivWellConnectionFactorGeometryGenerator* geometryGenerator); + + RimWellPath* wellPath() const; + + size_t globalCellIndexFromTriangleIndex(cvf::uint triangleIndex) const; + double connectionFactorFromTriangleIndex(cvf::uint triangleIndex) const; + +private: + caf::PdmPointer m_wellPath; + cvf::ref m_geometryGenerator; +}; diff --git a/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp index 940fd1beb9..ee6c762a2b 100644 --- a/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellConnectionsPartMgr.cpp @@ -96,7 +96,7 @@ void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasi characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize(); - m_rimWell->wellHeadTopBottomPosition(frameIndex, &wellHeadTop, &wellHeadBottom); + m_rimWell->wellHeadTopBottomPosition(static_cast(frameIndex), &wellHeadTop, &wellHeadBottom); wellHeadTop = displayCordXf->transformToDisplayCoord(wellHeadTop); wellHeadBottom = displayCordXf->transformToDisplayCoord(wellHeadBottom); wellHeadTop.z() += characteristicCellSize; @@ -183,7 +183,7 @@ void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasi cvf::Vec3d otherWellHeadTop; cvf::Vec3d otherWellHeadBottom; { - otherWell->wellHeadTopBottomPosition(frameIndex, &otherWellHeadTop, &otherWellHeadBottom); + otherWell->wellHeadTopBottomPosition(static_cast(frameIndex), &otherWellHeadTop, &otherWellHeadBottom); otherWellHeadTop = displayCordXf->transformToDisplayCoord(otherWellHeadTop); otherWellHeadBottom = displayCordXf->transformToDisplayCoord(otherWellHeadBottom); otherWellHeadTop.z() += characteristicCellSize; diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp index 0132d44d24..187306ff3e 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.cpp @@ -16,31 +16,40 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RivWellFracturePartMgr.h" - #include "RiaApplication.h" +#include "RiaColorTables.h" +#include "RiaFractureDefines.h" +#include "RigCellGeometryTools.h" +#include "RigFractureCell.h" #include "RigFractureGrid.h" -#include "RigMainGrid.h" #include "RigHexIntersectionTools.h" -#include "RigCellGeometryTools.h" +#include "RigMainGrid.h" +#include "RigWellPath.h" -#include "RigFractureCell.h" +#include "RimCase.h" #include "RimEclipseView.h" +#include "RimEllipseFractureTemplate.h" #include "RimFracture.h" #include "RimFractureContainment.h" #include "RimFractureTemplate.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" +#include "RimSimWellInView.h" #include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" #include "RivFaultGeometryGenerator.h" -#include "RivPartPriority.h" #include "RivObjectSourceInfo.h" +#include "RivPartPriority.h" +#include "RivPipeGeometryGenerator.h" +#include "RivWellFracturePartMgr.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" +#include "cvfAssert.h" #include "cvfDrawableGeo.h" #include "cvfGeometryTools.h" #include "cvfModelBasicList.h" @@ -48,11 +57,12 @@ #include "cvfPrimitiveSet.h" #include "cvfPrimitiveSetDirect.h" #include "cvfPrimitiveSetIndexedUInt.h" -#include "cvfScalarMapperContinuousLinear.h" #include "cvfRenderStateDepth.h" -#include "cvfAssert.h" +#include "cvfScalarMapperContinuousLinear.h" +#include "cvfTransform.h" + +#include -#include //-------------------------------------------------------------------------------------------------- /// @@ -70,6 +80,254 @@ RivWellFracturePartMgr::~RivWellFracturePartMgr() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) +{ + if (!m_rimFracture->isChecked() || !eclView.fractureColors()->isChecked()) return; + + if (!m_rimFracture->fractureTemplate()) return; + + double characteristicCellSize = eclView.ownerCase()->characteristicCellSize(); + + cvf::Collection parts; + RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + + if (stimPlanFracTemplate) + { + if (eclView.fractureColors()->stimPlanResultColorType() == RimStimPlanColors::SINGLE_ELEMENT_COLOR) + { + auto part = createStimPlanElementColorSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + else + { + auto part = createStimPlanColorInterpolatedSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + + if (eclView.fractureColors()->showStimPlanMesh()) + { + auto part = createStimPlanMeshPart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + } + else + { + auto part = createEllipseSurfacePart(eclView); + if (part.notNull()) parts.push_back(part.p()); + } + + double distanceToCenterLine = 1.0; + { + RimWellPathCollection* wellPathColl = nullptr; + m_rimFracture->firstAncestorOrThisOfType(wellPathColl); + if (wellPathColl) + { + distanceToCenterLine = wellPathColl->wellPathRadiusScaleFactor() * characteristicCellSize; + } + + RimSimWellInView* simWell = nullptr; + m_rimFracture->firstAncestorOrThisOfType(simWell); + if (simWell) + { + distanceToCenterLine = simWell->pipeRadius(); + } + } + + + // Make sure the distance is slightly smaller than the pipe radius to make the pipe is visible through the fracture + distanceToCenterLine *= 0.1; + + if (distanceToCenterLine < 0.03) + { + distanceToCenterLine = 0.03; + } + + auto fractureMatrix = m_rimFracture->transformMatrix(); + + if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) + { + cvf::Vec3d partTranslation = distanceToCenterLine * cvf::Vec3d(fractureMatrix.col(2)); + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (auto& part : parts) + { + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } + } + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + for (const auto& originalPart : parts) + { + auto part = originalPart->shallowCopy(); + + part->setTransform(partTransform.p()); + model->addPart(part.p()); + } + } + } + else + { + for (auto& part : parts) + { + model->addPart(part.p()); + } + } + + if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) + { + // Position the containment mask outside the fracture parts + // Always duplicate the containment mask parts + + auto originalPart = createContainmentMaskPart(eclView); + if (originalPart.notNull()) + { + double scaleFactor = 0.03; + if (m_rimFracture->fractureTemplate() && m_rimFracture->fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) + { + scaleFactor = 2 * distanceToCenterLine; + } + + cvf::Vec3d partTranslation = scaleFactor * cvf::Vec3d(fractureMatrix.col(2)); + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + originalPart->setTransform(partTransform.p()); + model->addPart(originalPart.p()); + } + + { + cvf::Mat4d m = cvf::Mat4d::fromTranslation(-partTranslation); + + cvf::ref partTransform = new cvf::Transform; + partTransform->setLocalTransform(m); + + auto copy = originalPart->shallowCopy(); + copy->setTransform(partTransform.p()); + model->addPart(copy.p()); + } + } + } + + appendFracturePerforationLengthParts(eclView, model); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString RivWellFracturePartMgr::resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const +{ + QString text; + + if (m_rimFracture.isNull()) return text; + + RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + RimStimPlanFractureTemplate* stimPlanTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + if (ellipseFractureTemplate) + { + text.append("Result value: CONDUCTIVITY "); + text.append(QString::number(ellipseFractureTemplate->conductivity()) + "\n"); + + } + else if (stimPlanTemplate) + { + const RigFractureCell* cell = getFractureCellAtDomainCoord(domainIntersectionPoint); + RimStimPlanColors* stimPlanColors = activeView.fractureColors(); + + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); + + double resultValue = stimPlanTemplate->resultValueAtIJ( + resultNameFromColors, resultUnitFromColors, stimPlanTemplate->activeTimeStepIndex(), cell->getI(), cell->getJ()); + + QString resultValueText = QString("%1").arg(resultValue); + + QString iText = cell ? QString::number(cell->getI()) : "-"; + QString jText = cell ? QString::number(cell->getJ()) : "-"; + + // Conductivity + text.append("Result value: "); + + QString resultName = stimPlanTemplate->mapUiResultNameToFileResultName(stimPlanColors->uiResultName()); + text.append(resultName + " "); + text.append(resultValueText + "\n"); + + // Cell index + text.append("Cell Index: "); + text.append(iText + ", " + jText + "\n"); + } + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFractureCell* RivWellFracturePartMgr::getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const +{ + if (!m_rimFracture) return nullptr; + + cvf::Mat4d toFractureXf = m_rimFracture->transformMatrix().getInverted(); + cvf::Vec3d fractureCoord = domainCoord.getTransformedPoint(toFractureXf); + + const RimStimPlanFractureTemplate* stimPlanTempl = dynamic_cast(m_rimFracture->fractureTemplate()); + if (!stimPlanTempl) return nullptr; + + const RigFractureGrid* grid = stimPlanTempl->fractureGrid(); + size_t cellI = cvf::UNDEFINED_SIZE_T; + size_t cellJ = cvf::UNDEFINED_SIZE_T; + const std::vector& cells = grid->fractureCells(); + + for (size_t i = 0; i < grid->iCellCount(); i++) + { + const RigFractureCell& cell = cells[i * grid->jCellCount()]; + std::vector polygon = cell.getPolygon(); + double xmin = polygon[0].x(); + double xmax = polygon[2].x(); + if (fractureCoord.x() >= xmin && fractureCoord.x() <= xmax) + { + cellI = cell.getI(); + break; + } + } + + for (size_t j = 0; j < grid->jCellCount(); j++) + { + const RigFractureCell& cell = cells[j]; + std::vector polygon = cell.getPolygon(); + double ymin = polygon[2].y(); + double ymax = polygon[0].y(); + if (fractureCoord.y() >= ymin && fractureCoord.y() <= ymax) + { + cellJ = cell.getJ(); + break; + } + } + + if (cellI != cvf::UNDEFINED_SIZE_T && cellJ != cvf::UNDEFINED_SIZE_T) + { + return &grid->cellFromIndex(grid->getGlobalIndexFromIJ(cellI, cellJ)); + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -82,30 +340,49 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc { std::vector nodeCoords; std::vector triangleIndices; - m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords); - std::vector displayCoords; + m_rimFracture->fractureTemplate()->fractureTriangleGeometry(&nodeCoords, &triangleIndices); - for (size_t i = 0; i < nodeCoords.size(); i++) - { - cvf::Vec3d nodeCoordsDouble = static_cast(nodeCoords[i]); - cvf::Vec3d displayCoordsDouble = displayCoordTransform->transformToDisplayCoord(nodeCoordsDouble); - displayCoords.push_back(static_cast(displayCoordsDouble)); - } + cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); + std::vector nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform); - if (triangleIndices.size() == 0 || displayCoords.size() == 0) + if (triangleIndices.empty() || nodeDisplayCoords.empty()) { return nullptr; } - cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, displayCoords); + cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, nodeDisplayCoords); CVF_ASSERT(geo.notNull()); cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_ellipse"); surfacePart->setDrawable(geo.p()); surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor()); + cvf::Color4f fractureColor = cvf::Color4f(activeView.fractureColors()->defaultColor()); + + RimRegularLegendConfig* legendConfig = nullptr; + if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) + { + legendConfig = activeView.fractureColors()->activeLegend(); + } + + if (legendConfig && legendConfig->scalarMapper()) + { + cvf::Color3ub resultColor = cvf::Color3ub(RiaColorTables::undefinedCellColor()); + + if (activeView.fractureColors()->uiResultName() == RiaDefines::conductivityResultName()) + { + RimEllipseFractureTemplate* ellipseFractureTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + if (ellipseFractureTemplate) + { + double conductivity = ellipseFractureTemplate->conductivity(); + resultColor = legendConfig->scalarMapper()->mapToColor(conductivity); + } + } + + fractureColor.set(cvf::Color3f::fromByteColor(resultColor.r(), resultColor.g(), resultColor.b())); + } + caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1); cvf::ref eff = surfaceGen.generateCachedEffect(); surfacePart->setEffect(eff.p()); @@ -120,7 +397,7 @@ cvf::ref RivWellFracturePartMgr::createEllipseSurfacePart(const RimEc //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimEclipseView& activeView) +cvf::ref RivWellFracturePartMgr::createStimPlanColorInterpolatedSurfacePart(const RimEclipseView& activeView) { CVF_ASSERT(m_rimFracture); RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); @@ -133,26 +410,21 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE // If this ever changes, the entire code must be revisited std::vector nodeCoords; std::vector triangleIndices; - m_rimFracture->triangleGeometry(&triangleIndices, &nodeCoords); - if (triangleIndices.size() == 0 || nodeCoords.size() == 0) - { - return NULL; - } + stimPlanFracTemplate->fractureTriangleGeometry(&nodeCoords, &triangleIndices); - // Transforms the node coordinates for display - for (size_t i = 0; i < nodeCoords.size(); i++) + if (triangleIndices.empty() || nodeCoords.empty()) { - cvf::Vec3d doubleCoord(nodeCoords[i]); - doubleCoord = displayCoordTransform->transformToDisplayCoord(doubleCoord); - nodeCoords[i] = cvf::Vec3f(doubleCoord); + return nullptr; } + cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); + std::vector nodeDisplayCoords = transformToFractureDisplayCoords(nodeCoords, fractureXf, *displayCoordTransform); - RimLegendConfig* legendConfig = nullptr; - if (activeView.stimPlanColors() && activeView.stimPlanColors()->isChecked()) + RimRegularLegendConfig* legendConfig = nullptr; + if (activeView.fractureColors() && activeView.fractureColors()->isChecked()) { - legendConfig = activeView.stimPlanColors()->activeLegend(); + legendConfig = activeView.fractureColors()->activeLegend(); } // Show selected result on the surface geometry and filter out triangles that have result values near 0 @@ -160,21 +432,19 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE { // Construct array with per node result values that correspond to the node coordinates of the triangle mesh // Since some time steps don't have result vales, we initialize the array to well known values before populating it - std::vector perNodeResultValues(nodeCoords.size(), HUGE_VAL); + std::vector perNodeResultValues(nodeDisplayCoords.size(), HUGE_VAL); { size_t idx = 0; - const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.stimPlanColors->resultName(), activeView.stimPlanColors->unit(), stimPlanFracTemplate->activeTimeStepIndex()); - for (const std::vector& unmirroredDataAtDepth : dataToPlot) + const std::vector > dataToPlot = stimPlanFracTemplate->resultValues(activeView.fractureColors()->uiResultName(), activeView.fractureColors()->unit(), stimPlanFracTemplate->activeTimeStepIndex()); + for (const std::vector& dataAtY : dataToPlot) { - const std::vector mirroredValuesAtDepth = mirrorDataAtSingleDepth(unmirroredDataAtDepth); - for (double val : mirroredValuesAtDepth) + for (double val : dataAtY) { perNodeResultValues[idx++] = val; } } } - CVF_ASSERT(perNodeResultValues.size() == nodeCoords.size()); - + CVF_ASSERT(perNodeResultValues.size() == nodeDisplayCoords.size()); std::vector triIndicesToInclude; for (size_t i = 0; i < triangleIndices.size(); i += 6) @@ -198,22 +468,16 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE } } - if (triIndicesToInclude.size() == 0) + if (triIndicesToInclude.empty()) { return nullptr; } - - cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeCoords); - cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); - surfacePart->setDrawable(geo.p()); - surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); - surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); - - + cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords); const cvf::ScalarMapper* scalarMapper = legendConfig->scalarMapper(); CVF_ASSERT(scalarMapper); - cvf::ref textureCoords = new cvf::Vec2fArray(nodeCoords.size()); + + cvf::ref textureCoords = new cvf::Vec2fArray(nodeDisplayCoords.size()); textureCoords->setAll(cvf::Vec2f(0.5f, 1.0f)); for (size_t i = 0; i < perNodeResultValues.size(); i++) { @@ -225,52 +489,169 @@ cvf::ref RivWellFracturePartMgr::createStimPlanSurfacePart(const RimE } geo->setTextureCoordArray(textureCoords.p()); - - caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); - effGen.disableLighting(activeView.isLightingDisabled()); - cvf::ref eff = effGen.generateCachedEffect(); - surfacePart->setEffect(eff.p()); + cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); return surfacePart; } - - // No result is mapped, show the entire StimPlan surface with default color else { - cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, nodeCoords); + // No result is mapped, show the entire StimPlan surface with default color - cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); - surfacePart->setDrawable(geo.p()); - surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); - surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); + return createSingleColorSurfacePart(triangleIndices, nodeCoords, activeView.fractureColors()->defaultColor()); + } - cvf::Color4f fractureColor = cvf::Color4f(activeView.stimPlanColors->defaultColor()); - caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1); - cvf::ref eff = surfaceGen.generateCachedEffect(); - surfacePart->setEffect(eff.p()); + return nullptr; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellFracturePartMgr::createSingleColorSurfacePart(const std::vector& triangleIndices, const std::vector& nodeCoords, const cvf::Color3f& color) +{ + cvf::ref geo = buildDrawableGeoFromTriangles(triangleIndices, nodeCoords); + + cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); + surfacePart->setDrawable(geo.p()); + surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); + surfacePart->setSourceInfo(new RivObjectSourceInfo(m_rimFracture)); + + cvf::Color4f fractureColor = cvf::Color4f(color); + caf::SurfaceEffectGenerator surfaceGen(fractureColor, caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); + surfacePart->setEffect(eff.p()); + + return surfacePart; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RivWellFracturePartMgr::createStimPlanElementColorSurfacePart(const RimEclipseView& activeView) +{ + CVF_ASSERT(m_rimFracture); + RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); + CVF_ASSERT(stimPlanFracTemplate); + + if (!stimPlanFracTemplate->fractureGrid()) return nullptr; + + auto displayCoordTransform = activeView.displayCoordTransform(); + if (displayCoordTransform.isNull()) return nullptr; + + std::vector stimPlanMeshVertices; + cvf::ref textureCoords = new cvf::Vec2fArray; + const cvf::ScalarMapper* scalarMapper = nullptr; + + { + std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); + + RimRegularLegendConfig* legendConfig = nullptr; + if (activeView.fractureColors() && + activeView.fractureColors()->isChecked() && + activeView.fractureColors()->activeLegend()) + { + legendConfig = activeView.fractureColors()->activeLegend(); + + scalarMapper = legendConfig->scalarMapper(); + + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); + + std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, + resultUnitFromColors, + stimPlanFracTemplate->activeTimeStepIndex()); + + textureCoords->reserve(prCellResults.size() * 4); + + for (size_t cIdx = 0; cIdx < stimPlanCells.size(); ++cIdx) + { + if (prCellResults[cIdx] > 1e-7) + { + const RigFractureCell& stimPlanCell = stimPlanCells[cIdx]; + std::vector stimPlanCellPolygon = stimPlanCell.getPolygon(); + for (const cvf::Vec3d& cellCorner : stimPlanCellPolygon) + { + stimPlanMeshVertices.push_back(static_cast(cellCorner)); + textureCoords->add(scalarMapper->mapToTextureCoord(prCellResults[cIdx])); + } + } + } + + textureCoords->squeeze(); + } + else + { + for (const auto& stimPlanCell : stimPlanCells) + { + for (const auto& cellCorner : stimPlanCell.getPolygon()) + { + stimPlanMeshVertices.push_back(static_cast(cellCorner)); + } + } + } + } + + if (stimPlanMeshVertices.empty()) + { + return nullptr; + } + + cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); + std::vector nodeDisplayCoords = + transformToFractureDisplayCoords(stimPlanMeshVertices, fractureXf, *displayCoordTransform); + + std::vector triIndicesToInclude; + + size_t cellCount = stimPlanMeshVertices.size() / 4; + for (cvf::uint i = 0; i < cellCount; i++) + { + triIndicesToInclude.push_back(i * 4 + 0); + triIndicesToInclude.push_back(i * 4 + 1); + triIndicesToInclude.push_back(i * 4 + 2); + + triIndicesToInclude.push_back(i * 4 + 0); + triIndicesToInclude.push_back(i * 4 + 2); + triIndicesToInclude.push_back(i * 4 + 3); + } + + // Show selected result on the surface geometry and filter out triangles that have result values near 0 + if (scalarMapper) + { + if (triIndicesToInclude.empty()) + { + return nullptr; + } + + cvf::ref geo = buildDrawableGeoFromTriangles(triIndicesToInclude, nodeDisplayCoords); + geo->setTextureCoordArray(textureCoords.p()); + + cvf::ref surfacePart = createScalarMapperPart(geo.p(), scalarMapper, m_rimFracture, activeView.isLightingDisabled()); return surfacePart; } -} + else + { + // No result is mapped, show the entire StimPlan surface with default color + return createSingleColorSurfacePart(triIndicesToInclude, nodeDisplayCoords, activeView.fractureColors()->defaultColor()); + } +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimEclipseView& activeView) { - std::vector borderPolygonLocalCS = m_rimFracture->fractureTemplate()->fractureBorderPolygon(m_rimFracture->fractureUnit()); + std::vector borderPolygonLocalCS = fractureBorderPolygon(); cvf::Mat4d frMx = m_rimFracture->transformMatrix(); cvf::BoundingBox frBBox; - std::vector borderPolygonGlobCs; std::vector borderPolygonLocalCsd; for (const auto& pv: borderPolygonLocalCS) { cvf::Vec3d pvd(pv); borderPolygonLocalCsd.push_back(pvd); pvd.transformPoint(frMx); - borderPolygonGlobCs.push_back(pvd); frBBox.add(pvd); } @@ -307,7 +688,6 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE } cvf::Vec3d fractureNormal = cvf::Vec3d(frMx.col(2)); - cvf::Vec3d maskOffset = fractureNormal * 0.01 * frBBox.radius(); for (const std::vector& eclCellPolygon : eclCellPolygons) { // Clip Eclipse cell polygon with fracture border @@ -339,12 +719,7 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE for (size_t idx: triangleIndices) { - maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx] + maskOffset)) ); - } - - for (size_t idx: triangleIndices) - { - maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx] - maskOffset)) ); + maskTriangles.push_back( cvf::Vec3f( displCoordTrans->transformToDisplayCoord(clippedPolygon[idx]) ) ); } } } @@ -377,6 +752,66 @@ cvf::ref RivWellFracturePartMgr::createContainmentMaskPart(const RimE return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellFracturePartMgr::appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model) +{ + if (!m_rimFracture->isChecked()) return; + + if (!m_rimFracture->fractureTemplate()) return; + if (m_rimFracture->fractureTemplate()->orientationType() != RimFractureTemplate::ALONG_WELL_PATH) return; + + auto displayCoordTransform = activeView.displayCoordTransform(); + if (displayCoordTransform.isNull()) return; + + double characteristicCellSize = activeView.ownerCase()->characteristicCellSize(); + double wellPathRadius = 1.0; + + { + RimWellPath* rimWellPath = nullptr; + m_rimFracture->firstAncestorOrThisOfType(rimWellPath); + if (rimWellPath) + { + wellPathRadius = rimWellPath->wellPathRadius(characteristicCellSize); + } + } + + { + RimSimWellInView* simWell = nullptr; + m_rimFracture->firstAncestorOrThisOfType(simWell); + if (simWell) + { + wellPathRadius = simWell->pipeRadius(); + } + } + + std::vector displayCoords; + { + std::vector perforationLengthCoord = m_rimFracture->perforationLengthCenterLineCoords(); + for (const cvf::Vec3d& point : perforationLengthCoord) + { + displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(point)); + } + } + + if (!displayCoords.empty()) + { + cvf::ref objectSourceInfo = new RivObjectSourceInfo(m_rimFracture); + double perforationRadius = wellPathRadius * 1.2; + cvf::Collection parts; + + RivPipeGeometryGenerator geoGenerator; + geoGenerator.cylinderWithCenterLineParts(&parts, displayCoords, RiaColorTables::perforationLengthColor(), perforationRadius); + + for (auto part : parts) + { + part->setSourceInfo(objectSourceInfo.p()); + model->addPart(part.p()); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -411,12 +846,9 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshPart(const RimEcli //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const +cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) { - //TODO: This is needed to avoid errors when loading project with stimPlan fractures with multipled timesteps. - //Should probably be moved, since it now is called twice in some cases... - stimPlanFracTemplate->updateFractureGrid(); - + if (!stimPlanFracTemplate->fractureGrid()) return nullptr; auto displayCoordTransform = activeView.displayCoordTransform(); if (displayCoordTransform.isNull()) return nullptr; @@ -424,33 +856,35 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri std::vector stimPlanCells = stimPlanFracTemplate->fractureGrid()->fractureCells(); std::vector stimPlanMeshVertices; - QString resultNameFromColors = activeView.stimPlanColors->resultName(); - QString resultUnitFromColors = activeView.stimPlanColors->unit(); + QString resultNameFromColors = activeView.fractureColors()->uiResultName(); + QString resultUnitFromColors = activeView.fractureColors()->unit(); std::vector prCellResults = stimPlanFracTemplate->fractureGridResults(resultNameFromColors, resultUnitFromColors, stimPlanFracTemplate->activeTimeStepIndex()); + m_visibleFracturePolygons.clear(); for ( size_t cIdx = 0; cIdx < stimPlanCells.size() ; ++cIdx) { if (prCellResults[cIdx] > 1e-7) { const RigFractureCell& stimPlanCell = stimPlanCells[cIdx]; std::vector stimPlanCellPolygon = stimPlanCell.getPolygon(); - for (cvf::Vec3d cellCorner : stimPlanCellPolygon) + for (const cvf::Vec3d& cellCorner : stimPlanCellPolygon) { stimPlanMeshVertices.push_back(static_cast(cellCorner)); } + m_visibleFracturePolygons.push_back(stimPlanCellPolygon); } } - if (stimPlanMeshVertices.size() == 0) + if (stimPlanMeshVertices.empty()) { return nullptr; } cvf::Mat4d fractureXf = m_rimFracture->transformMatrix(); - std::vector stimPlanMeshVerticesDisplayCoords = transformToFractureDisplayCoords(stimPlanMeshVertices, + std::vector stimPlanMeshVerticesDisplayCoords = transformToFractureDisplayCoords(stimPlanMeshVertices, fractureXf, *displayCoordTransform); @@ -472,93 +906,52 @@ cvf::ref RivWellFracturePartMgr::createStimPlanMeshDrawable(Ri //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RivWellFracturePartMgr::transformToFractureDisplayCoords(const std::vector& coordinatesVector, - cvf::Mat4d m, - const caf::DisplayCoordTransform& displayCoordTransform) +cvf::ref RivWellFracturePartMgr::createScalarMapperPart(cvf::DrawableGeo* drawableGeo, + const cvf::ScalarMapper* scalarMapper, + RimFracture* fracture, + bool disableLighting) { - std::vector polygonInDisplayCoords; - polygonInDisplayCoords.reserve(coordinatesVector.size()); + cvf::ref surfacePart = new cvf::Part(0, "FractureSurfacePart_stimPlan"); + surfacePart->setDrawable(drawableGeo); + surfacePart->setPriority(RivPartPriority::PartType::BaseLevel); + surfacePart->setSourceInfo(new RivObjectSourceInfo(fracture)); - for (const cvf::Vec3f& v : coordinatesVector) - { - cvf::Vec3d vd(v); - vd.transformPoint(m); - cvf::Vec3d displayCoordsDouble = displayCoordTransform.transformToDisplayCoord(vd); - polygonInDisplayCoords.push_back(cvf::Vec3f(displayCoordsDouble)); - } + caf::ScalarMapperEffectGenerator effGen(scalarMapper, caf::PO_1); + effGen.disableLighting(disableLighting); - return polygonInDisplayCoords; + cvf::ref eff = effGen.generateCachedEffect(); + surfacePart->setEffect(eff.p()); + + return surfacePart; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RivWellFracturePartMgr::mirrorDataAtSingleDepth(std::vector depthData) +std::vector RivWellFracturePartMgr::fractureBorderPolygon() { - std::vector mirroredValuesAtGivenDepth; - mirroredValuesAtGivenDepth.push_back(depthData[0]); - for (size_t i = 1; i < (depthData.size()); i++) //starting at 1 since we don't want center value twice - { - double valueAtGivenX = depthData[i]; - mirroredValuesAtGivenDepth.insert(mirroredValuesAtGivenDepth.begin(), valueAtGivenX); - mirroredValuesAtGivenDepth.push_back(valueAtGivenX); - } - - return mirroredValuesAtGivenDepth; + return RigCellGeometryTools::unionOfPolygons(m_visibleFracturePolygons); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellFracturePartMgr::appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) +std::vector RivWellFracturePartMgr::transformToFractureDisplayCoords(const std::vector& coordinatesVector, + cvf::Mat4d m, + const caf::DisplayCoordTransform& displayCoordTransform) { - if (!m_rimFracture->isChecked()) return; - - cvf::ref surfacePart; - cvf::ref stimPlanMeshPart; - cvf::ref containmentMaskPart; - - - RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(m_rimFracture->fractureTemplate()); - if (m_rimFracture->fractureTemplate()) - { - // StimPlan - if (stimPlanFracTemplate) - { - surfacePart = createStimPlanSurfacePart(eclView); - - if (stimPlanFracTemplate->showStimPlanMesh()) - { - stimPlanMeshPart = createStimPlanMeshPart(eclView); - } - } - // Ellipse - else - { - surfacePart = createEllipseSurfacePart(eclView); - } - - if (m_rimFracture->fractureTemplate()->fractureContainment()->isEnabled()) - { - containmentMaskPart = createContainmentMaskPart(eclView); - } - } - - - if (surfacePart.notNull()) - { - model->addPart(surfacePart.p()); - } + std::vector polygonInDisplayCoords; + polygonInDisplayCoords.reserve(coordinatesVector.size()); - if (stimPlanMeshPart.notNull()) + for (const cvf::Vec3f& v : coordinatesVector) { - model->addPart(stimPlanMeshPart.p()); + cvf::Vec3d vd(v); + vd.transformPoint(m); + cvf::Vec3d displayCoordsDouble = displayCoordTransform.transformToDisplayCoord(vd); + polygonInDisplayCoords.push_back(cvf::Vec3f(displayCoordsDouble)); } - if (containmentMaskPart.notNull()) - { - model->addPart(containmentMaskPart.p()); - } + return polygonInDisplayCoords; } //-------------------------------------------------------------------------------------------------- @@ -581,33 +974,3 @@ cvf::ref RivWellFracturePartMgr::buildDrawableGeoFromTriangles return geo; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool RivWellFracturePartMgr::stimPlanCellTouchesPolygon(const std::vector& polygon, - double xMin, double xMax, double yMin, double yMax, - float polygonXmin, float polygonXmax, float polygonYmin, float polygonYmax) -{ - - if (static_cast(xMin) > polygonXmin && static_cast(xMax) < polygonXmax) - { - if (static_cast(yMin) > polygonYmin && static_cast(yMax) < polygonYmax) - { - return true; - } - } - - for (cvf::Vec3f v : polygon) - { - if (v.x() > xMin && v.x() < xMax) - { - if (v.y() > yMin && v.y() < yMax) - { - return true; - } - } - } - - return false; -} - diff --git a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h index 7a0805400d..ca1d41b1c2 100644 --- a/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellFracturePartMgr.h @@ -25,13 +25,16 @@ #include "cafPdmPointer.h" +#include #include namespace cvf { - class ModelBasicList; - class DrawableGeo; - class Part; + class ModelBasicList; + class DrawableGeo; + class Part; + class Color3f; + class ScalarMapper; } namespace caf @@ -40,8 +43,10 @@ namespace caf } class RimFracture; +class RimFractureTemplate; class RimStimPlanFractureTemplate; class RimEclipseView; +class RigFractureCell; //-------------------------------------------------------------------------------------------------- /// @@ -54,33 +59,37 @@ class RivWellFracturePartMgr : public cvf::Object void appendGeometryPartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView); - static std::vector mirrorDataAtSingleDepth(std::vector depthData); + const QString resultInfoText(const RimEclipseView& activeView, cvf::Vec3d domainIntersectionPoint) const; + + const RigFractureCell* getFractureCellAtDomainCoord(cvf::Vec3d domainCoord) const; private: cvf::ref createEllipseSurfacePart(const RimEclipseView& activeView); - cvf::ref createStimPlanSurfacePart(const RimEclipseView& activeView); + cvf::ref createStimPlanColorInterpolatedSurfacePart(const RimEclipseView& activeView); + + cvf::ref createSingleColorSurfacePart(const std::vector& triangleIndices, const std::vector& nodeCoords, const cvf::Color3f& color); + + cvf::ref createStimPlanElementColorSurfacePart(const RimEclipseView& activeView); cvf::ref createContainmentMaskPart(const RimEclipseView& activeView); + + void appendFracturePerforationLengthParts(const RimEclipseView& activeView, cvf::ModelBasicList* model); cvf::ref createStimPlanMeshPart(const RimEclipseView& activeView); - cvf::ref createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView) const; + cvf::ref createStimPlanMeshDrawable(RimStimPlanFractureTemplate* stimPlanFracTemplate, const RimEclipseView& activeView); - static std::vector transformToFractureDisplayCoords(const std::vector& polygon, + std::vector fractureBorderPolygon(); + + static cvf::ref createScalarMapperPart(cvf::DrawableGeo* drawableGeo, const cvf::ScalarMapper* scalarMapper, RimFracture* fracture, bool disableLighting); + + static std::vector transformToFractureDisplayCoords(const std::vector& polygon, cvf::Mat4d m, const caf::DisplayCoordTransform& displayCoordTransform); - static bool stimPlanCellTouchesPolygon(const std::vector& polygon, - double xMin, - double xMax, - double yMin, - double yMax, - float polygonXmin, - float polygonXmax, - float polygonYmin, - float polygonYmax); - static cvf::ref buildDrawableGeoFromTriangles(const std::vector& triangleIndices, const std::vector& nodeCoords); private: - caf::PdmPointer m_rimFracture; + caf::PdmPointer m_rimFracture; + + std::vector> m_visibleFracturePolygons; }; diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp index f2e91fdc4c..21c5404f3c 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.cpp @@ -50,16 +50,16 @@ #include "cvfTransform.h" #include "cvfqtUtils.h" #include "cafDisplayCoordTransform.h" +#include "RivSectionFlattner.h" //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellHeadPartMgr::RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well) +RivWellHeadPartMgr::RivWellHeadPartMgr(RimSimWellInView* well) +: m_rimWell(well) { - m_rimReservoirView = reservoirView; - m_rimWell = well; } //-------------------------------------------------------------------------------------------------- @@ -73,36 +73,48 @@ RivWellHeadPartMgr::~RivWellHeadPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) +void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex, + const caf::DisplayCoordTransform * displayXf, + bool doFlatten, + double xOffset) { clearAllGeometry(); - if (m_rimReservoirView.isNull()) return; + if (!viewWithSettings()) return; - RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData(); - RimSimWellInView* well = m_rimWell; - double characteristicCellSize = rigReservoir->mainGrid()->characteristicIJCellSize(); + double characteristicCellSize = viewWithSettings()->ownerCase()->characteristicCellSize(); cvf::Vec3d whEndPos; cvf::Vec3d whStartPos; { - well->wellHeadTopBottomPosition(frameIndex, &whEndPos, &whStartPos); + well->wellHeadTopBottomPosition(static_cast(frameIndex), &whEndPos, &whStartPos); - cvf::ref transForm = m_rimReservoirView->displayCoordTransform(); - whEndPos = transForm->transformToDisplayCoord(whEndPos); - whStartPos = transForm->transformToDisplayCoord(whStartPos); - whEndPos.z() += characteristicCellSize; + if (doFlatten) + { + whEndPos.x() = xOffset; + whEndPos.y() = 0.0; + whStartPos.x() = xOffset; + whStartPos.y() = 0.0; + whEndPos = displayXf->scaleToDisplaySize(whEndPos); + whStartPos = displayXf->scaleToDisplaySize(whStartPos); + whEndPos.z() += characteristicCellSize; + } + else + { + whEndPos = displayXf->transformToDisplayCoord(whEndPos); + whStartPos = displayXf->transformToDisplayCoord(whStartPos); + whEndPos.z() += characteristicCellSize; + } } - - if (!well->simWellData()->hasWellResult(frameIndex)) return; const RigWellResultFrame& wellResultFrame = well->simWellData()->wellResultFrame(frameIndex); double pipeRadius = m_rimWell->pipeRadius(); + int pipeCrossSectionVxCount = m_rimWell->pipeCrossSectionVertexCount(); if (wellResultFrame.m_isOpen) { @@ -125,8 +137,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) cvf::ref pipeGeomGenerator = new RivPipeGeometryGenerator; pipeGeomGenerator->setPipeCenterCoords(wellHeadPipeCoords.p()); - pipeGeomGenerator->setPipeColor(well->wellPipeColor()); - pipeGeomGenerator->setCrossSectionVertexCount(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); + pipeGeomGenerator->setCrossSectionVertexCount(pipeCrossSectionVxCount); pipeGeomGenerator->setRadius(pipeRadius); @@ -141,7 +152,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) part->setDrawable(pipeSurface.p()); caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(well->wellPipeColor()), caf::PO_1); - if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + if (viewWithSettings() && viewWithSettings()->isLightingDisabled()) { surfaceGen.enableLighting(false); } @@ -167,10 +178,12 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) part->setSourceInfo(sourceInfo.p()); m_wellHeadPipeCenterPart = part; + part->updateBoundingBox(); + CVF_ASSERT(part->boundingBox().isValid()); } } - double arrowLength = characteristicCellSize * m_rimReservoirView->wellCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor(); + double arrowLength = characteristicCellSize * simWellInViewCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor(); if (wellResultFrame.m_isOpen) { @@ -208,7 +221,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) gen.setShaftRelativeRadius(0.5f); gen.setHeadRelativeRadius(1.0f); gen.setHeadRelativeLength(0.4f); - gen.setNumSlices(m_rimReservoirView->wellCollection()->pipeCrossSectionVertexCount()); + gen.setNumSlices(pipeCrossSectionVxCount); gen.generate(&builder); cvf::ref vertices = builder.vertices(); @@ -269,7 +282,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) } caf::SurfaceEffectGenerator surfaceGen(headColor, caf::PO_1); - if (m_rimReservoirView && m_rimReservoirView->isLightingDisabled()) + if (viewWithSettings() && viewWithSettings()->isLightingDisabled()) { surfaceGen.enableLighting(false); } @@ -291,7 +304,7 @@ void RivWellHeadPartMgr::buildWellHeadParts(size_t frameIndex) drawableText->setDrawBorder(false); drawableText->setDrawBackground(false); drawableText->setVerticalAlignment(cvf::TextDrawer::CENTER); - drawableText->setTextColor(m_rimReservoirView->wellCollection()->wellLabelColor()); + drawableText->setTextColor(simWellInViewCollection()->wellLabelColor()); cvf::String cvfString = cvfqt::Utils::toString(m_rimWell->name()); @@ -326,18 +339,16 @@ void RivWellHeadPartMgr::clearAllGeometry() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex) +void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf) { - if (m_rimReservoirView.isNull()) return; if (m_rimWell.isNull()) return; - - RimSimWellInViewCollection* wellCollection = nullptr; - m_rimWell->firstAncestorOrThisOfType(wellCollection); - if (!wellCollection) return; + if (!viewWithSettings()) return; if (!m_rimWell->isWellPipeVisible(frameIndex)) return; - buildWellHeadParts(frameIndex); + buildWellHeadParts(frameIndex, displayXf, false, 0.0); // Always add pipe part of well head if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); @@ -356,4 +367,57 @@ void RivWellHeadPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellHeadPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf, + double xOffset) +{ + if (m_rimWell.isNull()) return; + if (!viewWithSettings()) return; + + if (!m_rimWell->isWellPipeVisible(frameIndex)) return; + + buildWellHeadParts(frameIndex, displayXf, true, xOffset); + + // Always add pipe part of well head + if (m_wellHeadPipeCenterPart.notNull()) model->addPart(m_wellHeadPipeCenterPart.p()); + if (m_wellHeadPipeSurfacePart.notNull()) model->addPart(m_wellHeadPipeSurfacePart.p()); + + if (m_rimWell->showWellLabel() && + m_wellHeadLabelPart.notNull()) + { + model->addPart(m_wellHeadLabelPart.p()); + } + + if (m_rimWell->showWellHead() && + m_wellHeadArrowPart.notNull()) + { + model->addPart(m_wellHeadArrowPart.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dView* RivWellHeadPartMgr::viewWithSettings() +{ + Rim3dView* view = nullptr; + if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(view); + + return view; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSimWellInViewCollection* RivWellHeadPartMgr::simWellInViewCollection() +{ + RimSimWellInViewCollection* wellCollection = nullptr; + if (m_rimWell) m_rimWell->firstAncestorOrThisOfType(wellCollection); + + return wellCollection; +} diff --git a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h index 6ac6ec3f44..c44ea15f6d 100644 --- a/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellHeadPartMgr.h @@ -30,32 +30,42 @@ namespace cvf class Transform; class Font; } +namespace caf +{ + class DisplayCoordTransform; +} -class RimEclipseView; +class Rim3dView; class RimSimWellInView; +class RimSimWellInViewCollection; class RivWellHeadPartMgr : public cvf::Object { public: - RivWellHeadPartMgr(RimEclipseView* reservoirView, RimSimWellInView* well); + RivWellHeadPartMgr( RimSimWellInView* well); ~RivWellHeadPartMgr(); - void setScaleTransform(cvf::Transform * scaleTransform) { m_scaleTransform = scaleTransform;} + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf); + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t frameIndex, + const caf::DisplayCoordTransform * displayXf, + double xOffset); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, size_t frameIndex); private: - void buildWellHeadParts(size_t frameIndex); - void clearAllGeometry(); - - + void buildWellHeadParts(size_t frameIndex, + const caf::DisplayCoordTransform * displayXf, + bool doFlatten, + double xOffset); + void clearAllGeometry(); + Rim3dView* viewWithSettings(); + RimSimWellInViewCollection* simWellInViewCollection(); private: - caf::PdmPointer m_rimReservoirView; caf::PdmPointer m_rimWell; - cvf::ref m_scaleTransform; - cvf::ref< cvf::Part > m_wellHeadArrowPart; cvf::ref< cvf::Part > m_wellHeadLabelPart; cvf::ref< cvf::Part > m_wellHeadPipeSurfacePart; diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp index 7c96a7cad9..4a45594996 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.cpp @@ -23,9 +23,12 @@ #include "RiaApplication.h" +#include "RigEclipseCaseData.h" #include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" +#include "Rim3dWellLogCurveCollection.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimFishboneWellPath.h" @@ -40,15 +43,18 @@ #include "RimWellPathFractureCollection.h" #include "RimWellPathFracture.h" +#include "Riv3dWellLogPlanePartMgr.h" #include "RivFishbonesSubsPartMgr.h" #include "RivObjectSourceInfo.h" #include "RivPartPriority.h" #include "RivPipeGeometryGenerator.h" -#include "RivWellPathSourceInfo.h" - -#include "RivPartPriority.h" +#include "RivSectionFlattner.h" +#include "RivWellConnectionFactorPartMgr.h" #include "RivWellFracturePartMgr.h" #include "RivWellPathPartMgr.h" +#include "RivWellPathSourceInfo.h" + +#include "RiuViewer.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" @@ -65,29 +71,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath) +RivWellPathPartMgr::RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view) { m_rimWellPath = wellPath; - - // Setup a scalar mapper - cvf::ref scalarMapper = new cvf::ScalarMapperDiscreteLinear; - cvf::Color3ubArray legendColors; - legendColors.resize(4); - legendColors[0] = cvf::Color3::GRAY; - legendColors[1] = cvf::Color3::GREEN; - legendColors[2] = cvf::Color3::BLUE; - legendColors[3] = cvf::Color3::RED; - scalarMapper->setColors(legendColors); - scalarMapper->setRange(0.0 , 4.0); - scalarMapper->setLevelCount(4, true); - - m_scalarMapper = scalarMapper; - - caf::ScalarMapperEffectGenerator surfEffGen(scalarMapper.p(), caf::PO_1); - m_scalarMapperSurfaceEffect = surfEffGen.generateCachedEffect(); - - caf::ScalarMapperMeshEffectGenerator meshEffGen(scalarMapper.p()); - m_scalarMapperMeshEffect = meshEffGen.generateCachedEffect(); + m_rimView = view; } //-------------------------------------------------------------------------------------------------- @@ -101,19 +88,60 @@ RivWellPathPartMgr::~RivWellPathPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const RimEclipseView& eclView) +bool RivWellPathPartMgr::isWellPathWithinBoundingBox(const cvf::BoundingBox& wellPathClipBoundingBox) const { + if (!m_rimWellPath->wellPathGeometry()) return false; + + const std::vector& wellpathCenterLine = m_rimWellPath->wellPathGeometry()->m_wellPathPoints; + if (wellpathCenterLine.size() < 2) return false; + + // Skip visualization if outside the domain of this case + { + cvf::Vec3d casemax = wellPathClipBoundingBox.max(); + cvf::Vec3d casemin = wellPathClipBoundingBox.min(); + cvf::Vec3d caseext = wellPathClipBoundingBox.extent(); + + // Add up to the sealevel + cvf::BoundingBox relevantWellpathBBox = wellPathClipBoundingBox; + relevantWellpathBBox.add(cvf::Vec3d(casemax.x(), casemax.y(), 0.0)); + + // Add some sideways leeway + + cvf::Vec3d addSize = 3.0*cvf::Vec3d(caseext.x(), caseext.y(), 0.0); + relevantWellpathBBox.add(casemax + addSize); + relevantWellpathBBox.add(casemin - addSize); + + if (!RigWellPath::isAnyPointInsideBoundingBox(wellpathCenterLine, relevantWellpathBBox)) + { + return false; + } + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (m_rimView.isNull()) return; + + const RimEclipseView* eclView = dynamic_cast(m_rimView.p()); + if (!eclView) return; + if (!m_rimWellPath || !m_rimWellPath->showWellPath() || !m_rimWellPath->fractureCollection()->isChecked()) return; + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + for (RimWellPathFracture* f : m_rimWellPath->fractureCollection()->fractures()) { CVF_ASSERT(f); - f->fracturePartManager()->appendGeometryPartsToModel(model, eclView); + f->fracturePartManager()->appendGeometryPartsToModel(model, *eclView); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -124,7 +152,7 @@ void RivWellPathPartMgr::appendFishboneSubsPartsToModel(cvf::ModelBasicList* mod { if ( !m_rimWellPath || !m_rimWellPath->fishbonesCollection()->isChecked() ) return; - for ( auto rimFishboneSubs : m_rimWellPath->fishbonesCollection()->fishbonesSubs() ) + for (const auto& rimFishboneSubs : m_rimWellPath->fishbonesCollection()->fishbonesSubs() ) { cvf::ref fishbSubPartMgr = new RivFishbonesSubsPartMgr(rimFishboneSubs); fishbSubPartMgr->appendGeometryPartsToModel(model, displayCoordTransform, characteristicCellSize); @@ -148,7 +176,7 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod if (!fbWellPath->isChecked()) continue; std::vector displayCoords; - for (auto lateralDomainCoords : fbWellPath->coordinates()) + for (const auto& lateralDomainCoords : fbWellPath->coordinates()) { displayCoords.push_back(displayCoordTransform->transformToDisplayCoord(lateralDomainCoords)); } @@ -171,10 +199,11 @@ void RivWellPathPartMgr::appendImportedFishbonesToModel(cvf::ModelBasicList* mod //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewDate, - cvf::ModelBasicList* model, +void RivWellPathPartMgr::appendPerforationsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize) + double characteristicCellSize, + bool doFlatten) { if (!m_rimWellPath || !m_rimWellPath->perforationIntervalCollection()->isChecked()) return; @@ -184,6 +213,22 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; + QDateTime currentTimeStamp; + if (m_rimView) + { + RimCase* rimCase = nullptr; + m_rimView->firstAncestorOrThisOfType(rimCase); + + if (rimCase) + { + std::vector timeStamps = rimCase->timeStepDates(); + if (timeStepIndex < timeStamps.size()) + { + currentTimeStamp = timeStamps[timeStepIndex]; + } + } + } + // Since we're using the index of measured depths to find the index of a point, ensure they're equal CVF_ASSERT(wellPathGeometry->m_measuredDepths.size() == wellPathGeometry->m_wellPathPoints.size()); @@ -195,23 +240,53 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD m_rimWellPath->descendantsIncludingThisOfType(perforations); for (RimPerforationInterval* perforation : perforations) { + using namespace std; + if (!perforation->isChecked()) continue; if (perforation->startMD() > perforation->endMD()) continue; - if (currentViewDate.isValid() && !perforation->isActiveOnDate(currentViewDate)) continue; + if (!perforation->isActiveOnDate(currentTimeStamp)) continue; + + double horizontalLengthAlongWellPath = 0.0; + vector perfIntervalCL; + { + pair, vector > perfintervalCoordsAndMD = wellPathGeometry->clippedPointSubset(perforation->startMD(), + perforation->endMD(), + &horizontalLengthAlongWellPath); + perfIntervalCL = perfintervalCoordsAndMD.first; + } - using namespace std; - pair, vector > displayCoordsAndMD = wellPathGeometry->clippedPointSubset(perforation->startMD(), - perforation->endMD()); - - if (displayCoordsAndMD.first.size() < 2) continue; + if (perfIntervalCL.size() < 2) continue; - for (cvf::Vec3d& point : displayCoordsAndMD.first) point = displayCoordTransform->transformToDisplayCoord(point); + + vector perfIntervalCLDiplayCS; + if ( doFlatten ) + { + cvf::Vec3d dummy; + vector flatningCSs = + RivSectionFlattner::calculateFlatteningCSsForPolyline(perfIntervalCL, + cvf::Vec3d::Z_AXIS, + { horizontalLengthAlongWellPath, 0.0, perfIntervalCL[0].z() }, + &dummy); + + for ( size_t cIdx = 0; cIdx < perfIntervalCL.size(); ++cIdx ) + { + auto clpoint = perfIntervalCL[cIdx].getTransformedPoint(flatningCSs[cIdx]); + perfIntervalCLDiplayCS.push_back( displayCoordTransform->scaleToDisplaySize(clpoint)); + } + } + else + { + for ( cvf::Vec3d& point : perfIntervalCL ) + { + perfIntervalCLDiplayCS.push_back( displayCoordTransform->transformToDisplayCoord(point)); + } + } cvf::ref objectSourceInfo = new RivObjectSourceInfo(perforation); cvf::Collection parts; - geoGenerator.cylinderWithCenterLineParts(&parts, displayCoordsAndMD.first, cvf::Color3f::GREEN, perforationRadius); + geoGenerator.cylinderWithCenterLineParts(&parts, perfIntervalCLDiplayCS, cvf::Color3f::GREEN, perforationRadius); for (auto part : parts) { part->setSourceInfo(objectSourceInfo.p()); @@ -220,12 +295,39 @@ void RivWellPathPartMgr::appendPerforationsToModel(const QDateTime& currentViewD } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize) +{ + RimEclipseView* eclView = dynamic_cast(m_rimView.p()); + if (!eclView) return; + + if (!eclView->isVirtualConnectionFactorGeometryVisible()) return; + + RimEclipseCase* eclipseCase = nullptr; + eclView->firstAncestorOrThisOfType(eclipseCase); + if (!eclipseCase) return; + + const RigVirtualPerforationTransmissibilities* trans = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (trans) + { + m_wellConnectionFactorPartMgr = new RivWellConnectionFactorPartMgr(m_rimWellPath, eclView->virtualPerforationResult()); + + m_wellConnectionFactorPartMgr->appendDynamicGeometryPartsToModel(model, timeStepIndex); + } +} + //-------------------------------------------------------------------------------------------------- /// The pipe geometry needs to be rebuilt on scale change to keep the pipes round //-------------------------------------------------------------------------------------------------- void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox) + const cvf::BoundingBox& wellPathClipBoundingBox, + bool doFlatten) { RimWellPathCollection* wellPathCollection = this->wellPathCollection(); if (!wellPathCollection) return; @@ -233,117 +335,102 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di RigWellPath* wellPathGeometry = m_rimWellPath->wellPathGeometry(); if (!wellPathGeometry) return; - if (wellPathGeometry->m_wellPathPoints.size() < 2) return; + const std::vector& wellpathCenterLine = wellPathGeometry->m_wellPathPoints; + + if (wellpathCenterLine.size() < 2) return; clearAllBranchData(); + double wellPathRadius = this->wellPathRadius(characteristicCellSize, wellPathCollection); - cvf::Vec3d textPosition; + std::vector clippedWellPathCenterLine; // Generate the well path geometry as a line and pipe structure - { - RivPipeBranchData& pbd = m_pipeBranchData; - - pbd.m_pipeGeomGenerator = new RivPipeGeometryGenerator; - pbd.m_pipeGeomGenerator->setRadius(wellPathRadius); - pbd.m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); - pbd.m_pipeGeomGenerator->setPipeColor( m_rimWellPath->wellPathColor()); + m_pipeGeomGenerator = new RivPipeGeometryGenerator; - cvf::ref cvfCoords = new cvf::Vec3dArray; - if (wellPathCollection->wellPathClip) - { - size_t firstVisibleSegmentIndex = cvf::UNDEFINED_SIZE_T; - for (size_t idx = 0; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) - { - cvf::Vec3d point = wellPathGeometry->m_wellPathPoints[idx]; - if (point.z() < (wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance)) - { - firstVisibleSegmentIndex = idx; - break; - } - } + m_pipeGeomGenerator->setRadius(wellPathRadius); + m_pipeGeomGenerator->setCrossSectionVertexCount(wellPathCollection->wellPathCrossSectionVertexCount()); - std::vector clippedPoints; + double horizontalLengthAlongWellToClipPoint = 0.0; + size_t idxToFirstVisibleSegment = 0; + if ( wellPathCollection->wellPathClip ) + { + double maxZClipHeight = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; + clippedWellPathCenterLine = RigWellPath::clipPolylineStartAboveZ(wellpathCenterLine, + maxZClipHeight, + &horizontalLengthAlongWellToClipPoint, + &idxToFirstVisibleSegment); + } + else + { + clippedWellPathCenterLine = wellpathCenterLine; + } - if (firstVisibleSegmentIndex != cvf::UNDEFINED_SIZE_T) - { - if (firstVisibleSegmentIndex > 0) - { - double wellPathStartPoint = wellPathClipBoundingBox.max().z() + wellPathCollection->wellPathClipZDistance; - double stepsize = (wellPathStartPoint - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()) / - (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex].z() - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1].z()); - - cvf::Vec3d newPoint = wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1] + - stepsize * (wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex] - wellPathGeometry->m_wellPathPoints[firstVisibleSegmentIndex - 1]); - - clippedPoints.push_back(newPoint); - pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex - 1); - } - else - { - pbd.m_pipeGeomGenerator->setFirstVisibleSegmentIndex(firstVisibleSegmentIndex); - } - - for (size_t idx = firstVisibleSegmentIndex; idx < wellPathGeometry->m_wellPathPoints.size(); idx++) - { - clippedPoints.push_back(wellPathGeometry->m_wellPathPoints[idx]); - } + if ( clippedWellPathCenterLine.size() < 2 ) return; - } + cvf::ref cvfCoords = new cvf::Vec3dArray(clippedWellPathCenterLine.size()); - if (clippedPoints.size() < 2) return; + // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - cvfCoords->assign(clippedPoints); - } - else + if ( doFlatten ) + { + cvf::Vec3d dummy; + std::vector flatningCSs = + RivSectionFlattner::calculateFlatteningCSsForPolyline(clippedWellPathCenterLine, + cvf::Vec3d::Z_AXIS, + { horizontalLengthAlongWellToClipPoint, 0.0, clippedWellPathCenterLine[0].z() }, + &dummy); + + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) { - cvfCoords->assign(wellPathGeometry->m_wellPathPoints); + auto clpoint = clippedWellPathCenterLine[cIdx].getTransformedPoint(flatningCSs[cIdx]); + (*cvfCoords)[cIdx] = displayCoordTransform->scaleToDisplaySize(clpoint); } - - // Scale the centerline coordinates using the Z-scale transform of the grid and correct for the display offset. - for (size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx) + } + else + { + for ( size_t cIdx = 0; cIdx < cvfCoords->size(); ++cIdx ) { - (*cvfCoords)[cIdx] = displayCoordTransform->transformToDisplayCoord((*cvfCoords)[cIdx]); + (*cvfCoords)[cIdx] = displayCoordTransform->transformToDisplayCoord(clippedWellPathCenterLine[cIdx]); } + } - textPosition = cvfCoords->get(0); + m_pipeGeomGenerator->setFirstVisibleSegmentIndex(idxToFirstVisibleSegment); + m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); + m_surfaceDrawable = m_pipeGeomGenerator->createPipeSurface(); + m_centerLineDrawable = m_pipeGeomGenerator->createCenterLine(); - pbd.m_pipeGeomGenerator->setPipeCenterCoords(cvfCoords.p()); - pbd.m_surfaceDrawable = pbd.m_pipeGeomGenerator->createPipeSurface(); - pbd.m_centerLineDrawable = pbd.m_pipeGeomGenerator->createCenterLine(); + if ( m_surfaceDrawable.notNull() ) + { + m_surfacePart = new cvf::Part; + m_surfacePart->setDrawable(m_surfaceDrawable.p()); - if (pbd.m_surfaceDrawable.notNull()) - { - pbd.m_surfacePart = new cvf::Part; - pbd.m_surfacePart->setDrawable(pbd.m_surfaceDrawable.p()); - - RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath); - pbd.m_surfacePart->setSourceInfo(sourceInfo); + RivWellPathSourceInfo* sourceInfo = new RivWellPathSourceInfo(m_rimWellPath, m_pipeGeomGenerator.p()); + m_surfacePart->setSourceInfo(sourceInfo); - caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); - cvf::ref eff = surfaceGen.generateCachedEffect(); + caf::SurfaceEffectGenerator surfaceGen(cvf::Color4f(m_rimWellPath->wellPathColor()), caf::PO_1); + cvf::ref eff = surfaceGen.generateCachedEffect(); - pbd.m_surfacePart->setEffect(eff.p()); - } + m_surfacePart->setEffect(eff.p()); + } - if (pbd.m_centerLineDrawable.notNull()) - { - pbd.m_centerLinePart = new cvf::Part; - pbd.m_centerLinePart->setDrawable(pbd.m_centerLineDrawable.p()); + if ( m_centerLineDrawable.notNull() ) + { + m_centerLinePart = new cvf::Part; + m_centerLinePart->setDrawable(m_centerLineDrawable.p()); - caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor()); - cvf::ref eff = gen.generateCachedEffect(); + caf::MeshEffectGenerator gen(m_rimWellPath->wellPathColor()); + cvf::ref eff = gen.generateCachedEffect(); - pbd.m_centerLinePart->setEffect(eff.p()); - } + m_centerLinePart->setEffect(eff.p()); } // Generate label with well-path name + cvf::Vec3d textPosition = cvfCoords->get(0); textPosition.z() += 2.2 * characteristicCellSize; - m_wellLabelPart = NULL; if (wellPathCollection->showWellPathLabel() && m_rimWellPath->showWellPathLabel() && !m_rimWellPath->name().isEmpty()) { cvf::Font* font = RiaApplication::instance()->customFont(); @@ -379,10 +466,10 @@ void RivWellPathPartMgr::buildWellPathParts(const caf::DisplayCoordTransform* di //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) +void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) { RimWellPathCollection* wellPathCollection = this->wellPathCollection(); if (!wellPathCollection) return; @@ -393,17 +480,19 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m if (wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false ) return; + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + // The pipe geometry needs to be rebuilt on scale change to keep the pipes round - buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); + buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, false); - if (m_pipeBranchData.m_surfacePart.notNull()) + if (m_surfacePart.notNull()) { - model->addPart(m_pipeBranchData.m_surfacePart.p()); + model->addPart(m_surfacePart.p()); } - if (m_pipeBranchData.m_centerLinePart.notNull()) + if (m_centerLinePart.notNull()) { - model->addPart(m_pipeBranchData.m_centerLinePart.p()); + model->addPart(m_centerLinePart.p()); } if (m_wellLabelPart.notNull()) @@ -413,16 +502,51 @@ void RivWellPathPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* m appendFishboneSubsPartsToModel(model, displayCoordTransform, characteristicCellSize); appendImportedFishbonesToModel(model, displayCoordTransform, characteristicCellSize); + + RimGridView* gridView = dynamic_cast(m_rimView.p()); + if (!gridView) return; + + m_3dWellLogPlanePartMgr = new Riv3dWellLogPlanePartMgr(m_rimWellPath, gridView); + m_3dWellLogPlanePartMgr->appendPlaneToModel(model, displayCoordTransform, wellPathClipBoundingBox); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) +void RivWellPathPartMgr::appendFlattenedStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + + // The pipe geometry needs to be rebuilt on scale change to keep the pipes round + buildWellPathParts(displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox, true); + + if (m_surfacePart.notNull()) + { + model->addPart(m_surfacePart.p()); + } + + if (m_centerLinePart.notNull()) + { + model->addPart(m_centerLinePart.p()); + } + + if (m_wellLabelPart.notNull()) + { + model->addPart(m_wellLabelPart.p()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) { CVF_ASSERT(model); @@ -431,33 +555,51 @@ void RivWellPathPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* if (m_rimWellPath.isNull()) return; - if (wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) - return; + if (wellPathCollection->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; if (wellPathCollection->wellPathVisibility() != RimWellPathCollection::FORCE_ALL_ON && m_rimWellPath->showWellPath() == false) + { return; + } - appendPerforationsToModel(timeStamp, model, displayCoordTransform, characteristicCellSize); + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, false); + appendVirtualTransmissibilitiesToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RivWellPathPartMgr::clearAllBranchData() +void RivWellPathPartMgr::appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) { - m_pipeBranchData.m_pipeGeomGenerator = NULL; - m_pipeBranchData.m_surfacePart = NULL; - m_pipeBranchData.m_surfaceDrawable = NULL; - m_pipeBranchData.m_centerLinePart = NULL; - m_pipeBranchData.m_centerLineDrawable = NULL; + CVF_ASSERT(model); + + RimWellPathCollection* wellPathCollection = this->wellPathCollection(); + if (!wellPathCollection) return; + + if (m_rimWellPath.isNull()) return; + + if (!isWellPathWithinBoundingBox(wellPathClipBoundingBox)) return; + + appendPerforationsToModel(model, timeStepIndex, displayCoordTransform, characteristicCellSize, true); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -size_t RivWellPathPartMgr::segmentIndexFromTriangleIndex(size_t triangleIndex) +void RivWellPathPartMgr::clearAllBranchData() { - return m_pipeBranchData.m_pipeGeomGenerator->segmentIndexFromTriangleIndex(triangleIndex); + m_pipeGeomGenerator = nullptr; + m_surfacePart = nullptr; + m_surfaceDrawable = nullptr; + m_centerLinePart = nullptr; + m_centerLineDrawable = nullptr; + m_wellLabelPart = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h index e6da91630a..39195027a2 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h +++ b/ApplicationCode/ModelVisualization/RivWellPathPartMgr.h @@ -44,74 +44,88 @@ class RimProject; class RimWellPath; class RivFishbonesSubsPartMgr; class RimWellPathCollection; -class RimEclipseView; +class Rim3dView; +class Riv3dWellLogPlanePartMgr; +class RivWellConnectionFactorPartMgr; class QDateTime; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RivWellPathPartMgr : public cvf::Object { public: - explicit RivWellPathPartMgr(RimWellPath* wellPath); + explicit RivWellPathPartMgr(RimWellPath* wellPath, Rim3dView* view); ~RivWellPathPartMgr(); - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + void appendFlattenedStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); - size_t segmentIndexFromTriangleIndex(size_t triangleIndex); + void appendFlattenedDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const cvf::BoundingBox& wellPathClipBoundingBox); private: - void appendFishboneSubsPartsToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendFishboneSubsPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); + + void appendImportedFishbonesToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); - void appendImportedFishbonesToModel(cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendPerforationsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + bool doFlatten); - void appendPerforationsToModel(const QDateTime& currentViewDate, - cvf::ModelBasicList* model, - const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize); + void appendVirtualTransmissibilitiesToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize); + void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox, + bool doFlatten); - void buildWellPathParts(const caf::DisplayCoordTransform* displayCoordTransform, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox); void clearAllBranchData(); inline RimWellPathCollection* wellPathCollection(); inline double wellPathRadius(double characteristicCellSize, RimWellPathCollection* wellPathCollection); + bool isWellPathWithinBoundingBox(const cvf::BoundingBox& wellPathClipBoundingBox) const; + private: - caf::PdmPointer m_rimWellPath; + caf::PdmPointer m_rimWellPath; + caf::PdmPointer m_rimView; - struct RivPipeBranchData - { - cvf::ref m_pipeGeomGenerator; - cvf::ref m_surfacePart; - cvf::ref m_surfaceDrawable; - cvf::ref m_centerLinePart; - cvf::ref m_centerLineDrawable; - }; - - RivPipeBranchData m_pipeBranchData; - cvf::ref m_wellLabelPart; - - cvf::ref m_scalarMapper; - cvf::ref m_scalarMapperSurfaceEffect; - cvf::ref m_scalarMapperMeshEffect; - + cvf::ref m_pipeGeomGenerator; + cvf::ref m_surfacePart; + cvf::ref m_surfaceDrawable; + cvf::ref m_centerLinePart; + cvf::ref m_centerLineDrawable; + cvf::ref m_wellLabelPart; + + cvf::ref m_3dWellLogPlanePartMgr; + cvf::ref m_wellConnectionFactorPartMgr; }; diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp index 41b008e230..1890ad3b90 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.cpp @@ -23,6 +23,9 @@ #include "RimCase.h" #include "RimWellPath.h" +#include "Rim3dView.h" +#include "RivPipeGeometryGenerator.h" + #include "RimWellPathCollection.h" #include "RivWellPathPartMgr.h" @@ -32,9 +35,19 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath) +RivWellPathSourceInfo::RivWellPathSourceInfo(RimWellPath* wellPath, RivPipeGeometryGenerator* pipeGeomGenerator) + : m_wellPath(wellPath) + , m_pipeGeomGenerator(pipeGeomGenerator) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellPathSourceInfo::~RivWellPathSourceInfo() { - m_wellPath = wellPath; + } //-------------------------------------------------------------------------------------------------- @@ -64,7 +77,7 @@ double RivWellPathSourceInfo::measuredDepth(size_t triangleIndex, const cvf::Vec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RivWellPathSourceInfo::trueVerticalDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const +cvf::Vec3d RivWellPathSourceInfo::closestPointOnCenterLine(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const { size_t firstSegmentIndex = cvf::UNDEFINED_SIZE_T; double norm = 0.0; @@ -103,6 +116,6 @@ void RivWellPathSourceInfo::normalizedIntersection(size_t triangleIndex, const c //-------------------------------------------------------------------------------------------------- size_t RivWellPathSourceInfo::segmentIndex(size_t triangleIndex) const { - return m_wellPath->partMgr()->segmentIndexFromTriangleIndex(triangleIndex); + return m_pipeGeomGenerator->segmentIndexFromTriangleIndex( triangleIndex); } diff --git a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h index 6bb3935cdf..563a1613a8 100644 --- a/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h +++ b/ApplicationCode/ModelVisualization/RivWellPathSourceInfo.h @@ -26,6 +26,7 @@ #include "cvfVector3.h" class RimWellPath; +class RivPipeGeometryGenerator; //================================================================================================== /// @@ -33,18 +34,22 @@ class RimWellPath; class RivWellPathSourceInfo : public cvf::Object { public: - explicit RivWellPathSourceInfo(RimWellPath* wellPath); + explicit RivWellPathSourceInfo(RimWellPath* wellPath, RivPipeGeometryGenerator* pipeGeomGenerator); + ~RivWellPathSourceInfo(); RimWellPath* wellPath() const; size_t segmentIndex(size_t triangleIndex) const; double measuredDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const; - cvf::Vec3d trueVerticalDepth(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const; + cvf::Vec3d closestPointOnCenterLine(size_t triangleIndex, const cvf::Vec3d& globalIntersection) const; private: - void normalizedIntersection(size_t triangleIndex, const cvf::Vec3d& globalIntersection, - size_t* firstSegmentIndex, double* normalizedSegmentIntersection) const; + void normalizedIntersection(size_t triangleIndex, + const cvf::Vec3d& globalIntersection, + size_t* firstSegmentIndex, + double* normalizedSegmentIntersection) const; private: caf::PdmPointer m_wellPath; + cvf::ref m_pipeGeomGenerator; }; diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp new file mode 100644 index 0000000000..38cac4d069 --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.cpp @@ -0,0 +1,153 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RivWellPathsPartMgr.h" + +#include "RiaApplication.h" + +#include "RimEclipseView.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimWellPathCollection.h" + +#include "RivWellPathPartMgr.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellPathsPartMgr::RivWellPathsPartMgr(Rim3dView* view) + : m_rimView(view) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWellPathsPartMgr::~RivWellPathsPartMgr() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!isWellPathVisible()) return; + + createPartManagersIfRequired(); + + for (auto& partMgr : m_wellPathsPartMgrs) + { + partMgr->appendStaticGeometryPartsToModel(model, displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!isWellPathVisible()) return; + + createPartManagersIfRequired(); + + for (auto& partMgr : m_wellPathsPartMgrs) + { + partMgr->appendStaticFracturePartsToModel(model, wellPathClipBoundingBox); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox) +{ + if (!isWellPathVisible()) return; + + createPartManagersIfRequired(); + + for (auto& partMgr : m_wellPathsPartMgrs) + { + partMgr->appendDynamicGeometryPartsToModel( + model, timeStepIndex, displayCoordTransform, characteristicCellSize, wellPathClipBoundingBox); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::clearGeometryCache() +{ + m_wellPathsPartMgrs.clear(); + m_mapFromViewToIndex.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::scheduleGeometryRegen() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWellPathsPartMgr::createPartManagersIfRequired() +{ + RimProject* proj = RiaApplication::instance()->project(); + auto wellPaths = proj->allWellPaths(); + + if (m_wellPathsPartMgrs.size() != wellPaths.size()) + { + clearGeometryCache(); + + for (auto wellPath : wellPaths) + { + RivWellPathPartMgr* wppm = new RivWellPathPartMgr(wellPath, m_rimView); + m_wellPathsPartMgrs.push_back(wppm); + m_mapFromViewToIndex[wellPath] = wppm; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellPathCollection* RivWellPathsPartMgr::wellPathCollection() const +{ + RimProject* proj = RiaApplication::instance()->project(); + + return proj->activeOilField()->wellPathCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivWellPathsPartMgr::isWellPathVisible() const +{ + auto wellPathColl = wellPathCollection(); + + if (!wellPathColl->isActive()) return false; + if (wellPathColl->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return false; + + return true; +} diff --git a/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h new file mode 100644 index 0000000000..c3dbd73d8c --- /dev/null +++ b/ApplicationCode/ModelVisualization/RivWellPathsPartMgr.h @@ -0,0 +1,82 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfCollection.h" +#include "cvfObject.h" + +#include "cafPdmPointer.h" + +#include + +#include + +namespace cvf +{ +class BoundingBox; +class Transform; +class ModelBasicList; +} // namespace cvf + +namespace caf +{ +class DisplayCoordTransform; +} + +class Rim3dView; +class RivWellPathPartMgr; +class RimWellPathCollection; +class RimWellPath; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RivWellPathsPartMgr : public cvf::Object +{ +public: + explicit RivWellPathsPartMgr(Rim3dView* view); + ~RivWellPathsPartMgr(); + + void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + + + void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, + size_t timeStepIndex, + const caf::DisplayCoordTransform* displayCoordTransform, + double characteristicCellSize, + const cvf::BoundingBox& wellPathClipBoundingBox); + + void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, const cvf::BoundingBox& wellPathClipBoundingBox); + +private: + void clearGeometryCache(); + void scheduleGeometryRegen(); + void createPartManagersIfRequired(); + RimWellPathCollection* wellPathCollection() const; + bool isWellPathVisible() const; + +private: + caf::PdmPointer m_rimView; + cvf::Collection m_wellPathsPartMgrs; + std::map m_mapFromViewToIndex; +}; diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake new file mode 100644 index 0000000000..37eb426653 --- /dev/null +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/CMakeLists_files.cmake @@ -0,0 +1,19 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RivWindowEdgeAxesOverlayItem.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RivWindowEdgeAxesOverlayItem.cpp + +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "ModelVisualization\\WindowEdgeAxesOverlayItem" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp new file mode 100644 index 0000000000..666ccd0cf8 --- /dev/null +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.cpp @@ -0,0 +1,616 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RivWindowEdgeAxesOverlayItem.h" + +#include "cvfBase.h" +#include "cvfOpenGL.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfGeometryBuilderDrawableGeo.h" +#include "cvfGeometryUtils.h" +#include "cvfViewport.h" +#include "cvfCamera.h" +#include "cvfTextDrawer.h" +#include "cvfFont.h" +#include "cvfShaderProgram.h" +#include "cvfShaderProgramGenerator.h" +#include "cvfShaderSourceProvider.h" +#include "cvfShaderSourceRepository.h" +#include "cvfUniform.h" +#include "cvfMatrixState.h" +#include "cvfBufferObjectManaged.h" +#include "cvfGlyph.h" +#include "cvfRenderStateDepth.h" +#include "cvfRenderStateLine.h" + +#ifndef CVF_OPENGL_ES +#include "cvfRenderState_FF.h" +#endif + +#include "cvfScalarMapper.h" +#include "cvfRenderStateBlending.h" +#include "cafTickMarkGenerator.h" +#include + +using namespace cvf; + + +//================================================================================================== +/// +/// \class cvf::OverlayColorLegend +/// \ingroup Render +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// Constructor +//-------------------------------------------------------------------------------------------------- +RivWindowEdgeAxesOverlayItem::RivWindowEdgeAxesOverlayItem(Font* font) +: m_windowSize(600, 600), + m_textColor(Color3::BLACK), + m_lineColor(Color3::BLACK), + m_frameColor(Color3::WHITE), + m_lineWidth(1), + m_font(font), + m_isSwitchingYAxisValueSign(true) +{ + CVF_ASSERT(font); + CVF_ASSERT(!font->isEmpty()); + + setLayoutFixedPosition({0,0}); + updateGeomerySizes(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RivWindowEdgeAxesOverlayItem::~RivWindowEdgeAxesOverlayItem() +{ +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::setDisplayCoordTransform(const caf::DisplayCoordTransform* displayCoordTransform) +{ + m_dispalyCoordsTransform = displayCoordTransform; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::updateGeomerySizes() +{ + String str = String::number(99999.0); + m_textSize = m_font->textExtent(str); + m_pixelSpacing = 2.0f; + m_tickLineLength = m_textSize.y() *0.3f; + m_frameBorderHeight = m_pixelSpacing + m_textSize.y() + m_pixelSpacing + m_tickLineLength + m_lineWidth; + m_frameBorderWidth = m_pixelSpacing + m_textSize.x() + m_pixelSpacing + m_tickLineLength + m_lineWidth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::updateFromCamera(const Camera* camera) +{ + if (!camera || camera->projection() != Camera::ORTHO ) + { + m_domainCoordsXValues.clear(); + m_domainCoordsYValues.clear(); + m_windowTickXValues.clear(); + m_windowTickYValues.clear(); + + return; + } + + m_windowSize = Vec2ui( camera->viewport()->width(), camera->viewport()->height()); + Vec3d windowOrigoInDomain; + Vec3d windowMaxInDomain; + camera->unproject(Vec3d(0,0,0), &windowOrigoInDomain ); + camera->unproject(Vec3d(m_windowSize.x(),m_windowSize.y(),0), &windowMaxInDomain ); + + if (m_dispalyCoordsTransform.notNull()) + { + windowOrigoInDomain = m_dispalyCoordsTransform->transformToDomainCoord(windowOrigoInDomain); + windowMaxInDomain = m_dispalyCoordsTransform->transformToDomainCoord(windowMaxInDomain); + } + + double domainMinX = windowOrigoInDomain.x(); + double domainMaxX = windowMaxInDomain.x(); + + double domainMinY = windowOrigoInDomain.z(); + double domainMaxY = windowMaxInDomain.z(); + + int xTickMaxCount = m_windowSize.x()/(2*m_textSize.x()); + int yTickMaxCount = m_windowSize.y()/(2*m_textSize.x()); + + double minDomainXStepSize = (domainMaxX - domainMinX)/xTickMaxCount; + caf::TickMarkGenerator xTickCreator(domainMinX, domainMaxX, minDomainXStepSize); + m_domainCoordsXValues = xTickCreator.tickMarkValues(); + + double minDomainYStepSize = (domainMaxY - domainMinY)/yTickMaxCount; + caf::TickMarkGenerator yTickCreator(domainMinY, domainMaxY, minDomainYStepSize); + m_domainCoordsYValues = yTickCreator.tickMarkValues(); + + + m_windowTickXValues.clear(); + Vec3d windowPoint; + for (double domainX : m_domainCoordsXValues) + { + Vec3d displayDomainTick(domainX, 0, domainMinY); + if ( m_dispalyCoordsTransform.notNull() ) + { + displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord(displayDomainTick); + } + camera->project(displayDomainTick, &windowPoint); + m_windowTickXValues.push_back(windowPoint.x()); + } + + m_windowTickYValues.clear(); + for (double domainY : m_domainCoordsYValues) + { + Vec3d displayDomainTick(domainMinX, 0, domainY); + if ( m_dispalyCoordsTransform.notNull() ) + { + displayDomainTick = m_dispalyCoordsTransform->transformToDisplayCoord(displayDomainTick); + } + camera->project(displayDomainTick, &windowPoint); + m_windowTickYValues.push_back(windowPoint.y()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui RivWindowEdgeAxesOverlayItem::sizeHint() +{ + return m_windowSize; +} + +//-------------------------------------------------------------------------------------------------- +/// Set color of the text and lines to be rendered +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::setTextColor(const Color3f& color) +{ + m_textColor = color; +} + + +//-------------------------------------------------------------------------------------------------- +/// Returns the color of the text and lines +//-------------------------------------------------------------------------------------------------- +const Color3f& RivWindowEdgeAxesOverlayItem::textColor() const +{ + return m_textColor; +} + +//-------------------------------------------------------------------------------------------------- +/// Hardware rendering using shader programs +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + renderGeneric(oglContext, position, size, false); +} + + +//-------------------------------------------------------------------------------------------------- +/// Software rendering using software +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + renderGeneric(oglContext, position, size, true); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RivWindowEdgeAxesOverlayItem::pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) +{ + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set up camera/viewport and render +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +{ + if (size.x() <= 0 || size.y() <= 0 + || (m_windowTickXValues.size() == 0 && m_windowTickYValues.size() == 0 ) ) + { + return; + } + + Camera camera; + camera.setViewport(position.x(), position.y(), size.x(), size.y()); + camera.setProjectionAsPixelExact2D(); + camera.setViewMatrix(Mat4d::IDENTITY); + camera.applyOpenGL(); + camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); + + TextDrawer textDrawer(m_font.p()); + addTextToTextDrawer(&textDrawer); + + + if (software) + { + renderSoftwareFrameAndTickLines(oglContext); + textDrawer.renderSoftware(oglContext, camera); + } + else + { + const MatrixState matrixState(camera); + renderShaderFrameAndTickLines(oglContext, matrixState); + + textDrawer.render(oglContext, camera); + } + + CVF_CHECK_OGL(oglContext); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::addTextToTextDrawer(TextDrawer* textDrawer) +{ + textDrawer->setVerticalAlignment(TextDrawer::CENTER); + textDrawer->setTextColor(m_textColor); + + // Bottom X - axis text + { + const float textYTop = m_windowSize.y() - m_pixelSpacing - m_textSize.y()*0.5f; + const float textYBott = m_pixelSpacing + m_textSize.y()*0.5f; + + size_t numTicks = m_domainCoordsXValues.size(); + size_t i; + for ( i = 0; i < numTicks; i++ ) + { + float textX = static_cast(m_windowTickXValues[i]); + + double tickValue = m_domainCoordsXValues[i]; + String valueString; + + valueString = String::number(tickValue); + auto labelSize = m_font->textExtent(valueString); + + Vec2f pos(textX - labelSize.x()*0.5f, textYBott); + textDrawer->addText(valueString, pos); + pos[1] = textYTop; + textDrawer->addText(valueString, pos); + } + } + + // Right Y - axis texts + { + const float textXRight = m_windowSize.x() - m_pixelSpacing - m_textSize.x(); + const float textXLeft = m_frameBorderWidth - m_tickLineLength - m_pixelSpacing; + + size_t numTicks = m_domainCoordsYValues.size(); + size_t i; + for ( i = 0; i < numTicks; i++ ) + { + float textY = static_cast(m_windowTickYValues[i]); + + double tickValue = m_isSwitchingYAxisValueSign ? -m_domainCoordsYValues[i]: m_domainCoordsYValues[i]; + String valueString; + + valueString = String::number(tickValue); + auto labelSize = m_font->textExtent(valueString); + + Vec2f pos(textXRight, textY); + textDrawer->addText(valueString, pos); + Vec2f posl(textXLeft - labelSize.x(), textY); + textDrawer->addText(valueString, posl); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::array RivWindowEdgeAxesOverlayItem::frameVertexArray() +{ + float windowWidth = static_cast(m_windowSize.x()); + float windowHeight = static_cast(m_windowSize.y()); + + // 3 2 + // 7 6 + // + // 4 5 + // 0 1 + + std::array vertexArray ={ + Vec3f(0.0f , 0.0f , 0.0f), + Vec3f(windowWidth , 0.0f , 0.0f), + Vec3f(windowWidth , windowHeight , 0.0f), + Vec3f(0.0f , windowHeight , 0.0f), + + Vec3f(m_frameBorderWidth , m_frameBorderHeight , 0.0f), + Vec3f(windowWidth - m_frameBorderWidth, m_frameBorderHeight , 0.0f), + Vec3f(windowWidth - m_frameBorderWidth, windowHeight - m_frameBorderHeight, 0.0f), + Vec3f(m_frameBorderWidth , windowHeight - m_frameBorderHeight, 0.0f), + }; + + return vertexArray; +} + +//-------------------------------------------------------------------------------------------------- +/// Draw the legend using immediate mode OpenGL +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderSoftwareFrameAndTickLines(OpenGLContext* oglContext) +{ + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLighting_FF lighting(false); + lighting.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Frame vertices + + std::array vertexArray = frameVertexArray(); + + glColor4fv(m_frameColor.ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glVertex3fv(vertexArray[7].ptr()); + glEnd(); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[7].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glEnd(); + + + // Render Line around + + { + glColor3fv(m_lineColor.ptr()); + glBegin(GL_LINES); + // Frame lines + glVertex3fv(vertexArray[7].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glVertex3fv(vertexArray[4].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glVertex3fv(vertexArray[5].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glVertex3fv(vertexArray[6].ptr()); + glVertex3fv(vertexArray[7].ptr()); + + // X - axis Tick lines + for (double txpos : m_windowTickXValues) + { + Vec3f p1(Vec3f::ZERO); + Vec3f p2(Vec3f::ZERO); + + p1[0] = (float)txpos; + p1[1] = m_frameBorderHeight; + p2[0] = (float)txpos; + p2[1] = m_frameBorderHeight - m_tickLineLength; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + + p1[0] = (float)txpos; + p1[1] = m_windowSize.y() - m_frameBorderHeight; + p2[0] = (float)txpos; + p2[1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + } + + // Left Y - axis Tick lines + for (double typos : m_windowTickYValues) + { + Vec3f p1(Vec3f::ZERO); + Vec3f p2(Vec3f::ZERO); + + p1[0] = m_frameBorderWidth; + p1[1] = (float)typos; + p2[0] = m_frameBorderWidth - m_tickLineLength; + p2[1] = (float)typos; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + + p1[0] = m_windowSize.x() - m_frameBorderWidth; + p1[1] = (float)typos; + p2[0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength; + p2[1] = (float)typos; + + glVertex3fv(p1.ptr()); + glVertex3fv(p2.ptr()); + } + + glEnd(); + } + + // Reset render states + + RenderStateLighting_FF resetLighting; + resetLighting.applyOpenGL(oglContext); + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + CVF_CHECK_OGL(oglContext); +} + +//-------------------------------------------------------------------------------------------------- +/// Draw the frame using shader programs +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::renderShaderFrameAndTickLines(OpenGLContext* oglContext, const MatrixState& matrixState) +{ + CVF_CALLSITE_OPENGL(oglContext); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLine line(static_cast(m_lineWidth)); + line.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Shader program + + ref shaderProgram = oglContext->resourceManager()->getLinkedUnlitColorShaderProgram(oglContext); + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + + if (shaderProgram->useProgram(oglContext)) + { + shaderProgram->clearUniformApplyTracking(); + shaderProgram->applyFixedUniforms(oglContext, matrixState); + } + + // Frame vertices + std::array vertexArray = frameVertexArray(); + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glEnableVertexAttribArray(ShaderProgram::VERTEX); + glVertexAttribPointer(ShaderProgram::VERTEX, 3, GL_FLOAT, GL_FALSE, 0, vertexArray.data()); + + // Draw frame background + + UniformFloat backgroundColorUniform("u_color", m_frameColor); + shaderProgram->applyUniform(oglContext, backgroundColorUniform); + + // Triangle indices for the frame background + + static const ushort backgroundTriangleIndices[] = { 0, 1, 5, 0, 5, 4, + 1, 2, 6, 1, 6, 5, + 3, 0, 4, 3, 4, 7, + 2, 3, 6, 3, 7, 6 }; + + glDrawRangeElements(GL_TRIANGLES, 0, 7, 24, GL_UNSIGNED_SHORT, backgroundTriangleIndices); + + + // Draw frame border lines + + UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + shaderProgram->applyUniform(oglContext, uniformColor); + + static const ushort frameLineIndices[] = { 7, 4, + 4, 5, + 5, 6, + 6, 7 }; + + glDrawRangeElements(GL_LINES, 0, 7, 8, GL_UNSIGNED_SHORT, frameLineIndices); + + // Render tickmarks + + static const ushort tickLineIndices[] = { 0, 1 }; + + // X - axis Tick lines + + for (double txpos : m_windowTickXValues) + { + vertexArray[0][0] = (float)txpos; + vertexArray[0][1] = m_frameBorderHeight; + vertexArray[1][0] = (float)txpos; + vertexArray[1][1] = m_frameBorderHeight - m_tickLineLength; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + + vertexArray[0][0] = (float)txpos; + vertexArray[0][1] = m_windowSize.y() - m_frameBorderHeight; + vertexArray[1][0] = (float)txpos; + vertexArray[1][1] = m_windowSize.y() - m_frameBorderHeight + m_tickLineLength; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + } + + // Left Y - axis Tick lines + + for (double typos : m_windowTickYValues) + { + vertexArray[0][0] = m_frameBorderWidth; + vertexArray[0][1] = (float)typos; + vertexArray[1][0] = m_frameBorderWidth - m_tickLineLength; + vertexArray[1][1] = (float)typos; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + + vertexArray[0][0] = m_windowSize.x() - m_frameBorderWidth; + vertexArray[0][1] = (float)typos; + vertexArray[1][0] = m_windowSize.x() - m_frameBorderWidth + m_tickLineLength; + vertexArray[1][1] = (float)typos; + + glDrawRangeElements(GL_LINES, 0, 1, 2, GL_UNSIGNED_SHORT, tickLineIndices); + } + + glDisableVertexAttribArray(ShaderProgram::VERTEX); + + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + shaderProgram->useNoProgram(oglContext); + + // Reset render states + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + RenderStateLine resetLine; + resetLine.applyOpenGL(oglContext); + + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RivWindowEdgeAxesOverlayItem::setLineColor(const Color3f& lineColor) +{ + m_lineColor = lineColor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const Color3f& RivWindowEdgeAxesOverlayItem::lineColor() const +{ + return m_lineColor; +} + diff --git a/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h new file mode 100644 index 0000000000..8aefe6a6b4 --- /dev/null +++ b/ApplicationCode/ModelVisualization/WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h @@ -0,0 +1,137 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#pragma once + +#include "cvfBase.h" +#include "cvfOverlayItem.h" +#include "cvfArray.h" +#include "cvfCamera.h" +#include "cvfString.h" +#include "cvfRect.h" +#include "cafDisplayCoordTransform.h" + +namespace caf +{ + class DisplayCoordTransform; +} + +namespace cvf +{ +class Font; +class ShaderProgram; +class MatrixState; +class TextDrawer; +class ScalarMapper; +} + +//================================================================================================== +// +// Overlay color legend +// +//================================================================================================== +class RivWindowEdgeAxesOverlayItem : public cvf::OverlayItem +{ + using Font = cvf::Font; + using Vec2ui = cvf::Vec2ui; + using ScalarMapper = cvf::ScalarMapper; + using OpenGLContext = cvf::OpenGLContext; + using Vec2i = cvf::Vec2i; + using Color3f = cvf::Color3f; + using Color4f = cvf::Color4f; + using String = cvf::String; + using Vec2f = cvf::Vec2f; + using Vec3f = cvf::Vec3f; + using Rectf = cvf::Rectf; + using DoubleArray = cvf::DoubleArray; + using MatrixState = cvf::MatrixState; + using TextDrawer = cvf::TextDrawer; + using Camera = cvf::Camera; +public: + RivWindowEdgeAxesOverlayItem(Font* font); + virtual ~RivWindowEdgeAxesOverlayItem(); + + void setDisplayCoordTransform(const caf::DisplayCoordTransform* displayCoordTransform); + void updateFromCamera(const Camera* camera); + + void setTextColor(const Color3f& color); + const Color3f& textColor() const; + void setLineColor(const Color3f& lineColor); + const Color3f& lineColor() const; + void setFrameColor(const Color4f& frameColor); + + int frameBorderWidth() { return static_cast( m_frameBorderWidth); } + int frameBorderHeight() { return static_cast( m_frameBorderHeight); } + +protected: + Vec2ui sizeHint() override; + void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) override; + +private: + void updateGeomerySizes(); + void renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software); + void renderSoftwareFrameAndTickLines(OpenGLContext* oglContext); + void renderShaderFrameAndTickLines(OpenGLContext* oglContext, const MatrixState& matrixState); + void addTextToTextDrawer(TextDrawer* textDrawer); + + std::array frameVertexArray(); +private: + cvf::cref m_dispalyCoordsTransform; + + Vec2ui m_windowSize; // Pixel size of the window + Vec2ui m_textSize; + Color3f m_textColor; + Color3f m_lineColor; + Color4f m_frameColor; + int m_lineWidth; + cvf::ref m_font; + + float m_frameBorderHeight; + float m_frameBorderWidth; + float m_tickLineLength; + float m_pixelSpacing; + bool m_isSwitchingYAxisValueSign; + + std::vector m_domainCoordsXValues; + std::vector m_domainCoordsYValues; + std::vector m_windowTickXValues; + std::vector m_windowTickYValues; +}; + + diff --git a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake index b0207bc356..0851d05385 100644 --- a/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/CMakeLists_files.cmake @@ -1,211 +1,221 @@ -# 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}RimEclipseCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimCellFilter.h -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimPropertyFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.h -${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimLegendConfig.h -${CEE_CURRENT_LIST_DIR}RimOilField.h -${CEE_CURRENT_LIST_DIR}RimProject.h -${CEE_CURRENT_LIST_DIR}RimEclipseCase.h -${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.h -${CEE_CURRENT_LIST_DIR}RimEclipseInputProperty.h -${CEE_CURRENT_LIST_DIR}RimEclipseInputPropertyCollection.h -${CEE_CURRENT_LIST_DIR}RimEclipseInputCase.h -${CEE_CURRENT_LIST_DIR}RimEclipseResultCase.h -${CEE_CURRENT_LIST_DIR}RimEclipseView.h -${CEE_CURRENT_LIST_DIR}RimEclipseResultDefinition.h -${CEE_CURRENT_LIST_DIR}RimEclipseCellColors.h -${CEE_CURRENT_LIST_DIR}RimCellEdgeColors.h -${CEE_CURRENT_LIST_DIR}RimSimWellInView.h -${CEE_CURRENT_LIST_DIR}RimSimWellInViewCollection.h -${CEE_CURRENT_LIST_DIR}RimWellPath.h -${CEE_CURRENT_LIST_DIR}RimWellPathCollection.h -${CEE_CURRENT_LIST_DIR}RimScriptCollection.h -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCase.h -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimCalcScript.h -${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.h -${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.h -${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.h -${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.h -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.h -${CEE_CURRENT_LIST_DIR}RimMimeData.h -${CEE_CURRENT_LIST_DIR}RimCommandObject.h -${CEE_CURRENT_LIST_DIR}RimTools.h -${CEE_CURRENT_LIST_DIR}RimFaultInView.h -${CEE_CURRENT_LIST_DIR}RimFaultInViewCollection.h -${CEE_CURRENT_LIST_DIR}RimFormationNames.h -${CEE_CURRENT_LIST_DIR}RimFormationNamesCollection.h -${CEE_CURRENT_LIST_DIR}RimMockModelSettings.h -${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.h -${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.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}RimGeoMechPropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.h -${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.h -${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.h -${CEE_CURRENT_LIST_DIR}RimViewWindow.h -${CEE_CURRENT_LIST_DIR}RimView.h -${CEE_CURRENT_LIST_DIR}RimViewManipulator.h -${CEE_CURRENT_LIST_DIR}RimCase.h -${CEE_CURRENT_LIST_DIR}RimViewController.h -${CEE_CURRENT_LIST_DIR}RimMainPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimWellLogPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimRftPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimPltPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimWellLogPlot.h -${CEE_CURRENT_LIST_DIR}RimWellLogTrack.h -${CEE_CURRENT_LIST_DIR}RimWellLogCurve.h -${CEE_CURRENT_LIST_DIR}RimViewLinker.h -${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.h -${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.h -${CEE_CURRENT_LIST_DIR}RimWellLogFile.h -${CEE_CURRENT_LIST_DIR}RimWellLogFileChannel.h -${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.h -${CEE_CURRENT_LIST_DIR}RimWellLogRftCurve.h -${CEE_CURRENT_LIST_DIR}RimIntersection.h -${CEE_CURRENT_LIST_DIR}RimIntersectionCollection.h -${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.h -${CEE_CURRENT_LIST_DIR}RimGridCollection.h -${CEE_CURRENT_LIST_DIR}RimPlotCurve.h -${CEE_CURRENT_LIST_DIR}RimIntersectionBox.h -${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.h -${CEE_CURRENT_LIST_DIR}RimMdiWindowController.h -${CEE_CURRENT_LIST_DIR}RimPropertyFilter.h -${CEE_CURRENT_LIST_DIR}RimNamedObject.h -${CEE_CURRENT_LIST_DIR}RimCheckableNamedObject.h -${CEE_CURRENT_LIST_DIR}RimGridTimeHistoryCurve.h -${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.h -${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.h -${CEE_CURRENT_LIST_DIR}RimDialogData.h -${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.h -${CEE_CURRENT_LIST_DIR}RimSummaryCalculation.h -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationVariable.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCellFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimRegularLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimOilField.h +${CMAKE_CURRENT_LIST_DIR}/RimProject.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCase.h +${CMAKE_CURRENT_LIST_DIR}/RimIdenticalGridCaseGroup.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputProperty.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputPropertyCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputCase.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultCase.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseView.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCellColors.h +${CMAKE_CURRENT_LIST_DIR}/RimCellEdgeColors.h +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInView.h +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPath.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCase.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimCalcScript.h +${CMAKE_CURRENT_LIST_DIR}/RimExportInputPropertySettings.h +${CMAKE_CURRENT_LIST_DIR}/RimBinaryExportSettings.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dOverlayInfoConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimTensorResults.h +${CMAKE_CURRENT_LIST_DIR}/RimReservoirCellResultsStorage.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseEvaluator.h +${CMAKE_CURRENT_LIST_DIR}/RimMimeData.h +${CMAKE_CURRENT_LIST_DIR}/RimCommandObject.h +${CMAKE_CURRENT_LIST_DIR}/RimTools.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultInView.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultInViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimFormationNames.h +${CMAKE_CURRENT_LIST_DIR}/RimFormationNamesCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimMockModelSettings.h +${CMAKE_CURRENT_LIST_DIR}/RimTernaryLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseFaultColors.h +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNNC.h +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNncCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechModels.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCase.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechView.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilterCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechResultDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCellColors.h +${CMAKE_CURRENT_LIST_DIR}/RimViewWindow.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dView.h +${CMAKE_CURRENT_LIST_DIR}/RimGridView.h +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionView.h +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimViewManipulator.h +${CMAKE_CURRENT_LIST_DIR}/RimCase.h +${CMAKE_CURRENT_LIST_DIR}/RimViewController.h +${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimViewLinker.h +${CMAKE_CURRENT_LIST_DIR}/RimViewLinkerCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimIntersection.h +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimContextCommandBuilder.h +${CMAKE_CURRENT_LIST_DIR}/RimGridCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionBox.h +${CMAKE_CURRENT_LIST_DIR}/RimMultiSnapshotDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.h +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.h +${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.h +${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.h +${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.h +${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.h +${CMAKE_CURRENT_LIST_DIR}/RimDialogData.h +${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculation.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.h +${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.h +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.h +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveNameConfig.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.h - ${CEE_CURRENT_LIST_DIR}RimStimPlanColors.h - ) -endif() set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimEclipseCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCellFilter.cpp -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimPropertyFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimEclipsePropertyFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCellRangeFilter.cpp -${CEE_CURRENT_LIST_DIR}RimCellRangeFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimLegendConfig.cpp -${CEE_CURRENT_LIST_DIR}RimOilField.cpp -${CEE_CURRENT_LIST_DIR}RimProject.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseCase.cpp -${CEE_CURRENT_LIST_DIR}RimIdenticalGridCaseGroup.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseInputProperty.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseInputPropertyCollection.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseInputCase.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseResultCase.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseView.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseResultDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseCellColors.cpp -${CEE_CURRENT_LIST_DIR}RimCellEdgeColors.cpp -${CEE_CURRENT_LIST_DIR}RimSimWellInView.cpp -${CEE_CURRENT_LIST_DIR}RimSimWellInViewCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellPath.cpp -${CEE_CURRENT_LIST_DIR}RimWellPathCollection.cpp -${CEE_CURRENT_LIST_DIR}RimScriptCollection.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCase.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimCalcScript.cpp -${CEE_CURRENT_LIST_DIR}RimExportInputPropertySettings.cpp -${CEE_CURRENT_LIST_DIR}RimBinaryExportSettings.cpp -${CEE_CURRENT_LIST_DIR}Rim3dOverlayInfoConfig.cpp -${CEE_CURRENT_LIST_DIR}RimReservoirCellResultsStorage.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseStatisticsCaseEvaluator.cpp -${CEE_CURRENT_LIST_DIR}RimMimeData.cpp -${CEE_CURRENT_LIST_DIR}RimCommandObject.cpp -${CEE_CURRENT_LIST_DIR}RimTools.cpp -${CEE_CURRENT_LIST_DIR}RimFaultInView.cpp -${CEE_CURRENT_LIST_DIR}RimFaultInViewCollection.cpp -${CEE_CURRENT_LIST_DIR}RimFormationNames.cpp -${CEE_CURRENT_LIST_DIR}RimFormationNamesCollection.cpp -${CEE_CURRENT_LIST_DIR}RimMockModelSettings.cpp -${CEE_CURRENT_LIST_DIR}RimTernaryLegendConfig.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseFaultColors.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}RimGeoMechPropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechPropertyFilterCollection.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechResultDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimGeoMechCellColors.cpp -${CEE_CURRENT_LIST_DIR}RimViewWindow.cpp -${CEE_CURRENT_LIST_DIR}RimView.cpp -${CEE_CURRENT_LIST_DIR}RimViewManipulator.cpp -${CEE_CURRENT_LIST_DIR}RimCase.cpp -${CEE_CURRENT_LIST_DIR}RimViewController.cpp -${CEE_CURRENT_LIST_DIR}RimMainPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimRftPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPltPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogTrack.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogCurve.cpp -${CEE_CURRENT_LIST_DIR}RimViewLinker.cpp -${CEE_CURRENT_LIST_DIR}RimViewLinkerCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurve.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogFile.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogFileChannel.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogFileCurve.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogRftCurve.cpp -${CEE_CURRENT_LIST_DIR}RimIntersection.cpp -${CEE_CURRENT_LIST_DIR}RimIntersectionCollection.cpp -${CEE_CURRENT_LIST_DIR}RimContextCommandBuilder.cpp -${CEE_CURRENT_LIST_DIR}RimGridCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPlotCurve.cpp -${CEE_CURRENT_LIST_DIR}RimIntersectionBox.cpp -${CEE_CURRENT_LIST_DIR}RimMultiSnapshotDefinition.cpp -${CEE_CURRENT_LIST_DIR}RimMdiWindowController.cpp -${CEE_CURRENT_LIST_DIR}RimPropertyFilter.cpp -${CEE_CURRENT_LIST_DIR}RimNamedObject.cpp -${CEE_CURRENT_LIST_DIR}RimCheckableNamedObject.cpp -${CEE_CURRENT_LIST_DIR}RimGridTimeHistoryCurve.cpp -${CEE_CURRENT_LIST_DIR}RimGeometrySelectionItem.cpp -${CEE_CURRENT_LIST_DIR}RimEclipseGeometrySelectionItem.cpp -${CEE_CURRENT_LIST_DIR}RimDialogData.cpp -${CEE_CURRENT_LIST_DIR}RimTimeStepFilter.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCalculation.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCalculationVariable.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipsePropertyFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellRangeFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimRegularLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimOilField.cpp +${CMAKE_CURRENT_LIST_DIR}/RimProject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIdenticalGridCaseGroup.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputProperty.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputPropertyCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseInputCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseResultDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseCellColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCellEdgeColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSimWellInViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPath.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimScriptCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCalcScript.cpp +${CMAKE_CURRENT_LIST_DIR}/RimExportInputPropertySettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimBinaryExportSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dOverlayInfoConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTensorResults.cpp +${CMAKE_CURRENT_LIST_DIR}/RimReservoirCellResultsStorage.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseStatisticsCaseEvaluator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMimeData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCommandObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultInView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultInViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFormationNames.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFormationNamesCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMockModelSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTernaryLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseFaultColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNNC.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNoCommonAreaNncCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechModels.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechPropertyFilterCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechResultDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeoMechCellColors.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dView.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridView.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionView.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim2dIntersectionViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewManipulator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewController.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMainPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimRftPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPltPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewLinker.cpp +${CMAKE_CURRENT_LIST_DIR}/RimViewLinkerCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFile.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileChannel.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogFileCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogRftCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntersection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimContextCommandBuilder.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntersectionBox.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMultiSnapshotDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RimMdiWindowController.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPropertyFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimNamedObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCheckableNamedObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCheckableObject.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridTimeHistoryCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGeometrySelectionItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEclipseGeometrySelectionItem.cpp +${CMAKE_CURRENT_LIST_DIR}/RimDialogData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTimeStepFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculation.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCalculationVariable.cpp +${CMAKE_CURRENT_LIST_DIR}/RimStimPlanLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimStimPlanColors.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogFileCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogExtractionCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogRftCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimVirtualPerforationResults.cpp +${CMAKE_CURRENT_LIST_DIR}/RimLegendConfig.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurveNameConfig.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RimStimPlanLegendConfig.cpp - ${CEE_CURRENT_LIST_DIR}RimStimPlanColors.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) @@ -215,4 +225,4 @@ ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake index 7ea1beaf38..6255f8499f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Completions/CMakeLists_files.cmake @@ -1,68 +1,53 @@ -# 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}RimCompletionCellIntersectionCalc.h -${CEE_CURRENT_LIST_DIR}RimFishbonesCollection.h -${CEE_CURRENT_LIST_DIR}RimFishbonesMultipleSubs.h -${CEE_CURRENT_LIST_DIR}RimFishbonesPipeProperties.h -${CEE_CURRENT_LIST_DIR}RimFishboneWellPath.h -${CEE_CURRENT_LIST_DIR}RimFishboneWellPathCollection.h -${CEE_CURRENT_LIST_DIR}RimPerforationCollection.h -${CEE_CURRENT_LIST_DIR}RimPerforationInterval.h -${CEE_CURRENT_LIST_DIR}RimWellPathCompletions.h +${CMAKE_CURRENT_LIST_DIR}/RimCompletionCellIntersectionCalc.h +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesMultipleSubs.h +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesPipeProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPath.h +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPathCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPerforationCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimPerforationInterval.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions.h +${CMAKE_CURRENT_LIST_DIR}/RimEllipseFractureTemplate.h +${CMAKE_CURRENT_LIST_DIR}/RimFracture.h +${CMAKE_CURRENT_LIST_DIR}/RimFractureContainment.h +${CMAKE_CURRENT_LIST_DIR}/RimFractureExportSettings.h +${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplate.h +${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplateCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSimWellFracture.h +${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.h +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurveCollection.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimFracture.h - ${CEE_CURRENT_LIST_DIR}RimFractureContainment.h - ${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.h - ${CEE_CURRENT_LIST_DIR}RimFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.h - ${CEE_CURRENT_LIST_DIR}RimSimWellFracture.h - ${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.h - ${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.h - ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.h - ${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.h - ) -endif() - - set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimCompletionCellIntersectionCalc.cpp -${CEE_CURRENT_LIST_DIR}RimFishbonesCollection.cpp -${CEE_CURRENT_LIST_DIR}RimFishbonesMultipleSubs.cpp -${CEE_CURRENT_LIST_DIR}RimFishbonesPipeProperties.cpp -${CEE_CURRENT_LIST_DIR}RimFishboneWellPath.cpp -${CEE_CURRENT_LIST_DIR}RimFishboneWellPathCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPerforationCollection.cpp -${CEE_CURRENT_LIST_DIR}RimPerforationInterval.cpp -${CEE_CURRENT_LIST_DIR}RimWellPathCompletions.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCompletionCellIntersectionCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesMultipleSubs.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishbonesPipeProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPath.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFishboneWellPathCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPerforationCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimPerforationInterval.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathCompletions.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEllipseFractureTemplate.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFracture.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFractureContainment.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFractureExportSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplate.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFractureTemplateCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSimWellFracture.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSimWellFractureCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimStimPlanFractureTemplate.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathFracture.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPathFractureCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/Rim3dWellLogCurveCollection.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RimEllipseFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureContainment.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureExportSettings.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimFractureTemplateCollection.cpp - ${CEE_CURRENT_LIST_DIR}RimSimWellFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimSimWellFractureCollection.cpp - ${CEE_CURRENT_LIST_DIR}RimStimPlanFractureTemplate.cpp - ${CEE_CURRENT_LIST_DIR}RimWellPathFracture.cpp - ${CEE_CURRENT_LIST_DIR}RimWellPathFractureCollection.cpp - ) -endif() - - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) @@ -71,4 +56,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel\\Completions" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel\\Completions" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp new file mode 100644 index 0000000000..f1709c5f69 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.cpp @@ -0,0 +1,222 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogCurveCollection.h" + +#include "RiaColorTables.h" +#include "Rim3dWellLogCurve.h" +#include "RimWellPath.h" +#include "RimProject.h" + +#include "cafPdmUiDoubleSliderEditor.h" +#include "cvfMath.h" + +CAF_PDM_SOURCE_INIT(Rim3dWellLogCurveCollection, "Rim3dWellLogCurveCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection::Rim3dWellLogCurveCollection() +{ + CAF_PDM_InitObject("3D Track", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitField(&m_showPlot, "Show3dWellLogCurves", true, "Show 3d Well Log Curves", "", "", ""); + m_showPlot.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_planeWidthScaling, "PlaneWidthScaling", 1.0f, "Width Scaling", "", "", ""); + m_planeWidthScaling.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_showGrid, "Show3dWellLogGrid", true, "Show Grid", "", "", ""); + CAF_PDM_InitField(&m_showBackground, "Show3dWellLogBackground", false, "Show Background", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "ArrayOf3dWellLogCurves", "", "", "", ""); + m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection::~Rim3dWellLogCurveCollection() +{ + m_3dWellLogCurves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::has3dWellLogCurves() const +{ + return !m_3dWellLogCurves.empty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::add3dWellLogCurve(Rim3dWellLogCurve* curve) +{ + if (curve) + { + size_t index = m_3dWellLogCurves.size(); + curve->setColor(RiaColorTables::wellLogPlotPaletteColors().cycledColor3f(index)); + m_3dWellLogCurves.push_back(curve); + curve->createCurveAutoName(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::remove3dWellLogCurve(Rim3dWellLogCurve* curve) +{ + m_3dWellLogCurves.removeChildObject(curve); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::isShowingPlot() const +{ + return m_showPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::isShowingGrid() const +{ + return m_showGrid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurveCollection::isShowingBackground() const +{ + return m_showBackground; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float Rim3dWellLogCurveCollection::planeWidthScaling() const +{ + return m_planeWidthScaling; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Rim3dWellLogCurveCollection::vectorOf3dWellLogCurves() const +{ + std::vector curves; + for (auto& wellLogCurve : m_3dWellLogCurves) + { + curves.push_back(wellLogCurve); + } + + return curves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::redrawAffectedViewsAndEditors() +{ + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + RimWellPath* path = nullptr; + this->firstAncestorOrThisOfType(path); + if (path) + { + path->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve* Rim3dWellLogCurveCollection::checkForCurveIntersection(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint) +{ + double smallestDistance = std::numeric_limits::max(); + Rim3dWellLogCurve* closestCurve = nullptr; + for (auto& wellLogCurve : m_3dWellLogCurves) + { + cvf::Vec3d closestPointOnCurve; + double measuredDepthAtPointOnCurve; + double valueAtPointOnCurve; + if (wellLogCurve->findClosestPointOnCurve(globalIntersection, &closestPointOnCurve, &measuredDepthAtPointOnCurve, &valueAtPointOnCurve)) + { + double distance = globalIntersection.pointDistance(closestPointOnCurve); + if (distance < smallestDistance) + { + closestCurve = wellLogCurve.p(); + *closestPoint = closestPointOnCurve; + *measuredDepthAtPoint = measuredDepthAtPointOnCurve; + *valueAtPoint = valueAtPointOnCurve; + } + } + } + return closestCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + proj->createDisplayModelAndRedrawAllViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogCurveCollection::objectToggleField() +{ + return &m_showPlot; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* settingsGroup = uiOrdering.addNewGroup("Draw Plane Appearance"); + settingsGroup->add(&m_showGrid); + settingsGroup->add(&m_showBackground); + settingsGroup->add(&m_planeWidthScaling); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurveCollection::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiDoubleSliderEditorAttribute* widthAttribute = dynamic_cast(attribute); + if (widthAttribute) + { + widthAttribute->m_minimum = 0.25; + widthAttribute->m_maximum = 2.5; + } +} diff --git a/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h new file mode 100644 index 0000000000..1121aefa26 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Completions/Rim3dWellLogCurveCollection.h @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafAppEnum.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "cvfBase.h" +#include "cvfVector3.h" + +class Rim3dWellLogCurve; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogCurveCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogCurveCollection(); + virtual ~Rim3dWellLogCurveCollection(); + + bool has3dWellLogCurves() const; + void add3dWellLogCurve(Rim3dWellLogCurve* curve); + void remove3dWellLogCurve(Rim3dWellLogCurve* curve); + + bool isShowingPlot() const; + bool isShowingGrid() const; + bool isShowingBackground() const; + + float planeWidthScaling() const; + + std::vector vectorOf3dWellLogCurves() const; + void redrawAffectedViewsAndEditors(); + Rim3dWellLogCurve* checkForCurveIntersection(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint); + +private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); +private: + caf::PdmField m_showPlot; + caf::PdmField m_planeWidthScaling; + + caf::PdmField m_showGrid; + caf::PdmField m_showBackground; + + + caf::PdmChildArrayField m_3dWellLogCurves; +}; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index d2cc18dae8..aa0638dfcc 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,235 +19,104 @@ #include "RimCompletionCellIntersectionCalc.h" #include "RiaDefines.h" + +#include "RigCompletionData.h" +#include "RigVirtualPerforationTransmissibilities.h" +#include "RigWellPath.h" +#include "RigWellPathIntersectionTools.h" + #include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimSimWellInViewCollection.h" -#include "RimFishbonesCollection.h" -#include "RimFishbonesMultipleSubs.h" #include "RimOilField.h" -#include "RimPerforationCollection.h" -#include "RimPerforationInterval.h" #include "RimProject.h" -#include "RimSimWellInView.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include "RimWellPathCompletions.h" - -#include "RigMainGrid.h" -#include "RigWellPath.h" -#include "RigWellPathIntersectionTools.h" -#include "RigCellGeometryTools.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimFracture.h" -#include "RimWellPathFracture.h" -#include "RimFractureTemplate.h" -#include "RimWellPathFractureCollection.h" -#include "RimSimWellFractureCollection.h" -#include "RimSimWellFracture.h" -#include "RigFractureGrid.h" -#include "RigFractureCell.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - -#include -#include "RigHexIntersectionTools.h" //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimProject* project, - const RimEclipseCase* eclipseCase, - const RigMainGrid* grid, - std::vector& completionTypeCellResults, - const QDateTime& fromDate) +std::vector fromCompletionData(const std::vector& data) { - for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) - { - if (wellPath->showWellPath()) - { - calculateWellPathIntersections(wellPath, grid, completionTypeCellResults, fromDate); - } - } + std::vector appCompletionTypes; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - for (RimEclipseView* view : eclipseCase->reservoirViews()) + for (const auto& d : data) { - for (RimSimWellInView* simWell : view->wellCollection()->wells()) + switch (d.completionType()) { - for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) - { - calculateFractureIntersections(grid, fracture, completionTypeCellResults); - } - } - } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const RimWellPath* wellPath, - const RigMainGrid* grid, - std::vector& values, - const QDateTime& fromDate) -{ - std::vector intersections; - if (wellPath->wellPathGeometry()) - { - intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(grid, - wellPath->wellPathGeometry()->m_wellPathPoints); - } - - for (auto& intersection : intersections) - { - values[intersection.m_hexIndex] = RiaDefines::WELL_PATH; - } - - if (wellPath->fishbonesCollection()->isChecked()) - { - for (const RimFishbonesMultipleSubs* fishbones : wellPath->fishbonesCollection()->fishbonesSubs) - { - if (fishbones->isActive()) - { - calculateFishbonesIntersections(fishbones, grid, values); - } - } - } - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - if (wellPath->fractureCollection()->isChecked()) - { - for (const RimWellPathFracture* fracture : wellPath->fractureCollection()->fractures()) - { - if (fracture->isChecked()) - { - calculateFractureIntersections(grid, fracture, values); - } + case RigCompletionData::FRACTURE: + appCompletionTypes.push_back(RiaDefines::FRACTURE); + break; + case RigCompletionData::PERFORATION: + appCompletionTypes.push_back(RiaDefines::PERFORATION_INTERVAL); + break; + case RigCompletionData::FISHBONES: + appCompletionTypes.push_back(RiaDefines::FISHBONES); + break; + default: + break; } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - if (wellPath->perforationIntervalCollection()->isChecked()) - { - for (const RimPerforationInterval* perforationInterval : wellPath->perforationIntervalCollection()->perforations()) - { - if (perforationInterval->isChecked() && perforationInterval->isActiveOnDate(fromDate)) - { - calculatePerforationIntersections(wellPath, perforationInterval, grid, values); - } - } - } + return appCompletionTypes; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values) +void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep) { - for (auto& sub : fishbonesSubs->installedLateralIndices()) - { - for (size_t lateralIndex : sub.lateralIndices) - { - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(grid, - fishbonesSubs->coordsForLateral(sub.subIndex, lateralIndex)); - for (auto& intersection : intersections) - { - values[intersection.m_hexIndex] = RiaDefines::FISHBONES; - } - } - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculatePerforationIntersections(const RimWellPath* wellPath, - const RimPerforationInterval* perforationInterval, - const RigMainGrid* grid, - std::vector& values) -{ - using namespace std; - pair, vector > clippedWellPathData = wellPath->wellPathGeometry()->clippedPointSubset(perforationInterval->startMD(), - perforationInterval->endMD()); - - std::vector intersections = RigWellPathIntersectionTools::findRawHexCellIntersections(grid, - clippedWellPathData.first); - for (auto& intersection : intersections) - { - values[intersection.m_hexIndex] = RiaDefines::PERFORATION_INTERVAL; - } -} + CVF_ASSERT(eclipseCase && eclipseCase->eclipseCaseData()); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RimCompletionCellIntersectionCalc::calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values) -{ - if (!fracture->fractureTemplate()) return; + RimProject* project = nullptr; + eclipseCase->firstAncestorOrThisOfTypeAsserted(project); - for (const RigFractureCell& fractureCell : fracture->fractureTemplate()->fractureGrid()->fractureCells()) + if (project->activeOilField()->wellPathCollection->isActive) { - if (!fractureCell.hasNonZeroConductivity()) continue; + const RigEclipseCaseData* eclipseCaseData = eclipseCase->eclipseCaseData(); - std::vector fractureCellTransformed; - for (const auto& v : fractureCell.getPolygon()) + for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) { - cvf::Vec3d polygonNode = v; - polygonNode.transformPoint(fracture->transformMatrix()); - fractureCellTransformed.push_back(polygonNode); - } - - std::vector potentialCells; - - { - cvf::BoundingBox boundingBox; - - for (cvf::Vec3d nodeCoord : fractureCellTransformed) + if (wellPath->showWellPath() && wellPath->wellPathGeometry()) { - boundingBox.add(nodeCoord); - } - - mainGrid->findIntersectingCells(boundingBox, &potentialCells); - } + auto intersectedCells = RigWellPathIntersectionTools::findIntersectedGlobalCellIndices( + eclipseCaseData, wellPath->wellPathGeometry()->m_wellPathPoints); - for (size_t cellIndex : potentialCells) - { - if (!fracture->isEclipseCellWithinContainment(mainGrid, cellIndex)) continue; - - std::array hexCorners; - mainGrid->cellCornerVertices(cellIndex, hexCorners.data()); - - std::vector< std::vector > planeCellPolygons; - bool isPlaneIntersected = RigHexIntersectionTools::planeHexIntersectionPolygons(hexCorners, fracture->transformMatrix(), planeCellPolygons); - if (!isPlaneIntersected || planeCellPolygons.empty()) continue; - - { - cvf::Mat4d invertedTransformMatrix = cvf::Mat4d(fracture->transformMatrix().getInverted()); - for (std::vector& planeCellPolygon : planeCellPolygons) + for (auto& intersection : intersectedCells) { - for (cvf::Vec3d& v : planeCellPolygon) - { - v.transformPoint(invertedTransformMatrix); - } + completionTypeCellResult[intersection] = RiaDefines::WELL_PATH; } - } - for (const std::vector& planeCellPolygon : planeCellPolygons) - { - std::vector< std::vector > clippedPolygons = RigCellGeometryTools::intersectPolygons(planeCellPolygon, fractureCell.getPolygon()); - for (const auto& clippedPolygon : clippedPolygons) + auto completions = eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + if (completions) { - if (!clippedPolygon.empty()) + for (const auto& completionsForWell : completions->multipleCompletionsPerEclipseCell(wellPath, timeStep)) { - values[cellIndex] = RiaDefines::FRACTURE; - break; + RiaDefines::CompletionType appCompletionType = RiaDefines::WELL_PATH; + + auto appCompletionTypes = fromCompletionData(completionsForWell.second); + + if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FRACTURE) != + appCompletionTypes.end()) + { + appCompletionType = RiaDefines::FRACTURE; + } + else if (std::find(appCompletionTypes.begin(), appCompletionTypes.end(), RiaDefines::FISHBONES) != + appCompletionTypes.end()) + { + appCompletionType = RiaDefines::FISHBONES; + } + else if (std::find(appCompletionTypes.begin(), + appCompletionTypes.end(), + RiaDefines::PERFORATION_INTERVAL) != appCompletionTypes.end()) + { + appCompletionType = RiaDefines::PERFORATION_INTERVAL; + } + + completionTypeCellResult[completionsForWell.first.globalCellIndex()] = appCompletionType; } } } } - } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index d7d997aff7..f4cfac4aa6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -1,57 +1,36 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include #include -class RimProject; -class RimWellPath; -class RimFishbonesMultipleSubs; -class RimPerforationInterval; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -class RimFracture; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - class RimEclipseCase; -class RigMainGrid; -class QDateTime; - //================================================================================================== -/// -/// +/// +/// //================================================================================================== class RimCompletionCellIntersectionCalc { public: - static void calculateCompletionTypeResult(const RimProject* project, - const RimEclipseCase* eclipseCase, - const RigMainGrid* grid, - std::vector& completionTypeCellResult, - const QDateTime& fromDate); - -private: - static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate); - static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values); - static void calculatePerforationIntersections(const RimWellPath* wellPath, const RimPerforationInterval* perforationInterval, const RigMainGrid* grid, std::vector& values); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - static void calculateFractureIntersections(const RigMainGrid* mainGrid, const RimFracture* fracture, std::vector& values); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + static void calculateCompletionTypeResult(RimEclipseCase* eclipseCase, + std::vector& completionTypeCellResult, + size_t timeStep); }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp index 27c3c23c1d..fd9f9dfb7d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.cpp @@ -18,18 +18,23 @@ #include "RimEllipseFractureTemplate.h" +#include "RiaApplication.h" #include "RiaEclipseUnitTools.h" +#include "RiaFractureDefines.h" #include "RiaLogging.h" #include "RigCellGeometryTools.h" #include "RigFractureCell.h" #include "RigFractureGrid.h" +#include "RigStatisticsMath.h" #include "RigTesselatorTools.h" +#include "RimEclipseView.h" #include "RimFracture.h" #include "RimFractureContainment.h" #include "RimFractureTemplate.h" #include "RimProject.h" +#include "RimStimPlanColors.h" #include "cafPdmObject.h" @@ -43,19 +48,18 @@ CAF_PDM_SOURCE_INIT(RimEllipseFractureTemplate, "RimEllipseFractureTemplate"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimEllipseFractureTemplate::RimEllipseFractureTemplate(void) +RimEllipseFractureTemplate::RimEllipseFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); - CAF_PDM_InitField(&halfLength, "HalfLength", 650.0f, "Halflength Xf", "", "", ""); - CAF_PDM_InitField(&height, "Height", 75.0f, "Height", "", "", ""); - CAF_PDM_InitField(&width, "Width", 1.0f, "Width", "", "", ""); + CAF_PDM_InitField(&m_halfLength, "HalfLength", 0.0, "Halflength Xf", "", "", ""); + CAF_PDM_InitField(&m_height, "Height", 0.0, "Height", "", "", ""); + CAF_PDM_InitField(&m_width, "Width", 0.0, "Width", "", "", ""); - CAF_PDM_InitField(&permeability,"Permeability", 22000.f, "Permeability [mD]", "", "", ""); + CAF_PDM_InitField(&m_userDefinedEffectivePermeability,"Permeability", 0.0, "Permeability [mD]", "", "", ""); m_fractureGrid = new RigFractureGrid(); - setupFractureGridCells(); - + assignConductivityToCellsInsideEllipse(); } //-------------------------------------------------------------------------------------------------- @@ -70,7 +74,10 @@ RimEllipseFractureTemplate::~RimEllipseFractureTemplate() //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::loadDataAndUpdate() { - setupFractureGridCells(); + assignConductivityToCellsInsideEllipse(); + + RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + if (activeView) activeView->loadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- @@ -80,21 +87,21 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha { RimFractureTemplate::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &halfLength || changedField == &height) + if ( changedField == &m_halfLength + || changedField == &m_height + || changedField == &m_width + || changedField == &m_userDefinedEffectivePermeability + || changedField == &m_scaleApplyButton) { + m_scaleApplyButton = false; + //Changes to one of these parameters should change all fractures with this fracture template attached. - RimProject* proj; - this->firstAncestorOrThisOfType(proj); - if (proj) - { - //Regenerate geometry - proj->createDisplayModelAndRedrawAllViews(); - setupFractureGridCells(); - } + reload(); } - if (changedField == &width || changedField == &permeability) + + if (changedField == &m_width || changedField == &m_userDefinedEffectivePermeability) { - setupFractureGridCells(); + assignConductivityToCellsInsideEllipse(); } } @@ -102,38 +109,12 @@ void RimEllipseFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* cha /// //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) + std::vector* triangleIndices) { RigEllipsisTesselator tesselator(20); - float a = cvf::UNDEFINED_FLOAT; - float b = cvf::UNDEFINED_FLOAT; - - if (neededUnit == fractureTemplateUnit()) - { - a = halfLength; - b = height / 2.0f; - - } - else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD) - { - RiaLogging::info(QString("Converting fracture template geometry from metric to field")); - a = RiaEclipseUnitTools::meterToFeet(halfLength); - b = RiaEclipseUnitTools::meterToFeet(height / 2.0f); - } - else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC) - { - RiaLogging::info(QString("Converting fracture template geometry from field to metric")); - a = RiaEclipseUnitTools::feetToMeter(halfLength); - b = RiaEclipseUnitTools::feetToMeter(height / 2.0f); - } - else - { - //Should never get here... - RiaLogging::error(QString("Error: Could not convert units for fracture / fracture template")); - return; - } + float a = m_halfLength * m_widthScaleFactor; + float b = m_height / 2.0f * m_heightScaleFactor; tesselator.tesselateEllipsis(a, b, triangleIndices, nodeCoords); } @@ -141,14 +122,14 @@ void RimEllipseFractureTemplate::fractureTriangleGeometry(std::vector RimEllipseFractureTemplate::fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) +std::vector RimEllipseFractureTemplate::fractureBorderPolygon() { std::vector polygon; std::vector nodeCoords; std::vector triangleIndices; - fractureTriangleGeometry(&nodeCoords, &triangleIndices, neededUnit); + fractureTriangleGeometry(&nodeCoords, &triangleIndices); for (size_t i = 1; i < nodeCoords.size(); i++) { @@ -163,23 +144,13 @@ std::vector RimEllipseFractureTemplate::fractureBorderPolygon(RiaEcl //-------------------------------------------------------------------------------------------------- void RimEllipseFractureTemplate::changeUnits() { - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - halfLength = RiaEclipseUnitTools::meterToFeet(halfLength); - height = RiaEclipseUnitTools::meterToFeet(height); - width = RiaEclipseUnitTools::meterToInch(width); - wellDiameter = RiaEclipseUnitTools::meterToInch(wellDiameter); - perforationLength = RiaEclipseUnitTools::meterToFeet(perforationLength); - fractureTemplateUnit = RiaEclipseUnitTools::UNITS_FIELD; + convertToUnitSystem(RiaEclipseUnitTools::UNITS_FIELD); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - halfLength = RiaEclipseUnitTools::feetToMeter(halfLength); - height = RiaEclipseUnitTools::feetToMeter(height); - width = RiaEclipseUnitTools::inchToMeter(width); - wellDiameter = RiaEclipseUnitTools::inchToMeter(wellDiameter); - perforationLength = RiaEclipseUnitTools::feetToMeter(perforationLength); - fractureTemplateUnit = RiaEclipseUnitTools::UNITS_METRIC; + convertToUnitSystem(RiaEclipseUnitTools::UNITS_METRIC); } this->updateConnectedEditors(); @@ -188,25 +159,26 @@ void RimEllipseFractureTemplate::changeUnits() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEllipseFractureTemplate::setupFractureGridCells() +void RimEllipseFractureTemplate::assignConductivityToCellsInsideEllipse() { - std::vector fractureCells; - std::pair wellCenterFractureCellIJ = std::make_pair(0, 0); - int numberOfCellsX = 35; - int numberOfCellsY = 35; + int numberOfCellsI = 35; + int numberOfCellsJ = 35; - double cellSizeX = (halfLength * 2) / numberOfCellsX; - double cellSizeZ = height / numberOfCellsY; + double height = m_height * m_heightScaleFactor; + double halfLength = m_halfLength * m_widthScaleFactor; + + double cellSizeX = (halfLength * 2) / numberOfCellsI * m_widthScaleFactor; + double cellSizeZ = height / numberOfCellsJ * m_heightScaleFactor; double cellArea = cellSizeX * cellSizeZ; double areaTresholdForIncludingCell = 0.5 * cellArea; - for (int i = 0; i < numberOfCellsX; i++) + for (int i = 0; i < numberOfCellsI; i++) { - for (int j = 0; j < numberOfCellsX; j++) + for (int j = 0; j < numberOfCellsJ; j++) { double X1 = - halfLength + i * cellSizeX; double X2 = - halfLength + (i+1) * cellSizeX; @@ -219,25 +191,15 @@ void RimEllipseFractureTemplate::setupFractureGridCells() cellPolygon.push_back(cvf::Vec3d(X2, Y2, 0.0)); cellPolygon.push_back(cvf::Vec3d(X1, Y2, 0.0)); - double cond = cvf::UNDEFINED_DOUBLE; - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) - { - //Conductivity should be md-m, width is in m - cond = permeability * width; - } - else if(fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) - { - //Conductivity should be md-ft, but width is in inches - cond = permeability * RiaEclipseUnitTools::inchToFeet(width); - } + double cond = conductivity(); - std::vector ellipseFracPolygon = fractureBorderPolygon(fractureTemplateUnit()); + std::vector ellipseFracPolygon = fractureBorderPolygon(); std::vector ellipseFracPolygonDouble; - for (auto v : ellipseFracPolygon) ellipseFracPolygonDouble.push_back(static_cast(v)); + for (const auto& v : ellipseFracPolygon) ellipseFracPolygonDouble.push_back(static_cast(v)); std::vector >clippedFracturePolygons = RigCellGeometryTools::intersectPolygons(cellPolygon, ellipseFracPolygonDouble); - if (clippedFracturePolygons.size() > 0) + if (!clippedFracturePolygons.empty()) { - for (auto clippedFracturePolygon : clippedFracturePolygons) + for (const auto& clippedFracturePolygon : clippedFracturePolygons) { double areaCutPolygon = cvf::GeometryTools::polygonAreaNormal3D(clippedFracturePolygon).length(); if (areaCutPolygon < areaTresholdForIncludingCell) cond = 0.0; //Cell is excluded from calculation, cond is set to zero. Must be included for indexing to be correct @@ -248,24 +210,30 @@ void RimEllipseFractureTemplate::setupFractureGridCells() RigFractureCell fractureCell(cellPolygon, i, j); fractureCell.setConductivityValue(cond); - if (cellPolygon[0].x() < 0.0 && cellPolygon[1].x() > 0.0) - { - if (cellPolygon[1].y() < 0.0 && cellPolygon[2].y() > 0.0) - { - wellCenterFractureCellIJ = std::make_pair(fractureCell.getI(), fractureCell.getJ()); - RiaLogging::debug(QString("Setting wellCenterFractureCell at cell %1, %2"). - arg(QString::number(fractureCell.getI()), QString::number(fractureCell.getJ()))); - } - } - fractureCells.push_back(fractureCell); } } m_fractureGrid->setFractureCells(fractureCells); + + // Set well intersection to center of ellipse + std::pair wellCenterFractureCellIJ = std::make_pair(numberOfCellsI / 2, numberOfCellsJ / 2); m_fractureGrid->setWellCenterFractureCellIJ(wellCenterFractureCellIJ); - m_fractureGrid->setICellCount(numberOfCellsX); - m_fractureGrid->setJCellCount(numberOfCellsY); + + m_fractureGrid->setICellCount(numberOfCellsI); + m_fractureGrid->setJCellCount(numberOfCellsJ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +FractureWidthAndConductivity RimEllipseFractureTemplate::widthAndConductivityAtWellPathIntersection() const +{ + FractureWidthAndConductivity values; + values.m_width = m_width; + values.m_permeability = m_userDefinedEffectivePermeability; + + return values; } //-------------------------------------------------------------------------------------------------- @@ -279,59 +247,160 @@ const RigFractureGrid* RimEllipseFractureTemplate::fractureGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void RimEllipseFractureTemplate::setDefaultValuesFromUnit() { - RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); - - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); - height.uiCapability()->setUiName("Height [m]"); - width.uiCapability()->setUiName("Width [m]"); - wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); + m_width = 0.5; + m_userDefinedEffectivePermeability = 80000.0; + m_halfLength = 300.0; + m_height = 225.0; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + else { - halfLength.uiCapability()->setUiName("Halflenght Xf [Ft]"); - height.uiCapability()->setUiName("Height [Ft]"); - width.uiCapability()->setUiName("Width [inches]"); - wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); + m_width = 0.01; + m_userDefinedEffectivePermeability = 100000.0; + m_halfLength = 100.0; + m_height = 75.0; } + this->setDefaultWellDiameterFromUnit(); +} - if (conductivityType == FINITE_CONDUCTIVITY) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimEllipseFractureTemplate::conductivity() const +{ + double cond = cvf::UNDEFINED_DOUBLE; + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - permeability.uiCapability()->setUiHidden(false); - width.uiCapability()->setUiHidden(false); + //Conductivity should be md-m, width is in m + cond = m_userDefinedEffectivePermeability * m_width; } - else if (conductivityType == INFINITE_CONDUCTIVITY) + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - permeability.uiCapability()->setUiHidden(true); - width.uiCapability()->setUiHidden(true); + //Conductivity should be md-ft, but width is in inches + cond = m_userDefinedEffectivePermeability * RiaEclipseUnitTools::inchToFeet(m_width); } + return m_conductivityScaleFactor * cond; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::appendDataToResultStatistics(const QString& uiResultName, const QString& unit, MinMaxAccumulator& minMaxAccumulator, PosNegAccumulator& posNegAccumulator) const +{ + if (uiResultName == RiaDefines::conductivityResultName()) + { + minMaxAccumulator.addValue(conductivity()); + posNegAccumulator.addValue(conductivity()); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RimEllipseFractureTemplate::uiResultNamesWithUnit() const +{ + std::vector> propertyNamesAndUnits; + + QString condUnit = RiaDefines::unitStringConductivity(fractureTemplateUnit()); + propertyNamesAndUnits.push_back(std::make_pair(RiaDefines::conductivityResultName(), condUnit)); + + return propertyNamesAndUnits; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::reload() +{ + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->reloadCompletionTypeResultsInAllViews(); + assignConductivityToCellsInsideEllipse(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) +{ + if (m_fractureTemplateUnit() == neededUnit) return; + + setFractureTemplateUnit(neededUnit); + RimFractureTemplate::convertToUnitSystem(neededUnit); + + if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + m_halfLength = RiaEclipseUnitTools::meterToFeet(m_halfLength); + m_height = RiaEclipseUnitTools::meterToFeet(m_height); + m_width = RiaEclipseUnitTools::meterToInch(m_width); + } + else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + m_halfLength = RiaEclipseUnitTools::feetToMeter(m_halfLength); + m_height = RiaEclipseUnitTools::feetToMeter(m_height); + m_width = RiaEclipseUnitTools::inchToMeter(m_width); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEllipseFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ - uiOrdering.add(&name); + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) + { + m_halfLength.uiCapability()->setUiName("Halflenght Xf [m]"); + m_height.uiCapability()->setUiName("Height [m]"); + m_width.uiCapability()->setUiName("Width [m]"); + } + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) + { + m_halfLength.uiCapability()->setUiName("Halflenght Xf [ft]"); + m_height.uiCapability()->setUiName("Height [ft]"); + m_width.uiCapability()->setUiName("Width [inches]"); + } + + if (conductivityType() == FINITE_CONDUCTIVITY) + { + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(false); + m_width.uiCapability()->setUiHidden(false); + } + else if (conductivityType() == INFINITE_CONDUCTIVITY) + { + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(true); + m_width.uiCapability()->setUiHidden(true); + } + + uiOrdering.add(&m_name); + uiOrdering.add(&m_id); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); - geometryGroup->add(&halfLength); - geometryGroup->add(&height); - geometryGroup->add(&orientationType); - geometryGroup->add(&azimuthAngle); + geometryGroup->add(&m_halfLength); + geometryGroup->add(&m_height); + geometryGroup->add(&m_orientationType); + geometryGroup->add(&m_azimuthAngle); caf::PdmUiGroup* trGr = uiOrdering.addNewGroup("Fracture Truncation"); m_fractureContainment()->defineUiOrdering(uiConfigName, *trGr); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); - propertyGroup->add(&conductivityType); - propertyGroup->add(&permeability); - propertyGroup->add(&width); - propertyGroup->add(&skinFactor); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); - - uiOrdering.add(&fractureTemplateUnit); - uiOrdering.skipRemainingFields(true); + propertyGroup->add(&m_conductivityType); + propertyGroup->add(&m_userDefinedEffectivePermeability); + propertyGroup->add(&m_width); + propertyGroup->add(&m_skinFactor); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); + + RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h index 48b0b4feae..1c86cbef95 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimEllipseFractureTemplate.h @@ -43,31 +43,42 @@ class RimEllipseFractureTemplate : public RimFractureTemplate CAF_PDM_HEADER_INIT; public: - RimEllipseFractureTemplate(void); - virtual ~RimEllipseFractureTemplate(void); - - caf::PdmField halfLength; - caf::PdmField height; + RimEllipseFractureTemplate(); + virtual ~RimEllipseFractureTemplate(); - caf::PdmField width; - caf::PdmField permeability; - - void loadDataAndUpdate(); + void fractureTriangleGeometry(std::vector* nodeCoords, std::vector* polygonIndices) override; - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - - void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* polygonIndices, - RiaEclipseUnitTools::UnitSystem neededUnit); - std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit); - void changeUnits(); + std::vector fractureBorderPolygon() override; + void changeUnits(); + const RigFractureGrid* fractureGrid() const override; + void setDefaultValuesFromUnit(); + double conductivity() const; - const RigFractureGrid* fractureGrid() const; + void appendDataToResultStatistics(const QString& uiResultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const override; + + void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + + void loadDataAndUpdate() override; + std::vector> uiResultNamesWithUnit() const override; + virtual void reload() override; protected: - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; private: - void setupFractureGridCells(); - cvf::ref m_fractureGrid; + void assignConductivityToCellsInsideEllipse(); + + FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; + +private: + cvf::ref m_fractureGrid; + + caf::PdmField m_halfLength; + caf::PdmField m_height; + caf::PdmField m_width; + caf::PdmField m_userDefinedEffectivePermeability; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp index 9908933ab8..59507d5ff0 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishboneWellPathCollection.cpp @@ -22,13 +22,13 @@ #include "RimFishboneWellPath.h" #include "RimFishbonesCollection.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigWellPath.h" #include "RifWellPathImporter.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" CAF_PDM_SOURCE_INIT(RimFishboneWellPathCollection, "WellPathCompletionCollection"); @@ -133,11 +133,11 @@ void RimFishboneWellPathCollection::appendCompletion(RimFishboneWellPath* comple m_wellPaths.push_back(completion); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(completion); + Riu3DMainWindowTools::selectAsCurrentItem(completion); uiCapability()->setUiHidden(!m_wellPaths.empty()); - RimProject* project = NULL; + RimProject* project = nullptr; firstAncestorOrThisOfTypeAsserted(project); if (project) { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp index a0935ebd4f..22903f9c5a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.cpp @@ -32,6 +32,7 @@ #include #include +#include "cvfMath.h" CAF_PDM_SOURCE_INIT(RimFishbonesMultipleSubs, "FishbonesMultipleSubs"); @@ -403,23 +404,38 @@ void RimFishbonesMultipleSubs::fieldChangedByUi(const caf::PdmFieldHandle* chang changedField == &m_rangeSubSpacing) { recomputeLocations = true; - } - if (changedField == &m_rangeStart && m_rangeStart > m_rangeEnd) - { - m_rangeEnd = m_rangeStart; - } + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + + RigWellPath* rigWellPathGeo = wellPath->wellPathGeometry(); + if (rigWellPathGeo && !rigWellPathGeo->m_measuredDepths.empty()) + { + double lastWellPathMD = rigWellPathGeo->m_measuredDepths.back(); - if (changedField == &m_rangeEnd && m_rangeEnd < m_rangeStart) - { - m_rangeStart = m_rangeEnd; + m_rangeStart = cvf::Math::clamp(m_rangeStart(), 0.0, lastWellPathMD); + m_rangeEnd = cvf::Math::clamp(m_rangeEnd(), m_rangeStart(), lastWellPathMD); + } } - if (changedField == &m_rangeSubSpacing && - m_rangeSubSpacing() < 13.0) + if (changedField == &m_rangeSubSpacing) { - // Minimum distance between fishbones is 13m - m_rangeSubSpacing = 13.0; + // Minimum distance between fishbones is 13.0m + // Use 10.0m to allow for some flexibility + + double minimumDistanceMeter = 10.0; + + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + if (wellPath->unitSystem() == RiaEclipseUnitTools::UNITS_FIELD) + { + double minimumDistanceFeet = RiaEclipseUnitTools::meterToFeet(minimumDistanceMeter); + m_rangeSubSpacing = cvf::Math::clamp(m_rangeSubSpacing(), minimumDistanceFeet, std::max(m_rangeSubSpacing(), minimumDistanceFeet)); + } + else + { + m_rangeSubSpacing = cvf::Math::clamp(m_rangeSubSpacing(), minimumDistanceMeter, std::max(m_rangeSubSpacing(), minimumDistanceMeter)); + } } if (recomputeLocations) @@ -462,24 +478,6 @@ caf::PdmFieldHandle* RimFishbonesMultipleSubs::objectToggleField() return &m_isActive; } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimFishbonesMultipleSubs::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) -{ - if (field == &m_rangeStart || - field == &m_rangeEnd || - field == &m_rangeSubSpacing) - { - caf::PdmUiDoubleValueEditorAttribute* attr = dynamic_cast(attribute); - - if (attr) - { - attr->m_decimals = 2; - } - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h index 75dc7d472c..0fc81fb520 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFishbonesMultipleSubs.h @@ -110,8 +110,6 @@ class RimFishbonesMultipleSubs : public caf::PdmObject, public Rim3dPropertiesIn virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, - caf::PdmUiEditorAttribute* attribute) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp index f44a3b0d4f..8edc8a8dc1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.cpp @@ -19,6 +19,7 @@ #include "RimFracture.h" #include "RiaApplication.h" +#include "RiaCompletionTypeCalculationScheduler.h" #include "RiaEclipseUnitTools.h" #include "RiaLogging.h" @@ -47,7 +48,7 @@ #include "RimReservoirCellResultsStorage.h" #include "RimStimPlanFractureTemplate.h" #include "RimStimPlanColors.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RivWellFracturePartMgr.h" @@ -64,6 +65,7 @@ #include "cvfMatrix4.h" #include "cvfPlane.h" +#include #include #include @@ -80,14 +82,14 @@ void setDefaultFractureColorResult() for (RimEclipseCase* const eclCase : proj->eclipseCases()) { - for (RimView* const view : eclCase->views()) + for (Rim3dView* const view : eclCase->views()) { std::vector fractureColors; view->descendantsIncludingThisOfType(fractureColors); for (RimStimPlanColors* const stimPlanColors : fractureColors) { - stimPlanColors->setDefaultResultNameForStimPlan(); + stimPlanColors->setDefaultResultName(); } } } @@ -104,27 +106,28 @@ RimFracture::RimFracture(void) CAF_PDM_InitFieldNoDefault(&m_anchorPosition, "AnchorPosition", "Anchor Position", "", "", ""); m_anchorPosition.uiCapability()->setUiHidden(true); + m_anchorPosition.xmlCapability()->disableIO(); CAF_PDM_InitFieldNoDefault(&m_uiAnchorPosition, "ui_positionAtWellpath", "Fracture Position", "", "", ""); m_uiAnchorPosition.registerGetMethod(this, &RimFracture::fracturePositionForUi); m_uiAnchorPosition.uiCapability()->setUiReadOnly(true); m_uiAnchorPosition.xmlCapability()->disableIO(); - CAF_PDM_InitField(&azimuth, "Azimuth", 0.0, "Azimuth", "", "", ""); - azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_azimuth, "Azimuth", 0.0, "Azimuth", "", "", ""); + m_azimuth.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); - CAF_PDM_InitField(&perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); - perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); + CAF_PDM_InitField(&m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); + m_perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); - CAF_PDM_InitField(&dip, "Dip", 0.0, "Dip", "", "", ""); - CAF_PDM_InitField(&tilt, "Tilt", 0.0, "Tilt", "", "", ""); + CAF_PDM_InitField(&m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); + CAF_PDM_InitField(&m_dip, "Dip", 0.0, "Dip", "", "", ""); + CAF_PDM_InitField(&m_tilt, "Tilt", 0.0, "Tilt", "", "", ""); CAF_PDM_InitField(&m_fractureUnit, "FractureUnit", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Fracture Unit System", "", "", ""); m_fractureUnit.uiCapability()->setUiReadOnly(true); - CAF_PDM_InitField(&stimPlanTimeIndexToPlot, "TimeIndexToPlot", 0, "StimPlan Time Step", "", "", ""); + CAF_PDM_InitField(&m_stimPlanTimeIndexToPlot, "TimeIndexToPlot", 0, "StimPlan Time Step", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_uiWellPathAzimuth, "WellPathAzimuth", "Well Path Azimuth", "", "", ""); m_uiWellPathAzimuth.registerGetMethod(this, &RimFracture::wellAzimuthAtFracturePositionText); @@ -150,6 +153,30 @@ RimFracture::~RimFracture() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFracture::perforationLength() const +{ + return m_perforationLength(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFracture::perforationEfficiency() const +{ + return m_perforationEfficiency(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFracture::setStimPlanTimeIndexToPlot(int timeIndex) +{ + m_stimPlanTimeIndexToPlot = timeIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -172,22 +199,44 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons { if (changedField == &m_fractureTemplate) { + if (fractureUnit() != m_fractureTemplate->fractureTemplateUnit()) + { + QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); + + QString warningText = QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a " + "fracture template of unit '%1'") + .arg(fractureUnitText); + + QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); + + PdmObjectHandle* prevValue = oldValue.value>().rawPtr(); + auto prevTemplate = dynamic_cast(prevValue); + + m_fractureTemplate = prevTemplate; + } + setFractureTemplate(m_fractureTemplate); setDefaultFractureColorResult(); } - if (changedField == &azimuth || + if (changedField == &m_azimuth || changedField == &m_fractureTemplate || - changedField == &stimPlanTimeIndexToPlot || + changedField == &m_stimPlanTimeIndexToPlot || changedField == this->objectToggleField() || - changedField == &dip || - changedField == &tilt) + changedField == &m_dip || + changedField == &m_tilt || + changedField == &m_perforationLength) { - RimView* rimView = nullptr; + RimEclipseView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { - rimView->createDisplayModelAndRedraw(); + RimEclipseCase* eclipseCase = nullptr; + rimView->firstAncestorOrThisOfType(eclipseCase); + if (eclipseCase) + { + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCase); + } } else { @@ -197,7 +246,6 @@ void RimFracture::fieldChangedByUi(const caf::PdmFieldHandle* changedField, cons proj->reloadCompletionTypeResultsInAllViews(); } } - } //-------------------------------------------------------------------------------------------------- @@ -213,7 +261,7 @@ cvf::Vec3d RimFracture::fracturePosition() const //-------------------------------------------------------------------------------------------------- double RimFracture::wellFractureAzimuthDiff() const { - double wellDifference = fabs(wellAzimuthAtFracturePosition() - azimuth); + double wellDifference = fabs(wellAzimuthAtFracturePosition() - m_azimuth); return wellDifference; } @@ -243,7 +291,7 @@ cvf::BoundingBox RimFracture::boundingBoxInDomainCoords() this->triangleGeometry(&triangleIndices, &nodeCoordVec); cvf::BoundingBox fractureBBox; - for (cvf::Vec3f nodeCoord : nodeCoordVec) fractureBBox.add(nodeCoord); + for (const auto& nodeCoord : nodeCoordVec) fractureBBox.add(nodeCoord); return fractureBBox; } @@ -252,30 +300,17 @@ cvf::BoundingBox RimFracture::boundingBoxInDomainCoords() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFracture::wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const +double RimFracture::wellRadius() const { if (m_fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) { - if (unitSystem == RiaEclipseUnitTools::UNITS_FIELD) - { - return RiaEclipseUnitTools::meterToFeet(wellDiameter / 2); - } - else - { - return wellDiameter / 2; - } + return m_wellDiameter / 2.0; } else if (m_fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) { - if (unitSystem == RiaEclipseUnitTools::UNITS_METRIC) - { - return RiaEclipseUnitTools::inchToMeter(wellDiameter / 2); - } - else - { - return RiaEclipseUnitTools::inchToFeet(wellDiameter / 2); - } + return RiaEclipseUnitTools::inchToFeet(m_wellDiameter / 2.0); } + return cvf::UNDEFINED_DOUBLE; } @@ -295,17 +330,17 @@ cvf::Mat4d RimFracture::transformMatrix() const cvf::Vec3d center = anchorPosition(); // Dip (in XY plane) - cvf::Mat4d dipRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(dip())); + cvf::Mat4d dipRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(m_dip())); // Dip (out of XY plane) - cvf::Mat4d tiltRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(tilt())); + cvf::Mat4d tiltRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(m_tilt())); // Ellipsis geometry is produced in XY-plane, rotate 90 deg around X to get zero azimuth along Y cvf::Mat4d rotationFromTesselator = cvf::Mat4d::fromRotation(cvf::Vec3d::X_AXIS, cvf::Math::toRadians(90.0f)); // Azimuth rotation - cvf::Mat4d azimuthRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(-azimuth()-90)); + cvf::Mat4d azimuthRotation = cvf::Mat4d::fromRotation(cvf::Vec3d::Z_AXIS, cvf::Math::toRadians(-m_azimuth()-90)); cvf::Mat4d m = azimuthRotation * rotationFromTesselator * dipRotation * tiltRotation; m.setTranslation(center); @@ -316,26 +351,47 @@ cvf::Mat4d RimFracture::transformMatrix() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFracture::triangleGeometry(std::vector* triangleIndices, std::vector* nodeCoords) +void RimFracture::setFractureTemplateNoUpdate(RimFractureTemplate* fractureTemplate) { - RimFractureTemplate* fractureDef = fractureTemplate(); - if (fractureDef ) - { - fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices, fractureUnit()); - } + if (fractureTemplate && fractureTemplate->fractureTemplateUnit() != fractureUnit()) + { + QString fractureUnitText = RiaEclipseUnitTools::UnitSystemType::uiText(fractureUnit()); - cvf::Mat4d m = transformMatrix(); + QString warningText = + QString("Using a fracture template defined in a different unit is not supported.\n\nPlease select a " + "fracture template of unit '%1'") + .arg(fractureUnitText); - for (cvf::Vec3f& v : *nodeCoords) - { - cvf::Vec3d vd(v); + QMessageBox::warning(nullptr, "Fracture Template Selection", warningText); - vd.transformPoint(m); + return; + } - v = cvf::Vec3f(vd); - } + m_fractureTemplate = fractureTemplate; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFracture::triangleGeometry(std::vector* triangleIndices, std::vector* nodeCoords) +{ + RimFractureTemplate* fractureDef = fractureTemplate(); + if (fractureDef) + { + fractureDef->fractureTriangleGeometry(nodeCoords, triangleIndices); + } + + cvf::Mat4d m = transformMatrix(); + + for (cvf::Vec3f& v : *nodeCoords) + { + cvf::Vec3d vd(v); + + vd.transformPoint(m); + + v = cvf::Vec3f(vd); + } +} //-------------------------------------------------------------------------------------------------- /// @@ -359,20 +415,26 @@ QList RimFracture::calculateValueOptions(const caf::PdmF RimProject* proj = RiaApplication::instance()->project(); CVF_ASSERT(proj); - RimOilField* oilField = proj->activeOilField(); - if (oilField == nullptr) return options; - if (fieldNeedingOptions == &m_fractureTemplate) { - RimFractureTemplateCollection* fracDefColl = oilField->fractureDefinitionCollection(); - if (fracDefColl == nullptr) return options; - - for (RimFractureTemplate* fracDef : fracDefColl->fractureDefinitions()) + RimOilField* oilField = proj->activeOilField(); + if (oilField && oilField->fractureDefinitionCollection) { - options.push_back(caf::PdmOptionItemInfo(fracDef->name(), fracDef)); + RimFractureTemplateCollection* fracDefColl = oilField->fractureDefinitionCollection(); + + for (RimFractureTemplate* fracDef : fracDefColl->fractureTemplates()) + { + QString displayText = fracDef->nameAndUnit(); + if (fracDef->fractureTemplateUnit() != fractureUnit()) + { + displayText += " (non-matching unit)"; + } + + options.push_back(caf::PdmOptionItemInfo(displayText, fracDef)); + } } } - else if (fieldNeedingOptions == &stimPlanTimeIndexToPlot) + else if (fieldNeedingOptions == &m_stimPlanTimeIndexToPlot) { if (fractureTemplate()) { @@ -402,26 +464,26 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO { if (m_fractureUnit() == RiaEclipseUnitTools::UNITS_METRIC) { - wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); - perforationLength.uiCapability()->setUiName("Perforation Length [m]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [m]"); } else if (m_fractureUnit() == RiaEclipseUnitTools::UNITS_FIELD) { - wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); - perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [ft]"); } if (fractureTemplate()) { - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { m_uiWellPathAzimuth.uiCapability()->setUiHidden(true); m_uiWellFractureAzimuthDiff.uiCapability()->setUiHidden(true); m_wellFractureAzimuthAngleWarning.uiCapability()->setUiHidden(true); } - else if (fractureTemplate()->orientationType == RimFractureTemplate::AZIMUTH) + else if (fractureTemplate()->orientationType() == RimFractureTemplate::AZIMUTH) { m_uiWellPathAzimuth.uiCapability()->setUiHidden(false); m_uiWellFractureAzimuthDiff.uiCapability()->setUiHidden(false); @@ -437,50 +499,51 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO } } - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - azimuth.uiCapability()->setUiReadOnly(true); + m_azimuth.uiCapability()->setUiReadOnly(true); } - else if (fractureTemplate()->orientationType == RimFractureTemplate::AZIMUTH) + else if (fractureTemplate()->orientationType() == RimFractureTemplate::AZIMUTH) { - azimuth.uiCapability()->setUiReadOnly(false); + m_azimuth.uiCapability()->setUiReadOnly(false); } - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { - perforationEfficiency.uiCapability()->setUiHidden(false); - perforationLength.uiCapability()->setUiHidden(false); + m_perforationEfficiency.uiCapability()->setUiHidden(false); + m_perforationLength.uiCapability()->setUiHidden(false); } else { - perforationEfficiency.uiCapability()->setUiHidden(true); - perforationLength.uiCapability()->setUiHidden(true); + m_perforationEfficiency.uiCapability()->setUiHidden(true); + m_perforationLength.uiCapability()->setUiHidden(true); } - if (fractureTemplate()->conductivityType == RimFractureTemplate::FINITE_CONDUCTIVITY) + if (fractureTemplate()->conductivityType() == RimFractureTemplate::FINITE_CONDUCTIVITY) { - wellDiameter.uiCapability()->setUiHidden(false); + m_wellDiameter.uiCapability()->setUiHidden(false); } - else if (fractureTemplate()->conductivityType == RimFractureTemplate::INFINITE_CONDUCTIVITY) + else if (fractureTemplate()->conductivityType() == RimFractureTemplate::INFINITE_CONDUCTIVITY) { - wellDiameter.uiCapability()->setUiHidden(true); + m_wellDiameter.uiCapability()->setUiHidden(true); } RimFractureTemplate* fracTemplate = fractureTemplate(); if (dynamic_cast(fracTemplate)) { - stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(false); - stimPlanTimeIndexToPlot.uiCapability()->setUiReadOnly(true); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(false); + + m_stimPlanTimeIndexToPlot.uiCapability()->setUiReadOnly(true); } else { - stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); } } else { - stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); + m_stimPlanTimeIndexToPlot.uiCapability()->setUiHidden(true); } } @@ -489,7 +552,7 @@ void RimFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiO //-------------------------------------------------------------------------------------------------- void RimFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) { - if (field == &azimuth) + if (field == &m_azimuth) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -499,7 +562,7 @@ void RimFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, QStrin } } - if (field == &perforationEfficiency) + if (field == &m_perforationEfficiency) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); if (myAttr) @@ -587,7 +650,7 @@ size_t RimFracture::findAnchorEclipseCell(const RigMainGrid* mainGrid ) const //-------------------------------------------------------------------------------------------------- void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) { - m_fractureTemplate = fractureTemplate; + setFractureTemplateNoUpdate(fractureTemplate); if (!fractureTemplate) { @@ -597,19 +660,19 @@ void RimFracture::setFractureTemplate(RimFractureTemplate* fractureTemplate) RimStimPlanFractureTemplate* stimPlanFracTemplate = dynamic_cast(fractureTemplate); if (stimPlanFracTemplate) { - stimPlanTimeIndexToPlot = stimPlanFracTemplate->activeTimeStepIndex(); + m_stimPlanTimeIndexToPlot = stimPlanFracTemplate->activeTimeStepIndex(); } - if (fractureTemplate->orientationType == RimFractureTemplate::AZIMUTH) + if (fractureTemplate->orientationType() == RimFractureTemplate::AZIMUTH) { - azimuth = fractureTemplate->azimuthAngle; + m_azimuth = fractureTemplate->azimuthAngle(); } else { this->updateAzimuthBasedOnWellAzimuthAngle(); } - this->wellDiameter = fractureTemplate->wellDiameterInFractureUnit(m_fractureUnit()); - this->perforationLength = fractureTemplate->perforationLengthInFractureUnit(m_fractureUnit()); + this->m_wellDiameter = fractureTemplate->wellDiameter(); + this->m_perforationLength = fractureTemplate->perforationLength(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h index 6d75ca5b0d..915822e312 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFracture.h @@ -29,7 +29,6 @@ #include "cvfMatrix4.h" #include "cvfPlane.h" -#include "cafAppEnum.h" #include "cafPdmChildField.h" #include "cafPdmFieldCvfVec3d.h" #include "cafPdmProxyValueField.h" @@ -43,6 +42,7 @@ class RimFractureTemplate; class RigFracturedEclipseCellExportData; class RigMainGrid; + //================================================================================================== /// /// @@ -55,18 +55,12 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf RimFracture(void); virtual ~RimFracture(void); - caf::PdmField azimuth; - caf::PdmField perforationLength; - caf::PdmField perforationEfficiency; - caf::PdmField wellDiameter; - - caf::PdmField dip; - caf::PdmField tilt; - - caf::PdmField stimPlanTimeIndexToPlot; - + double perforationLength() const; + double perforationEfficiency() const; + + void setStimPlanTimeIndexToPlot(int timeIndex); - double wellRadius(RiaEclipseUnitTools::UnitSystem unitSystem) const; + double wellRadius() const; cvf::Vec3d anchorPosition() const ; void setAnchorPosition(const cvf::Vec3d& pos); RiaEclipseUnitTools::UnitSystem fractureUnit() const; @@ -78,6 +72,7 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf cvf::Mat4d transformMatrix() const; + void setFractureTemplateNoUpdate(RimFractureTemplate* fractureTemplate); void setFractureTemplate(RimFractureTemplate* fractureTemplate); RimFractureTemplate* fractureTemplate() const; @@ -95,7 +90,10 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf virtual double fractureMD() const = 0; virtual void loadDataAndUpdate() = 0; + virtual std::vector perforationLengthCenterLineCoords() const = 0; + friend class RimFractureTemplate; + protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; @@ -115,13 +113,20 @@ class RimFracture : public RimCheckableNamedObject, public Rim3dPropertiesInterf caf::PdmProxyValueField m_uiAnchorPosition; caf::PdmField< RiaEclipseUnitTools::UnitSystemType > m_fractureUnit; - caf::PdmProxyValueField m_uiWellPathAzimuth; - caf::PdmProxyValueField m_uiWellFractureAzimuthDiff; - caf::PdmField m_wellFractureAzimuthAngleWarning; + caf::PdmProxyValueField m_uiWellPathAzimuth; + caf::PdmProxyValueField m_uiWellFractureAzimuthDiff; + caf::PdmField m_wellFractureAzimuthAngleWarning; + caf::PdmField m_dip; + caf::PdmField m_tilt; + caf::PdmField m_azimuth; + caf::PdmField m_perforationLength; + caf::PdmField m_perforationEfficiency; + caf::PdmField m_wellDiameter; + caf::PdmField m_stimPlanTimeIndexToPlot; private: - caf::PdmField m_anchorPosition; + caf::PdmField m_anchorPosition; - cvf::ref m_fracturePartMgr; + cvf::ref m_fracturePartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp index bb6bc3816f..3d303b5e2c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.cpp @@ -116,6 +116,22 @@ bool RimFractureContainment::isEclipseCellWithinContainment(const RigMainGrid* m return true; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureContainment::setTopKLayer(int topKLayer) +{ + m_topKLayer = topKLayer; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureContainment::setBaseKLayer(int baseKLayer) +{ + m_baseKLayer = baseKLayer; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h index 52089c4a6d..c5c3257762 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainment.h @@ -41,6 +41,9 @@ class RimFractureContainment : public caf::PdmObject bool isEnabled() const { return m_isUsingFractureContainment();} bool isEclipseCellWithinContainment(const RigMainGrid* mainGrid, size_t anchorEclipseCell, size_t globalCellIndex) const; + void setTopKLayer(int topKLayer); + void setBaseKLayer(int baseKLayer); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; protected: diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp index d03302b918..1e3e012bba 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.cpp @@ -18,6 +18,7 @@ #include "RimFractureTemplate.h" +#include "RiaFractureDefines.h" #include "RigTesselatorTools.h" #include "RimFracture.h" @@ -26,6 +27,9 @@ #include "cafPdmObject.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "cafPdmUiDoubleValueEditor.h" +#include "cafPdmUiTextEditor.h" +#include "cafPdmUiPushButtonEditor.h" #include "cvfVector3.h" @@ -36,9 +40,9 @@ namespace caf template<> void caf::AppEnum< RimFractureTemplate::FracOrientationEnum>::setUp() { - addItem(RimFractureTemplate::AZIMUTH, "Az", "Azimuth"); - addItem(RimFractureTemplate::ALONG_WELL_PATH, "AlongWellPath", "Along Well Path"); - addItem(RimFractureTemplate::TRANSVERSE_WELL_PATH, "TransverseWellPath", "Transverse (normal) to Well Path"); + addItem(RimFractureTemplate::AZIMUTH, "Az", "Azimuth"); + addItem(RimFractureTemplate::ALONG_WELL_PATH, "AlongWellPath", "Along Well Path"); + addItem(RimFractureTemplate::TRANSVERSE_WELL_PATH, "TransverseWellPath", "Transverse (normal) to Well Path"); setDefault(RimFractureTemplate::TRANSVERSE_WELL_PATH); } @@ -47,43 +51,122 @@ namespace caf void caf::AppEnum< RimFractureTemplate::FracConductivityEnum>::setUp() { addItem(RimFractureTemplate::INFINITE_CONDUCTIVITY, "InfiniteConductivity", "Infinite Conductivity"); - addItem(RimFractureTemplate::FINITE_CONDUCTIVITY, "FiniteConductivity", "Finite Conductivity"); + addItem(RimFractureTemplate::FINITE_CONDUCTIVITY, "FiniteConductivity", "Finite Conductivity"); setDefault(RimFractureTemplate::INFINITE_CONDUCTIVITY); } + template<> + void caf::AppEnum< RimFractureTemplate::PermeabilityEnum>::setUp() + { + addItem(RimFractureTemplate::USER_DEFINED_PERMEABILITY, "UserDefinedPermeability", "User Defined"); + addItem(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE, "FractureConductivity", "Use Fracture Conductivity"); + + setDefault(RimFractureTemplate::CONDUCTIVITY_FROM_FRACTURE); + } + + template<> + void caf::AppEnum::setUp() + { + addItem(RimFractureTemplate::USER_DEFINED_WIDTH, "UserDefinedWidth", "User Defined"); + addItem(RimFractureTemplate::WIDTH_FROM_FRACTURE, "FractureWidth", "Use Fracture Width"); + + setDefault(RimFractureTemplate::WIDTH_FROM_FRACTURE); + } + template<> + void caf::AppEnum::setUp() + { + addItem(RimFractureTemplate::NON_DARCY_NONE, "None", "None"); + addItem(RimFractureTemplate::NON_DARCY_COMPUTED, "Computed", "Compute D-factor"); + addItem(RimFractureTemplate::NON_DARCY_USER_DEFINED,"UserDefined", "User Defined D-factor"); + + setDefault(RimFractureTemplate::NON_DARCY_NONE); + } } +// TODO Move to cafPdmObject.h +#define CAF_PDM_InitField_Basic(field, keyword, default, uiName) CAF_PDM_InitField(field, keyword, default, uiName, "", "", "") + CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimFractureTemplate, "RimFractureTemplate"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFractureTemplate::RimFractureTemplate(void) +RimFractureTemplate::RimFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); - CAF_PDM_InitField(&name, "UserDescription", QString("Fracture Template"), "Name", "", "", ""); - CAF_PDM_InitField(&fractureTemplateUnit,"UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); - fractureTemplateUnit.uiCapability()->setUiReadOnly(true); + CAF_PDM_InitField(&m_id, "Id", -1, "ID", "", "", ""); + m_id.uiCapability()->setUiReadOnly(true); - CAF_PDM_InitField(&orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); - CAF_PDM_InitField(&azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle", "", "", ""); //Is this correct description? - CAF_PDM_InitField(&skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", ""); + CAF_PDM_InitField(&m_name, "UserDescription", QString("Fracture Template"), "Name", "", "", ""); - CAF_PDM_InitField(&perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); - CAF_PDM_InitField(&perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); - perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); - CAF_PDM_InitField(&wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_nameAndUnit, "NameAndUnit", "NameAndUnit", "", "", ""); + m_nameAndUnit.registerGetMethod(this, &RimFractureTemplate::nameAndUnit); + m_nameAndUnit.uiCapability()->setUiHidden(true); + m_nameAndUnit.xmlCapability()->disableIO(); - CAF_PDM_InitField(&conductivityType, "ConductivityType", caf::AppEnum(FINITE_CONDUCTIVITY), "Conductivity in Fracture", "", "", ""); + CAF_PDM_InitField(&m_fractureTemplateUnit, "UnitSystem", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Units System", "", "", ""); + m_fractureTemplateUnit.uiCapability()->setUiReadOnly(true); + + CAF_PDM_InitField(&m_orientationType, "Orientation", caf::AppEnum(TRANSVERSE_WELL_PATH), "Fracture Orientation", "", "", ""); + CAF_PDM_InitField(&m_azimuthAngle, "AzimuthAngle", 0.0f, "Azimuth Angle", "", "", ""); //Is this correct description? + CAF_PDM_InitField(&m_skinFactor, "SkinFactor", 0.0f, "Skin Factor", "", "", ""); + + CAF_PDM_InitField(&m_perforationLength, "PerforationLength", 1.0, "Perforation Length", "", "", ""); + + CAF_PDM_InitField(&m_perforationEfficiency, "PerforationEfficiency", 1.0, "Perforation Efficiency", "", "", ""); + m_perforationEfficiency.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleSliderEditor::uiEditorTypeName()); + + CAF_PDM_InitField(&m_wellDiameter, "WellDiameter", 0.216, "Well Diameter at Fracture", "", "", ""); + CAF_PDM_InitField(&m_conductivityType, "ConductivityType", caf::AppEnum(FINITE_CONDUCTIVITY), "Conductivity in Fracture", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_fractureContainment, "FractureContainmentField", "Fracture Containment", "", "", ""); m_fractureContainment = new RimFractureContainment(); m_fractureContainment.uiCapability()->setUiTreeHidden(true); m_fractureContainment.uiCapability()->setUiTreeChildrenHidden(true); + + // Non-Darcy Flow options + CAF_PDM_InitFieldNoDefault(&m_nonDarcyFlowType, "NonDarcyFlowType", "Non-Darcy Flow", "", "", ""); + + CAF_PDM_InitField(&m_userDefinedDFactor, "UserDefinedDFactor", 1.0, "D Factor", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_fractureWidthType, "FractureWidthType", "Type", "", "", ""); + CAF_PDM_InitField_Basic(&m_fractureWidth, "FractureWidth", 0.01, "Fracture Width (h)"); + + CAF_PDM_InitField_Basic(&m_inertialCoefficient, "InertialCoefficient", 0.006083236, "Inertial Coefficient (β) [Forch. unit]"); + + CAF_PDM_InitFieldNoDefault(&m_permeabilityType, "PermeabilityType", "Type", "", "", ""); + CAF_PDM_InitField_Basic(&m_relativePermeability, "RelativePermeability", 1.0, "Relative Permeability"); + CAF_PDM_InitField(&m_userDefinedEffectivePermeability, "EffectivePermeability",0.0, "Effective Permeability (Ke) [mD]", "", "", ""); + + CAF_PDM_InitField(&m_relativeGasDensity, "RelativeGasDensity", 0.8, "Relative Gas Density (γ)", "", "Relative density of gas at surface conditions with respect to air at STP", ""); + CAF_PDM_InitField(&m_gasViscosity, "GasViscosity", 0.02, "Gas Viscosity (μ) [cP]", "", "Gas viscosity at bottom hole pressure", ""); + + CAF_PDM_InitFieldNoDefault(&m_dFactorDisplayField, "dFactorDisplayField", "D Factor", "", "", ""); + m_dFactorDisplayField.registerGetMethod(this, &RimFractureTemplate::dFactor); + m_dFactorDisplayField.uiCapability()->setUiEditorTypeName(caf::PdmUiDoubleValueEditor::uiEditorTypeName()); + m_dFactorDisplayField.uiCapability()->setUiReadOnly(true); + m_dFactorDisplayField.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault(&m_dFactorSummaryText, "dFactorSummaryText", "D Factor Summary", "", "", ""); + m_dFactorSummaryText.registerGetMethod(this, &RimFractureTemplate::dFactorSummary); + m_dFactorSummaryText.uiCapability()->setUiReadOnly(true); + m_dFactorSummaryText.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); + m_dFactorSummaryText.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::LabelPosType::TOP); + m_dFactorSummaryText.xmlCapability()->disableIO(); + + CAF_PDM_InitField(&m_heightScaleFactor, "HeightScaleFactor", 1.0, "Height", "", "", ""); + CAF_PDM_InitField(&m_widthScaleFactor, "WidthScaleFactor", 1.0, "Width", "", "", ""); + CAF_PDM_InitField(&m_dFactorScaleFactor, "DFactorScaleFactor", 1.0, "D-factor", "", "", ""); + CAF_PDM_InitField(&m_conductivityScaleFactor, "ConductivityFactor", 1.0, "Conductivity", "", "The conductivity values read from file will be scaled with this parameters", ""); + CAF_PDM_InitField(&m_scaleApplyButton, "ScaleApplyButton", false, "Apply", "", "", ""); + + m_scaleApplyButton.xmlCapability()->disableIO(); + m_scaleApplyButton.uiCapability()->setUiEditorTypeName(caf::PdmUiPushButtonEditor::uiEditorTypeName()); + m_scaleApplyButton.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); } //-------------------------------------------------------------------------------------------------- @@ -93,12 +176,60 @@ RimFractureTemplate::~RimFractureTemplate() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFractureTemplate::id() const +{ + return m_id; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setName(const QString& name) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setFractureTemplateUnit(RiaEclipseUnitTools::UnitSystemType unitSystem) +{ + m_fractureTemplateUnit = unitSystem; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFractureTemplate::name() const +{ + return m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate::FracOrientationEnum RimFractureTemplate::orientationType() const +{ + return m_orientationType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaEclipseUnitTools::UnitSystemType RimFractureTemplate::fractureTemplateUnit() const +{ + return m_fractureTemplateUnit(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() { - return &name; + return &m_nameAndUnit; } //-------------------------------------------------------------------------------------------------- @@ -106,7 +237,8 @@ caf::PdmFieldHandle* RimFractureTemplate::userDescriptionField() //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - if (changedField == &azimuthAngle || changedField == &orientationType) + bool createDisplayModelAndRedraw = false; + if (changedField == &m_azimuthAngle || changedField == &m_orientationType) { //Changes to one of these parameters should change all fractures with this fracture template attached. RimProject* proj; @@ -121,27 +253,27 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { if (fracture->fractureTemplate() == this) { - if (changedField == &azimuthAngle && (fabs(oldValue.toDouble() - fracture->azimuth()) < 1e-5)) + if (changedField == &m_azimuthAngle && (fabs(oldValue.toDouble() - fracture->m_azimuth()) < 1e-5)) { - fracture->azimuth = azimuthAngle; + fracture->m_azimuth = m_azimuthAngle; } - if (changedField == &orientationType) + if (changedField == &m_orientationType) { if (newValue == AZIMUTH) { - fracture->azimuth = azimuthAngle; + fracture->m_azimuth = m_azimuthAngle; } else fracture->updateAzimuthBasedOnWellAzimuthAngle(); } } } - proj->createDisplayModelAndRedrawAllViews(); + createDisplayModelAndRedraw = true; } } - if (changedField == &perforationLength || changedField == &perforationEfficiency || changedField == &wellDiameter) + if (changedField == &m_perforationLength || changedField == &m_perforationEfficiency || changedField == &m_wellDiameter) { RimProject* proj; this->firstAncestorOrThisOfType(proj); @@ -153,21 +285,36 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie { if (fracture->fractureTemplate() == this) { - if (changedField == &perforationLength && (fabs(oldValue.toDouble() - fracture->perforationLength()) < 1e-5)) + if (changedField == &m_perforationLength && (fabs(oldValue.toDouble() - fracture->m_perforationLength()) < 1e-5)) { - fracture->perforationLength = perforationLength; + fracture->m_perforationLength = m_perforationLength; } - if (changedField == &perforationEfficiency && (fabs(oldValue.toDouble() - fracture->perforationEfficiency()) < 1e-5)) + if (changedField == &m_perforationEfficiency && (fabs(oldValue.toDouble() - fracture->m_perforationEfficiency()) < 1e-5)) { - fracture->perforationEfficiency = perforationEfficiency; + fracture->m_perforationEfficiency = m_perforationEfficiency; } - if (changedField == &wellDiameter && (fabs(oldValue.toDouble() - fracture->wellDiameter()) < 1e-5)) + if (changedField == &m_wellDiameter && (fabs(oldValue.toDouble() - fracture->m_wellDiameter()) < 1e-5)) { - fracture->wellDiameter = wellDiameter; + fracture->m_wellDiameter = m_wellDiameter; } } } } + + if (changedField == &m_perforationLength) + { + createDisplayModelAndRedraw = true; + } + + if (createDisplayModelAndRedraw) + { + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->reloadCompletionTypeResultsInAllViews(); + } + } } //-------------------------------------------------------------------------------------------------- @@ -175,111 +322,446 @@ void RimFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* changedFie //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { + prepareFieldsForUiDisplay(); + + { + auto group = uiOrdering.addNewGroup("Sensitivity Scale Factors"); + group->setCollapsedByDefault(false); + group->add(&m_heightScaleFactor); + group->add(&m_widthScaleFactor); + group->add(&m_dFactorScaleFactor); + group->add(&m_conductivityScaleFactor); + + group->add(&m_scaleApplyButton); + } + + auto nonDarcyFlowGroup = uiOrdering.addNewGroup("Non-Darcy Flow"); + nonDarcyFlowGroup->add(&m_nonDarcyFlowType); + + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) + { + nonDarcyFlowGroup->add(&m_userDefinedDFactor); + } + + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_COMPUTED) + { + nonDarcyFlowGroup->add(&m_inertialCoefficient); + + { + auto group = nonDarcyFlowGroup->addNewGroup("Effective Permeability"); + group->add(&m_permeabilityType); + group->add(&m_relativePermeability); + group->add(&m_userDefinedEffectivePermeability); + } + + { + auto group = nonDarcyFlowGroup->addNewGroup("Width"); + group->add(&m_fractureWidthType); + group->add(&m_fractureWidth); + } + + nonDarcyFlowGroup->add(&m_relativeGasDensity); + nonDarcyFlowGroup->add(&m_gasViscosity); + nonDarcyFlowGroup->add(&m_dFactorDisplayField); + + { + auto group = nonDarcyFlowGroup->addNewGroup("D Factor Details"); + group->setCollapsedByDefault(true); + group->add(&m_dFactorSummaryText); + } + } + + uiOrdering.add(&m_fractureTemplateUnit); + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_perforationEfficiency) + { + auto myAttr = dynamic_cast(attribute); + if (myAttr) + { + myAttr->m_minimum = 0; + myAttr->m_maximum = 1.0; + } + } + + if (field == &m_dFactorSummaryText) + { + auto myAttr = dynamic_cast(attribute); + if (myAttr) + { + myAttr->wrapMode = caf::PdmUiTextEditorAttribute::NoWrap; + + QFont font("Monospace", 10); + myAttr->font = font; + myAttr->textMode = caf::PdmUiTextEditorAttribute::HTML; + } + } + + if (field == &m_scaleApplyButton) + { + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + if (attrib) + { + attrib->m_buttonText = "Apply"; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimFractureTemplate::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + if (fieldNeedingOptions == &m_fractureWidthType) { - wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); - perforationLength.uiCapability()->setUiName("Perforation Length [m]"); + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(USER_DEFINED_WIDTH), USER_DEFINED_WIDTH)); + + auto widthAndCond = widthAndConductivityAtWellPathIntersection(); + if (widthAndCond.isValid()) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(WIDTH_FROM_FRACTURE), WIDTH_FROM_FRACTURE)); + } + else + { + m_fractureWidthType = USER_DEFINED_WIDTH; + } } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::prepareFieldsForUiDisplay() +{ + if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + m_wellDiameter.uiCapability()->setUiName("Well Diameter [m]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [m]"); + m_fractureWidth.uiCapability()->setUiName("Fracture Width [m]"); + } + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); - perforationLength.uiCapability()->setUiName("Perforation Length [Ft]"); + m_wellDiameter.uiCapability()->setUiName("Well Diameter [inches]"); + m_perforationLength.uiCapability()->setUiName("Perforation Length [ft]"); + m_fractureWidth.uiCapability()->setUiName("Fracture Width [ft]"); } - if (orientationType == RimFractureTemplate::ALONG_WELL_PATH - || orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH + || m_orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - azimuthAngle.uiCapability()->setUiHidden(true); + m_azimuthAngle.uiCapability()->setUiHidden(true); } - else if (orientationType == RimFractureTemplate::AZIMUTH) + else if (m_orientationType == RimFractureTemplate::AZIMUTH) { - azimuthAngle.uiCapability()->setUiHidden(false); + m_azimuthAngle.uiCapability()->setUiHidden(false); } - if (orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (m_orientationType == RimFractureTemplate::ALONG_WELL_PATH) { - perforationEfficiency.uiCapability()->setUiHidden(false); - perforationLength.uiCapability()->setUiHidden(false); + m_perforationEfficiency.uiCapability()->setUiHidden(false); + m_perforationLength.uiCapability()->setUiHidden(false); } else { - perforationEfficiency.uiCapability()->setUiHidden(true); - perforationLength.uiCapability()->setUiHidden(true); + m_perforationEfficiency.uiCapability()->setUiHidden(true); + m_perforationLength.uiCapability()->setUiHidden(true); + } + + if (m_conductivityType == FINITE_CONDUCTIVITY) + { + m_wellDiameter.uiCapability()->setUiHidden(false); + } + else if (m_conductivityType == INFINITE_CONDUCTIVITY) + { + m_wellDiameter.uiCapability()->setUiHidden(true); + } + + // Non Darcy Flow + + auto values = widthAndConductivityAtWellPathIntersection(); + if (!values.isValid()) + { + m_fractureWidthType = RimFractureTemplate::USER_DEFINED_WIDTH; + } + + if (m_fractureWidthType == RimFractureTemplate::USER_DEFINED_WIDTH) + { + m_fractureWidth.uiCapability()->setUiReadOnly(false); + } + else + { + m_fractureWidth = values.m_width; + + m_fractureWidth.uiCapability()->setUiReadOnly(true); } - if (conductivityType == FINITE_CONDUCTIVITY) + if (m_permeabilityType == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { - wellDiameter.uiCapability()->setUiHidden(false); + m_relativePermeability.uiCapability()->setUiHidden(true); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(false); } - else if (conductivityType == INFINITE_CONDUCTIVITY) + else { - wellDiameter.uiCapability()->setUiHidden(true); + m_relativePermeability.uiCapability()->setUiHidden(false); + m_userDefinedEffectivePermeability.uiCapability()->setUiHidden(true); } - } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +QString RimFractureTemplate::dFactorSummary() const +{ + QString text; + + auto val = dFactor(); + text += QString("D-factor : %1").arg(val); + + text += "
"; + text += "
"; + auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); + text += QString("α : %1").arg(alpha); + + text += "
"; + auto beta = m_inertialCoefficient; + text += QString("β : %1").arg(beta); + + text += "
"; + double effPerm = effectivePermeability(); + text += QString("Ke : %1").arg(effPerm); + + text += "
"; + double gamma = m_relativeGasDensity; + text += QString("γ : %1").arg(gamma); + + text += "
"; + auto h = fractureWidth(); + text += QString("h : %1").arg(h); + + text += "
"; + auto wellRadius = m_wellDiameter / 2.0; + text += QString("rw : %1").arg(wellRadius); + + text += "
"; + auto mu = m_gasViscosity; + text += QString("μ : %1").arg(mu); + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::effectivePermeability() const { - if (field == &perforationEfficiency) + if (m_permeabilityType() == RimFractureTemplate::USER_DEFINED_PERMEABILITY) { - caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); - if (myAttr) - { - myAttr->m_minimum = 0; - myAttr->m_maximum = 1.0; - } + return m_userDefinedEffectivePermeability; + } + else + { + auto values = widthAndConductivityAtWellPathIntersection(); + + auto fracPermeability = values.m_permeability; + + return fracPermeability * m_relativePermeability; } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::dFactor() const +{ + double d; + + if (m_nonDarcyFlowType == RimFractureTemplate::NON_DARCY_USER_DEFINED) + { + d = m_userDefinedDFactor; + } + else + { + auto alpha = RiaDefines::nonDarcyFlowAlpha(m_fractureTemplateUnit()); + auto beta = m_inertialCoefficient; + auto effPerm = effectivePermeability(); + auto gamma = m_relativeGasDensity; + + auto radius = m_wellDiameter / 2.0; + auto mu = m_gasViscosity; + auto h = fractureWidth(); + + double numerator = alpha * beta * effPerm * gamma; + double denumerator = h * radius * mu; + + if (denumerator < 1e-10) return HUGE_VAL; + + d = numerator / denumerator; + } + + return d * m_dFactorScaleFactor; +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit) +double RimFractureTemplate::kh() const { - if (fractureUnit == fractureTemplateUnit()) + // kh = permeability * h + // conductivity = permeability * h + + auto values = widthAndConductivityAtWellPathIntersection(); + if (values.m_conductivity != HUGE_VAL) { - return wellDiameter; + // If conductivity is found in stim plan file, use this directly + return values.m_conductivity; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC - && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) + + return effectivePermeability() * fractureWidth(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) +{ + if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) { - return RiaEclipseUnitTools::meterToInch(wellDiameter); + m_perforationLength = RiaEclipseUnitTools::feetToMeter(m_perforationLength); + m_wellDiameter = RiaEclipseUnitTools::inchToMeter(m_wellDiameter); + m_fractureWidth = RiaEclipseUnitTools::feetToMeter(m_fractureWidth); } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD - && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) + else if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) { - return RiaEclipseUnitTools::inchToMeter(wellDiameter); + m_perforationLength = RiaEclipseUnitTools::meterToFeet(m_perforationLength); + m_wellDiameter = RiaEclipseUnitTools::meterToInch(m_wellDiameter); + m_fractureWidth = RiaEclipseUnitTools::meterToFeet(m_fractureWidth); } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::disconnectAllFracturesAndRedrawViews() const +{ + // The unit has changed. Disconnect all fractures referencing this fracture template to avoid mix of units between fracture + // and template - return cvf::UNDEFINED_DOUBLE; + std::vector referringObjects; + this->objectsWithReferringPtrFields(referringObjects); + + for (auto objHandle : referringObjects) + { + RimFracture* fracture = dynamic_cast(objHandle); + if (fracture) + { + fracture->setFractureTemplate(nullptr); + } + } + + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -double RimFractureTemplate::perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit) +void RimFractureTemplate::setId(int id) { - if (fractureUnit == fractureTemplateUnit()) + m_id = id; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setScaleFactors(double width, double height, double dFactor, double conductivity) +{ + m_widthScaleFactor = width; + m_heightScaleFactor = height; + m_dFactorScaleFactor = dFactor; + m_conductivityScaleFactor = conductivity; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setContainmentTopKLayer(int topKLayer) +{ + m_fractureContainment->setTopKLayer(topKLayer); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplate::setContainmentBaseKLayer(int baseKLayer) +{ + m_fractureContainment->setBaseKLayer(baseKLayer); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::fractureWidth() const +{ + if (m_fractureWidthType == RimFractureTemplate::WIDTH_FROM_FRACTURE) { - return perforationLength; + auto values = widthAndConductivityAtWellPathIntersection(); + + return values.m_width; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC - && fractureUnit == RiaEclipseUnitTools::UNITS_FIELD) + + return m_fractureWidth; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFractureTemplate::nameAndUnit() const +{ + QString decoratedName; + + if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { - return RiaEclipseUnitTools::meterToFeet(perforationLength); + decoratedName += "[M] - "; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD - && fractureUnit == RiaEclipseUnitTools::UNITS_METRIC) + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - return RiaEclipseUnitTools::feetToMeter(perforationLength); + decoratedName += "[F] - "; } - return cvf::UNDEFINED_DOUBLE; + decoratedName += m_name; + + return decoratedName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::wellDiameter() +{ + return m_wellDiameter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimFractureTemplate::perforationLength() +{ + return m_perforationLength; } //-------------------------------------------------------------------------------------------------- @@ -290,17 +772,49 @@ const RimFractureContainment * RimFractureTemplate::fractureContainment() return m_fractureContainment(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate::FracConductivityEnum RimFractureTemplate::conductivityType() const +{ + return m_conductivityType(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimFractureTemplate::azimuthAngle() const +{ + return m_azimuthAngle; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimFractureTemplate::skinFactor() const +{ + return m_skinFactor; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimFractureTemplate::setDefaultWellDiameterFromUnit() { - if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) + if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD) { - wellDiameter = 8.5; + m_wellDiameter = 8.5; } - else if (fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) + else if (m_fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC) { - wellDiameter = 0.216; + m_wellDiameter = 0.216; } -} \ No newline at end of file +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFractureTemplate::isNonDarcyFlowEnabled() const +{ + return m_nonDarcyFlowType() != RimFractureTemplate::NON_DARCY_NONE; +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h index e053b9e0b0..af87b73e14 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplate.h @@ -21,20 +21,50 @@ #include "RiaEclipseUnitTools.h" #include "cafAppEnum.h" +#include "cafPdmChildField.h" #include "cafPdmField.h" +#include "cafPdmFieldCvfVec3d.h" #include "cafPdmFieldHandle.h" #include "cafPdmObject.h" -#include "cafPdmChildField.h" -#include "cafPdmFieldCvfVec3d.h" +#include "cafPdmProxyValueField.h" #include "cvfBase.h" #include "cvfVector3.h" #include +#include -class RigEclipseCaseData; class RigFractureGrid; class RimFractureContainment; +class MinMaxAccumulator; +class PosNegAccumulator; + +class FractureWidthAndConductivity +{ +public: + FractureWidthAndConductivity() + : m_width(0.0) + , m_permeability(0.0) + , m_conductivity(HUGE_VAL) + { + } + + bool isValid() const + { + if (m_width != 0.0) return true; + if (m_permeability != 0.0) return true; + + return false; + } + + // Unit : meter or feet + double m_width; + + // Unit : mD (milliDarcy) + double m_permeability; + + double m_conductivity; +}; //================================================================================================== /// @@ -45,54 +75,139 @@ class RimFractureTemplate : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - RimFractureTemplate(void); - virtual ~RimFractureTemplate(void); - - caf::PdmField name; - caf::PdmField azimuthAngle; - caf::PdmField skinFactor; - - caf::PdmField perforationLength; - caf::PdmField perforationEfficiency; - caf::PdmField wellDiameter; - enum FracOrientationEnum { AZIMUTH, ALONG_WELL_PATH, TRANSVERSE_WELL_PATH }; - caf::PdmField< caf::AppEnum< FracOrientationEnum > > orientationType; enum FracConductivityEnum { INFINITE_CONDUCTIVITY, FINITE_CONDUCTIVITY, }; - caf::PdmField< caf::AppEnum< FracConductivityEnum > > conductivityType; - caf::PdmField< RiaEclipseUnitTools::UnitSystemType > fractureTemplateUnit; + enum PermeabilityEnum + { + USER_DEFINED_PERMEABILITY, + CONDUCTIVITY_FROM_FRACTURE, + }; - void setDefaultWellDiameterFromUnit(); - double wellDiameterInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); - double perforationLengthInFractureUnit(RiaEclipseUnitTools::UnitSystemType fractureUnit); - - virtual void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) = 0; - virtual std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) = 0; + enum WidthEnum + { + USER_DEFINED_WIDTH, + WIDTH_FROM_FRACTURE, + }; + enum NonDarcyFlowEnum + { + NON_DARCY_NONE, + NON_DARCY_COMPUTED, + NON_DARCY_USER_DEFINED, + }; + +public: + RimFractureTemplate(); + virtual ~RimFractureTemplate(); + + int id() const; + QString name() const; + QString nameAndUnit() const; + + RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit() const; + FracOrientationEnum orientationType() const; + float azimuthAngle() const; + float skinFactor() const; + double wellDiameter(); + FracConductivityEnum conductivityType() const; + double perforationLength(); + + virtual void fractureTriangleGeometry(std::vector* nodeCoords, + std::vector* triangleIndices) = 0; + + virtual std::vector fractureBorderPolygon() = 0; virtual const RigFractureGrid* fractureGrid() const = 0; + const RimFractureContainment* fractureContainment(); - const RimFractureContainment * fractureContainment(); + virtual void appendDataToResultStatistics(const QString& resultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const = 0; -protected: - caf::PdmChildField m_fractureContainment; + virtual std::vector> uiResultNamesWithUnit() const = 0; + + void setName(const QString& name); + void setFractureTemplateUnit(RiaEclipseUnitTools::UnitSystemType unitSystem); + void setDefaultWellDiameterFromUnit(); + bool isNonDarcyFlowEnabled() const; + double dFactor() const; + double kh() const; + + virtual void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit); + + virtual void loadDataAndUpdate() = 0; + + void disconnectAllFracturesAndRedrawViews() const; + void setId(int id); + void setScaleFactors(double width, double height, double dFactor, double conductivity); + virtual void reload() {} + + void setContainmentTopKLayer(int topKLayer); + void setContainmentBaseKLayer(int baseKLayer); + +protected: virtual caf::PdmFieldHandle* userDescriptionField() override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); - + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + +private: + void prepareFieldsForUiDisplay(); + virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const = 0; + + QString dFactorSummary() const; + double effectivePermeability() const; + double fractureWidth() const; + +protected: + caf::PdmField m_id; + caf::PdmField m_name; + caf::PdmProxyValueField m_nameAndUnit; + + caf::PdmField m_fractureTemplateUnit; + caf::PdmField> m_orientationType; + caf::PdmField m_azimuthAngle; + caf::PdmField m_skinFactor; + caf::PdmField m_perforationLength; + caf::PdmField m_perforationEfficiency; + caf::PdmField m_wellDiameter; + caf::PdmField> m_conductivityType; + caf::PdmChildField m_fractureContainment; + + caf::PdmField> m_nonDarcyFlowType; + caf::PdmField m_userDefinedDFactor; + + caf::PdmField> m_fractureWidthType; + caf::PdmField m_fractureWidth; + caf::PdmField m_inertialCoefficient; + + caf::PdmField> m_permeabilityType; + caf::PdmField m_relativePermeability; + caf::PdmField m_userDefinedEffectivePermeability; + + caf::PdmField m_relativeGasDensity; + caf::PdmField m_gasViscosity; + + caf::PdmProxyValueField m_dFactorDisplayField; + caf::PdmProxyValueField m_dFactorSummaryText; + + caf::PdmField m_heightScaleFactor; + caf::PdmField m_widthScaleFactor; + caf::PdmField m_dFactorScaleFactor; + caf::PdmField m_conductivityScaleFactor; + caf::PdmField m_scaleApplyButton; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp index 81960b5880..46caf585da 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.cpp @@ -18,12 +18,29 @@ #include "RimFractureTemplateCollection.h" +#include "RiaLogging.h" + +#include "RigStatisticsMath.h" + +#include "RimCase.h" +#include "RimEclipseView.h" #include "RimEllipseFractureTemplate.h" +#include "RimFracture.h" #include "RimFractureTemplate.h" +#include "RimOilField.h" +#include "RimProject.h" +#include "RimSimWellInViewCollection.h" +#include "RimStimPlanColors.h" #include "RimStimPlanFractureTemplate.h" +#include "RimWellPath.h" +#include "RimWellPathCollection.h" +#include "RimWellPathFracture.h" +#include "RimWellPathFractureCollection.h" #include "cafPdmObject.h" +#include + CAF_PDM_SOURCE_INIT(RimFractureTemplateCollection, "FractureDefinitionCollection"); @@ -31,16 +48,19 @@ CAF_PDM_SOURCE_INIT(RimFractureTemplateCollection, "FractureDefinitionCollection //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimFractureTemplateCollection::RimFractureTemplateCollection(void) +RimFractureTemplateCollection::RimFractureTemplateCollection() { CAF_PDM_InitObject("Fracture Templates", ":/FractureTemplates16x16.png", "", ""); - CAF_PDM_InitField(&defaultUnitsForFracTemplates, "DefaultUnitForTemplates", + CAF_PDM_InitField(&m_defaultUnitsForFracTemplates, "DefaultUnitForTemplates", caf::AppEnum(RiaEclipseUnitTools::UNITS_METRIC), "Default unit system for fracture templates", "", "", ""); - CAF_PDM_InitFieldNoDefault(&fractureDefinitions, "FractureDefinitions", "", "", "", ""); - fractureDefinitions.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_fractureDefinitions, "FractureDefinitions", "", "", "", ""); + m_fractureDefinitions.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_nextValidFractureTemplateId, "NextValidFractureTemplateId", 0, "", "", "", ""); + m_nextValidFractureTemplateId.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -48,71 +68,173 @@ RimFractureTemplateCollection::RimFractureTemplateCollection(void) //-------------------------------------------------------------------------------------------------- RimFractureTemplateCollection::~RimFractureTemplateCollection() { - fractureDefinitions.deleteAllChildObjects(); + m_fractureDefinitions.deleteAllChildObjects(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector > RimFractureTemplateCollection::stimPlanResultNamesAndUnits() const +RimFractureTemplate* RimFractureTemplateCollection::fractureTemplate(int id) const { - std::set > nameSet; + for (const auto& templ : m_fractureDefinitions) + { + if (templ->id() == id) return templ; + } + return nullptr; +} - for (const RimFractureTemplate* f : fractureDefinitions()) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimFractureTemplateCollection::fractureTemplates() const +{ + std::vector templates; + for (auto& templ : m_fractureDefinitions) { - auto stimPlanFracture = dynamic_cast(f); - if (stimPlanFracture) - { - std::vector > namesAndUnits = stimPlanFracture->resultNamesWithUnit(); + templates.push_back(templ); + } + return templates; +} - for (auto nameAndUnit : namesAndUnits) - { - nameSet.insert(nameAndUnit); - } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplateCollection::addFractureTemplate(RimFractureTemplate* templ) +{ + templ->setId(nextFractureTemplateId()); + m_fractureDefinitions.push_back(templ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaEclipseUnitTools::UnitSystemType RimFractureTemplateCollection::defaultUnitSystemType() const +{ + return m_defaultUnitsForFracTemplates; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFractureTemplate* RimFractureTemplateCollection::firstFractureOfUnit(RiaEclipseUnitTools::UnitSystem unitSet) const +{ + for (RimFractureTemplate* f : m_fractureDefinitions()) + { + if (f->fractureTemplateUnit() == unitSet) + { + return f; } } - std::vector> names(nameSet.begin(), nameSet.end()); - - return names; + return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimFractureTemplateCollection::stimPlanResultNames() const +std::vector > RimFractureTemplateCollection::resultNamesAndUnits() const { - std::vector names; + std::set > nameSet; - for (auto nameAndUnit : stimPlanResultNamesAndUnits()) + for (const RimFractureTemplate* f : m_fractureDefinitions()) { - names.push_back(nameAndUnit.first); + std::vector > namesAndUnits = f->uiResultNamesWithUnit(); + + for (const auto& nameAndUnit : namesAndUnits) + { + nameSet.insert(nameAndUnit); + } } + std::vector> names(nameSet.begin(), nameSet.end()); + return names; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplateCollection::computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const +void RimFractureTemplateCollection::computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, + double* maxValue, double* posClosestToZero, double* negClosestToZero) const { - for (const RimFractureTemplate* f : fractureDefinitions()) + MinMaxAccumulator minMaxAccumulator; + PosNegAccumulator posNegAccumulator; + + for (const RimFractureTemplate* f : m_fractureDefinitions()) { - auto stimPlanFracture = dynamic_cast(f); - if (stimPlanFracture) + if (f) { - stimPlanFracture->computeMinMax(resultName, unit, minValue, maxValue, posClosestToZero, negClosestToZero); + f->appendDataToResultStatistics(uiResultName, unit, minMaxAccumulator, posNegAccumulator); } } + + if (*minValue) *minValue = minMaxAccumulator.min; + if (*maxValue) *maxValue = minMaxAccumulator.max; + if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos; + if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimFractureTemplateCollection::deleteFractureDefinitions() +void RimFractureTemplateCollection::createAndAssignTemplateCopyForNonMatchingUnit() { - fractureDefinitions.deleteAllChildObjects(); + // If a fracture has different unit than the associated template, create a copy of template in correct unit + + std::vector templatesToBeAdded; + + for (RimFractureTemplate* fractureTemplate : m_fractureDefinitions()) + { + if (fractureTemplate && fractureTemplate->fractureGrid()) + { + RimFractureTemplate* templateWithMatchingUnit = nullptr; + + std::vector referringObjects; + fractureTemplate->objectsWithReferringPtrFields(referringObjects); + + for (auto refObj : referringObjects) + { + auto fracture = dynamic_cast(refObj); + if (fracture && fracture->fractureUnit() != fractureTemplate->fractureTemplateUnit()) + { + if (!templateWithMatchingUnit) + { + templateWithMatchingUnit = dynamic_cast(fractureTemplate->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + + auto currentUnit = fractureTemplate->fractureTemplateUnit(); + auto neededUnit = RiaEclipseUnitTools::UNITS_UNKNOWN; + if (currentUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + neededUnit = RiaEclipseUnitTools::UNITS_FIELD; + } + else if (currentUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + neededUnit = RiaEclipseUnitTools::UNITS_METRIC; + } + + templateWithMatchingUnit->convertToUnitSystem(neededUnit); + + QString name = templateWithMatchingUnit->name(); + name += " (created to match fracture unit)"; + templateWithMatchingUnit->setName(name); + + templatesToBeAdded.push_back(templateWithMatchingUnit); + } + + RiaLogging::warning("Detected fracture with different unit than fracture template. Creating copy of template " + "with matching unit."); + + CVF_ASSERT(templateWithMatchingUnit->fractureTemplateUnit() == fracture->fractureUnit()); + fracture->setFractureTemplateNoUpdate(templateWithMatchingUnit); + } + } + } + } + + for (auto templateWithMatchingUnit : templatesToBeAdded) + { + m_fractureDefinitions.push_back(templateWithMatchingUnit); + } } //-------------------------------------------------------------------------------------------------- @@ -120,7 +242,7 @@ void RimFractureTemplateCollection::deleteFractureDefinitions() //-------------------------------------------------------------------------------------------------- void RimFractureTemplateCollection::loadAndUpdateData() { - for (RimFractureTemplate* f : fractureDefinitions()) + for (RimFractureTemplate* f : m_fractureDefinitions()) { RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); if (stimPlanFracture) @@ -135,7 +257,7 @@ void RimFractureTemplateCollection::loadAndUpdateData() //-------------------------------------------------------------------------------------------------- void RimFractureTemplateCollection::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - for (RimFractureTemplate* f : fractureDefinitions()) + for (RimFractureTemplate* f : m_fractureDefinitions()) { RimStimPlanFractureTemplate* stimPlanFracture = dynamic_cast(f); if (stimPlanFracture) @@ -151,3 +273,123 @@ void RimFractureTemplateCollection::updateFilePathsFromProjectPath(const QString } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFractureTemplateCollection::initAfterRead() +{ + // Assign template id if not already assigned + for (auto& templ : m_fractureDefinitions) + { + if (templ->id() < 0) templ->setId(nextFractureTemplateId()); + } + + RimProject* proj = nullptr; + this->firstAncestorOrThisOfType(proj); + if (proj && proj->isProjectFileVersionEqualOrOlderThan("2018.1.0.103")) + { + bool setAllShowMeshToFalseOnAllEclipseViews = false; + + std::vector wellPathFractures; + RimWellPathCollection* wellPathCollection = proj->activeOilField()->wellPathCollection(); + wellPathCollection->descendantsIncludingThisOfType(wellPathFractures); + + for (RimWellPathFracture* fracture : wellPathFractures) + { + RimStimPlanFractureTemplate* stimPlanFractureTemplate = dynamic_cast(fracture->fractureTemplate()); + if (stimPlanFractureTemplate) + { + if (stimPlanFractureTemplate->showStimPlanMesh() == false) + { + setAllShowMeshToFalseOnAllEclipseViews = true; + break; + } + } + } + + std::vector eclipseViews; + + std::vector rimCases; + proj->allCases(rimCases); + + for (RimCase* rimCase : rimCases) + { + for (Rim3dView* view : rimCase->views()) + { + RimEclipseView* eclView = dynamic_cast(view); + if (eclView) + { + eclipseViews.push_back(eclView); + } + } + } + + for (RimEclipseView* eclipseView : eclipseViews) + { + if (setAllShowMeshToFalseOnAllEclipseViews) + { + eclipseView->fractureColors()->setShowStimPlanMesh(false); + continue; + } + + //Find all fractures in all simWells + std::map stimPlanFractureTemplatesInView; + + std::vector fractures; + if (eclipseView->wellCollection()) + { + eclipseView->wellCollection()->descendantsIncludingThisOfType(fractures); + } + if (fractures.empty()) continue; + + for (RimFracture* fracture : fractures) + { + RimStimPlanFractureTemplate* stimPlanFractureTemplate = dynamic_cast(fracture->fractureTemplate()); + if (stimPlanFractureTemplate) + { + stimPlanFractureTemplatesInView[stimPlanFractureTemplate]; + } + } + + if (stimPlanFractureTemplatesInView.empty()) continue; + + auto templateIt = stimPlanFractureTemplatesInView.begin(); + + if (stimPlanFractureTemplatesInView.size() == 1) + { + eclipseView->fractureColors()->setShowStimPlanMesh(templateIt->first->showStimPlanMesh()); + } + else + { + bool anySetShowStimPlanMeshIsSetToFalse = false; + for (templateIt; templateIt != stimPlanFractureTemplatesInView.end(); templateIt++) + { + if (templateIt->first->showStimPlanMesh() == false) + { + anySetShowStimPlanMeshIsSetToFalse = true; + break; + } + } + if (anySetShowStimPlanMeshIsSetToFalse) + { + eclipseView->fractureColors()->setShowStimPlanMesh(false); + } + else + { + eclipseView->fractureColors()->setShowStimPlanMesh(true); + } + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFractureTemplateCollection::nextFractureTemplateId() +{ + int newId = m_nextValidFractureTemplateId; + m_nextValidFractureTemplateId = m_nextValidFractureTemplateId + 1; + + return newId; +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h index c6f71ec9c9..2f677287d6 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureTemplateCollection.h @@ -35,18 +35,31 @@ class RimFractureTemplateCollection : public caf::PdmObject CAF_PDM_HEADER_INIT; public: - RimFractureTemplateCollection(void); - virtual ~RimFractureTemplateCollection(void); - - caf::PdmChildArrayField fractureDefinitions; - caf::PdmField< RiaEclipseUnitTools::UnitSystemType > defaultUnitsForFracTemplates; + RimFractureTemplateCollection(); + virtual ~RimFractureTemplateCollection(); - std::vector > stimPlanResultNamesAndUnits() const; - std::vector stimPlanResultNames() const; - void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; + RimFractureTemplate* fractureTemplate(int id) const; + std::vector fractureTemplates() const; + void addFractureTemplate(RimFractureTemplate* templ); + RiaEclipseUnitTools::UnitSystemType defaultUnitSystemType() const; - void deleteFractureDefinitions(); + RimFractureTemplate* firstFractureOfUnit(RiaEclipseUnitTools::UnitSystem unitSet) const; + + std::vector > resultNamesAndUnits() const; + void computeMinMax(const QString& uiResultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; + + void createAndAssignTemplateCopyForNonMatchingUnit(); void loadAndUpdateData(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); +protected: + virtual void initAfterRead() override; + +private: + int nextFractureTemplateId(); + + caf::PdmChildArrayField m_fractureDefinitions; + caf::PdmField< RiaEclipseUnitTools::UnitSystemType > m_defaultUnitsForFracTemplates; + caf::PdmField m_nextValidFractureTemplateId; // Unique fracture template ID within a project, used to identify a fracture template + }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp index 4d90f97f36..f67766a70d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimPerforationCollection.cpp @@ -21,13 +21,13 @@ #include "RimPerforationInterval.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RigWellPath.h" #include "RifWellPathImporter.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" CAF_PDM_SOURCE_INIT(RimPerforationCollection, "PerforationCollection"); @@ -81,7 +81,7 @@ void RimPerforationCollection::appendPerforation(RimPerforationInterval* perfora perforation->setUnitSystemSpecificDefaults(); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(perforation); + Riu3DMainWindowTools::selectAsCurrentItem(perforation); RimProject* proj; this->firstAncestorOrThisOfTypeAsserted(proj); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp b/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp index e700d9f0b3..881665cc3a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimPerforationInterval.cpp @@ -124,6 +124,9 @@ bool RimPerforationInterval::isActiveOnDate(const QDateTime& date) const { return true; } + + if (!date.isValid()) return false; + return m_date() < date; } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp index e336b8d4fe..d6f67a8d4b 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.cpp @@ -30,6 +30,7 @@ #include "RimSimWellInView.h" #include "cafPdmUiDoubleSliderEditor.h" +#include "RigWellPath.h" @@ -65,7 +66,7 @@ RimSimWellFracture::~RimSimWellFracture() //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::setClosestWellCoord(cvf::Vec3d& position, size_t branchIndex) { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); double location = m_branchCenterLines[branchIndex].locationAlongWellCoords(position); @@ -80,22 +81,22 @@ void RimSimWellFracture::setClosestWellCoord(cvf::Vec3d& position, size_t branch //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::updateAzimuthBasedOnWellAzimuthAngle() { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); if (!fractureTemplate()) return; - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { double simWellAzimuth = wellAzimuthAtFracturePosition(); - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH ) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH ) { - azimuth = simWellAzimuth; + m_azimuth = simWellAzimuth; } - else if (fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + else if (fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - if (simWellAzimuth + 90 < 360) azimuth = simWellAzimuth + 90; - else azimuth = simWellAzimuth - 90; + if (simWellAzimuth + 90 < 360) m_azimuth = simWellAzimuth + 90; + else m_azimuth = simWellAzimuth - 90; } } } @@ -116,7 +117,7 @@ double RimSimWellFracture::wellAzimuthAtFracturePosition() const //-------------------------------------------------------------------------------------------------- double RimSimWellFracture::wellDipAtFracturePosition() { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); double simWellDip = m_branchCenterLines[m_branchIndex].simWellDipAngle(fracturePosition()); return simWellDip; } @@ -126,11 +127,34 @@ double RimSimWellFracture::wellDipAtFracturePosition() //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::loadDataAndUpdate() { - setBranchGeometry(); + computeSimWellBranchCenterLines(); updateFracturePositionFromLocation(); updateAzimuthBasedOnWellAzimuthAngle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSimWellFracture::perforationLengthCenterLineCoords() const +{ + std::vector coords; + + if (!m_branchCenterLines.empty() && m_branchIndex < static_cast(m_branchCenterLines.size())) + { + RigWellPath wellPathGeometry; + + wellPathGeometry.m_wellPathPoints = m_branchCenterLines[m_branchIndex].wellPathPoints(); + wellPathGeometry.m_measuredDepths = m_branchCenterLines[m_branchIndex].measuredDepths(); + + double startMd = m_location - perforationLength() / 2.0; + double endMd = m_location + perforationLength() / 2.0; + + coords = wellPathGeometry.clippedPointSubset(startMd, endMd).first; + } + + return coords; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -166,7 +190,7 @@ void RimSimWellFracture::recomputeWellCenterlineCoordinates() { m_branchCenterLines.clear(); - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); } //-------------------------------------------------------------------------------------------------- @@ -174,7 +198,7 @@ void RimSimWellFracture::recomputeWellCenterlineCoordinates() //-------------------------------------------------------------------------------------------------- void RimSimWellFracture::updateFracturePositionFromLocation() { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); if (m_branchCenterLines.size() > 0) { @@ -197,24 +221,24 @@ void RimSimWellFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi RimFracture::defineUiOrdering(uiConfigName, uiOrdering); uiOrdering.add(nameField()); + uiOrdering.add(&m_fractureTemplate); caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation"); locationGroup->add(&m_location); locationGroup->add(&m_branchIndex); - locationGroup->add(&azimuth); + locationGroup->add(&m_azimuth); locationGroup->add(&m_uiWellPathAzimuth); locationGroup->add(&m_uiWellFractureAzimuthDiff); locationGroup->add(&m_wellFractureAzimuthAngleWarning); - locationGroup->add(&dip); - locationGroup->add(&tilt); + locationGroup->add(&m_dip); + locationGroup->add(&m_tilt); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_fractureUnit); - propertyGroup->add(&m_fractureTemplate); - propertyGroup->add(&stimPlanTimeIndexToPlot); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_stimPlanTimeIndexToPlot); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); caf::PdmUiGroup* fractureCenterGroup = uiOrdering.addNewGroup("Fracture Center Info"); fractureCenterGroup->add(&m_uiAnchorPosition); @@ -234,7 +258,7 @@ void RimSimWellFracture::defineEditorAttribute(const caf::PdmFieldHandle* field, if (myAttr) { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); if (m_branchCenterLines.size() > 0) { @@ -259,7 +283,7 @@ QList RimSimWellFracture::calculateValueOptions(const ca { if (m_branchCenterLines.size() == 0) { - updateBranchGeometry(); + computeSimWellBranchesIfRequired(); } if (m_branchCenterLines.size() > 0) @@ -294,18 +318,18 @@ RigMainGrid* RimSimWellFracture::ownerCaseMainGrid() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellFracture::updateBranchGeometry() +void RimSimWellFracture::computeSimWellBranchesIfRequired() { if (m_branchCenterLines.size() == 0) { - setBranchGeometry(); + computeSimWellBranchCenterLines(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellFracture::setBranchGeometry() +void RimSimWellFracture::computeSimWellBranchCenterLines() { m_branchCenterLines.clear(); @@ -336,9 +360,12 @@ QString RimSimWellFracture::createOneBasedIJKText() const size_t i,j,k; size_t anchorCellIdx = findAnchorEclipseCell(mainGrid); if (anchorCellIdx == cvf::UNDEFINED_SIZE_T) return ""; + + size_t gridLocalCellIdx; + const RigGridBase* hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(anchorCellIdx, &gridLocalCellIdx); - bool ok = mainGrid->ijkFromCellIndex(anchorCellIdx, &i, &j, &k); + bool ok = hostGrid->ijkFromCellIndex(gridLocalCellIdx, &i, &j, &k); if (!ok) return ""; - return QString("[%1, %2, %3]").arg(i + 1).arg(j + 1).arg(k + 1); + return QString("Grid %1: [%2, %3, %4]").arg(QString::fromStdString(hostGrid->gridName())).arg(i + 1).arg(j + 1).arg(k + 1); } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h index 2c4e474310..31d559c51c 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFracture.h @@ -52,6 +52,8 @@ class RimSimWellFracture : public RimFracture virtual void loadDataAndUpdate() override; + virtual std::vector perforationLengthCenterLineCoords() const override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; @@ -60,8 +62,8 @@ class RimSimWellFracture : public RimFracture RigMainGrid* ownerCaseMainGrid() const; private: - void updateBranchGeometry(); - void setBranchGeometry(); + void computeSimWellBranchesIfRequired(); + void computeSimWellBranchCenterLines(); private: caf::PdmField m_location; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp index 0b0974d089..438921e99d 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -21,13 +21,10 @@ #include "RimSimWellFracture.h" #include "cafPdmObject.h" - - - CAF_PDM_SOURCE_INIT(RimSimWellFractureCollection, "SimWellFractureCollection"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSimWellFractureCollection::RimSimWellFractureCollection(void) { @@ -38,18 +35,28 @@ RimSimWellFractureCollection::RimSimWellFractureCollection(void) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSimWellFractureCollection::~RimSimWellFractureCollection() { simwellFractures.deleteAllChildObjects(); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSimWellFractureCollection::deleteFractures() { simwellFractures.deleteAllChildObjects(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSimWellFractureCollection::recomputeSimWellCenterlines() +{ + for (RimSimWellFracture* frac : simwellFractures()) + { + frac->recomputeWellCenterlineCoordinates(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h index d0d14b5848..9281fbb92a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimSimWellFractureCollection.h @@ -40,4 +40,5 @@ class RimSimWellFractureCollection : public caf::PdmObject void deleteFractures(); + void recomputeSimWellCenterlines(); }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp index d371bc762e..921a088887 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.cpp @@ -19,6 +19,7 @@ #include "RimStimPlanFractureTemplate.h" #include "RiaApplication.h" +#include "RiaFractureDefines.h" #include "RiaLogging.h" #include "RifStimPlanXmlReader.h" @@ -56,7 +57,7 @@ CAF_PDM_SOURCE_INIT(RimStimPlanFractureTemplate, "RimStimPlanFractureTemplate"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimStimPlanFractureTemplate::RimStimPlanFractureTemplate(void) +RimStimPlanFractureTemplate::RimStimPlanFractureTemplate() { CAF_PDM_InitObject("Fracture Template", ":/FractureTemplate16x16.png", "", ""); @@ -69,9 +70,11 @@ RimStimPlanFractureTemplate::RimStimPlanFractureTemplate(void) CAF_PDM_InitField(&m_borderPolygonResultName, "BorderPolygonResultName", QString(""), "Parameter", "", "", ""); m_borderPolygonResultName.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", ""); - CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show StimPlan Mesh", "", "", ""); - CAF_PDM_InitField(&m_conductivityScalingFactor, "ConductivityFactor", 1.0, "Conductivity Scaling Factor", "", "The conductivity values read from file will be scaled with this parameters", ""); + CAF_PDM_InitField(&m_activeTimeStepIndex, "ActiveTimeStepIndex", 0, "Active TimeStep Index", "", "", ""); + CAF_PDM_InitField(&m_conductivityResultNameOnFile, "ConductivityResultName", QString(""), "Active Conductivity Result Name", "", "", ""); + + CAF_PDM_InitField(&m_showStimPlanMesh_OBSOLETE, "ShowStimPlanMesh", true, "", "", "", ""); + m_showStimPlanMesh_OBSOLETE.uiCapability()->setUiHidden(true); m_fractureGrid = new RigFractureGrid(); m_readError = false; @@ -84,6 +87,14 @@ RimStimPlanFractureTemplate::~RimStimPlanFractureTemplate() { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimStimPlanFractureTemplate::activeTimeStepIndex() +{ + return m_activeTimeStepIndex; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -94,15 +105,12 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch if (&m_stimPlanFileName == changedField) { m_readError = false; - updateUiTreeName(); loadDataAndUpdate(); setDefaultsBasedOnXMLfile(); } if (&m_activeTimeStepIndex == changedField) { - updateFractureGrid(); - //Changes to this parameters should change all fractures with this fracture template attached. RimProject* proj; this->firstAncestorOrThisOfType(proj); @@ -114,42 +122,34 @@ void RimStimPlanFractureTemplate::fieldChangedByUi(const caf::PdmFieldHandle* ch { if (fracture->fractureTemplate() == this) { - fracture->stimPlanTimeIndexToPlot = m_activeTimeStepIndex; + fracture->setStimPlanTimeIndexToPlot(m_activeTimeStepIndex); } } proj->createDisplayModelAndRedrawAllViews(); } } - if (&m_wellPathDepthAtFracture == changedField || &m_borderPolygonResultName == changedField || &m_activeTimeStepIndex == changedField - || &m_showStimPlanMesh == changedField - || &m_conductivityScalingFactor == changedField) + || &m_stimPlanFileName == changedField + || &m_conductivityResultNameOnFile == changedField) { - if (&m_conductivityScalingFactor == changedField) - { - loadDataAndUpdate(); - } + updateFractureGrid(); RimProject* proj; this->firstAncestorOrThisOfType(proj); if (proj) { - //Regenerate geometry proj->createDisplayModelAndRedrawAllViews(); } } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimStimPlanFractureTemplate::updateUiTreeName() -{ - this->uiCapability()->setUiName(fileNameWithOutPath()); + if (changedField == &m_scaleApplyButton) + { + m_scaleApplyButton = false; + reload(); + } } //-------------------------------------------------------------------------------------------------- @@ -158,8 +158,6 @@ void RimStimPlanFractureTemplate::updateUiTreeName() void RimStimPlanFractureTemplate::setFileName(const QString& fileName) { m_stimPlanFileName = fileName; - - updateUiTreeName(); } //-------------------------------------------------------------------------------------------------- @@ -170,15 +168,6 @@ const QString& RimStimPlanFractureTemplate::fileName() return m_stimPlanFileName(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimStimPlanFractureTemplate::fileNameWithOutPath() -{ - QFileInfo stimplanfileFileInfo(m_stimPlanFileName()); - return stimplanfileFileInfo.fileName(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -192,13 +181,21 @@ void RimStimPlanFractureTemplate::updateFilePathsFromProjectPath(const QString& //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile() { + if (m_stimPlanFractureDefinitionData.isNull()) return; + setDepthOfWellPathAtFracture(); + setPerforationLength(); RiaLogging::info(QString("Setting well/fracture intersection depth at %1").arg(m_wellPathDepthAtFracture)); m_activeTimeStepIndex = static_cast(m_stimPlanFractureDefinitionData->totalNumberTimeSteps() - 1); bool polygonPropertySet = setBorderPolygonResultNameToDefault(); if (polygonPropertySet) RiaLogging::info(QString("Calculating polygon outline based on %1 at timestep %2").arg(m_borderPolygonResultName).arg(m_stimPlanFractureDefinitionData->timeSteps()[m_activeTimeStepIndex])); else RiaLogging::info(QString("Property for polygon calculation not set.")); + + if (!m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) + { + m_conductivityResultNameOnFile = m_stimPlanFractureDefinitionData->conductivityResultNames().front(); + } } //-------------------------------------------------------------------------------------------------- @@ -207,7 +204,7 @@ void RimStimPlanFractureTemplate::setDefaultsBasedOnXMLfile() bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault() { // first option: Width - for (std::pair property : resultNamesWithUnit()) + for (std::pair property : uiResultNamesWithUnit()) { if (property.first == "WIDTH") { @@ -219,14 +216,14 @@ bool RimStimPlanFractureTemplate::setBorderPolygonResultNameToDefault() // if width not found, use conductivity if (hasConductivity()) { - m_borderPolygonResultName = m_stimPlanFractureDefinitionData->conductivityResultName(); + m_borderPolygonResultName = m_stimPlanFractureDefinitionData->conductivityResultNames().first(); return true; } // else: Set to first property - if (resultNamesWithUnit().size() > 0) + if (!uiResultNamesWithUnit().empty()) { - m_borderPolygonResultName = resultNamesWithUnit()[0].first; + m_borderPolygonResultName = uiResultNamesWithUnit()[0].first; return true; } return false; @@ -241,17 +238,30 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() if (m_readError) return; - m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), m_conductivityScalingFactor(), &errorMessage); + m_stimPlanFractureDefinitionData = RifStimPlanXmlReader::readStimPlanXMLFile( m_stimPlanFileName(), + m_conductivityScaleFactor(), + m_widthScaleFactor(), + m_heightScaleFactor(), + -m_wellPathDepthAtFracture(), + RifStimPlanXmlReader::MIRROR_AUTO, + fractureTemplateUnit(), + &errorMessage); if (errorMessage.size() > 0) RiaLogging::error(errorMessage); if (m_stimPlanFractureDefinitionData.notNull()) { - fractureTemplateUnit = m_stimPlanFractureDefinitionData->unitSet(); + setDefaultConductivityResultIfEmpty(); + + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_UNKNOWN) + { + setFractureTemplateUnit(m_stimPlanFractureDefinitionData->unitSet()); + } + m_readError = false; } else { - fractureTemplateUnit = RiaEclipseUnitTools::UNITS_UNKNOWN; + setFractureTemplateUnit(RiaEclipseUnitTools::UNITS_UNKNOWN); m_readError = true; } @@ -259,7 +269,7 @@ void RimStimPlanFractureTemplate::loadDataAndUpdate() // Todo: Must update all views using this fracture template RimEclipseView* activeView = dynamic_cast(RiaApplication::instance()->activeReservoirView()); - if (activeView) activeView->stimPlanColors->loadDataAndUpdate(); + if (activeView) activeView->fractureColors()->loadDataAndUpdate(); updateConnectedEditors(); } @@ -271,29 +281,38 @@ QList RimStimPlanFractureTemplate::calculateValueOptions { QList options; + options = RimFractureTemplate::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + if (fieldNeedingOptions == &m_borderPolygonResultName) { - for (std::pair nameUnit : resultNamesWithUnit()) + for (std::pair nameUnit : uiResultNamesWithUnit()) { - //options.push_back(caf::PdmOptionItemInfo(nameUnit.first + " [" + nameUnit.second + "]", nameUnit.first + " " + nameUnit.second)); options.push_back(caf::PdmOptionItemInfo(nameUnit.first, nameUnit.first)); } } - else if (fieldNeedingOptions == &m_activeTimeStepIndex) { std::vector timeValues = timeSteps(); - int index = 0; + int index = 0; for (double value : timeValues) { options.push_back(caf::PdmOptionItemInfo(QString::number(value), index)); index++; } - + } + else if (fieldNeedingOptions == &m_conductivityResultNameOnFile) + { + if (m_stimPlanFractureDefinitionData.notNull()) + { + QStringList conductivityResultNames = m_stimPlanFractureDefinitionData->conductivityResultNames(); + for (const auto& resultName : conductivityResultNames) + { + options.push_back(caf::PdmOptionItemInfo(resultName, resultName)); + } + } } return options; - } //-------------------------------------------------------------------------------------------------- @@ -303,10 +322,45 @@ void RimStimPlanFractureTemplate::setDepthOfWellPathAtFracture() { if (!m_stimPlanFractureDefinitionData.isNull()) { - double firstDepth = m_stimPlanFractureDefinitionData->minDepth(); - double lastDepth = m_stimPlanFractureDefinitionData->maxDepth(); - double averageDepth = (firstDepth + lastDepth) / 2; - m_wellPathDepthAtFracture = averageDepth; + double firstTvd = m_stimPlanFractureDefinitionData->topPerfTvd(); + double lastTvd = m_stimPlanFractureDefinitionData->bottomPerfTvd(); + + if (firstTvd != HUGE_VAL && lastTvd != HUGE_VAL) + { + m_wellPathDepthAtFracture = (firstTvd + lastTvd) / 2; + } + else + { + firstTvd = m_stimPlanFractureDefinitionData->minDepth(); + lastTvd = m_stimPlanFractureDefinitionData->maxDepth(); + m_wellPathDepthAtFracture = (firstTvd + lastTvd) / 2; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::setPerforationLength() +{ + if (!m_stimPlanFractureDefinitionData.isNull()) + { + double firstTvd = m_stimPlanFractureDefinitionData->topPerfTvd(); + double lastTvd = m_stimPlanFractureDefinitionData->bottomPerfTvd(); + + if (firstTvd != HUGE_VAL && lastTvd != HUGE_VAL) + { + m_perforationLength = std::round(cvf::Math::abs(firstTvd - lastTvd)); + } + } + + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC && m_perforationLength < 10) + { + m_perforationLength = 10; + } + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD && m_perforationLength < RiaEclipseUnitTools::meterToFeet(10)) + { + m_perforationLength = std::round(RiaEclipseUnitTools::meterToFeet(10)); } } @@ -319,7 +373,7 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet bool found = false; bool foundMultiple = false; - for (std::pair nameUnit : resultNamesWithUnit()) + for (std::pair nameUnit : uiResultNamesWithUnit()) { if (nameUnit.first == parameterName) { @@ -338,52 +392,258 @@ QString RimStimPlanFractureTemplate::getUnitForStimPlanParameter(QString paramet //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const std::vector& RimStimPlanFractureTemplate::timeSteps() +FractureWidthAndConductivity RimStimPlanFractureTemplate::widthAndConductivityAtWellPathIntersection() const +{ + FractureWidthAndConductivity values; + + if (m_fractureGrid.notNull()) + { + std::pair wellCellIJ = m_fractureGrid->fractureCellAtWellCenter(); + size_t wellCellIndex = m_fractureGrid->getGlobalIndexFromIJ(wellCellIJ.first, wellCellIJ.second); + const RigFractureCell& wellCell = m_fractureGrid->cellFromIndex(wellCellIndex); + + double conductivity = wellCell.getConductivtyValue(); + values.m_conductivity = conductivity; + + std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); + + QString propertyNameForFractureWidth; + { + QString widthParameterName; + QString effWidthParameterName; + for (const auto& nameUnit : propertyNamesUnitsOnFile) + { + if (effWidthParameterName.isEmpty() && nameUnit.first.contains("effective width", Qt::CaseInsensitive)) + { + effWidthParameterName = nameUnit.first; + } + + if (widthParameterName.isEmpty() && nameUnit.first.contains("width", Qt::CaseInsensitive)) + { + widthParameterName = nameUnit.first; + } + } + + if (!effWidthParameterName.isEmpty()) + { + propertyNameForFractureWidth = effWidthParameterName; + } + else + { + propertyNameForFractureWidth = widthParameterName; + } + } + + if (!propertyNameForFractureWidth.isEmpty()) + { + for (const auto& nameUnit : propertyNamesUnitsOnFile) + { + if (nameUnit.first == propertyNameForFractureWidth) + { + double widthInRequiredUnit = HUGE_VAL; + { + auto resultValues = m_stimPlanFractureDefinitionData->fractureGridResults(nameUnit.first, nameUnit.second, m_activeTimeStepIndex); + + double widthInFileUnitSystem = resultValues[wellCellIndex]; + + if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_METRIC) + { + QString unitText = nameUnit.second; + + widthInRequiredUnit = RiaEclipseUnitTools::convertToMeter(widthInFileUnitSystem, unitText); + } + else if (fractureTemplateUnit() == RiaEclipseUnitTools::UNITS_FIELD) + { + QString unitText = nameUnit.second; + + widthInRequiredUnit = RiaEclipseUnitTools::convertToFeet(widthInFileUnitSystem, unitText); + } + } + + if (widthInRequiredUnit != HUGE_VAL && fabs(widthInRequiredUnit) > 1e-20) + { + values.m_width = widthInRequiredUnit; + values.m_permeability = conductivity / widthInRequiredUnit; + } + } + } + } + } + + return values; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::setDefaultConductivityResultIfEmpty() +{ + if (m_conductivityResultNameOnFile().isEmpty()) + { + if (!m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) + { + m_conductivityResultNameOnFile = m_stimPlanFractureDefinitionData->conductivityResultNames().front(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimStimPlanFractureTemplate::mapUiResultNameToFileResultName(const QString& uiResultName) const +{ + QString fileResultName; + + if (uiResultName == RiaDefines::conductivityResultName()) + { + fileResultName = m_conductivityResultNameOnFile(); + } + else + { + fileResultName = uiResultName; + } + + return fileResultName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStimPlanFractureTemplate::showStimPlanMesh() const { - if (m_stimPlanFractureDefinitionData.isNull()) loadDataAndUpdate(); - return m_stimPlanFractureDefinitionData.notNull() ? m_stimPlanFractureDefinitionData->timeSteps() : EMPTY_DOUBLE_VECTOR; + return m_showStimPlanMesh_OBSOLETE(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector > RimStimPlanFractureTemplate::resultNamesWithUnit() const +void RimStimPlanFractureTemplate::convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) +{ + if (m_fractureTemplateUnit() == neededUnit) return; + + setFractureTemplateUnit(neededUnit); + RimFractureTemplate::convertToUnitSystem(neededUnit); + + m_readError = false; + loadDataAndUpdate(); + + if (m_stimPlanFractureDefinitionData.isNull()) return; + + if (neededUnit == RiaEclipseUnitTools::UNITS_FIELD) + { + m_wellPathDepthAtFracture = RiaEclipseUnitTools::meterToFeet(m_wellPathDepthAtFracture); + } + else if (neededUnit == RiaEclipseUnitTools::UNITS_METRIC) + { + m_wellPathDepthAtFracture = RiaEclipseUnitTools::feetToMeter(m_wellPathDepthAtFracture); + } + + m_activeTimeStepIndex = static_cast(m_stimPlanFractureDefinitionData->totalNumberTimeSteps() - 1); + bool polygonPropertySet = setBorderPolygonResultNameToDefault(); + + if (polygonPropertySet) RiaLogging::info(QString("Calculating polygon outline based on %1 at timestep %2").arg(m_borderPolygonResultName).arg(m_stimPlanFractureDefinitionData->timeSteps()[m_activeTimeStepIndex])); + else RiaLogging::info(QString("Property for polygon calculation not set.")); + + if (!m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) + { + m_conductivityResultNameOnFile = m_stimPlanFractureDefinitionData->conductivityResultNames().front(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::reload() +{ + loadDataAndUpdate(); + + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimStimPlanFractureTemplate::timeSteps() { - std::vector > propertyNamesUnits; if (m_stimPlanFractureDefinitionData.notNull()) { - propertyNamesUnits = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); + return m_stimPlanFractureDefinitionData->timeSteps(); } - return propertyNamesUnits; + + return std::vector(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStimPlanFractureTemplate::computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const +std::vector > RimStimPlanFractureTemplate::uiResultNamesWithUnit() const { + std::vector > propertyNamesAndUnits; + if (m_stimPlanFractureDefinitionData.notNull()) { - m_stimPlanFractureDefinitionData->computeMinMax(resultName, unitName, minValue, maxValue, posClosestToZero, negClosestToZero); + QString conductivityUnit = "mD/s"; + + std::vector > tmp; + + std::vector > propertyNamesUnitsOnFile = m_stimPlanFractureDefinitionData->getStimPlanPropertyNamesUnits(); + for (const auto& nameUnitPair : propertyNamesUnitsOnFile) + { + if (nameUnitPair.first.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) + { + conductivityUnit = nameUnitPair.second; + } + else + { + tmp.push_back(nameUnitPair); + } + } + + propertyNamesAndUnits.push_back(std::make_pair(RiaDefines::conductivityResultName(), conductivityUnit)); + + for (const auto& nameUnitPair : tmp) + { + propertyNamesAndUnits.push_back(nameUnitPair); + } } + + return propertyNamesAndUnits; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector> RimStimPlanFractureTemplate::resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const +std::vector> RimStimPlanFractureTemplate::resultValues(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const { - if (m_stimPlanFractureDefinitionData.isNull()) return std::vector>(); - return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(resultName, unitName, timeStepIndex); + if (m_stimPlanFractureDefinitionData.notNull()) + { + QString fileResultName = mapUiResultNameToFileResultName(uiResultName); + + return m_stimPlanFractureDefinitionData->getDataAtTimeIndex(fileResultName, unitName, timeStepIndex); + } + + return std::vector>(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimStimPlanFractureTemplate::fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const +std::vector RimStimPlanFractureTemplate::fractureGridResults(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const { - if (m_stimPlanFractureDefinitionData.isNull()) return EMPTY_DOUBLE_VECTOR; - return m_stimPlanFractureDefinitionData->fractureGridResults(resultName, unitName, timeStepIndex); + if (m_stimPlanFractureDefinitionData.notNull()) + { + QString fileResultName = mapUiResultNameToFileResultName(uiResultName); + + return m_stimPlanFractureDefinitionData->fractureGridResults(fileResultName, unitName, timeStepIndex); + } + + return std::vector(); } //-------------------------------------------------------------------------------------------------- @@ -392,7 +652,7 @@ std::vector RimStimPlanFractureTemplate::fractureGridResults(const QStri bool RimStimPlanFractureTemplate::hasConductivity() const { if (m_stimPlanFractureDefinitionData.notNull() && - !m_stimPlanFractureDefinitionData->conductivityResultName().isEmpty()) + !m_stimPlanFractureDefinitionData->conductivityResultNames().isEmpty()) { return true; } @@ -403,6 +663,42 @@ bool RimStimPlanFractureTemplate::hasConductivity() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +double RimStimPlanFractureTemplate::resultValueAtIJ(const QString& uiResultName, const QString& unitName, size_t timeStepIndex, size_t i, size_t j) +{ + auto values = resultValues(uiResultName, unitName, timeStepIndex); + + if (values.empty()) return HUGE_VAL; + + size_t adjustedI = i + 1; + size_t adjustedJ = j + 1; + + if (adjustedI >= fractureGrid()->iCellCount() || adjustedJ >= fractureGrid()->jCellCount()) + { + + return HUGE_VAL; + } + + return values[adjustedJ][adjustedI]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanFractureTemplate::appendDataToResultStatistics(const QString& uiResultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const +{ + if (m_stimPlanFractureDefinitionData.notNull()) + { + QString fileResultName = mapUiResultNameToFileResultName(uiResultName); + + m_stimPlanFractureDefinitionData->appendDataToResultStatistics(fileResultName, unit, minMaxAccumulator, posNegAccumulator); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const { return m_fractureGrid.p(); @@ -413,11 +709,14 @@ const RigFractureGrid* RimStimPlanFractureTemplate::fractureGrid() const //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::updateFractureGrid() { + m_fractureGrid = nullptr; + if (m_stimPlanFractureDefinitionData.notNull()) { - m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_activeTimeStepIndex, - fractureTemplateUnit, - m_wellPathDepthAtFracture); + m_fractureGrid = m_stimPlanFractureDefinitionData->createFractureGrid(m_conductivityResultNameOnFile, + m_activeTimeStepIndex, + m_wellPathDepthAtFracture, + m_fractureTemplateUnit()); } } @@ -427,41 +726,29 @@ void RimStimPlanFractureTemplate::updateFractureGrid() /// //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) + std::vector* triangleIndices) { if (m_stimPlanFractureDefinitionData.isNull()) { loadDataAndUpdate(); } - else + else { m_stimPlanFractureDefinitionData->createFractureTriangleGeometry(m_wellPathDepthAtFracture, - neededUnit, - name, + name(), nodeCoords, triangleIndices); } - return; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit) +std::vector RimStimPlanFractureTemplate::fractureBorderPolygon() { - if (m_stimPlanFractureDefinitionData.isNull()) return std::vector(); - - QString parameterName = m_borderPolygonResultName; - QString parameterUnit = getUnitForStimPlanParameter(parameterName); - - return m_stimPlanFractureDefinitionData->createFractureBorderPolygon(parameterName, - parameterUnit, - m_activeTimeStepIndex, - m_wellPathDepthAtFracture, - neededUnit, - name); + // Not implemented + return std::vector(); } @@ -470,10 +757,8 @@ std::vector RimStimPlanFractureTemplate::fractureBorderPolygon(RiaEc //-------------------------------------------------------------------------------------------------- void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); - - uiOrdering.add(&name); - uiOrdering.add(&m_showStimPlanMesh); + uiOrdering.add(&m_name); + uiOrdering.add(&m_id); caf::PdmUiGroup* fileGroup = uiOrdering.addNewGroup("Input"); fileGroup->add(&m_stimPlanFileName); @@ -481,19 +766,21 @@ void RimStimPlanFractureTemplate::defineUiOrdering(QString uiConfigName, caf::Pd fileGroup->add(&m_wellPathDepthAtFracture); caf::PdmUiGroup* geometryGroup = uiOrdering.addNewGroup("Geometry"); - geometryGroup->add(&orientationType); - geometryGroup->add(&azimuthAngle); + geometryGroup->add(&m_orientationType); + geometryGroup->add(&m_azimuthAngle); caf::PdmUiGroup* trGr = uiOrdering.addNewGroup("Fracture Truncation"); m_fractureContainment()->defineUiOrdering(uiConfigName, *trGr); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); - propertyGroup->add(&m_conductivityScalingFactor); - propertyGroup->add(&conductivityType); - propertyGroup->add(&skinFactor); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_conductivityResultNameOnFile); + propertyGroup->add(&m_conductivityType); + propertyGroup->add(&m_skinFactor); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); + + RimFractureTemplate::defineUiOrdering(uiConfigName, uiOrdering); } //-------------------------------------------------------------------------------------------------- @@ -514,7 +801,7 @@ void RimStimPlanFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandl if (field == &m_wellPathDepthAtFracture) { - if ( !m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->depthCount() > 0) ) + if ( !m_stimPlanFractureDefinitionData.isNull() && (m_stimPlanFractureDefinitionData->yCount() > 0) ) { caf::PdmUiDoubleSliderEditorAttribute* myAttr = dynamic_cast(attribute); if ( myAttr ) @@ -525,4 +812,3 @@ void RimStimPlanFractureTemplate::defineEditorAttribute(const caf::PdmFieldHandl } } } - diff --git a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h index 3bb90111a1..1554eb6718 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimStimPlanFractureTemplate.h @@ -49,63 +49,77 @@ class RimStimPlanFractureTemplate : public RimFractureTemplate CAF_PDM_HEADER_INIT; public: - RimStimPlanFractureTemplate(void); - virtual ~RimStimPlanFractureTemplate(void); + RimStimPlanFractureTemplate(); + virtual ~RimStimPlanFractureTemplate(); - int activeTimeStepIndex() { return m_activeTimeStepIndex; } - bool showStimPlanMesh() { return m_showStimPlanMesh;} + int activeTimeStepIndex(); - void loadDataAndUpdate(); + void loadDataAndUpdate() override; void setDefaultsBasedOnXMLfile(); void setFileName(const QString& fileName); const QString& fileName(); - QString fileNameWithOutPath(); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); // Fracture geometry - const RigFractureGrid* fractureGrid() const; + const RigFractureGrid* fractureGrid() const override; void updateFractureGrid(); void fractureTriangleGeometry(std::vector* nodeCoords, - std::vector* triangleIndices, - RiaEclipseUnitTools::UnitSystem neededUnit) override; - std::vector fractureBorderPolygon(RiaEclipseUnitTools::UnitSystem neededUnit); + std::vector* triangleIndices) override; + std::vector fractureBorderPolygon() override; // Result Access - const std::vector& timeSteps(); - std::vector > resultNamesWithUnit() const; - void computeMinMax(const QString& resultName, const QString& unitName, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; - std::vector> resultValues(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; + std::vector timeSteps(); + std::vector > uiResultNamesWithUnit() const override; + std::vector> resultValues(const QString& uiResultName, const QString& unitName, size_t timeStepIndex) const; std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; bool hasConductivity() const; + double resultValueAtIJ(const QString& uiResultName, const QString& unitName, size_t timeStepIndex, size_t i, size_t j); + + void appendDataToResultStatistics(const QString& uiResultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const override; + + QString mapUiResultNameToFileResultName(const QString& uiResultName) const; + + bool showStimPlanMesh() const; + + + void convertToUnitSystem(RiaEclipseUnitTools::UnitSystem neededUnit) override; + virtual void reload() override; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; private: - void updateUiTreeName(); - + void setDefaultConductivityResultIfEmpty(); bool setBorderPolygonResultNameToDefault(); void setDepthOfWellPathAtFracture(); + void setPerforationLength(); QString getUnitForStimPlanParameter(QString parameterName); + + virtual FractureWidthAndConductivity widthAndConductivityAtWellPathIntersection() const override; + +private: caf::PdmField m_activeTimeStepIndex; - caf::PdmField m_showStimPlanMesh; + caf::PdmField m_conductivityResultNameOnFile; caf::PdmField m_wellPathDepthAtFracture; caf::PdmField m_borderPolygonResultName; caf::PdmField m_stimPlanFileName; cvf::ref m_stimPlanFractureDefinitionData; - caf::PdmField m_conductivityScalingFactor; cvf::ref m_fractureGrid; - bool m_readError; + + caf::PdmField m_showStimPlanMesh_OBSOLETE; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp index 103d1ba069..861462bfc1 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.cpp @@ -21,9 +21,7 @@ #include "RimFishbonesCollection.h" #include "RimFishboneWellPathCollection.h" #include "RimPerforationCollection.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimWellPathFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cvfAssert.h" @@ -47,11 +45,9 @@ RimWellPathCompletions::RimWellPathCompletions() m_fishbonesCollection = new RimFishbonesCollection; m_fishbonesCollection.uiCapability()->setUiHidden(true); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&m_fractureCollection, "Fractures", "Fractures", "", "", ""); m_fractureCollection = new RimWellPathFractureCollection; m_fractureCollection.uiCapability()->setUiHidden(true); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitField(&m_wellNameForExport, "WellNameForExport", QString(), "Well Name for Completion Export", "", "", ""); } @@ -95,26 +91,22 @@ QString RimWellPathCompletions::wellNameForExport() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* RimWellPathCompletions::fractureCollection() const { CVF_ASSERT(m_fractureCollection); return m_fractureCollection; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RimWellPathCompletions::hasCompletions() const { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (!fractureCollection()->fractures().empty()) { return true; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return !fishbonesCollection()->fishbonesSubs().empty() || !fishbonesCollection()->wellPathCollection()->wellPaths().empty() || @@ -147,10 +139,8 @@ void RimWellPathCompletions::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTree uiTreeOrdering.add(&m_fishbonesCollection); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (!fractureCollection()->fractures().empty()) { uiTreeOrdering.add(&m_fractureCollection); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h index 05183d1677..04ec0c37fd 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathCompletions.h @@ -24,9 +24,7 @@ class RimFishbonesCollection; class RimPerforationCollection; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimWellPathFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //================================================================================================== /// @@ -41,9 +39,7 @@ class RimWellPathCompletions : public caf::PdmObject RimFishbonesCollection* fishbonesCollection() const; RimPerforationCollection* perforationCollection() const; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* fractureCollection() const; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES void setWellNameForExport(const QString& name); QString wellNameForExport() const; @@ -57,9 +53,7 @@ class RimWellPathCompletions : public caf::PdmObject private: caf::PdmChildField m_fishbonesCollection; caf::PdmChildField m_perforationCollection; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField m_fractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmField m_wellNameForExport; }; diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp index 1300e493ce..9284429f6a 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.cpp @@ -83,20 +83,20 @@ void RimWellPathFracture::updateAzimuthBasedOnWellAzimuthAngle() { if (!fractureTemplate()) return; - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH - || fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH + || fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { double wellPathAzimuth = wellAzimuthAtFracturePosition(); - if (fractureTemplate()->orientationType == RimFractureTemplate::ALONG_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::ALONG_WELL_PATH) { - azimuth = wellPathAzimuth; + m_azimuth = wellPathAzimuth; } - if (fractureTemplate()->orientationType == RimFractureTemplate::TRANSVERSE_WELL_PATH) + if (fractureTemplate()->orientationType() == RimFractureTemplate::TRANSVERSE_WELL_PATH) { - if (wellPathAzimuth + 90 < 360) azimuth = wellPathAzimuth + 90; - else azimuth = wellPathAzimuth - 90; + if (wellPathAzimuth + 90 < 360) m_azimuth = wellPathAzimuth + 90; + else m_azimuth = wellPathAzimuth - 90; } } } @@ -132,6 +132,28 @@ void RimWellPathFracture::loadDataAndUpdate() updateAzimuthBasedOnWellAzimuthAngle(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWellPathFracture::perforationLengthCenterLineCoords() const +{ + std::vector wellPathCoords; + + RimWellPath* wellPath = nullptr; + this->firstAncestorOrThisOfType(wellPath); + if (wellPath && wellPath->wellPathGeometry()) + { + double startMd = m_measuredDepth - perforationLength() / 2.0; + double endMd = m_measuredDepth + perforationLength() / 2.0; + + auto coordsAndMd = wellPath->wellPathGeometry()->clippedPointSubset(startMd, endMd); + + wellPathCoords = coordsAndMd.first; + } + + return wellPathCoords; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -163,23 +185,23 @@ void RimWellPathFracture::defineUiOrdering(QString uiConfigName, caf::PdmUiOrder RimFracture::defineUiOrdering(uiConfigName, uiOrdering); uiOrdering.add(nameField()); + uiOrdering.add(&m_fractureTemplate); caf::PdmUiGroup* locationGroup = uiOrdering.addNewGroup("Location / Orientation"); locationGroup->add(&m_measuredDepth); - locationGroup->add(&azimuth); + locationGroup->add(&m_azimuth); locationGroup->add(&m_uiWellPathAzimuth); locationGroup->add(&m_uiWellFractureAzimuthDiff); locationGroup->add(&m_wellFractureAzimuthAngleWarning); - locationGroup->add(&dip); - locationGroup->add(&tilt); + locationGroup->add(&m_dip); + locationGroup->add(&m_tilt); caf::PdmUiGroup* propertyGroup = uiOrdering.addNewGroup("Properties"); propertyGroup->add(&m_fractureUnit); - propertyGroup->add(&m_fractureTemplate); - propertyGroup->add(&stimPlanTimeIndexToPlot); - propertyGroup->add(&perforationLength); - propertyGroup->add(&perforationEfficiency); - propertyGroup->add(&wellDiameter); + propertyGroup->add(&m_stimPlanTimeIndexToPlot); + propertyGroup->add(&m_perforationLength); + propertyGroup->add(&m_perforationEfficiency); + propertyGroup->add(&m_wellDiameter); caf::PdmUiGroup* fractureCenterGroup = uiOrdering.addNewGroup("Fracture Center Info"); fractureCenterGroup->add(&m_uiAnchorPosition); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h index 5ff63787b3..44f0457b17 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimWellPathFracture.h @@ -47,6 +47,8 @@ class RimWellPathFracture : public RimFracture virtual void loadDataAndUpdate() override; + virtual std::vector perforationLengthCenterLineCoords() const override; + protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute * attribute) override; diff --git a/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake index 028af8c003..fdbdaa46a8 100644 --- a/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Flow/CMakeLists_files.cmake @@ -1,37 +1,32 @@ -# 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}RimFlowDiagSolution.h -${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RimTofAccumulatedPhaseFractionsPlot.h -${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.h -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlotLegend.h -${CEE_CURRENT_LIST_DIR}RimFlowCharacteristicsPlot.h -${CEE_CURRENT_LIST_DIR}RimWellRftPlot.h -${CEE_CURRENT_LIST_DIR}RimWellPltPlot.h -${CEE_CURRENT_LIST_DIR}RimDataSourceForRftPlt.h -${CEE_CURRENT_LIST_DIR}RimWellPlotTools.h +${CMAKE_CURRENT_LIST_DIR}/RimFlowDiagSolution.h +${CMAKE_CURRENT_LIST_DIR}/RimFlowPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimTotalWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimTofAccumulatedPhaseFractionsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellFlowRateCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlotLegend.h +${CMAKE_CURRENT_LIST_DIR}/RimFlowCharacteristicsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellRftPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPltPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimDataSourceForRftPlt.h +${CMAKE_CURRENT_LIST_DIR}/RimWellPlotTools.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimFlowDiagSolution.cpp -${CEE_CURRENT_LIST_DIR}RimFlowPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlot.cpp -${CEE_CURRENT_LIST_DIR}RimTotalWellAllocationPlot.cpp -${CEE_CURRENT_LIST_DIR}RimTofAccumulatedPhaseFractionsPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellFlowRateCurve.cpp -${CEE_CURRENT_LIST_DIR}RimWellAllocationPlotLegend.cpp -${CEE_CURRENT_LIST_DIR}RimFlowCharacteristicsPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellRftPlot.cpp -${CEE_CURRENT_LIST_DIR}RimWellPltPlot.cpp -${CEE_CURRENT_LIST_DIR}RimDataSourceForRftPlt.cpp -${CEE_CURRENT_LIST_DIR}RimWellPlotTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFlowDiagSolution.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFlowPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTotalWellAllocationPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimTofAccumulatedPhaseFractionsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellFlowRateCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellAllocationPlotLegend.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFlowCharacteristicsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellRftPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPltPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimDataSourceForRftPlt.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellPlotTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -42,4 +37,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel\\Flow" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel\\Flow" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp index 7f06884d8f..65f697ed4b 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTofAccumulatedPhaseFractionsPlot.cpp @@ -30,7 +30,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuTofAccumulatedPhaseFractionsPlot.h" #include "RiuWellAllocationPlot.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp index de2ff98810..d90f21c660 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimTotalWellAllocationPlot.cpp @@ -28,7 +28,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuNightchartsWidget.h" #include "RiuWellAllocationPlot.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp index f178b4ab3a..b539bb7746 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellAllocationPlot.cpp @@ -43,7 +43,7 @@ #include "RimWellLogPlot.h" #include "RimWellLogTrack.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuWellAllocationPlot.h" #include "RiuWellLogTrack.h" #include "RimWellLogFile.h" diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp index 0649d83772..838da84278 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -39,24 +39,23 @@ #include "RimWellPath.h" #include "RimWellPathCollection.h" -#include #include "RimTools.h" - +#include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -const std::set RimWellPlotTools::PRESSURE_DATA_NAMES = { "PRESSURE", "PRES_FORM" }; +const std::set RimWellPlotTools::PRESSURE_DATA_NAMES = {"PRESSURE", "PRES_FORM"}; -const std::set RimWellPlotTools::OIL_CHANNEL_NAMES = { "QOZT", "QOIL", "^.*\\D_QOIL" }; -const std::set RimWellPlotTools::GAS_CHANNEL_NAMES = { "QGZT", "QGAS", "^.*\\D_QGAS" }; -const std::set RimWellPlotTools::WATER_CHANNEL_NAMES = { "QWZT", "QWAT", "^.*\\D_QWAT" }; -const std::set RimWellPlotTools::TOTAL_CHANNEL_NAMES = { "QTZT", "QTOT", "^.*\\D_QTOT" }; +const std::set RimWellPlotTools::OIL_CHANNEL_NAMES = {"QOZT", "QOIL", "^.*\\D_QOIL"}; +const std::set RimWellPlotTools::GAS_CHANNEL_NAMES = {"QGZT", "QGAS", "^.*\\D_QGAS"}; +const std::set RimWellPlotTools::WATER_CHANNEL_NAMES = {"QWZT", "QWAT", "^.*\\D_QWAT"}; +const std::set RimWellPlotTools::TOTAL_CHANNEL_NAMES = {"QTZT", "QTOT", "^.*\\D_QTOT"}; std::set RimWellPlotTools::FLOW_DATA_NAMES = {}; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- class StaticFieldsInitializer { @@ -64,15 +63,19 @@ class StaticFieldsInitializer StaticFieldsInitializer() { // Init static list - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::OIL_CHANNEL_NAMES.begin(), RimWellPlotTools::OIL_CHANNEL_NAMES.end()); - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::GAS_CHANNEL_NAMES.begin(), RimWellPlotTools::GAS_CHANNEL_NAMES.end()); - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::WATER_CHANNEL_NAMES.begin(), RimWellPlotTools::WATER_CHANNEL_NAMES.end()); - RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(), RimWellPlotTools::TOTAL_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::OIL_CHANNEL_NAMES.begin(), + RimWellPlotTools::OIL_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::GAS_CHANNEL_NAMES.begin(), + RimWellPlotTools::GAS_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::WATER_CHANNEL_NAMES.begin(), + RimWellPlotTools::WATER_CHANNEL_NAMES.end()); + RimWellPlotTools::FLOW_DATA_NAMES.insert(RimWellPlotTools::TOTAL_CHANNEL_NAMES.begin(), + RimWellPlotTools::TOTAL_CHANNEL_NAMES.end()); } } staticFieldsInitializer; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData(const RimWellLogFile* wellLogFile) { @@ -84,7 +87,7 @@ bool RimWellPlotTools::hasPressureData(const RimWellLogFile* wellLogFile) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData(RimWellPath* wellPath) { @@ -99,7 +102,7 @@ bool RimWellPlotTools::hasPressureData(RimWellPath* wellPath) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::pair RimWellPlotTools::pressureResultDataInfo(const RigEclipseCaseData* eclipseCaseData) { @@ -107,8 +110,8 @@ std::pair RimWellPlotTools::pressureResultDataInfo(const RigEcl { for (const auto& pressureDataName : PRESSURE_DATA_NAMES) { - size_t index = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)-> - findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, pressureDataName); + size_t index = eclipseCaseData->results(RiaDefines::MATRIX_MODEL) + ->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, pressureDataName); if (index != cvf::UNDEFINED_SIZE_T) { return std::make_pair(index, pressureDataName); @@ -119,7 +122,7 @@ std::pair RimWellPlotTools::pressureResultDataInfo(const RigEcl } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isPressureChannel(RimWellLogFileChannel* channel) { @@ -131,14 +134,14 @@ bool RimWellPlotTools::isPressureChannel(RimWellLogFileChannel* channel) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasPressureData(RimEclipseResultCase* gridCase) { return pressureResultDataInfo(gridCase->eclipseCaseData()).first != cvf::UNDEFINED_SIZE_T; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData(const RimWellLogFile* wellLogFile) { @@ -150,7 +153,7 @@ bool RimWellPlotTools::hasFlowData(const RimWellLogFile* wellLogFile) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData(const RimWellPath* wellPath) { @@ -165,7 +168,7 @@ bool RimWellPlotTools::hasFlowData(const RimWellPath* wellPath) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasAssociatedWellPath(const QString& wellName) { @@ -176,7 +179,7 @@ bool RimWellPlotTools::hasAssociatedWellPath(const QString& wellName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isFlowChannel(RimWellLogFileChannel* channel) { @@ -184,7 +187,7 @@ bool RimWellPlotTools::isFlowChannel(RimWellLogFileChannel* channel) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isOilFlowChannel(const QString& channelName) { @@ -192,7 +195,7 @@ bool RimWellPlotTools::isOilFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isGasFlowChannel(const QString& channelName) { @@ -200,7 +203,7 @@ bool RimWellPlotTools::isGasFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isWaterFlowChannel(const QString& channelName) { @@ -208,7 +211,7 @@ bool RimWellPlotTools::isWaterFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::isTotalFlowChannel(const QString& channelName) { @@ -216,7 +219,7 @@ bool RimWellPlotTools::isTotalFlowChannel(const QString& channelName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase) { @@ -224,8 +227,8 @@ bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase) for (const QString& channelName : FLOW_DATA_NAMES) { - size_t resultIndex = eclipseCaseData->results(RiaDefines::MATRIX_MODEL)-> - findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName); + size_t resultIndex = + eclipseCaseData->results(RiaDefines::MATRIX_MODEL)->findScalarResultIndex(RiaDefines::DYNAMIC_NATIVE, channelName); if (resultIndex != cvf::UNDEFINED_SIZE_T) return true; } @@ -233,7 +236,7 @@ bool RimWellPlotTools::hasFlowData(RimEclipseResultCase* gridCase) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- FlowPhase RimWellPlotTools::flowPhaseFromChannelName(const QString& channelName) { @@ -244,12 +247,11 @@ FlowPhase RimWellPlotTools::flowPhaseFromChannelName(const QString& channelName) return FLOW_PHASE_NONE; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::addTimeStepsToMap(std::map>& destMap, - const std::map>& timeStepsToAdd) +void RimWellPlotTools::addTimeStepsToMap(std::map>& destMap, + const std::map>& timeStepsToAdd) { for (const auto& timeStepPair : timeStepsToAdd) { @@ -262,19 +264,18 @@ void RimWellPlotTools::addTimeStepsToMap(std::map RimWellPlotTools::wellLogFilesContainingPressure(const QString& wellPathNameOrSimWellName) { std::vector wellLogFiles; - const RimProject* const project = RiaApplication::instance()->project(); - std::vector wellPaths = project->allWellPaths(); + const RimProject* const project = RiaApplication::instance()->project(); + std::vector wellPaths = project->allWellPaths(); for (auto wellPath : wellPaths) { - if (!wellPathNameOrSimWellName.isEmpty() && - (wellPathNameOrSimWellName == wellPath->associatedSimulationWellName() || - wellPathNameOrSimWellName == wellPath->name())) + if (!wellPathNameOrSimWellName.isEmpty() && (wellPathNameOrSimWellName == wellPath->associatedSimulationWellName() || + wellPathNameOrSimWellName == wellPath->name())) { const std::vector files = wellPath->wellLogFiles(); @@ -283,7 +284,7 @@ std::vector RimWellPlotTools::wellLogFilesContainingPressure(co if (hasPressureData(file)) { wellLogFiles.push_back(file); - } + } } } } @@ -292,7 +293,7 @@ std::vector RimWellPlotTools::wellLogFilesContainingPressure(co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellLogFileChannel* RimWellPlotTools::getPressureChannelFromWellFile(const RimWellLogFile* wellLogFile) { @@ -310,23 +311,23 @@ RimWellLogFileChannel* RimWellPlotTools::getPressureChannelFromWellFile(const Ri } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellPlotTools::wellLogFilesContainingFlow(const QString& wellPathName) { std::vector wellLogFiles; - const RimProject* const project = RiaApplication::instance()->project(); - std::vector wellPaths = project->allWellPaths(); + const RimProject* const project = RiaApplication::instance()->project(); + std::vector wellPaths = project->allWellPaths(); - for ( auto wellPath : wellPaths ) + for (auto wellPath : wellPaths) { - if ( wellPath->name() == wellPathName ) + if (wellPath->name() == wellPathName) { std::vector files = wellPath->wellLogFiles(); - for ( RimWellLogFile* file : files ) + for (RimWellLogFile* file : files) { - if ( hasFlowData(file) ) + if (hasFlowData(file)) { wellLogFiles.push_back(file); } @@ -337,14 +338,15 @@ std::vector RimWellPlotTools::wellLogFilesContainingFlow(const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellPath* RimWellPlotTools::wellPathFromWellLogFile(const RimWellLogFile* wellLogFile) { RimProject* const project = RiaApplication::instance()->project(); for (const auto& oilField : project->oilFields) { - auto wellPaths = std::vector(oilField->wellPathCollection()->wellPaths.begin(), oilField->wellPathCollection()->wellPaths.end()); + auto wellPaths = std::vector(oilField->wellPathCollection()->wellPaths.begin(), + oilField->wellPathCollection()->wellPaths.end()); for (const auto& wellPath : wellPaths) { @@ -362,19 +364,19 @@ RimWellPath* RimWellPlotTools::wellPathFromWellLogFile(const RimWellLogFile* wel } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellPlotTools::gridCasesForWell(const QString& simWellName) { std::vector cases; - const RimProject* project = RiaApplication::instance()->project(); + const RimProject* project = RiaApplication::instance()->project(); for (RimEclipseCase* eclCase : project->eclipseCases()) { RimEclipseResultCase* resultCase = dynamic_cast(eclCase); if (resultCase != nullptr) { - if ( eclCase->eclipseCaseData()->findSimWellData(simWellName) ) + if (eclCase->eclipseCaseData()->findSimWellData(simWellName)) { cases.push_back(resultCase); break; @@ -385,20 +387,18 @@ std::vector RimWellPlotTools::gridCasesForWell(const QStr } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellPlotTools::rftCasesForWell(const QString& simWellName) { std::vector cases; - const RimProject* project = RiaApplication::instance()->project(); + const RimProject* project = RiaApplication::instance()->project(); for (RimEclipseCase* eclCase : project->eclipseCases()) { RimEclipseResultCase* resultCase = dynamic_cast(eclCase); - if (resultCase - && resultCase->rftReader() - && resultCase->rftReader()->wellNames().count(simWellName)) + if (resultCase && resultCase->rftReader() && resultCase->rftReader()->wellNames().count(simWellName)) { cases.push_back(resultCase); } @@ -407,12 +407,11 @@ std::vector RimWellPlotTools::rftCasesForWell(const QStri } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* rftCase, - const QString& simWellName) +std::set RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* rftCase, const QString& simWellName) { - std::set timeSteps; + std::set timeSteps; RifReaderEclipseRft* const reader = rftCase->rftReader(); if (reader != nullptr) { @@ -425,12 +424,12 @@ std::set RimWellPlotTools::timeStepsFromRftCase(RimEclipseResultCase* } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RimWellPlotTools::timeStepsFromGridCase(RimEclipseCase* gridCase) { const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); - std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); + std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); std::set timeSteps; if (resultDataInfo.first != cvf::UNDEFINED_SIZE_T) @@ -444,7 +443,7 @@ std::set RimWellPlotTools::timeStepsFromGridCase(RimEclipseCase* grid } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QDateTime RimWellPlotTools::timeStepFromWellLogFile(RimWellLogFile* wellLogFile) { @@ -453,12 +452,12 @@ QDateTime RimWellPlotTools::timeStepFromWellLogFile(RimWellLogFile* wellLogFile) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::map> RimWellPlotTools::timeStepsMapFromGridCase(RimEclipseCase* gridCase) { const RigEclipseCaseData* const eclipseCaseData = gridCase->eclipseCaseData(); - std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); + std::pair resultDataInfo = pressureResultDataInfo(eclipseCaseData); std::map> timeStepsMap; if (resultDataInfo.first != cvf::UNDEFINED_SIZE_T) @@ -476,32 +475,31 @@ std::map> RimWellPlotTools::timeStep } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std::set& baseTimeLine, +std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std::set& baseTimeLine, const std::set& availableTimeSteps) { std::set resultTimeSteps; - for (const QDateTime& baseTimeStep: baseTimeLine ) + for (const QDateTime& baseTimeStep : baseTimeLine) { auto itToEqualOrLargerTime = availableTimeSteps.lower_bound(baseTimeStep); if (itToEqualOrLargerTime != availableTimeSteps.end()) { resultTimeSteps.insert(*itToEqualOrLargerTime); - if ( *itToEqualOrLargerTime != baseTimeStep - && itToEqualOrLargerTime != availableTimeSteps.begin() ) + if (*itToEqualOrLargerTime != baseTimeStep && itToEqualOrLargerTime != availableTimeSteps.begin()) { // Found a larger time, then add the timestep before it as the adjacent timestep before the base timestep itToEqualOrLargerTime--; resultTimeSteps.insert(*itToEqualOrLargerTime); - } + } } } // The above will only work if there are at least one available timestep equal or after any of the basetimeline times. // If no timesteps matched but we have some, add the last available because the above code missed it. - if (!resultTimeSteps.size() && baseTimeLine.size() && availableTimeSteps.size()) + if (!resultTimeSteps.size() && baseTimeLine.size() && availableTimeSteps.size()) { resultTimeSteps.insert(*availableTimeSteps.rbegin()); } @@ -510,20 +508,19 @@ std::set RimWellPlotTools::findMatchingOrAdjacentTimeSteps(const std: } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase * eclCase, - const QString& simWellName, - bool addFirstReportTimestep) +std::set + RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase* eclCase, const QString& simWellName, bool addFirstReportTimestep) { - std::set availebleTimeSteps; + std::set availebleTimeSteps; std::vector allTimeSteps = eclCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(); - const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData(simWellName); + const RigSimWellData* simWell = eclCase->eclipseCaseData()->findSimWellData(simWellName); - for ( size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx ) + for (size_t tsIdx = 0; tsIdx < allTimeSteps.size(); ++tsIdx) { - if ( simWell->hasWellResult(tsIdx) || (addFirstReportTimestep && tsIdx == 0) ) + if (simWell->hasWellResult(tsIdx) || (addFirstReportTimestep && tsIdx == 0)) { availebleTimeSteps.insert(allTimeSteps[tsIdx]); } @@ -533,13 +530,13 @@ std::set RimWellPlotTools::availableSimWellTimesteps(RimEclipseCase * } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCurve* curve) { - const RimWellLogRftCurve* rftCurve = dynamic_cast(curve); - const RimWellLogExtractionCurve* gridCurve = dynamic_cast(curve); - const RimWellLogFileCurve* wellLogFileCurve = dynamic_cast(curve); + const RimWellLogRftCurve* rftCurve = dynamic_cast(curve); + const RimWellLogExtractionCurve* gridCurve = dynamic_cast(curve); + const RimWellLogFileCurve* wellLogFileCurve = dynamic_cast(curve); if (rftCurve != nullptr) { @@ -547,7 +544,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur if (rftCase != nullptr) { const RifEclipseRftAddress rftAddress = rftCurve->rftAddress(); - const QDateTime timeStep = rftAddress.timeStep(); + const QDateTime timeStep = rftAddress.timeStep(); return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase), timeStep); } } @@ -556,21 +553,21 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur RimEclipseResultCase* gridCase = dynamic_cast(gridCurve->rimCase()); if (gridCase != nullptr) { - size_t timeStepIndex = gridCurve->currentTimeStep(); - const std::map>& timeStepsMap = timeStepsMapFromGridCase(gridCase); - auto timeStepsVector = std::vector>>( - timeStepsMap.begin(), timeStepsMap.end()); + size_t timeStepIndex = gridCurve->currentTimeStep(); + const std::map>& timeStepsMap = timeStepsMapFromGridCase(gridCase); + auto timeStepsVector = + std::vector>>(timeStepsMap.begin(), timeStepsMap.end()); if (timeStepIndex < timeStepsMap.size()) { return RiaRftPltCurveDefinition(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase), - timeStepsVector[timeStepIndex].first); + timeStepsVector[timeStepIndex].first); } } } else if (wellLogFileCurve != nullptr) { - const RimWellPath* const wellPath = wellLogFileCurve->wellPath(); - RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile(); + const RimWellPath* const wellPath = wellLogFileCurve->wellPath(); + RimWellLogFile* const wellLogFile = wellLogFileCurve->wellLogFile(); if (wellLogFile != nullptr) { @@ -590,7 +587,7 @@ RiaRftPltCurveDefinition RimWellPlotTools::curveDefFromCurve(const RimWellLogCur //-------------------------------------------------------------------------------------------------- RimWellPath* RimWellPlotTools::wellPathByWellPathNameOrSimWellName(const QString& wellPathNameOrSimwellName) { - RimProject* proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); RimWellPath* wellPath = proj->wellPathByName(wellPathNameOrSimwellName); return wellPath != nullptr ? wellPath : proj->wellPathFromSimWellName(wellPathNameOrSimwellName); @@ -610,8 +607,7 @@ QString RimWellPlotTools::simWellName(const QString& wellPathNameOrSimWellName) //-------------------------------------------------------------------------------------------------- bool RimWellPlotTools::tryMatchChannelName(const std::set& channelNames, const QString& channelNameToMatch) { - auto itr = std::find_if(channelNames.begin(), channelNames.end(), [&](const QString& channelName) - { + auto itr = std::find_if(channelNames.begin(), channelNames.end(), [&](const QString& channelName) { if (channelName.startsWith('^')) { std::regex pattern(channelName.toStdString()); @@ -625,51 +621,51 @@ bool RimWellPlotTools::tryMatchChannelName(const std::set& channelNames return itr != channelNames.end(); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName, - const std::vector& selectedTimeSteps, - bool firstSimWellTimeStepIsValid, - const std::vector& selectedSourcesExpanded) +std::set + RimWellPlotTools::curveDefsFromTimesteps(const QString& simWellName, + const std::vector& selectedTimeSteps, + bool firstSimWellTimeStepIsValid, + const std::vector& selectedSourcesExpanded) { std::set curveDefs; std::set selectedTimeStepSet(selectedTimeSteps.begin(), selectedTimeSteps.end()); - for ( const RifDataSourceForRftPlt& addr : selectedSourcesExpanded ) + for (const RifDataSourceForRftPlt& addr : selectedSourcesExpanded) { - if ( addr.rftReader() ) + if (addr.rftReader()) { - std::set rftTimes = addr.rftReader()->availableTimeSteps(simWellName, { RifEclipseRftAddress::ORAT, - RifEclipseRftAddress::WRAT, - RifEclipseRftAddress::GRAT }); - for ( const QDateTime& time : rftTimes ) + std::set rftTimes = addr.rftReader()->availableTimeSteps( + simWellName, {RifEclipseRftAddress::ORAT, RifEclipseRftAddress::WRAT, RifEclipseRftAddress::GRAT}); + for (const QDateTime& time : rftTimes) { - if ( selectedTimeStepSet.count(time) ) + if (selectedTimeStepSet.count(time)) { curveDefs.insert(RiaRftPltCurveDefinition(addr, time)); } } } - else if ( addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase() ) + else if (addr.sourceType() == RifDataSourceForRftPlt::GRID && addr.eclCase()) { - std::set timeSteps = RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName, firstSimWellTimeStepIsValid); + std::set timeSteps = + RimWellPlotTools::availableSimWellTimesteps(addr.eclCase(), simWellName, firstSimWellTimeStepIsValid); - for ( const QDateTime& time : timeSteps ) + for (const QDateTime& time : timeSteps) { - if ( selectedTimeStepSet.count(time) ) + if (selectedTimeStepSet.count(time)) { curveDefs.insert(RiaRftPltCurveDefinition(addr, time)); } } } - else if ( addr.sourceType() == RifDataSourceForRftPlt::OBSERVED ) + else if (addr.sourceType() == RifDataSourceForRftPlt::OBSERVED) { - if ( addr.wellLogFile() ) + if (addr.wellLogFile()) { - if ( selectedTimeStepSet.count(addr.wellLogFile()->date()) ) + if (selectedTimeStepSet.count(addr.wellLogFile()->date())) { curveDefs.insert(RiaRftPltCurveDefinition(addr, addr.wellLogFile()->date())); } @@ -680,12 +676,11 @@ std::set < RiaRftPltCurveDefinition > RimWellPlotTools::curveDefsFromTimesteps(c return curveDefs; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::flowPlotAxisTitle(RimWellLogFile::WellFlowCondition condition, - RiaEclipseUnitTools::UnitSystem unitSystem) +QString RimWellPlotTools::flowPlotAxisTitle(RimWellLogFile::WellFlowCondition condition, + RiaEclipseUnitTools::UnitSystem unitSystem) { QString axisTitle; @@ -706,7 +701,7 @@ QString RimWellPlotTools::flowPlotAxisTitle(RimWellLogFile::WellFlowCondition co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString flowConditionReservoirUnitText(RiaEclipseUnitTools::UnitSystem unitSystem) { @@ -714,17 +709,24 @@ QString flowConditionReservoirUnitText(RiaEclipseUnitTools::UnitSystem unitSyste switch (unitSystem) { - case RiaEclipseUnitTools::UNITS_METRIC: unitText = "[m3/day]"; break; - case RiaEclipseUnitTools::UNITS_FIELD: unitText = "[Brl/day]"; break; - case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm3/hr]"; break; - default: break; + case RiaEclipseUnitTools::UNITS_METRIC: + unitText = "[m3/day]"; + break; + case RiaEclipseUnitTools::UNITS_FIELD: + unitText = "[Brl/day]"; + break; + case RiaEclipseUnitTools::UNITS_LAB: + unitText = "[cm3/hr]"; + break; + default: + break; } return unitText; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellPlotTools::flowUnitText(RimWellLogFile::WellFlowCondition condition, RiaEclipseUnitTools::UnitSystem unitSystem) { @@ -738,21 +740,29 @@ QString RimWellPlotTools::flowUnitText(RimWellLogFile::WellFlowCondition conditi { switch (unitSystem) { - case RiaEclipseUnitTools::UNITS_METRIC: unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; break; - case RiaEclipseUnitTools::UNITS_FIELD: unitText = "[Liquid BBL/day], [Gas BOE/day]"; break; - case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm3/hr]"; break; - default: break; + case RiaEclipseUnitTools::UNITS_METRIC: + unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; + break; + case RiaEclipseUnitTools::UNITS_FIELD: + unitText = "[Liquid BBL/day], [Gas BOE/day]"; + break; + case RiaEclipseUnitTools::UNITS_LAB: + unitText = "[cm3/hr]"; + break; + default: + break; } } return unitText; } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condition, RiaEclipseUnitTools::UnitSystem unitSystem, FlowPhase flowPhase) +QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condition, + RiaEclipseUnitTools::UnitSystem unitSystem, + FlowPhase flowPhase) { QString unitText; @@ -767,24 +777,39 @@ QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condit case RiaEclipseUnitTools::UNITS_METRIC: switch (flowPhase) { - case FLOW_PHASE_GAS: unitText = "[kSm3/day]"; break; + case FLOW_PHASE_GAS: + unitText = "[kSm3/day]"; + break; case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit - case FLOW_PHASE_OIL: unitText = "[Sm3/day]"; break; - default: unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; break; + case FLOW_PHASE_OIL: + unitText = "[Sm3/day]"; + break; + default: + unitText = "[Liquid Sm3/day], [Gas kSm3/day]"; + break; } break; case RiaEclipseUnitTools::UNITS_FIELD: switch (flowPhase) { - case FLOW_PHASE_GAS: unitText = "[BOE/day]"; break; + case FLOW_PHASE_GAS: + unitText = "[BOE/day]"; + break; case FLOW_PHASE_WATER: // Intentionally fall through, water and oil have same unit - case FLOW_PHASE_OIL: unitText = "[BBL/day]"; break; - default: unitText = "[Liquid BBL/day], [Gas BOE/day]"; break; + case FLOW_PHASE_OIL: + unitText = "[BBL/day]"; + break; + default: + unitText = "[Liquid BBL/day], [Gas BOE/day]"; + break; } break; - case RiaEclipseUnitTools::UNITS_LAB: unitText = "[cm3/hr]"; break; - default: break; + case RiaEclipseUnitTools::UNITS_LAB: + unitText = "[cm3/hr]"; + break; + default: + break; } } @@ -792,78 +817,76 @@ QString RimWellPlotTools::curveUnitText(RimWellLogFile::WellFlowCondition condit } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellName, - const std::vector& selSources, - const std::set& interestingRFTResults, - QList& options) +std::map> RimWellPlotTools::calculateRelevantTimeStepsFromCases( + const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults) { - //std::vector selSources = selectedSourcesExpanded(); - bool addFirstTimestep = (interestingRFTResults.count(RifEclipseRftAddress::PRESSURE) == 1); - bool hasObservedData = false; - bool hasRftData = false; - bool hasGridData = false; + bool hasObservedData = false; + bool hasRftData = false; + bool hasGridData = false; - for (const auto& source : selSources ) + for (const auto& source : selSources) { switch (source.sourceType()) { case RifDataSourceForRftPlt::RFT: - hasRftData = true; - break; + hasRftData = true; + break; case RifDataSourceForRftPlt::GRID: - hasGridData = true; - break; + hasGridData = true; + break; case RifDataSourceForRftPlt::OBSERVED: - hasObservedData = true; - break; + hasObservedData = true; + break; } } - std::map > observedTimeStepsWithSources; - std::map > rftTimeStepsWithSources; - std::map > gridTimestepsWithSources; - - + std::map> observedTimeStepsWithSources; + std::map> rftTimeStepsWithSources; + std::map> gridTimestepsWithSources; if (hasObservedData) { - for (const auto& source : selSources ) + for (const auto& source : selSources) { if (source.sourceType() == RifDataSourceForRftPlt::OBSERVED && source.wellLogFile()) { observedTimeStepsWithSources[source.wellLogFile()->date()].insert(source); - } + } } } if (hasRftData) { - for (const auto& source : selSources ) + for (const auto& source : selSources) { if (source.sourceType() == RifDataSourceForRftPlt::RFT && source.rftReader()) - { - std::set rftTimes = source.rftReader()->availableTimeSteps(simWellName, interestingRFTResults ); - for ( const QDateTime& date: rftTimes) + { + std::set rftTimes = + source.rftReader()->availableTimeSteps(wellPathNameOrSimWellName, interestingRFTResults); + for (const QDateTime& date : rftTimes) { rftTimeStepsWithSources[date].insert(source); } - } + } } } - if ( hasGridData ) + if (hasGridData) { - for ( const auto& source : selSources ) + for (const auto& source : selSources) { - if ( source.sourceType() == RifDataSourceForRftPlt::GRID && source.eclCase() ) + if (source.sourceType() == RifDataSourceForRftPlt::GRID && source.eclCase()) { - std::set wellTimeSteps = RimWellPlotTools::availableSimWellTimesteps(source.eclCase(), simWellName, addFirstTimestep); + std::set wellTimeSteps = + RimWellPlotTools::availableSimWellTimesteps(source.eclCase(), wellPathNameOrSimWellName, addFirstTimestep); - for ( const QDateTime& date: wellTimeSteps) + for (const QDateTime& date : wellTimeSteps) { gridTimestepsWithSources[date].insert(source); } @@ -873,8 +896,8 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN // If we have a time baseline add the equal or adjacent grid timesteps - std::map > timestepsToShowWithSources; - std::map >* timeBaseline = nullptr; + std::map> timestepsToShowWithSources; + std::map>* timeBaseline = nullptr; if (hasObservedData) { @@ -888,39 +911,43 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN if (timeBaseline) { std::set baseTimeSteps; - for (const auto& dateSourceSetPair: *timeBaseline) baseTimeSteps.insert(dateSourceSetPair.first); - + for (const auto& dateSourceSetPair : *timeBaseline) + baseTimeSteps.insert(dateSourceSetPair.first); + std::set rftTimeSteps; - for (const auto& dateSourceSetPair: rftTimeStepsWithSources) rftTimeSteps.insert(dateSourceSetPair.first); + for (const auto& dateSourceSetPair : rftTimeStepsWithSources) + rftTimeSteps.insert(dateSourceSetPair.first); std::set gridTimeSteps; - for (const auto& dateSourceSetPair: gridTimestepsWithSources) gridTimeSteps.insert(dateSourceSetPair.first); + for (const auto& dateSourceSetPair : gridTimestepsWithSources) + gridTimeSteps.insert(dateSourceSetPair.first); std::set filteredRftTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, rftTimeSteps); - std::set filteredGridTimeSteps = RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, gridTimeSteps); + std::set filteredGridTimeSteps = + RimWellPlotTools::findMatchingOrAdjacentTimeSteps(baseTimeSteps, gridTimeSteps); if (addFirstTimestep && gridTimeSteps.size()) { filteredGridTimeSteps.insert(*gridTimeSteps.begin()); } - // Fill final map + // Fill final map timestepsToShowWithSources = observedTimeStepsWithSources; std::set& allFilteredTimesteps = filteredRftTimeSteps; allFilteredTimesteps.insert(filteredGridTimeSteps.begin(), filteredGridTimeSteps.end()); - for (const QDateTime& time: allFilteredTimesteps) + for (const QDateTime& time : allFilteredTimesteps) { auto rftTimeSourceSetIt = rftTimeStepsWithSources.find(time); - if ( rftTimeSourceSetIt != rftTimeStepsWithSources.end() ) + if (rftTimeSourceSetIt != rftTimeStepsWithSources.end()) { std::set& sourceSet = rftTimeSourceSetIt->second; timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end()); } auto gridTimeSourceSetIt = gridTimestepsWithSources.find(time); - if ( gridTimeSourceSetIt != gridTimestepsWithSources.end() ) + if (gridTimeSourceSetIt != gridTimestepsWithSources.end()) { std::set& sourceSet = gridTimeSourceSetIt->second; timestepsToShowWithSources[time].insert(sourceSet.begin(), sourceSet.end()); @@ -932,11 +959,26 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN timestepsToShowWithSources = gridTimestepsWithSources; } - // Create formatted options of all the timesteps + return timestepsToShowWithSources; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPlotTools::calculateValueOptionsForTimeSteps( + const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults, + QList& options) +{ + auto timestepsToShowWithSources = + calculateRelevantTimeStepsFromCases(wellPathNameOrSimWellName, selSources, interestingRFTResults); + + // Create formatted options of all the time steps QString dateFormatString; { std::vector allTimeSteps; - for ( const std::pair>& timeStepPair : timestepsToShowWithSources ) + for (const std::pair>& timeStepPair : timestepsToShowWithSources) { allTimeSteps.push_back(timeStepPair.first); } @@ -945,17 +987,24 @@ void RimWellPlotTools::calculateValueOptionsForTimeSteps(const QString& simWellN for (const std::pair>& timeStepPair : timestepsToShowWithSources) { - QString optionText = timeStepPair.first.toString(dateFormatString); - bool hasObs = false; - bool hasRft = false; - bool hasGrid = false; + QString optionText = timeStepPair.first.toString(dateFormatString); + bool hasObs = false; + bool hasRft = false; + bool hasGrid = false; - for (const auto& source : timeStepPair.second) + for (const auto& source : timeStepPair.second) { - switch (source.sourceType()){ - case RifDataSourceForRftPlt::OBSERVED: hasObs = true; break; - case RifDataSourceForRftPlt::RFT : hasRft = true; break; - case RifDataSourceForRftPlt::GRID : hasGrid = true; break; + switch (source.sourceType()) + { + case RifDataSourceForRftPlt::OBSERVED: + hasObs = true; + break; + case RifDataSourceForRftPlt::RFT: + hasRft = true; + break; + case RifDataSourceForRftPlt::GRID: + hasGrid = true; + break; } } diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h index 48545d81c5..51819d6b60 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPlotTools.h @@ -86,10 +86,16 @@ class RimWellPlotTools static std::vector rftCasesForWell(const QString& simWellName); static QString simWellName(const QString& wellPathNameOrSimWellName); + static std::map> + calculateRelevantTimeStepsFromCases(const QString& wellPathNameOrSimWellName, + const std::vector& selSources, + const std::set& interestingRFTResults); + static void calculateValueOptionsForTimeSteps(const QString& wellPathNameOrSimWellName, const std::vector& selSources, const std::set& interestingRFTResults, QList& options); + static std::set < RiaRftPltCurveDefinition > curveDefsFromTimesteps(const QString& simWellName, const std::vector& selectedTimeStepVector, bool firstReportTimeStepIsValid, diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp index 9931c41fdf..55a1989977 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellPltPlot.cpp @@ -101,7 +101,7 @@ const char RimWellPltPlot::PLOT_NAME_QFORMAT_STRING[] = "PLT: %1"; //-------------------------------------------------------------------------------------------------- RimWellPltPlot::RimWellPltPlot() { - CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", ""); + CAF_PDM_InitObject("Well Allocation Plot", ":/WellFlowPlot16x16.png", "", ""); CAF_PDM_InitField(&m_userName, "PlotDescription", QString("PLT Plot"), "Name", "", "", ""); m_userName.uiCapability()->setUiReadOnly(true); diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp index adf38bec41..98e0371597 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -30,7 +30,6 @@ #include "RigSimWellData.h" #include "RigWellPath.h" -#include "RimWellPlotTools.h" #include "RimEclipseCase.h" #include "RimEclipseCaseCollection.h" #include "RimEclipseResultCase.h" @@ -47,6 +46,7 @@ #include "RimWellLogTrack.h" #include "RimWellPath.h" #include "RimWellPathCollection.h" +#include "RimWellPlotTools.h" #include "RimWellPltPlot.h" #include "RiuWellRftPlot.h" @@ -61,16 +61,16 @@ CAF_PDM_SOURCE_INIT(RimWellRftPlot, "WellRftPlot"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const char RimWellRftPlot::PLOT_NAME_QFORMAT_STRING[] = "RFT: %1"; //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellRftPlot::RimWellRftPlot() { - CAF_PDM_InitObject("Well Allocation Plot", ":/WellAllocPlot16x16.png", "", ""); + CAF_PDM_InitObject("Well Allocation Plot", ":/RFTPlot16x16.png", "", ""); CAF_PDM_InitField(&m_userName, "PlotDescription", QString("RFT Plot"), "Name", "", "", ""); m_userName.uiCapability()->setUiReadOnly(true); @@ -84,8 +84,13 @@ RimWellRftPlot::RimWellRftPlot() CAF_PDM_InitFieldNoDefault(&m_wellPathNameOrSimWellName, "WellName", "Well Name", "", "", ""); CAF_PDM_InitField(&m_branchIndex, "BranchIndex", 0, "Branch Index", "", "", ""); - CAF_PDM_InitField(&m_branchDetection, "BranchDetection", true, "Branch Detection", "", - "Compute branches based on how simulation well cells are organized", ""); + CAF_PDM_InitField(&m_branchDetection, + "BranchDetection", + true, + "Branch Detection", + "", + "Compute branches based on how simulation well cells are organized", + ""); CAF_PDM_InitFieldNoDefault(&m_selectedSources, "Sources", "Sources", "", "", ""); m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); @@ -101,7 +106,7 @@ RimWellRftPlot::RimWellRftPlot() this->setAsPlotMdiWindow(); m_selectedSourcesOrTimeStepsFieldsChanged = false; - m_isOnLoad = true; + m_isOnLoad = true; } //-------------------------------------------------------------------------------------------------- @@ -115,7 +120,7 @@ RimWellRftPlot::~RimWellRftPlot() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::deleteViewWidget() { @@ -127,7 +132,7 @@ void RimWellRftPlot::deleteViewWidget() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) { @@ -136,25 +141,22 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) std::vector colorTable; RiaColorTables::summaryCurveDefaultPaletteColors().color3fArray().toStdVector(&colorTable); - std::vector symbolTable = - { - RimPlotCurve::SYMBOL_ELLIPSE, - RimPlotCurve::SYMBOL_RECT, - RimPlotCurve::SYMBOL_DIAMOND, - RimPlotCurve::SYMBOL_TRIANGLE, - RimPlotCurve::SYMBOL_CROSS, - RimPlotCurve::SYMBOL_XCROSS - }; + std::vector symbolTable = {RimPlotCurve::SYMBOL_ELLIPSE, + RimPlotCurve::SYMBOL_RECT, + RimPlotCurve::SYMBOL_DIAMOND, + RimPlotCurve::SYMBOL_TRIANGLE, + RimPlotCurve::SYMBOL_CROSS, + RimPlotCurve::SYMBOL_XCROSS}; // State variables - static size_t defaultColorTableIndex = 0; - static size_t defaultSymbolTableIndex = 0; + static size_t defaultColorTableIndex = 0; + static size_t defaultSymbolTableIndex = 0; - cvf::Color3f currentColor; - RimPlotCurve::PointSymbolEnum currentSymbol = symbolTable.front(); - RimPlotCurve::LineStyleEnum currentLineStyle = RimPlotCurve::STYLE_SOLID; - bool isCurrentColorSet = false; - bool isCurrentSymbolSet = false; + cvf::Color3f currentColor; + RimPlotCurve::PointSymbolEnum currentSymbol = symbolTable.front(); + RimPlotCurve::LineStyleEnum currentLineStyle = RimPlotCurve::STYLE_SOLID; + bool isCurrentColorSet = false; + bool isCurrentSymbolSet = false; std::set assignedColors; std::set assignedSymbols; @@ -167,12 +169,12 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) RiaRftPltCurveDefinition cDef = RimWellPlotTools::curveDefFromCurve(curve); if (cDef.address() == newCurveDef.address()) { - currentColor = curve->color(); + currentColor = curve->color(); isCurrentColorSet = true; } if (cDef.timeStep() == newCurveDef.timeStep()) { - currentSymbol = curve->symbol(); + currentSymbol = curve->symbol(); isCurrentSymbolSet = true; } assignedColors.insert(curve->color()); @@ -182,11 +184,11 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) // Assign color if (!isCurrentColorSet) { - for(const auto& color : colorTable) + for (const auto& color : colorTable) { if (assignedColors.count(color) == 0) { - currentColor = color; + currentColor = color; isCurrentColorSet = true; break; } @@ -194,9 +196,7 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) if (!isCurrentColorSet) { currentColor = colorTable[defaultColorTableIndex]; - if (++defaultColorTableIndex == colorTable.size()) - defaultColorTableIndex = 0; - + if (++defaultColorTableIndex == colorTable.size()) defaultColorTableIndex = 0; } } @@ -207,7 +207,7 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) { if (assignedSymbols.count(symbol) == 0) { - currentSymbol = symbol; + currentSymbol = symbol; isCurrentSymbolSet = true; break; } @@ -215,29 +215,27 @@ void RimWellRftPlot::applyCurveAppearance(RimWellLogCurve* newCurve) if (!isCurrentSymbolSet) { currentSymbol = symbolTable[defaultSymbolTableIndex]; - if (++defaultSymbolTableIndex == symbolTable.size()) - defaultSymbolTableIndex = 0; + if (++defaultSymbolTableIndex == symbolTable.size()) defaultSymbolTableIndex = 0; } } // Observed data - currentLineStyle = newCurveDef.address().sourceType() == RifDataSourceForRftPlt::OBSERVED - ? RimPlotCurve::STYLE_NONE : RimPlotCurve::STYLE_SOLID; + currentLineStyle = newCurveDef.address().sourceType() == RifDataSourceForRftPlt::OBSERVED ? RimPlotCurve::STYLE_NONE + : RimPlotCurve::STYLE_SOLID; newCurve->setColor(currentColor); newCurve->setSymbol(currentSymbol); newCurve->setLineStyle(currentLineStyle); } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateFormationsOnPlot() const { if (m_wellLogPlot->trackCount() > 0) { - RimProject* proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); RimWellPath* wellPath = proj->wellPathByName(m_wellPathNameOrSimWellName); RimCase* formationNamesCase = m_wellLogPlot->trackByIndex(0)->formationNamesCase(); @@ -248,7 +246,7 @@ void RimWellRftPlot::updateFormationsOnPlot() const std::vector cases; proj->allCases(cases); - if ( !cases.empty() ) + if (!cases.empty()) { formationNamesCase = cases[0]; } @@ -260,13 +258,14 @@ void RimWellRftPlot::updateFormationsOnPlot() const } else { - m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData(formationNamesCase, associatedSimWellName(), m_branchIndex, m_branchDetection); + m_wellLogPlot->trackByIndex(0)->setAndUpdateSimWellFormationNamesAndBranchData( + formationNamesCase, associatedSimWellName(), m_branchIndex, m_branchDetection); } } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellRftPlot::associatedSimWellName() const { @@ -279,60 +278,51 @@ QString RimWellRftPlot::associatedSimWellName() const void RimWellRftPlot::applyInitialSelections() { std::vector sourcesToSelect; - std::set rftTimeSteps; - std::set observedTimeSteps; - std::set gridTimeSteps; - const QString simWellName = associatedSimWellName(); + const QString simWellName = associatedSimWellName(); - for(RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell(simWellName)) + for (RimEclipseResultCase* const rftCase : RimWellPlotTools::rftCasesForWell(simWellName)) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase)); - RimWellPlotTools::appendSet(rftTimeSteps, RimWellPlotTools::timeStepsFromRftCase(rftCase, simWellName)); } - + for (RimEclipseResultCase* const gridCase : RimWellPlotTools::gridCasesForWell(simWellName)) { sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase)); - RimWellPlotTools::appendSet(gridTimeSteps, RimWellPlotTools::timeStepsFromGridCase(gridCase)); } - + std::vector wellLogFiles = RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName); - if(wellLogFiles.size() > 0) + if (!wellLogFiles.empty()) { - sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED)); for (RimWellLogFile* const wellLogFile : wellLogFiles) { - observedTimeSteps.insert(RimWellPlotTools::timeStepFromWellLogFile(wellLogFile)); + sourcesToSelect.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED, wellLogFile)); } } m_selectedSources = sourcesToSelect; - - std::set timeStepsToSelect; - for (const QDateTime& timeStep : rftTimeSteps) - { - timeStepsToSelect.insert(timeStep); - } - for (const QDateTime& timeStep : observedTimeSteps) + { - timeStepsToSelect.insert(timeStep); - } - if (gridTimeSteps.size() > 0) - timeStepsToSelect.insert(*gridTimeSteps.begin()); + auto relevantTimeSteps = RimWellPlotTools::calculateRelevantTimeStepsFromCases( + associatedSimWellName(), m_selectedSources, {RifEclipseRftAddress::PRESSURE}); - m_selectedTimeSteps = std::vector(timeStepsToSelect.begin(), timeStepsToSelect.end()); + std::vector timeStepVector; + for (const auto& item : relevantTimeSteps) + timeStepVector.push_back(item.first); + + m_selectedTimeSteps = timeStepVector; + } syncCurvesFromUiSelection(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateEditorsFromCurves() { - std::set selectedSources; - std::set selectedTimeSteps; - std::map> selectedTimeStepsMap; + std::set selectedSources; + std::set selectedTimeSteps; + std::map> selectedTimeStepsMap; for (const RiaRftPltCurveDefinition& curveDef : curveDefsFromCurves()) { @@ -341,21 +331,18 @@ void RimWellRftPlot::updateEditorsFromCurves() else selectedSources.insert(curveDef.address()); - auto newTimeStepMap = std::map> - { - { curveDef.timeStep(), std::set { curveDef.address()} } - }; + auto newTimeStepMap = std::map>{ + {curveDef.timeStep(), std::set{curveDef.address()}}}; RimWellPlotTools::addTimeStepsToMap(selectedTimeStepsMap, newTimeStepMap); selectedTimeSteps.insert(curveDef.timeStep()); } - m_selectedSources = std::vector(selectedSources.begin(), selectedSources.end()); + m_selectedSources = std::vector(selectedSources.begin(), selectedSources.end()); m_selectedTimeSteps = std::vector(selectedTimeSteps.begin(), selectedTimeSteps.end()); - } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateWidgetTitleWindowTitle() { @@ -375,25 +362,27 @@ void RimWellRftPlot::updateWidgetTitleWindowTitle() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::syncCurvesFromUiSelection() { RimWellLogTrack* plotTrack = m_wellLogPlot->trackByIndex(0); - const std::set& allCurveDefs = selectedCurveDefs(); + const std::set& allCurveDefs = selectedCurveDefs(); const std::set& curveDefsInPlot = curveDefsFromCurves(); - std::set curvesToDelete; + std::set curvesToDelete; std::set newCurveDefs; if (allCurveDefs.size() < curveDefsInPlot.size()) { // Determine which curves to delete from plot std::set deleteCurveDefs; - - std::set_difference(curveDefsInPlot.begin(), curveDefsInPlot.end(), - allCurveDefs.begin(), allCurveDefs.end(), + + std::set_difference(curveDefsInPlot.begin(), + curveDefsInPlot.end(), + allCurveDefs.begin(), + allCurveDefs.end(), std::inserter(deleteCurveDefs, deleteCurveDefs.end())); for (RimWellLogCurve* const curve : plotTrack->curvesVector()) @@ -408,8 +397,10 @@ void RimWellRftPlot::syncCurvesFromUiSelection() else { // Determine which curves are new since last time - std::set_difference(allCurveDefs.begin(), allCurveDefs.end(), - curveDefsInPlot.begin(), curveDefsInPlot.end(), + std::set_difference(allCurveDefs.begin(), + allCurveDefs.end(), + curveDefsInPlot.begin(), + curveDefsInPlot.end(), std::inserter(newCurveDefs, newCurveDefs.end())); } @@ -417,18 +408,16 @@ void RimWellRftPlot::syncCurvesFromUiSelection() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::set < RiaRftPltCurveDefinition > RimWellRftPlot::selectedCurveDefs() const +std::set RimWellRftPlot::selectedCurveDefs() const { - return RimWellPlotTools::curveDefsFromTimesteps(associatedSimWellName(), - m_selectedTimeSteps.v(), - true, - selectedSourcesExpanded()); + return RimWellPlotTools::curveDefsFromTimesteps( + associatedSimWellName(), m_selectedTimeSteps.v(), true, selectedSourcesExpanded()); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::set RimWellRftPlot::curveDefsFromCurves() const { @@ -443,14 +432,14 @@ std::set RimWellRftPlot::curveDefsFromCurves() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::updateCurvesInPlot(const std::set& allCurveDefs, const std::set& curveDefsToAdd, - const std::set& curvesToDelete) + const std::set& curvesToDelete) { - const QString simWellName = associatedSimWellName(); - RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); + const QString simWellName = associatedSimWellName(); + RimWellLogTrack* const plotTrack = m_wellLogPlot->trackByIndex(0); // Delete curves plotTrack->deleteAllCurves(); @@ -488,15 +477,20 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set { // Case curve->setCase(gridCase); - curve->setEclipseResultVariable("PRESSURE"); + curve->setEclipseResultVariable("PRESSURE"); // Time step - std::vector timeSteps = gridCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(); + std::vector timeSteps = + gridCase->eclipseCaseData()->results(RiaDefines::MATRIX_MODEL)->timeStepDates(); int currentTimeStepIndex = -1; - for (size_t tsIdx = 0; tsIdx < timeSteps.size(); ++tsIdx) + for (size_t tsIdx = 0; tsIdx < timeSteps.size(); ++tsIdx) { - if (timeSteps[tsIdx] == curveDefToAdd.timeStep()){ currentTimeStepIndex = static_cast(tsIdx); break;} + if (timeSteps[tsIdx] == curveDefToAdd.timeStep()) + { + currentTimeStepIndex = static_cast(tsIdx); + break; + } } curve->setCurrentTimeStep(currentTimeStepIndex); @@ -508,11 +502,12 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set else if (curveDefToAdd.address().sourceType() == RifDataSourceForRftPlt::OBSERVED) { RimWellLogFile* const wellLogFile = curveDefToAdd.address().wellLogFile(); - RimWellPath* const wellPath = RimWellPlotTools::wellPathFromWellLogFile(wellLogFile); - if(wellLogFile!= nullptr) + RimWellPath* const wellPath = RimWellPlotTools::wellPathFromWellLogFile(wellLogFile); + if (wellLogFile != nullptr) { RimWellLogFileChannel* pressureChannel = RimWellPlotTools::getPressureChannelFromWellFile(wellLogFile); - auto curve = new RimWellLogFileCurve(); + auto curve = new RimWellLogFileCurve(); + plotTrack->addCurve(curve); curve->setWellPath(wellPath); curve->setWellLogFile(wellLogFile); @@ -525,15 +520,14 @@ void RimWellRftPlot::updateCurvesInPlot(const std::set } m_wellLogPlot->loadDataAndUpdate(); - if ( plotTrack->curveCount() ) + if (plotTrack->curveCount()) { m_wellLogPlot->zoomAll(); } } - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimWellRftPlot::selectedSourcesExpanded() const { @@ -542,7 +536,8 @@ std::vector RimWellRftPlot::selectedSourcesExpanded() co { if (addr.sourceType() == RifDataSourceForRftPlt::OBSERVED) { - for (RimWellLogFile* const wellLogFile : RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName)) + for (RimWellLogFile* const wellLogFile : + RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName)) { sources.push_back(RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED, wellLogFile)); } @@ -554,7 +549,7 @@ std::vector RimWellRftPlot::selectedSourcesExpanded() co } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QWidget* RimWellRftPlot::viewWidget() { @@ -562,7 +557,7 @@ QWidget* RimWellRftPlot::viewWidget() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::zoomAll() { @@ -570,7 +565,7 @@ void RimWellRftPlot::zoomAll() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimWellLogPlot* RimWellRftPlot::wellLogPlot() const { @@ -578,7 +573,7 @@ RimWellLogPlot* RimWellRftPlot::wellLogPlot() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::setSimWellOrWellPathName(const QString& currWellName) { @@ -590,7 +585,7 @@ void RimWellRftPlot::setSimWellOrWellPathName(const QString& currWellName) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellRftPlot::simWellOrWellPathName() const { @@ -598,7 +593,7 @@ QString RimWellRftPlot::simWellOrWellPathName() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- int RimWellRftPlot::branchIndex() const { @@ -606,7 +601,7 @@ int RimWellRftPlot::branchIndex() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const char* RimWellRftPlot::plotNameFormatString() { @@ -614,9 +609,10 @@ const char* RimWellRftPlot::plotNameFormatString() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -QList RimWellRftPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +QList RimWellRftPlot::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) { QList options; @@ -629,34 +625,39 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P else if (fieldNeedingOptions == &m_selectedSources) { const std::vector rftCases = RimWellPlotTools::rftCasesForWell(simWellName); - if (rftCases.size() > 0) + if (!rftCases.empty()) { - options.push_back(caf::PdmOptionItemInfo::createHeader(RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::RFT), true)); - } - for (const auto& rftCase : rftCases) - { - auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase); - auto item = caf::PdmOptionItemInfo(rftCase->caseUserDescription(), QVariant::fromValue(addr)); - item.setLevel(1); - options.push_back(item); + options.push_back(caf::PdmOptionItemInfo::createHeader( + RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::RFT), true)); + + for (const auto& rftCase : rftCases) + { + auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::RFT, rftCase); + auto item = caf::PdmOptionItemInfo(rftCase->caseUserDescription(), QVariant::fromValue(addr)); + item.setLevel(1); + options.push_back(item); + } } const std::vector gridCases = RimWellPlotTools::gridCasesForWell(simWellName); - if (gridCases.size() > 0) + if (!gridCases.empty()) { - options.push_back(caf::PdmOptionItemInfo::createHeader(RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::GRID), true)); - } - for (const auto& gridCase : gridCases) - { - auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase); - auto item = caf::PdmOptionItemInfo(gridCase->caseUserDescription(), QVariant::fromValue(addr)); - item.setLevel(1); - options.push_back(item); + options.push_back(caf::PdmOptionItemInfo::createHeader( + RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::GRID), true)); + + for (const auto& gridCase : gridCases) + { + auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::GRID, gridCase); + auto item = caf::PdmOptionItemInfo(gridCase->caseUserDescription(), QVariant::fromValue(addr)); + item.setLevel(1); + options.push_back(item); + } } - if (RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName).size() > 0) + if (!RimWellPlotTools::wellLogFilesContainingPressure(m_wellPathNameOrSimWellName).empty()) { - options.push_back(caf::PdmOptionItemInfo::createHeader(RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::OBSERVED), true)); + options.push_back(caf::PdmOptionItemInfo::createHeader( + RifDataSourceForRftPlt::sourceTypeUiText(RifDataSourceForRftPlt::OBSERVED), true)); auto addr = RifDataSourceForRftPlt(RifDataSourceForRftPlt::OBSERVED); auto item = caf::PdmOptionItemInfo("Observed Data", QVariant::fromValue(addr)); @@ -666,10 +667,8 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P } else if (fieldNeedingOptions == &m_selectedTimeSteps) { - RimWellPlotTools::calculateValueOptionsForTimeSteps( associatedSimWellName(), - selectedSourcesExpanded(), - { RifEclipseRftAddress::PRESSURE }, - options); + RimWellPlotTools::calculateValueOptionsForTimeSteps( + associatedSimWellName(), selectedSourcesExpanded(), {RifEclipseRftAddress::PRESSURE}, options); } else if (fieldNeedingOptions == &m_branchIndex) { @@ -682,7 +681,7 @@ QList RimWellRftPlot::calculateValueOptions(const caf::P } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { @@ -706,18 +705,15 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c updateEditorsFromCurves(); updateFormationsOnPlot(); } - else if (changedField == &m_branchIndex || - changedField == &m_branchDetection) + else if (changedField == &m_branchIndex || changedField == &m_branchDetection) { const QString simWellName = associatedSimWellName(); - m_branchIndex = RiaSimWellBranchTools::clampBranchIndex(simWellName, m_branchIndex, m_branchDetection); + m_branchIndex = RiaSimWellBranchTools::clampBranchIndex(simWellName, m_branchIndex, m_branchDetection); updateFormationsOnPlot(); syncCurvesFromUiSelection(); - } - else if (changedField == &m_selectedSources || - changedField == &m_selectedTimeSteps) + else if (changedField == &m_selectedSources || changedField == &m_selectedTimeSteps) { updateFormationsOnPlot(); syncCurvesFromUiSelection(); @@ -725,12 +721,12 @@ void RimWellRftPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } else if (changedField == &m_showPlotTitle) { - //m_wellLogPlot->setShowDescription(m_showPlotTitle); + // m_wellLogPlot->setShowDescription(m_showPlotTitle); } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) { @@ -738,7 +734,7 @@ void RimWellRftPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QImage RimWellRftPlot::snapshotWindowContent() { @@ -747,14 +743,14 @@ QImage RimWellRftPlot::snapshotWindowContent() if (m_wellLogPlotWidget) { QPixmap pix = QPixmap::grabWidget(m_wellLogPlotWidget); - image = pix.toImage(); + image = pix.toImage(); } return image; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { @@ -767,10 +763,8 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add(&m_userName); uiOrdering.add(&m_wellPathNameOrSimWellName); - RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName(&uiOrdering, - m_wellPathNameOrSimWellName, - m_branchDetection, - m_branchIndex); + RiaSimWellBranchTools::appendSimWellBranchFieldsIfRequiredFromWellName( + &uiOrdering, m_wellPathNameOrSimWellName, m_branchDetection, m_branchIndex); caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", "Sources"); sourcesGroup->add(&m_selectedSources); @@ -786,7 +780,7 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& caf::PdmUiGroup* legendAndAxisGroup = uiOrdering.addNewGroup("Legend and Axis"); legendAndAxisGroup->setCollapsedByDefault(true); - + m_wellLogPlot->uiOrderingForPlot(*legendAndAxisGroup); track->uiOrderingForVisibleXRange(*legendAndAxisGroup); @@ -798,18 +792,18 @@ void RimWellRftPlot::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::calculateValueOptionsForWells(QList& options) { - RimProject * proj = RiaApplication::instance()->project(); + RimProject* proj = RiaApplication::instance()->project(); options.push_back(caf::PdmOptionItemInfo("None", "None")); if (proj != nullptr) { - const std::vector simWellNames = proj->simulationWellNames(); - std::set simWellsAssociatedWithWellPath; + const std::vector simWellNames = proj->simulationWellNames(); + std::set simWellsAssociatedWithWellPath; std::set> wellNames; // Observed wells @@ -840,7 +834,7 @@ void RimWellRftPlot::calculateValueOptionsForWells(QList } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::setDescription(const QString& description) { @@ -850,7 +844,7 @@ void RimWellRftPlot::setDescription(const QString& description) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QString RimWellRftPlot::description() const { @@ -858,7 +852,7 @@ QString RimWellRftPlot::description() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimWellRftPlot::onLoadDataAndUpdate() { @@ -871,19 +865,22 @@ void RimWellRftPlot::onLoadDataAndUpdate() m_isOnLoad = false; } + updateMdiWindowVisibility(); updateFormationsOnPlot(); + m_wellLogPlot->loadDataAndUpdate(); + updateEditorsFromCurves(); updateWidgetTitleWindowTitle(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- QWidget* RimWellRftPlot::createViewWidget(QWidget* mainWindowParent) { m_wellLogPlotWidget = new RiuWellRftPlot(this, mainWindowParent); + return m_wellLogPlotWidget; } - diff --git a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h index f1995a020c..106d37be79 100644 --- a/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h +++ b/ApplicationCode/ProjectDataModel/Flow/RimWellRftPlot.h @@ -93,7 +93,7 @@ class RimWellRftPlot : public RimViewWindow // Overridden PDM methods virtual caf::PdmFieldHandle* userDescriptionField() override { return &m_userName; } virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; - virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName); + void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) override; virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; @@ -117,7 +117,7 @@ class RimWellRftPlot : public RimViewWindow void updateCurvesInPlot(const std::set& allCurveDefs, const std::set& curveDefsToAdd, const std::set& curvesToDelete); - std::vector selectedSourcesExpanded() const; + std::vector selectedSourcesExpanded() const; // RimViewWindow overrides @@ -141,10 +141,10 @@ class RimWellRftPlot : public RimViewWindow caf::PdmField> m_selectedTimeSteps; - QPointer m_wellLogPlotWidget; - caf::PdmChildField m_wellLogPlot; + QPointer m_wellLogPlotWidget; + bool m_selectedSourcesOrTimeStepsFieldsChanged; bool m_isOnLoad; }; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp new file mode 100644 index 0000000000..7508c16ae2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.cpp @@ -0,0 +1,762 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim2dIntersectionView.h" + +#include "Rim3dOverlayInfoConfig.h" +#include "RimCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseView.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechView.h" +#include "RimGridView.h" +#include "RimIntersection.h" +#include "RimRegularLegendConfig.h" +#include "RimSimWellInView.h" +#include "RimTernaryLegendConfig.h" +#include "RimWellPath.h" + +#include "RiuMainWindow.h" +#include "RiuViewer.h" + +#include "RivIntersectionPartMgr.h" +#include "RivSimWellPipesPartMgr.h" +#include "RivTernarySaturationOverlayItem.h" +#include "RivWellHeadPartMgr.h" +#include "RivWellPathPartMgr.h" + +#include "cafDisplayCoordTransform.h" + +#include "cvfModelBasicList.h" +#include "cvfTransform.h" +#include "cvfScene.h" +#include "cvfPart.h" + +#include + +CAF_PDM_SOURCE_INIT(Rim2dIntersectionView, "Intersection2dView"); + +const cvf::Mat4d defaultIntersectinoViewMatrix(1, 0, 0, 0, + 0, 0, 1, 0, + 0, -1, 0, 1000, + 0, 0, 0, 1); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView::Rim2dIntersectionView(void) +{ + CAF_PDM_InitObject("Intersection View", ":/CrossSection16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_intersection, "Intersection", "Intersection", ":/CrossSection16x16.png", "", ""); + m_intersection.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + m_legendConfig.uiCapability()->setUiHidden(true); + m_legendConfig.uiCapability()->setUiTreeChildrenHidden(true); + m_legendConfig.xmlCapability()->disableIO(); + m_legendConfig = new RimRegularLegendConfig(); + + CAF_PDM_InitFieldNoDefault(&m_ternaryLegendConfig, "TernaryLegendDefinition", "Ternary Legend Definition", "", "", ""); + m_ternaryLegendConfig.uiCapability()->setUiTreeHidden(true); + m_ternaryLegendConfig.uiCapability()->setUiTreeChildrenHidden(true); + m_ternaryLegendConfig.xmlCapability()->disableIO(); + m_ternaryLegendConfig = new RimTernaryLegendConfig(); + + CAF_PDM_InitField(&m_showDefiningPoints, "ShowDefiningPoints", true, "Show Points", "", "", ""); + + m_showWindow = false; + m_scaleTransform = new cvf::Transform(); + m_intersectionVizModel = new cvf::ModelBasicList; + + hasUserRequestedAnimation = true; + + ((RiuViewerToViewInterface*)this)->setCameraPosition(defaultIntersectinoViewMatrix ); + + disableGridBoxField(); + disablePerspectiveProjectionField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView::~Rim2dIntersectionView(void) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setVisible(bool isVisible) +{ + m_showWindow = isVisible; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::setIntersection(RimIntersection* intersection) +{ + CAF_ASSERT(intersection); + + m_intersection = intersection; + + this->updateName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersection* Rim2dIntersectionView::intersection() const +{ + return m_intersection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isUsingFormationNames() const +{ + // Todo: + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::scheduleGeometryRegen(RivCellSetEnum geometryType) +{ + m_flatIntersectionPartMgr = nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCase* Rim2dIntersectionView::ownerCase() const +{ + RimCase* rimCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(rimCase); + return rimCase; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isTimeStepDependentDataVisible() const +{ + if ( m_intersection() ) + { + RimGridView * gridView = nullptr; + m_intersection->firstAncestorOrThisOfTypeAsserted(gridView); + return gridView->isTimeStepDependentDataVisible(); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::update3dInfo() +{ + if (!m_viewer) return; + + QString overlayInfoText; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView && !eclView->overlayInfoConfig()->isActive()) + { + m_viewer->showInfoText(false); + m_viewer->showHistogram(false); + m_viewer->showAnimationProgress(false); + + m_viewer->update(); + return; + } + if (eclView && eclView->overlayInfoConfig()->showCaseInfo()) + { + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + } + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView && geoView->overlayInfoConfig()->showCaseInfo()) + { + overlayInfoText += "--" + ownerCase()->caseUserDescription() + "--"; + } + + overlayInfoText += "

"; + + overlayInfoText += "Z-scale: " + QString::number(scaleZ()) + "
"; + + if (m_intersection->simulationWell()) + { + overlayInfoText += "Simulation Well: " + m_intersection->simulationWell()->name() + "
"; + } + else if (m_intersection->wellPath()) + { + overlayInfoText += "Well Path: " + m_intersection->wellPath()->name() + "
"; + } + else + { + overlayInfoText += "Intersection: " + m_intersection->name() + "
"; + } + + if (eclView) + { + if (eclView->overlayInfoConfig()->showAnimProgress()) + { + m_viewer->showAnimationProgress(true); + } + else + { + m_viewer->showAnimationProgress(false); + } + + if (eclView->overlayInfoConfig()->showResultInfo()) + { + overlayInfoText += "Cell Result: " + eclView->cellResult()->resultVariableUiShortName() + "
"; + } + } + + if (geoView) + { + if (geoView->overlayInfoConfig()->showAnimProgress()) + { + m_viewer->showAnimationProgress(true); + } + else + { + m_viewer->showAnimationProgress(false); + } + + if (geoView->overlayInfoConfig()->showResultInfo()) + { + QString resultPos; + QString fieldName = geoView->cellResultResultDefinition()->resultFieldUiName(); + QString compName = geoView->cellResultResultDefinition()->resultComponentUiName(); + + switch (geoView->cellResultResultDefinition()->resultPositionType()) + { + case RIG_NODAL: + resultPos = "Nodal"; + break; + + case RIG_ELEMENT_NODAL: + resultPos = "Element nodal"; + break; + + case RIG_INTEGRATION_POINT: + resultPos = "Integration point"; + break; + + case RIG_ELEMENT: + resultPos = "Element"; + break; + default: + break; + } + if (compName == "") + { + overlayInfoText += QString("Cell result: %1, %2
").arg(resultPos).arg(fieldName); + } + else + { + overlayInfoText += QString("Cell result: %1, %2, %3
").arg(resultPos).arg(fieldName).arg(compName); + } + } + } + + + overlayInfoText += "

"; + m_viewer->setInfoText(overlayInfoText); + m_viewer->showInfoText(true); + m_viewer->update(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateName() +{ + if ( m_intersection ) + { + Rim3dView * parentView = nullptr; + m_intersection->firstAncestorOrThisOfTypeAsserted(parentView); + name = parentView->name() + ": " + m_intersection->name(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim2dIntersectionView::flatIntersectionPartMgr() const +{ + return m_flatIntersectionPartMgr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isGridVisualizationMode() const +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d Rim2dIntersectionView::transformToUtm(const cvf::Vec3d& unscaledPointInFlatDomain) const +{ + cvf::Mat4d unflatXf = this->flatIntersectionPartMgr()->unflattenTransformMatrix(unscaledPointInFlatDomain); + + return unscaledPointInFlatDomain.getTransformedPoint(unflatXf); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim2dIntersectionView::displayCoordTransform() const +{ + cvf::ref dispTx = new caf::DisplayCoordTransform(); + dispTx->setScale(cvf::Vec3d(1.0, 1.0, scaleZ())); + return dispTx; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::showDefiningPoints() const +{ + return m_showDefiningPoints; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Rim2dIntersectionView::legendConfigs() const +{ + std::vector legendsIn3dView; + + // Return empty list, as the intersection view has a copy of the legend items. Picking and selection of the corresponding + // item is handeled by handleOverlayItemPicked() + return legendsIn3dView; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::handleOverlayItemPicked(const cvf::OverlayItem* pickedOverlayItem) const +{ + if (m_legendObjectToSelect) + { + RiuMainWindow::instance()->selectAsCurrentItem(m_legendObjectToSelect); + + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim2dIntersectionView::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::hasResults() +{ + if (!m_intersection()) return false; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + if (eclView) + { + return (eclView->cellResult()->hasResult() || eclView->cellResult()->isTernarySaturationSelected()); + } + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + if (geoView) + { + return geoView->cellResult()->hasResult(); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int Rim2dIntersectionView::timeStepCount() +{ + if ( isTimeStepDependentDataVisible() ) + { + return static_cast( this->ownerCase()->timeStepStrings().size()); + } + + return 0; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim2dIntersectionView::isWindowVisible() +{ + return m_showWindow(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::createDisplayModel() +{ + if (m_viewer.isNull()) return; + if (!m_intersection()) return; + + updateScaleTransform(); + + m_viewer->removeAllFrames(); + + int tsCount = this->timeStepCount(); + + for (int i = 0; i < tsCount; ++i) + { + m_viewer->addFrame(new cvf::Scene()); + } + + m_flatIntersectionPartMgr = new RivIntersectionPartMgr(m_intersection(), true); + + + m_intersectionVizModel->removeAllParts(); + + m_flatIntersectionPartMgr->appendNativeCrossSectionFacesToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendMeshLinePartsToModel(m_intersectionVizModel.p(), scaleTransform()); + m_flatIntersectionPartMgr->appendPolylinePartsToModel(*this, m_intersectionVizModel.p(), scaleTransform()); + + m_flatIntersectionPartMgr->applySingleColorEffect(); + + m_flatSimWellPipePartMgr = nullptr; + m_flatWellHeadPartMgr = nullptr; + + if ( m_intersection->type() == RimIntersection::CS_SIMULATION_WELL + && m_intersection->simulationWell() ) + { + RimEclipseView* eclipseView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclipseView); + + if ( eclipseView ) + { + m_flatSimWellPipePartMgr = new RivSimWellPipesPartMgr(m_intersection->simulationWell()); + m_flatWellHeadPartMgr = new RivWellHeadPartMgr(m_intersection->simulationWell()); + } + } + + m_flatWellpathPartMgr = nullptr; + if ( m_intersection->type() == RimIntersection::CS_WELL_PATH + && m_intersection->wellPath() ) + { + Rim3dView* settingsView = nullptr; + m_intersection->firstAncestorOrThisOfType(settingsView); + if ( settingsView ) + { + m_flatWellpathPartMgr = new RivWellPathPartMgr(m_intersection->wellPath(), settingsView); + m_flatWellpathPartMgr->appendFlattenedStaticGeometryPartsToModel(m_intersectionVizModel.p(), + this->displayCoordTransform().p(), + this->ownerCase()->characteristicCellSize(), + this->ownerCase()->activeCellsBoundingBox()); + } + } + + m_viewer->addStaticModelOnce(m_intersectionVizModel.p()); + + m_intersectionVizModel->updateBoundingBoxesRecursive(); + + if ( this->hasUserRequestedAnimation() ) + { + m_viewer->setCurrentFrame(m_currentTimeStep); + updateCurrentTimeStep(); + } + + if ( this->viewer()->mainCamera()->viewMatrix() == defaultIntersectinoViewMatrix ) + { + this->zoomAll(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateCurrentTimeStep() +{ + update3dInfo(); + updateLegends(); + + if ( m_flatSimWellPipePartMgr.notNull() ) + { + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + { + cvf::String name = "SimWellPipeMod"; + Rim3dView::removeModelByName(frameScene, name); + + cvf::ref simWellModelBasicList = new cvf::ModelBasicList; + simWellModelBasicList->setName(name); + + m_flatSimWellPipePartMgr->appendFlattenedDynamicGeometryPartsToModel(simWellModelBasicList.p(), + m_currentTimeStep, + this->displayCoordTransform().p(), + m_intersection->extentLength(), + m_intersection->branchIndex()); + + for ( double offset : m_flatSimWellPipePartMgr->flattenedBranchWellHeadOffsets() ) + { + m_flatWellHeadPartMgr->appendFlattenedDynamicGeometryPartsToModel(simWellModelBasicList.p(), + m_currentTimeStep, + this->displayCoordTransform().p(), + offset); + } + + simWellModelBasicList->updateBoundingBoxesRecursive(); + frameScene->addModel(simWellModelBasicList.p()); + m_flatSimWellPipePartMgr->updatePipeResultColor(m_currentTimeStep); + } + } + } + + if ( m_flatWellpathPartMgr.notNull() ) + { + cvf::Scene* frameScene = m_viewer->frame(m_currentTimeStep); + if (frameScene) + { + { + cvf::String name = "WellPipeDynMod"; + Rim3dView::removeModelByName(frameScene, name); + cvf::ref dynWellPathModel = new cvf::ModelBasicList; + dynWellPathModel->setName(name); + + m_flatWellpathPartMgr->appendFlattenedDynamicGeometryPartsToModel(dynWellPathModel.p(), + m_currentTimeStep, + this->displayCoordTransform().p(), + this->ownerCase()->characteristicCellSize(), + this->ownerCase()->activeCellsBoundingBox()); + dynWellPathModel->updateBoundingBoxesRecursive(); + frameScene->addModel(dynWellPathModel.p()); + } + } + } + + + if ((this->hasUserRequestedAnimation() && this->hasResults())) + { + m_flatIntersectionPartMgr->updateCellResultColor(m_currentTimeStep, + m_legendConfig->scalarMapper(), + m_ternaryLegendConfig()->scalarMapper()); + } + else + { + m_flatIntersectionPartMgr->applySingleColorEffect(); + } + +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateLegends() +{ + m_legendObjectToSelect = nullptr; + + if (!m_viewer) return; + + m_viewer->removeAllColorLegends(); + + if (!hasResults()) return; + + RimEclipseView * eclView = nullptr; + m_intersection->firstAncestorOrThisOfType(eclView); + + RimGeoMechView * geoView = nullptr; + m_intersection->firstAncestorOrThisOfType(geoView); + + caf::TitledOverlayFrame* legend = nullptr; + + if (eclView) + { + m_legendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->legendConfig()); + m_ternaryLegendConfig()->setUiValuesFromLegendConfig(eclView->cellResult()->ternaryLegendConfig()); + eclView->cellResult()->updateLegendData(m_currentTimeStep(), m_legendConfig(), m_ternaryLegendConfig()); + + if ( eclView->cellResult()->isTernarySaturationSelected() ) + { + m_ternaryLegendConfig()->setTitle("Cell Result:\n"); + legend = m_ternaryLegendConfig()->titledOverlayFrame(); + + m_legendObjectToSelect = eclView->cellResult()->ternaryLegendConfig(); + } + else + { + m_legendConfig()->setTitle("Cell Result:\n" + eclView->cellResult()->resultVariableUiShortName()); + legend = m_legendConfig()->titledOverlayFrame(); + + m_legendObjectToSelect = eclView->cellResult()->legendConfig(); + } + } + + if (geoView) + { + m_legendConfig()->setUiValuesFromLegendConfig(geoView->cellResult()->legendConfig()); + + geoView->updateLegendTextAndRanges(m_legendConfig(), m_currentTimeStep()); + legend = m_legendConfig()->titledOverlayFrame(); + + m_legendObjectToSelect = geoView->cellResult()->legendConfig(); + } + + if ( legend ) + { + m_viewer->addColorLegendToBottomLeftCorner(legend); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::resetLegendsInViewer() +{ + m_viewer->showAxisCross(false); + m_viewer->showAnimationProgress(true); + m_viewer->showHistogram(false); + m_viewer->showInfoText(false); + m_viewer->showEdgeTickMarks(true); + + m_viewer->setMainScene(new cvf::Scene()); + m_viewer->enableNavigationRotation(false); + + m_ternaryLegendConfig()->recreateLegend(); + m_legendConfig()->recreateLegend(); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::createPartCollectionFromSelection(cvf::Collection* parts) +{ +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onTimeStepChanged() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::clampCurrentTimestep() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateStaticCellColors() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::updateScaleTransform() +{ + cvf::Mat4d scale = cvf::Mat4d::IDENTITY; + scale(2, 2) = scaleZ(); + + this->scaleTransform()->setLocalTransform(scale); + + if (m_viewer) m_viewer->updateCachedValuesInScene(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Transform* Rim2dIntersectionView::scaleTransform() +{ + return m_scaleTransform.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::onLoadDataAndUpdate() +{ + updateMdiWindowVisibility(); + + this->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); + + if (changedField == & m_intersection || + changedField == &m_showDefiningPoints) + { + this->loadDataAndUpdate(); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); + uiOrdering.skipRemainingFields(true); + + if (m_intersection->hasDefiningPoints()) + { + caf::PdmUiGroup* plGroup = uiOrdering.addNewGroup("Defining Points"); + plGroup->add(&m_showDefiningPoints); + } +} diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h new file mode 100644 index 0000000000..7a06559d66 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionView.h @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dView.h" +#include "cafPdmPtrField.h" + +class RimIntersection; +class RimRegularLegendConfig; +class RimTernaryLegendConfig; +class RivSimWellPipesPartMgr; +class RivWellHeadPartMgr; +class RivWellPathPartMgr; +class RivIntersectionPartMgr; + +namespace cvf +{ + class ModelBasicList; + class OverlayItem; +} + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim2dIntersectionView : public Rim3dView +{ + CAF_PDM_HEADER_INIT; +public: + Rim2dIntersectionView(void); + virtual ~Rim2dIntersectionView(void); + + void setVisible(bool isVisible); + void setIntersection(RimIntersection* intersection); + RimIntersection* intersection() const; + + virtual bool isUsingFormationNames() const override; + virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; + virtual RimCase* ownerCase() const override; + virtual void selectOverlayInfoConfig() override {} + + virtual RimViewLinker* assosiatedViewLinker() const override { return nullptr; } + virtual RimViewController* viewController() const override { return nullptr; } + + virtual bool isTimeStepDependentDataVisible() const override; + + void update3dInfo(); + void updateName(); + + cvf::ref flatIntersectionPartMgr() const; + cvf::Vec3d transformToUtm(const cvf::Vec3d& unscaledPointInFlatDomain) const; + + virtual cvf::ref displayCoordTransform() const override; + + bool showDefiningPoints() const; + + std::vector legendConfigs() const override; + bool handleOverlayItemPicked(const cvf::OverlayItem* pickedOverlayItem) const; + +protected: + void updateLegends() override; + + virtual bool isGridVisualizationMode() const override; + virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) override; + virtual void createDisplayModel() override; + virtual void createPartCollectionFromSelection(cvf::Collection* parts) override; + virtual void clampCurrentTimestep() override; + virtual void updateCurrentTimeStep() override; + virtual void onTimeStepChanged() override; + virtual void updateStaticCellColors() override; + virtual void updateScaleTransform() override; + virtual cvf::Transform* scaleTransform() override; + virtual void resetLegendsInViewer() override; + virtual void onLoadDataAndUpdate() override; + virtual bool isWindowVisible() override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + + bool hasResults(); + int timeStepCount(); + + + caf::PdmChildField m_legendConfig; + caf::PdmChildField m_ternaryLegendConfig; + + caf::PdmPtrField m_intersection; + + cvf::ref m_flatIntersectionPartMgr; + cvf::ref m_flatSimWellPipePartMgr; + cvf::ref m_flatWellHeadPartMgr; + cvf::ref m_flatWellpathPartMgr; + cvf::ref m_intersectionVizModel; + cvf::ref m_scaleTransform; + + caf::PdmField m_showDefiningPoints; + + caf::PdmPointer m_legendObjectToSelect; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp new file mode 100644 index 0000000000..3b85df0ccc --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.cpp @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim2dIntersectionViewCollection.h" + +#include "Rim2dIntersectionView.h" +#include "RimCase.h" +#include "RimIntersection.h" + +CAF_PDM_SOURCE_INIT(Rim2dIntersectionViewCollection, "Intersection2dViewCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionViewCollection::Rim2dIntersectionViewCollection() +{ + CAF_PDM_InitObject("2D Intersection Views", ":/CrossSection16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_intersectionViews, "IntersectionViews", "Intersection Views", ":/CrossSection16x16.png", "", ""); + m_intersectionViews.uiCapability()->setUiTreeHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionViewCollection::~Rim2dIntersectionViewCollection() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector Rim2dIntersectionViewCollection::views() +{ + return m_intersectionViews.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim2dIntersectionViewCollection::syncFromExistingIntersections( bool doUpdate ) +{ + RimCase* parentCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(parentCase); + + std::vector allOrderedIntersectionsInCase; + parentCase->descendantsIncludingThisOfType(allOrderedIntersectionsInCase); + + std::set currentIntersections(allOrderedIntersectionsInCase.begin(), allOrderedIntersectionsInCase.end()); + std::set intersectionsNeedingViews = currentIntersections; + + // Delete views without a valid intersection + + for ( Rim2dIntersectionView* iv: m_intersectionViews ) + { + if ( iv && !iv->intersection() ) + { + delete iv; + } + } + + // Clean up the container by removing nullptr's + + m_intersectionViews.removeChildObject(nullptr); + + // Build map from intersection to view + + std::map intersectionToViewMap; + for (Rim2dIntersectionView* iv: m_intersectionViews) + { + CVF_ASSERT (iv && iv->intersection()); + intersectionToViewMap[iv->intersection()] = iv; + } + + m_intersectionViews.clear(); // Not deleting the views. The are managed by the map + + // Insert the old views in correct order, and create new views as we go + + for (RimIntersection* intersection : allOrderedIntersectionsInCase) + { + auto it = intersectionToViewMap.find(intersection); + if (it == intersectionToViewMap.end()) + { + Rim2dIntersectionView* newView = new Rim2dIntersectionView(); + newView->setIntersection(intersection); + m_intersectionViews.push_back(newView); + } + else + { + m_intersectionViews.push_back(it->second); + } + } + + if (doUpdate) this->updateConnectedEditors(); + + RimCase* rimCase = nullptr; + firstAncestorOrThisOfType(rimCase); + + if (rimCase) rimCase->updateConnectedEditors(); +} diff --git a/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h new file mode 100644 index 0000000000..ce02db28c1 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim2dIntersectionViewCollection.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmObject.h" +#include "cafPdmField.h" +#include "cafPdmChildArrayField.h" + +class Rim2dIntersectionView; + +class Rim2dIntersectionViewCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + Rim2dIntersectionViewCollection(); + virtual ~Rim2dIntersectionViewCollection(); + + void syncFromExistingIntersections( bool doUpdate ); + + std::vector views(); + +private: + caf::PdmChildArrayField m_intersectionViews; +}; + + + diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp index 311c249987..a761bb0175 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.cpp @@ -35,6 +35,10 @@ #include "RigMainGrid.h" #include "RigStatisticsDataCache.h" +#include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" +#include "Rim3dView.h" +#include "RimCase.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -47,7 +51,6 @@ #include "RimGeoMechView.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInViewCollection.h" -#include "RimView.h" #include "RimTools.h" #include "RiuViewer.h" @@ -92,14 +95,14 @@ Rim3dOverlayInfoConfig::Rim3dOverlayInfoConfig() { CAF_PDM_InitObject("Info Box", ":/InfoBox16x16.png", "", ""); - CAF_PDM_InitField(&active, "Active", true, "Active", "", "", ""); - active.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_active, "Active", true, "Active", "", "", ""); + m_active.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&showAnimProgress, "ShowAnimProgress", true, "Animation progress", "", "", ""); - CAF_PDM_InitField(&showCaseInfo, "ShowInfoText", true, "Case Info", "", "", ""); - CAF_PDM_InitField(&showResultInfo, "ShowResultInfo", true, "Result Info", "", "", ""); - CAF_PDM_InitField(&showHistogram, "ShowHistogram", true, "Histogram", "", "", ""); - CAF_PDM_InitField(&showVolumeWeightedMean, "ShowVolumeWeightedMean", true, "Mobile Volume Weighted Mean", "", "", ""); + CAF_PDM_InitField(&m_showAnimProgress, "ShowAnimProgress", true, "Animation progress", "", "", ""); + CAF_PDM_InitField(&m_showCaseInfo, "ShowInfoText", true, "Case Info", "", "", ""); + CAF_PDM_InitField(&m_showResultInfo, "ShowResultInfo", true, "Result Info", "", "", ""); + CAF_PDM_InitField(&m_showHistogram, "ShowHistogram", true, "Histogram", "", "", ""); + CAF_PDM_InitField(&m_showVolumeWeightedMean, "ShowVolumeWeightedMean", true, "Mobile Volume Weighted Mean", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_statisticsTimeRange, "StatisticsTimeRange", "Statistics Time Range", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_statisticsCellRange, "StatisticsCellRange", "Statistics Cell Range", "", "", ""); @@ -131,17 +134,17 @@ void Rim3dOverlayInfoConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed if ( changedField == &m_statisticsCellRange ) m_statisticsCellRange = ALL_CELLS; } - if (changedField == &showResultInfo) + if (changedField == &m_showResultInfo) { - if (!showResultInfo()) + if (!m_showResultInfo()) { - showVolumeWeightedMean = false; - showVolumeWeightedMean.uiCapability()->setUiReadOnly(true); + m_showVolumeWeightedMean = false; + m_showVolumeWeightedMean.uiCapability()->setUiReadOnly(true); } else { - showVolumeWeightedMean = true; - showVolumeWeightedMean.uiCapability()->setUiReadOnly(false); + m_showVolumeWeightedMean = true; + m_showVolumeWeightedMean.uiCapability()->setUiReadOnly(false); } } @@ -209,7 +212,7 @@ QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData) auto eclipseView = dynamic_cast(m_viewDef.p()); auto geoMechView = dynamic_cast(m_viewDef.p()); - if (eclipseView) return resultInfoText(histData, eclipseView, showVolumeWeightedMean()); + if (eclipseView) return resultInfoText(histData, eclipseView, m_showVolumeWeightedMean()); if (geoMechView) return resultInfoText(histData, geoMechView); return ""; } @@ -226,6 +229,38 @@ QImage Rim3dOverlayInfoConfig::statisticsDialogScreenShotImage() return QImage(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::showAnimProgress() const +{ + return m_showAnimProgress; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::showCaseInfo() const +{ + return m_showCaseInfo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::showResultInfo() const +{ + return m_showResultInfo; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dOverlayInfoConfig::isActive() const +{ + return m_active; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -467,7 +502,7 @@ QString Rim3dOverlayInfoConfig::caseInfoText(RimGeoMechView* geoMechView) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; - RigFemPartCollection* femParts = caseData ? caseData->femParts() : NULL; + RigFemPartCollection* femParts = caseData ? caseData->femParts() : nullptr; if (femParts) { @@ -597,12 +632,21 @@ QString Rim3dOverlayInfoConfig::resultInfoText(const HistogramData& histData, Ri case RIG_INTEGRATION_POINT: resultPos = "Integration point"; break; - + + case RIG_ELEMENT: + resultPos = "Element"; + break; default: break; } - - infoText += QString("Cell result: %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); + if (compName == "") + { + infoText += QString("Cell result: %1, %2").arg(resultPos).arg(fieldName); + } + else + { + infoText += QString("Cell result: %1, %2, %3").arg(resultPos).arg(fieldName).arg(compName); + } infoText += QString("
Statistics: ") + m_statisticsTimeRange().uiText() + " and " + m_statisticsCellRange().uiText(); infoText += QString("" @@ -645,18 +689,19 @@ void Rim3dOverlayInfoConfig::update3DInfo() if (!m_viewDef) return; if (!m_viewDef->viewer()) return; - if (!this->active()) + if (!this->m_active()) { m_viewDef->viewer()->showInfoText(false); m_viewDef->viewer()->showHistogram(false); m_viewDef->viewer()->showAnimationProgress(false); + update3DInfoIn2dViews(); return; } - m_viewDef->viewer()->showInfoText(showCaseInfo() || showResultInfo()); + m_viewDef->viewer()->showInfoText(m_showCaseInfo() || m_showResultInfo()); m_viewDef->viewer()->showHistogram(false); - m_viewDef->viewer()->showAnimationProgress(showAnimProgress()); + m_viewDef->viewer()->showAnimationProgress(m_showAnimProgress()); m_isVisCellStatUpToDate = false; @@ -678,13 +723,15 @@ void Rim3dOverlayInfoConfig::update3DInfo() RimGeoMechView * geoMechView = dynamic_cast(m_viewDef.p()); if (geoMechView) { - showVolumeWeightedMean = false; + m_showVolumeWeightedMean = false; updateGeoMech3DInfo(geoMechView); // Update statistics dialog m_gridStatisticsDialog->updateFromRimView(geoMechView); } + + update3DInfoIn2dViews(); } //-------------------------------------------------------------------------------------------------- @@ -692,7 +739,7 @@ void Rim3dOverlayInfoConfig::update3DInfo() //-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* Rim3dOverlayInfoConfig::objectToggleField() { - return &active; + return &m_active; } @@ -703,16 +750,16 @@ void Rim3dOverlayInfoConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr { caf::PdmUiGroup* visGroup = uiOrdering.addNewGroup("Visibility"); - visGroup->add(&showAnimProgress); - visGroup->add(&showCaseInfo); - visGroup->add(&showResultInfo); + visGroup->add(&m_showAnimProgress); + visGroup->add(&m_showCaseInfo); + visGroup->add(&m_showResultInfo); RimGeoMechView * geoMechView = dynamic_cast(m_viewDef.p()); if (!geoMechView) { - visGroup->add(&showVolumeWeightedMean); + visGroup->add(&m_showVolumeWeightedMean); } - visGroup->add(&showHistogram); + visGroup->add(&m_showHistogram); caf::PdmUiGroup* statGroup = uiOrdering.addNewGroup("Statistics Options"); RimEclipseView * eclipseView = dynamic_cast(m_viewDef.p()); @@ -729,7 +776,7 @@ void Rim3dOverlayInfoConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void Rim3dOverlayInfoConfig::setReservoirView(RimView* ownerReservoirView) +void Rim3dOverlayInfoConfig::setReservoirView(RimGridView* ownerReservoirView) { m_viewDef = ownerReservoirView; } @@ -741,19 +788,19 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) { HistogramData histData; - if (showHistogram() || showResultInfo()) + if (m_showHistogram() || m_showResultInfo()) { histData = histogramData(); } QString infoText; - if (showCaseInfo()) + if (m_showCaseInfo()) { infoText = caseInfoText(); } - if (showResultInfo()) + if (m_showResultInfo()) { infoText += resultInfoText(histData); } @@ -763,7 +810,7 @@ void Rim3dOverlayInfoConfig::updateEclipse3DInfo(RimEclipseView * eclipseView) eclipseView->viewer()->setInfoText(infoText); } - if (showHistogram()) + if (m_showHistogram()) { bool isResultsInfoRelevant = eclipseView->hasUserRequestedAnimation() && eclipseView->cellResult()->hasResult(); @@ -783,7 +830,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) { HistogramData histData; - if (showResultInfo() || showHistogram()) + if (m_showResultInfo() || m_showHistogram()) { histData = histogramData(geoMechView); } @@ -792,12 +839,12 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) QString infoText; - if (showCaseInfo()) + if (m_showCaseInfo()) { infoText = caseInfoText(geoMechView); } - if (showResultInfo()) + if (m_showResultInfo()) { infoText += resultInfoText(histData, geoMechView); } @@ -809,7 +856,7 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) // Populate histogram - if (showHistogram()) + if (m_showHistogram()) { RimGeoMechCase* geoMechCase = geoMechView->geoMechCase(); RigGeoMechCaseData* caseData = geoMechCase ? geoMechCase->geoMechData() : nullptr; @@ -824,6 +871,22 @@ void Rim3dOverlayInfoConfig::updateGeoMech3DInfo(RimGeoMechView * geoMechView) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dOverlayInfoConfig::update3DInfoIn2dViews() const +{ + RimCase* rimCase; + firstAncestorOrThisOfType(rimCase); + if (rimCase) + { + for (Rim2dIntersectionView* view : rimCase->intersectionViewCollection()->views()) + { + view->update3dInfo(); + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -851,7 +914,9 @@ QString Rim3dOverlayInfoConfig::timeStepText(RimEclipseView* eclipseView) QString Rim3dOverlayInfoConfig::timeStepText(RimGeoMechView* geoMechView) { int currTimeStepIndex = geoMechView->currentTimeStep(); - QStringList timeSteps = geoMechView->geoMechCase()->timeStepStrings(); + + QStringList timeSteps; + if (geoMechView->geoMechCase()) timeSteps = geoMechView->geoMechCase()->timeStepStrings(); QString dateTimeString; if (currTimeStepIndex >= 0 && currTimeStepIndex < timeSteps.size()) diff --git a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h index 66c81a2421..9a55f603fd 100644 --- a/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h +++ b/ApplicationCode/ProjectDataModel/Rim3dOverlayInfoConfig.h @@ -32,7 +32,7 @@ class RimEclipseView; class RimGeoMechView; -class RimView; +class RimGridView; class RigStatisticsDataCache; class RicGridStatisticsDialog; @@ -67,17 +67,22 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void update3DInfo(); - void setReservoirView(RimView* ownerView); + void setReservoirView(RimGridView* ownerView); void setPosition(cvf::Vec2ui position); - HistogramData histogramData(); - QString timeStepText(); - QString caseInfoText(); - QString resultInfoText(const HistogramData& histData); + HistogramData histogramData(); + QString timeStepText(); + QString caseInfoText(); + QString resultInfoText(const HistogramData& histData); - void showStatisticsInfoDialog(bool raise = true); - QImage statisticsDialogScreenShotImage(); + void showStatisticsInfoDialog(bool raise = true); + QImage statisticsDialogScreenShotImage(); + + bool showAnimProgress() const; + bool showCaseInfo() const; + bool showResultInfo() const; + bool isActive() const; enum StatisticsTimeRangeType { @@ -101,6 +106,8 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject void updateEclipse3DInfo(RimEclipseView * reservoirView); void updateGeoMech3DInfo(RimGeoMechView * geoMechView); + void update3DInfoIn2dViews() const; + QString timeStepText(RimEclipseView* eclipseView); QString timeStepText(RimGeoMechView* geoMechView); HistogramData histogramData(RimEclipseView* eclipseView); @@ -110,17 +117,17 @@ class Rim3dOverlayInfoConfig : public caf::PdmObject QString resultInfoText(const HistogramData& histData, RimEclipseView* eclipseView, bool showVolumeWeightedMean); QString resultInfoText(const HistogramData& histData, RimGeoMechView* geoMechView); - caf::PdmField active; - caf::PdmField showAnimProgress; - caf::PdmField showCaseInfo; - caf::PdmField showResultInfo; - caf::PdmField showVolumeWeightedMean; - caf::PdmField showHistogram; + caf::PdmField m_active; + caf::PdmField m_showAnimProgress; + caf::PdmField m_showCaseInfo; + caf::PdmField m_showResultInfo; + caf::PdmField m_showVolumeWeightedMean; + caf::PdmField m_showHistogram; caf::PdmField > m_statisticsTimeRange; caf::PdmField > m_statisticsCellRange; - caf::PdmPointer m_viewDef; + caf::PdmPointer m_viewDef; cvf::Vec2ui m_position; diff --git a/ApplicationCode/ProjectDataModel/RimView.cpp b/ApplicationCode/ProjectDataModel/Rim3dView.cpp similarity index 62% rename from ApplicationCode/ProjectDataModel/RimView.cpp rename to ApplicationCode/ProjectDataModel/Rim3dView.cpp index 9ad8e8535c..9bd8c48bb0 100644 --- a/ApplicationCode/ProjectDataModel/RimView.cpp +++ b/ApplicationCode/ProjectDataModel/Rim3dView.cpp @@ -17,76 +17,69 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RimView.h" +#include "Rim3dView.h" #include "RiaApplication.h" #include "RiaPreferences.h" +#include "RiaViewRedrawScheduler.h" -#include "Rim3dOverlayInfoConfig.h" -#include "RimCellRangeFilterCollection.h" -#include "RimEclipseCase.h" -#include "RimEclipseView.h" -#include "RimGridCollection.h" -#include "RimIntersectionCollection.h" +#include "RimCase.h" +#include "RimGridView.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" #include "RimProject.h" -#include "RimPropertyFilterCollection.h" #include "RimViewController.h" #include "RimViewLinker.h" -#include "RimViewLinkerCollection.h" #include "RimWellPathCollection.h" +#include "RivWellPathsPartMgr.h" + #include "RiuMainWindow.h" #include "RiuViewer.h" #include "RiuTimeStepChangedHandler.h" #include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" -#include "cafPdmObjectFactory.h" #include "cvfCamera.h" -#include "cvfModel.h" #include "cvfModelBasicList.h" #include "cvfPart.h" -#include "cvfScene.h" +#include "cvfTransform.h" #include "cvfViewport.h" -#include - -#include -#include "cvfTransform.h" +#include +#include "cvfScene.h" namespace caf { template<> -void caf::AppEnum< RimView::MeshModeType >::setUp() +void caf::AppEnum< Rim3dView::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); + addItem(Rim3dView::FULL_MESH, "FULL_MESH", "All"); + addItem(Rim3dView::FAULTS_MESH, "FAULTS_MESH", "Faults only"); + addItem(Rim3dView::NO_MESH, "NO_MESH", "None"); + setDefault(Rim3dView::FULL_MESH); } template<> -void caf::AppEnum< RimView::SurfaceModeType >::setUp() +void caf::AppEnum< Rim3dView::SurfaceModeType >::setUp() { - addItem(RimView::SURFACE, "SURFACE", "All"); - addItem(RimView::FAULTS, "FAULTS", "Faults only"); - addItem(RimView::NO_SURFACE, "NO_SURFACE", "None"); - setDefault(RimView::SURFACE); + addItem(Rim3dView::SURFACE, "SURFACE", "All"); + addItem(Rim3dView::FAULTS, "FAULTS", "Faults only"); + addItem(Rim3dView::NO_SURFACE, "NO_SURFACE", "None"); + setDefault(Rim3dView::SURFACE); } } // End namespace caf -CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimView, "GenericView"); // Do not use. Abstract class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(Rim3dView, "GenericView"); // Do not use. Abstract class //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView::RimView(void) +Rim3dView::Rim3dView(void) { RiaApplication* app = RiaApplication::instance(); RiaPreferences* preferences = app->preferences(); @@ -95,11 +88,11 @@ RimView::RimView(void) CAF_PDM_InitField(&name, "UserDescription", QString(""), "Name", "", "", ""); - CAF_PDM_InitField(&cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); - cameraPosition.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_cameraPosition, "CameraPosition", cvf::Mat4d::IDENTITY, "", "", "", ""); + m_cameraPosition.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); - cameraPointOfInterest.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_cameraPointOfInterest, "CameraPointOfInterest", cvf::Vec3d::ZERO, "", "", "", ""); + m_cameraPointOfInterest.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&isPerspectiveView, "PerspectiveProjection", true, "Perspective Projection", "", "", ""); @@ -107,7 +100,7 @@ RimView::RimView(void) 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(&m_backgroundColor, "ViewBackgroundColor", defBackgColor, "Background", "", "", ""); CAF_PDM_InitField(&maximumFrameRate, "MaximumFrameRate", 10, "Maximum Frame Rate", "", "", ""); maximumFrameRate.uiCapability()->setUiHidden(true); @@ -117,40 +110,15 @@ RimView::RimView(void) CAF_PDM_InitField(&m_currentTimeStep, "CurrentTimeStep", 0, "Current Time Step", "", "", ""); m_currentTimeStep.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); - m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); - m_overlayInfoConfig->setReservoirView(this); - m_overlayInfoConfig.uiCapability()->setUiHidden(true); - - caf::AppEnum defaultMeshType = NO_MESH; + caf::AppEnum 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(&showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", ""); + CAF_PDM_InitField(&m_showGridBox, "ShowGridBox", true, "Show Grid Box", "", "", ""); CAF_PDM_InitField(&m_disableLighting, "DisableLighting", false, "Disable Results Lighting", "", "Disable light model for scalar result colors", ""); - - CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); - m_rangeFilterCollection.uiCapability()->setUiHidden(true); - m_rangeFilterCollection = new RimCellRangeFilterCollection(); - - CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); - m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); - m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); - m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); - - CAF_PDM_InitFieldNoDefault(&crossSectionCollection, "CrossSections", "Intersections", "", "", ""); - crossSectionCollection.uiCapability()->setUiHidden(true); - crossSectionCollection = new RimIntersectionCollection(); - - CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); - m_gridCollection.uiCapability()->setUiHidden(true); - m_gridCollection = new RimGridCollection(); - - m_previousGridModeMeshLinesWasFaults = false; - m_crossSectionVizModel = new cvf::ModelBasicList; m_crossSectionVizModel->setName("CrossSectionModel"); @@ -160,50 +128,25 @@ RimView::RimView(void) m_wellPathPipeVizModel = new cvf::ModelBasicList; m_wellPathPipeVizModel->setName("WellPathPipeModel"); + m_wellPathsPartManager = new RivWellPathsPartMgr(this); + this->setAs3DViewMdiWindow(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView::~RimView(void) +Rim3dView::~Rim3dView(void) { - RimProject* proj = RiaApplication::instance()->project(); - - if (proj && this->isMasterView()) - { - delete proj->viewLinkerCollection->viewLinker(); - proj->viewLinkerCollection->viewLinker = NULL; - - proj->uiCapability()->updateConnectedEditors(); - } - - RimViewController* vController = this->viewController(); - if (proj && vController) - { - vController->setManagedView(NULL); - vController->ownerViewLinker()->removeViewController(vController); - delete vController; - - proj->uiCapability()->updateConnectedEditors(); - } - - delete this->m_overlayInfoConfig(); - removeMdiWindowFromMdiArea(); deleteViewWidget(); - - delete m_rangeFilterCollection; - delete m_overrideRangeFilterCollection; - delete crossSectionCollection; - delete m_gridCollection; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuViewer* RimView::viewer() +RiuViewer* Rim3dView::viewer() { return m_viewer; } @@ -211,22 +154,28 @@ RiuViewer* RimView::viewer() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QWidget* RimView::createViewWidget(QWidget* mainWindowParent) +QWidget* Rim3dView::createViewWidget(QWidget* mainWindowParent) { QGLFormat glFormat; glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); - m_viewer = new RiuViewer(glFormat, NULL); + m_viewer = new RiuViewer(glFormat, nullptr); m_viewer->setOwnerReservoirView(this); + cvf::String xLabel; + cvf::String yLabel; + cvf::String zLabel; + + this->axisLabels(&xLabel, &yLabel, &zLabel); + m_viewer->setAxisLabels(xLabel, yLabel, zLabel); + return m_viewer->layoutWidget(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::updateViewWidgetAfterCreation() +void Rim3dView::updateViewWidgetAfterCreation() { m_viewer->setDefaultPerspectiveNearPlaneDistance(10); @@ -235,8 +184,8 @@ void RimView::updateViewWidgetAfterCreation() m_viewer->updateNavigationPolicy(); m_viewer->enablePerfInfoHud(RiaApplication::instance()->showPerformanceInfo()); - m_viewer->mainCamera()->setViewMatrix(cameraPosition); - m_viewer->setPointOfInterest(cameraPointOfInterest()); + m_viewer->mainCamera()->setViewMatrix(m_cameraPosition); + m_viewer->setPointOfInterest(m_cameraPointOfInterest()); m_viewer->enableParallelProjection(!isPerspectiveView()); m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); @@ -251,7 +200,7 @@ void RimView::updateViewWidgetAfterCreation() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::updateMdiWindowTitle() +void Rim3dView::updateMdiWindowTitle() { if (m_viewer) { @@ -269,11 +218,10 @@ void RimView::updateMdiWindowTitle() } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::deleteViewWidget() +void Rim3dView::deleteViewWidget() { if (m_viewer) { @@ -285,12 +233,12 @@ void RimView::deleteViewWidget() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +void Rim3dView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* viewGroup = uiOrdering.addNewGroup("Viewer"); viewGroup->add(&name); - viewGroup->add(&backgroundColor); - viewGroup->add(&showGridBox); + viewGroup->add(&m_backgroundColor); + viewGroup->add(&m_showGridBox); viewGroup->add(&isPerspectiveView); viewGroup->add(&m_disableLighting); @@ -298,19 +246,17 @@ void RimView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrder gridGroup->add(&scaleZ); gridGroup->add(&meshMode); gridGroup->add(&surfaceMode); - - } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QImage RimView::snapshotWindowContent() +QImage Rim3dView::snapshotWindowContent() { if (m_viewer) { // Force update of scheduled display models before snapshotting - RiaApplication::instance()->slotUpdateScheduledDisplayModels(); + RiaViewRedrawScheduler::instance()->updateAndRedrawScheduledViews(); m_viewer->repaint(); @@ -323,9 +269,9 @@ QImage RimView::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::scheduleCreateDisplayModelAndRedraw() +void Rim3dView::scheduleCreateDisplayModelAndRedraw() { - RiaApplication::instance()->scheduleDisplayModelUpdateAndRedraw(this); + RiaViewRedrawScheduler::instance()->scheduleDisplayModelUpdateAndRedraw(this); if (this->isMasterView()) { RimViewLinker* viewLinker = this->assosiatedViewLinker(); @@ -339,7 +285,7 @@ void RimView::scheduleCreateDisplayModelAndRedraw() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setCurrentTimeStepAndUpdate(int frameIndex) +void Rim3dView::setCurrentTimeStepAndUpdate(int frameIndex) { setCurrentTimeStep(frameIndex); @@ -353,7 +299,15 @@ void RimView::setCurrentTimeStepAndUpdate(int frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setCurrentTimeStep(int frameIndex) +QString Rim3dView::timeStepName(int frameIdx) const +{ + return this->ownerCase()->timeStepName(frameIdx); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::setCurrentTimeStep(int frameIndex) { const int oldTimeStep = m_currentTimeStep; @@ -363,19 +317,17 @@ void RimView::setCurrentTimeStep(int frameIndex) if (m_currentTimeStep != oldTimeStep) { RiuTimeStepChangedHandler::instance()->handleTimeStepChanged(this); + this->onTimeStepChanged(); } this->hasUserRequestedAnimation = true; - if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) - { - m_currentReservoirCellVisibility = NULL; - } + } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::updateCurrentTimeStepAndRedraw() +void Rim3dView::updateCurrentTimeStepAndRedraw() { this->updateCurrentTimeStep(); @@ -389,7 +341,7 @@ void RimView::updateCurrentTimeStepAndRedraw() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::createDisplayModelAndRedraw() +void Rim3dView::createDisplayModelAndRedraw() { if (m_viewer) { @@ -399,22 +351,41 @@ void RimView::createDisplayModelAndRedraw() createHighlightAndGridBoxDisplayModel(); updateDisplayModelVisibility(); - if (cameraPosition().isIdentity()) + if (m_cameraPosition().isIdentity()) { setDefaultView(); - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - cameraPointOfInterest = m_viewer->pointOfInterest(); + m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); + m_cameraPointOfInterest = m_viewer->pointOfInterest(); } } RiuMainWindow::instance()->refreshAnimationActions(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) +{ + std::vector modelsToBeRemoved; + for (cvf::uint i = 0; i < scene->modelCount(); i++) + { + if (scene->model(i)->name() == modelName) + { + modelsToBeRemoved.push_back(scene->model(i)); + } + } + + for (size_t i = 0; i < modelsToBeRemoved.size(); i++) + { + scene->removeModel(modelsToBeRemoved[i]); + } +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setDefaultView() +void Rim3dView::setDefaultView() { if (m_viewer) { @@ -422,21 +393,19 @@ void RimView::setDefaultView() } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::endAnimation() +void Rim3dView::endAnimation() { this->hasUserRequestedAnimation = false; this->updateStaticCellColors(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimWellPathCollection* RimView::wellPathCollection() const +RimWellPathCollection* Rim3dView::wellPathCollection() const { RimProject* proj = nullptr; this->firstAncestorOrThisOfTypeAsserted(proj); @@ -448,131 +417,56 @@ RimWellPathCollection* RimView::wellPathCollection() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setupBeforeSave() +void Rim3dView::setupBeforeSave() { if (m_viewer) { hasUserRequestedAnimation = m_viewer->isAnimationActive(); // JJS: This is not conceptually correct. The variable is updated as we go, and store the user intentions. But I guess that in practice... - cameraPosition = m_viewer->mainCamera()->viewMatrix(); - cameraPointOfInterest = m_viewer->pointOfInterest(); + m_cameraPosition = m_viewer->mainCamera()->viewMatrix(); + m_cameraPointOfInterest = m_viewer->pointOfInterest(); } } -//-------------------------------------------------------------------------------------------------- -/// -// 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() +void Rim3dView::setMeshOnlyDrawstyle() { - if (isGridVisualizationMode()) - { - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - + meshMode.setValueWithFieldChanged(FULL_MESH); surfaceMode.setValueWithFieldChanged(NO_SURFACE); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setMeshSurfDrawstyle() +void Rim3dView::setMeshSurfDrawstyle() { - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - meshMode.setValueWithFieldChanged(FULL_MESH); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - meshMode.setValueWithFieldChanged(FAULTS_MESH); - } + surfaceMode.setValueWithFieldChanged(SURFACE); + meshMode.setValueWithFieldChanged(FULL_MESH); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setFaultMeshSurfDrawstyle() +void Rim3dView::setFaultMeshSurfDrawstyle() { - // Surf: No Fault Surf - // Mesh ------------- - // No FF FF SF - // Fault FF FF SF - // Mesh SF SF SF - if (this->isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - + surfaceMode.setValueWithFieldChanged(SURFACE); meshMode.setValueWithFieldChanged(FAULTS_MESH); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setSurfOnlyDrawstyle() +void Rim3dView::setSurfOnlyDrawstyle() { - if (isGridVisualizationMode()) - { - surfaceMode.setValueWithFieldChanged(SURFACE); - } - else - { - surfaceMode.setValueWithFieldChanged(FAULTS); - } - + surfaceMode.setValueWithFieldChanged(SURFACE); meshMode.setValueWithFieldChanged(NO_MESH); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::showGridCells(bool enableGridCells) -{ - if (!enableGridCells) - { - m_previousGridModeMeshLinesWasFaults = meshMode() == FAULTS_MESH; - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(FAULTS); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(FAULTS_MESH); - } - else - { - if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); - if (meshMode() != NO_MESH) meshMode.setValueWithFieldChanged(m_previousGridModeMeshLinesWasFaults ? FAULTS_MESH : FULL_MESH); - } - - m_gridCollection->isActive = enableGridCells; - m_gridCollection->updateConnectedEditors(); - m_gridCollection->updateUiIconFromState(enableGridCells); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setSurfaceDrawstyle() +void Rim3dView::setSurfaceDrawstyle() { if (surfaceMode() != NO_SURFACE) surfaceMode.setValueWithFieldChanged(SURFACE); } @@ -580,7 +474,7 @@ void RimView::setSurfaceDrawstyle() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::disableLighting(bool disable) +void Rim3dView::disableLighting(bool disable) { m_disableLighting = disable; updateCurrentTimeStepAndRedraw(); @@ -590,7 +484,7 @@ void RimView::disableLighting(bool disable) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimView::isLightingDisabled() const +bool Rim3dView::isLightingDisabled() const { return m_disableLighting(); } @@ -598,7 +492,7 @@ bool RimView::isLightingDisabled() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +void Rim3dView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { RimViewWindow::fieldChangedByUi(changedField, oldValue, newValue); @@ -618,12 +512,6 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV if (scaleZ < 1) scaleZ = 1; this->updateGridBoxData(); - - // Regenerate well paths - RimOilField* oilFields = RiaApplication::instance()->project() ? RiaApplication::instance()->project()->activeOilField() : NULL; - RimWellPathCollection* wellPathCollection = (oilFields) ? oilFields->wellPathCollection() : NULL; - - crossSectionCollection->updateIntersectionBoxGeometry(); if (m_viewer) { @@ -644,12 +532,7 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV m_viewer->update(); - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateScaleZ(this, scaleZ); - viewLinker->updateCamera(this); - } + } RiuMainWindow::instance()->updateScaleValue(); @@ -661,7 +544,7 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV RiuMainWindow::instance()->refreshDrawStyleActions(); RiuMainWindow::instance()->refreshAnimationActions(); } - else if (changedField == &showGridBox) + else if (changedField == &m_showGridBox) { createHighlightAndGridBoxDisplayModelWithRedraw(); } @@ -695,21 +578,12 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV { m_viewer->update(); - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateTimeStep(this, m_currentTimeStep); - } + } } - else if (changedField == &backgroundColor) + else if (changedField == &m_backgroundColor) { - if (m_viewer != nullptr) - { - m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); - } - updateGridBoxData(); - updateAnnotationItems(); + this->applyBackgroundColor(); } else if (changedField == &maximumFrameRate) { @@ -717,7 +591,7 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV // !! Should be able to specify legal range for number properties if (m_viewer) { - m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : INT_MAX); + m_viewer->animationControl()->setTimeout(maximumFrameRate != 0 ? 1000/maximumFrameRate : std::numeric_limits::max()); } } } @@ -725,17 +599,17 @@ void RimView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QV //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, +void Rim3dView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) { if (!this->ownerCase()) return; cvf::ref transForm = displayCoordTransform(); - wellPathCollection()->appendStaticGeometryPartsToModel(wellPathModelBasicList, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); + m_wellPathsPartManager->appendStaticGeometryPartsToModel(wellPathModelBasicList, + transForm.p(), + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox); wellPathModelBasicList->updateBoundingBoxesRecursive(); } @@ -743,24 +617,18 @@ void RimView::addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) +void Rim3dView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox) { if (!this->ownerCase()) return; cvf::ref transForm = displayCoordTransform(); - QDateTime currentTimeStamp; - std::vector timeStamps = ownerCase()->timeStepDates(); - if (currentTimeStep() < static_cast(timeStamps.size())) - { - currentTimeStamp = timeStamps[currentTimeStep()]; - } - - wellPathCollection()->appendDynamicGeometryPartsToModel(wellPathModelBasicList, - currentTimeStamp, - this->ownerCase()->characteristicCellSize(), - wellPathClipBoundingBox, - transForm.p()); + size_t timeStepIndex = currentTimeStep(); + m_wellPathsPartManager->appendDynamicGeometryPartsToModel(wellPathModelBasicList, + timeStepIndex, + transForm.p(), + this->ownerCase()->characteristicCellSize(), + wellPathClipBoundingBox); wellPathModelBasicList->updateBoundingBoxesRecursive(); } @@ -768,326 +636,279 @@ void RimView::addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasic //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCellRangeFilterCollection* RimView::rangeFilterCollection() +void Rim3dView::setScaleZAndUpdate(double scaleZ) { - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else - { - return m_rangeFilterCollection; - } + this->scaleZ = scaleZ; + updateScaleTransform(); + + this->updateGridBoxData(); + + this->scheduleCreateDisplayModelAndRedraw(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimCellRangeFilterCollection* RimView::rangeFilterCollection() const +bool Rim3dView::isMasterView() const { - if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) - { - return m_overrideRangeFilterCollection; - } - else + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if (viewLinker && this == viewLinker->masterView()) { - return m_rangeFilterCollection; + return true; } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) -{ - if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); - - m_overrideRangeFilterCollection = rfc; - this->scheduleGeometryRegen(RANGE_FILTERED); - this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); - this->scheduleCreateDisplayModelAndRedraw(); + return false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::setScaleZAndUpdate(double scaleZ) +void Rim3dView::updateGridBoxData() { - this->scaleZ = scaleZ; - updateScaleTransform(); - - this->updateGridBoxData(); - - this->scheduleCreateDisplayModelAndRedraw(); + if (m_viewer && ownerCase()) + { + m_viewer->updateGridBoxData(scaleZ(), + ownerCase()->displayModelOffset(), + backgroundColor(), + showActiveCellsOnly() ? ownerCase()->activeCellsBoundingBox() + : ownerCase()->allCellsBoundingBox() + ); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimViewController* RimView::viewController() const +void Rim3dView::updateAnnotationItems() { - RimViewController* viewController = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); - for (size_t i = 0; i < reffingObjs.size(); ++i) + if (m_viewer) { - viewController = dynamic_cast(reffingObjs[i]); - if (viewController) break; + m_viewer->updateAnnotationItems(); } - - return viewController; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimViewLinker* RimView::viewLinkerIfMasterView() const +void Rim3dView::createHighlightAndGridBoxDisplayModelWithRedraw() { - RimViewLinker* viewLinker = NULL; - std::vector reffingObjs; - - this->objectsWithReferringPtrFields(reffingObjs); + createHighlightAndGridBoxDisplayModel(); - for (size_t i = 0; i < reffingObjs.size(); ++i) + if (m_viewer) { - viewLinker = dynamic_cast(reffingObjs[i]); - if (viewLinker) break; + m_viewer->update(); } - - return viewLinker; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimViewLinker* RimView::assosiatedViewLinker() const +void Rim3dView::createHighlightAndGridBoxDisplayModel() { - RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); - if (!viewLinker) + m_viewer->removeStaticModel(m_highlightVizModel.p()); + + m_highlightVizModel->removeAllParts(); + + cvf::Collection parts; + createPartCollectionFromSelection(&parts); + if (parts.size() > 0) { - RimViewController* viewController = this->viewController(); - if (viewController) + for (size_t i = 0; i < parts.size(); i++) { - viewLinker = viewController->ownerViewLinker(); + m_highlightVizModel->addPart(parts[i].p()); } + + m_highlightVizModel->updateBoundingBoxesRecursive(); + m_viewer->addStaticModelOnce(m_highlightVizModel.p()); } - return viewLinker; + m_viewer->showGridBox(m_showGridBox()); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimView::currentTotalCellVisibility() +void Rim3dView::applyBackgroundColor() { - if (m_currentReservoirCellVisibility.isNull()) + if (m_viewer != nullptr) { - m_currentReservoirCellVisibility = new cvf::UByteArray; - this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); + m_viewer->mainCamera()->viewport()->setClearColor(cvf::Color4f(backgroundColor())); } - - return m_currentReservoirCellVisibility; + updateGridBoxData(); + updateAnnotationItems(); + updateLegends(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimView::isMasterView() const +void Rim3dView::updateDisplayModelVisibility() { - RimViewLinker* viewLinker = this->assosiatedViewLinker(); - if (viewLinker && this == viewLinker->masterView()) + 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; + const cvf::uint uintIntersectionCellFaceBit = intersectionCellFaceBit; + const cvf::uint uintIntersectionCellMeshBit = intersectionCellMeshBit; + const cvf::uint uintIntersectionFaultMeshBit = intersectionFaultMeshBit; + + // Initialize the mask to show everything except the the bits controlled here + unsigned int mask = + 0xffffffff + & ~uintSurfaceBit + & ~uintFaultBit + & ~uintMeshSurfaceBit + & ~uintMeshFaultBit + & ~intersectionCellFaceBit + & ~intersectionCellMeshBit + & ~intersectionFaultMeshBit; + + // Then turn the appropriate bits on according to the user settings + + if (surfaceMode == SURFACE) { - return true; + mask |= uintSurfaceBit; + mask |= uintFaultBit; + mask |= intersectionCellFaceBit; + } + else if (surfaceMode == FAULTS) + { + mask |= uintFaultBit; + mask |= intersectionCellFaceBit; } - return false; + if (meshMode == FULL_MESH) + { + mask |= uintMeshSurfaceBit; + mask |= uintMeshFaultBit; + mask |= intersectionCellMeshBit; + mask |= intersectionFaultMeshBit; + } + else if (meshMode == FAULTS_MESH) + { + mask |= uintMeshFaultBit; + mask |= intersectionFaultMeshBit; + } + + m_viewer->setEnableMask(mask); + m_viewer->update(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimView::hasOverridenRangeFilterCollection() +bool Rim3dView::showActiveCellsOnly() { - return m_overrideRangeFilterCollection() != NULL; + return false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::replaceRangeFilterCollectionWithOverride() +void Rim3dView::zoomAll() { - RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; - CVF_ASSERT(overrideRfc); - - RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; - if (currentRfc) + if (m_viewer) { - delete currentRfc; + m_viewer->zoomAll(); } - - // Must call removeChildObject() to make sure the object has no parent - // No parent is required when assigning a object into a field - m_overrideRangeFilterCollection.removeChildObject(overrideRfc); - - m_rangeFilterCollection = overrideRfc; - - this->uiCapability()->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::removeModelByName(cvf::Scene* scene, const cvf::String& modelName) +cvf::ref Rim3dView::displayCoordTransform() const { - std::vector modelsToBeRemoved; - for (cvf::uint i = 0; i < scene->modelCount(); i++) - { - if (scene->model(i)->name() == modelName) - { - modelsToBeRemoved.push_back(scene->model(i)); - } - } + cvf::ref coordTrans = new caf::DisplayCoordTransform; - for (size_t i = 0; i < modelsToBeRemoved.size(); i++) + cvf::Vec3d scale(1.0, 1.0, scaleZ); + coordTrans->setScale(scale); + + RimCase* rimCase = ownerCase(); + if (rimCase) { - scene->removeModel(modelsToBeRemoved[i]); + coordTrans->setTranslation(rimCase->displayModelOffset()); } + + return coordTrans; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::updateGridBoxData() +cvf::Mat4d Rim3dView::cameraPosition() const { - if (m_viewer) - { - m_viewer->updateGridBoxData(); - } + return m_cameraPosition(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::updateAnnotationItems() +cvf::Vec3d Rim3dView::cameraPointOfInterest() const { - if (m_viewer) - { - m_viewer->updateAnnotationItems(); - } + return m_cameraPointOfInterest(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -Rim3dOverlayInfoConfig* RimView::overlayInfoConfig() const +QWidget* Rim3dView::viewWidget() { - return m_overlayInfoConfig; + if ( m_viewer ) return m_viewer->layoutWidget(); + else return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::createHighlightAndGridBoxDisplayModelWithRedraw() +void Rim3dView::forceShowWindowOn() { - createHighlightAndGridBoxDisplayModel(); - - if (m_viewer) - { - m_viewer->update(); - } + m_showWindow.setValueWithFieldChanged(true); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::createHighlightAndGridBoxDisplayModel() +void Rim3dView::disableGridBoxField() { - m_viewer->removeStaticModel(m_highlightVizModel.p()); - m_viewer->removeStaticModel(m_viewer->gridBoxModel()); - - m_highlightVizModel->removeAllParts(); - - cvf::Collection parts; - createPartCollectionFromSelection(&parts); - if (parts.size() > 0) - { - for (size_t i = 0; i < parts.size(); i++) - { - m_highlightVizModel->addPart(parts[i].p()); - } - - m_highlightVizModel->updateBoundingBoxesRecursive(); - m_viewer->addStaticModelOnce(m_highlightVizModel.p()); - } - - if (showGridBox) - { - m_viewer->addStaticModelOnce(m_viewer->gridBoxModel()); - } + m_showGridBox = false; + m_showGridBox.uiCapability()->setUiHidden(true); + m_showGridBox.xmlCapability()->setIOWritable(false); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimView::showActiveCellsOnly() +void Rim3dView::disablePerspectiveProjectionField() { - return false; + isPerspectiveView = false; + isPerspectiveView.uiCapability()->setUiHidden(true); + isPerspectiveView.xmlCapability()->setIOWritable(false); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::selectOverlayInfoConfig() +void Rim3dView::handleMdiWindowClosed() { - RiuMainWindow::instance()->selectAsCurrentItem(m_overlayInfoConfig); + RimViewWindow::handleMdiWindowClosed(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::zoomAll() +void Rim3dView::setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) { - if (m_viewer) - { - m_viewer->zoomAll(); - } + RimViewWindow::setMdiWindowGeometry(windowGeometry); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::ref RimView::displayCoordTransform() const -{ - cvf::ref coordTrans = new caf::DisplayCoordTransform; - - cvf::Vec3d scale(1.0, 1.0, scaleZ); - coordTrans->setScale(scale); - - RimCase* rimCase = ownerCase(); - if (rimCase) - { - coordTrans->setTranslation(rimCase->displayModelOffset()); - } - - return coordTrans; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QWidget* RimView::viewWidget() -{ - if ( m_viewer ) return m_viewer->layoutWidget(); - else return nullptr; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimView::forceShowWindowOn() -{ - m_showWindow.setValueWithFieldChanged(true); -} - diff --git a/ApplicationCode/ProjectDataModel/RimView.h b/ApplicationCode/ProjectDataModel/Rim3dView.h similarity index 67% rename from ApplicationCode/ProjectDataModel/RimView.h rename to ApplicationCode/ProjectDataModel/Rim3dView.h index 7164fcb062..d4d365f5da 100644 --- a/ApplicationCode/ProjectDataModel/RimView.h +++ b/ApplicationCode/ProjectDataModel/Rim3dView.h @@ -16,41 +16,32 @@ // for more details. // ///////////////////////////////////////////////////////////////////////////////// - #pragma once +#include "RiuViewerToViewInterface.h" +#include "RimViewWindow.h" + +#include "RivCellSetEnum.h" + #include "cafAppEnum.h" -#include "cafPdmChildArrayField.h" -#include "cafPdmChildField.h" #include "cafPdmField.h" +#include "cafPdmObject.h" + #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" #include "cafPdmFieldCvfVec3d.h" -#include "cafPdmObject.h" - -#include "RivCellSetEnum.h" - -#include "RimViewWindow.h" -#include "cvfArray.h" #include "cvfBase.h" #include "cvfCollection.h" #include "cvfObject.h" #include - -class Rim3dOverlayInfoConfig; class RimCase; -class RimCellRangeFilter; -class RimCellRangeFilterCollection; -class RimIntersectionCollection; -class RimGridCollection; -class RimPropertyFilterCollection; -class RimViewController; -class RimViewLinker; -class RiuViewer; +class RimLegendConfig; class RimWellPathCollection; +class RiuViewer; +class RivWellPathsPartMgr; namespace cvf { @@ -66,61 +57,48 @@ namespace caf { class DisplayCoordTransform; } + + +enum PartRenderMaskEnum +{ + surfaceBit = 1, + meshSurfaceBit = 2, + faultBit = 4, + meshFaultBit = 8, + intersectionCellFaceBit = 16, + intersectionCellMeshBit = 32, + intersectionFaultMeshBit = 64 +}; + + //================================================================================================== /// /// //================================================================================================== -class RimView : public RimViewWindow +class Rim3dView : public RimViewWindow, public RiuViewerToViewInterface { CAF_PDM_HEADER_INIT; public: - RimView(void); - virtual ~RimView(void); + Rim3dView(void); + virtual ~Rim3dView(void); - // 3D Viewer - RiuViewer* viewer(); + // Public fields: caf::PdmField name; caf::PdmField scaleZ; - - caf::PdmField cameraPosition; - caf::PdmField cameraPointOfInterest; caf::PdmField isPerspectiveView; - caf::PdmField< cvf::Color3f > backgroundColor; - caf::PdmField maximumFrameRate; caf::PdmField hasUserRequestedAnimation; - virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; - RimCellRangeFilterCollection* rangeFilterCollection(); - const RimCellRangeFilterCollection* rangeFilterCollection() const; - - bool hasOverridenRangeFilterCollection(); - void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); - void replaceRangeFilterCollectionWithOverride(); - - - caf::PdmChildField crossSectionCollection; - // Draw style - enum MeshModeType - { - FULL_MESH, - FAULTS_MESH, - NO_MESH - }; + enum MeshModeType { FULL_MESH, FAULTS_MESH, NO_MESH }; + enum SurfaceModeType { SURFACE, FAULTS, NO_SURFACE }; - enum SurfaceModeType - { - SURFACE, - FAULTS, - NO_SURFACE - }; + caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; + caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - caf::PdmField< caf::AppEnum< MeshModeType > > meshMode; - caf::PdmField< caf::AppEnum< SurfaceModeType > > surfaceMode; - caf::PdmField showGridBox; + RiuViewer* viewer(); void setMeshOnlyDrawstyle(); void setMeshSurfDrawstyle(); @@ -130,124 +108,126 @@ class RimView : public RimViewWindow void disableLighting(bool disable); bool isLightingDisabled() const; - - void showGridCells(bool enableGridCells); - bool isGridVisualizationMode() const; + + virtual bool isGridVisualizationMode() const = 0; void setScaleZAndUpdate(double scaleZ); + virtual bool showActiveCellsOnly(); + virtual bool isUsingFormationNames() const = 0; + + virtual QImage snapshotWindowContent() override; + virtual void zoomAll() override; + void forceShowWindowOn(); // Animation int currentTimeStep() const { return m_currentTimeStep;} void setCurrentTimeStep(int frameIdx); - void setCurrentTimeStepAndUpdate(int frameIdx); - - void updateCurrentTimeStepAndRedraw(); + void setCurrentTimeStepAndUpdate(int frameIdx) override; + virtual bool isTimeStepDependentDataVisible() const = 0; + // Updating + void updateCurrentTimeStepAndRedraw() override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) = 0; void scheduleCreateDisplayModelAndRedraw(); void createDisplayModelAndRedraw(); void createHighlightAndGridBoxDisplayModelWithRedraw(); + void updateGridBoxData(); + void updateAnnotationItems(); - RimViewController* viewController() const; bool isMasterView() const; - RimViewLinker* assosiatedViewLinker() const; - - virtual bool isUsingFormationNames() const = 0; - cvf::ref currentTotalCellVisibility(); - virtual bool showActiveCellsOnly(); - virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; - - void selectOverlayInfoConfig(); - - virtual QImage snapshotWindowContent() override; - - virtual void zoomAll() override; + cvf::ref displayCoordTransform() const override; - cvf::ref displayCoordTransform() const; - - virtual QWidget* viewWidget() override; - void forceShowWindowOn(); - -public: - void updateGridBoxData(); - void updateAnnotationItems(); virtual RimCase* ownerCase() const = 0; - - virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } - - Rim3dOverlayInfoConfig* overlayInfoConfig() const; + virtual std::vector legendConfigs() const = 0; protected: + static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); + + virtual void setDefaultView(); + void disableGridBoxField(); + void disablePerspectiveProjectionField(); + cvf::Mat4d cameraPosition() const; + cvf::Vec3d cameraPointOfInterest() const; - void setDefaultView(); + RimWellPathCollection* wellPathCollection() const; void addWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox); void addDynamicWellPathsToModel(cvf::ModelBasicList* wellPathModelBasicList, const cvf::BoundingBox& wellPathClipBoundingBox); - static void removeModelByName(cvf::Scene* scene, const cvf::String& modelName); - - virtual void createDisplayModel() = 0; - void createHighlightAndGridBoxDisplayModel(); + // Implementation of RiuViewerToViewInterface + virtual cvf::Color3f backgroundColor() const override { return m_backgroundColor(); } + void applyBackgroundColor(); + + // Abstract methods to implement in subclasses + + virtual void axisLabels(cvf::String* xLabel, cvf::String* yLabel, cvf::String* zLabel) = 0; + + virtual void createDisplayModel() = 0; virtual void createPartCollectionFromSelection(cvf::Collection* parts) = 0; - virtual void updateDisplayModelVisibility() = 0; + virtual void updateDisplayModelVisibility(); virtual void clampCurrentTimestep() = 0; virtual void updateCurrentTimeStep() = 0; + virtual void onTimeStepChanged() = 0; virtual void updateStaticCellColors() = 0; virtual void updateScaleTransform() = 0; virtual cvf::Transform* scaleTransform() = 0; virtual void resetLegendsInViewer() = 0; - virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; - virtual void onLoadDataAndUpdate() = 0; - - RimWellPathCollection* wellPathCollection() const; +protected: // Fields + caf::PdmField m_currentTimeStep; +protected: QPointer m_viewer; - caf::PdmField m_currentTimeStep; - caf::PdmChildField m_overlayInfoConfig; + cvf::ref m_wellPathPipeVizModel; + cvf::ref m_crossSectionVizModel; + cvf::ref m_highlightVizModel; - caf::PdmChildField m_rangeFilterCollection; - caf::PdmChildField m_overrideRangeFilterCollection; - - caf::PdmChildField m_gridCollection; - - // Overridden PDM methods: + cvf::ref m_wellPathsPartManager; + +private: + // Overridden PdmObject methods: + + virtual caf::PdmFieldHandle* userDescriptionField() override { return &name; } virtual void setupBeforeSave() override; +protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; +private: + // Overridden ViewWindow methods: + virtual QWidget* createViewWidget(QWidget* mainWindowParent) override; virtual void updateViewWidgetAfterCreation() override; virtual void updateMdiWindowTitle() override; virtual void deleteViewWidget() override; + virtual QWidget* viewWidget() override; - cvf::ref m_currentReservoirCellVisibility; - - cvf::ref m_wellPathPipeVizModel; - cvf::ref m_crossSectionVizModel; - cvf::ref m_highlightVizModel; + // Implementation of RiuViewerToViewInterface -private: - RimViewLinker* viewLinkerIfMasterView() const; - - friend class RiuViewer; - void endAnimation(); + virtual void setCameraPosition(const cvf::Mat4d& cameraPosition) override { m_cameraPosition = cameraPosition; } + virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) override { m_cameraPointOfInterest = cameraPointOfInterest;} + virtual QString timeStepName(int frameIdx) const override; + virtual void endAnimation() override; + virtual caf::PdmObjectHandle* implementingPdmObject() override { return this; } + virtual void handleMdiWindowClosed() override; + virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) override; private: - bool m_previousGridModeMeshLinesWasFaults; caf::PdmField m_disableLighting; -}; - - + caf::PdmField m_cameraPosition; + caf::PdmField m_cameraPointOfInterest; + caf::PdmField< cvf::Color3f > m_backgroundColor; + caf::PdmField m_showGridBox; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp new file mode 100644 index 0000000000..dfceae1f9d --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.cpp @@ -0,0 +1,286 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogCurve.h" + +#include "RigCurveDataTools.h" +#include "Riv3dWellLogCurveGeometryGenerator.h" + +#include "Rim3dWellLogCurveCollection.h" +#include "RimProject.h" + +#include "cafPdmUiDoubleSliderEditor.h" + +#include "cvfVector3.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_ABSTRACT_SOURCE_INIT(Rim3dWellLogCurve, "Rim3dWellLogCurve"); + +namespace caf +{ + template<> + void AppEnum< Rim3dWellLogCurve::DrawPlane >::setUp() + { + addItem(Rim3dWellLogCurve::VERTICAL_ABOVE, "VERTICAL_ABOVE", "Above"); + addItem(Rim3dWellLogCurve::VERTICAL_CENTER, "VERTICAL_CENTER", "Centered - Vertical"); + addItem(Rim3dWellLogCurve::VERTICAL_BELOW, "VERTICAL_BELOW", "Below"); + addItem(Rim3dWellLogCurve::HORIZONTAL_LEFT, "HORIZONTAL_LEFT", "Left"); + addItem(Rim3dWellLogCurve::HORIZONTAL_CENTER, "HORIZONTAL_CENTER", "Centered - Horizontal"); + addItem(Rim3dWellLogCurve::HORIZONTAL_RIGHT, "HORIZONTAL_RIGHT", "Right"); + setDefault(Rim3dWellLogCurve::VERTICAL_ABOVE); + } + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::Rim3dWellLogCurve() + : m_minCurveDataValue(-std::numeric_limits::infinity()) + , m_maxCurveDataValue(std::numeric_limits::infinity()) +{ + CAF_PDM_InitObject("3d Well Log Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitField(&m_showCurve, "Show3dWellLogCurve", true, "Show 3d Well Log Curve", "", "", ""); + m_showCurve.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_minCurveUIValue, "MinCurveValue", -std::numeric_limits::infinity(), "Minimum Curve Value", "", "Clip curve values below this.", ""); + CAF_PDM_InitField(&m_maxCurveUIValue, "MaxCurveValue", std::numeric_limits::infinity(), "Maximum Curve Value", "", "Clip curve values above this.", ""); + + CAF_PDM_InitField(&m_drawPlane, "DrawPlane", DrawPlaneEnum(VERTICAL_ABOVE), "Draw Plane", "", "", ""); + CAF_PDM_InitField(&m_color, "CurveColor", cvf::Color3f(0.0f, 0.0f, 0.0f), "Curve Color", "", "", ""); + this->uiCapability()->setUiTreeChildrenHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::~Rim3dWellLogCurve() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::updateCurveIn3dView() +{ + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + proj->createDisplayModelAndRedrawAllViews(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurve::DrawPlane Rim3dWellLogCurve::drawPlane() const +{ + return m_drawPlane(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double Rim3dWellLogCurve::drawPlaneAngle() const +{ + switch (drawPlane()) + { + case HORIZONTAL_LEFT: + case HORIZONTAL_CENTER: + return cvf::PI_D / 2.0; + case HORIZONTAL_RIGHT: + return -cvf::PI_D / 2.0; + case VERTICAL_ABOVE: + case VERTICAL_CENTER: + return 0.0; + case VERTICAL_BELOW: + return cvf::PI_D; + default: + return 0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3f Rim3dWellLogCurve::color() const +{ + return m_color; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurve::isShowingCurve() const +{ + return m_showCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::setColor(const cvf::Color3f& color) +{ + m_color = color; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float Rim3dWellLogCurve::minCurveUIValue() const +{ + return m_minCurveUIValue(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float Rim3dWellLogCurve::maxCurveUIValue() const +{ + return m_maxCurveUIValue(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogCurve::objectToggleField() +{ + return &m_showCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimProject* proj; + this->firstAncestorOrThisOfTypeAsserted(proj); + if (changedField == &m_showCurve) + { + proj->reloadCompletionTypeResultsInAllViews(); + } + else + { + proj->createDisplayModelAndRedrawAllViews(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::configurationUiOrdering(caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* configurationGroup = uiOrdering.addNewGroup("Curve Appearance"); + configurationGroup->add(&m_drawPlane); + configurationGroup->add(&m_color); + configurationGroup->add(&m_minCurveUIValue); + configurationGroup->add(&m_maxCurveUIValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (m_minCurveDataValue == -std::numeric_limits::infinity() && + m_maxCurveDataValue == std::numeric_limits::infinity()) + { + this->resetMinMaxValues(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::initAfterRead() +{ + this->createCurveAutoName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::resetMinMaxValuesAndUpdateUI() +{ + this->resetMinMaxValues(); + this->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool Rim3dWellLogCurve::findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint) const +{ + if (m_geometryGenerator.notNull()) + { + return m_geometryGenerator->findClosestPointOnCurve(globalIntersection, closestPoint, measuredDepthAtPoint, valueAtPoint); + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator) +{ + m_geometryGenerator = generator; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref Rim3dWellLogCurve::geometryGenerator() +{ + return m_geometryGenerator; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogCurve::resetMinMaxValues() +{ + std::vector values; + std::vector measuredDepths; + this->curveValuesAndMds(&values, &measuredDepths); + double foundMinValue = std::numeric_limits::infinity(); + double foundMaxValue = -std::numeric_limits::infinity(); + for (double value : values) + { + if (RigCurveDataTools::isValidValue(value, false)) + { + foundMinValue = std::min(foundMinValue, value); + foundMaxValue = std::max(foundMaxValue, value); + } + } + + m_minCurveDataValue = foundMinValue; + m_maxCurveDataValue = foundMaxValue; + + m_minCurveUIValue = m_minCurveDataValue; + m_maxCurveUIValue = m_maxCurveDataValue; + + m_minCurveUIValue.uiCapability()->setUiName(QString("Minimum Curve Value (%1)").arg(m_minCurveDataValue)); + m_maxCurveUIValue.uiCapability()->setUiName(QString("Maximum Curve Value (%1)").arg(m_maxCurveDataValue)); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h new file mode 100644 index 0000000000..fce0067f9e --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogCurve.h @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafAppEnum.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "cafPdmFieldCvfColor.h" +#include "cafPdmChildField.h" +#include "cvfObject.h" +#include "cvfVector3.h" + +#include "RimWellLogCurveNameConfig.h" + +class Riv3dWellLogCurveGeometryGenerator; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogCurve : public caf::PdmObject, public RimCurveNameConfigHolderInterface +{ + CAF_PDM_HEADER_INIT; + +public: + enum DrawPlane + { + VERTICAL_ABOVE, + VERTICAL_CENTER, + VERTICAL_BELOW, + HORIZONTAL_LEFT, + HORIZONTAL_CENTER, + HORIZONTAL_RIGHT + }; + typedef caf::AppEnum DrawPlaneEnum; + +public: + Rim3dWellLogCurve(); + virtual ~Rim3dWellLogCurve(); + + void updateCurveIn3dView(); + + virtual QString name() const = 0; + virtual QString resultPropertyString() const = 0; + + DrawPlane drawPlane() const; + double drawPlaneAngle() const; + + cvf::Color3f color() const; + bool isShowingCurve() const; + + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const = 0; + + void setColor(const cvf::Color3f& color); + + float minCurveUIValue() const; + float maxCurveUIValue() const; + void resetMinMaxValuesAndUpdateUI(); + bool findClosestPointOnCurve(const cvf::Vec3d& globalIntersection, + cvf::Vec3d* closestPoint, + double* measuredDepthAtPoint, + double* valueAtPoint) const; + + void setGeometryGenerator(Riv3dWellLogCurveGeometryGenerator* generator); + cvf::ref geometryGenerator(); + +protected: + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + void configurationUiOrdering(caf::PdmUiOrdering& uiOrdering); + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + virtual void initAfterRead(); +private: + void resetMinMaxValues(); +protected: + caf::PdmField m_drawPlane; + caf::PdmField m_color; + caf::PdmField m_minCurveUIValue; + caf::PdmField m_maxCurveUIValue; + float m_minCurveDataValue; + float m_maxCurveDataValue; + cvf::ref m_geometryGenerator; +private: + caf::PdmField m_showCurve; + +}; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp new file mode 100644 index 0000000000..afde7d1128 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.cpp @@ -0,0 +1,406 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogExtractionCurve.h" + +#include "RigWellLogFile.h" + +#include "RiaExtractionTools.h" +#include "RigEclipseCaseData.h" +#include "RigGeoMechCaseData.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigGeoMechWellLogExtractor.h" +#include "RigResultAccessorFactory.h" +#include "RigCaseCellResultsData.h" +#include "RigFemPartResultsCollection.h" +#include "RimEclipseCase.h" +#include "RimGeoMechCase.h" +#include "Rim3dView.h" +#include "RimWellLogCurveNameConfig.h" +#include "RimCase.h" +#include "RimEclipseCase.h" +#include "RimEclipseCellColors.h" +#include "RimEclipseResultDefinition.h" +#include "RimEclipseView.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" +#include "RimTools.h" +#include "RimWellLogFile.h" +#include "RimWellLogFileChannel.h" +#include "RimWellPath.h" + +#include "cafUtils.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogExtractionCurve, "Rim3dWellLogExtractionCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogExtractionCurve::Rim3dWellLogExtractionCurve() +{ + CAF_PDM_InitObject("3d Well Log Extraction Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_case, "CurveCase", "Case", "", "", ""); + m_case.uiCapability()->setUiTreeChildrenHidden(true); + m_case = nullptr; + + CAF_PDM_InitField(&m_timeStep, "CurveTimeStep", 0, "Time Step", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_eclipseResultDefinition, "CurveEclipseResult", "", "", "", ""); + m_eclipseResultDefinition.uiCapability()->setUiHidden(true); + m_eclipseResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); + m_eclipseResultDefinition = new RimEclipseResultDefinition; + m_eclipseResultDefinition->findField("MResultType")->uiCapability()->setUiName("Result Type"); + + CAF_PDM_InitFieldNoDefault(&m_geomResultDefinition, "CurveGeomechResult", "", "", "", ""); + m_geomResultDefinition.uiCapability()->setUiHidden(true); + m_geomResultDefinition.uiCapability()->setUiTreeChildrenHidden(true); + m_geomResultDefinition = new RimGeoMechResultDefinition; + + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); + m_nameConfig = new RimWellLogExtractionCurveNameConfig(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogExtractionCurve::~Rim3dWellLogExtractionCurve() +{ + delete m_geomResultDefinition; + delete m_eclipseResultDefinition; + delete m_nameConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) +{ + if (!view) return; + + m_case = view->ownerCase(); + + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + m_eclipseResultDefinition->setEclipseCase(eclipseCase); + m_geomResultDefinition->setGeoMechCase(geomCase); + + RimEclipseView* eclipseView = dynamic_cast(view); + if (eclipseView) + { + m_eclipseResultDefinition->simpleCopy(eclipseView->cellResult()); + m_timeStep = eclipseView->currentTimeStep(); + } + + RimGeoMechView* geoMechView = dynamic_cast(view); + if (geoMechView) + { + m_geomResultDefinition->setResultAddress(geoMechView->cellResultResultDefinition()->resultAddress()); + m_timeStep = geoMechView->currentTimeStep(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogExtractionCurve::resultPropertyString() const +{ + RimGeoMechCase* geoMechCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + QString name; + if (eclipseCase) + { + name = caf::Utils::makeValidFileBasename(m_eclipseResultDefinition->resultVariableUiName()); + } + else if (geoMechCase) + { + QString resCompName = m_geomResultDefinition->resultComponentUiName(); + if (resCompName.isEmpty()) + { + name = m_geomResultDefinition->resultFieldUiName(); + } + else + { + name = m_geomResultDefinition->resultFieldUiName() + "." + resCompName; + } + } + + return name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const +{ + CAF_ASSERT(values != nullptr); + CAF_ASSERT(measuredDepthValues != nullptr); + + cvf::ref eclExtractor; + cvf::ref geomExtractor; + + RimWellPath* wellPath; + firstAncestorOrThisOfType(wellPath); + + RimEclipseCase* eclipseCase = dynamic_cast(m_case()); + + if (eclipseCase) + { + eclExtractor = RiaExtractionTools::wellLogExtractorEclipseCase(wellPath, eclipseCase); + } + else + { + RimGeoMechCase* geomCase = dynamic_cast(m_case()); + if (geomCase) + { + geomExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase(wellPath, geomCase); + } + } + + if (eclExtractor.notNull() && eclipseCase) + { + *measuredDepthValues = eclExtractor->measuredDepth(); + + m_eclipseResultDefinition->loadResult(); + + cvf::ref resAcc = RigResultAccessorFactory::createFromResultDefinition(eclipseCase->eclipseCaseData(), + 0, + m_timeStep, + m_eclipseResultDefinition); + if (resAcc.notNull()) + { + eclExtractor->curveData(resAcc.p(), values); + } + } + else if (geomExtractor.notNull()) + { + *measuredDepthValues = geomExtractor->measuredDepth(); + + m_geomResultDefinition->loadResult(); + + geomExtractor->curveData(m_geomResultDefinition->resultAddress(), m_timeStep, values); + } +} + +QString Rim3dWellLogExtractionCurve::name() const +{ + return m_nameConfig()->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogExtractionCurve::createCurveAutoName() const +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + QStringList generatedCurveName; + + if (m_nameConfig->addWellName()) + { + RimWellPath* wellPath; + this->firstAncestorOrThisOfTypeAsserted(wellPath); + if (!wellPath->name().isEmpty()) + { + generatedCurveName += wellPath->name(); + } + } + + if (m_nameConfig->addCaseName() && m_case()) + { + generatedCurveName.push_back(m_case->caseUserDescription()); + } + + if (m_nameConfig->addProperty() && !resultPropertyString().isEmpty()) + { + generatedCurveName.push_back(resultPropertyString()); + } + + if (m_nameConfig->addTimeStep() || m_nameConfig->addDate()) + { + size_t maxTimeStep = 0; + + if (eclipseCase) + { + RigEclipseCaseData* data = eclipseCase->eclipseCaseData(); + if (data) + { + maxTimeStep = data->results(m_eclipseResultDefinition->porosityModel())->maxTimeStepCount(); + } + } + else if (geomCase) + { + RigGeoMechCaseData* data = geomCase->geoMechData(); + if (data) + { + maxTimeStep = data->femPartResults()->frameCount(); + } + } + + if (m_nameConfig->addDate()) + { + QString dateString = wellDate(); + if (!dateString.isEmpty()) + { + generatedCurveName.push_back(dateString); + } + } + + if (m_nameConfig->addTimeStep()) + { + generatedCurveName.push_back(QString("[%1/%2]").arg(m_timeStep()).arg(maxTimeStep)); + } + } + + return generatedCurveName.join(", "); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogExtractionCurve::userDescriptionField() +{ + return m_nameConfig()->nameField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_timeStep || changedField == &m_case) + { + this->resetMinMaxValuesAndUpdateUI(); + } + Rim3dWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogExtractionCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + options = Rim3dWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + + if (fieldNeedingOptions == &m_case) + { + RimTools::caseOptionItems(&options); + + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_timeStep) + { + QStringList timeStepNames; + + if (m_case) + { + timeStepNames = m_case->timeStepStrings(); + } + + for (int i = 0; i < timeStepNames.size(); i++) + { + options.push_back(caf::PdmOptionItemInfo(timeStepNames[i], i)); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + + curveDataGroup->add(&m_case); + + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + if (eclipseCase) + { + m_eclipseResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); + } + else if (geomCase) + { + m_geomResultDefinition->uiOrdering(uiConfigName, *curveDataGroup); + } + + if ((eclipseCase && m_eclipseResultDefinition->hasDynamicResult()) + || geomCase) + { + curveDataGroup->add(&m_timeStep); + } + + Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); + + m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogExtractionCurve::initAfterRead() +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + m_eclipseResultDefinition->setEclipseCase(eclipseCase); + m_geomResultDefinition->setGeoMechCase(geomCase); +} + +QString Rim3dWellLogExtractionCurve::wellDate() const +{ + RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); + RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); + + QStringList timeStepNames; + + if (eclipseCase) + { + if (eclipseCase->eclipseCaseData()) + { + timeStepNames = eclipseCase->timeStepStrings(); + } + } + else if (geomCase) + { + if (geomCase->geoMechData()) + { + timeStepNames = geomCase->timeStepStrings(); + } + } + + return (m_timeStep >= 0 && m_timeStep < timeStepNames.size()) ? timeStepNames[m_timeStep] : ""; +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h new file mode 100644 index 0000000000..a37e06aec5 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogExtractionCurve.h @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dWellLogCurve.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmPtrField.h" + +class Rim3dView; +class RimCase; +class RimGeoMechResultDefinition; +class RimEclipseResultDefinition; +class RimWellLogExtractionCurveNameConfig; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogExtractionCurve : public Rim3dWellLogCurve +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogExtractionCurve(); + virtual ~Rim3dWellLogExtractionCurve(); + + void setPropertiesFromView(Rim3dView* view); + virtual QString resultPropertyString() const override; + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + + virtual QString name() const override; + virtual QString createCurveAutoName() const override; +protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; + QString wellDate() const; +private: + caf::PdmPtrField m_case; + caf::PdmField m_timeStep; + + caf::PdmChildField m_eclipseResultDefinition; + caf::PdmChildField m_geomResultDefinition; + caf::PdmChildField m_nameConfig; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp new file mode 100644 index 0000000000..40976b2b95 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.cpp @@ -0,0 +1,258 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogFileCurve.h" + +#include "RigWellLogFile.h" + +#include "RimWellLogCurveNameConfig.h" +#include "RimWellLogFile.h" +#include "RimWellLogFileChannel.h" +#include "RimWellPath.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogFileCurve, "Rim3dWellLogFileCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogFileCurve::Rim3dWellLogFileCurve() +{ + CAF_PDM_InitObject("3d Well Log File Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellLogChannelName, "CurveWellLogChannel", "Well Log Channel", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellLogFile, "WellLogFile", "Well Log File", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); + m_nameConfig = new RimWellLogFileCurveNameConfig(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogFileCurve::~Rim3dWellLogFileCurve() +{ + delete m_nameConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::setDefaultFileCurveDataInfo() +{ + RimWellPath* wellPath = nullptr; + firstAncestorOrThisOfType(wellPath); + + if (wellPath && !wellPath->wellLogFiles().empty()) + { + m_wellLogFile = wellPath->wellLogFiles()[0]; + } + + if (m_wellLogFile) + { + std::vector fileLogs = m_wellLogFile->wellLogChannels(); + + if (!fileLogs.empty()) + { + m_wellLogChannelName = fileLogs[0]->name(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const +{ + CAF_ASSERT(values != nullptr); + CAF_ASSERT(measuredDepthValues != nullptr); + + if (m_wellLogFile) + { + RigWellLogFile* wellLogFile = m_wellLogFile->wellLogFileData(); + if (wellLogFile) + { + *values = wellLogFile->values(m_wellLogChannelName); + *measuredDepthValues = wellLogFile->depthValues(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogFileCurve::resultPropertyString() const +{ + return m_wellLogChannelName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogFileCurve::name() const +{ + return m_nameConfig->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogFileCurve::createCurveAutoName() const +{ + QStringList name; + QString unit; + bool channelNameAvailable = false; + + RimWellPath* wellPath; + this->firstAncestorOrThisOfType(wellPath); + + if (wellPath) + { + name.push_back(wellPath->name()); + name.push_back("LAS"); + + if (!m_wellLogChannelName().isEmpty()) + { + name.push_back(m_wellLogChannelName); + channelNameAvailable = true; + } + + RigWellLogFile* wellLogFile = m_wellLogFile ? m_wellLogFile->wellLogFileData() : nullptr; + + if (wellLogFile) + { + if (channelNameAvailable) + { + /* RimWellLogPlot* wellLogPlot; + firstAncestorOrThisOfType(wellLogPlot); + CVF_ASSERT(wellLogPlot); + QString unitName = wellLogFile->wellLogChannelUnitString(m_wellLogChannelName, wellLogPlot->depthUnit()); + + if (!unitName.isEmpty()) + { + name.back() += QString(" [%1]").arg(unitName); + } */ + } + + QString date = wellLogFile->date(); + if (!date.isEmpty()) + { + name.push_back(wellLogFile->date()); + } + + } + + return name.join(", "); + } + + return "Empty curve"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogFileCurve::userDescriptionField() +{ + return m_nameConfig()->nameField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_wellLogFile || changedField == &m_wellLogChannelName) + { + this->resetMinMaxValuesAndUpdateUI(); + } + Rim3dWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogFileCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + + options = Rim3dWellLogCurve::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + + if (!options.empty()) return options; + + if (fieldNeedingOptions == &m_wellLogChannelName) + { + if (m_wellLogFile) + { + std::vector fileLogs = m_wellLogFile->wellLogChannels(); + + for (size_t i = 0; i < fileLogs.size(); i++) + { + QString wellLogChannelName = fileLogs[i]->name(); + options.push_back(caf::PdmOptionItemInfo(wellLogChannelName, wellLogChannelName)); + } + } + + if (options.size() == 0) + { + options.push_back(caf::PdmOptionItemInfo("None", "None")); + } + } + + if (fieldNeedingOptions == &m_wellLogFile) + { + RimWellPath* wellPath = nullptr; + firstAncestorOrThisOfType(wellPath); + + if (wellPath && !wellPath->wellLogFiles().empty()) + { + for (RimWellLogFile* const wellLogFile : wellPath->wellLogFiles()) + { + QFileInfo fileInfo(wellLogFile->fileName()); + options.push_back(caf::PdmOptionItemInfo(fileInfo.baseName(), wellLogFile)); + } + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogFileCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + curveDataGroup->add(&m_wellLogFile); + curveDataGroup->add(&m_wellLogChannelName); + + Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); + + m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + + uiOrdering.skipRemainingFields(true); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h new file mode 100644 index 0000000000..58390e7a7f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogFileCurve.h @@ -0,0 +1,63 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dWellLogCurve.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmPtrField.h" + +class RimWellLogFile; +class RimWellLogFileCurveNameConfig; + +//================================================================================================== +/// +/// +//================================================================================================== +class Rim3dWellLogFileCurve : public Rim3dWellLogCurve +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogFileCurve(); + virtual ~Rim3dWellLogFileCurve(); + + void setDefaultFileCurveDataInfo(); + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + virtual QString resultPropertyString() const override; + virtual QString name() const override; + virtual QString createCurveAutoName() const override; +protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) override; + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + +private: + caf::PdmPtrField m_wellLogFile; + caf::PdmField m_wellLogChannelName; + caf::PdmChildField m_nameConfig; +}; diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp new file mode 100644 index 0000000000..29fb3db642 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.cpp @@ -0,0 +1,230 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Rim3dWellLogRftCurve.h" + +#include "RifReaderEclipseRft.h" +#include "RigWellLogCurveData.h" + +#include "RimWellLogCurveNameConfig.h" +#include "RimEclipseResultCase.h" +#include "RimTools.h" +#include "RimWellPath.h" +#include "RimWellLogCurve.h" + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(Rim3dWellLogRftCurve, "Rim3dWellLogRftCurve"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogRftCurve::Rim3dWellLogRftCurve() +{ + CAF_PDM_InitObject("3d Well Log RFT Curve", ":/WellLogCurve16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_eclipseResultCase, "eclipseResultCase", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_timeStep, "timeStep", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_wellLogChannelName, "wellLogChannelName", "", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_2dWellLogRftCurve, "my2dWellLogRftCurve", "", "", "", ""); + + m_2dWellLogRftCurve = new RimWellLogRftCurve(); + m_2dWellLogRftCurve.xmlCapability()->disableIO(); + + CAF_PDM_InitFieldNoDefault(&m_nameConfig, "NameConfig", "", "", "", ""); + m_nameConfig = new RimWellLogRftCurveNameConfig(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogRftCurve::~Rim3dWellLogRftCurve() +{ + delete m_nameConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogRftCurve::curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const +{ + if (m_2dWellLogRftCurve->wellName() == QString()) + { + m_2dWellLogRftCurve->setDefaultAddress(wellName()); + } + + const RigWellLogCurveData* curveData = m_2dWellLogRftCurve->curveData(); + + //These values are for a simulation well + *values = curveData->xValues(); + *measuredDepthValues = curveData->measuredDepths(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::resultPropertyString() const +{ + return caf::AppEnum::uiText(m_wellLogChannelName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::name() const +{ + return m_nameConfig->name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::createCurveAutoName() const +{ + QStringList name; + + if (!wellName().isEmpty()) + { + name.push_back(wellName()); + } + + name.push_back("RFT"); + + if (m_eclipseResultCase) + { + name.push_back(m_eclipseResultCase->caseUserDescription()); + } + if (m_wellLogChannelName().text() != caf::AppEnum::text(RifEclipseRftAddress::NONE)) + { + RifEclipseRftAddress::RftWellLogChannelType channelNameEnum = m_wellLogChannelName(); + name.push_back(caf::AppEnum::uiText(channelNameEnum)); + } + if (!m_timeStep().isNull()) + { + name.push_back(m_timeStep().toString(RimTools::dateFormatString())); + } + + return name.join(", "); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* Rim3dWellLogRftCurve::userDescriptionField() +{ + return m_nameConfig()->nameField(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogRftCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_wellLogChannelName || changedField == &m_timeStep) + { + this->resetMinMaxValuesAndUpdateUI(); + } + Rim3dWellLogCurve::fieldChangedByUi(changedField, oldValue, newValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList Rim3dWellLogRftCurve::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_eclipseResultCase) + { + RimTools::caseOptionItems(&options); + + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_wellLogChannelName) + { + if (m_eclipseResultCase) + { + RifReaderEclipseRft* reader = m_eclipseResultCase()->rftReader(); + if (reader) + { + for (const RifEclipseRftAddress::RftWellLogChannelType& channelName : reader->availableWellLogChannels(wellName())) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(channelName), channelName)); + } + } + if (options.empty()) + { + options.push_back(caf::PdmOptionItemInfo(caf::AppEnum::uiText(RifEclipseRftAddress::NONE), RifEclipseRftAddress::NONE)); + } + } + } + else if (fieldNeedingOptions == &m_timeStep) + { + if (m_eclipseResultCase) + { + RifReaderEclipseRft* reader = m_eclipseResultCase()->rftReader(); + if (reader) + { + QString dateFormat = "dd MMM yyyy"; + std::vector timeStamps = reader->availableTimeSteps(wellName(), m_wellLogChannelName()); + for (const QDateTime& dt : timeStamps) + { + options.push_back(caf::PdmOptionItemInfo(dt.toString(dateFormat), dt)); + } + } + + options.push_back(caf::PdmOptionItemInfo("None", QDateTime())); + } + } + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Rim3dWellLogRftCurve::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroup("Curve Data"); + curveDataGroup->add(&m_eclipseResultCase); + curveDataGroup->add(&m_wellLogChannelName); + curveDataGroup->add(&m_timeStep); + + Rim3dWellLogCurve::configurationUiOrdering(uiOrdering); + + m_nameConfig()->createUiGroup(uiConfigName, uiOrdering); + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString Rim3dWellLogRftCurve::wellName() const +{ + RimWellPath* wellPath = nullptr; + firstAncestorOrThisOfType(wellPath); + + return wellPath->name(); +} diff --git a/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h new file mode 100644 index 0000000000..ee9b157fe0 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Rim3dWellLogRftCurve.h @@ -0,0 +1,75 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dWellLogCurve.h" + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmPtrField.h" + +#include "RifEclipseRftAddress.h" +#include "RimWellLogRftCurve.h" + +class RimEclipseResultCase; +class RimWellLogRftCurveNameConfig; +class QString; + +//================================================================================================== +/// Not in use yet +/// +//================================================================================================== +class Rim3dWellLogRftCurve : public Rim3dWellLogCurve +{ + CAF_PDM_HEADER_INIT; + +public: + Rim3dWellLogRftCurve(); + virtual ~Rim3dWellLogRftCurve(); + + virtual void curveValuesAndMds(std::vector* values, std::vector* measuredDepthValues) const override; + + virtual QString resultPropertyString() const override; + virtual QString name() const override; + virtual QString createCurveAutoName() const override; + +protected: + virtual caf::PdmFieldHandle* userDescriptionField() override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) override; + +private: + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) override; + + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + QString wellName() const; + +private: + caf::PdmPtrField m_eclipseResultCase; + caf::PdmField m_timeStep; + + caf::PdmField> m_wellLogChannelName; + + caf::PdmChildField m_2dWellLogRftCurve; + caf::PdmChildField m_nameConfig; +}; diff --git a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp index 7cc376c539..1ffe6debc9 100644 --- a/ApplicationCode/ProjectDataModel/RimCalcScript.cpp +++ b/ApplicationCode/ProjectDataModel/RimCalcScript.cpp @@ -27,7 +27,7 @@ CAF_PDM_SOURCE_INIT(RimCalcScript, "CalcScript"); //-------------------------------------------------------------------------------------------------- RimCalcScript::RimCalcScript() { - CAF_PDM_InitObject("CalcScript", ":/octave.png", "Calc Script", ""); + CAF_PDM_InitObject("CalcScript", ":/OctaveScriptFile16x16.png", "Calc Script", ""); CAF_PDM_InitField(&absolutePath, "AbsolutePath", QString(), "Location", "", "" ,""); CAF_PDM_InitField(&content, "Content", QString(), "Directory", "", "" ,""); diff --git a/ApplicationCode/ProjectDataModel/RimCase.cpp b/ApplicationCode/ProjectDataModel/RimCase.cpp index 1382c40e11..ee0ce66da0 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimCase.cpp @@ -28,6 +28,11 @@ #include "cafPdmObjectFactory.h" +#include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" +#include "RimIntersection.h" +#include "RimGridView.h" + CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); @@ -35,7 +40,7 @@ CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCase, "RimCase"); //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimCase::RimCase() +RimCase::RimCase() : m_isInActiveDestruction(false) { CAF_PDM_InitField(&caseUserDescription, "CaseUserDescription", QString(), "Case Name", "", "" ,""); @@ -48,6 +53,10 @@ RimCase::RimCase() m_timeStepFilter.uiCapability()->setUiHidden(true); m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden(true); m_timeStepFilter = new RimTimeStepFilter; + + CAF_PDM_InitFieldNoDefault(&m_2dIntersectionViewCollection, "IntersectionViewCollection", "2D Intersection Views", ":/CrossSections16x16.png", "", ""); + m_2dIntersectionViewCollection.uiCapability()->setUiTreeHidden(true); + m_2dIntersectionViewCollection = new Rim2dIntersectionViewCollection(); } //-------------------------------------------------------------------------------------------------- @@ -55,7 +64,40 @@ RimCase::RimCase() //-------------------------------------------------------------------------------------------------- RimCase::~RimCase() { + m_isInActiveDestruction = true; // Needed because destruction of m_intersectionViews results in call to views() +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCase::views() const +{ + if (m_isInActiveDestruction) return std::vector(); + + std::vector allViews = this->allSpecialViews(); + std::vector isectViews = m_2dIntersectionViewCollection->views(); + for (auto view: isectViews) + { + allViews.push_back(view); + } + + return allViews; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimCase::gridViews() const +{ + std::vector grViews; + + for (Rim3dView* const view : views()) + { + RimGridView* grView = dynamic_cast(view); + if (grView) grViews.push_back(grView); + } + return grViews; } //-------------------------------------------------------------------------------------------------- @@ -89,6 +131,14 @@ size_t RimCase::uiToNativeTimeStepIndex(size_t uiTimeStepIndex) return uiTimeStepIndex; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionViewCollection* RimCase::intersectionViewCollection() +{ + return m_2dIntersectionViewCollection; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimCase.h b/ApplicationCode/ProjectDataModel/RimCase.h index 5b151baae6..d13f3a908d 100644 --- a/ApplicationCode/ProjectDataModel/RimCase.h +++ b/ApplicationCode/ProjectDataModel/RimCase.h @@ -23,15 +23,20 @@ #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmChildField.h" +#include "cafPdmChildArrayField.h" #include "cvfBase.h" #include "cvfVector3.h" #include -class RimView; +class Rim3dView; +class RimGridView; class RimFormationNames; class RimTimeStepFilter; +class Rim2dIntersectionView; +class RimIntersection; +class Rim2dIntersectionViewCollection; namespace cvf { class BoundingBox; @@ -49,7 +54,8 @@ class RimCase : public caf::PdmObject caf::PdmPtrField activeFormationNames; - virtual std::vector views() = 0; + std::vector views() const; + std::vector gridViews() const; virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath) = 0; @@ -69,13 +75,20 @@ class RimCase : public caf::PdmObject size_t uiToNativeTimeStepIndex(size_t uiTimeStepIndex); + Rim2dIntersectionViewCollection* intersectionViewCollection(); protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual std::vector allSpecialViews() const = 0; + private: virtual caf::PdmFieldHandle* userDescriptionField() override { return &caseUserDescription; } protected: caf::PdmChildField m_timeStepFilter; + caf::PdmChildField m_2dIntersectionViewCollection; + +private: + bool m_isInActiveDestruction; }; diff --git a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp index b63de1f8f8..75ef608631 100644 --- a/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCaseCollection.cpp @@ -66,5 +66,5 @@ RimEclipseCase* RimCaseCollection::findByDescription(const QString& caseDescript } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp index 3263a4ed79..6f3e73f500 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.cpp @@ -25,7 +25,7 @@ #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" #include "cafPdmUiListEditor.h" @@ -70,7 +70,7 @@ RimCellEdgeColors::RimCellEdgeColors() m_resultVariable.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); - m_legendConfig = new RimLegendConfig(); + m_legendConfig = new RimRegularLegendConfig(); m_ignoredResultScalar = cvf::UNDEFINED_DOUBLE; resetResultIndices(); @@ -497,6 +497,14 @@ void RimCellEdgeColors::posNegClosestToZero(double& pos, double& neg) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellEdgeColors::updateUiFieldsFromActiveResult() +{ + m_singleVarEdgeResultColors->updateUiFieldsFromActiveResult(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -585,7 +593,7 @@ RimEclipseCellColors* RimCellEdgeColors::singleVarEdgeResultColors() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimCellEdgeColors::legendConfig() +RimRegularLegendConfig* RimCellEdgeColors::legendConfig() { if (isUsingSingleVariable()) { diff --git a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h index 409208e767..c5e99c7608 100644 --- a/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h +++ b/ApplicationCode/ProjectDataModel/RimCellEdgeColors.h @@ -30,7 +30,7 @@ class RigCaseCellResultsData; class RimEclipseCase; class RimEclipseCellColors; class RimEclipseView; -class RimLegendConfig; +class RimRegularLegendConfig; class RimCellEdgeMetaData { @@ -86,11 +86,14 @@ class RimCellEdgeColors : public caf::PdmObject bool isUsingSingleVariable() const; RimEclipseCellColors* singleVarEdgeResultColors(); - RimLegendConfig* legendConfig(); + RimRegularLegendConfig* legendConfig(); PropertyType propertyType() const; void minMaxCellEdgeValues(double& min, double& max); void posNegClosestToZero(double& pos, double& neg); + + void updateUiFieldsFromActiveResult(); + protected: virtual void initAfterRead(); @@ -120,7 +123,7 @@ class RimCellEdgeColors : public caf::PdmObject caf::PdmField > m_propertyType; - caf::PdmChildField m_legendConfig; + caf::PdmChildField m_legendConfig; caf::PdmChildField m_singleVarEdgeResultColors; }; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp index d0538fc992..ecec2521cd 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilter.cpp @@ -147,7 +147,9 @@ void RimCellRangeFilter::setDefaultValues() const cvf::StructGridInterface* grid = selectedGrid(); - RimView* rimView = nullptr; + if (!grid) return; + + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimView); RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView); @@ -208,6 +210,8 @@ void RimCellRangeFilter::defineEditorAttribute(const caf::PdmFieldHandle* field, } const cvf::StructGridInterface* grid = selectedGrid(); + + if (!grid) return; if (field == &startIndexI || field == &cellCountI) { @@ -246,7 +250,7 @@ void RimCellRangeFilter::defineUiOrdering(QString uiConfigName, caf::PdmUiOrderi this->firstAncestorOrThisOfTypeAsserted(rimCase); const cvf::StructGridInterface* mainGrid = RigReservoirGridTools::mainGrid(rimCase); - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfTypeAsserted(rimView); RigActiveCellInfo* actCellInfo = RigReservoirGridTools::activeCellInfo(rimView); @@ -332,7 +336,7 @@ QList RimCellRangeFilter::calculateValueOptions(const ca //-------------------------------------------------------------------------------------------------- bool RimCellRangeFilter::isRangeFilterControlled() const { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfTypeAsserted(rimView); bool isRangeFilterControlled = false; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp index d975e4739c..d621a4bb9f 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.cpp @@ -21,7 +21,7 @@ #include "RimCellRangeFilterCollection.h" #include "RimCellRangeFilter.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -102,7 +102,7 @@ void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* c updateIconState(); uiCapability()->updateConnectedEditors(); - updateDisplayModeNotifyManagedViews(NULL); + updateDisplayModeNotifyManagedViews(nullptr); } //-------------------------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ void RimCellRangeFilterCollection::fieldChangedByUi(const caf::PdmFieldHandle* c //-------------------------------------------------------------------------------------------------- void RimCellRangeFilterCollection::updateDisplayModeNotifyManagedViews(RimCellRangeFilter* changedRangeFilter) { - RimView* view = NULL; + Rim3dView* view = nullptr; firstAncestorOrThisOfType(view); if (!view) return; @@ -173,9 +173,9 @@ bool RimCellRangeFilterCollection::hasActiveIncludeFilters() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimCellRangeFilterCollection::baseView() const +Rim3dView* RimCellRangeFilterCollection::baseView() const { - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); return rimView; diff --git a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h index 00983fd659..57c65d6dbf 100644 --- a/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimCellRangeFilterCollection.h @@ -22,7 +22,7 @@ #include "cafPdmChildArrayField.h" #include "cafPdmField.h" -class RimView; +class Rim3dView; class RimCellRangeFilter; namespace cvf { @@ -58,5 +58,5 @@ class RimCellRangeFilterCollection : public caf::PdmObject virtual caf::PdmFieldHandle* objectToggleField(); private: - RimView* baseView() const; + Rim3dView* baseView() const; }; diff --git a/ApplicationCode/ProjectDataModel/RimCheckableObject.cpp b/ApplicationCode/ProjectDataModel/RimCheckableObject.cpp new file mode 100644 index 0000000000..33946e0508 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCheckableObject.cpp @@ -0,0 +1,61 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimCheckableObject.h" + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimCheckableObject, "RimCheckableObject"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCheckableObject::RimCheckableObject(void) +{ + CAF_PDM_InitField(&m_isChecked, "IsChecked", true, "Active", "", "", ""); + m_isChecked.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCheckableObject::~RimCheckableObject(void) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCheckableObject::isChecked() const +{ + return m_isChecked(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCheckableObject::setCheckState(bool checkState) +{ + m_isChecked = checkState; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCheckableObject::objectToggleField() +{ + return &m_isChecked; +} diff --git a/ApplicationCode/ProjectDataModel/RimCheckableObject.h b/ApplicationCode/ProjectDataModel/RimCheckableObject.h new file mode 100644 index 0000000000..d2ed97adfa --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimCheckableObject.h @@ -0,0 +1,44 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCheckableObject : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; +public: + RimCheckableObject(void); + virtual ~RimCheckableObject(void); + + bool isChecked() const; + void setCheckState(bool checkState); + +protected: + virtual caf::PdmFieldHandle* objectToggleField() override; + +protected: + caf::PdmField m_isChecked; +}; + diff --git a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp index f53be8ce52..bd13d041ab 100644 --- a/ApplicationCode/ProjectDataModel/RimCommandObject.cpp +++ b/ApplicationCode/ProjectDataModel/RimCommandObject.cpp @@ -308,7 +308,7 @@ caf::PdmObjectHandle* RimCommandIssueFieldChanged::findObjectByName(caf::PdmObje } } - return NULL; + return nullptr; } @@ -328,7 +328,7 @@ caf::PdmFieldHandle* RimCommandIssueFieldChanged::findFieldByKeyword(caf::PdmObj } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp index 399b21c256..f3297af89e 100644 --- a/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -22,6 +22,10 @@ #include "RiaApplication.h" #include "Rim3dOverlayInfoConfig.h" +#include "Rim3dWellLogCurveCollection.h" +#include "Rim3dWellLogExtractionCurve.h" +#include "Rim3dWellLogFileCurve.h" +#include "Rim3dWellLogRftCurve.h" #include "RimCalcScript.h" #include "RimCaseCollection.h" #include "RimCellRangeFilter.h" @@ -35,6 +39,8 @@ #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSet.h" #include "RimFaultInView.h" #include "RimFlowCharacteristicsPlot.h" #include "RimFlowDiagSolution.h" @@ -57,6 +63,8 @@ #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlot.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryCurve.h" @@ -77,7 +85,6 @@ #include "RimWellPltPlot.h" #include "RimWellRftPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimEllipseFractureTemplate.h" #include "RimStimPlanFractureTemplate.h" #include "RimFractureTemplateCollection.h" @@ -85,7 +92,6 @@ #include "RimSimWellFracture.h" #include "RimWellPathFracture.h" #include "RimWellPathFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RiuMainWindow.h" @@ -122,9 +128,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() if (dynamic_cast(uiItem)) { + menuBuilder.subMenuStart("Import"); menuBuilder << "RicImportEclipseCaseFeature"; + menuBuilder << "RicImportEclipseCasesFeature"; menuBuilder << "RicImportInputEclipseCaseFeature"; menuBuilder << "RicCreateGridCaseGroupFeature"; + menuBuilder << "RicCreateGridCaseGroupFromFilesFeature"; + menuBuilder.subMenuEnd(); menuBuilder << "RicEclipseCaseNewGroupFeature"; } else if (dynamic_cast(uiItem)) @@ -176,6 +186,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicNewViewFeature"; menuBuilder << "Separator"; + menuBuilder << "RicImportElementPropertyFeature"; + menuBuilder << "Separator"; } else if (dynamic_cast(uiItem)) { @@ -250,28 +262,50 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder.addSeparator(); - menuBuilder.subMenuStart("Well Plots", QIcon(":/SummaryPlot16x16.png")); + menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png")); menuBuilder << "RicNewRftPlotFeature"; menuBuilder << "RicNewPltPlotFeature"; menuBuilder << "RicShowWellAllocationPlotFeature"; menuBuilder << "RicNewWellLogFileCurveFeature"; menuBuilder << "RicNewWellLogCurveExtractionFeature"; - menuBuilder << "RicNewWellPathIntersectionFeature"; menuBuilder.subMenuEnd(); menuBuilder.addSeparator(); + menuBuilder.subMenuStart("3D Well Log Curves", QIcon(":/WellLogCurve16x16.png")); + + menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicAdd3dWellLogFileCurveFeature"; + + menuBuilder.subMenuEnd(); + + menuBuilder << "RicNewWellPathIntersectionFeature"; + + menuBuilder.addSeparator(); + menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); - // Fracture commands -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewWellPathFractureFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewFishbonesSubsFeature"; menuBuilder << "RicNewPerforationIntervalFeature"; menuBuilder << "RicEditPerforationCollectionFeature"; menuBuilder.subMenuEnd(); + menuBuilder.subMenuStart("Export Completions", QIcon(":/FishBoneGroup16x16.png")); + menuBuilder << "RicExportCompletionsForVisibleWellPathsFeature"; + menuBuilder << "RicWellPathExportCompletionDataFeature"; + menuBuilder.subMenuEnd(); + menuBuilder << "Separator"; + + } + else if (dynamic_cast(uiItem) || + dynamic_cast(uiItem) || + dynamic_cast(uiItem) || + dynamic_cast(uiItem)) + { + menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicAdd3dWellLogFileCurveFeature"; + menuBuilder << "RicAdd3dWellLogRftCurveFeature"; } else if (dynamic_cast(uiItem)) { @@ -389,11 +423,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicPasteSummaryCrossPlotCurveFeature"; menuBuilder << "RicPasteSummaryPlotFeature"; menuBuilder << "RicPasteAsciiDataToSummaryPlotFeature"; + menuBuilder << "RicPasteEnsembleCurveSetFeature"; menuBuilder << "Separator"; menuBuilder << "RicEditSummaryPlotFeature"; menuBuilder << "RicNewSummaryPlotFeature"; menuBuilder << "RicDuplicateSummaryPlotFeature"; menuBuilder << "RicNewSummaryCurveFeature"; + menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; menuBuilder << "RicDuplicateSummaryCrossPlotFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; menuBuilder << "Separator"; @@ -431,12 +467,54 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewSummaryCurveFeature"; menuBuilder << "RicNewSummaryCrossPlotCurveFeature"; } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; + menuBuilder << "RicPasteEnsembleCurveSetFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicNewSummaryEnsembleCurveSetFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicImportSummaryCaseFeature"; + menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportSummaryGroupFeature"; + menuBuilder << "RicImportEnsembleFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder.subMenuStart("Import"); + menuBuilder << "RicImportSummaryCaseFeature"; + menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportSummaryGroupFeature"; + menuBuilder << "RicImportEnsembleFeature"; + menuBuilder.subMenuEnd(); + menuBuilder.addSeparator(); + menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicNewSummaryCrossPlotFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicConvertGroupToEnsembleFeature"; + menuBuilder.addSeparator(); + } else if (dynamic_cast(uiItem)) { + menuBuilder.subMenuStart("Import"); + menuBuilder << "RicImportSummaryCaseFeature"; + menuBuilder << "RicImportSummaryCasesFeature"; + menuBuilder << "RicImportSummaryGroupFeature"; + menuBuilder << "RicImportEnsembleFeature"; + menuBuilder.subMenuEnd(); + menuBuilder.addSeparator(); + menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicNewSummaryCrossPlotFeature"; + menuBuilder.addSeparator(); + if (!dynamic_cast(uiItem)) { menuBuilder << "RicShowSummaryCurveCalculatorFeature"; - menuBuilder << "RicNewSummaryPlotFeature"; + //menuBuilder << "RicNewSummaryPlotFeature"; } } else if (dynamic_cast(uiItem)) @@ -445,18 +523,32 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteIntersectionsFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteIntersectionsFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewIntersectionViewFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteIntersectionsFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicAppendIntersectionFeature"; menuBuilder << "RicAppendIntersectionBoxFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } else if (dynamic_cast(uiItem)) { @@ -464,13 +556,19 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicNewWellLogRftCurveFeature"; menuBuilder << "RicNewSimWellIntersectionFeature"; - menuBuilder.subMenuStart("Well Plots", QIcon(":/SummaryPlot16x16.png")); + menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png")); menuBuilder << "RicNewRftPlotFeature"; menuBuilder << "RicNewPltPlotFeature"; menuBuilder << "Separator"; menuBuilder << "RicPlotProductionRateFeature"; menuBuilder << "RicShowWellAllocationPlotFeature"; menuBuilder.subMenuEnd(); + + menuBuilder << "RicExportCompletionsForVisibleSimWellsFeature"; + } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicExportCompletionsForVisibleSimWellsFeature"; } else if(dynamic_cast(uiItem)) { @@ -507,31 +605,43 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() { menuBuilder << "RicShowGridStatisticsFeature"; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES else if (dynamic_cast(uiItem)) { menuBuilder << "RicNewSimWellFractureFeature"; } - else if (dynamic_cast(uiItem) || - dynamic_cast(uiItem)) + else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder << "RicPasteStimPlanFractureFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; menuBuilder << "Separator"; menuBuilder << "RicConvertAllFractureTemplatesToMetricFeature"; menuBuilder << "RicConvertAllFractureTemplatesToFieldFeature"; } + else if (dynamic_cast(uiItem)) + { + menuBuilder << "RicPasteStimPlanFractureFeature"; + menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewEllipseFractureTemplateFeature"; + menuBuilder << "RicNewStimPlanFractureTemplateFeature"; + menuBuilder << "Separator"; + menuBuilder << "RicConvertFractureTemplateUnitFeature"; + } else if (dynamic_cast(uiItem)) { + menuBuilder << "RicPasteEllipseFractureFeature"; + menuBuilder << "RicPasteStimPlanFractureFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicNewEllipseFractureTemplateFeature"; menuBuilder << "RicNewStimPlanFractureTemplateFeature"; menuBuilder << "Separator"; menuBuilder << "RicConvertFractureTemplateUnitFeature"; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - if (dynamic_cast(uiItem)) + if (dynamic_cast(uiItem)) { menuBuilder << "Separator"; menuBuilder << "RicLinkVisibleViewsFeature"; @@ -554,13 +664,20 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicPasteTimeHistoryCurveFeature"; menuBuilder << "RicPasteAsciiDataCurveFeature"; + menuBuilder << "RicPasteSummaryCaseFeature"; + menuBuilder.addSeparator(); menuBuilder << "RicCopyReferencesToClipboardFeature"; menuBuilder << "RicShowPlotDataFeature"; menuBuilder << "RicShowTotalAllocationDataFeature"; + menuBuilder << "RicNewSummaryPlotFeature"; + menuBuilder << "RicNewSummaryCrossPlotFeature"; menuBuilder << "RicSummaryCurveSwitchAxisFeature"; - + menuBuilder.addSeparator(); + menuBuilder << "RicConvertGroupToEnsembleFeature"; + menuBuilder.addSeparator(); + if (!menuBuilder.isCmdFeatureAdded("RicNewFishbonesSubsFeature")) { menuBuilder << "RicNewFishbonesSubsFeature"; @@ -573,19 +690,43 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEditPerforationCollectionFeature"; menuBuilder << "RicExportFishbonesLateralsFeature"; menuBuilder << "RicExportFishbonesWellSegmentsFeature"; - menuBuilder << "RicWellPathExportCompletionDataFeature"; + + { + QStringList candidates; + + if (!menuBuilder.isCmdFeatureAdded("RicExportCompletionsForVisibleWellPathsFeature")) + { + candidates << "RicExportCompletionsForVisibleWellPathsFeature"; + } + if (!menuBuilder.isCmdFeatureAdded("RicWellPathExportCompletionDataFeature")) + { + candidates << "RicWellPathExportCompletionDataFeature"; + } + + if (!candidates.isEmpty()) + { + menuBuilder.subMenuStart("Export Completions", QIcon(":/FishBoneGroup16x16.png")); + + for (const auto& text : candidates) + { + menuBuilder << text; + } + + menuBuilder.subMenuEnd(); + } + } + menuBuilder << "RicWellPathImportCompletionsFileFeature"; menuBuilder << "RicFlyToObjectFeature"; menuBuilder << "RicExportCarfin"; menuBuilder << "RicImportObservedDataFeature"; - menuBuilder << "RicPasteSummaryCaseFeature"; menuBuilder << "RicReloadSummaryCaseFeature"; menuBuilder << "RicCreateSummaryCaseCollectionFeature"; menuBuilder << "Separator"; menuBuilder << "RicCutReferencesToClipboardFeature"; menuBuilder << "Separator"; - menuBuilder << "RicCloseSummaryCaseFeature"; + menuBuilder << "RicCloseSummaryCaseFeature"; menuBuilder << "RicCloseSummaryCaseInCollectionFeature"; menuBuilder << "RicDeleteSummaryCaseCollectionFeature"; menuBuilder << "RicCloseObservedDataFeature"; @@ -644,11 +785,11 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicEclipseWellShowSpheresFeature"; menuBuilder << "RicEclipseWellShowWellCellsFeature"; menuBuilder << "RicEclipseWellShowWellCellFenceFeature"; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "Separator"; menuBuilder << "RicNewSimWellFractureFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } + menuBuilder.addSeparator(); + menuBuilder << "RicCopyIntersectionsToAllViewsInCaseFeature"; } { @@ -682,18 +823,22 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "RicDeleteSubItemsFeature"; } + // Special delete commands for specific features + // Placed here to fit context menu location of general delete feature if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellPathDeleteFeature")->canFeatureBeExecuted()) { - // Special delete command for Well paths - // Placed here to fit context menu location of general delete feature menuBuilder << "Separator"; menuBuilder << "RicWellPathDeleteFeature"; } + if (caf::CmdFeatureManager::instance()->getCommandFeature("Ric3dWellLogCurveDeleteFeature")->canFeatureBeExecuted()) + { + menuBuilder << "Separator"; + menuBuilder << "Ric3dWellLogCurveDeleteFeature"; + } + if (caf::CmdFeatureManager::instance()->getCommandFeature("RicWellLogFileCloseFeature")->canFeatureBeExecuted()) { - // Special delete command for Well paths - // Placed here to fit context menu location of general delete feature menuBuilder << "Separator"; menuBuilder << "RicWellLogFileCloseFeature"; } diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.cpp b/ApplicationCode/ProjectDataModel/RimDialogData.cpp index 1d0b3d81e5..79138b2a90 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.cpp +++ b/ApplicationCode/ProjectDataModel/RimDialogData.cpp @@ -19,7 +19,7 @@ #include "RimDialogData.h" #include "ExportCommands/RicExportCarfinUi.h" -#include "CompletionCommands/RicExportCompletionDataSettingsUi.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" CAF_PDM_SOURCE_INIT(RimDialogData, "RimDialogData"); @@ -34,7 +34,7 @@ RimDialogData::RimDialogData() m_exportCarfin = new RicExportCarfinUi; CAF_PDM_InitFieldNoDefault(&m_exportCompletionData, "ExportCompletionData", "Export Completion Data", "", "", ""); - m_exportCompletionData = new RicExportCompletionDataSettingsUi(false); + m_exportCompletionData = new RicExportCompletionDataSettingsUi(); } //-------------------------------------------------------------------------------------------------- @@ -65,9 +65,8 @@ void RimDialogData::setExportCarfinDataFromString(const QString& data) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData(bool onlyWellPathCollectionSelected) const +RicExportCompletionDataSettingsUi* RimDialogData::exportCompletionData() const { - m_exportCompletionData->setOnlyWellPathCollectionSelected(onlyWellPathCollectionSelected); return m_exportCompletionData; } diff --git a/ApplicationCode/ProjectDataModel/RimDialogData.h b/ApplicationCode/ProjectDataModel/RimDialogData.h index 257a78621a..a03131c48d 100644 --- a/ApplicationCode/ProjectDataModel/RimDialogData.h +++ b/ApplicationCode/ProjectDataModel/RimDialogData.h @@ -39,7 +39,7 @@ class RimDialogData : public caf::PdmObject QString exportCarfinDataAsString() const; void setExportCarfinDataFromString(const QString& data); - RicExportCompletionDataSettingsUi* exportCompletionData(bool onlyWellPathCollectionSelected) const; + RicExportCompletionDataSettingsUi* exportCompletionData() const; private: caf::PdmChildField m_exportCarfin; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp index 54cf89d46e..04e6ea9c39 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.cpp @@ -24,12 +24,17 @@ #include "RiaColorTables.h" #include "RiaPreferences.h" +#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h" +#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h" + #include "RigActiveCellInfo.h" #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigSimWellData.h" +#include "RigVirtualPerforationTransmissibilities.h" +#include "Rim2dIntersectionViewCollection.h" #include "RimCaseCollection.h" #include "RimCellEdgeColors.h" #include "RimCommandObject.h" @@ -41,15 +46,20 @@ #include "RimFlowCharacteristicsPlot.h" #include "RimFlowPlotCollection.h" #include "RimFormationNames.h" +#include "RimIntersectionCollection.h" +#include "RimRegularLegendConfig.h" #include "RimMainPlotCollection.h" #include "RimOilField.h" +#include "RimPerforationCollection.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" +#include "RimStimPlanColors.h" #include "RimSummaryCase.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlot.h" #include "RimSummaryPlotCollection.h" #include "RimTools.h" +#include "RimVirtualPerforationResults.h" #include "RimWellAllocationPlot.h" #include "RimWellLogPlot.h" #include "RimWellLogPlotCollection.h" @@ -58,6 +68,7 @@ #include "cafPdmDocument.h" #include "cafProgressInfo.h" +#include "cafPdmUiTreeOrdering.h" #include #include @@ -105,7 +116,7 @@ RimEclipseCase::RimEclipseCase() m_fractureModelResults.uiCapability()->setUiHidden(true); m_fractureModelResults.uiCapability()->setUiTreeChildrenHidden(true); - this->setReservoirData( NULL ); + this->setReservoirData( nullptr ); } //-------------------------------------------------------------------------------------------------- @@ -196,6 +207,19 @@ cvf::Color3f RimEclipseCase::defaultWellColor(const QString& wellName) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigMainGrid* RimEclipseCase::mainGrid() const +{ + if (eclipseCaseData()) + { + return eclipseCaseData()->mainGrid(); + } + + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -223,8 +247,22 @@ RimEclipseView* RimEclipseCase::createAndAddReservoirView() { RimEclipseView* rimEclipseView = new RimEclipseView(); rimEclipseView->setEclipseCase(this); - rimEclipseView->cellEdgeResult()->setResultVariable("MULT"); - rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; + + // Set default values + { + rimEclipseView->cellResult()->setResultType(RiaDefines::DYNAMIC_NATIVE); + + if (RiaApplication::instance()->preferences()->loadAndShowSoil) + { + rimEclipseView->cellResult()->setResultVariable("SOIL"); + } + + rimEclipseView->hasUserRequestedAnimation = true; + + rimEclipseView->cellEdgeResult()->setResultVariable("MULT"); + rimEclipseView->cellEdgeResult()->enableCellEdgeColors = false; + rimEclipseView->fractureColors()->setDefaultResultName(); + } caf::PdmDocument::updateUiIconStateRecursively(rimEclipseView); @@ -262,18 +300,96 @@ RimEclipseView* RimEclipseCase::createCopyAndAddView(const RimEclipseView* sourc //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCase::recalculateCompletionTypeAndRedrawAllViews() +const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirtualPerforationTransmissibilities() { - results(RiaDefines::MATRIX_MODEL)->clearScalarResult(RiaDefines::DYNAMIC_NATIVE, RiaDefines::completionTypeResultName()); + RigEclipseCaseData* rigEclipseCase = eclipseCaseData(); - for (RimView* view : views()) + if (rigEclipseCase->virtualPerforationTransmissibilities() == nullptr) { - RimEclipseView* eclipseView = dynamic_cast(view); - if (eclipseView) + cvf::ref perfTrans = new RigVirtualPerforationTransmissibilities; + + std::vector visibleWellPaths; + bool anyPerforationsPresent = false; { - eclipseView->calculateCompletionTypeAndRedrawIfRequired(); + RimProject* proj = RiaApplication::instance()->project(); + std::vector wellPaths = proj->allWellPaths(); + for (auto w : wellPaths) + { + if (w->showWellPath()) + { + visibleWellPaths.push_back(w); + + if (!w->perforationIntervalCollection()->perforations().empty()) + { + anyPerforationsPresent = true; + } + } + } } + + for (auto w : visibleWellPaths) + { + std::vector staticCompletionData = RicWellPathExportCompletionDataFeatureImpl::computeStaticCompletionsForWellPath(w, this); + + if (anyPerforationsPresent) + { + std::vector> allCompletionData; + + for (size_t i = 0; i < timeStepDates().size(); i++) + { + std::vector dynamicCompletionDataOneTimeStep = RicWellPathExportCompletionDataFeatureImpl::computeDynamicCompletionsForWellPath(w, this, i); + + std::copy(staticCompletionData.begin(), staticCompletionData.end(), std::back_inserter(dynamicCompletionDataOneTimeStep)); + + allCompletionData.push_back(dynamicCompletionDataOneTimeStep); + } + + perfTrans->setCompletionDataForWellPath(w, allCompletionData); + } + else + { + std::vector> allCompletionData; + allCompletionData.push_back(staticCompletionData); + + perfTrans->setCompletionDataForWellPath(w, allCompletionData); + } + } + + for (const auto& wellRes : rigEclipseCase->wellResults()) + { + std::vector> completionsPerTimeStep; + for (size_t i = 0; i < timeStepDates().size(); i++) + { + std::vector completionData; + + if (wellRes->hasWellResult(i)) + { + for (const auto& wellResultBranch : wellRes->wellResultFrame(i).m_wellResultBranches) + { + for (const auto& r : wellResultBranch.m_branchResultPoints) + { + if (r.isValid()) + { + RigCompletionData compData(wellRes->m_wellName, RigCompletionDataGridCell(r.m_gridCellIndex, rigEclipseCase->mainGrid()), 0); + compData.setTransmissibility(r.connectionFactor()); + + completionData.push_back(compData); + } + } + } + + } + + completionsPerTimeStep.push_back(completionData); + + perfTrans->setCompletionDataForSimWell(wellRes.p(), completionsPerTimeStep); + } + } + + rigEclipseCase->setVirtualPerforationTransmissibilities(perfTrans.p()); } + + return rigEclipseCase->virtualPerforationTransmissibilities(); } //-------------------------------------------------------------------------------------------------- @@ -329,8 +445,8 @@ void RimEclipseCase::updateFormationNamesData() { rigEclipseCase->setActiveFormationNames(nullptr); } - std::vector views = this->views(); - for(RimView* view : views) + std::vector views = this->views(); + for(Rim3dView* view : views) { RimEclipseView* eclView = dynamic_cast(view); @@ -366,11 +482,30 @@ void RimEclipseCase::updateFormationNamesData() view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); + eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + std::vector children; + reservoirViews.childObjects(&children); + + for (auto child : children) uiTreeOrdering.add(child); + + if (!m_2dIntersectionViewCollection->views().empty()) + { + uiTreeOrdering.add(&m_2dIntersectionViewCollection); + } + + uiTreeOrdering.skipRemainingChildren(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -430,8 +565,8 @@ void RimEclipseCase::setReservoirData(RigEclipseCaseData* eclipseCase) } else { - m_fractureModelResults()->setCellResults(NULL); - m_matrixModelResults()->setCellResults(NULL); + m_fractureModelResults()->setCellResults(nullptr); + m_matrixModelResults()->setCellResults(nullptr); } } @@ -655,13 +790,14 @@ bool RimEclipseCase::openReserviorCase() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimEclipseCase::views() +std::vector RimEclipseCase::allSpecialViews() const { - std::vector views; + std::vector views; for (size_t vIdx = 0; vIdx < reservoirViews.size(); ++vIdx) { views.push_back(reservoirViews[vIdx]); } + return views; } @@ -730,10 +866,7 @@ void RimEclipseCase::reloadDataAndUpdate() RimSummaryCaseMainCollection* sumCaseColl = project->activeOilField() ? project->activeOilField()->summaryCaseMainCollection() : nullptr; if (sumCaseColl) { - for (auto sumCase : sumCaseColl->allSummaryCases()) - { - sumCase->createSummaryReaderInterface(); - } + sumCaseColl->loadAllSummaryCaseData(); } if (project->mainPlotCollection()) diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCase.h b/ApplicationCode/ProjectDataModel/RimEclipseCase.h index 8731b2b62c..16faea32cc 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCase.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCase.h @@ -39,10 +39,12 @@ class QString; class RigEclipseCaseData; class RigCaseCellResultsData; class RigGridBase; +class RigMainGrid; class RimCaseCollection; class RimIdenticalGridCaseGroup; class RimReservoirCellResultsStorage; class RimEclipseView; +class RigVirtualPerforationTransmissibilities; //================================================================================================== @@ -74,6 +76,8 @@ class RimEclipseCase : public RimCase const RigEclipseCaseData* eclipseCaseData() const; cvf::Color3f defaultWellColor(const QString& wellName); + const RigMainGrid* mainGrid() const; + RigCaseCellResultsData* results(RiaDefines::PorosityModelType porosityModel); const RigCaseCellResultsData* results(RiaDefines::PorosityModelType porosityModel) const; @@ -83,7 +87,7 @@ class RimEclipseCase : public RimCase RimEclipseView* createAndAddReservoirView(); RimEclipseView* createCopyAndAddView(const RimEclipseView* sourceView); - void recalculateCompletionTypeAndRedrawAllViews(); + const RigVirtualPerforationTransmissibilities* computeAndGetVirtualPerforationTransmissibilities(); virtual QString locationOnDisc() const { return QString(); } virtual QString gridFileName() const { return QString(); } @@ -91,7 +95,6 @@ class RimEclipseCase : public RimCase RimCaseCollection* parentCaseCollection(); - virtual std::vector views(); virtual QStringList timeStepStrings() const override; virtual QString timeStepName(int frameIdx) const override; virtual std::vector timeStepDates() const override; @@ -112,6 +115,7 @@ class RimEclipseCase : public RimCase protected: virtual void initAfterRead(); virtual void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ); + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void updateFormationNamesData() override; @@ -122,6 +126,7 @@ class RimEclipseCase : public RimCase private: void createTimeStepFormatString(); + virtual std::vector allSpecialViews() const override; private: cvf::ref m_rigEclipseCase; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp index db6bf8bf95..fe3d9148dd 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -29,7 +29,7 @@ #include "RimEclipseCase.h" #include "RimEclipseFaultColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimTernaryLegendConfig.h" @@ -70,7 +70,7 @@ RimEclipseCellColors::RimEclipseCellColors() //-------------------------------------------------------------------------------------------------- RimEclipseCellColors::~RimEclipseCellColors() { - CVF_ASSERT(obsoleteField_legendConfig() == NULL); + CVF_ASSERT(obsoleteField_legendConfig() == nullptr); m_legendConfigData.deleteAllChildObjects(); @@ -143,7 +143,7 @@ void RimEclipseCellColors::changeLegendConfig(QString resultVarNameOfNewLegend) // Not found ? if (!found) { - RimLegendConfig* newLegend = new RimLegendConfig; + RimRegularLegendConfig* newLegend = new RimRegularLegendConfig; newLegend->resultVariableName = resultVarNameOfNewLegend; m_legendConfigData.push_back(newLegend); @@ -168,10 +168,10 @@ void RimEclipseCellColors::initAfterRead() if (obsoleteField_legendConfig) { // The current legend config is NOT stored in in ResInsight up to v 1.3.7-dev - RimLegendConfig* obsoleteLegend = obsoleteField_legendConfig(); + RimRegularLegendConfig* obsoleteLegend = obsoleteField_legendConfig(); // set to NULL before pushing into container - obsoleteField_legendConfig = NULL; + obsoleteField_legendConfig = nullptr; m_legendConfigData.push_back(obsoleteLegend); m_legendConfigPtrField = obsoleteLegend; @@ -208,19 +208,19 @@ void RimEclipseCellColors::updateLegendCategorySettings() if (this->hasCategoryResult()) { - legendConfig()->setMappingMode(RimLegendConfig::CATEGORY_INTEGER); - legendConfig()->setColorRangeMode(RimLegendConfig::CATEGORY); + legendConfig()->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); + legendConfig()->setColorRange(RimRegularLegendConfig::CATEGORY); } else { - if (legendConfig()->mappingMode() == RimLegendConfig::CATEGORY_INTEGER) + if (legendConfig()->mappingMode() == RimRegularLegendConfig::CATEGORY_INTEGER) { - legendConfig()->setMappingMode(RimLegendConfig::LINEAR_CONTINUOUS); + legendConfig()->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS); } - if (legendConfig()->colorRangeMode() == RimLegendConfig::CATEGORY) + if (legendConfig()->colorRange() == RimRegularLegendConfig::CATEGORY) { - legendConfig()->setColorRangeMode(RimLegendConfig::NORMAL); + legendConfig()->setColorRange(RimRegularLegendConfig::NORMAL); } } } @@ -273,135 +273,229 @@ public : //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseCellColors::updateLegendData(size_t currentTimeStep) +void RimEclipseCellColors::updateLegendData(size_t currentTimeStep, + RimRegularLegendConfig* legendConfig, + RimTernaryLegendConfig* ternaryLegendConfig) { - if (this->isFlowDiagOrInjectionFlooding()) + if (!legendConfig) legendConfig = this->legendConfig(); + if (!ternaryLegendConfig) ternaryLegendConfig = this->ternaryLegendConfig(); + + if ( this->hasResult() ) { - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); - RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); + if ( this->isFlowDiagOrInjectionFlooding() ) + { + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + RigFlowDiagResults* flowResultsData = this->flowDiagSolution()->flowDiagResults(); + RigFlowDiagResultAddress resAddr = this->flowDiagResAddress(); - int integerTimeStep = static_cast(currentTimeStep); + int integerTimeStep = static_cast(currentTimeStep); - flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax); - flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero); + flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &globalMin, &globalMax); + flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &globalPosClosestToZero, &globalNegClosestToZero); - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if (this->hasDynamicResult()) - { - flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); - flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); - } - else - { - localMin = globalMin; - localMax = globalMax; + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) + { + flowResultsData->minMaxScalarValues(resAddr, integerTimeStep, &localMin, &localMax); + flowResultsData->posNegClosestToZero(resAddr, integerTimeStep, &localPosClosestToZero, &localNegClosestToZero); + } + else + { + localMin = globalMin; + localMax = globalMax; - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; + } - CVF_ASSERT(this->legendConfig()); + CVF_ASSERT(legendConfig); - this->legendConfig()->disableAllTimeStepsRange(true); - this->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - this->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + legendConfig->disableAllTimeStepsRange(true); + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, + localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - if (this->hasCategoryResult()) - { - std::set, TupleCompare > categories; - //std::set > categories; + if ( this->hasCategoryResult() ) + { + std::set, TupleCompare > categories; + //std::set > categories; + + std::vector tracerNames = this->flowDiagSolution()->tracerNames(); + int tracerIndex = 0; + for ( const auto& tracerName : tracerNames ) + { + RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName)); + cvf::Color3ub color(cvf::Color3::GRAY); + if ( well ) color = cvf::Color3ub(well->wellPipeColor()); + + categories.insert(std::make_tuple(tracerName, tracerIndex, color)); + ++tracerIndex; + } - std::vector tracerNames = this->flowDiagSolution()->tracerNames(); - int tracerIndex = 0; - for (const auto& tracerName : tracerNames) + std::vector> reverseCategories; + for ( auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt ) + { + reverseCategories.push_back(*tupIt); + } + + legendConfig->setCategoryItems(reverseCategories); + } + } + else + { + RimEclipseCase* rimEclipseCase = nullptr; + this->firstAncestorOrThisOfType(rimEclipseCase); + CVF_ASSERT(rimEclipseCase); + if ( !rimEclipseCase ) return; + + RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); + CVF_ASSERT(eclipseCase); + if ( !eclipseCase ) return; + + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); + CVF_ASSERT(cellResultsData); + + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), globalMin, globalMax); + cellResultsData->posNegClosestToZero(this->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + if ( this->hasDynamicResult() ) { - RimSimWellInView* well = m_reservoirView->wellCollection()->findWell(RimFlowDiagSolution::removeCrossFlowEnding(tracerName)); - cvf::Color3ub color(cvf::Color3::GRAY); - if (well) color = cvf::Color3ub(well->wellPipeColor()); + cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), currentTimeStep, localMin, localMax); + cellResultsData->posNegClosestToZero(this->scalarResultIndex(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); + } + else + { + localMin = globalMin; + localMax = globalMax; - categories.insert(std::make_tuple(tracerName, tracerIndex, color)); - ++tracerIndex; + localPosClosestToZero = globalPosClosestToZero; + localNegClosestToZero = globalNegClosestToZero; } - std::vector> reverseCategories; - for (auto tupIt = categories.rbegin(); tupIt != categories.rend(); ++tupIt) + CVF_ASSERT(legendConfig); + + legendConfig->disableAllTimeStepsRange(false); + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + if ( this->hasCategoryResult() ) { - reverseCategories.push_back(*tupIt); + if ( this->resultType() == RiaDefines::FORMATION_NAMES ) + { + const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); + legendConfig->setNamedCategoriesInverse(fnVector); + } + else if ( this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName() ) + { + std::vector< std::tuple > categories; + + caf::AppEnum wellPath(RiaDefines::WELL_PATH); + caf::AppEnum fishbone(RiaDefines::FISHBONES); + caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); + caf::AppEnum fracture(RiaDefines::FRACTURE); + + const std::vector& visibleCatetories = cellResultsData->uniqueCellScalarValues(this->scalarResultIndex()); + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), wellPath.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); + } + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), fishbone.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); + } + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), perforationInterval.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); + } + + if (std::find(visibleCatetories.begin(), visibleCatetories.end(), fracture.index()) != visibleCatetories.end()) + { + categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + } + + legendConfig->setCategoryItems(categories); + } + else + { + legendConfig->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->scalarResultIndex())); + } } - - this->legendConfig()->setCategoryItems(reverseCategories); } } - else + + // Ternary legend update { RimEclipseCase* rimEclipseCase = nullptr; this->firstAncestorOrThisOfType(rimEclipseCase); CVF_ASSERT(rimEclipseCase); - if (!rimEclipseCase) return; + if ( !rimEclipseCase ) return; RigEclipseCaseData* eclipseCase = rimEclipseCase->eclipseCaseData(); CVF_ASSERT(eclipseCase); - if (!eclipseCase) return; + if ( !eclipseCase ) return; - RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); - CVF_ASSERT(cellResultsData); - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), globalMin, globalMax); - cellResultsData->posNegClosestToZero(this->scalarResultIndex(), globalPosClosestToZero, globalNegClosestToZero); + RigCaseCellResultsData* cellResultsData = eclipseCase->results(this->porosityModel()); - double localMin, localMax; - double localPosClosestToZero, localNegClosestToZero; - if (this->hasDynamicResult()) + size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); + if ( this->isTernarySaturationSelected() && maxTimeStepCount > 1 ) { - cellResultsData->minMaxCellScalarValues(this->scalarResultIndex(), currentTimeStep, localMin, localMax); - cellResultsData->posNegClosestToZero(this->scalarResultIndex(), currentTimeStep, localPosClosestToZero, localNegClosestToZero); - } - else - { - localMin = globalMin; - localMax = globalMax; - - localPosClosestToZero = globalPosClosestToZero; - localNegClosestToZero = globalNegClosestToZero; - } - - CVF_ASSERT(this->legendConfig()); + RigCaseCellResultsData* gridCellResults = this->currentGridCellResults(); + { + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; - this->legendConfig()->disableAllTimeStepsRange(false); - this->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - this->legendConfig()->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); - if (this->hasCategoryResult()) - { - if (this->resultType() == RiaDefines::FORMATION_NAMES) - { - const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); - this->legendConfig()->setNamedCategoriesInverse(fnVector); + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); + } } - else if (this->resultType() == RiaDefines::DYNAMIC_NATIVE && this->resultVariable() == RiaDefines::completionTypeResultName()) - { - std::vector< std::tuple > categories; - caf::AppEnum wellPath(RiaDefines::WELL_PATH); - caf::AppEnum fishbone(RiaDefines::FISHBONES); - caf::AppEnum perforationInterval(RiaDefines::PERFORATION_INTERVAL); - caf::AppEnum fracture(RiaDefines::FRACTURE); + { + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; - categories.push_back(std::make_tuple(wellPath.uiText(), static_cast(wellPath.index()), cvf::Color3::RED)); - categories.push_back(std::make_tuple(fishbone.uiText(), static_cast(fishbone.index()), cvf::Color3::DARK_GREEN)); - categories.push_back(std::make_tuple(perforationInterval.uiText(), static_cast(perforationInterval.index()), cvf::Color3::GREEN)); - categories.push_back(std::make_tuple(fracture.uiText(), static_cast(fracture.index()), cvf::Color3::YELLOW_GREEN)); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); - legendConfig()->setCategoryItems(categories); + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); + } } - else + { - this->legendConfig()->setIntegerCategories(cellResultsData->uniqueCellScalarValues(this->scalarResultIndex())); + size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); + if ( scalarSetIndex != cvf::UNDEFINED_SIZE_T ) + { + double globalMin = 0.0; + double globalMax = 1.0; + double localMin = 0.0; + double localMax = 1.0; + + cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); + cellResultsData->minMaxCellScalarValues(scalarSetIndex, currentTimeStep, localMin, localMax); + + ternaryLegendConfig->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); + } } } } @@ -420,7 +514,7 @@ void RimEclipseCellColors::setResultVariable(const QString& val) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimEclipseCellColors::legendConfig() +RimRegularLegendConfig* RimEclipseCellColors::legendConfig() { return m_legendConfigPtrField; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h index 184be112e3..3962a7ecaa 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseCellColors.h @@ -27,7 +27,7 @@ #include "cafPdmPtrField.h" class RimTernaryLegendConfig; -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== /// @@ -43,8 +43,10 @@ class RimEclipseCellColors : public RimEclipseResultDefinition void setReservoirView(RimEclipseView* ownerReservoirView); RimEclipseView* reservoirView(); - void updateLegendData(size_t timestep); - RimLegendConfig* legendConfig(); + void updateLegendData(size_t timestep, + RimRegularLegendConfig* legendConfig = nullptr, + RimTernaryLegendConfig* ternaryLegendConfig = nullptr); + RimRegularLegendConfig* legendConfig(); caf::PdmChildField ternaryLegendConfig; virtual void setResultVariable(const QString& resultName); @@ -65,12 +67,12 @@ class RimEclipseCellColors : public RimEclipseResultDefinition private: void changeLegendConfig(QString resultVarNameOfNewLegend); - caf::PdmChildArrayField m_legendConfigData; - caf::PdmPtrField m_legendConfigPtrField; + caf::PdmChildArrayField m_legendConfigData; + caf::PdmPtrField m_legendConfigPtrField; caf::PdmPointer m_reservoirView; // Obsolete - caf::PdmChildField obsoleteField_legendConfig; + caf::PdmChildField obsoleteField_legendConfig; }; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp index 32a9b6918a..4810907227 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.cpp @@ -22,8 +22,6 @@ #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" -#include "RimLegendConfig.h" -#include "RimTernaryLegendConfig.h" #include "RiuMainWindow.h" @@ -56,7 +54,7 @@ RimEclipseFaultColors::RimEclipseFaultColors() RimEclipseFaultColors::~RimEclipseFaultColors() { delete m_customFaultResultColors; - m_customFaultResultColors = NULL; + m_customFaultResultColors = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -97,6 +95,14 @@ RimEclipseCellColors* RimEclipseFaultColors::customFaultResult() return this->m_customFaultResultColors(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseFaultColors::updateUiFieldsFromActiveResult() +{ + m_customFaultResultColors->updateUiFieldsFromActiveResult(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h index 458f185e45..2856bf484e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseFaultColors.h @@ -46,6 +46,8 @@ class RimEclipseFaultColors : public caf::PdmObject bool hasValidCustomResult(); RimEclipseCellColors* customFaultResult(); + void updateUiFieldsFromActiveResult(); + protected: virtual void initAfterRead(); virtual caf::PdmFieldHandle* objectToggleField(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp index 4bbefbf730..d3bcae58ba 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputCase.cpp @@ -103,7 +103,7 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames) return true; } - if (this->eclipseCaseData() == NULL) + if (this->eclipseCaseData() == nullptr) { this->setReservoirData(new RigEclipseCaseData(this)); } @@ -181,7 +181,7 @@ bool RimEclipseInputCase::openDataFileSet(const QStringList& fileNames) bool RimEclipseInputCase::openEclipseGridFile() { // Early exit if reservoir data is created - if (this->eclipseCaseData() == NULL) + if (this->eclipseCaseData() == nullptr) { cvf::ref readerInterface; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp index 8a44efb595..caf2e71ff2 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseInputPropertyCollection.cpp @@ -76,6 +76,6 @@ RimEclipseInputProperty * RimEclipseInputPropertyCollection::findInputProperty(Q } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp index 497ad0fc3d..ec2d91f925 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.cpp @@ -267,7 +267,7 @@ void RimEclipsePropertyFilter::updateRangeLabel() //-------------------------------------------------------------------------------------------------- bool RimEclipsePropertyFilter::isPropertyFilterControlled() { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfTypeAsserted(rimView); bool isPropertyFilterControlled = false; @@ -350,7 +350,7 @@ void RimEclipsePropertyFilter::computeResultValueRange() if (resultDefinition->isFlowDiagOrInjectionFlooding()) { - RimView* view; + Rim3dView* view; this->firstAncestorOrThisOfType(view); int timeStep = 0; @@ -390,7 +390,7 @@ void RimEclipsePropertyFilter::computeResultValueRange() else if (resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) { std::vector ctNames; - for (QString ctName : caf::AppEnum::uiTexts()) + for (const QString& ctName : caf::AppEnum::uiTexts()) { ctNames.push_back(ctName); } @@ -446,7 +446,7 @@ void RimEclipsePropertyFilter::updateFromCurrentTimeStep() clearCategories(); - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfTypeAsserted(view); int timeStep = view->currentTimeStep(); @@ -548,3 +548,11 @@ void RimEclipsePropertyFilter::initAfterRead() resultDefinition->setEclipseCase(parentContainer()->reservoirView()->eclipseCase()); updateIconState(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipsePropertyFilter::updateUiFieldsFromActiveResult() +{ + resultDefinition->updateUiFieldsFromActiveResult(); +} diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h index 36562035d8..506fb9a1b1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilter.h @@ -49,8 +49,10 @@ class RimEclipsePropertyFilter : public RimPropertyFilter void computeResultValueRange(); void updateFromCurrentTimeStep(); - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void initAfterRead(); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void initAfterRead() override; + + void updateUiFieldsFromActiveResult(); protected: virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); diff --git a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp index 9929da2fce..5c7709e76f 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipsePropertyFilterCollection.cpp @@ -56,7 +56,7 @@ RimEclipsePropertyFilterCollection::~RimEclipsePropertyFilterCollection() //-------------------------------------------------------------------------------------------------- RimEclipseView* RimEclipsePropertyFilterCollection::reservoirView() { - RimEclipseView* eclipseView = NULL; + RimEclipseView* eclipseView = nullptr; firstAncestorOrThisOfType(eclipseView); return eclipseView; @@ -143,7 +143,7 @@ void RimEclipsePropertyFilterCollection::updateIconState() { bool activeIcon = true; - RimEclipseView* view = NULL; + RimEclipseView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) { diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp index 334d08dad2..28c0c2d5a0 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultCase.cpp @@ -152,7 +152,7 @@ bool RimEclipseResultCase::importGridAndResultMetaData(bool showTimeStepFilter) m_timeStepFilter->setTimeStepsFromFile(timeSteps); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, m_timeStepFilter, "Time Step Filter", "", QDialogButtonBox::Ok | QDialogButtonBox::Cancel); propertyDialog.resize(QSize(400, 400)); if (propertyDialog.exec() != QDialog::Accepted) @@ -304,7 +304,7 @@ void RimEclipseResultCase::loadAndUpdateSourSimData() if (!hasSourSimFile()) { // Deselect SourSimRL cell results - for (RimView* view : views()) + for (Rim3dView* view : views()) { RimEclipseView* eclipseView = dynamic_cast(view); if (eclipseView != nullptr) @@ -387,7 +387,7 @@ cvf::ref RimEclipseResultCase::createMockModel(QString model RimMockModelSettings rimMockModelSettings; caf::PdmSettings::readFieldsFromApplicationStore(&rimMockModelSettings); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, &rimMockModelSettings, "Customize Mock Model", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, &rimMockModelSettings, "Customize Mock Model", ""); if (propertyDialog.exec() == QDialog::Accepted) { QApplication::restoreOverrideCursor(); diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp index ea528d28fc..0c0be159a1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.cpp @@ -25,6 +25,8 @@ #include "RigEclipseCaseData.h" #include "RigFlowDiagResultAddress.h" +#include "Rim3dView.h" +#include "Rim3dWellLogCurve.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" @@ -33,11 +35,11 @@ #include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "RimFlowDiagSolution.h" +#include "RimGridTimeHistoryCurve.h" +#include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimReservoirCellResultsStorage.h" -#include "RimView.h" #include "RimViewLinker.h" -#include "RimGridTimeHistoryCurve.h" #include "RimWellLogExtractionCurve.h" #include "cafPdmUiListEditor.h" @@ -335,6 +337,13 @@ void RimEclipseResultDefinition::updateAnyFieldHasChanged() { curve->updateConnectedEditors(); } + + Rim3dWellLogCurve* rim3dWellLogCurve = nullptr; + this->firstAncestorOrThisOfType(rim3dWellLogCurve); + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->resetMinMaxValuesAndUpdateUI(); + } } //-------------------------------------------------------------------------------------------------- @@ -377,7 +386,7 @@ void RimEclipseResultDefinition::assignFlowSolutionFromCase() //-------------------------------------------------------------------------------------------------- void RimEclipseResultDefinition::loadDataAndUpdate() { - RimView* view = nullptr; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); loadResult(); @@ -409,6 +418,8 @@ void RimEclipseResultDefinition::loadDataAndUpdate() { viewLinker->updateCellResult(); } + RimGridView* eclView = dynamic_cast(view); + if (eclView) eclView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } @@ -431,6 +442,13 @@ void RimEclipseResultDefinition::loadDataAndUpdate() { curve->loadDataAndUpdate(true); } + + Rim3dWellLogCurve* rim3dWellLogCurve = nullptr; + this->firstAncestorOrThisOfType(rim3dWellLogCurve); + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->updateCurveIn3dView(); + } } //-------------------------------------------------------------------------------------------------- @@ -745,7 +763,7 @@ RigFlowDiagResultAddress RimEclipseResultDefinition::flowDiagResAddress() const { size_t timeStep = 0; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { @@ -1057,6 +1075,15 @@ void RimEclipseResultDefinition::setSelectedSouringTracers(const std::vectorm_selectedSouringTracersUiField = selectedTracers; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseResultDefinition::updateUiFieldsFromActiveResult() +{ + m_resultTypeUiField = m_resultType; + m_resultVariableUiField = resultVariable(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h index 8e7aeb4058..d9d1ff188b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseResultDefinition.h @@ -99,6 +99,7 @@ class RimEclipseResultDefinition : public caf::PdmObject void setSelectedTracers(const std::vector& selectedTracers); void setSelectedSouringTracers(const std::vector& selectedTracers); + void updateUiFieldsFromActiveResult(); protected: virtual void updateLegendCategorySettings() {}; diff --git a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp index e03df89591..68c7cc305e 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseStatisticsCase.cpp @@ -39,6 +39,7 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTextEditor.h" #include "cafProgressInfo.h" +#include "RimIntersectionCollection.h" namespace caf { template<> @@ -200,7 +201,7 @@ void RimEclipseStatisticsCase::populateResultSelectionAfterLoadingGrid() //-------------------------------------------------------------------------------------------------- void RimEclipseStatisticsCase::computeStatistics() { - if (this->eclipseCaseData() == NULL) + if (this->eclipseCaseData() == nullptr) { openEclipseGridFile(); } @@ -335,7 +336,7 @@ RimIdenticalGridCaseGroup* RimEclipseStatisticsCase::caseGroup() return parentCollection->parentCaseGroup(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -685,12 +686,13 @@ void RimEclipseStatisticsCase::updateConnectedEditorsAndReservoirViews() if (reservoirViews[i]) { // As new result might have been introduced, update all editors connected - reservoirViews[i]->cellResult->updateConnectedEditors(); + reservoirViews[i]->cellResult()->updateConnectedEditors(); // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required reservoirViews[i]->hasUserRequestedAnimation = true; reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp index 49cc223a6f..969156944b 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.cpp +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.cpp @@ -21,6 +21,7 @@ #include "RimEclipseView.h" #include "RiaApplication.h" +#include "RiaColorTables.h" #include "RiaPreferences.h" #include "RigActiveCellInfo.h" @@ -32,6 +33,7 @@ #include "RigResultAccessor.h" #include "RigResultAccessorFactory.h" #include "RigSimWellData.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "Rim3dOverlayInfoConfig.h" #include "RimCellEdgeColors.h" @@ -48,7 +50,7 @@ #include "RimGridCollection.h" #include "RimIntersection.h" #include "RimIntersectionCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimOilField.h" #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" @@ -58,6 +60,7 @@ #include "RimTernaryLegendConfig.h" #include "RimViewController.h" #include "RimViewLinker.h" +#include "RimVirtualPerforationResults.h" #include "RimWellPathCollection.h" #include "RiuMainWindow.h" @@ -68,13 +71,12 @@ #include "RivReservoirViewPartMgr.h" #include "RivSingleCellPartGenerator.h" #include "RivTernarySaturationOverlayItem.h" +#include "RivWellPathsPartMgr.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFracture.h" #include "RimFractureTemplateCollection.h" #include "RimSimWellFracture.h" #include "RivWellFracturePartMgr.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "cafCadNavigation.h" @@ -82,10 +84,10 @@ #include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" #include "cafPdmUiTreeOrdering.h" +#include "cafOverlayScalarMapperLegend.h" #include "cvfDrawable.h" #include "cvfModelBasicList.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfPart.h" #include "cvfScene.h" #include "cvfViewport.h" @@ -109,52 +111,54 @@ RimEclipseView::RimEclipseView() CAF_PDM_InitObject("Reservoir View", ":/3DView16x16.png", "", ""); - CAF_PDM_InitFieldNoDefault(&cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); - cellResult = new RimEclipseCellColors(); - cellResult.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_cellResult, "GridCellResult", "Cell Result", ":/CellResult.png", "", ""); + m_cellResult = new RimEclipseCellColors(); + m_cellResult.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", ""); - cellEdgeResult = new RimCellEdgeColors(); - cellEdgeResult.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_cellEdgeResult, "GridCellEdgeResult", "Cell Edge Result", ":/EdgeResult_1.png", "", ""); + m_cellEdgeResult = new RimCellEdgeColors(); + m_cellEdgeResult.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&faultResultSettings, "FaultResultSettings", "Separate Fault Result", "", "", ""); - faultResultSettings = new RimEclipseFaultColors(); - faultResultSettings.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_faultResultSettings, "FaultResultSettings", "Separate Fault Result", "", "", ""); + m_faultResultSettings = new RimEclipseFaultColors(); + m_faultResultSettings.uiCapability()->setUiHidden(true); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - CAF_PDM_InitFieldNoDefault(&stimPlanColors, "StimPlanColors", "Fracture Colors", "", "", ""); - stimPlanColors = new RimStimPlanColors(); - stimPlanColors.uiCapability()->setUiHidden(true); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + CAF_PDM_InitFieldNoDefault(&m_fractureColors, "StimPlanColors", "Fracture", "", "", ""); + m_fractureColors = new RimStimPlanColors(); + m_fractureColors.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&wellCollection, "WellCollection", "Simulation Wells", "", "", ""); - wellCollection = new RimSimWellInViewCollection; - wellCollection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_virtualPerforationResult, "VirtualPerforationResult", "", "", "", ""); + m_virtualPerforationResult = new RimVirtualPerforationResults(); + m_virtualPerforationResult.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&faultCollection, "FaultCollection", "Faults", "", "", ""); - faultCollection = new RimFaultInViewCollection; - faultCollection.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_wellCollection, "WellCollection", "Simulation Wells", "", "", ""); + m_wellCollection = new RimSimWellInViewCollection; + m_wellCollection.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_faultCollection, "FaultCollection", "Faults", "", "", ""); + m_faultCollection = new RimFaultInViewCollection; + m_faultCollection.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); m_propertyFilterCollection = new RimEclipsePropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->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", "", "", ""); + CAF_PDM_InitField(&m_showMainGrid, "ShowMainGrid", true, "Show Main Grid", "", "", ""); + CAF_PDM_InitField(&m_showInactiveCells, "ShowInactiveCells", false, "Show Inactive Cells", "", "", ""); + CAF_PDM_InitField(&m_showInvalidCells, "ShowInvalidCells", false, "Show Invalid Cells", "", "", ""); this->cellResult()->setReservoirView(this); this->cellEdgeResult()->setReservoirView(this); - this->cellEdgeResult()->legendConfig()->setColorRangeMode(RimLegendConfig::PINK_WHITE); + this->cellEdgeResult()->legendConfig()->setColorRange(RimRegularLegendConfig::PINK_WHITE); this->faultResultSettings()->setReservoirView(this); m_reservoirGridPartManager = new RivReservoirViewPartMgr(this); m_simWellsPartManager = new RivReservoirSimWellsPartMgr(this); - - m_eclipseCase = NULL; + + m_eclipseCase = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -172,9 +176,65 @@ RimEclipseView::~RimEclipseView() m_reservoirGridPartManager->clearGeometryCache(); - m_eclipseCase = NULL; + m_eclipseCase = nullptr; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCellColors* RimEclipseView::cellResult() const +{ + return m_cellResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCellEdgeColors* RimEclipseView::cellEdgeResult() const +{ + return m_cellEdgeResult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseFaultColors* RimEclipseView::faultResultSettings() const +{ + return m_faultResultSettings; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStimPlanColors* RimEclipseView::fractureColors() const +{ + return m_fractureColors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSimWellInViewCollection* RimEclipseView::wellCollection() const +{ + return m_wellCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultInViewCollection* RimEclipseView::faultCollection() const +{ + return m_faultCollection; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVirtualPerforationResults* RimEclipseView::virtualPerforationResult() const +{ + return m_virtualPerforationResult(); +} //-------------------------------------------------------------------------------------------------- /// Clamp the current timestep to actual possibilities @@ -216,16 +276,16 @@ void RimEclipseView::setVisibleGridPartsWatertight() //-------------------------------------------------------------------------------------------------- void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimView::fieldChangedByUi(changedField, oldValue, newValue); + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); - if (changedField == &showInvalidCells) + if (changedField == &m_showInvalidCells) { this->scheduleGeometryRegen(INACTIVE); this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); scheduleCreateDisplayModelAndRedraw(); } - else if (changedField == &showInactiveCells) + else if (changedField == &m_showInactiveCells) { this->updateGridBoxData(); @@ -234,7 +294,7 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c scheduleCreateDisplayModelAndRedraw(); } - else if (changedField == &showMainGrid) + else if (changedField == &m_showMainGrid) { scheduleCreateDisplayModelAndRedraw(); } @@ -251,8 +311,6 @@ void RimEclipseView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c scheduleCreateDisplayModelAndRedraw(); } - - } //-------------------------------------------------------------------------------------------------- @@ -326,7 +384,7 @@ void RimEclipseView::createDisplayModel() // The parts are still cached in the RivReservoir geometry and friends m_viewer->removeAllFrames(); - wellCollection->scheduleIsWellPipesVisibleRecalculation(); + wellCollection()->scheduleIsWellPipesVisibleRecalculation(); // Create vector of grid indices to render std::vector gridIndices; @@ -340,7 +398,8 @@ void RimEclipseView::createDisplayModel() if (!this->eclipsePropertyFilterCollection()->hasActiveFilters() - || this->viewController() && this->viewController()->isVisibleCellsOveridden()) + || ( this->viewController() + && this->viewController()->isVisibleCellsOveridden()) ) { std::vector geometryTypesToAdd; @@ -393,28 +452,41 @@ void RimEclipseView::createDisplayModel() { for (size_t gtIdx = 0; gtIdx < geometryTypesToAdd.size(); ++gtIdx) { - m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryTypesToAdd[gtIdx], gridIndices); + if ( isGridVisualizationMode() ) + { + m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryTypesToAdd[gtIdx], gridIndices); + } + else + { + m_reservoirGridPartManager->ensureStaticGeometryPartsCreated( geometryTypesToAdd[gtIdx]); + } } } - // Set static colors this->updateStaticCellColors(); } + else + { + std::vector empty; + setVisibleGridParts(empty); + } m_reservoirGridPartManager->clearWatertightGeometryFlags(); - if (faultCollection()->showFaultsOutsideFilters() || !this->eclipsePropertyFilterCollection()->hasActiveFilters() ) + if ( faultCollection()->showFaultCollection() + || !this->eclipsePropertyFilterCollection()->hasActiveFilters() ) { setVisibleGridPartsWatertight(); std::set faultGeometryTypesToAppend = allVisibleFaultGeometryTypes(); - RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->showFaultsOutsideFilters()); + RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->isShowingFaultsAndFaultsOutsideFilters()); for (size_t frameIdx = 0; frameIdx < frameModels.size(); ++frameIdx) { for (RivCellSetEnum geometryType : faultGeometryTypesToAppend) { if (geometryType == PROPERTY_FILTERED || geometryType == PROPERTY_FILTERED_WELL_CELLS) continue; + m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameModels[frameIdx].p(), geometryType); } @@ -426,49 +498,20 @@ void RimEclipseView::createDisplayModel() // Cross sections m_crossSectionVizModel->removeAllParts(); - crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); + m_crossSectionCollection->appendPartsToModel(*this, m_crossSectionVizModel.p(), m_reservoirGridPartManager->scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); - - // Compute triangle count, Debug only -/* - if (false) - { - size_t totalTriangleCount = 0; - { - size_t mIdx; - for (mIdx = 0; mIdx < frameModels.size(); mIdx++) - { - cvf::Collection partCollection; - frameModels.at(mIdx)->allParts(&partCollection); - - size_t modelTriangleCount = 0; - size_t pIdx; - for (pIdx = 0; pIdx < partCollection.size(); pIdx++) - { - modelTriangleCount += partCollection.at(pIdx)->drawable()->triangleCount(); - } - - totalTriangleCount += modelTriangleCount; - } - } - } -*/ // Well path model m_wellPathPipeVizModel->removeAllParts(); // NB! StimPlan legend colors must be updated before well path geometry is added to the model // as the fracture geometry depends on the StimPlan legend colors -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - stimPlanColors->updateLegendData(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + fractureColors()->updateLegendData(); addWellPathsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - wellPathCollection()->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), *this); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + m_wellPathsPartManager->appendStaticFracturePartsToModel(m_wellPathPipeVizModel.p(), currentActiveCellInfo()->geometryBoundingBox()); m_wellPathPipeVizModel->updateBoundingBoxesRecursive(); m_viewer->addStaticModelOnce(m_wellPathPipeVizModel.p()); @@ -539,10 +582,18 @@ void RimEclipseView::updateCurrentTimeStep() this->indicesToVisibleGrids(&gridIndices); geometriesToRecolor.push_back( PROPERTY_FILTERED); - m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep, gridIndices); - geometriesToRecolor.push_back( PROPERTY_FILTERED_WELL_CELLS); - m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, gridIndices); + + if ( isGridVisualizationMode() ) + { + m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED, m_currentTimeStep, gridIndices); + m_reservoirGridPartManager->appendDynamicGeometryPartsToModel(frameParts.p(), PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep, gridIndices); + } + else + { + m_reservoirGridPartManager->ensureDynamicGeometryPartsCreated(PROPERTY_FILTERED, m_currentTimeStep); + m_reservoirGridPartManager->ensureDynamicGeometryPartsCreated(PROPERTY_FILTERED_WELL_CELLS, m_currentTimeStep); + } setVisibleGridParts(geometriesToRecolor); setVisibleGridPartsWatertight(); @@ -560,7 +611,7 @@ void RimEclipseView::updateCurrentTimeStep() } } - RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->showFaultsOutsideFilters()); + RivCellSetEnum faultLabelType = m_reservoirGridPartManager->geometryTypeForFaultLabels(faultGeometryTypesToAppend, faultCollection()->isShowingFaultsAndFaultsOutsideFilters()); if (faultLabelType == PROPERTY_FILTERED) { m_reservoirGridPartManager->appendFaultLabelsDynamicGeometryPartsToModel(frameParts.p(), faultLabelType, m_currentTimeStep); @@ -584,7 +635,7 @@ void RimEclipseView::updateCurrentTimeStep() { m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), RANGE_FILTERED_INACTIVE, gridIndices); - if (!faultCollection()->showFaultsOutsideFilters()) + if (!faultCollection()->isShowingFaultsAndFaultsOutsideFilters()) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), RANGE_FILTERED_INACTIVE); } @@ -593,7 +644,7 @@ void RimEclipseView::updateCurrentTimeStep() { m_reservoirGridPartManager->appendStaticGeometryPartsToModel(frameParts.p(), INACTIVE, gridIndices); - if (!faultCollection()->showFaultsOutsideFilters()) + if (!faultCollection()->isShowingFaultsAndFaultsOutsideFilters()) { m_reservoirGridPartManager->appendFaultsStaticGeometryPartsToModel(frameParts.p(), INACTIVE); } @@ -655,11 +706,13 @@ void RimEclipseView::updateCurrentTimeStep() if ((this->hasUserRequestedAnimation() && this->cellResult()->hasResult()) || this->cellResult()->isTernarySaturationSelected()) { - crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep, + this->cellResult()->legendConfig()->scalarMapper(), + this->cellResult()->ternaryLegendConfig()->scalarMapper()); } else { - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); } if (m_viewer) @@ -698,7 +751,6 @@ void RimEclipseView::updateCurrentTimeStep() } // Sim Well Fractures -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES { cvf::String name = "SimWellFracturesModel"; this->removeModelByName(frameScene, name); @@ -729,7 +781,6 @@ void RimEclipseView::updateCurrentTimeStep() simWellFracturesModelBasicList->updateBoundingBoxesRecursive(); frameScene->addModel(simWellFracturesModelBasicList.p()); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } } @@ -737,7 +788,7 @@ void RimEclipseView::updateCurrentTimeStep() // Invisible Wells are marked as read only when "show wells intersecting visible cells" is enabled // Visibility of wells differ betweeen time steps, so trigger a rebuild of tree state items - wellCollection->updateConnectedEditors(); + wellCollection()->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -754,21 +805,19 @@ void RimEclipseView::onLoadDataAndUpdate() QMessageBox::warning(RiuMainWindow::instance(), "Error when opening project file", "Could not open the Eclipse Grid file: \n"+ m_eclipseCase->gridFileName()); - this->setEclipseCase( NULL); + this->setEclipseCase( nullptr); return; } } - CVF_ASSERT(this->cellResult() != NULL); + CVF_ASSERT(this->cellResult() != nullptr); this->cellResult()->loadResult(); - CVF_ASSERT(this->cellEdgeResult() != NULL); + CVF_ASSERT(this->cellEdgeResult() != nullptr); this->cellEdgeResult()->loadResult(); this->faultResultSettings()->customFaultResult()->loadResult(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - this->stimPlanColors->loadDataAndUpdate(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + this->fractureColors()->loadDataAndUpdate(); updateMdiWindowVisibility(); @@ -782,7 +831,6 @@ void RimEclipseView::onLoadDataAndUpdate() syncronizeWellsWithResults(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES { // Update simulation well fractures after well cell results are imported @@ -793,7 +841,11 @@ void RimEclipseView::onLoadDataAndUpdate() fracture->loadDataAndUpdate(); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + + if (this->isVirtualConnectionFactorGeometryVisible()) + { + m_virtualPerforationResult->loadData(); + } this->scheduleCreateDisplayModelAndRedraw(); } @@ -805,7 +857,7 @@ void RimEclipseView::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- void RimEclipseView::initAfterRead() { - RimViewWindow::initAfterRead(); + RimGridView::initAfterRead(); this->faultResultSettings()->setReservoirView(this); this->cellResult()->setReservoirView(this); @@ -851,10 +903,10 @@ void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType) color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; case VISIBLE_WELL_FENCE_CELLS_OUTSIDE_RANGE_FILTER: color = cvf::Color4f(cvf::Color3::ORANGE); break; - case INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; + case INACTIVE: color = cvf::Color4f(RiaColorTables::undefinedCellColor()); break; case RANGE_FILTERED: color = cvf::Color4f(cvf::Color3::ORANGE); break; case RANGE_FILTERED_WELL_CELLS: color = cvf::Color4f(cvf::Color3f(cvf::Color3::BROWN), opacity ); break; - case RANGE_FILTERED_INACTIVE: color = cvf::Color4f(cvf::Color3::LIGHT_GRAY); break; + case RANGE_FILTERED_INACTIVE: color = cvf::Color4f(RiaColorTables::undefinedCellColor()); break; } if (geometryType == PROPERTY_FILTERED || geometryType == PROPERTY_FILTERED_WELL_CELLS) @@ -874,49 +926,16 @@ void RimEclipseView::updateStaticCellColors(RivCellSetEnum geometryType) //-------------------------------------------------------------------------------------------------- void RimEclipseView::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 + Rim3dView::updateDisplayModelVisibility(); - 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(); - - faultCollection->updateConnectedEditors(); + faultCollection()->updateConnectedEditors(); // This is required to update the read-only state of simulation wells // when a range filter is manipulated and visible simulation wells might change // // The visibility is controlled by RimEclipseWell::defineUiTreeOrdering // updateConnectedEditors will call recursively on child objects - wellCollection->updateConnectedEditors(); + wellCollection()->updateConnectedEditors(); } //-------------------------------------------------------------------------------------------------- @@ -926,10 +945,10 @@ RigCaseCellResultsData* RimEclipseView::currentGridCellResults() { if (m_eclipseCase) { - return m_eclipseCase->results(cellResult->porosityModel()); + return m_eclipseCase->results(cellResult()->porosityModel()); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -941,10 +960,10 @@ RigActiveCellInfo* RimEclipseView::currentActiveCellInfo() m_eclipseCase->eclipseCaseData() ) { - return m_eclipseCase->eclipseCaseData()->activeCellInfo(cellResult->porosityModel()); + return m_eclipseCase->eclipseCaseData()->activeCellInfo(cellResult()->porosityModel()); } - return NULL; + return nullptr; } @@ -964,7 +983,7 @@ void RimEclipseView::scheduleGeometryRegen(RivCellSetEnum geometryType) } } - m_currentReservoirCellVisibility = NULL; + m_currentReservoirCellVisibility = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -989,7 +1008,7 @@ void RimEclipseView::scheduleSimWellGeometryRegen() //-------------------------------------------------------------------------------------------------- void RimEclipseView::indicesToVisibleGrids(std::vector* gridIndices) { - CVF_ASSERT(gridIndices != NULL); + CVF_ASSERT(gridIndices != nullptr); // Create vector of grid indices to render std::vector grids; @@ -1036,128 +1055,90 @@ void RimEclipseView::updateLegends() updateMinMaxValuesAndAddLegendToView(QString("Fault Results: \n"), this->currentFaultResultColors(), results); } - if (this->cellEdgeResult()->hasResult()) + if (this->cellEdgeResult()->legendConfig()->showLegend()) { - if (this->cellEdgeResult()->isUsingSingleVariable()) - { - this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep); - } - else + if (this->cellEdgeResult()->hasResult()) { - double globalMin, globalMax; - double globalPosClosestToZero, globalNegClosestToZero; - this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax); - this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero); + if (this->cellEdgeResult()->isUsingSingleVariable()) + { + this->cellEdgeResult()->singleVarEdgeResultColors()->updateLegendData(m_currentTimeStep); + } + else + { + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + this->cellEdgeResult()->minMaxCellEdgeValues(globalMin, globalMax); + this->cellEdgeResult()->posNegClosestToZero(globalPosClosestToZero, globalNegClosestToZero); - this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero); - this->cellEdgeResult()->legendConfig()->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax); + this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, globalPosClosestToZero, globalNegClosestToZero); + this->cellEdgeResult()->legendConfig()->setAutomaticRanges(globalMin, globalMax, globalMin, globalMax); - if (this->cellEdgeResult()->hasCategoryResult()) - { - if(cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RiaDefines::FORMATION_NAMES) + if (this->cellEdgeResult()->hasCategoryResult()) { - cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex())); - } - else - { - const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); - cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector); + if (cellEdgeResult()->singleVarEdgeResultColors()->resultType() != RiaDefines::FORMATION_NAMES) + { + cellEdgeResult()->legendConfig()->setIntegerCategories(results->uniqueCellScalarValues(cellEdgeResult()->singleVarEdgeResultColors()->scalarResultIndex())); + } + else + { + const std::vector& fnVector = eclipseCase->activeFormationNames()->formationNames(); + cellEdgeResult()->legendConfig()->setNamedCategoriesInverse(fnVector); + } } } - } - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); - this->cellEdgeResult()->legendConfig()->setTitle(cvfqt::Utils::toString(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName())); - } - else - { - this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0); - this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); + this->cellEdgeResult()->legendConfig()->setTitle(QString("Edge Results: \n") + this->cellEdgeResult()->resultVariableUiShortName()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->titledOverlayFrame()); + } + else + { + this->cellEdgeResult()->legendConfig()->setClosestToZeroValues(0, 0, 0, 0); + this->cellEdgeResult()->legendConfig()->setAutomaticRanges(cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE, cvf::UNDEFINED_DOUBLE); + } } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - RimLegendConfig* stimPlanLegend = stimPlanColors()->activeLegend(); - if (stimPlanLegend) + RimRegularLegendConfig* stimPlanLegend = fractureColors()->activeLegend(); + if (stimPlanLegend && stimPlanLegend->showLegend()) { - stimPlanColors->updateLegendData(); + fractureColors()->updateLegendData(); - if (stimPlanColors()->isChecked() && stimPlanLegend->legend()) + if (fractureColors()->isChecked() && stimPlanLegend->titledOverlayFrame()) { - m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->legend()); + m_viewer->addColorLegendToBottomLeftCorner(stimPlanLegend->titledOverlayFrame()); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + + if (m_virtualPerforationResult->showConnectionFactors() && m_virtualPerforationResult->legendConfig()->showLegend()) + { + updateVirtualConnectionLegendRanges(); + + RimRegularLegendConfig* virtLegend = m_virtualPerforationResult->legendConfig(); + m_viewer->addColorLegendToBottomLeftCorner(virtLegend->titledOverlayFrame()); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData) +void RimEclipseView::updateMinMaxValuesAndAddLegendToView(QString legendLabel, + RimEclipseCellColors* resultColors, + RigCaseCellResultsData* cellResultsData) { - if (resultColors->hasResult()) - { - resultColors->updateLegendData(m_currentTimeStep); + resultColors->updateLegendData(m_currentTimeStep); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->legend()); - resultColors->legendConfig()->setTitle(cvfqt::Utils::toString(legendLabel + resultColors->resultVariableUiShortName())); + if (resultColors->hasResult() && resultColors->legendConfig()->showLegend()) + { + resultColors->legendConfig()->setTitle(legendLabel + resultColors->resultVariableUiShortName()); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->legendConfig()->titledOverlayFrame()); } size_t maxTimeStepCount = cellResultsData->maxTimeStepCount(); if (resultColors->isTernarySaturationSelected() && maxTimeStepCount > 1) { - RigCaseCellResultsData* gridCellResults = resultColors->currentGridCellResults(); - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SOIL"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SOIL_IDX, globalMin, globalMax, localMin, localMax); - } - } - - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SGAS"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SGAS_IDX, globalMin, globalMax, localMin, localMax); - } - } - - { - size_t scalarSetIndex = gridCellResults->findOrLoadScalarResult(RiaDefines::DYNAMIC_NATIVE, "SWAT"); - if (scalarSetIndex != cvf::UNDEFINED_SIZE_T) - { - double globalMin = 0.0; - double globalMax = 1.0; - double localMin = 0.0; - double localMax = 1.0; - - cellResultsData->minMaxCellScalarValues(scalarSetIndex, globalMin, globalMax); - cellResultsData->minMaxCellScalarValues(scalarSetIndex, m_currentTimeStep, localMin, localMax); - - resultColors->ternaryLegendConfig()->setAutomaticRanges(RimTernaryLegendConfig::TERNARY_SWAT_IDX, globalMin, globalMax, localMin, localMax); - } - } - - if (resultColors->ternaryLegendConfig->legend()) + if (resultColors->ternaryLegendConfig->showLegend() && resultColors->ternaryLegendConfig->titledOverlayFrame()) { - resultColors->ternaryLegendConfig->legend()->setTitle(cvfqt::Utils::toString(legendLabel)); - m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->legend()); + resultColors->ternaryLegendConfig->setTitle(legendLabel); + m_viewer->addColorLegendToBottomLeftCorner(resultColors->ternaryLegendConfig->titledOverlayFrame()); } } } @@ -1208,7 +1189,7 @@ void RimEclipseView::syncronizeWellsWithResults() for (size_t wIdx = 0; wIdx < this->wellCollection()->wells().size(); ++wIdx) { RimSimWellInView* well = this->wellCollection()->wells()[wIdx]; - well->setSimWellData(NULL, -1); + well->setSimWellData(nullptr, -1); } bool isAnyWellCreated = false; @@ -1237,7 +1218,7 @@ void RimEclipseView::syncronizeWellsWithResults() { RimSimWellInView* well = this->wellCollection()->wells()[wIdx]; RigSimWellData* simWellData = well->simWellData(); - if (simWellData == NULL) + if (simWellData == nullptr) { delete well; } @@ -1280,7 +1261,7 @@ RivReservoirViewPartMgr * RimEclipseView::reservoirGridPartManager() //-------------------------------------------------------------------------------------------------- void RimEclipseView::calculateVisibleWellCellsIncFence(cvf::UByteArray* visibleCells, RigGridBase * grid) { - CVF_ASSERT(visibleCells != NULL); + CVF_ASSERT(visibleCells != nullptr); // Initialize the return array if (visibleCells->size() != grid->cellCount()) @@ -1400,7 +1381,7 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() { bool isDependingOnCompletionType = false; - if (cellResult->isCompletionTypeSelected()) + if (cellResult()->isCompletionTypeSelected()) { isDependingOnCompletionType = true; } @@ -1409,7 +1390,7 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() { std::vector metaData; cellEdgeResult()->cellEdgeMetaData(&metaData); - for (const auto cellEdgeMeta : metaData) + for (const auto& cellEdgeMeta : metaData) { if (cellEdgeMeta.m_resultVariable == RiaDefines::completionTypeResultName()) { @@ -1423,7 +1404,7 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() isDependingOnCompletionType = true; } - for (auto propFilter : m_propertyFilterCollection()->propertyFilters) + for (const auto& propFilter : m_propertyFilterCollection()->propertyFilters) { if (propFilter->isActive() && propFilter->resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) { @@ -1435,6 +1416,28 @@ void RimEclipseView::calculateCompletionTypeAndRedrawIfRequired() { this->loadDataAndUpdate(); } + + for (const auto& propFilter : m_propertyFilterCollection()->propertyFilters) + { + if (propFilter->isActive() && propFilter->resultDefinition->resultVariable() == RiaDefines::completionTypeResultName()) + { + propFilter->updateConnectedEditors(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::isVirtualConnectionFactorGeometryVisible() const +{ + if (!m_showWindow()) return false; + + if (!m_virtualPerforationResult->showConnectionFactors()) return false; + + // TODO: Consider check if no well paths are visible + + return true; } //-------------------------------------------------------------------------------------------------- @@ -1450,12 +1453,12 @@ const std::vector& RimEclipseView::visibleGridParts() const //-------------------------------------------------------------------------------------------------- void RimEclipseView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - RimView::defineUiOrdering(uiConfigName, uiOrdering); + Rim3dView::defineUiOrdering(uiConfigName, uiOrdering); caf::PdmUiGroup* cellGroup = uiOrdering.addNewGroup("Cell Visibility"); - cellGroup->add(&showMainGrid); - cellGroup->add(&showInactiveCells); - cellGroup->add(&showInvalidCells); + cellGroup->add(&m_showMainGrid); + cellGroup->add(&m_showInactiveCells); + cellGroup->add(&m_showInvalidCells); } //-------------------------------------------------------------------------------------------------- @@ -1469,7 +1472,7 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(cellResult()); uiTreeOrdering.add(cellEdgeResult()); uiTreeOrdering.add(faultResultSettings()); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES + uiTreeOrdering.add(wellCollection()); RimProject* project = RiaApplication::instance()->project(); CVF_ASSERT(project); @@ -1477,14 +1480,14 @@ void RimEclipseView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering if (oilfield && oilfield->fractureDefinitionCollection().notNull()) { - if (!oilfield->fractureDefinitionCollection()->fractureDefinitions.empty()) + if (!oilfield->fractureDefinitionCollection()->fractureTemplates().empty()) { - uiTreeOrdering.add(stimPlanColors()); + uiTreeOrdering.add(fractureColors()); } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - uiTreeOrdering.add(wellCollection()); + uiTreeOrdering.add(m_virtualPerforationResult); + uiTreeOrdering.add(faultCollection()); uiTreeOrdering.add(crossSectionCollection()); @@ -1502,7 +1505,7 @@ std::set RimEclipseView::allVisibleFaultGeometryTypes() const std::set faultGeoTypes; faultGeoTypes.insert(m_visibleGridParts.begin(), m_visibleGridParts.end()); - if (faultCollection()->showFaultsOutsideFilters()) + if (faultCollection()->isShowingFaultsAndFaultsOutsideFilters()) { faultGeoTypes.insert(ACTIVE); faultGeoTypes.insert(ALL_WELL_CELLS); @@ -1548,15 +1551,15 @@ bool RimEclipseView::isTimeStepDependentDataVisible() const if (this->eclipsePropertyFilterCollection()->hasActiveDynamicFilters()) return true; - if (this->wellCollection->hasVisibleWellPipes()) return true; + if (this->wellCollection()->hasVisibleWellPipes()) return true; if (this->cellResult()->isTernarySaturationSelected()) return true; - if (this->faultResultSettings->showCustomFaultResult()) + if (this->faultResultSettings()->showCustomFaultResult()) { - if (this->faultResultSettings->customFaultResult()->hasDynamicResult()) return true; + if (this->faultResultSettings()->customFaultResult()->hasDynamicResult()) return true; - if (this->faultResultSettings->customFaultResult()->isTernarySaturationSelected()) return true; + if (this->faultResultSettings()->customFaultResult()->isTernarySaturationSelected()) return true; } if (this->wellPathCollection()->anyWellsContainingPerforationIntervals()) return true; @@ -1585,7 +1588,7 @@ RimEclipseCellColors* RimEclipseView::currentFaultResultColors() //-------------------------------------------------------------------------------------------------- void RimEclipseView::resetLegendsInViewer() { - RimLegendConfig* cellResultNormalLegendConfig = this->cellResult()->legendConfig(); + RimRegularLegendConfig* cellResultNormalLegendConfig = this->cellResult()->legendConfig(); if (cellResultNormalLegendConfig) cellResultNormalLegendConfig->recreateLegend(); this->cellResult()->ternaryLegendConfig->recreateLegend(); @@ -1593,9 +1596,39 @@ void RimEclipseView::resetLegendsInViewer() m_viewer->removeAllColorLegends(); - if (cellResultNormalLegendConfig) m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->legend()); + if (cellResultNormalLegendConfig) + { + m_viewer->addColorLegendToBottomLeftCorner(cellResultNormalLegendConfig->titledOverlayFrame()); + } + + m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->titledOverlayFrame()); +} - m_viewer->addColorLegendToBottomLeftCorner(this->cellEdgeResult()->legendConfig()->legend()); +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEclipseView::updateVirtualConnectionLegendRanges() +{ + if (!eclipseCase()) return; + + const RigVirtualPerforationTransmissibilities* virtualTransmissibilities = eclipseCase()->computeAndGetVirtualPerforationTransmissibilities(); + if (virtualTransmissibilities) + { + double minValue = HUGE_VAL; + double maxValue = -HUGE_VAL; + double posClosestToZero = HUGE_VAL; + double negClosestToZero = -HUGE_VAL; + + virtualTransmissibilities->computeMinMax(&minValue, &maxValue, &posClosestToZero, &negClosestToZero); + + if (minValue != HUGE_VAL) + { + RimRegularLegendConfig* legendConfig = virtualPerforationResult()->legendConfig(); + + legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); + legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); + } + } } //-------------------------------------------------------------------------------------------------- @@ -1696,12 +1729,30 @@ void RimEclipseView::calculateCurrentTotalCellVisibility(cvf::UByteArray* totalV } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEclipseView::legendConfigs() const +{ + std::vector absLegends; + + absLegends.push_back(cellResult()->legendConfig()); + absLegends.push_back(cellResult()->ternaryLegendConfig()); + absLegends.push_back(faultResultSettings()->customFaultResult()->legendConfig()); + absLegends.push_back(faultResultSettings()->customFaultResult()->ternaryLegendConfig()); + absLegends.push_back(cellEdgeResult()->legendConfig()); + absLegends.push_back(fractureColors()->activeLegend()); + absLegends.push_back(virtualPerforationResult()->legendConfig()); + + return absLegends; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- bool RimEclipseView::showActiveCellsOnly() { - return !showInactiveCells; + return !m_showInactiveCells; } //-------------------------------------------------------------------------------------------------- @@ -1769,6 +1820,30 @@ bool RimEclipseView::isUsingFormationNames() const return eclipsePropertyFilterCollection()->isUsingFormationNames(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::showInvalidCells() const +{ + return m_showInvalidCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::showInactiveCells() const +{ + return m_showInactiveCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEclipseView::showMainGrid() const +{ + return m_showMainGrid; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimEclipseView.h b/ApplicationCode/ProjectDataModel/RimEclipseView.h index ddc07daabd..fe973c9ce1 100644 --- a/ApplicationCode/ProjectDataModel/RimEclipseView.h +++ b/ApplicationCode/ProjectDataModel/RimEclipseView.h @@ -33,7 +33,7 @@ #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" -#include "RimView.h" +#include "RimGridView.h" class RigActiveCellInfo; class RigCaseCellResultsData; @@ -53,9 +53,8 @@ class RimFaultInViewCollection; class RimReservoirCellResultsStorage; class RimReservoirCellResultsStorage; class RimSimWellInViewCollection; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimStimPlanColors; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES +class RimVirtualPerforationResults; class RiuViewer; class RivReservoirSimWellsPartMgr; class RivIntersectionPartMgr; @@ -69,42 +68,28 @@ namespace cvf class OverlayItem; } -enum PartRenderMaskEnum -{ - surfaceBit = 0x00000001, - meshSurfaceBit = 0x00000002, - faultBit = 0x00000004, - meshFaultBit = 0x00000008, -}; - //================================================================================================== /// /// //================================================================================================== -class RimEclipseView : public RimView +class RimEclipseView : public RimGridView { CAF_PDM_HEADER_INIT; public: - RimEclipseView(void); - virtual ~RimEclipseView(void); - - // Fields containing child objects : + RimEclipseView(); + virtual ~RimEclipseView(); - caf::PdmChildField cellResult; - caf::PdmChildField cellEdgeResult; - caf::PdmChildField faultResultSettings; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - caf::PdmChildField stimPlanColors; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES + RimEclipseCellColors* cellResult() const; + RimCellEdgeColors* cellEdgeResult() const; + RimEclipseFaultColors* faultResultSettings() const; + RimStimPlanColors* fractureColors() const; + RimSimWellInViewCollection* wellCollection() const; + RimFaultInViewCollection* faultCollection() const; + RimVirtualPerforationResults* virtualPerforationResult() const; - caf::PdmChildField wellCollection; - caf::PdmChildField faultCollection; - - // Fields - - caf::PdmField showInvalidCells; - caf::PdmField showInactiveCells; - caf::PdmField showMainGrid; + bool showInvalidCells() const; + bool showInactiveCells() const; + bool showMainGrid() const; // Access internal objects virtual const RimPropertyFilterCollection* propertyFilterCollection() const override; @@ -125,7 +110,7 @@ class RimEclipseView : public RimView // Display model generation - bool isTimeStepDependentDataVisible() const; + bool isTimeStepDependentDataVisible() const override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; void scheduleReservoirGridGeometryRegen(); @@ -134,6 +119,9 @@ class RimEclipseView : public RimView void calculateCompletionTypeAndRedrawIfRequired(); + bool isVirtualConnectionFactorGeometryVisible() const; + + const std::vector& visibleGridParts() const; const RivReservoirViewPartMgr* reservoirGridPartManager() const; RivReservoirViewPartMgr* reservoirGridPartManager(); @@ -150,6 +138,8 @@ class RimEclipseView : public RimView virtual bool isUsingFormationNames() const override; virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override; + + std::vector legendConfigs() const override; protected: virtual void initAfterRead() override; @@ -171,9 +161,10 @@ class RimEclipseView : public RimView virtual void updateStaticCellColors() override; void updateStaticCellColors(RivCellSetEnum geometryType); - void updateLegends(); + void updateLegends() override; void updateMinMaxValuesAndAddLegendToView(QString legendLabel, RimEclipseCellColors* resultColors, RigCaseCellResultsData* cellResultsData); virtual void resetLegendsInViewer() override; + void updateVirtualConnectionLegendRanges(); std::set allVisibleFaultGeometryTypes() const; void updateFaultColors(); @@ -185,6 +176,19 @@ class RimEclipseView : public RimView void setVisibleGridPartsWatertight(); private: + caf::PdmField m_showInvalidCells; + caf::PdmField m_showInactiveCells; + caf::PdmField m_showMainGrid; + + caf::PdmChildField m_cellResult; + caf::PdmChildField m_cellEdgeResult; + caf::PdmChildField m_faultResultSettings; + caf::PdmChildField m_fractureColors; + caf::PdmChildField m_virtualPerforationResult; + + caf::PdmChildField m_wellCollection; + caf::PdmChildField m_faultCollection; + caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; @@ -192,7 +196,6 @@ class RimEclipseView : public RimView cvf::ref m_reservoirGridPartManager; cvf::ref m_simWellsPartManager; - + std::vector m_visibleGridParts; }; - diff --git a/ApplicationCode/ProjectDataModel/RimFaultInView.cpp b/ApplicationCode/ProjectDataModel/RimFaultInView.cpp index 3844f92a0a..04deaa447a 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInView.cpp @@ -22,6 +22,7 @@ #include "RigFault.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimFaultInView, "Fault"); @@ -41,7 +42,7 @@ RimFaultInView::RimFaultInView() CAF_PDM_InitField(&faultColor, "Color", cvf::Color3f(0.588f, 0.588f, 0.804f), "Fault Color", "", "", ""); - m_rigFault = NULL; + m_rigFault = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -68,13 +69,14 @@ void RimFaultInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c if (&faultColor == changedField || &showFault == changedField) { - RimEclipseView* reservoirView = NULL; + RimEclipseView* reservoirView = nullptr; this->firstAncestorOrThisOfType(reservoirView); if (reservoirView) { reservoirView->scheduleCreateDisplayModelAndRedraw(); + reservoirView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp index 13e2d04f4e..5bfafccde1 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.cpp @@ -29,6 +29,7 @@ #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimFaultInView.h" +#include "RimIntersectionCollection.h" #include "RimNoCommonAreaNNC.h" #include "RimNoCommonAreaNncCollection.h" @@ -84,7 +85,7 @@ RimFaultInViewCollection::RimFaultInViewCollection() CAF_PDM_InitFieldNoDefault(&faults, "Faults", "Faults", "", "", ""); faults.uiCapability()->setUiHidden(true); - m_reservoirView = NULL; + m_reservoirView = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -108,6 +109,7 @@ void RimFaultInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang if (&faultLabelColor == changedField) { m_reservoirView->scheduleReservoirGridGeometryRegen(); + m_reservoirView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } if (&showFaultFaces == changedField || @@ -124,6 +126,7 @@ void RimFaultInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* chang if (m_reservoirView) { m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + m_reservoirView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } @@ -164,7 +167,7 @@ RimFaultInView* RimFaultInViewCollection::findFaultByName(QString name) return this->faults()[i]; } } - return NULL; + return nullptr; } @@ -282,10 +285,8 @@ void RimFaultInViewCollection::syncronizeFaults() QString secondConnectionText; { - const RigCell& cell = mainGrid->globalCellArray()[nncConnections[i].m_c1GlobIdx]; - - RigGridBase* hostGrid = cell.hostGrid(); - size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + size_t gridLocalCellIndex; + const RigGridBase* hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConnections[i].m_c1GlobIdx, &gridLocalCellIndex); size_t i, j, k; if (hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k)) @@ -305,10 +306,8 @@ void RimFaultInViewCollection::syncronizeFaults() } { - const RigCell& cell = mainGrid->globalCellArray()[nncConnections[i].m_c2GlobIdx]; - - RigGridBase* hostGrid = cell.hostGrid(); - size_t gridLocalCellIndex = cell.gridLocalCellIndex(); + size_t gridLocalCellIndex; + const RigGridBase* hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(nncConnections[i].m_c2GlobIdx, &gridLocalCellIndex); size_t i, j, k; if (hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k)) @@ -377,7 +376,7 @@ void RimFaultInViewCollection::defineUiOrdering(QString uiConfigName, caf::PdmUi //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimFaultInViewCollection::showFaultsOutsideFilters() const +bool RimFaultInViewCollection::isShowingFaultsAndFaultsOutsideFilters() const { if (!showFaultCollection) return false; diff --git a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h index 5dba0763f2..7e91ac2875 100644 --- a/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimFaultInViewCollection.h @@ -62,7 +62,7 @@ class RimFaultInViewCollection : public caf::PdmObject bool isGridVisualizationMode() const; - bool showFaultsOutsideFilters() const; + bool isShowingFaultsAndFaultsOutsideFilters() const; caf::PdmField showFaultFaces; caf::PdmField showOppositeFaultFaces; diff --git a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp index 5d91738cb7..fdb8a6db9d 100644 --- a/ApplicationCode/ProjectDataModel/RimFormationNames.cpp +++ b/ApplicationCode/ProjectDataModel/RimFormationNames.cpp @@ -22,7 +22,7 @@ #include "RimCase.h" #include "RimTools.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafPdmUiFilePathEditor.h" @@ -215,6 +215,6 @@ void RimFormationNames::readFormationNamesFile(QString * errorMessage) //-------------------------------------------------------------------------------------------------- void RimFormationNames::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - m_formationNamesFileName = RimTools::relocateFile(m_formationNamesFileName(), newProjectPath, oldProjectPath, NULL, NULL); + m_formationNamesFileName = RimTools::relocateFile(m_formationNamesFileName(), newProjectPath, oldProjectPath, nullptr, nullptr); } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp index 2032fe6ab1..2e4dd648f1 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.cpp @@ -26,23 +26,28 @@ #include "RigFemPartCollection.h" #include "RigFemPartResultsCollection.h" -#include "RigGeoMechCaseData.h" #include "RigFormationNames.h" +#include "RigGeoMechCaseData.h" +#include "Rim2dIntersectionViewCollection.h" +#include "RimFormationNames.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechPropertyFilter.h" +#include "RimGeoMechPropertyFilterCollection.h" +#include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimMainPlotCollection.h" #include "RimProject.h" #include "RimTools.h" #include "RimWellLogPlotCollection.h" -#include "RimFormationNames.h" -#include "RimGeoMechPropertyFilterCollection.h" -#include "RimGeoMechCellColors.h" -#include "RimGeoMechResultDefinition.h" -#include "RimGeoMechPropertyFilter.h" +#include "cafPdmUiPushButtonEditor.h" +#include "cafPdmUiTreeOrdering.h" #include "cafUtils.h" #include +#include CAF_PDM_SOURCE_INIT(RimGeoMechCase, "ResInsightGeoMechCase"); //-------------------------------------------------------------------------------------------------- @@ -52,7 +57,7 @@ RimGeoMechCase::RimGeoMechCase(void) { CAF_PDM_InitObject("Geomechanical Case", ":/GeoMechCase48x48.png", "", ""); - CAF_PDM_InitField(&m_caseFileName, "CaseFileName", QString(), "Case File Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_caseFileName, "CaseFileName", "Case File Name", "", "", ""); m_caseFileName.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&geoMechViews, "GeoMechViews", "", "", "", ""); geoMechViews.uiCapability()->setUiHidden(true); @@ -60,6 +65,16 @@ RimGeoMechCase::RimGeoMechCase(void) CAF_PDM_InitField(&m_cohesion, "CaseCohesion", 10.0, "Cohesion", "", "Used to calculate the SE:SFI result", ""); CAF_PDM_InitField(&m_frictionAngleDeg, "FrctionAngleDeg", 30.0, "Friction Angle [Deg]", "", "Used to calculate the SE:SFI result", ""); + CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNames, "ElementPropertyFileNames", "Element Property Files", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_elementPropertyFileNameIndexUiSelection, "ElementPropertyFileNameIndexUiSelection", "", "", "", ""); + m_elementPropertyFileNameIndexUiSelection.xmlCapability()->disableIO(); + + CAF_PDM_InitField(&m_closeElementPropertyFileCommand, "closeElementPropertyFileCommad", false, "", "", "", ""); + caf::PdmUiPushButtonEditor::configureEditorForField(&m_closeElementPropertyFileCommand); + + CAF_PDM_InitField(&m_reloadElementPropertyFileCommand, "reloadElementPropertyFileCommand", false, "", "", "", ""); + caf::PdmUiPushButtonEditor::configureEditorForField(&m_reloadElementPropertyFileCommand); } //-------------------------------------------------------------------------------------------------- @@ -94,7 +109,7 @@ RimGeoMechCase::~RimGeoMechCase(void) //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::setFileName(const QString& fileName) { - m_caseFileName = fileName; + m_caseFileName.v().setPath(fileName); } //-------------------------------------------------------------------------------------------------- @@ -102,7 +117,7 @@ void RimGeoMechCase::setFileName(const QString& fileName) //-------------------------------------------------------------------------------------------------- QString RimGeoMechCase::caseFileName() const { - return m_caseFileName(); + return m_caseFileName().path(); } //-------------------------------------------------------------------------------------------------- @@ -144,31 +159,41 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) // If read already, return if (this->m_geoMechCaseData.notNull()) return true; - if (!caf::Utils::fileExists(m_caseFileName())) + if (!caf::Utils::fileExists(m_caseFileName().path())) { return false; } - m_geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().toStdString()); + m_geoMechCaseData = new RigGeoMechCaseData(m_caseFileName().path().toStdString()); bool fileOpenSuccess = m_geoMechCaseData->openAndReadFemParts(errorMessage); if (!fileOpenSuccess) { // If opening failed, release all data // Also, several places is checked for this data to validate availability of data - m_geoMechCaseData = NULL; + m_geoMechCaseData = nullptr; + return false; + } + + if (activeFormationNames()) + { + m_geoMechCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData()); } else { - if ( activeFormationNames() ) - { - m_geoMechCaseData->femPartResults()->setActiveFormationNames(activeFormationNames()->formationNamesData()); - } - else + m_geoMechCaseData->femPartResults()->setActiveFormationNames(nullptr); + } + + if (m_geoMechCaseData.notNull()) + { + std::vector fileNames; + for (const caf::FilePath& fileName : m_elementPropertyFileNames.v()) { - m_geoMechCaseData->femPartResults()->setActiveFormationNames(nullptr); + fileNames.push_back(fileName.path()); } + geoMechData()->femPartResults()->addElementPropertyFiles(fileNames); } + return fileOpenSuccess; } @@ -177,26 +202,16 @@ bool RimGeoMechCase::openGeoMechCase(std::string* errorMessage) //-------------------------------------------------------------------------------------------------- void RimGeoMechCase::updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath) { - bool foundFile = false; - std::vector searchedPaths; - - // Update filename and folder paths when opening project from a different file location - m_caseFileName = RimTools::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 - + //No longer in use. Filepaths are now of type caf::FilePath, and updated in RimProject on load. } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RimGeoMechCase::views() +std::vector RimGeoMechCase::allSpecialViews() const { - std::vector views; + std::vector views; for (size_t vIdx = 0; vIdx < geoMechViews.size(); ++vIdx) { views.push_back(geoMechViews[vIdx]); @@ -204,6 +219,24 @@ std::vector RimGeoMechCase::views() return views; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + std::vector children; + geoMechViews.childObjects(&children); + + for ( auto child : children ) uiTreeOrdering.add(child); + + if (!m_2dIntersectionViewCollection->views().empty()) + { + uiTreeOrdering.add(&m_2dIntersectionViewCollection); + } + + uiTreeOrdering.skipRemainingChildren(true); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -316,6 +349,64 @@ void RimGeoMechCase::setFormationNames(RimFormationNames* formationNames) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::addElementPropertyFiles(const std::vector& fileNames) +{ + std::vector newFileNames; + + for (const caf::FilePath& newFileNameToPossiblyAdd : fileNames) + { + bool fileAlreadyAdded = false; + + for (const caf::FilePath& existingFileName : m_elementPropertyFileNames()) + { + if (existingFileName == newFileNameToPossiblyAdd) + { + fileAlreadyAdded = true; + break; + } + } + if (!fileAlreadyAdded) + { + newFileNames.push_back(newFileNameToPossiblyAdd.path()); + m_elementPropertyFileNames.v().push_back(newFileNameToPossiblyAdd); + } + } + + this->updateConnectedEditors(); + + if (m_geoMechCaseData.notNull()) + { + geoMechData()->femPartResults()->addElementPropertyFiles(newFileNames); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGeoMechCase::cohesion() const +{ + return m_cohesion; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimGeoMechCase::frictionAngleDeg() const +{ + return m_frictionAngleDeg; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec3d RimGeoMechCase::displayModelOffset() const +{ + return this->allCellsBoundingBox().min(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -360,8 +451,8 @@ void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c rigCaseData->femPartResults()->setCalculationParameters(m_cohesion(), cvf::Math::toRadians(m_frictionAngleDeg())); } - std::vector views = this->views(); - for ( RimView* view : views ) + std::vector views = this->views(); + for ( Rim3dView* view : views ) { if ( view ) // Todo: only those using the variable actively { @@ -369,6 +460,18 @@ void RimGeoMechCase::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c } } } + else if (changedField == &m_reloadElementPropertyFileCommand) + { + m_reloadElementPropertyFileCommand = false; + reloadSelectedElementPropertyFiles(); + updateConnectedEditors(); + } + else if (changedField == &m_closeElementPropertyFileCommand) + { + m_closeElementPropertyFileCommand = false; + closeSelectedElementPropertyFiles(); + updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- @@ -388,8 +491,8 @@ void RimGeoMechCase::updateFormationNamesData() rigCaseData->femPartResults()->setActiveFormationNames(nullptr); } - std::vector views = this->views(); - for(RimView* view : views) + std::vector views = this->views(); + for(Rim3dView* view : views) { RimGeoMechView* geomView = dynamic_cast(view); @@ -427,6 +530,7 @@ void RimGeoMechCase::updateFormationNamesData() view->scheduleGeometryRegen(PROPERTY_FILTERED); view->scheduleCreateDisplayModelAndRedraw(); + geomView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } @@ -461,6 +565,84 @@ QString RimGeoMechCase::subStringOfDigits(const QString& inputString, int number return ""; } +struct descendingComparator +{ + template + bool operator()(T const &a, T const &b) const { return a > b; } +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::closeSelectedElementPropertyFiles() +{ + std::sort(m_elementPropertyFileNameIndexUiSelection.v().begin(), m_elementPropertyFileNameIndexUiSelection.v().end(), descendingComparator()); + + std::vector filesToClose; + + for (size_t idx : m_elementPropertyFileNameIndexUiSelection.v()) + { + filesToClose.push_back(m_elementPropertyFileNames.v().at(idx).path()); + m_elementPropertyFileNames.v().erase(m_elementPropertyFileNames.v().begin() + idx); + } + + m_elementPropertyFileNameIndexUiSelection.v().clear(); + + std::vector addressesToDelete; + + if (m_geoMechCaseData.notNull()) + { + addressesToDelete = geoMechData()->femPartResults()->removeElementPropertyFiles(filesToClose); + } + + for (RimGeoMechView* view : geoMechViews()) + { + for (RigFemResultAddress address : addressesToDelete) + { + if (address == view->cellResultResultDefinition()->resultAddress()) + { + view->cellResult()->setResultAddress(RigFemResultAddress()); + } + + for (RimGeoMechPropertyFilter* propertyFilter : view->geoMechPropertyFilterCollection()->propertyFilters()) + { + if (address == propertyFilter->resultDefinition->resultAddress()) + { + propertyFilter->resultDefinition->setResultAddress(RigFemResultAddress()); + } + } + } + + view->loadDataAndUpdate(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::reloadSelectedElementPropertyFiles() +{ + std::vector filesToReload; + + for (size_t idx : m_elementPropertyFileNameIndexUiSelection.v()) + { + filesToReload.push_back(m_elementPropertyFileNames.v().at(idx).path()); + } + + m_elementPropertyFileNameIndexUiSelection.v().clear(); + + if (m_geoMechCaseData.notNull()) + { + geoMechData()->femPartResults()->removeElementPropertyFiles(filesToReload); + geoMechData()->femPartResults()->addElementPropertyFiles(filesToReload); + } + + for (RimGeoMechView* view : geoMechViews()) + { + view->loadDataAndUpdate(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -470,10 +652,48 @@ void RimGeoMechCase::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering.add(&caseId); uiOrdering.add(&m_caseFileName); - auto group = uiOrdering.addNewGroup("Case Options"); - group->add(&activeFormationNames); - group->add(&m_cohesion); - group->add(&m_frictionAngleDeg); + caf::PdmUiGroup* caseGroup = uiOrdering.addNewGroup("Case Options"); + caseGroup->add(&activeFormationNames); + caseGroup->add(&m_cohesion); + caseGroup->add(&m_frictionAngleDeg); + caf::PdmUiGroup* elmPropGroup = uiOrdering.addNewGroup("Element Properties"); + elmPropGroup->add(&m_elementPropertyFileNameIndexUiSelection); + elmPropGroup->add(&m_reloadElementPropertyFileCommand); + elmPropGroup->add(&m_closeElementPropertyFileCommand); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechCase::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_reloadElementPropertyFileCommand) + { + dynamic_cast (attribute)->m_buttonText = "Reload Case(s)"; + } + if (field == &m_closeElementPropertyFileCommand) + { + dynamic_cast (attribute)->m_buttonText = "Close Case(s)"; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimGeoMechCase::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) +{ + QList options; + + options = RimCase::calculateValueOptions(fieldNeedingOptions, useOptionsOnly); + + if (fieldNeedingOptions == &m_elementPropertyFileNameIndexUiSelection) + { + for (size_t i = 0; i < m_elementPropertyFileNames.v().size(); i++) + { + options.push_back(caf::PdmOptionItemInfo(m_elementPropertyFileNames.v().at(i).path(), (int)i, true, QIcon())); + } + } + + return options; +} diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h index b16f458535..3caae63564 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCase.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCase.h @@ -21,6 +21,7 @@ #include "RimCase.h" +#include "cafFilePath.h" #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" @@ -56,37 +57,56 @@ class RimGeoMechCase : public RimCase RimGeoMechView* createAndAddReservoirView(); virtual void updateFilePathsFromProjectPath(const QString& projectPath, const QString& oldProjectPath); - virtual std::vector views(); virtual std::vector timeStepDates() const override; virtual QStringList timeStepStrings() const override; virtual QString timeStepName(int frameIdx) const override; - virtual cvf::BoundingBox activeCellsBoundingBox() const; - virtual cvf::BoundingBox allCellsBoundingBox() const; + virtual cvf::BoundingBox activeCellsBoundingBox() const override; + virtual cvf::BoundingBox allCellsBoundingBox() const override; virtual double characteristicCellSize() const override; virtual void setFormationNames(RimFormationNames* formationNames) override; + void addElementPropertyFiles(const std::vector& filenames); + + double cohesion() const; + double frictionAngleDeg() const; + // Fields: caf::PdmChildArrayField geoMechViews; + + + private: + virtual cvf::Vec3d displayModelOffset() const override; static std::vector dateTimeVectorFromTimeStepStrings(const QStringList& timeStepStrings); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; virtual void updateFormationNamesData() override; - virtual void initAfterRead(); + virtual void initAfterRead() override; static QString subStringOfDigits(const QString& timeStepString, int numberOfDigitsToFind); + void closeSelectedElementPropertyFiles(); + void reloadSelectedElementPropertyFiles(); + virtual std::vector allSpecialViews() const override; + private: - cvf::ref m_geoMechCaseData; - caf::PdmField m_caseFileName; - caf::PdmField m_cohesion; - caf::PdmField m_frictionAngleDeg; + cvf::ref m_geoMechCaseData; + caf::PdmField m_caseFileName; + caf::PdmField m_cohesion; + caf::PdmField m_frictionAngleDeg; + caf::PdmField> m_elementPropertyFileNames; + caf::PdmField > m_elementPropertyFileNameIndexUiSelection; + caf::PdmField m_closeElementPropertyFileCommand; + caf::PdmField m_reloadElementPropertyFileCommand; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp index 7b7c81a1b6..98c9bdf542 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.cpp @@ -19,8 +19,8 @@ #include "RimGeoMechCellColors.h" -#include "RimLegendConfig.h" -#include "RimView.h" +#include "RimRegularLegendConfig.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -34,7 +34,7 @@ CAF_PDM_SOURCE_INIT(RimGeoMechCellColors, "GeoMechResultSlot"); RimGeoMechCellColors::RimGeoMechCellColors(void) { CAF_PDM_InitFieldNoDefault(&legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); - this->legendConfig = new RimLegendConfig(); + this->legendConfig = new RimRegularLegendConfig(); legendConfig.uiCapability()->setUiHidden(true); } @@ -51,7 +51,7 @@ RimGeoMechCellColors::~RimGeoMechCellColors(void) //-------------------------------------------------------------------------------------------------- void RimGeoMechCellColors::updateIconState() { - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); @@ -87,19 +87,19 @@ void RimGeoMechCellColors::updateLegendCategorySettings() { if(this->hasCategoryResult()) { - legendConfig->setMappingMode(RimLegendConfig::CATEGORY_INTEGER); - legendConfig->setColorRangeMode(RimLegendConfig::CATEGORY); + legendConfig->setMappingMode(RimRegularLegendConfig::CATEGORY_INTEGER); + legendConfig->setColorRange(RimRegularLegendConfig::CATEGORY); } else { - if(legendConfig->mappingMode() == RimLegendConfig::CATEGORY_INTEGER) + if(legendConfig->mappingMode() == RimRegularLegendConfig::CATEGORY_INTEGER) { - legendConfig->setMappingMode(RimLegendConfig::LINEAR_CONTINUOUS); + legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_CONTINUOUS); } - if(legendConfig->colorRangeMode() == RimLegendConfig::CATEGORY) + if(legendConfig->colorRange() == RimRegularLegendConfig::CATEGORY) { - legendConfig->setColorRangeMode(RimLegendConfig::NORMAL); + legendConfig->setColorRange(RimRegularLegendConfig::NORMAL); } } } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h index c3da0cb14c..0e14fdd270 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechCellColors.h @@ -24,7 +24,7 @@ #include "cafPdmChildField.h" #include "cafPdmField.h" -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== @@ -39,7 +39,7 @@ class RimGeoMechCellColors : public RimGeoMechResultDefinition RimGeoMechCellColors(void); virtual ~RimGeoMechCellColors(void); - caf::PdmChildField legendConfig; + caf::PdmChildField legendConfig; void updateIconState(); virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp index c12847f834..bbc305e647 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilter.cpp @@ -41,7 +41,7 @@ CAF_PDM_SOURCE_INIT(RimGeoMechPropertyFilter, "GeoMechPropertyFilter"); /// //-------------------------------------------------------------------------------------------------- RimGeoMechPropertyFilter::RimGeoMechPropertyFilter() - : m_parentContainer(NULL) + : m_parentContainer(nullptr) { CAF_PDM_InitObject("Property Filter", ":/CellFilter_Values.png", "", ""); @@ -193,7 +193,7 @@ bool RimGeoMechPropertyFilter::isPropertyFilterControlled() { bool isPropertyFilterControlled = false; - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); if (rimView) @@ -311,6 +311,7 @@ void RimGeoMechPropertyFilter::updateFilterName() case RIG_NODAL: posName = "N"; break; case RIG_ELEMENT_NODAL: posName = "EN"; break; case RIG_INTEGRATION_POINT: posName = "IP"; break; + case RIG_ELEMENT: posName = "E"; break; } QString fieldUiName = resultDefinition->resultFieldUiName(); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp index acc74532fb..d356f79309 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.cpp @@ -55,7 +55,7 @@ RimGeoMechPropertyFilterCollection::~RimGeoMechPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- RimGeoMechView* RimGeoMechPropertyFilterCollection::reservoirView() { - RimGeoMechView* geoMechView = NULL; + RimGeoMechView* geoMechView = nullptr; firstAncestorOrThisOfType(geoMechView); return geoMechView; @@ -142,7 +142,7 @@ void RimGeoMechPropertyFilterCollection::updateIconState() { bool activeIcon = true; - RimGeoMechView* view = NULL; + RimGeoMechView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) { diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h index 440f0a9d9e..d27fac7ec2 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechPropertyFilterCollection.h @@ -45,14 +45,14 @@ class RimGeoMechPropertyFilterCollection : public RimPropertyFilterCollection caf::PdmChildArrayField propertyFilters; // Methods - bool hasActiveFilters() const; - bool hasActiveDynamicFilters() const; + bool hasActiveFilters() const override; + bool hasActiveDynamicFilters() const override; bool isUsingFormationNames() const; - void loadAndInitializePropertyFilters(); - void updateIconState(); + void loadAndInitializePropertyFilters() override; + void updateIconState() override; protected: // Overridden methods - virtual void initAfterRead(); + virtual void initAfterRead() override; }; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp index df30ec308f..c8b2d20710 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.cpp @@ -24,12 +24,17 @@ #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" #include "RigGeoMechCaseData.h" +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" #include "RiaDefines.h" + +#include "Rim3dWellLogCurve.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilter.h" #include "RimGeoMechView.h" +#include "RimIntersectionCollection.h" #include "RimPlotCurve.h" #include "RimViewLinker.h" @@ -45,6 +50,7 @@ void caf::AppEnum< RigFemResultPosEnum >::setUp() addItem(RIG_INTEGRATION_POINT,"INTEGRATION_POINT","Integration Point"); addItem(RIG_ELEMENT_NODAL_FACE, "ELEMENT_NODAL_FACE", "Element Nodal On Face"); addItem(RIG_FORMATION_NAMES, "FORMATION_NAMES", "Formation Names"); + addItem(RIG_ELEMENT, "ELEMENT", "Element"); setDefault(RIG_NODAL); } } @@ -75,6 +81,9 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) CAF_PDM_InitField(&m_timeLapseBaseTimestep, "TimeLapseBaseTimeStep", 0, "Base Time Step", "", "", ""); m_timeLapseBaseTimestep.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_compactionRefLayer, "CompactionRefLayer", 0, "Compaction Ref Layer", "", "", ""); + m_compactionRefLayer.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_resultPositionTypeUiField, "ResultPositionTypeUi", "Result Position", "", "", ""); m_resultPositionTypeUiField.xmlCapability()->setIOWritable(false); m_resultPositionTypeUiField.xmlCapability()->setIOReadable(false); @@ -94,6 +103,10 @@ RimGeoMechResultDefinition::RimGeoMechResultDefinition(void) m_resultVariableUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_resultVariableUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); + CAF_PDM_InitField(&m_compactionRefLayerUiField, "CompactionRefLayerUi", (int)RigFemResultAddress::NO_COMPACTION, "Compaction Ref Layer", "", "The compaction is calculated with reference to this layer. Default layer is the topmost layer with POR", ""); + m_compactionRefLayerUiField.xmlCapability()->setIOWritable(false); + m_compactionRefLayerUiField.xmlCapability()->setIOReadable(false); + m_isChangedByField = false; } @@ -121,6 +134,20 @@ void RimGeoMechResultDefinition::defineUiOrdering(QString uiConfigName, caf::Pdm timeLapseGr->add(&m_timeLapseBaseTimestepUiField); } + if (m_resultPositionTypeUiField() == RIG_NODAL) + { + caf::PdmUiGroup * compactionGroup = uiOrdering.addNewGroup("Compaction Options"); + compactionGroup->add(&m_compactionRefLayerUiField); + + if (m_compactionRefLayerUiField == (int)RigFemResultAddress::NO_COMPACTION) + { + if (m_geomCase && m_geomCase->geoMechData() ) + { + m_compactionRefLayerUiField = (int)m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->reservoirIJKBoundingBox().first.z(); + } + } + } + if (!m_isChangedByField) { m_resultPositionTypeUiField = m_resultPositionType; @@ -145,6 +172,7 @@ QList RimGeoMechResultDefinition::calculateValueOptions( if (&m_resultVariableUiField == fieldNeedingOptions) { std::map > fieldCompNames = getResultMetaDataForUIFieldSetting(); + QStringList uiVarNames; QStringList varNames; bool isNeedingTimeLapseStrings = m_isTimeLapseResultUiField() && (m_resultPositionTypeUiField() != RIG_FORMATION_NAMES); @@ -174,6 +202,17 @@ QList RimGeoMechResultDefinition::calculateValueOptions( options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(stepNames[stepIdx]), static_cast(stepIdx))); } } + else if (&m_compactionRefLayerUiField == fieldNeedingOptions) + { + if (m_geomCase->geoMechData()) + { + size_t kCount = m_geomCase->geoMechData()->femParts()->part(0)->structGrid()->gridPointCountK() - 1; + for ( size_t layerIdx = 0; layerIdx < kCount; ++layerIdx ) + { + options.push_back(caf::PdmOptionItemInfo(QString::number(layerIdx + 1), (int)layerIdx)); + } + } + } } return options; @@ -221,12 +260,15 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha // Get the possible property filter owner RimGeoMechPropertyFilter* propFilter = dynamic_cast(this->parentField()->ownerObject()); - RimView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); RimPlotCurve* curve = nullptr; this->firstAncestorOrThisOfType(curve); + Rim3dWellLogCurve* rim3dWellLogCurve = nullptr; + this->firstAncestorOrThisOfType(rim3dWellLogCurve); + - if (&m_resultVariableUiField == changedField) + if (&m_resultVariableUiField == changedField || &m_compactionRefLayerUiField == changedField) { QStringList fieldComponentNames = m_resultVariableUiField().split(QRegExp("\\s+")); if (fieldComponentNames.size() > 0) @@ -252,11 +294,12 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha m_resultComponentName = ""; } - m_isTimeLapseResult = m_isTimeLapseResultUiField(); + m_isTimeLapseResult = m_isTimeLapseResultUiField(); m_timeLapseBaseTimestep = m_timeLapseBaseTimestepUiField(); + m_compactionRefLayer = m_compactionRefLayerUiField(); } - if (m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) + if (m_geomCase->geoMechData() && m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress())) { if (view) view->hasUserRequestedAnimation = true; } @@ -268,7 +311,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha if (view) view->scheduleGeometryRegen(PROPERTY_FILTERED); } - if (view) view->scheduleCreateDisplayModelAndRedraw(); + if ( view ) + { + view->scheduleCreateDisplayModelAndRedraw(); + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } if (dynamic_cast(this)) { @@ -288,6 +335,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha { curve->loadDataAndUpdate(true); } + + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->updateCurveIn3dView(); + } } } @@ -300,6 +352,11 @@ void RimGeoMechResultDefinition::fieldChangedByUi(const caf::PdmFieldHandle* cha { curve->updateConnectedEditors(); } + + if (rim3dWellLogCurve) + { + rim3dWellLogCurve->resetMinMaxValuesAndUpdateUI(); + } } //-------------------------------------------------------------------------------------------------- @@ -371,6 +428,7 @@ void RimGeoMechResultDefinition::initAfterRead() m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_isTimeLapseResultUiField = m_isTimeLapseResult; m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep; + m_compactionRefLayerUiField = m_compactionRefLayer; } @@ -379,22 +437,22 @@ void RimGeoMechResultDefinition::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimGeoMechResultDefinition::loadResult() { - if (m_geomCase) + if (m_geomCase && m_geomCase->geoMechData()) { m_geomCase->geoMechData()->femPartResults()->assertResultsLoaded(this->resultAddress()); } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RigFemResultAddress RimGeoMechResultDefinition::resultAddress() { - if(m_isTimeLapseResult) - return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString(), m_timeLapseBaseTimestep); - else - return RigFemResultAddress(resultPositionType(), resultFieldName().toStdString(), resultComponentName().toStdString()); + return RigFemResultAddress(resultPositionType(), + resultFieldName().toStdString(), + resultComponentName().toStdString(), + m_isTimeLapseResult() ? m_timeLapseBaseTimestep() : RigFemResultAddress::NO_TIME_LAPSE, + resultFieldName().toStdString() == RigFemPartResultsCollection::FIELD_NAME_COMPACTION ? m_compactionRefLayer() : RigFemResultAddress::NO_COMPACTION); } //-------------------------------------------------------------------------------------------------- @@ -443,6 +501,8 @@ QString RimGeoMechResultDefinition::convertToUiResultFieldName(QString resultFie if (resultFieldName == "S") newName = "NativeAbaqus Stress"; if (resultFieldName == "NE") newName = "E"; // Make NE and NS appear as E and SE if (resultFieldName == "POR-Bar") newName = "POR"; // POR-Bar appear as POR + if (resultFieldName == "MODULUS") newName = "Young's Modulus"; + if (resultFieldName == "RATIO") newName = "Poisson's Ratio"; if (isTimeLapseResultList) newName += "_D" + QString::number(baseFrameIdx); @@ -470,11 +530,13 @@ void RimGeoMechResultDefinition::setResultAddress( const RigFemResultAddress& re m_resultFieldName = QString::fromStdString(resultAddress.fieldName); m_resultComponentName = QString::fromStdString(resultAddress.componentName); m_isTimeLapseResult = resultAddress.isTimeLapse(); - - m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: 0; + + m_timeLapseBaseTimestep = m_isTimeLapseResult ? resultAddress.timeLapseBaseFrameIdx: -1; + m_compactionRefLayer = resultAddress.refKLayerIndex; m_resultPositionTypeUiField = m_resultPositionType; m_resultVariableUiField = composeFieldCompString(m_resultFieldName(), m_resultComponentName()); m_isTimeLapseResultUiField = m_isTimeLapseResult; m_timeLapseBaseTimestepUiField = m_timeLapseBaseTimestep; + m_compactionRefLayerUiField = m_compactionRefLayer; } diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h index bb4dfeeb7a..0cc449b192 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechResultDefinition.h @@ -70,11 +70,11 @@ class RimGeoMechResultDefinition : public caf::PdmObject // Overridden PDM methods virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, - bool * useOptionsOnly); + bool * useOptionsOnly) override; virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, - const QVariant& newValue); - virtual void initAfterRead(); + const QVariant& newValue) override; + virtual void initAfterRead() override; // Metadata and option build tools @@ -101,6 +101,7 @@ class RimGeoMechResultDefinition : public caf::PdmObject caf::PdmField m_resultComponentName; caf::PdmField m_isTimeLapseResult; caf::PdmField m_timeLapseBaseTimestep; + caf::PdmField m_compactionRefLayer; // UI Fields only @@ -112,7 +113,7 @@ class RimGeoMechResultDefinition : public caf::PdmObject caf::PdmField m_resultVariableUiField; caf::PdmField m_isTimeLapseResultUiField; caf::PdmField m_timeLapseBaseTimestepUiField; - + caf::PdmField m_compactionRefLayerUiField; caf::PdmPointer m_geomCase; bool m_isChangedByField; diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp index f318180a83..bfbfbe501b 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.cpp @@ -30,16 +30,17 @@ #include "Rim3dOverlayInfoConfig.h" #include "RimCellRangeFilterCollection.h" -#include "RimIntersectionCollection.h" #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechPropertyFilterCollection.h" #include "RimGridCollection.h" -#include "RimLegendConfig.h" +#include "RimIntersectionCollection.h" +#include "RimRegularLegendConfig.h" +#include "RimTensorResults.h" #include "RimViewLinker.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -47,15 +48,17 @@ #include "RivGeoMechPartMgrCache.h" #include "RivGeoMechVizLogic.h" #include "RivSingleCellPartGenerator.h" +#include "RivTensorResultPartMgr.h" #include "cafCadNavigation.h" #include "cafCeetronPlusNavigation.h" +#include "cafDisplayCoordTransform.h" #include "cafFrameAnimationControl.h" +#include "cafOverlayScalarMapperLegend.h" #include "cafPdmUiTreeOrdering.h" #include "cafProgressInfo.h" #include "cvfModelBasicList.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfPart.h" #include "cvfScene.h" #include "cvfTransform.h" @@ -81,12 +84,18 @@ RimGeoMechView::RimGeoMechView(void) cellResult = new RimGeoMechCellColors(); cellResult.uiCapability()->setUiHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_tensorResults, "TensorResults", "Tensor Results", "", "", ""); + m_tensorResults = new RimTensorResults(); + m_tensorResults.uiCapability()->setUiHidden(true); + CAF_PDM_InitFieldNoDefault(&m_propertyFilterCollection, "PropertyFilters", "Property Filters", "", "", ""); m_propertyFilterCollection = new RimGeoMechPropertyFilterCollection(); m_propertyFilterCollection.uiCapability()->setUiHidden(true); m_scaleTransform = new cvf::Transform(); m_vizLogic = new RivGeoMechVizLogic(this); + m_tensorPartMgr = new RivTensorResultPartMgr(this); } //-------------------------------------------------------------------------------------------------- @@ -94,8 +103,9 @@ RimGeoMechView::RimGeoMechView(void) //-------------------------------------------------------------------------------------------------- RimGeoMechView::~RimGeoMechView(void) { - m_geomechCase = NULL; + m_geomechCase = nullptr; + delete m_tensorResults; delete cellResult; delete m_propertyFilterCollection; } @@ -116,10 +126,10 @@ void RimGeoMechView::onLoadDataAndUpdate() { QString displayMessage = errorMessage.empty() ? "Could not open the Odb file: \n" + m_geomechCase->caseFileName() : QString::fromStdString(errorMessage); - QMessageBox::warning(RiuMainWindow::instance(), - "File open error", - displayMessage); - m_geomechCase = NULL; + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), + "File open error", + displayMessage); + m_geomechCase = nullptr; return; } } @@ -127,7 +137,7 @@ void RimGeoMechView::onLoadDataAndUpdate() progress.setProgressDescription("Reading Current Result"); - CVF_ASSERT(this->cellResult() != NULL); + CVF_ASSERT(this->cellResult() != nullptr); if (this->hasUserRequestedAnimation()) { m_geomechCase->geoMechData()->femPartResults()->assertResultsLoaded(this->cellResult()->resultAddress()); @@ -205,12 +215,13 @@ void RimGeoMechView::createDisplayModel() cvf::ref mainSceneGridVizModel = new cvf::ModelBasicList; mainSceneGridVizModel->setName("GridModel"); m_vizLogic->appendNoAnimPartsToModel(mainSceneGridVizModel.p()); + mainSceneGridVizModel->updateBoundingBoxesRecursive(); mainScene->addModel(mainSceneGridVizModel.p()); // Well path model - cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox(); + cvf::BoundingBox femBBox = femParts()->boundingBox(); m_wellPathPipeVizModel->removeAllParts(); addWellPathsToModel(m_wellPathPipeVizModel.p(), femBBox); @@ -221,7 +232,7 @@ void RimGeoMechView::createDisplayModel() // Cross sections m_crossSectionVizModel->removeAllParts(); - crossSectionCollection->appendPartsToModel(m_crossSectionVizModel.p(), scaleTransform()); + m_crossSectionCollection->appendPartsToModel(*this, m_crossSectionVizModel.p(), scaleTransform()); m_viewer->addStaticModelOnce(m_crossSectionVizModel.p()); // If the animation was active before recreating everything, make viewer view current frame @@ -234,7 +245,7 @@ void RimGeoMechView::createDisplayModel() { updateLegends(); m_vizLogic->updateStaticCellColors(-1); - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); m_overlayInfoConfig()->update3DInfo(); } @@ -275,11 +286,27 @@ void RimGeoMechView::updateCurrentTimeStep() cvf::ref wellPathModelBasicList = new cvf::ModelBasicList; wellPathModelBasicList->setName(name); - cvf::BoundingBox femBBox = geoMechCase()->geoMechData()->femParts()->boundingBox(); + cvf::BoundingBox femBBox = femParts()->boundingBox(); addDynamicWellPathsToModel(wellPathModelBasicList.p(), femBBox); frameScene->addModel(wellPathModelBasicList.p()); } + + { + // Tensors + cvf::String name = "Tensor"; + this->removeModelByName(frameScene, name); + + cvf::ref frameParts = new cvf::ModelBasicList; + frameParts->setName(name); + m_tensorPartMgr->appendDynamicGeometryPartsToModel(frameParts.p(), m_currentTimeStep); + frameParts->updateBoundingBoxesRecursive(); + + if (frameParts->partCount() != 0) + { + frameScene->addModel(frameParts.p()); + } + } } } @@ -290,18 +317,20 @@ void RimGeoMechView::updateCurrentTimeStep() if (this->cellResult()->hasResult()) { - crossSectionCollection->updateCellResultColor(m_currentTimeStep); + m_crossSectionCollection->updateCellResultColor(m_currentTimeStep, + this->cellResult()->legendConfig()->scalarMapper(), + nullptr); } else { - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); } } else { m_vizLogic->updateStaticCellColors(-1); - crossSectionCollection->applySingleColorEffect(); + m_crossSectionCollection->applySingleColorEffect(); m_viewer->animationControl()->slotPause(); // To avoid animation timer spinning in the background } @@ -317,46 +346,6 @@ void RimGeoMechView::updateStaticCellColors() m_vizLogic->updateStaticCellColors(-1); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -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(); -} //-------------------------------------------------------------------------------------------------- /// @@ -376,7 +365,7 @@ void RimGeoMechView::resetLegendsInViewer() this->cellResult()->legendConfig->recreateLegend(); m_viewer->removeAllColorLegends(); - m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->legend()); + m_viewer->addColorLegendToBottomLeftCorner(this->cellResult()->legendConfig->titledOverlayFrame()); } //-------------------------------------------------------------------------------------------------- @@ -384,12 +373,70 @@ void RimGeoMechView::resetLegendsInViewer() //-------------------------------------------------------------------------------------------------- void RimGeoMechView::updateLegends() { - if (m_viewer) + if ( m_viewer ) { m_viewer->removeAllColorLegends(); + + this->updateLegendTextAndRanges(cellResult()->legendConfig(), m_currentTimeStep()); + + if (cellResult()->hasResult() && cellResult()->legendConfig()->showLegend()) + { + m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->titledOverlayFrame()); + } + + if (tensorResults()->showTensors()) + { + updateTensorLegendTextAndRanges(m_tensorResults->arrowColorLegendConfig(), m_currentTimeStep()); + + if (tensorResults()->vectorColors() == RimTensorResults::RESULT_COLORS && + tensorResults()->arrowColorLegendConfig()->showLegend()) + { + m_viewer->addColorLegendToBottomLeftCorner(m_tensorResults->arrowColorLegendConfig->titledOverlayFrame()); + } + } } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateTensorLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex) +{ + if (!m_geomechCase || !m_geomechCase->geoMechData()) return; + + double localMin, localMax; + double localPosClosestToZero, localNegClosestToZero; + double globalMin, globalMax; + double globalPosClosestToZero, globalNegClosestToZero; + + RigGeoMechCaseData* gmCase = m_geomechCase->geoMechData(); + CVF_ASSERT(gmCase); + + RigFemResultPosEnum resPos = tensorResults()->resultPositionType(); + QString resFieldName = tensorResults()->resultFieldName(); + + RigFemResultAddress resVarAddress(resPos, resFieldName.toStdString(), ""); + + gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents(resVarAddress, timeStepIndex, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents(resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero); + + gmCase->femPartResults()->minMaxScalarValuesOverAllTensorComponents(resVarAddress, &globalMin, &globalMax); + gmCase->femPartResults()->posNegClosestToZeroOverAllTensorComponents(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); + + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + + QString legendTitle = "Tensors:\n" + RimTensorResults::uiFieldName(resFieldName); + + legendConfig->setTitle(legendTitle); +} - if (!m_geomechCase || !m_viewer || !m_geomechCase->geoMechData() +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGeoMechView::updateLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex) +{ + if (!m_geomechCase || !m_geomechCase->geoMechData() || !this->isTimeStepDependentDataVisible() || !(cellResult()->resultAddress().isValid()) ) { @@ -406,16 +453,16 @@ void RimGeoMechView::updateLegends() RigFemResultAddress resVarAddress = cellResult()->resultAddress(); - gmCase->femPartResults()->minMaxScalarValues(resVarAddress, m_currentTimeStep, &localMin, &localMax); - gmCase->femPartResults()->posNegClosestToZero(resVarAddress, m_currentTimeStep, &localPosClosestToZero, &localNegClosestToZero); + gmCase->femPartResults()->minMaxScalarValues(resVarAddress, timeStepIndex, &localMin, &localMax); + gmCase->femPartResults()->posNegClosestToZero(resVarAddress, timeStepIndex, &localPosClosestToZero, &localNegClosestToZero); gmCase->femPartResults()->minMaxScalarValues(resVarAddress, &globalMin, &globalMax); gmCase->femPartResults()->posNegClosestToZero(resVarAddress, &globalPosClosestToZero, &globalNegClosestToZero); - cellResult()->legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); - cellResult()->legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); - + legendConfig->setClosestToZeroValues(globalPosClosestToZero, globalNegClosestToZero, localPosClosestToZero, localNegClosestToZero); + legendConfig->setAutomaticRanges(globalMin, globalMax, localMin, localMax); + if (cellResult()->hasCategoryResult()) { std::vector fnVector; @@ -423,18 +470,15 @@ void RimGeoMechView::updateLegends() { fnVector = gmCase->femPartResults()->activeFormationNames()->formationNames(); } - cellResult()->legendConfig->setNamedCategoriesInverse(fnVector); + legendConfig->setNamedCategoriesInverse(fnVector); } - - m_viewer->addColorLegendToBottomLeftCorner(cellResult()->legendConfig->legend()); - cvf::String legendTitle = cvfqt::Utils::toString( - caf::AppEnum(cellResult->resultPositionType()).uiText() + "\n" - + cellResult->resultFieldUiName()); + QString legendTitle = "Cell Results:\n" + caf::AppEnum(cellResult->resultPositionType()).uiText() + + "\n" + cellResult->resultFieldUiName(); if (!cellResult->resultComponentUiName().isEmpty()) { - legendTitle += ", " + cvfqt::Utils::toString(cellResult->resultComponentUiName()); + legendTitle += ", " + cellResult->resultComponentUiName(); } if ( cellResult->resultFieldName() == "SE" || cellResult->resultFieldName() == "ST" || cellResult->resultFieldName() == "POR-Bar" @@ -443,12 +487,129 @@ void RimGeoMechView::updateLegends() legendTitle += " [Bar]"; } - cellResult()->legendConfig->setTitle(legendTitle); + if (cellResult->resultFieldName() == "MODULUS") + { + legendTitle += " [GPa]"; + } + + legendConfig->setTitle(legendTitle); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const cvf::ref RimGeoMechView::vizLogic() const +{ + return m_vizLogic; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimTensorResults* RimGeoMechView::tensorResults() const +{ + return m_tensorResults; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults* RimGeoMechView::tensorResults() +{ + return m_tensorResults; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimGeoMechView::legendConfigs() const +{ + std::vector absLegendConfigs; + + absLegendConfigs.push_back(cellResult()->legendConfig()); + absLegendConfigs.push_back(tensorResults()->arrowColorLegendConfig()); + + return absLegendConfigs; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigFemPartCollection* RimGeoMechView::femParts() const +{ + if (m_geomechCase && m_geomechCase->geoMechData()) + { + return m_geomechCase->geoMechData()->femParts(); + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemPartCollection* RimGeoMechView::femParts() +{ + if (m_geomechCase && m_geomechCase->geoMechData()) + { + return m_geomechCase->geoMechData()->femParts(); + } + + return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +void RimGeoMechView::convertCameraPositionFromOldProjectFiles() +{ + auto geoMechCase = this->geoMechCase(); + if ( geoMechCase ) + { + // Up-cast to get access to public interface for camera functions + RimCase* rimCase = geoMechCase; + RiuViewerToViewInterface* viewerToViewInterface = this; + cvf::Vec3d offset = rimCase->displayModelOffset(); + auto diplayCoordTrans = this->displayCoordTransform(); + + { + cvf::Mat4d cameraMx = this->cameraPosition().getInverted(); + + cvf::Vec3d translation = cameraMx.translation(); + + cvf::Vec3d translationDomainCoord = diplayCoordTrans->scaleToDomainSize(translation); + translationDomainCoord -= offset; + + cvf::Vec3d newCameraTranslation = diplayCoordTrans->scaleToDisplaySize(translationDomainCoord); + + cameraMx.setTranslation(newCameraTranslation); + + viewerToViewInterface->setCameraPosition(cameraMx.getInverted()); + } + + { + cvf::Vec3d pointOfInterest = this->cameraPointOfInterest(); + + cvf::Vec3d pointOfInterestDomain = diplayCoordTrans->scaleToDomainSize(pointOfInterest); + pointOfInterestDomain -= offset; + + cvf::Vec3d newPointOfInterest = diplayCoordTrans->scaleToDisplaySize(pointOfInterestDomain); + + viewerToViewInterface->setCameraPointOfInterest(newPointOfInterest); + } + + if (m_viewer) + { + m_viewer->mainCamera()->setViewMatrix(this->cameraPosition()); + m_viewer->setPointOfInterest(this->cameraPointOfInterest()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- RimGeoMechCase* RimGeoMechView::geoMechCase() { return m_geomechCase; @@ -472,7 +633,7 @@ void RimGeoMechView::clampCurrentTimestep() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimGeoMechView::isTimeStepDependentDataVisible() +bool RimGeoMechView::isTimeStepDependentDataVisible() const { return this->hasUserRequestedAnimation() && (this->cellResult()->hasResult() || this->geoMechPropertyFilterCollection()->hasActiveFilters()); } @@ -490,7 +651,7 @@ cvf::Transform* RimGeoMechView::scaleTransform() //-------------------------------------------------------------------------------------------------- void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) { - RimView::fieldChangedByUi(changedField, oldValue, newValue); + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); } //-------------------------------------------------------------------------------------------------- @@ -498,7 +659,7 @@ void RimGeoMechView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c //-------------------------------------------------------------------------------------------------- void RimGeoMechView::initAfterRead() { - RimViewWindow::initAfterRead(); + RimGridView::initAfterRead(); this->cellResult()->setGeoMechCase(m_geomechCase); this->updateUiIconFromToggleField(); @@ -527,7 +688,7 @@ void RimGeoMechView::scheduleGeometryRegen(RivCellSetEnum geometryType) viewLinker->scheduleGeometryRegenForDepViews(geometryType); } } - m_currentReservoirCellVisibility = NULL; + m_currentReservoirCellVisibility = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -649,8 +810,9 @@ void RimGeoMechView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering uiTreeOrdering.add(m_gridCollection()); uiTreeOrdering.add(cellResult()); + uiTreeOrdering.add(m_tensorResults()); - uiTreeOrdering.add(crossSectionCollection()); + uiTreeOrdering.add(m_crossSectionCollection()); uiTreeOrdering.add(m_rangeFilterCollection()); uiTreeOrdering.add(m_propertyFilterCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimGeoMechView.h b/ApplicationCode/ProjectDataModel/RimGeoMechView.h index a432329ed3..7448bae1f0 100644 --- a/ApplicationCode/ProjectDataModel/RimGeoMechView.h +++ b/ApplicationCode/ProjectDataModel/RimGeoMechView.h @@ -19,7 +19,7 @@ #pragma once -#include "RimView.h" +#include "RimGridView.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -32,15 +32,19 @@ #include "cvfObject.h" class RigFemPart; +class RigFemPartCollection; class Rim3dOverlayInfoConfig; class RimCellRangeFilterCollection; class RimGeoMechCase; class RimGeoMechCellColors; -class RimGeoMechResultDefinition; class RimGeoMechPropertyFilterCollection; +class RimGeoMechResultDefinition; +class RimRegularLegendConfig; +class RimTensorResults; class RiuViewer; class RivGeoMechPartMgr; class RivGeoMechVizLogic; +class RivTensorResultPartMgr; namespace cvf { class CellRangeFilter; @@ -51,7 +55,7 @@ namespace cvf { /// /// //================================================================================================== -class RimGeoMechView : public RimView +class RimGeoMechView : public RimGridView { CAF_PDM_HEADER_INIT; @@ -72,7 +76,7 @@ class RimGeoMechView : public RimView const RimGeoMechPropertyFilterCollection* geoMechPropertyFilterCollection() const; void setOverridePropertyFilterCollection(RimGeoMechPropertyFilterCollection* pfc); - bool isTimeStepDependentDataVisible(); + bool isTimeStepDependentDataVisible() const override ; virtual cvf::Transform* scaleTransform() override; virtual void scheduleGeometryRegen(RivCellSetEnum geometryType) override; @@ -84,6 +88,19 @@ class RimGeoMechView : public RimView virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) override; + void updateLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex); + + const cvf::ref vizLogic() const; + const RimTensorResults* tensorResults() const; + RimTensorResults* tensorResults(); + + std::vector legendConfigs() const override; + + const RigFemPartCollection* femParts() const; + RigFemPartCollection* femParts(); + + void convertCameraPositionFromOldProjectFiles(); + protected: virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; virtual void onLoadDataAndUpdate() override; @@ -92,7 +109,6 @@ class RimGeoMechView : public RimView private: virtual void createDisplayModel() override; - virtual void updateDisplayModelVisibility() override; virtual void updateScaleTransform() override; virtual void clampCurrentTimestep() override; @@ -102,13 +118,15 @@ class RimGeoMechView : public RimView virtual void resetLegendsInViewer() override; - void updateLegends(); + void updateLegends() override; + + void updateTensorLegendTextAndRanges(RimRegularLegendConfig* legendConfig, int timeStepIndex); virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; virtual void initAfterRead() override; - + caf::PdmChildField m_tensorResults; caf::PdmChildField m_propertyFilterCollection; caf::PdmPointer m_overridePropertyFilterCollection; @@ -116,5 +134,6 @@ class RimGeoMechView : public RimView cvf::ref m_vizLogic; cvf::ref m_scaleTransform; + cvf::ref m_tensorPartMgr; }; diff --git a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp index 051aa6eef5..d236211695 100644 --- a/ApplicationCode/ProjectDataModel/RimGridCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimGridCollection.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimGridCollection.h" -#include "RimView.h" +#include "RimGridView.h" CAF_PDM_SOURCE_INIT(RimGridCollection, "GridCollection"); @@ -57,7 +57,7 @@ void RimGridCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField { if (changedField == &isActive) { - RimView* rimView = NULL; + RimGridView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); CVF_ASSERT(rimView); diff --git a/ApplicationCode/ProjectDataModel/RimGridView.cpp b/ApplicationCode/ProjectDataModel/RimGridView.cpp new file mode 100644 index 0000000000..2353dbba16 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGridView.cpp @@ -0,0 +1,369 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimGridView.h" + +#include "RiaApplication.h" + +#include "Rim3dOverlayInfoConfig.h" +#include "RimCellRangeFilterCollection.h" +#include "RimGridCollection.h" +#include "RimIntersectionCollection.h" +#include "RimProject.h" +#include "RimPropertyFilterCollection.h" +#include "RimViewController.h" +#include "RimViewLinker.h" +#include "RimViewLinkerCollection.h" + +#include "Riu3DMainWindowTools.h" + +#include "cvfModel.h" +#include "cvfScene.h" +#include "RiuMainWindow.h" + + +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimGridView, "GenericGridView"); // Do not use. Abstract class + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView::RimGridView() +{ + + CAF_PDM_InitFieldNoDefault(&m_rangeFilterCollection, "RangeFilters", "Range Filters", "", "", ""); + m_rangeFilterCollection.uiCapability()->setUiHidden(true); + m_rangeFilterCollection = new RimCellRangeFilterCollection(); + + CAF_PDM_InitFieldNoDefault(&m_overrideRangeFilterCollection, "RangeFiltersControlled", "Range Filters (controlled)", "", "", ""); + m_overrideRangeFilterCollection.uiCapability()->setUiHidden(true); + m_overrideRangeFilterCollection.xmlCapability()->setIOWritable(false); + m_overrideRangeFilterCollection.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitFieldNoDefault(&m_crossSectionCollection, "CrossSections", "Intersections", "", "", ""); + m_crossSectionCollection.uiCapability()->setUiHidden(true); + m_crossSectionCollection = new RimIntersectionCollection(); + + CAF_PDM_InitFieldNoDefault(&m_gridCollection, "GridCollection", "GridCollection", "", "", ""); + m_gridCollection.uiCapability()->setUiHidden(true); + m_gridCollection = new RimGridCollection(); + + m_previousGridModeMeshLinesWasFaults = false; + + CAF_PDM_InitFieldNoDefault(&m_overlayInfoConfig, "OverlayInfoConfig", "Info Box", "", "", ""); + m_overlayInfoConfig = new Rim3dOverlayInfoConfig(); + m_overlayInfoConfig->setReservoirView(this); + m_overlayInfoConfig.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGridView::~RimGridView(void) +{ + RimProject* proj = RiaApplication::instance()->project(); + + if (proj && this->isMasterView()) + { + delete proj->viewLinkerCollection->viewLinker(); + proj->viewLinkerCollection->viewLinker = nullptr; + + proj->uiCapability()->updateConnectedEditors(); + } + + RimViewController* vController = this->viewController(); + if (proj && vController) + { + vController->setManagedView(nullptr); + vController->ownerViewLinker()->removeViewController(vController); + delete vController; + + proj->uiCapability()->updateConnectedEditors(); + } + + delete this->m_overlayInfoConfig(); + + delete m_rangeFilterCollection; + delete m_overrideRangeFilterCollection; + delete m_crossSectionCollection; + delete m_gridCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::showGridCells(bool enableGridCells) +{ + + m_gridCollection->isActive = enableGridCells; + + createDisplayModel(); + updateDisplayModelVisibility(); + RiuMainWindow::instance()->refreshDrawStyleActions(); + RiuMainWindow::instance()->refreshAnimationActions(); + + m_gridCollection->updateConnectedEditors(); + m_gridCollection->updateUiIconFromState(enableGridCells); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::ref RimGridView::currentTotalCellVisibility() +{ + if (m_currentReservoirCellVisibility.isNull()) + { + m_currentReservoirCellVisibility = new cvf::UByteArray; + this->calculateCurrentTotalCellVisibility(m_currentReservoirCellVisibility.p(), m_currentTimeStep()); + } + + return m_currentReservoirCellVisibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntersectionCollection* RimGridView::crossSectionCollection() const +{ + return m_crossSectionCollection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimCellRangeFilterCollection* RimGridView::rangeFilterCollection() const +{ + if (this->viewController() && this->viewController()->isRangeFiltersControlled() && m_overrideRangeFilterCollection) + { + return m_overrideRangeFilterCollection; + } + else + { + return m_rangeFilterCollection; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGridView::hasOverridenRangeFilterCollection() +{ + return m_overrideRangeFilterCollection() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc) +{ + if (m_overrideRangeFilterCollection()) delete m_overrideRangeFilterCollection(); + + m_overrideRangeFilterCollection = rfc; + this->scheduleGeometryRegen(RANGE_FILTERED); + this->scheduleGeometryRegen(RANGE_FILTERED_INACTIVE); + + this->scheduleCreateDisplayModelAndRedraw(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::replaceRangeFilterCollectionWithOverride() +{ + RimCellRangeFilterCollection* overrideRfc = m_overrideRangeFilterCollection; + CVF_ASSERT(overrideRfc); + + RimCellRangeFilterCollection* currentRfc = m_rangeFilterCollection; + if (currentRfc) + { + delete currentRfc; + } + + // Must call removeChildObject() to make sure the object has no parent + // No parent is required when assigning a object into a field + m_overrideRangeFilterCollection.removeChildObject(overrideRfc); + + m_rangeFilterCollection = overrideRfc; + + this->uiCapability()->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewController* RimGridView::viewController() const +{ + RimViewController* viewController = nullptr; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewController = dynamic_cast(reffingObjs[i]); + if (viewController) break; + } + + return viewController; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* RimGridView::assosiatedViewLinker() const +{ + RimViewLinker* viewLinker = this->viewLinkerIfMasterView(); + if (!viewLinker) + { + RimViewController* viewController = this->viewController(); + if (viewController) + { + viewLinker = viewController->ownerViewLinker(); + } + } + + return viewLinker; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGridView::isGridVisualizationMode() const +{ + return this->m_gridCollection->isActive(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dOverlayInfoConfig* RimGridView::overlayInfoConfig() const +{ + return m_overlayInfoConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::initAfterRead() +{ + RimViewWindow::initAfterRead(); + + RimProject* proj = nullptr; + firstAncestorOrThisOfType(proj); + if (proj && proj->isProjectFileVersionEqualOrOlderThan("2018.1.1")) + { + // For version prior to 2018.1.1 : Grid visualization mode was derived from surfaceMode and meshMode + // Current : Grid visualization mode is directly defined by m_gridCollection->isActive + // This change was introduced in https://github.com/OPM/ResInsight/commit/f7bfe8d0 + + bool isGridVisualizationModeBefore_2018_1_1 = ((surfaceMode() == RimGridView::SURFACE) || (meshMode() == RimGridView::FULL_MESH)); + + m_gridCollection->isActive = isGridVisualizationModeBefore_2018_1_1; + if (!isGridVisualizationModeBefore_2018_1_1) + { + // Was showing faults and intersections. + // If was showing with mesh and/or surfaces, turn to full mesh/surf mode to show the mesh, + // and to avoid a strange setup when dropping out into grid mode again + if (surfaceMode() != RimGridView::NO_SURFACE) surfaceMode = RimGridView::SURFACE; + if (meshMode() != RimGridView::NO_MESH) meshMode = RimGridView::FULL_MESH; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::onTimeStepChanged() +{ + if (this->propertyFilterCollection() && this->propertyFilterCollection()->hasActiveDynamicFilters()) + { + m_currentReservoirCellVisibility = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if ( changedField == &scaleZ ) + { + m_crossSectionCollection->updateIntersectionBoxGeometry(); + } + + Rim3dView::fieldChangedByUi(changedField, oldValue, newValue); + + if ( changedField == &scaleZ ) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if ( viewLinker ) + { + viewLinker->updateScaleZ(this, scaleZ); + viewLinker->updateCamera(this); + } + } + else if ( changedField == &m_currentTimeStep ) + { + RimViewLinker* viewLinker = this->assosiatedViewLinker(); + if ( viewLinker ) + { + viewLinker->updateTimeStep(this, m_currentTimeStep); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridView::selectOverlayInfoConfig() +{ + Riu3DMainWindowTools::selectAsCurrentItem(m_overlayInfoConfig); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimViewLinker* RimGridView::viewLinkerIfMasterView() const +{ + RimViewLinker* viewLinker = nullptr; + std::vector reffingObjs; + + this->objectsWithReferringPtrFields(reffingObjs); + + for (size_t i = 0; i < reffingObjs.size(); ++i) + { + viewLinker = dynamic_cast(reffingObjs[i]); + if (viewLinker) break; + } + + return viewLinker; +} + + diff --git a/ApplicationCode/ProjectDataModel/RimGridView.h b/ApplicationCode/ProjectDataModel/RimGridView.h new file mode 100644 index 0000000000..cb4d8f2143 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimGridView.h @@ -0,0 +1,84 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "Rim3dView.h" + +#include "cvfBase.h" +#include "cvfArray.h" + +class Rim3dOverlayInfoConfig; +class RimIntersectionCollection; +class RimPropertyFilterCollection; +class RimGridCollection; +class RimCellRangeFilterCollection; + +class RimGridView : public Rim3dView +{ + CAF_PDM_HEADER_INIT; +public: + RimGridView(); + virtual ~RimGridView(void); + + void showGridCells(bool enableGridCells); + + Rim3dOverlayInfoConfig* overlayInfoConfig() const; + + cvf::ref currentTotalCellVisibility(); + + RimIntersectionCollection* crossSectionCollection() const; + + virtual const RimPropertyFilterCollection* propertyFilterCollection() const = 0; + RimCellRangeFilterCollection* rangeFilterCollection(); + const RimCellRangeFilterCollection* rangeFilterCollection() const; + + bool hasOverridenRangeFilterCollection(); + void setOverrideRangeFilterCollection(RimCellRangeFilterCollection* rfc); + void replaceRangeFilterCollectionWithOverride(); + + RimViewController* viewController() const override; + RimViewLinker* assosiatedViewLinker() const override; + + + virtual bool isGridVisualizationMode() const override; + +protected: + virtual void initAfterRead() override; + virtual void onTimeStepChanged() override; + virtual void calculateCurrentTotalCellVisibility(cvf::UByteArray* totalVisibility, int timeStep) = 0; + virtual void selectOverlayInfoConfig() override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + +protected: // Fields + caf::PdmChildField m_crossSectionCollection; + caf::PdmChildField m_overlayInfoConfig; + caf::PdmChildField m_rangeFilterCollection; + caf::PdmChildField m_overrideRangeFilterCollection; + caf::PdmChildField m_gridCollection; + +protected: + cvf::ref m_currentReservoirCellVisibility; + +private: + RimViewLinker* viewLinkerIfMasterView() const; + bool m_previousGridModeMeshLinesWasFaults; +}; + + diff --git a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp index 6ffd07ff42..d88876c537 100644 --- a/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp +++ b/ApplicationCode/ProjectDataModel/RimIdenticalGridCaseGroup.cpp @@ -36,7 +36,7 @@ #include "RimEclipseView.h" #include "RimReservoirCellResultsStorage.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafProgressInfo.h" @@ -71,7 +71,7 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() statisticsCaseCollection->uiCapability()->setUiIcon(QIcon(":/Histograms16x16.png")); - m_mainGrid = NULL; + m_mainGrid = nullptr; m_unionOfMatrixActiveCells = new RigActiveCellInfo; m_unionOfFractureActiveCells = new RigActiveCellInfo; @@ -82,13 +82,13 @@ RimIdenticalGridCaseGroup::RimIdenticalGridCaseGroup() //-------------------------------------------------------------------------------------------------- RimIdenticalGridCaseGroup::~RimIdenticalGridCaseGroup() { - m_mainGrid = NULL; + m_mainGrid = nullptr; delete caseCollection; - caseCollection = NULL; + caseCollection = nullptr; delete statisticsCaseCollection; - statisticsCaseCollection = NULL; + statisticsCaseCollection = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -130,7 +130,7 @@ void RimIdenticalGridCaseGroup::removeCase(RimEclipseCase* reservoir) if (caseCollection()->reservoirs().size() == 0) { - m_mainGrid = NULL; + m_mainGrid = nullptr; } clearActiveCellUnions(); @@ -145,7 +145,7 @@ RigMainGrid* RimIdenticalGridCaseGroup::mainGrid() { if (m_mainGrid) return m_mainGrid; - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -173,7 +173,7 @@ void RimIdenticalGridCaseGroup::loadMainCaseAndActiveCellInfo() RimEclipseCase* mainCase = caseCollection()->reservoirs[0]; if (!mainCase->openReserviorCase()) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "Error when opening project file", "Could not open the Eclipse Grid file: \n"+ mainCase->gridFileName() + "\n"+ "Current working directory is: \n" + @@ -512,7 +512,7 @@ RimEclipseCase* RimIdenticalGridCaseGroup::mainCase() } else { - return NULL; + return nullptr; } } diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.cpp b/ApplicationCode/ProjectDataModel/RimIntersection.cpp index 06344c2cc0..07688ccf98 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersection.cpp @@ -32,7 +32,7 @@ #include "RimSimWellInView.h" #include "RimSimWellInViewCollection.h" #include "RimTools.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellPath.h" #include "RiuViewer.h" @@ -47,6 +47,7 @@ #include "cvfBoundingBox.h" #include "cvfGeometryTools.h" #include "cvfPlane.h" +#include "Rim2dIntersectionView.h" namespace caf { @@ -154,9 +155,7 @@ void RimIntersection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, || changedField == &isActive || changedField == &type) { - m_wellBranchCenterlines.clear(); - updateWellCenterline(); - m_branchIndex = -1; + recomputeSimulationWellBranchData(); } if (changedField == &simulationWell @@ -166,6 +165,16 @@ void RimIntersection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, updateName(); } + if (changedField == &name) + { + Rim2dIntersectionView* iView = correspondingIntersectionView(); + if (iView) + { + iView->updateName(); + iView->updateConnectedEditors(); + } + } + if (changedField == &inputPolyLineFromViewerEnabled || changedField == &m_userPolyline) { @@ -230,8 +239,8 @@ void RimIntersection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& else if (type == CS_SIMULATION_WELL) { geometryGroup->add(&simulationWell); - updateWellCenterline(); - if (simulationWell() && m_wellBranchCenterlines.size() > 1) + updateSimulationWellCenterline(); + if (simulationWell() && m_simulationWellBranchCenterlines.size() > 1) { geometryGroup->add(&m_branchIndex); } @@ -321,9 +330,9 @@ QList RimIntersection::calculateValueOptions(const caf:: } else if (fieldNeedingOptions == &m_branchIndex) { - updateWellCenterline(); + updateSimulationWellCenterline(); - size_t branchCount = m_wellBranchCenterlines.size(); + size_t branchCount = m_simulationWellBranchCenterlines.size(); options.push_back(caf::PdmOptionItemInfo("All", -1)); @@ -354,14 +363,14 @@ caf::PdmFieldHandle* RimIntersection::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSimWellInViewCollection* RimIntersection::simulationWellCollection() +RimSimWellInViewCollection* RimIntersection::simulationWellCollection() const { RimEclipseView* eclipseView = nullptr; firstAncestorOrThisOfType(eclipseView); if (eclipseView) { - return eclipseView->wellCollection; + return eclipseView->wellCollection(); } return nullptr; @@ -391,31 +400,47 @@ void RimIntersection::updateAzimuthLine() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > RimIntersection::polyLines() const +std::vector< std::vector > RimIntersection::polyLines(cvf::Vec3d * flattenedPolylineStartPoint) const { + if (flattenedPolylineStartPoint) *flattenedPolylineStartPoint = cvf::Vec3d::ZERO; + std::vector< std::vector > lines; + + double horizontalProjectedLengthAlongWellPathToClipPoint = 0.0; + if (type == CS_WELL_PATH) { if (wellPath() && wellPath->wellPathGeometry() ) { lines.push_back(wellPath->wellPathGeometry()->m_wellPathPoints); - clipToReservoir(lines[0]); + RimCase* ownerCase = nullptr; + this->firstAncestorOrThisOfType(ownerCase); + if (ownerCase) + { + size_t dummy; + lines[0] = RigWellPath::clipPolylineStartAboveZ(lines[0], + ownerCase->activeCellsBoundingBox().max().z(), + &horizontalProjectedLengthAlongWellPathToClipPoint, + &dummy); + } } } else if (type == CS_SIMULATION_WELL) { if (simulationWell()) { - updateWellCenterline(); + updateSimulationWellCenterline(); + + int branchIndexToUse = branchIndex(); - if (0 <= m_branchIndex && m_branchIndex < static_cast(m_wellBranchCenterlines.size())) + if (0 <= branchIndexToUse && branchIndexToUse < static_cast(m_simulationWellBranchCenterlines.size())) { - lines.push_back(m_wellBranchCenterlines[m_branchIndex]); + lines.push_back(m_simulationWellBranchCenterlines[branchIndexToUse]); } - if (m_branchIndex == -1) + if (branchIndexToUse == -1) { - lines = m_wellBranchCenterlines; + lines = m_simulationWellBranchCenterlines; } } } @@ -430,13 +455,38 @@ std::vector< std::vector > RimIntersection::polyLines() const if (type == CS_WELL_PATH || type == CS_SIMULATION_WELL) { + if (type == CS_SIMULATION_WELL && simulationWell()) + { + cvf::Vec3d top, bottom; + + simulationWell->wellHeadTopBottomPosition(-1, &top, &bottom); + + for ( size_t lIdx = 0; lIdx < lines.size(); ++lIdx ) + { + std::vector& polyLine = lines[lIdx]; + polyLine.insert(polyLine.begin(), top); + } + } + for (size_t lIdx = 0; lIdx < lines.size(); ++lIdx) { std::vector& polyLine = lines[lIdx]; addExtents(polyLine); } - } + if (flattenedPolylineStartPoint && lines.size() && lines[0].size() > 1) + { + (*flattenedPolylineStartPoint)[0] = horizontalProjectedLengthAlongWellPathToClipPoint - m_extentLength; + (*flattenedPolylineStartPoint)[2] = lines[0][1].z(); // Depth of first point in first polyline + } + } + else + { + if ( flattenedPolylineStartPoint && lines.size() && lines[0].size() ) + { + (*flattenedPolylineStartPoint)[2] = lines[0][0].z(); // Depth of first point in first polyline + } + } return lines; } @@ -453,44 +503,30 @@ RivIntersectionPartMgr* RimIntersection::intersectionPartMgr() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector< std::vector > RimIntersection::polyLinesForExtrusionDirection() const +std::vector RimIntersection::polyLinesForExtrusionDirection() const { - std::vector< std::vector > lines; - - lines.push_back(m_customExtrusionPoints); - - return lines; + return m_customExtrusionPoints; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersection::updateWellCenterline() const +void RimIntersection::updateSimulationWellCenterline() const { if (isActive() && type == CS_SIMULATION_WELL && simulationWell()) { - if (m_wellBranchCenterlines.size() == 0) + if (m_simulationWellBranchCenterlines.empty()) { - RimEclipseCase* rimEclCase = nullptr; - simulationWell->firstAncestorOrThisOfType(rimEclCase); - if (rimEclCase) + auto branches = simulationWell->wellPipeBranches(); + for (const auto& branch : branches) { - bool includeCellCenters = false; - bool detectBrances = true; - - RigEclipseCaseData* caseData = rimEclCase->eclipseCaseData(); - auto branches = caseData->simulationWellBranches(simulationWell->name, includeCellCenters, detectBrances); - - for (auto b : branches) - { - m_wellBranchCenterlines.push_back(b->m_wellPathPoints); - } + m_simulationWellBranchCenterlines.push_back(branch->m_wellPathPoints); } } } else { - m_wellBranchCenterlines.clear(); + m_simulationWellBranchCenterlines.clear(); } } @@ -576,9 +612,9 @@ void RimIntersection::updateName() if (type == CS_SIMULATION_WELL && simulationWell()) { name = simulationWell()->name(); - if (m_branchIndex() != -1) + if (branchIndex() != -1) { - name = name() + " Branch " + QString::number(m_branchIndex() + 1); + name = name() + " Branch " + QString::number(branchIndex() + 1); } } else if (type() == CS_WELL_PATH && wellPath()) @@ -586,52 +622,32 @@ void RimIntersection::updateName() name = wellPath()->name(); } + Rim2dIntersectionView* iView = correspondingIntersectionView(); + if (iView) + { + iView->updateName(); + iView->updateConnectedEditors(); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersection::clipToReservoir(std::vector &polyLine) const +int RimIntersection::branchIndex() const { - RimCase* ownerCase = nullptr; - firstAncestorOrThisOfType(ownerCase); - - std::vector clippedPolyLine; + RimSimWellInViewCollection* coll = simulationWellCollection(); - if (ownerCase) + if (coll && !coll->isAutoDetectingBranches()) { - cvf::BoundingBox caseBB = ownerCase->activeCellsBoundingBox(); - bool hasEnteredReservoirBB = false; - for (size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx) - { - if (!caseBB.contains(polyLine[vxIdx])) - { - continue; - } - - if (!hasEnteredReservoirBB) - { - if (vxIdx > 0) - { - // clip line, and add vx to start - cvf::Plane topPlane; - topPlane.setFromPointAndNormal(caseBB.max(), cvf::Vec3d::Z_AXIS); - cvf::Vec3d intersection; - - if (topPlane.intersect(polyLine[vxIdx-1], polyLine[vxIdx], &intersection)) - { - clippedPolyLine.push_back(intersection); - } - } - - hasEnteredReservoirBB = true; - } + return -1; + } - clippedPolyLine.push_back(polyLine[vxIdx]); - } + if (m_branchIndex >= static_cast(m_simulationWellBranchCenterlines.size())) + { + return -1; } - - polyLine.swap(clippedPolyLine); + + return m_branchIndex; } //-------------------------------------------------------------------------------------------------- @@ -723,6 +739,24 @@ void RimIntersection::appendPointToPolyLine(const cvf::Vec3d& point) rebuildGeometryAndScheduleCreateDisplayModel(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* RimIntersection::correspondingIntersectionView() +{ + std::vector objects; + + this->objectsWithReferringPtrFields(objects); + Rim2dIntersectionView* isectView = nullptr; + for (auto obj : objects) + { + isectView = dynamic_cast(obj); + if (isectView) break; + } + return isectView; + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -830,6 +864,36 @@ void RimIntersection::setLengthDown(double lengthDown) m_lengthDown = lengthDown; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimIntersection::extentLength() +{ + return m_extentLength(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersection::recomputeSimulationWellBranchData() +{ + if (type() == CS_SIMULATION_WELL) + { + m_simulationWellBranchCenterlines.clear(); + updateSimulationWellCenterline(); + + m_crossSectionPartMgr = nullptr; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimIntersection::hasDefiningPoints() const +{ + return type == CS_POLYLINE || type == CS_AZIMUTHLINE; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -845,12 +909,19 @@ void RimIntersection::rebuildGeometryAndScheduleCreateDisplayModel() { m_crossSectionPartMgr = nullptr; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { rimView->scheduleCreateDisplayModelAndRedraw(); } + + Rim2dIntersectionView * iview = correspondingIntersectionView(); + if (iview) + { + iview->scheduleGeometryRegen(RivCellSetEnum::ALL_CELLS); + iview->scheduleCreateDisplayModelAndRedraw(); + } } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimIntersection.h b/ApplicationCode/ProjectDataModel/RimIntersection.h index 9de727ec40..3d30d1c1c3 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersection.h @@ -33,6 +33,7 @@ class RimWellPath; class RivIntersectionPartMgr; class RimSimWellInView; class RimSimWellInViewCollection; +class Rim2dIntersectionView; namespace caf { @@ -83,12 +84,13 @@ class RimIntersection : public caf::PdmObject caf::PdmField< bool > inputExtrusionPointsFromViewerEnabled; caf::PdmField< bool > inputTwoAzimuthPointsFromViewerEnabled; - std::vector< std::vector > polyLines() const; + std::vector< std::vector > polyLines(cvf::Vec3d * flattenedPolylineStartPoint = nullptr) const; void appendPointToPolyLine(const cvf::Vec3d& point); + Rim2dIntersectionView* correspondingIntersectionView(); RivIntersectionPartMgr* intersectionPartMgr(); - std::vector< std::vector > polyLinesForExtrusionDirection() const; + std::vector polyLinesForExtrusionDirection() const; void appendPointToExtrusionDirection(const cvf::Vec3d& point); void appendPointToAzimuthLine(const cvf::Vec3d& point); @@ -98,7 +100,11 @@ class RimIntersection : public caf::PdmObject double lengthDown() const; void setLengthUp(double heightUp); void setLengthDown(double heightDown); + double extentLength(); + void recomputeSimulationWellBranchData(); + bool hasDefiningPoints() const; + int branchIndex() const; protected: virtual caf::PdmFieldHandle* userDescriptionField(); virtual caf::PdmFieldHandle* objectToggleField(); @@ -110,7 +116,9 @@ class RimIntersection : public caf::PdmObject virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - + +private: + private: caf::PdmField m_branchIndex; caf::PdmField m_extentLength; @@ -126,12 +134,11 @@ class RimIntersection : public caf::PdmObject static void setPushButtonText(bool buttonEnable, caf::PdmUiPushButtonEditorAttribute* attribute); static void setBaseColor(bool enable, caf::PdmUiListEditorAttribute* attribute); - RimSimWellInViewCollection* simulationWellCollection(); + RimSimWellInViewCollection* simulationWellCollection() const; void updateAzimuthLine(); - void updateWellCenterline() const; + void updateSimulationWellCenterline() const; void updateWellExtentDefaultValue(); void addExtents(std::vector &polyLine) const; - void clipToReservoir(std::vector &polyLine) const; void updateName(); void rebuildGeometryAndScheduleCreateDisplayModel(); static double azimuthInRadians(cvf::Vec3d vec); @@ -139,5 +146,5 @@ class RimIntersection : public caf::PdmObject cvf::ref m_crossSectionPartMgr; mutable - std::vector< std::vector > m_wellBranchCenterlines; + std::vector< std::vector > m_simulationWellBranchCenterlines; }; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp index 7b6d6b8b5a..402a717a2d 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionBox.cpp @@ -20,7 +20,7 @@ #include "RimCase.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "IntersectionBoxCommands/RicBoxManipulatorEventHandler.h" @@ -318,7 +318,7 @@ void RimIntersectionBox::fieldChangedByUi(const caf::PdmFieldHandle* changedFiel { if (m_boxManipulator) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) @@ -345,7 +345,7 @@ void RimIntersectionBox::updateBoxManipulatorGeometry() { if (m_boxManipulator.isNull()) return; - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (!rimView) return; @@ -470,7 +470,7 @@ void RimIntersectionBox::initAfterRead() //-------------------------------------------------------------------------------------------------- void RimIntersectionBox::slotScheduleRedraw() { - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) { @@ -483,7 +483,7 @@ void RimIntersectionBox::slotScheduleRedraw() //-------------------------------------------------------------------------------------------------- void RimIntersectionBox::slotUpdateGeometry(const cvf::Vec3d& origin, const cvf::Vec3d& size) { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); if (rimView) @@ -628,7 +628,7 @@ void RimIntersectionBox::switchSingelPlaneState() //-------------------------------------------------------------------------------------------------- cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox() { - RimCase* rimCase = NULL; + RimCase* rimCase = nullptr; this->firstAncestorOrThisOfType(rimCase); CVF_ASSERT(rimCase); @@ -654,7 +654,7 @@ cvf::BoundingBox RimIntersectionBox::currentCellBoundingBox() //-------------------------------------------------------------------------------------------------- RiuViewer* RimIntersectionBox::viewer() { - RimView* rimView = nullptr; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); RiuViewer* riuViewer = nullptr; diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp index ae205a7e32..f18423d6b8 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.cpp @@ -19,12 +19,15 @@ #include "RimIntersectionCollection.h" +#include "Rim2dIntersectionView.h" +#include "Rim2dIntersectionViewCollection.h" +#include "Rim3dView.h" +#include "RimCase.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" #include "RimSimWellInView.h" -#include "RimView.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RivIntersectionBoxPartMgr.h" #include "RivIntersectionPartMgr.h" @@ -93,7 +96,9 @@ void RimIntersectionCollection::applySingleColorEffect() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) +void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper) { if(!this->isActive()) return; @@ -101,7 +106,7 @@ void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) { if(cs->isActive) { - cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex); + cs->intersectionPartMgr()->updateCellResultColor(timeStepIndex, scalarColorMapper, ternaryColorMapper); } } @@ -117,7 +122,7 @@ void RimIntersectionCollection::updateCellResultColor(size_t timeStepIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform) +void RimIntersectionCollection::appendPartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform) { if (!isActive) return; @@ -127,7 +132,7 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c { cs->intersectionPartMgr()->appendNativeCrossSectionFacesToModel(model, scaleTransform); cs->intersectionPartMgr()->appendMeshLinePartsToModel(model, scaleTransform); - cs->intersectionPartMgr()->appendPolylinePartsToModel(model, scaleTransform); + cs->intersectionPartMgr()->appendPolylinePartsToModel(view, model, scaleTransform); } } @@ -146,6 +151,33 @@ void RimIntersectionCollection::appendPartsToModel(cvf::ModelBasicList* model, c } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimIntersectionCollection::intersections() const +{ + return m_intersections.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimIntersectionCollection::intersectionBoxes() const +{ + return m_intersectionBoxes.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::recomputeSimWellBranchData() +{ + for (const auto& intersection : intersections()) + { + intersection->recomputeSimulationWellBranchData(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -153,10 +185,12 @@ void RimIntersectionCollection::appendIntersectionAndUpdate(RimIntersection* int { m_intersections.push_back(intersection); + syncronize2dIntersectionViews(); + updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(intersection); + Riu3DMainWindowTools::selectAsCurrentItem(intersection); - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); if (rimView) { @@ -164,6 +198,35 @@ void RimIntersectionCollection::appendIntersectionAndUpdate(RimIntersection* int } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::appendIntersectionNoUpdate(RimIntersection* intersection) +{ + m_intersections.push_back(intersection); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::syncronize2dIntersectionViews() +{ + RimCase* ownerCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(ownerCase); + ownerCase->intersectionViewCollection()->syncFromExistingIntersections(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::scheduleCreateDisplayModelAndRedraw2dIntersectionViews() +{ + for (RimIntersection* isection: m_intersections) + { + isection->correspondingIntersectionView()->scheduleCreateDisplayModelAndRedraw(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -172,9 +235,9 @@ void RimIntersectionCollection::appendIntersectionBoxAndUpdate(RimIntersectionBo m_intersectionBoxes.push_back(intersectionBox); updateConnectedEditors(); - RiuMainWindow::instance()->selectAsCurrentItem(intersectionBox); + Riu3DMainWindowTools::selectAsCurrentItem(intersectionBox); - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); if (rimView) { @@ -182,6 +245,14 @@ void RimIntersectionCollection::appendIntersectionBoxAndUpdate(RimIntersectionBo } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntersectionCollection::appendIntersectionBoxNoUpdate(RimIntersectionBox* intersectionBox) +{ + m_intersectionBoxes.push_back(intersectionBox); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -189,7 +260,7 @@ void RimIntersectionCollection::fieldChangedByUi(const caf::PdmFieldHandle* chan { if (changedField == &isActive) { - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; firstAncestorOrThisOfType(rimView); if (rimView) { diff --git a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h index 631107f5e7..12b0fd9eac 100644 --- a/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h +++ b/ApplicationCode/ProjectDataModel/RimIntersectionCollection.h @@ -23,14 +23,17 @@ #include "cafPdmChildArrayField.h" #include "cafPdmField.h" +class Rim3dView; class RimIntersection; class RimIntersectionBox; class RimEclipseCellColors; class RimSimWellInView; +class RivTernaryScalarMapper; namespace cvf { class ModelBasicList; class Transform; + class ScalarMapper; } //================================================================================================== @@ -49,18 +52,29 @@ class RimIntersectionCollection : public caf::PdmObject caf::PdmField isActive; void appendIntersectionAndUpdate(RimIntersection* intersection); + void appendIntersectionNoUpdate(RimIntersection* intersection); void appendIntersectionBoxAndUpdate(RimIntersectionBox* intersectionBox); + void appendIntersectionBoxNoUpdate(RimIntersectionBox* intersectionBox); bool hasActiveIntersectionForSimulationWell(const RimSimWellInView* simWell) const; void updateIntersectionBoxGeometry(); + void syncronize2dIntersectionViews(); + void scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + void recomputeSimWellBranchData(); + // Visualization interface void applySingleColorEffect(); - void updateCellResultColor(size_t timeStepIndex); - void appendPartsToModel(cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + void updateCellResultColor(size_t timeStepIndex, + const cvf::ScalarMapper* scalarColorMapper, + const RivTernaryScalarMapper* ternaryColorMapper); + void appendPartsToModel(Rim3dView& view, cvf::ModelBasicList* model, cvf::Transform* scaleTransform); + + std::vector intersections() const; + std::vector intersectionBoxes() const; protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp index 0207ce94d2..c95c9ab734 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.cpp @@ -1,156 +1,43 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS -// +// Copyright (C) 2018 Statoil ASA +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RimLegendConfig.h" -#include "RiaApplication.h" -#include "RiaColorTables.h" - -#include "RimCellEdgeColors.h" -#include "RimEclipseCellColors.h" -#include "RimEclipseView.h" -#include "RimGeoMechResultDefinition.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimStimPlanColors.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - -#include "RimViewLinker.h" - -#include "cafCategoryLegend.h" -#include "cafCategoryMapper.h" - -#include "cafFactory.h" -#include "cafPdmFieldCvfColor.h" -#include "cafPdmFieldCvfMat4d.h" -#include "cafPdmUiComboBoxEditor.h" -#include "cafPdmUiLineEditor.h" - -#include "cvfOverlayScalarMapperLegend.h" -#include "cvfScalarMapperContinuousLinear.h" -#include "cvfScalarMapperContinuousLog.h" -#include "cvfScalarMapperDiscreteLinear.h" -#include "cvfScalarMapperDiscreteLog.h" -#include "cvfqtUtils.h" - -#include - - -CAF_PDM_SOURCE_INIT(RimLegendConfig, "Legend"); +// NB! Special macro for pure virtual class +CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimLegendConfig, "LegendConfig"); namespace caf { template<> void AppEnum::setUp() { - addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "All Timesteps"); - addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Current Timestep"); - addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); + addItem(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Min and Max for All Timesteps"); + addItem(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP, "AUTOMATIC_CURRENT_TIMESTEP", "Min and Max for Current Timestep"); + addItem(RimLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User Defined Range"); setDefault(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS); } } -namespace caf { - template<> - void RimLegendConfig::ColorRangeEnum::setUp() - { - addItem(RimLegendConfig::NORMAL, "NORMAL", "Full color, Red on top"); - addItem(RimLegendConfig::OPPOSITE_NORMAL,"OPPOSITE_NORMAL", "Full color, Blue on top"); - addItem(RimLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink"); - addItem(RimLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white"); - addItem(RimLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red"); - addItem(RimLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue"); - addItem(RimLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black"); - addItem(RimLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white"); - addItem(RimLegendConfig::CATEGORY, "CATEGORY", "Category colors"); - addItem(RimLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic"); - addItem(RimLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors"); - setDefault(RimLegendConfig::NORMAL); - } -} - -namespace caf { - template<> - void RimLegendConfig::MappingEnum::setUp() - { - addItem(RimLegendConfig::LINEAR_DISCRETE, "LinearDiscrete", "Discrete Linear"); - addItem(RimLegendConfig::LINEAR_CONTINUOUS, "LinearContinuous", "Continuous Linear"); - addItem(RimLegendConfig::LOG10_CONTINUOUS, "Log10Continuous", "Continuous Logarithmic"); - addItem(RimLegendConfig::LOG10_DISCRETE, "Log10Discrete", "Discrete Logarithmic"); - addItem(RimLegendConfig::CATEGORY_INTEGER, "Category", "Category"); - setDefault(RimLegendConfig::LINEAR_CONTINUOUS); - } -} - -namespace caf { - template<> - void AppEnum::setUp() - { - addItem( RimLegendConfig::AUTO, "AUTO", "Automatic"); - addItem( RimLegendConfig::FIXED, "FIXED", "Fixed, decimal"); - addItem( RimLegendConfig::SCIENTIFIC, "SCIENTIFIC", "Scientific notation"); - setDefault(RimLegendConfig::FIXED); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig::RimLegendConfig() - : m_globalAutoMax(cvf::UNDEFINED_DOUBLE), - m_globalAutoMin(cvf::UNDEFINED_DOUBLE), - m_localAutoMax(cvf::UNDEFINED_DOUBLE), - m_localAutoMin(cvf::UNDEFINED_DOUBLE), - m_globalAutoPosClosestToZero(0), - m_globalAutoNegClosestToZero(0), - m_localAutoPosClosestToZero(0), - m_localAutoNegClosestToZero(0), - m_isAllTimeStepsRangeDisabled(false) +RimLegendConfig::RimLegendConfig() { - CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); - CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); - CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); - CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); - - CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Colors", "", "", ""); - CAF_PDM_InitField(&m_mappingMode, "MappingMode", MappingEnum(LINEAR_CONTINUOUS) , "Mapping", "", "", ""); - CAF_PDM_InitField(&m_rangeMode, "RangeType", RangeModeEnum(AUTOMATIC_ALLTIMESTEPS), "Range Type", "", "Switches between automatic and user defined range on the legend", ""); - CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Max value of the legend", ""); - CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Min value of the legend (if mapping is logarithmic only positive values are valid)", ""); - CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", ""); - resultVariableName.uiCapability()->setUiHidden(true); - - m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; - m_logDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLog; - m_linSmoothScalarMapper = new cvf::ScalarMapperContinuousLinear; - m_logSmoothScalarMapper = new cvf::ScalarMapperContinuousLog; - - m_currentScalarMapper = m_linDiscreteScalarMapper; - m_categoryMapper = new caf::CategoryMapper; - - cvf::Font* standardFont = RiaApplication::instance()->standardFont(); - m_scalarMapperLegend = new cvf::OverlayScalarMapperLegend(standardFont); - m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p()); - - updateFieldVisibility(); - updateLegend(); } //-------------------------------------------------------------------------------------------------- @@ -160,698 +47,3 @@ RimLegendConfig::~RimLegendConfig() { } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) -{ - if (changedField == &m_numLevels) - { - int upperLimit = std::numeric_limits::max(); - m_numLevels = cvf::Math::clamp(m_numLevels.v(), 1, upperLimit); - } - else if (changedField == &m_rangeMode || - changedField == &m_mappingMode) - { - if (m_rangeMode == USER_DEFINED) - { - if (m_userDefinedMaxValue == m_userDefinedMaxValue.defaultValue() && m_globalAutoMax != cvf::UNDEFINED_DOUBLE) - { - m_userDefinedMaxValue = roundToNumSignificantDigits(m_globalAutoMax, m_precision); - } - if (m_userDefinedMinValue == m_userDefinedMinValue.defaultValue() && m_globalAutoMin != cvf::UNDEFINED_DOUBLE) - { - m_userDefinedMinValue = roundToNumSignificantDigits(m_globalAutoMin, m_precision); - } - } - - updateFieldVisibility(); - } - - updateLegend(); - - RimView* view = nullptr; - this->firstAncestorOrThisOfType(view); - - if (view) - { - RimViewLinker* viewLinker = view->assosiatedViewLinker(); - if (viewLinker) - { - viewLinker->updateCellResult(); - } - - view->updateCurrentTimeStepAndRedraw(); - } - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - - // Update stim plan templates if relevant - RimStimPlanColors* stimPlanColors; - firstAncestorOrThisOfType(stimPlanColors); - if (stimPlanColors) - { - stimPlanColors->updateStimPlanTemplates(); - } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::updateLegend() -{ - double adjustedMin = cvf::UNDEFINED_DOUBLE; - double adjustedMax = cvf::UNDEFINED_DOUBLE; - - double posClosestToZero = cvf::UNDEFINED_DOUBLE; - double negClosestToZero = cvf::UNDEFINED_DOUBLE; - - if (m_rangeMode == AUTOMATIC_ALLTIMESTEPS) - { - adjustedMin = roundToNumSignificantDigits(m_globalAutoMin, m_precision); - adjustedMax = roundToNumSignificantDigits(m_globalAutoMax, m_precision); - - posClosestToZero = m_globalAutoPosClosestToZero; - negClosestToZero = m_globalAutoNegClosestToZero; - } - else if (m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP) - { - adjustedMin = roundToNumSignificantDigits(m_localAutoMin, m_precision); - adjustedMax = roundToNumSignificantDigits(m_localAutoMax, m_precision); - - posClosestToZero = m_localAutoPosClosestToZero; - negClosestToZero = m_localAutoNegClosestToZero; - } - else - { - adjustedMin = roundToNumSignificantDigits(m_userDefinedMinValue, m_precision); - adjustedMax = roundToNumSignificantDigits(m_userDefinedMaxValue, m_precision); - - posClosestToZero = m_globalAutoPosClosestToZero; - negClosestToZero = m_globalAutoNegClosestToZero; - } - - m_linDiscreteScalarMapper->setRange(adjustedMin, adjustedMax); - m_linSmoothScalarMapper->setRange(adjustedMin, adjustedMax); - - if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE) - { - if (adjustedMin != adjustedMax) - { - if (adjustedMin == 0) - { - if (adjustedMax > adjustedMin) - { - adjustedMin = posClosestToZero; - } - else - { - adjustedMin = negClosestToZero; - } - } - else if (adjustedMax == 0) - { - if (adjustedMin > adjustedMax) - { - adjustedMax = posClosestToZero; - } - else - { - adjustedMax = negClosestToZero; - } - } - else if (adjustedMin < 0 && adjustedMax > 0) - { - adjustedMin = posClosestToZero; - } - else if (adjustedMax < 0 && adjustedMin > 0) - { - adjustedMin = negClosestToZero; - } - } - } - - m_logDiscreteScalarMapper->setRange(adjustedMin, adjustedMax); - m_logSmoothScalarMapper->setRange(adjustedMin, adjustedMax); - - cvf::Color3ubArray legendColors = colorArrayFromColorType(m_colorRangeMode()); - - m_linDiscreteScalarMapper->setColors(legendColors); - m_logDiscreteScalarMapper->setColors(legendColors); - m_logSmoothScalarMapper->setColors(legendColors); - m_linSmoothScalarMapper->setColors(legendColors); - - - m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true); - m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true); - m_logSmoothScalarMapper->setLevelCount(m_numLevels, true); - m_linSmoothScalarMapper->setLevelCount(m_numLevels, true); - - switch(m_mappingMode()) - { - case LINEAR_DISCRETE: - m_currentScalarMapper = m_linDiscreteScalarMapper.p(); - break; - case LINEAR_CONTINUOUS: - m_currentScalarMapper = m_linSmoothScalarMapper.p(); - break; - case LOG10_CONTINUOUS: - m_currentScalarMapper = m_logSmoothScalarMapper.p(); - break; - case LOG10_DISCRETE: - m_currentScalarMapper = m_logDiscreteScalarMapper.p(); - break; - case CATEGORY_INTEGER: - m_categoryMapper->setCategoriesWithNames(m_categories, m_categoryNames); - - if (m_categoryColors.size() > 0) - { - m_categoryMapper->setCycleColors(m_categoryColors); - } - else - { - m_categoryMapper->setInterpolateColors(legendColors); - } - m_currentScalarMapper = m_categoryMapper.p(); - break; - default: - break; - } - - if (m_currentScalarMapper != m_categoryMapper.p()) - { - m_scalarMapperLegend->setScalarMapper(m_currentScalarMapper.p()); - } - double decadesInRange = 0; - - if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE) - { - // For log mapping, use the min value as reference for num valid digits - decadesInRange = cvf::Math::abs(adjustedMin) < cvf::Math::abs(adjustedMax) ? cvf::Math::abs(adjustedMin) : cvf::Math::abs(adjustedMax); - decadesInRange = log10(decadesInRange); - } - else - { - // For linear mapping, use the max value as reference for num valid digits - double absRange = CVF_MAX(cvf::Math::abs(adjustedMax), cvf::Math::abs(adjustedMin)); - decadesInRange = log10(absRange); - } - - decadesInRange = cvf::Math::ceil(decadesInRange); - - // Using Fixed format - NumberFormatType nft = m_tickNumberFormat(); - m_scalarMapperLegend->setTickFormat((cvf::OverlayScalarMapperLegend::NumberFormat)nft); - - // Set the fixed number of digits after the decimal point to the number needed to show all the significant digits. - int numDecimalDigits = m_precision(); - if (nft != SCIENTIFIC) - { - numDecimalDigits -= static_cast(decadesInRange); - } - m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); - - - if (m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) - { - m_userDefinedMaxValue.uiCapability()->setUiName(QString("Max ") + "(" + QString::number(m_globalAutoMax, 'g', m_precision) + ")"); - } - else - { - m_userDefinedMaxValue.uiCapability()->setUiName(QString()); - } - - if (m_globalAutoMin != cvf::UNDEFINED_DOUBLE ) - { - m_userDefinedMinValue.uiCapability()->setUiName(QString("Min ") + "(" + QString::number(m_globalAutoMin, 'g', m_precision) + ")"); - } - else - { - m_userDefinedMinValue.uiCapability()->setUiName(QString()); - } -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::disableAllTimeStepsRange(bool doDisable) -{ - // If we enable AllTimesteps, and we have used current timestep, then "restore" the default - if (m_isAllTimeStepsRangeDisabled && !doDisable && m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP) m_rangeMode = AUTOMATIC_ALLTIMESTEPS; - - m_isAllTimeStepsRangeDisabled = doDisable; - - if (doDisable && m_rangeMode == AUTOMATIC_ALLTIMESTEPS) m_rangeMode = AUTOMATIC_CURRENT_TIMESTEP; - -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax) -{ - double candidateGlobalAutoMin = roundToNumSignificantDigits(globalMin, m_precision); - double candidateGlobalAutoMax = roundToNumSignificantDigits(globalMax, m_precision); - - double candidateLocalAutoMin = roundToNumSignificantDigits(localMin, m_precision); - double candidateLocalAutoMax = roundToNumSignificantDigits(localMax, m_precision); - - bool needsUpdate = false; - const double epsilon = std::numeric_limits::epsilon(); - - if (cvf::Math::abs(candidateGlobalAutoMax - m_globalAutoMax) > epsilon) - { - needsUpdate = true; - } - - if (cvf::Math::abs(candidateGlobalAutoMin - m_globalAutoMin) > epsilon) - { - needsUpdate = true; - } - - if (cvf::Math::abs(candidateLocalAutoMax - m_localAutoMax) > epsilon) - { - needsUpdate = true; - } - - if (cvf::Math::abs(candidateLocalAutoMin - m_localAutoMin) > epsilon) - { - needsUpdate = true; - } - - if (needsUpdate) - { - m_globalAutoMin = candidateGlobalAutoMin; - m_globalAutoMax = candidateGlobalAutoMax; - - m_localAutoMin = candidateLocalAutoMin; - m_localAutoMax = candidateLocalAutoMax; - - updateLegend(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::initAfterRead() -{ - updateFieldVisibility(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::updateFieldVisibility() -{ - bool showRangeItems = m_mappingMode == CATEGORY_INTEGER ? false : true; - - m_numLevels.uiCapability()->setUiHidden(!showRangeItems); - m_precision.uiCapability()->setUiHidden(!showRangeItems); - m_tickNumberFormat.uiCapability()->setUiHidden(!showRangeItems); - m_rangeMode.uiCapability()->setUiHidden(!showRangeItems); - - if (showRangeItems && m_rangeMode == USER_DEFINED) - { - m_userDefinedMaxValue.uiCapability()->setUiHidden(false); - m_userDefinedMinValue.uiCapability()->setUiHidden(false); - } - else - { - m_userDefinedMaxValue.uiCapability()->setUiHidden(true); - m_userDefinedMinValue.uiCapability()->setUiHidden(true); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setColorRangeMode(ColorRangesType colorMode) -{ - m_colorRangeMode = colorMode; - updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setMappingMode(MappingType mappingType) -{ - m_mappingMode = mappingType; - updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::recreateLegend() -{ - // Due to possible visualization bug, we need to recreate the legend if the last viewer - // has been removed, (and thus the opengl resources has been deleted) The text in - // the legend disappeared because of this, so workaround: recreate the legend when needed: - - cvf::Font* standardFont = RiaApplication::instance()->standardFont(); - m_scalarMapperLegend = new cvf::OverlayScalarMapperLegend(standardFont); - m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p()); - - updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// Rounding the double value to given number of significant digits -//-------------------------------------------------------------------------------------------------- -double RimLegendConfig::roundToNumSignificantDigits(double domainValue, double numSignificantDigits) -{ - double absDomainValue = cvf::Math::abs(domainValue); - if (absDomainValue == 0.0) - { - return 0.0; - } - - double logDecValue = log10(absDomainValue); - logDecValue = cvf::Math::ceil(logDecValue); - - double factor = pow(10.0, numSignificantDigits - logDecValue); - - double tmp = domainValue * factor; - double integerPart; - double fraction = modf(tmp, &integerPart); - - if (cvf::Math::abs(fraction)>= 0.5) (integerPart >= 0) ? integerPart++: integerPart-- ; - - double newDomainValue = integerPart / factor; - - return newDomainValue; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero) -{ - bool needsUpdate = false; - const double epsilon = std::numeric_limits::epsilon(); - - if (cvf::Math::abs(globalPosClosestToZero - m_globalAutoPosClosestToZero) > epsilon) - { - needsUpdate = true; - } - if (cvf::Math::abs(globalNegClosestToZero - m_globalAutoNegClosestToZero) > epsilon) - { - needsUpdate = true; - } - if (cvf::Math::abs(localPosClosestToZero - m_localAutoPosClosestToZero) > epsilon) - { - needsUpdate = true; - } - if (cvf::Math::abs(localNegClosestToZero - m_localAutoNegClosestToZero) > epsilon) - { - needsUpdate = true; - } - - if (needsUpdate) - { - m_globalAutoPosClosestToZero = globalPosClosestToZero; - m_globalAutoNegClosestToZero = globalNegClosestToZero; - m_localAutoPosClosestToZero = localPosClosestToZero; - m_localAutoNegClosestToZero = localNegClosestToZero; - - if (m_globalAutoPosClosestToZero == HUGE_VAL) m_globalAutoPosClosestToZero = 0; - if (m_globalAutoNegClosestToZero == -HUGE_VAL) m_globalAutoNegClosestToZero = 0; - if (m_localAutoPosClosestToZero == HUGE_VAL) m_localAutoPosClosestToZero = 0; - if (m_localAutoNegClosestToZero == -HUGE_VAL) m_localAutoNegClosestToZero = 0; - - updateLegend(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setIntegerCategories(const std::vector& categories) -{ - m_categories = categories; - m_categoryNames.clear(); - m_categoryColors.clear(); - - updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setNamedCategoriesInverse(const std::vector& categoryNames) -{ - std::vector nameIndices; - std::vector names; - for(int i = static_cast(categoryNames.size()) - 1; i >= 0; --i) - { - nameIndices.push_back(i); - names.push_back(cvfqt::Utils::toString(categoryNames[i])); - } - - m_categories = nameIndices; - m_categoryNames = names; - m_categoryColors.clear(); - - updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setCategoryItems(const std::vector< std::tuple >& categories) -{ - m_categories.clear(); - m_categoryNames.clear(); - m_categoryColors.clear(); - m_categoryColors.reserve(categories.size()); - - for (auto item : categories) - { - m_categoryNames.push_back(cvfqt::Utils::toString(std::get<0>(item))); - m_categories.push_back(std::get<1>(item)); - m_categoryColors.add(std::get<2>(item)); - } - - updateLegend(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QString RimLegendConfig::categoryNameFromCategoryValue(double categoryResultValue) const -{ - if (categoryResultValue == HUGE_VAL) return "Undefined"; - - if (m_categoryNames.size() > 0) - { - for (size_t categoryIndex = 0; categoryIndex < m_categories.size(); categoryIndex++) - { - if (categoryResultValue == m_categories[categoryIndex]) - { - return cvfqt::Utils::toQString(m_categoryNames[categoryIndex]); - } - } - } - - return QString("%1").arg(categoryResultValue); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setTitle(const cvf::String& title) -{ - m_scalarMapperLegend->setTitle(title); - m_categoryLegend->setTitle(title); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::OverlayItem* RimLegendConfig::legend() -{ - if (m_currentScalarMapper == m_categoryMapper) - { - return m_categoryLegend.p(); - } - else - { - return m_scalarMapperLegend.p(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig) -{ - QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); - this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Color3ubArray RimLegendConfig::colorArrayFromColorType(ColorRangesType colorType) -{ - switch (colorType) - { - case RimLegendConfig::NORMAL: - return RiaColorTables::normalPaletteColors().color3ubArray(); - break; - case RimLegendConfig::OPPOSITE_NORMAL: - return RiaColorTables::normalPaletteOppositeOrderingColors().color3ubArray(); - break; - case RimLegendConfig::WHITE_PINK: - return RiaColorTables::whitePinkPaletteColors().color3ubArray(); - break; - case RimLegendConfig::PINK_WHITE: - return RiaColorTables::pinkWhitePaletteColors().color3ubArray(); - break; - case RimLegendConfig::WHITE_BLACK: - return RiaColorTables::whiteBlackPaletteColors().color3ubArray(); - break; - case RimLegendConfig::BLACK_WHITE: - return RiaColorTables::blackWhitePaletteColors().color3ubArray(); - break; - case RimLegendConfig::BLUE_WHITE_RED: - return RiaColorTables::blueWhiteRedPaletteColors().color3ubArray(); - break; - case RimLegendConfig::RED_WHITE_BLUE: - return RiaColorTables::redWhiteBluePaletteColors().color3ubArray(); - break; - case RimLegendConfig::CATEGORY: - return RiaColorTables::categoryPaletteColors().color3ubArray(); - break; - case RimLegendConfig::ANGULAR: - return RiaColorTables::angularPaletteColors().color3ubArray(); - break; - case RimLegendConfig::STIMPLAN: - return RiaColorTables::stimPlanPaletteColors().color3ubArray(); - break; - default: - break; - } - - return RiaColorTables::normalPaletteColors().color3ubArray(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) -{ - { - caf::PdmUiOrdering * formatGr = uiOrdering.addNewGroup("Format"); - formatGr->add(&m_numLevels); - formatGr->add(&m_precision); - formatGr->add(&m_tickNumberFormat); - formatGr->add(&m_colorRangeMode); - - caf::PdmUiOrdering * mappingGr = uiOrdering.addNewGroup("Mapping"); - mappingGr->add(&m_mappingMode); - mappingGr->add(&m_rangeMode); - mappingGr->add(&m_userDefinedMaxValue); - mappingGr->add(&m_userDefinedMinValue); - } - - updateFieldVisibility(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList RimLegendConfig::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) -{ - bool hasStimPlanParent = false; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - RimStimPlanColors* stimPlanColors = nullptr; - this->firstAncestorOrThisOfType(stimPlanColors); - if (stimPlanColors) hasStimPlanParent = true; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - bool isCategoryResult = false; - { - RimEclipseCellColors* eclCellColors = nullptr; - this->firstAncestorOrThisOfType(eclCellColors); - RimGeoMechResultDefinition* gmCellColors = nullptr; - this->firstAncestorOrThisOfType(gmCellColors); - RimCellEdgeColors* eclCellEdgColors = nullptr; - this->firstAncestorOrThisOfType(eclCellEdgColors); - - if ( ( eclCellColors && eclCellColors->hasCategoryResult()) - || ( gmCellColors && gmCellColors->hasCategoryResult()) - || ( eclCellEdgColors && eclCellEdgColors->hasCategoryResult()) ) - { - isCategoryResult = true; - } - } - - QList options; - - if (fieldNeedingOptions == &m_mappingMode) - { - // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of this type - std::vector mappingTypes; - mappingTypes.push_back(LINEAR_DISCRETE); - mappingTypes.push_back(LINEAR_CONTINUOUS); - mappingTypes.push_back(LOG10_CONTINUOUS); - mappingTypes.push_back(LOG10_DISCRETE); - - if (isCategoryResult) - { - mappingTypes.push_back(CATEGORY_INTEGER); - } - - for(MappingType mapType: mappingTypes) - { - options.push_back(caf::PdmOptionItemInfo(MappingEnum::uiText(mapType), mapType)); - } - } - else if (fieldNeedingOptions == &m_colorRangeMode) - { - // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of this type - std::vector rangeTypes; - rangeTypes.push_back(NORMAL); - rangeTypes.push_back(OPPOSITE_NORMAL); - rangeTypes.push_back(WHITE_PINK); - rangeTypes.push_back(PINK_WHITE); - rangeTypes.push_back(BLUE_WHITE_RED); - rangeTypes.push_back(RED_WHITE_BLUE); - rangeTypes.push_back(WHITE_BLACK); - rangeTypes.push_back(BLACK_WHITE); - rangeTypes.push_back(ANGULAR); - if (hasStimPlanParent) rangeTypes.push_back(STIMPLAN); - - if (isCategoryResult) - { - rangeTypes.push_back(CATEGORY); - } - - for(ColorRangesType colType: rangeTypes) - { - options.push_back(caf::PdmOptionItemInfo(ColorRangeEnum::uiText(colType), colType)); - } - } - else if (fieldNeedingOptions == &m_rangeMode) - { - if (!m_isAllTimeStepsRangeDisabled) - { - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_ALLTIMESTEPS), RimLegendConfig::AUTOMATIC_ALLTIMESTEPS)); - } - if (!hasStimPlanParent) - { - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), RimLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); - } - options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimLegendConfig::USER_DEFINED), RimLegendConfig::USER_DEFINED)); - } - - return options; -} - diff --git a/ApplicationCode/ProjectDataModel/RimLegendConfig.h b/ApplicationCode/ProjectDataModel/RimLegendConfig.h index 072f66b8ad..dacedeba67 100644 --- a/ApplicationCode/ProjectDataModel/RimLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimLegendConfig.h @@ -1,178 +1,52 @@ ///////////////////////////////////////////////////////////////////////////////// // -// Copyright (C) 2011- Statoil ASA -// Copyright (C) 2013- Ceetron Solutions AS -// Copyright (C) 2011-2012 Ceetron AS -// +// Copyright (C) 2018 Statoil ASA +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once -#include "cvfBase.h" -#include "cvfObject.h" -#include "cvfArray.h" -#include "cafPdmObject.h" #include "cafPdmField.h" - -#include - -namespace cvf -{ - class ScalarMapperContinuousLog; - class ScalarMapperContinuousLinear; - class OverlayItem; - class OverlayScalarMapperLegend; - class ScalarMapperDiscreteLinear; - class ScalarMapperDiscreteLog; - class ScalarMapper; - class String; -} +#include "cafPdmObject.h" namespace caf { - class CategoryLegend; - class CategoryMapper; +class TitledOverlayFrame; } -class RimView; - //================================================================================================== -/// -/// +/// +/// //================================================================================================== -class RimLegendConfig: public caf::PdmObject +class RimLegendConfig : public caf::PdmObject { CAF_PDM_HEADER_INIT; + public: RimLegendConfig(); virtual ~RimLegendConfig(); - caf::PdmField resultVariableName; // Used internally to describe the variable this legend setup is used for - enum RangeModeType { AUTOMATIC_ALLTIMESTEPS, AUTOMATIC_CURRENT_TIMESTEP, USER_DEFINED }; - - typedef caf::AppEnum RangeModeEnum; - - enum ColorRangesType - { - NORMAL, - OPPOSITE_NORMAL, - WHITE_PINK, - PINK_WHITE, - WHITE_BLACK, - BLACK_WHITE, - BLUE_WHITE_RED, - RED_WHITE_BLUE, - CATEGORY, - ANGULAR, - STIMPLAN - }; - - typedef caf::AppEnum ColorRangeEnum; - - enum MappingType - { - LINEAR_DISCRETE, - LINEAR_CONTINUOUS, - LOG10_CONTINUOUS, - LOG10_DISCRETE, - CATEGORY_INTEGER - }; - enum NumberFormatType { AUTO, SCIENTIFIC, FIXED}; - - typedef caf::AppEnum MappingEnum; - void recreateLegend(); - - void setColorRangeMode(ColorRangesType colorMode); - ColorRangesType colorRangeMode() { return m_colorRangeMode();} - void setMappingMode(MappingType mappingType); - MappingType mappingMode() { return m_mappingMode();} - void disableAllTimeStepsRange(bool doDisable); - - void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax); - void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero); - - void setIntegerCategories(const std::vector& categories); - void setNamedCategoriesInverse(const std::vector& categoryNames); - void setCategoryItems(const std::vector>& categories); - QString categoryNameFromCategoryValue(double categoryResultValue) const; - - void setTitle(const cvf::String& title); - - cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } - cvf::OverlayItem* legend(); - -protected: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void initAfterRead(); - - friend class RimStimPlanLegendConfig; - virtual void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); - -private: - void updateLegend(); - void updateFieldVisibility(); - double roundToNumSignificantDigits(double value, double precision); - - friend class RimViewLinker; - void setUiValuesFromLegendConfig(const RimLegendConfig* otherLegendConfig); - - static cvf::Color3ubArray colorArrayFromColorType(ColorRangesType colorType); - -private: - cvf::ref m_linDiscreteScalarMapper; - cvf::ref m_logDiscreteScalarMapper; - cvf::ref m_logSmoothScalarMapper; - cvf::ref m_linSmoothScalarMapper; - cvf::ref m_currentScalarMapper; - - cvf::ref m_scalarMapperLegend; - - cvf::ref m_categoryMapper; - cvf::ref m_categoryLegend; - - double m_globalAutoMax; - double m_globalAutoMin; - double m_localAutoMax; - double m_localAutoMin; - - double m_globalAutoPosClosestToZero; - double m_globalAutoNegClosestToZero; - double m_localAutoPosClosestToZero; - double m_localAutoNegClosestToZero; - - bool m_isAllTimeStepsRangeDisabled; - - std::vector m_categories; - std::vector m_categoryNames; - cvf::Color3ubArray m_categoryColors; + typedef caf::AppEnum RangeModeEnum; - // Fields - caf::PdmField m_numLevels; - caf::PdmField m_precision; - caf::PdmField > m_tickNumberFormat; - caf::PdmField m_rangeMode; - caf::PdmField m_userDefinedMaxValue; - caf::PdmField m_userDefinedMinValue; - caf::PdmField > m_colorRangeMode; - caf::PdmField > m_mappingMode; + virtual const caf::TitledOverlayFrame* titledOverlayFrame() const = 0; + virtual caf::TitledOverlayFrame* titledOverlayFrame() = 0; }; diff --git a/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp b/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp index 5064c83b1e..689dcb5ca5 100644 --- a/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp +++ b/ApplicationCode/ProjectDataModel/RimMdiWindowController.cpp @@ -140,7 +140,7 @@ void RimMdiWindowController::updateViewerWidget() RiuMainWindowBase* mainWindow = getMainWindow(); if ( !mainWindow ) return; - if ( viewPdmObject()->m_showWindow() ) + if ( viewPdmObject()->isWindowVisible() ) { if ( !viewWidget() ) { diff --git a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp index 0e9bc19aaa..d3075e792c 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp +++ b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.cpp @@ -29,7 +29,7 @@ #include "RimProject.h" #include "RimReservoirCellResultsStorage.h" #include "RimTools.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cafPdmPointer.h" @@ -92,7 +92,7 @@ QList RimMultiSnapshotDefinition::calculateValueOptions( { options.push_back(caf::PdmOptionItemInfo("None", nullptr)); - std::vector views; + std::vector views; RimProject* proj = RiaApplication::instance()->project(); std::vector cases; @@ -100,13 +100,13 @@ QList RimMultiSnapshotDefinition::calculateValueOptions( for (RimCase* rimCase : cases) { - for (RimView* rimView : rimCase->views()) + for (Rim3dView* rimView : rimCase->views()) { views.push_back(rimView); } } - for (RimView* view : views) + for (Rim3dView* view : views) { QString caseAndView = view->ownerCase()->caseUserDescription() + " - " + view->name(); options.push_back(caf::PdmOptionItemInfo(caseAndView, view)); diff --git a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h index 6b32dec272..cbfc10d715 100644 --- a/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h +++ b/ApplicationCode/ProjectDataModel/RimMultiSnapshotDefinition.h @@ -27,7 +27,7 @@ #include "cafPdmPtrArrayField.h" class RimCase; -class RimView; +class Rim3dView; //================================================================================================== /// @@ -42,7 +42,7 @@ class RimMultiSnapshotDefinition : public caf::PdmObject caf::PdmField isActive; - caf::PdmPtrField view; + caf::PdmPtrField view; caf::PdmField< caf::AppEnum< RiaDefines::ResultCatType > > eclipseResultType; caf::PdmField< std::vector > selectedEclipseResults; diff --git a/ApplicationCode/ProjectDataModel/RimOilField.cpp b/ApplicationCode/ProjectDataModel/RimOilField.cpp index b634f67fb8..47bdd2770d 100644 --- a/ApplicationCode/ProjectDataModel/RimOilField.cpp +++ b/ApplicationCode/ProjectDataModel/RimOilField.cpp @@ -22,11 +22,7 @@ #include "RimEclipseCaseCollection.h" #include "RimFormationNamesCollection.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "RimFractureTemplateCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - #include "RimGeoMechModels.h" #include "RimObservedData.h" #include "RimObservedDataCollection.h" @@ -47,18 +43,13 @@ RimOilField::RimOilField(void) CAF_PDM_InitFieldNoDefault(&geoMechModels, "GeoMechModels", "Geo Mech Models", ":/GridModels.png", "", ""); CAF_PDM_InitFieldNoDefault(&wellPathCollection, "WellPathCollection", "Well Paths", ":/WellCollection.png", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&fractureDefinitionCollection, "FractureDefinitionCollection", "Defenition of Fractures", "", "", ""); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&summaryCaseMainCollection,"SummaryCaseCollection","Summary Cases",":/GridModels.png","",""); CAF_PDM_InitFieldNoDefault(&formationNamesCollection,"FormationNamesCollection","Formations","","",""); CAF_PDM_InitFieldNoDefault(&observedDataCollection, "ObservedDataCollection", "Observed Data", ":/Cases16x16.png", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES fractureDefinitionCollection = new RimFractureTemplateCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - analysisModels = new RimEclipseCaseCollection(); wellPathCollection = new RimWellPathCollection(); summaryCaseMainCollection = new RimSummaryCaseMainCollection(); @@ -73,10 +64,7 @@ RimOilField::~RimOilField(void) { if (wellPathCollection()) delete wellPathCollection(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (fractureDefinitionCollection()) delete fractureDefinitionCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - if (geoMechModels()) delete geoMechModels(); if (analysisModels()) delete analysisModels(); if (summaryCaseMainCollection()) delete summaryCaseMainCollection(); diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp index b856cc3633..b1a8f070ee 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.cpp @@ -17,10 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPlotCurve.h" + +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" #include "RimSummaryCurveFilter.h" +#include "RimSummaryPlot.h" -#include "RiuLineSegmentQwtPlotCurve.h" +#include "RiuRimQwtPlotCurve.h" #include "cafPdmUiComboBoxEditor.h" @@ -105,9 +110,9 @@ RimPlotCurve::RimPlotCurve() CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Contribute To Legend", "", "", ""); - m_qwtPlotCurve = new RiuLineSegmentQwtPlotCurve; + m_qwtPlotCurve = new RiuRimQwtPlotCurve(this); - m_parentQwtPlot = NULL; + m_parentQwtPlot = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -115,17 +120,17 @@ RimPlotCurve::RimPlotCurve() //-------------------------------------------------------------------------------------------------- RimPlotCurve::~RimPlotCurve() { - if (m_qwtPlotCurve) - { - m_qwtPlotCurve->detach(); - delete m_qwtPlotCurve; - m_qwtPlotCurve = NULL; - } + if (m_qwtPlotCurve) + { + m_qwtPlotCurve->detach(); + delete m_qwtPlotCurve; + m_qwtPlotCurve = nullptr; + } - if (m_parentQwtPlot) - { - m_parentQwtPlot->replot(); - } + if (m_parentQwtPlot) + { + m_parentQwtPlot->replot(); + } } //-------------------------------------------------------------------------------------------------- @@ -188,6 +193,10 @@ void RimPlotCurve::updateCurveVisibility(bool updateParentPlot) RimSummaryCurveCollection* summaryCurveCollection = nullptr; this->firstAncestorOrThisOfType(summaryCurveCollection); if (summaryCurveCollection) isVisibleInPossibleParent = summaryCurveCollection->isCurvesVisible(); + + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) isVisibleInPossibleParent = ensembleCurveSet->isCurvesVisible(); } if (m_showCurve() && m_parentQwtPlot && isVisibleInPossibleParent) @@ -373,7 +382,7 @@ void RimPlotCurve::updateCurveAppearance() QColor curveColor(m_curveColor.value().rByte(), m_curveColor.value().gByte(), m_curveColor.value().bByte()); - QwtSymbol* symbol = NULL; + QwtSymbol* symbol = nullptr; if (m_pointSymbol() != SYMBOL_NONE) { @@ -545,7 +554,7 @@ void RimPlotCurve::showLegend(bool show) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::setZOrder(double z) { @@ -556,24 +565,11 @@ void RimPlotCurve::setZOrder(double z) } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() { - if (m_showLegend()) { - if (m_curveName().isEmpty()) - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); - } - else - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, true); - } - } - else - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); - } + updateLegendEntryVisibilityNoPlotUpdate(); if (m_parentQwtPlot != nullptr) { @@ -582,22 +578,30 @@ void RimPlotCurve::updateLegendEntryVisibilityAndPlotLegend() } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimPlotCurve::updateLegendEntryVisibilityNoPlotUpdate() { - if (m_showLegend()) { - if (m_curveName().isEmpty()) - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); - } - else - { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, true); - } + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) + { + return; } - else + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfType(summaryPlot); + + if (summaryPlot) { - m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, false); + bool showLegendInQwt = m_showLegend(); + + if (summaryPlot->ensembleCurveSetCollection()->curveSets().empty() && summaryPlot->curveCount() == 1) + { + // Disable display of legend if the summary plot has only one single curve + showLegendInQwt = false; + } + + m_qwtPlotCurve->setItemAttribute(QwtPlotItem::Legend, showLegendInQwt); } -} \ No newline at end of file +} diff --git a/ApplicationCode/ProjectDataModel/RimPlotCurve.h b/ApplicationCode/ProjectDataModel/RimPlotCurve.h index 0cd9c4495a..9ece407b89 100644 --- a/ApplicationCode/ProjectDataModel/RimPlotCurve.h +++ b/ApplicationCode/ProjectDataModel/RimPlotCurve.h @@ -100,6 +100,8 @@ class RimPlotCurve : public caf::PdmObject void setZOrder(double z); + virtual void updateCurveAppearance(); + protected: virtual QString createCurveAutoName() = 0; @@ -107,7 +109,6 @@ class RimPlotCurve : public caf::PdmObject virtual void onLoadDataAndUpdate(bool updateParentPlot) = 0; void updateCurvePresentation(bool updatePlotLegend); - virtual void updateCurveAppearance(); void updateOptionSensitivity(); diff --git a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp index 2f6f6a691e..044af69106 100644 --- a/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPltPlotCollection.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RimPltPlotCollection, "WellPltPlotCollection"); //-------------------------------------------------------------------------------------------------- RimPltPlotCollection::RimPltPlotCollection() { - CAF_PDM_InitObject("PLT Plots", ":/WellLogPlots16x16.png", "", ""); + CAF_PDM_InitObject("PLT Plots", ":/WellAllocPlots16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_pltPlots, "PltPlots", "", "", "", ""); m_pltPlots.uiCapability()->setUiHidden(true); @@ -88,7 +88,7 @@ RigEclipseWellLogExtractor* RimPltPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->eclipseCaseData())) { - return NULL; + return nullptr; } RigEclipseCaseData* eclCaseData = eclCase->eclipseCaseData(); @@ -115,7 +115,7 @@ RigGeoMechWellLogExtractor* RimPltPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { - return NULL; + return nullptr; } RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); diff --git a/ApplicationCode/ProjectDataModel/RimProject.cpp b/ApplicationCode/ProjectDataModel/RimProject.cpp index 4f435d01d1..76b8eb90a4 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationCode/ProjectDataModel/RimProject.cpp @@ -23,12 +23,12 @@ #include "RiaApplication.h" #include "RiaProjectFileVersionTools.h" #include "RiaVersionInfo.h" +#include "RiaFilePathTools.h" #include "RigEclipseCaseData.h" #include "RigGridBase.h" #include "RimCalcScript.h" -#include "RimSummaryCalculationCollection.h" #include "RimCase.h" #include "RimCaseCollection.h" #include "RimCommandObject.h" @@ -38,15 +38,12 @@ #include "RimEclipseCaseCollection.h" #include "RimFlowPlotCollection.h" #include "RimFormationNamesCollection.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimFractureTemplateCollection.h" #include "RimFractureTemplate.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - +#include "RimFractureTemplateCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechModels.h" #include "RimGridSummaryCase.h" +#include "RimGridView.h" #include "RimIdenticalGridCaseGroup.h" #include "RimMainPlotCollection.h" #include "RimMultiSnapshotDefinition.h" @@ -55,10 +52,11 @@ #include "RimPltPlotCollection.h" #include "RimRftPlotCollection.h" #include "RimScriptCollection.h" +#include "RimSummaryCalculationCollection.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryCrossPlotCollection.h" #include "RimSummaryPlotCollection.h" -#include "RimView.h" +#include "RimTools.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" #include "RimWellLogFile.h" @@ -67,19 +65,20 @@ #include "RimWellPathCollection.h" #include "RimWellPathImport.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" #include "OctaveScriptCommands/RicExecuteScriptForCasesFeature.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" -#include "cafPdmUiTreeOrdering.h" #include "cafCmdFeatureMenuBuilder.h" +#include "cafPdmUiTreeOrdering.h" #include "cvfBoundingBox.h" #include #include +#include "RiaCompletionTypeCalculationScheduler.h" CAF_PDM_SOURCE_INIT(RimProject, "ResInsightProject"); @@ -100,7 +99,7 @@ RimProject::RimProject(void) CAF_PDM_InitFieldNoDefault(&oilFields, "OilFields", "Oil Fields", "", "", ""); oilFields.uiCapability()->setUiHidden(true); - CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Scripts", ":/Default.png", "", ""); + CAF_PDM_InitFieldNoDefault(&scriptCollection, "ScriptCollection", "Octave Scripts", ":/octave.png", "", ""); scriptCollection.uiCapability()->setUiHidden(true); CAF_PDM_InitFieldNoDefault(&wellPathImport, "WellPathImport", "WellPathImport", "", "", ""); @@ -157,7 +156,7 @@ RimProject::RimProject(void) scriptCollection = new RimScriptCollection(); scriptCollection->directory.uiCapability()->setUiHidden(true); scriptCollection->uiCapability()->setUiName("Scripts"); - scriptCollection->uiCapability()->setUiIcon(QIcon(":/Default.png")); + scriptCollection->uiCapability()->setUiIcon(QIcon(":/octave.png")); mainPlotCollection = new RimMainPlotCollection(); @@ -205,7 +204,7 @@ void RimProject::close() calculationCollection->deleteAllContainedObjects(); delete viewLinkerCollection->viewLinker(); - viewLinkerCollection->viewLinker = NULL; + viewLinkerCollection->viewLinker = nullptr; fileName = ""; @@ -261,7 +260,7 @@ void RimProject::initScriptDirectories() } // Find largest used groupId read from file and make sure all groups have a valid groupId - RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : nullptr; if (analysisModels) { int largestGroupId = -1; @@ -310,7 +309,7 @@ void RimProject::initAfterRead() // Handle old project files with obsolete structure. // Move caseGroupsObsolete and casesObsolete to oilFields()[idx]->analysisModels() - RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = activeOilField() ? activeOilField()->analysisModels() : nullptr; bool movedOneRimIdenticalGridCaseGroup = false; for (size_t cgIdx = 0; cgIdx < caseGroupsObsolete.size(); ++cgIdx) { @@ -334,7 +333,7 @@ void RimProject::initAfterRead() if (analysisModels) { RimEclipseCase* sourceCase = casesObsolete[cIdx]; - casesObsolete.set(cIdx, NULL); + casesObsolete.set(cIdx, nullptr); analysisModels->cases.push_back(sourceCase); //printf("Moved m_project->casesObsolete[%i] to first oil fields analysis models\n", cIdx); movedOneRimCase = true; // moved at least one so assume the others will be moved too... @@ -356,7 +355,7 @@ void RimProject::initAfterRead() for (size_t oilFieldIdx = 0; oilFieldIdx < oilFields().size(); oilFieldIdx++) { RimOilField* oilField = oilFields[oilFieldIdx]; - if (oilField == NULL || oilField->wellPathCollection == NULL) continue; + if (oilField == nullptr || oilField->wellPathCollection == nullptr) continue; } } @@ -439,6 +438,18 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName QFileInfo fileInfoOld(oldProjectFileName); QString oldProjectPath = fileInfoOld.path(); + + std::vector filePaths; + fieldsByType(this, filePaths); + + for (caf::FilePath* filePath : filePaths) + { + bool foundFile = false; + std::vector searchedPaths; + + QString newFilePath = RimTools::relocateFile(filePath->path(), newProjectPath, oldProjectPath, &foundFile, &searchedPaths); + filePath->setPath(newFilePath); + } // Loop over all cases and update file path @@ -457,23 +468,21 @@ void RimProject::setProjectFileNameAndUpdateDependencies(const QString& fileName // Update path to well path file cache for(RimOilField* oilField: oilFields) { - if (oilField == NULL) continue; - if (oilField->wellPathCollection() != NULL) + if (oilField == nullptr) continue; + if (oilField->wellPathCollection() != nullptr) { oilField->wellPathCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } - if (oilField->formationNamesCollection() != NULL) + if (oilField->formationNamesCollection() != nullptr) { oilField->formationNamesCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } - if (oilField->summaryCaseMainCollection() != NULL) { + if (oilField->summaryCaseMainCollection() != nullptr) { oilField->summaryCaseMainCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CVF_ASSERT(oilField->fractureDefinitionCollection()); oilField->fractureDefinitionCollection()->updateFilePathsFromProjectPath(newProjectPath, oldProjectPath); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } { @@ -536,7 +545,7 @@ void RimProject::allCases(std::vector& cases) { // Load the Main case of each IdenticalGridCaseGroup RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups[cgIdx]; - if (cg == NULL) continue; + if (cg == nullptr) continue; if (cg->statisticsCaseCollection()) { @@ -597,12 +606,33 @@ std::vector RimProject::allSummaryCases() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allNotLinkedViews(std::vector& views) +std::vector RimProject::summaryGroups() const +{ + std::vector groups; + + for (RimOilField* oilField : oilFields) + { + if (!oilField) continue; + RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); + if (sumCaseMainColl) + { + std::vector g = sumCaseMainColl->summaryCaseCollections(); + groups.insert(groups.end(), g.begin(), g.end()); + } + } + + return groups; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::allNotLinkedViews(std::vector& views) { std::vector cases; allCases(cases); - std::vector alreadyLinkedViews; + std::vector alreadyLinkedViews; if (viewLinkerCollection->viewLinker()) { viewLinkerCollection->viewLinker()->allViews(alreadyLinkedViews); @@ -613,20 +643,24 @@ void RimProject::allNotLinkedViews(std::vector& views) RimCase* rimCase = cases[caseIdx]; if (!rimCase) continue; - std::vector caseViews = rimCase->views(); + std::vector caseViews = rimCase->views(); for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++) { + RimGridView* gridView = dynamic_cast(caseViews[viewIdx]); + + if (!gridView) continue; + bool isLinked = false; for (size_t lnIdx = 0; lnIdx < alreadyLinkedViews.size(); lnIdx++) { - if (caseViews[viewIdx] == alreadyLinkedViews[lnIdx]) + if (gridView == alreadyLinkedViews[lnIdx]) { isLinked = true; } } if (!isLinked) { - views.push_back(caseViews[viewIdx]); + views.push_back(gridView); } } } @@ -635,7 +669,7 @@ void RimProject::allNotLinkedViews(std::vector& views) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimProject::allVisibleViews(std::vector& views) +void RimProject::allVisibleViews(std::vector& views) { std::vector cases; allCases(cases); @@ -645,7 +679,7 @@ void RimProject::allVisibleViews(std::vector& views) RimCase* rimCase = cases[caseIdx]; if (!rimCase) continue; - std::vector caseViews = rimCase->views(); + std::vector caseViews = rimCase->views(); for (size_t viewIdx = 0; viewIdx < caseViews.size(); viewIdx++) { if (caseViews[viewIdx] && caseViews[viewIdx]->viewer()) @@ -656,6 +690,20 @@ void RimProject::allVisibleViews(std::vector& views) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProject::allVisibleGridViews(std::vector& views) +{ + std::vector visibleViews; + this->allVisibleViews(visibleViews); + for ( Rim3dView* view : visibleViews ) + { + RimGridView* gridView = dynamic_cast(view); + if ( gridView ) views.push_back(gridView); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -666,8 +714,8 @@ void RimProject::createDisplayModelAndRedrawAllViews() for (size_t caseIdx = 0; caseIdx < cases.size(); caseIdx++) { RimCase* rimCase = cases[caseIdx]; - if (rimCase == NULL) continue; - std::vector views = rimCase->views(); + if (rimCase == nullptr) continue; + std::vector views = rimCase->views(); for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++) { @@ -788,7 +836,7 @@ bool RimProject::showPlotWindow() const void RimProject::reloadCompletionTypeResultsInAllViews() { createDisplayModelAndRedrawAllViews(); - RiaApplication::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(); + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(); } //-------------------------------------------------------------------------------------------------- @@ -813,6 +861,21 @@ std::vector RimProject::eclipseCases() const return allCases; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimProject::eclipseCaseFromGridFileName(const QString& gridFileName) const +{ + for (RimEclipseCase* eclCase : eclipseCases()) + { + if (RiaFilePathTools::toInternalSeparator(eclCase->gridFileName()) == RiaFilePathTools::toInternalSeparator(gridFileName)) + { + return eclCase; + } + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -905,7 +968,6 @@ std::vector RimProject::geoMechCases() const return cases; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -934,28 +996,27 @@ std::vector RimProject::allFractureTemplates() const allOilFields(oilFields); for (RimFractureTemplateCollection* templColl : allFractureTemplateCollections()) { - for (RimFractureTemplate* templ : templColl->fractureDefinitions) + for (RimFractureTemplate* templ : templColl->fractureTemplates()) { templates.push_back(templ); } } return templates; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimProject::reloadCompletionTypeResultsForEclipseCase(RimEclipseCase* eclipseCase) { - std::vector views = eclipseCase->views(); + std::vector views = eclipseCase->views(); for (size_t viewIdx = 0; viewIdx < views.size(); viewIdx++) { views[viewIdx]->scheduleCreateDisplayModelAndRedraw(); } - RiaApplication::instance()->scheduleRecalculateCompletionTypeAndRedrawEclipseCase(eclipseCase); + RiaCompletionTypeCalculationScheduler::instance()->scheduleRecalculateCompletionTypeAndRedrawAllViews(eclipseCase); } //-------------------------------------------------------------------------------------------------- @@ -1026,10 +1087,7 @@ void RimProject::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QS if (oilField->geoMechModels()) uiTreeOrdering.add(oilField->geoMechModels()); if (oilField->wellPathCollection()) uiTreeOrdering.add(oilField->wellPathCollection()); if (oilField->formationNamesCollection()) uiTreeOrdering.add(oilField->formationNamesCollection()); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (oilField->fractureDefinitionCollection()) uiTreeOrdering.add(oilField->fractureDefinitionCollection()); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } uiTreeOrdering.add(scriptCollection()); diff --git a/ApplicationCode/ProjectDataModel/RimProject.h b/ApplicationCode/ProjectDataModel/RimProject.h index b8dc8c3b3b..22e1091435 100644 --- a/ApplicationCode/ProjectDataModel/RimProject.h +++ b/ApplicationCode/ProjectDataModel/RimProject.h @@ -47,7 +47,9 @@ class RimObservedData; class RimOilField; class RimScriptCollection; class RimSummaryCase; -class RimView; +class RimSummaryCaseCollection; +class Rim3dView; +class RimGridView; class RimViewLinker; class RimViewLinkerCollection; class RimWellPath; @@ -105,9 +107,11 @@ class RimProject : public caf::PdmDocument void allCases(std::vector& cases); std::vector allSummaryCases() const; + std::vector summaryGroups() const; - void allNotLinkedViews(std::vector& views); - void allVisibleViews(std::vector& views); + void allVisibleViews(std::vector& views); + void allVisibleGridViews(std::vector& views); + void allNotLinkedViews(std::vector& views); void createDisplayModelAndRedrawAllViews(); @@ -128,6 +132,8 @@ class RimProject : public caf::PdmDocument RimDialogData* dialogData() const; std::vector eclipseCases() const; + RimEclipseCase* eclipseCaseFromGridFileName(const QString& gridFileName) const; + std::vector simulationWellNames() const; RimWellPath* wellPathFromSimWellName(const QString& simWellName, int branchIndex = -1); @@ -136,10 +142,8 @@ class RimProject : public caf::PdmDocument std::vector geoMechCases() const; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES std::vector allFractureTemplateCollections() const; std::vector allFractureTemplates() const; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES protected: // Overridden methods @@ -149,6 +153,10 @@ class RimProject : public caf::PdmDocument virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); +private: + template + void fieldsByType(caf::PdmObjectHandle* object, std::vector& typedFields); + private: caf::PdmField m_projectFileVersionString; @@ -164,3 +172,39 @@ class RimProject : public caf::PdmDocument caf::PdmChildArrayField casesObsolete; // obsolete caf::PdmChildArrayField caseGroupsObsolete; // obsolete }; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void RimProject::fieldsByType(caf::PdmObjectHandle* object, std::vector& typedFields) +{ + if (!object) return; + + std::vector allFieldsInObject; + object->fields(allFieldsInObject); + + std::vector children; + + for (const auto& field : allFieldsInObject) + { + caf::PdmField* typedField = dynamic_cast*>(field); + if (typedField) typedFields.push_back(&typedField->v()); + + caf::PdmField< std::vector >* typedFieldInVector = dynamic_cast >*>(field); + if (typedFieldInVector) + { + for (T& typedFieldFromVector : typedFieldInVector->v()) + { + typedFields.push_back(&typedFieldFromVector); + } + } + + field->childObjects(&children); + } + + for (const auto& child : children) + { + fieldsByType(child, typedFields); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp b/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp index fb083d3eb4..c46df10fc6 100644 --- a/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimPropertyFilterCollection.cpp @@ -18,7 +18,7 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimPropertyFilterCollection.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" CAF_PDM_XML_ABSTRACT_SOURCE_INIT(RimPropertyFilterCollection, "RimPropertyFilterCollection"); // Abstract class @@ -46,7 +46,7 @@ RimPropertyFilterCollection::~RimPropertyFilterCollection() //-------------------------------------------------------------------------------------------------- void RimPropertyFilterCollection::updateDisplayModelNotifyManagedViews() const { - RimView* view = NULL; + Rim3dView* view = nullptr; this->firstAncestorOrThisOfType(view); CVF_ASSERT(view); if (!view) return; @@ -83,7 +83,7 @@ void RimPropertyFilterCollection::defineUiTreeOrdering(caf::PdmUiTreeOrdering& u { PdmObject::defineUiTreeOrdering(uiTreeOrdering, uiConfigName); - RimView* rimView = NULL; + Rim3dView* rimView = nullptr; this->firstAncestorOrThisOfType(rimView); RimViewController* viewController = rimView->viewController(); if (viewController && (viewController->isPropertyFilterOveridden() diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp new file mode 100644 index 0000000000..f07d096d52 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -0,0 +1,937 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimRegularLegendConfig.h" + +#include "RiaApplication.h" +#include "RiaColorTables.h" +#include "RiaPreferences.h" + +#include "RimCellEdgeColors.h" +#include "RimEclipseCellColors.h" +#include "RimEnsembleCurveSet.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" +#include "RimEclipseView.h" +#include "RimGeoMechResultDefinition.h" +#include "RimIntersectionCollection.h" +#include "RimStimPlanColors.h" +#include "RimViewLinker.h" + +#include "cafTitledOverlayFrame.h" +#include "cafCategoryLegend.h" +#include "cafCategoryMapper.h" +#include "cafOverlayScalarMapperLegend.h" + +#include "cafFactory.h" +#include "cafPdmFieldCvfColor.h" +#include "cafPdmFieldCvfMat4d.h" +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiLineEditor.h" + +#include "cvfScalarMapperContinuousLinear.h" +#include "cvfScalarMapperContinuousLog.h" +#include "cvfScalarMapperDiscreteLinear.h" +#include "cvfScalarMapperDiscreteLog.h" +#include "cvfqtUtils.h" + +#include +#include + +using ColorManager = RimEnsembleCurveSetColorManager; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CAF_PDM_SOURCE_INIT(RimRegularLegendConfig, "Legend"); + + +namespace caf { + template<> + void RimRegularLegendConfig::ColorRangeEnum::setUp() + { + addItem(RimRegularLegendConfig::NORMAL, "NORMAL", "Full color, Red on top"); + addItem(RimRegularLegendConfig::OPPOSITE_NORMAL, "OPPOSITE_NORMAL", "Full color, Blue on top"); + addItem(RimRegularLegendConfig::WHITE_PINK, "WHITE_PIMK", "White to pink"); + addItem(RimRegularLegendConfig::PINK_WHITE, "PINK_WHITE", "Pink to white"); + addItem(RimRegularLegendConfig::BLUE_WHITE_RED, "BLUE_WHITE_RED", "Blue, white, red"); + addItem(RimRegularLegendConfig::RED_WHITE_BLUE, "RED_WHITE_BLUE", "Red, white, blue"); + addItem(RimRegularLegendConfig::WHITE_BLACK, "WHITE_BLACK", "White to black"); + addItem(RimRegularLegendConfig::BLACK_WHITE, "BLACK_WHITE", "Black to white"); + addItem(RimRegularLegendConfig::CATEGORY, "CATEGORY", "Category colors"); + addItem(RimRegularLegendConfig::ANGULAR, "ANGULAR", "Full color cyclic"); + addItem(RimRegularLegendConfig::STIMPLAN, "STIMPLAN", "StimPlan colors"); + addItem(RimRegularLegendConfig::RED_LIGHT_DARK, "RED_DARK_LIGHT", "Red Light to Dark"); + addItem(RimRegularLegendConfig::GREEN_LIGHT_DARK, "GREEN_DARK_LIGHT", "Green Light to Dark"); + addItem(RimRegularLegendConfig::BLUE_LIGHT_DARK, "BLUE_DARK_LIGHT", "Blue Light to Dark"); + addItem(RimRegularLegendConfig::GREEN_RED, "GREEN_RED", "Green to Red"); + addItem(RimRegularLegendConfig::BLUE_MAGENTA, "BLUE_MAGENTA", "Blue to Magenta"); + setDefault(RimRegularLegendConfig::NORMAL); + } +} + +namespace caf { + template<> + void RimRegularLegendConfig::MappingEnum::setUp() + { + addItem(RimRegularLegendConfig::LINEAR_DISCRETE, "LinearDiscrete", "Discrete Linear"); + addItem(RimRegularLegendConfig::LINEAR_CONTINUOUS, "LinearContinuous", "Continuous Linear"); + addItem(RimRegularLegendConfig::LOG10_CONTINUOUS, "Log10Continuous", "Continuous Logarithmic"); + addItem(RimRegularLegendConfig::LOG10_DISCRETE, "Log10Discrete", "Discrete Logarithmic"); + addItem(RimRegularLegendConfig::CATEGORY_INTEGER, "Category", "Category"); + setDefault(RimRegularLegendConfig::LINEAR_CONTINUOUS); + } +} + +namespace caf { + template<> + void AppEnum::setUp() + { + addItem( RimRegularLegendConfig::AUTO, "AUTO", "Automatic"); + addItem( RimRegularLegendConfig::FIXED, "FIXED", "Fixed, decimal"); + addItem( RimRegularLegendConfig::SCIENTIFIC, "SCIENTIFIC", "Scientific notation"); + setDefault(RimRegularLegendConfig::FIXED); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig::RimRegularLegendConfig() + : m_globalAutoMax(cvf::UNDEFINED_DOUBLE), + m_globalAutoMin(cvf::UNDEFINED_DOUBLE), + m_localAutoMax(cvf::UNDEFINED_DOUBLE), + m_localAutoMin(cvf::UNDEFINED_DOUBLE), + m_globalAutoPosClosestToZero(0), + m_globalAutoNegClosestToZero(0), + m_localAutoPosClosestToZero(0), + m_localAutoNegClosestToZero(0), + m_isAllTimeStepsRangeDisabled(false) +{ + CAF_PDM_InitObject("Legend Definition", ":/Legend.png", "", ""); + CAF_PDM_InitField(&m_showLegend, "ShowLegend", true, "Show Legend", "", "", ""); + m_showLegend.uiCapability()->setUiHidden(true); + CAF_PDM_InitField(&m_numLevels, "NumberOfLevels", 8, "Number of Levels", "", "A hint on how many tick marks you whish.",""); + CAF_PDM_InitField(&m_precision, "Precision", 4, "Significant Digits", "", "The number of significant digits displayed in the legend numbers",""); + CAF_PDM_InitField(&m_tickNumberFormat, "TickNumberFormat", caf::AppEnum(FIXED), "Number format", "", "",""); + + CAF_PDM_InitField(&m_colorRangeMode, "ColorRangeMode", ColorRangeEnum(NORMAL) , "Colors", "", "", ""); + CAF_PDM_InitField(&m_mappingMode, "MappingMode", MappingEnum(LINEAR_CONTINUOUS) , "Mapping", "", "", ""); + CAF_PDM_InitField(&m_rangeMode, "RangeType", RangeModeEnum(AUTOMATIC_ALLTIMESTEPS), "Range Type", "", "Switches between automatic and user defined range on the legend", ""); + CAF_PDM_InitField(&m_userDefinedMaxValue, "UserDefinedMax", 1.0, "Max", "", "Max value of the legend", ""); + CAF_PDM_InitField(&m_userDefinedMinValue, "UserDefinedMin", 0.0, "Min", "", "Min value of the legend (if mapping is logarithmic only positive values are valid)", ""); + CAF_PDM_InitField(&resultVariableName, "ResultVariableUsage", QString(""), "", "", "", ""); + resultVariableName.uiCapability()->setUiHidden(true); + + m_linDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLinear; + m_logDiscreteScalarMapper = new cvf::ScalarMapperDiscreteLog; + m_linSmoothScalarMapper = new cvf::ScalarMapperContinuousLinear; + m_logSmoothScalarMapper = new cvf::ScalarMapperContinuousLog; + + m_currentScalarMapper = m_linDiscreteScalarMapper; + + m_categoryMapper = new caf::CategoryMapper; + + cvf::Font* standardFont = RiaApplication::instance()->standardFont(); + m_scalarMapperLegend = new caf::OverlayScalarMapperLegend(standardFont); + m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p()); + + updateFieldVisibility(); + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig::~RimRegularLegendConfig() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setNamedCategories(const std::vector& categoryNames, bool inverse) +{ + std::list nameIndices; + std::list names; + + int categoriesCount = static_cast(categoryNames.size()); + for (int i = 0; i < categoriesCount; i++) + { + if (!inverse) + { + nameIndices.push_back(i); + names.push_back(cvfqt::Utils::toString(categoryNames[i])); + } + else + { + nameIndices.push_front(i); + names.push_front(cvfqt::Utils::toString(categoryNames[i])); + } + } + + m_categories = std::vector(nameIndices.begin(), nameIndices.end()); + m_categoryNames = std::vector(names.begin(), names.end()); + m_categoryColors.clear(); + + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_numLevels) + { + int upperLimit = std::numeric_limits::max(); + m_numLevels = cvf::Math::clamp(m_numLevels.v(), 1, upperLimit); + } + else if (changedField == &m_rangeMode || + changedField == &m_mappingMode) + { + if (m_rangeMode == USER_DEFINED) + { + if (m_userDefinedMaxValue == m_userDefinedMaxValue.defaultValue() && m_globalAutoMax != cvf::UNDEFINED_DOUBLE) + { + m_userDefinedMaxValue = roundToNumSignificantDigits(m_globalAutoMax, m_precision); + } + if (m_userDefinedMinValue == m_userDefinedMinValue.defaultValue() && m_globalAutoMin != cvf::UNDEFINED_DOUBLE) + { + m_userDefinedMinValue = roundToNumSignificantDigits(m_globalAutoMin, m_precision); + } + } + + updateFieldVisibility(); + } + + updateLegend(); + + RimGridView* view = nullptr; + this->firstAncestorOrThisOfType(view); + + if (view) + { + RimViewLinker* viewLinker = view->assosiatedViewLinker(); + if (viewLinker) + { + viewLinker->updateCellResult(); + } + + view->updateCurrentTimeStepAndRedraw(); + + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } + + // Update stim plan templates if relevant + RimStimPlanColors* stimPlanColors; + firstAncestorOrThisOfType(stimPlanColors); + if (stimPlanColors) + { + stimPlanColors->updateStimPlanTemplates(); + } + + // Update ensemble curve set if relevant + RimEnsembleCurveSet* ensembleCurveSet; + firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) + { + ensembleCurveSet->onLegendDefinitionChanged(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::updateLegend() +{ + double adjustedMin = cvf::UNDEFINED_DOUBLE; + double adjustedMax = cvf::UNDEFINED_DOUBLE; + + double posClosestToZero = cvf::UNDEFINED_DOUBLE; + double negClosestToZero = cvf::UNDEFINED_DOUBLE; + + if (m_rangeMode == AUTOMATIC_ALLTIMESTEPS) + { + adjustedMin = roundToNumSignificantDigits(m_globalAutoMin, m_precision); + adjustedMax = roundToNumSignificantDigits(m_globalAutoMax, m_precision); + + posClosestToZero = m_globalAutoPosClosestToZero; + negClosestToZero = m_globalAutoNegClosestToZero; + } + else if (m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP) + { + adjustedMin = roundToNumSignificantDigits(m_localAutoMin, m_precision); + adjustedMax = roundToNumSignificantDigits(m_localAutoMax, m_precision); + + posClosestToZero = m_localAutoPosClosestToZero; + negClosestToZero = m_localAutoNegClosestToZero; + } + else + { + adjustedMin = roundToNumSignificantDigits(m_userDefinedMinValue, m_precision); + adjustedMax = roundToNumSignificantDigits(m_userDefinedMaxValue, m_precision); + + posClosestToZero = m_globalAutoPosClosestToZero; + negClosestToZero = m_globalAutoNegClosestToZero; + } + + m_linDiscreteScalarMapper->setRange(adjustedMin, adjustedMax); + m_linSmoothScalarMapper->setRange(adjustedMin, adjustedMax); + + if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE) + { + if (adjustedMin != adjustedMax) + { + if (adjustedMin == 0) + { + if (adjustedMax > adjustedMin) + { + adjustedMin = posClosestToZero; + } + else + { + adjustedMin = negClosestToZero; + } + } + else if (adjustedMax == 0) + { + if (adjustedMin > adjustedMax) + { + adjustedMax = posClosestToZero; + } + else + { + adjustedMax = negClosestToZero; + } + } + else if (adjustedMin < 0 && adjustedMax > 0) + { + adjustedMin = posClosestToZero; + } + else if (adjustedMax < 0 && adjustedMin > 0) + { + adjustedMin = negClosestToZero; + } + } + } + + m_logDiscreteScalarMapper->setRange(adjustedMin, adjustedMax); + m_logSmoothScalarMapper->setRange(adjustedMin, adjustedMax); + + cvf::Color3ubArray legendColors = colorArrayFromColorType(m_colorRangeMode()); + + m_linDiscreteScalarMapper->setColors(legendColors); + m_logDiscreteScalarMapper->setColors(legendColors); + m_logSmoothScalarMapper->setColors(legendColors); + m_linSmoothScalarMapper->setColors(legendColors); + + + m_linDiscreteScalarMapper->setLevelCount(m_numLevels, true); + m_logDiscreteScalarMapper->setLevelCount(m_numLevels, true); + m_logSmoothScalarMapper->setLevelCount(m_numLevels, true); + m_linSmoothScalarMapper->setLevelCount(m_numLevels, true); + + switch(m_mappingMode()) + { + case LINEAR_DISCRETE: + m_currentScalarMapper = m_linDiscreteScalarMapper.p(); + break; + case LINEAR_CONTINUOUS: + m_currentScalarMapper = m_linSmoothScalarMapper.p(); + break; + case LOG10_CONTINUOUS: + m_currentScalarMapper = m_logSmoothScalarMapper.p(); + break; + case LOG10_DISCRETE: + m_currentScalarMapper = m_logDiscreteScalarMapper.p(); + break; + case CATEGORY_INTEGER: + m_categoryMapper->setCategoriesWithNames(m_categories, m_categoryNames); + + if (m_categoryColors.size() > 0) + { + m_categoryMapper->setCycleColors(m_categoryColors); + } + else + { + m_categoryMapper->setInterpolateColors(legendColors); + } + m_currentScalarMapper = m_categoryMapper.p(); + break; + default: + break; + } + + if (m_currentScalarMapper != m_categoryMapper.p()) + { + m_scalarMapperLegend->setScalarMapper(m_currentScalarMapper.p()); + } + double decadesInRange = 0; + + if (m_mappingMode == LOG10_CONTINUOUS || m_mappingMode == LOG10_DISCRETE) + { + // For log mapping, use the min value as reference for num valid digits + decadesInRange = cvf::Math::abs(adjustedMin) < cvf::Math::abs(adjustedMax) ? cvf::Math::abs(adjustedMin) : cvf::Math::abs(adjustedMax); + decadesInRange = log10(decadesInRange); + } + else + { + // For linear mapping, use the max value as reference for num valid digits + double absRange = CVF_MAX(cvf::Math::abs(adjustedMax), cvf::Math::abs(adjustedMin)); + decadesInRange = log10(absRange); + } + + decadesInRange = cvf::Math::ceil(decadesInRange); + + // Using Fixed format + NumberFormatType nft = m_tickNumberFormat(); + m_scalarMapperLegend->setTickFormat((caf::OverlayScalarMapperLegend::NumberFormat)nft); + + // Set the fixed number of digits after the decimal point to the number needed to show all the significant digits. + int numDecimalDigits = m_precision(); + if (nft != SCIENTIFIC) + { + numDecimalDigits -= static_cast(decadesInRange); + } + m_scalarMapperLegend->setTickPrecision(cvf::Math::clamp(numDecimalDigits, 0, 20)); + + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + m_scalarMapperLegend->enableBackground(preferences->showLegendBackground()); + m_categoryLegend->enableBackground(preferences->showLegendBackground()); + + if (m_globalAutoMax != cvf::UNDEFINED_DOUBLE ) + { + m_userDefinedMaxValue.uiCapability()->setUiName(QString("Max ") + "(" + QString::number(m_globalAutoMax, 'g', m_precision) + ")"); + } + else + { + m_userDefinedMaxValue.uiCapability()->setUiName(QString()); + } + + if (m_globalAutoMin != cvf::UNDEFINED_DOUBLE ) + { + m_userDefinedMinValue.uiCapability()->setUiName(QString("Min ") + "(" + QString::number(m_globalAutoMin, 'g', m_precision) + ")"); + } + else + { + m_userDefinedMinValue.uiCapability()->setUiName(QString()); + } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::disableAllTimeStepsRange(bool doDisable) +{ + // If we enable AllTimesteps, and we have used current timestep, then "restore" the default + if (m_isAllTimeStepsRangeDisabled && !doDisable && m_rangeMode == AUTOMATIC_CURRENT_TIMESTEP) m_rangeMode = AUTOMATIC_ALLTIMESTEPS; + + m_isAllTimeStepsRangeDisabled = doDisable; + + if (doDisable && m_rangeMode == AUTOMATIC_ALLTIMESTEPS) m_rangeMode = AUTOMATIC_CURRENT_TIMESTEP; + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax) +{ + double candidateGlobalAutoMin = roundToNumSignificantDigits(globalMin, m_precision); + double candidateGlobalAutoMax = roundToNumSignificantDigits(globalMax, m_precision); + + double candidateLocalAutoMin = roundToNumSignificantDigits(localMin, m_precision); + double candidateLocalAutoMax = roundToNumSignificantDigits(localMax, m_precision); + + m_globalAutoMin = candidateGlobalAutoMin; + m_globalAutoMax = candidateGlobalAutoMax; + + m_localAutoMin = candidateLocalAutoMin; + m_localAutoMax = candidateLocalAutoMax; + + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::initAfterRead() +{ + updateFieldVisibility(); +} + +caf::PdmFieldHandle* RimRegularLegendConfig::objectToggleField() +{ + return &m_showLegend; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::updateFieldVisibility() +{ + bool showRangeItems = m_mappingMode == CATEGORY_INTEGER ? false : true; + + m_numLevels.uiCapability()->setUiHidden(!showRangeItems); + m_precision.uiCapability()->setUiHidden(!showRangeItems); + m_tickNumberFormat.uiCapability()->setUiHidden(!showRangeItems); + m_rangeMode.uiCapability()->setUiHidden(!showRangeItems); + + if (showRangeItems && m_rangeMode == USER_DEFINED) + { + m_userDefinedMaxValue.uiCapability()->setUiHidden(false); + m_userDefinedMinValue.uiCapability()->setUiHidden(false); + } + else + { + m_userDefinedMaxValue.uiCapability()->setUiHidden(true); + m_userDefinedMinValue.uiCapability()->setUiHidden(true); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setColorRange(ColorRangesType colorMode) +{ + m_colorRangeMode = colorMode; + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setMappingMode(MappingType mappingType) +{ + m_mappingMode = mappingType; + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::recreateLegend() +{ + // Due to possible visualization bug, we need to recreate the legend if the last viewer + // has been removed, (and thus the opengl resources has been deleted) The text in + // the legend disappeared because of this, so workaround: recreate the legend when needed: + + cvf::Font* standardFont = RiaApplication::instance()->standardFont(); + m_scalarMapperLegend = new caf::OverlayScalarMapperLegend(standardFont); + m_categoryLegend = new caf::CategoryLegend(standardFont, m_categoryMapper.p()); + + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// Rounding the double value to given number of significant digits +//-------------------------------------------------------------------------------------------------- +double RimRegularLegendConfig::roundToNumSignificantDigits(double domainValue, double numSignificantDigits) +{ + double absDomainValue = cvf::Math::abs(domainValue); + if (absDomainValue == 0.0) + { + return 0.0; + } + + double logDecValue = log10(absDomainValue); + logDecValue = cvf::Math::ceil(logDecValue); + + double factor = pow(10.0, numSignificantDigits - logDecValue); + + double tmp = domainValue * factor; + double integerPart; + double fraction = modf(tmp, &integerPart); + + if (cvf::Math::abs(fraction)>= 0.5) (integerPart >= 0) ? integerPart++: integerPart-- ; + + double newDomainValue = integerPart / factor; + + return newDomainValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero) +{ + bool needsUpdate = false; + const double epsilon = std::numeric_limits::epsilon(); + + if (cvf::Math::abs(globalPosClosestToZero - m_globalAutoPosClosestToZero) > epsilon) + { + needsUpdate = true; + } + if (cvf::Math::abs(globalNegClosestToZero - m_globalAutoNegClosestToZero) > epsilon) + { + needsUpdate = true; + } + if (cvf::Math::abs(localPosClosestToZero - m_localAutoPosClosestToZero) > epsilon) + { + needsUpdate = true; + } + if (cvf::Math::abs(localNegClosestToZero - m_localAutoNegClosestToZero) > epsilon) + { + needsUpdate = true; + } + + if (needsUpdate) + { + m_globalAutoPosClosestToZero = globalPosClosestToZero; + m_globalAutoNegClosestToZero = globalNegClosestToZero; + m_localAutoPosClosestToZero = localPosClosestToZero; + m_localAutoNegClosestToZero = localNegClosestToZero; + + if (m_globalAutoPosClosestToZero == HUGE_VAL) m_globalAutoPosClosestToZero = 0; + if (m_globalAutoNegClosestToZero == -HUGE_VAL) m_globalAutoNegClosestToZero = 0; + if (m_localAutoPosClosestToZero == HUGE_VAL) m_localAutoPosClosestToZero = 0; + if (m_localAutoNegClosestToZero == -HUGE_VAL) m_localAutoNegClosestToZero = 0; + + updateLegend(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setIntegerCategories(const std::vector& categories) +{ + m_categories = categories; + m_categoryNames.clear(); + m_categoryColors.clear(); + + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setNamedCategories(const std::vector& categoryNames) +{ + setNamedCategories(categoryNames, false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setNamedCategoriesInverse(const std::vector& categoryNames) +{ + setNamedCategories(categoryNames, true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setCategoryItems(const std::vector< std::tuple >& categories) +{ + m_categories.clear(); + m_categoryNames.clear(); + m_categoryColors.clear(); + m_categoryColors.reserve(categories.size()); + + for (auto item : categories) + { + m_categoryNames.push_back(cvfqt::Utils::toString(std::get<0>(item))); + m_categories.push_back(std::get<1>(item)); + m_categoryColors.add(std::get<2>(item)); + } + + updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimRegularLegendConfig::categoryNameFromCategoryValue(double categoryResultValue) const +{ + if (categoryResultValue == HUGE_VAL) return "Undefined"; + + if (m_categoryNames.size() > 0) + { + for (size_t categoryIndex = 0; categoryIndex < m_categories.size(); categoryIndex++) + { + if (categoryResultValue == m_categories[categoryIndex]) + { + return cvfqt::Utils::toQString(m_categoryNames[categoryIndex]); + } + } + } + + return QString("%1").arg(categoryResultValue); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimRegularLegendConfig::categoryValueFromCategoryName(const QString& categoryName) const +{ + for (int i = 0; i < (int)m_categoryNames.size(); i++) + { + if (cvfqt::Utils::toQString(m_categoryNames[i]).compare(categoryName, Qt::CaseInsensitive) == 0) + { + return i; + } + } + return HUGE_VAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setTitle(const QString& title) +{ + auto cvfTitle = cvfqt::Utils::toString(title); + m_scalarMapperLegend->setTitle(cvfTitle); + m_categoryLegend->setTitle(cvfTitle); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimRegularLegendConfig::showLegend() const +{ + return m_showLegend; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() +{ + if (m_currentScalarMapper == m_categoryMapper) + { + return m_categoryLegend.p(); + } + else + { + return m_scalarMapperLegend.p(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::TitledOverlayFrame* RimRegularLegendConfig::titledOverlayFrame() const +{ + if (m_currentScalarMapper == m_categoryMapper) + { + return m_categoryLegend.p(); + } + else + { + return m_scalarMapperLegend.p(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setUiValuesFromLegendConfig(const RimRegularLegendConfig* otherLegendConfig) +{ + QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); + this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); + this->updateLegend(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Color3ubArray RimRegularLegendConfig::colorArrayFromColorType(ColorRangesType colorType) +{ + switch (colorType) + { + case RimRegularLegendConfig::NORMAL: + return RiaColorTables::normalPaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::OPPOSITE_NORMAL: + return RiaColorTables::normalPaletteOppositeOrderingColors().color3ubArray(); + break; + case RimRegularLegendConfig::WHITE_PINK: + return RiaColorTables::whitePinkPaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::PINK_WHITE: + return RiaColorTables::pinkWhitePaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::WHITE_BLACK: + return RiaColorTables::whiteBlackPaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::BLACK_WHITE: + return RiaColorTables::blackWhitePaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::BLUE_WHITE_RED: + return RiaColorTables::blueWhiteRedPaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::RED_WHITE_BLUE: + return RiaColorTables::redWhiteBluePaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::CATEGORY: + return RiaColorTables::categoryPaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::ANGULAR: + return RiaColorTables::angularPaletteColors().color3ubArray(); + break; + case RimRegularLegendConfig::STIMPLAN: + return RiaColorTables::stimPlanPaletteColors().color3ubArray(); + break; + default: + if (ColorManager::isEnsembleColorRange(colorType)) return ColorManager::EnsembleColorRanges().at(colorType); + break; + } + + return RiaColorTables::normalPaletteColors().color3ubArray(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + { + caf::PdmUiOrdering * formatGr = uiOrdering.addNewGroup("Format"); + formatGr->add(&m_numLevels); + formatGr->add(&m_precision); + formatGr->add(&m_tickNumberFormat); + formatGr->add(&m_colorRangeMode); + + caf::PdmUiOrdering * mappingGr = uiOrdering.addNewGroup("Mapping"); + mappingGr->add(&m_mappingMode); + mappingGr->add(&m_rangeMode); + mappingGr->add(&m_userDefinedMaxValue); + mappingGr->add(&m_userDefinedMinValue); + } + + updateFieldVisibility(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimRegularLegendConfig::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + bool hasStimPlanParent = false; + bool hasEnsembleCurveSetParent = false; + + RimStimPlanColors* stimPlanColors = nullptr; + this->firstAncestorOrThisOfType(stimPlanColors); + if (stimPlanColors) hasStimPlanParent = true; + + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet) hasEnsembleCurveSetParent = true; + + bool isCategoryResult = false; + { + RimEclipseCellColors* eclCellColors = nullptr; + this->firstAncestorOrThisOfType(eclCellColors); + RimGeoMechResultDefinition* gmCellColors = nullptr; + this->firstAncestorOrThisOfType(gmCellColors); + RimCellEdgeColors* eclCellEdgColors = nullptr; + this->firstAncestorOrThisOfType(eclCellEdgColors); + + if ( ( eclCellColors && eclCellColors->hasCategoryResult()) + || ( gmCellColors && gmCellColors->hasCategoryResult()) + || ( eclCellEdgColors && eclCellEdgColors->hasCategoryResult()) + || ( ensembleCurveSet && ensembleCurveSet->currentEnsembleParameterType() == RimEnsembleCurveSet::TYPE_TEXT) ) + { + isCategoryResult = true; + } + } + + QList options; + + if (fieldNeedingOptions == &m_mappingMode) + { + // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of this type + std::vector mappingTypes; + mappingTypes.push_back(LINEAR_DISCRETE); + mappingTypes.push_back(LINEAR_CONTINUOUS); + mappingTypes.push_back(LOG10_CONTINUOUS); + mappingTypes.push_back(LOG10_DISCRETE); + + if (isCategoryResult) + { + mappingTypes.push_back(CATEGORY_INTEGER); + } + + for(MappingType mapType: mappingTypes) + { + options.push_back(caf::PdmOptionItemInfo(MappingEnum::uiText(mapType), mapType)); + } + } + else if (fieldNeedingOptions == &m_colorRangeMode) + { + // This is an app enum field, see cafInternalPdmFieldTypeSpecializations.h for the default specialization of this type + std::vector rangeTypes; + if (!hasEnsembleCurveSetParent) + { + rangeTypes.push_back(NORMAL); + rangeTypes.push_back(OPPOSITE_NORMAL); + rangeTypes.push_back(WHITE_PINK); + rangeTypes.push_back(PINK_WHITE); + rangeTypes.push_back(BLUE_WHITE_RED); + rangeTypes.push_back(RED_WHITE_BLUE); + rangeTypes.push_back(WHITE_BLACK); + rangeTypes.push_back(BLACK_WHITE); + rangeTypes.push_back(ANGULAR); + } + else + { + for (const auto& col : ColorManager::EnsembleColorRanges()) + { + rangeTypes.push_back(col.first); + } + } + + if (hasStimPlanParent) rangeTypes.push_back(STIMPLAN); + + if (isCategoryResult) + { + rangeTypes.push_back(CATEGORY); + } + + for(ColorRangesType colType: rangeTypes) + { + options.push_back(caf::PdmOptionItemInfo(ColorRangeEnum::uiText(colType), colType)); + } + } + else if (fieldNeedingOptions == &m_rangeMode) + { + if (!m_isAllTimeStepsRangeDisabled) + { + QString uiText; + if(!hasEnsembleCurveSetParent) uiText = RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS); + else uiText = "Auto Range"; + + options.push_back(caf::PdmOptionItemInfo(uiText, RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + } + if (!hasStimPlanParent && !hasEnsembleCurveSetParent) + { + options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); + } + options.push_back(caf::PdmOptionItemInfo(RangeModeEnum::uiText(RimRegularLegendConfig::USER_DEFINED), RimRegularLegendConfig::USER_DEFINED)); + } + + return options; +} + diff --git a/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h new file mode 100644 index 0000000000..8dafd2af15 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimRegularLegendConfig.h @@ -0,0 +1,184 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RimLegendConfig.h" + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfArray.h" + +#include + +namespace cvf +{ + class ScalarMapperContinuousLog; + class ScalarMapperContinuousLinear; + class OverlayItem; + class ScalarMapperDiscreteLinear; + class ScalarMapperDiscreteLog; + class ScalarMapper; + class String; +} + +namespace caf +{ + class TitledOverlayFrame; + class CategoryLegend; + class CategoryMapper; + class OverlayScalarMapperLegend; +} + +class Rim3dView; +class RimEnsembleCurveSet; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimRegularLegendConfig : public RimLegendConfig +{ + CAF_PDM_HEADER_INIT; +public: + RimRegularLegendConfig(); + virtual ~RimRegularLegendConfig(); + + caf::PdmField resultVariableName; // Used internally to describe the variable this legend setup is used for + + enum ColorRangesType + { + NORMAL, + OPPOSITE_NORMAL, + WHITE_PINK, + PINK_WHITE, + WHITE_BLACK, + BLACK_WHITE, + BLUE_WHITE_RED, + RED_WHITE_BLUE, + CATEGORY, + ANGULAR, + STIMPLAN, + + GREEN_RED, + BLUE_MAGENTA, + RED_LIGHT_DARK, + GREEN_LIGHT_DARK, + BLUE_LIGHT_DARK + }; + + typedef caf::AppEnum ColorRangeEnum; + + enum MappingType + { + LINEAR_DISCRETE, + LINEAR_CONTINUOUS, + LOG10_CONTINUOUS, + LOG10_DISCRETE, + CATEGORY_INTEGER + }; + enum NumberFormatType { AUTO, SCIENTIFIC, FIXED}; + + typedef caf::AppEnum MappingEnum; + void recreateLegend(); + + void setColorRange(ColorRangesType colorMode); + ColorRangesType colorRange() { return m_colorRangeMode();} + void setMappingMode(MappingType mappingType); + MappingType mappingMode() { return m_mappingMode();} + void disableAllTimeStepsRange(bool doDisable); + + void setAutomaticRanges(double globalMin, double globalMax, double localMin, double localMax); + void setClosestToZeroValues(double globalPosClosestToZero, double globalNegClosestToZero, double localPosClosestToZero, double localNegClosestToZero); + + void setIntegerCategories(const std::vector& categories); + void setNamedCategories(const std::vector& categoryNames); + void setNamedCategoriesInverse(const std::vector& categoryNames); + void setCategoryItems(const std::vector>& categories); + QString categoryNameFromCategoryValue(double categoryResultValue) const; + double categoryValueFromCategoryName(const QString& categoryName) const; + + void setTitle(const QString& title); + + void setUiValuesFromLegendConfig(const RimRegularLegendConfig* otherLegendConfig); + + cvf::ScalarMapper* scalarMapper() { return m_currentScalarMapper.p(); } + bool showLegend() const; + + const caf::TitledOverlayFrame* titledOverlayFrame() const override; + caf::TitledOverlayFrame* titledOverlayFrame() override; + +private: + void setNamedCategories(const std::vector& categoryNames, bool inverse); + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + void initAfterRead() override; + caf::PdmFieldHandle* objectToggleField() override; + + friend class RimStimPlanLegendConfig; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + + void updateLegend(); + void updateFieldVisibility(); + double roundToNumSignificantDigits(double value, double precision); + + friend class RimViewLinker; + + static cvf::Color3ubArray colorArrayFromColorType(ColorRangesType colorType); + +private: + cvf::ref m_linDiscreteScalarMapper; + cvf::ref m_logDiscreteScalarMapper; + cvf::ref m_logSmoothScalarMapper; + cvf::ref m_linSmoothScalarMapper; + cvf::ref m_currentScalarMapper; + + cvf::ref m_scalarMapperLegend; + + cvf::ref m_categoryMapper; + cvf::ref m_categoryLegend; + + double m_globalAutoMax; + double m_globalAutoMin; + double m_localAutoMax; + double m_localAutoMin; + + double m_globalAutoPosClosestToZero; + double m_globalAutoNegClosestToZero; + double m_localAutoPosClosestToZero; + double m_localAutoNegClosestToZero; + + bool m_isAllTimeStepsRangeDisabled; + + std::vector m_categories; + std::vector m_categoryNames; + cvf::Color3ubArray m_categoryColors; + + // Fields + caf::PdmField m_showLegend; + caf::PdmField m_numLevels; + caf::PdmField m_precision; + caf::PdmField > m_tickNumberFormat; + caf::PdmField m_rangeMode; + caf::PdmField m_userDefinedMaxValue; + caf::PdmField m_userDefinedMinValue; + caf::PdmField > m_colorRangeMode; + caf::PdmField > m_mappingMode; +}; diff --git a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp index 1ec7ebb26b..e366396acd 100644 --- a/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp +++ b/ApplicationCode/ProjectDataModel/RimReservoirCellResultsStorage.cpp @@ -49,7 +49,7 @@ CAF_PDM_SOURCE_INIT(RimReservoirCellResultsStorage, "ReservoirCellResultStorage" /// //-------------------------------------------------------------------------------------------------- RimReservoirCellResultsStorage::RimReservoirCellResultsStorage() - : m_cellResults(NULL) + : m_cellResults(nullptr) { CAF_PDM_InitObject("Cacher", "", "", ""); @@ -150,7 +150,7 @@ void RimReservoirCellResultsStorage::setupBeforeSave() // starting with the number of values for (size_t tsIdx = 0; tsIdx < resInfo[rIdx].dates().size() ; ++tsIdx) { - const std::vector* data = NULL; + const std::vector* data = nullptr; if (tsIdx < timestepCount) { data = &(m_cellResults->cellScalarResults(resInfo[rIdx].m_gridScalarResultIndex, tsIdx)); @@ -219,7 +219,7 @@ void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cell { m_cellResults = cellResults; - if (m_cellResults == NULL) + if (m_cellResults == nullptr) return; // Now that we have got the results container, we can finally @@ -283,7 +283,7 @@ void RimReservoirCellResultsStorage::setCellResults(RigCaseCellResultsData* cell for (size_t tsIdx = 0; tsIdx < resInfo->m_timeStepDates().size(); ++tsIdx) { - std::vector* data = NULL; + std::vector* data = nullptr; data = &(m_cellResults->cellScalarResults(resultIndex, tsIdx)); diff --git a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp index 48ae95afb2..ede492a3b0 100644 --- a/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimRftPlotCollection.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RimRftPlotCollection, "WellRftPlotCollection"); //-------------------------------------------------------------------------------------------------- RimRftPlotCollection::RimRftPlotCollection() { - CAF_PDM_InitObject("RFT Plots", ":/WellLogPlots16x16.png", "", ""); + CAF_PDM_InitObject("RFT Plots", ":/RFTPlots16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_rftPlots, "RftPlots", "", "", "", ""); m_rftPlots.uiCapability()->setUiHidden(true); @@ -88,7 +88,7 @@ RigEclipseWellLogExtractor* RimRftPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->eclipseCaseData())) { - return NULL; + return nullptr; } RigEclipseCaseData* eclCaseData = eclCase->eclipseCaseData(); @@ -115,7 +115,7 @@ RigGeoMechWellLogExtractor* RimRftPlotCollection::findOrCreateExtractor(RimWellP { if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { - return NULL; + return nullptr; } RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); diff --git a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp index 2ed6cc2778..8cbe4d1321 100644 --- a/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimScriptCollection.cpp @@ -160,12 +160,12 @@ RimScriptCollection * RimScriptCollection::findScriptCollection(const QString& p for (size_t i = 0; i < this->subDirectories.size(); ++i) { - RimScriptCollection* foundColl = NULL; + RimScriptCollection* foundColl = nullptr; if (this->subDirectories[i]) foundColl = this->subDirectories[i]->findScriptCollection(path); if (foundColl) return foundColl; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp index 15443e52c3..57ac920432 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.cpp @@ -20,32 +20,37 @@ #include "RimSimWellInView.h" -#include "RigSimulationWellCenterLineCalculator.h" +#include "RigActiveCellInfo.h" +#include "RigCell.h" +#include "RigEclipseCaseData.h" +#include "RigMainGrid.h" #include "RigSimWellData.h" +#include "RigSimulationWellCenterLineCalculator.h" #include "RimCellRangeFilterCollection.h" +#include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimIntersectionCollection.h" -#include "RimSimWellInViewCollection.h" - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimSimWellFractureCollection.h" +#include "RimPropertyFilterCollection.h" #include "RimSimWellFracture.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES +#include "RimSimWellFractureCollection.h" +#include "RimSimWellInViewCollection.h" +#include "RimIntersection.h" +#include "Rim2dIntersectionView.h" #include "RiuMainWindow.h" #include "RivReservoirViewPartMgr.h" #include "cafPdmUiTreeOrdering.h" - #include "cvfMath.h" -#include "RigCell.h" -#include "RimEclipseCase.h" -#include "RigEclipseCaseData.h" -#include "RigMainGrid.h" -#include "RigActiveCellInfo.h" -#include "RimPropertyFilterCollection.h" + + +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* corresponding2dIntersectionView(RimSimWellInView *simWellInView); + CAF_PDM_SOURCE_INIT(RimSimWellInView, "Well"); @@ -72,18 +77,14 @@ RimSimWellInView::RimSimWellInView() CAF_PDM_InitField(&showWellCells, "ShowWellCells", false, "Well Cells", "", "", ""); CAF_PDM_InitField(&showWellCellFence, "ShowWellCellFence", false, "Well Cell Fence", "", "", ""); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES CAF_PDM_InitFieldNoDefault(&simwellFractureCollection, "FractureCollection", "Fractures", "", "", ""); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES name.uiCapability()->setUiHidden(true); name.uiCapability()->setUiReadOnly(true); m_resultWellIndex = cvf::UNDEFINED_SIZE_T; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES simwellFractureCollection= new RimSimWellFractureCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -91,9 +92,7 @@ RimSimWellInView::RimSimWellInView() //-------------------------------------------------------------------------------------------------- RimSimWellInView::~RimSimWellInView() { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES if (simwellFractureCollection()) delete simwellFractureCollection(); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- @@ -120,6 +119,7 @@ void RimSimWellInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, &wellPipeColor == changedField) { reservoirView->scheduleCreateDisplayModelAndRedraw(); + schedule2dIntersectionViewUpdate(); } else if (&showWell == changedField || &showWellCells == changedField || @@ -128,15 +128,14 @@ void RimSimWellInView::fieldChangedByUi(const caf::PdmFieldHandle* changedField, { reservoirView->scheduleGeometryRegen(VISIBLE_WELL_CELLS); reservoirView->scheduleCreateDisplayModelAndRedraw(); + schedule2dIntersectionViewUpdate(); } else if ( &pipeScaleFactor == changedField || &wellHeadScaleFactor == changedField) { - if (reservoirView) - { - reservoirView->scheduleSimWellGeometryRegen(); - reservoirView->scheduleCreateDisplayModelAndRedraw(); - } + reservoirView->scheduleSimWellGeometryRegen(); + reservoirView->scheduleCreateDisplayModelAndRedraw(); + schedule2dIntersectionViewUpdate(); } } @@ -166,31 +165,37 @@ caf::PdmFieldHandle* RimSimWellInView::objectToggleField() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellInView::calculateWellPipeStaticCenterLine(std::vector>& pipeBranchesCLCoords, - std::vector>& pipeBranchesCellIds) +std::vector RimSimWellInView::wellPipeBranches() const { - RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(this, - pipeBranchesCLCoords, - pipeBranchesCellIds); + RimSimWellInViewCollection* simWellCollection = nullptr; + this->firstAncestorOrThisOfTypeAsserted(simWellCollection); + + RimEclipseCase* eclipseCase = nullptr; + this->firstAncestorOrThisOfTypeAsserted(eclipseCase); + RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); + CVF_ASSERT(caseData); + + bool includeCellCenters = this->isUsingCellCenterForPipe(); + bool detectBrances = simWellCollection->isAutoDetectingBranches; + + return caseData->simulationWellBranches(this->name(), includeCellCenters, detectBrances); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSimWellInView::calculateWellPipeDynamicCenterLine(size_t timeStepIdx, - std::vector>& pipeBranchesCLCoords, - std::vector>& pipeBranchesCellIds) const +void RimSimWellInView::calculateWellPipeStaticCenterLine(std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds) { - RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(this, - static_cast(timeStepIdx), - pipeBranchesCLCoords, - pipeBranchesCellIds); + RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(this, + pipeBranchesCLCoords, + pipeBranchesCellIds); } //-------------------------------------------------------------------------------------------------- -/// +/// frameIndex = -1 will use the static well frame //-------------------------------------------------------------------------------------------------- -void RimSimWellInView::wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom) +void RimSimWellInView::wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom) { RimEclipseView* m_rimReservoirView; @@ -198,10 +203,24 @@ void RimSimWellInView::wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData(); - if ( !this->simWellData()->hasAnyValidCells(frameIndex) ) return; + const RigWellResultFrame* wellResultFramePtr = nullptr; + const RigCell* whCellPtr = nullptr; + + if (frameIndex >= 0) + { + if ( !this->simWellData()->hasAnyValidCells(frameIndex) ) return; - const RigWellResultFrame& wellResultFrame = this->simWellData()->wellResultFrame(frameIndex); - const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.wellHeadOrStartCell()); + wellResultFramePtr = &(this->simWellData()->wellResultFrame(frameIndex)); + whCellPtr = &(rigReservoir->cellFromWellResultCell(wellResultFramePtr->wellHeadOrStartCell())); + } + else + { + wellResultFramePtr = &(this->simWellData()->staticWellCells()); + whCellPtr = &(rigReservoir->cellFromWellResultCell(wellResultFramePtr->wellHeadOrStartCell())); + } + + const RigWellResultFrame& wellResultFrame = *wellResultFramePtr; + const RigCell& whCell = *whCellPtr; // Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline() @@ -262,6 +281,16 @@ double RimSimWellInView::pipeRadius() return pipeRadius; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimSimWellInView::pipeCrossSectionVertexCount() +{ + RimSimWellInViewCollection* simWellCollection = nullptr; + this->firstAncestorOrThisOfTypeAsserted(simWellCollection); + return simWellCollection->pipeCrossSectionVertexCount(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -342,6 +371,18 @@ bool RimSimWellInView::intersectsWellCellsFilteredCells(const RigWellResultFrame return false; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSimWellInView::schedule2dIntersectionViewUpdate() +{ + Rim2dIntersectionView* intersectionView = corresponding2dIntersectionView(this); + if (intersectionView) + { + intersectionView->scheduleCreateDisplayModelAndRedraw(); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -389,13 +430,11 @@ void RimSimWellInView::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering //-------------------------------------------------------------------------------------------------- void RimSimWellInView::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES for (RimSimWellFracture* fracture : simwellFractureCollection()->simwellFractures()) { uiTreeOrdering.add(fracture); } uiTreeOrdering.skipRemainingChildren(true); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES const RimEclipseView* reservoirView = nullptr; this->firstAncestorOrThisOfType(reservoirView); @@ -599,3 +638,28 @@ size_t RimSimWellInView::resultWellIndex() const return m_resultWellIndex; } +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +Rim2dIntersectionView* corresponding2dIntersectionView(RimSimWellInView *simWellInView) +{ + Rim3dView* tdView; + simWellInView->firstAncestorOrThisOfType(tdView); + + std::vector intersectionColls; + if (tdView) + { + tdView->descendantsIncludingThisOfType(intersectionColls); + if (intersectionColls.size() == 1) + { + for (const auto intersection : intersectionColls[0]->intersections()) + { + if (intersection->simulationWell() == simWellInView) + { + return intersection->correspondingIntersectionView(); + } + } + } + } + return nullptr; +} diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInView.h b/ApplicationCode/ProjectDataModel/RimSimWellInView.h index 33f544c9f8..770c43f6b3 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInView.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInView.h @@ -36,10 +36,8 @@ class RigSimWellData; class RigWellResultFrame; struct RigWellResultPoint; - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimSimWellFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES +class RigWellPath; //================================================================================================== /// @@ -67,15 +65,17 @@ class RimSimWellInView : public caf::PdmObject virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; + std::vector wellPipeBranches() const; + void calculateWellPipeStaticCenterLine( std::vector< std::vector >& pipeBranchesCLCoords, std::vector< std::vector >& pipeBranchesCellIds); - void calculateWellPipeDynamicCenterLine(size_t timeStepIdx, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) const; - - void wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); + void wellHeadTopBottomPosition(int frameIndex, cvf::Vec3d* top, cvf::Vec3d* bottom); double pipeRadius(); + int pipeCrossSectionVertexCount(); + + void schedule2dIntersectionViewUpdate(); + caf::PdmField showWell; caf::PdmField name; @@ -93,9 +93,7 @@ class RimSimWellInView : public caf::PdmObject caf::PdmField showWellCells; caf::PdmField showWellCellFence; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES caf::PdmChildField simwellFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES protected: diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp index 66c298c664..269c8c59ac 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.cpp @@ -28,14 +28,13 @@ #include "RigSimWellData.h" #include "RimEclipseCase.h" +#include "RimEclipseResultCase.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimProject.h" +#include "RimSimWellFractureCollection.h" #include "RimSimWellInView.h" #include "RimWellAllocationPlot.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -#include "RimSimWellFracture.h" -#include "RimSimWellFractureCollection.h" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include "RiuMainWindow.h" @@ -43,7 +42,6 @@ #include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiCheckBoxTristateEditor.h" -#include "RimEclipseResultCase.h" namespace caf @@ -209,7 +207,7 @@ RimSimWellInViewCollection::RimSimWellInViewCollection() obsoleteField_showWellLabel.xmlCapability()->setIOWritable(false); obsoleteField_showWellCellFence.xmlCapability()->setIOWritable(false); - m_reservoirView = NULL; + m_reservoirView = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -266,7 +264,7 @@ RimSimWellInView* RimSimWellInViewCollection::findWell(QString name) return this->wells()[i]; } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -321,7 +319,7 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha { this->updateUiIconFromToggleField(); - RimView* view; + Rim3dView* view; firstAncestorOrThisOfType(view); if (view) { @@ -417,6 +415,8 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha { m_reservoirView->scheduleSimWellGeometryRegen(); m_reservoirView->scheduleCreateDisplayModelAndRedraw(); + + for (RimSimWellInView* w : wells) w->schedule2dIntersectionViewUpdate(); } else if (&showWellsIntersectingVisibleCells == changedField) { @@ -462,18 +462,19 @@ void RimSimWellInViewCollection::fieldChangedByUi(const caf::PdmFieldHandle* cha if (m_reservoirView) m_reservoirView->scheduleCreateDisplayModelAndRedraw(); } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - if (&wellPipeCoordType == changedField) + if (&wellPipeCoordType == changedField || &isAutoDetectingBranches == changedField) { + if (m_reservoirView) + { + m_reservoirView->crossSectionCollection()->recomputeSimWellBranchData(); + } + for (RimSimWellInView* w : wells) { - for (RimSimWellFracture* frac : w->simwellFractureCollection()->simwellFractures()) - { - frac->recomputeWellCenterlineCoordinates(); - } + w->simwellFractureCollection()->recomputeSimWellCenterlines(); + } } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h index df15464505..dea4460889 100644 --- a/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h +++ b/ApplicationCode/ProjectDataModel/RimSimWellInViewCollection.h @@ -109,8 +109,8 @@ class RimSimWellInViewCollection : public caf::PdmObject caf::PdmField wellHeadPosition; caf::PdmField isAutoDetectingBranches; - - caf::PdmChildArrayField wells; + + caf::PdmChildArrayField wells; RimSimWellInView* findWell(QString name); bool hasVisibleWellCells(); diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp index 03b5aef9fa..a9850e13d4 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.cpp @@ -19,10 +19,11 @@ #include "RimStimPlanColors.h" #include "RiaApplication.h" +#include "RiaFractureDefines.h" #include "RimEclipseView.h" #include "RimFractureTemplateCollection.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimOilField.h" #include "RimProject.h" #include "RimStimPlanFractureTemplate.h" @@ -39,10 +40,23 @@ CAF_PDM_SOURCE_INIT(RimStimPlanColors, "RimStimPlanColors"); +namespace caf { + + template<> + void caf::AppEnum< RimStimPlanColors::StimPlanResultColorType >::setUp() + { + addItem(RimStimPlanColors::COLOR_INTERPOLATION, "COLOR_INTERPOLATION", "On"); + addItem(RimStimPlanColors::SINGLE_ELEMENT_COLOR, "SINGLE_ELEMENT_COLOR", "Off"); + + setDefault(RimStimPlanColors::COLOR_INTERPOLATION); + } + +} // End namespace caf + //-------------------------------------------------------------------------------------------------- /// Internal methods //-------------------------------------------------------------------------------------------------- -static void setDefaultResultIfStimPlan(caf::PdmField &field); +static void setDefaultFractureResult(caf::PdmField &field); static QString toString(const std::pair& resultNameAndUnit); //-------------------------------------------------------------------------------------------------- @@ -50,17 +64,18 @@ static QString toString(const std::pair& resultNameAndUnit); //-------------------------------------------------------------------------------------------------- RimStimPlanColors::RimStimPlanColors() { - CAF_PDM_InitObject("StimPlan Colors", ":/FractureSymbol16x16.png", "", ""); + CAF_PDM_InitObject("Fractures", ":/FractureSymbol16x16.png", "", ""); - CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "StimPlan Result Variable", "", "", ""); + CAF_PDM_InitField(&m_resultNameAndUnit, "ResultName", QString(""), "Result Variable", "", "", ""); CAF_PDM_InitField(&m_defaultColor, "DefaultColor", cvf::Color3f(cvf::Color3::BROWN), "Default Color", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_legendConfigurations, "LegendConfigurations", "", "", "", ""); m_legendConfigurations.uiCapability()->setUiTreeHidden(true); - setName("Fracture Colors"); - nameField()->uiCapability()->setUiReadOnly(true); + CAF_PDM_InitField(&m_showStimPlanMesh, "ShowStimPlanMesh", true, "Show Mesh", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_stimPlanCellVizMode, "StimPlanCellVizMode", "Color Interpolation", "", "", ""); } //-------------------------------------------------------------------------------------------------- @@ -71,6 +86,14 @@ RimStimPlanColors::~RimStimPlanColors() } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanColors::setShowStimPlanMesh(bool showStimPlanMesh) +{ + m_showStimPlanMesh = showStimPlanMesh; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -78,12 +101,12 @@ void RimStimPlanColors::loadDataAndUpdate() { RimFractureTemplateCollection* fractureTemplates = fractureTemplateCollection(); - std::vector > resultNameAndUnits = fractureTemplates->stimPlanResultNamesAndUnits(); + std::vector > resultNameAndUnits = fractureTemplates->resultNamesAndUnits(); // Delete legends referencing results not present on file { - std::vector toBeDeleted; - for (RimLegendConfig* legend : m_legendConfigurations) + std::vector toBeDeleted; + for (RimRegularLegendConfig* legend : m_legendConfigurations) { QString legendVariableName = legend->resultVariableName(); @@ -116,7 +139,7 @@ void RimStimPlanColors::loadDataAndUpdate() QString resultNameUnitString = toString(resultNameAndUnit); bool foundResult = false; - for (RimLegendConfig* legend : m_legendConfigurations) + for (RimRegularLegendConfig* legend : m_legendConfigurations) { if (legend->resultVariableName() == resultNameUnitString) { @@ -126,10 +149,10 @@ void RimStimPlanColors::loadDataAndUpdate() if (!foundResult) { - RimLegendConfig* legendConfig = new RimLegendConfig(); + RimRegularLegendConfig* legendConfig = new RimRegularLegendConfig(); legendConfig->resultVariableName = resultNameUnitString; - legendConfig->setMappingMode(RimLegendConfig::LINEAR_DISCRETE); - legendConfig->setColorRangeMode(RimLegendConfig::STIMPLAN); + legendConfig->setMappingMode(RimRegularLegendConfig::LINEAR_DISCRETE); + legendConfig->setColorRange(RimRegularLegendConfig::STIMPLAN); m_legendConfigurations.push_back(legendConfig); @@ -152,7 +175,7 @@ QList RimStimPlanColors::calculateValueOptions(const caf options.push_back(caf::PdmOptionItemInfo("None", "")); - for (auto resultNameAndUnit : fractureTemplates->stimPlanResultNamesAndUnits()) + for (auto resultNameAndUnit : fractureTemplates->resultNamesAndUnits()) { QString resultNameAndUnitString = toString(resultNameAndUnit); options.push_back(caf::PdmOptionItemInfo(resultNameAndUnitString, resultNameAndUnitString)); @@ -178,14 +201,34 @@ void RimStimPlanColors::fieldChangedByUi(const caf::PdmFieldHandle* changedField { updateStimPlanTemplates(); } + + if (changedField == &m_showStimPlanMesh) + { + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + if (proj) + { + proj->createDisplayModelAndRedrawAllViews(); + } + } + + if(changedField == &m_stimPlanCellVizMode) + { + Rim3dView* rimView = nullptr; + this->firstAncestorOrThisOfType(rimView); + if (rimView) + { + rimView->createDisplayModelAndRedraw(); + } + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimLegendConfig* RimStimPlanColors::activeLegend() const +RimRegularLegendConfig* RimStimPlanColors::activeLegend() const { - for (RimLegendConfig* legendConfig : m_legendConfigurations) + for (RimRegularLegendConfig* legendConfig : m_legendConfigurations) { if (m_resultNameAndUnit == legendConfig->resultVariableName()) { @@ -199,7 +242,7 @@ RimLegendConfig* RimStimPlanColors::activeLegend() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimStimPlanColors::resultName() const +QString RimStimPlanColors::uiResultName() const { return RimStimPlanColors::toResultName(m_resultNameAndUnit()); } @@ -207,9 +250,9 @@ QString RimStimPlanColors::resultName() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimStimPlanColors::setDefaultResultNameForStimPlan() +void RimStimPlanColors::setDefaultResultName() { - setDefaultResultIfStimPlan(m_resultNameAndUnit); + setDefaultFractureResult(m_resultNameAndUnit); } //-------------------------------------------------------------------------------------------------- @@ -233,7 +276,7 @@ cvf::Color3f RimStimPlanColors::defaultColor() const //-------------------------------------------------------------------------------------------------- void RimStimPlanColors::updateLegendData() { - RimLegendConfig* legendConfig = activeLegend(); + RimRegularLegendConfig* legendConfig = activeLegend(); if (legendConfig) { double minValue = HUGE_VAL; @@ -243,7 +286,7 @@ void RimStimPlanColors::updateLegendData() RimFractureTemplateCollection* fracTemplateColl = fractureTemplateCollection(); - fracTemplateColl->computeMinMax(resultName(), unit(), &minValue, &maxValue, &posClosestToZero, &negClosestToZero); + fracTemplateColl->computeMinMax(uiResultName(), unit(), &minValue, &maxValue, &posClosestToZero, &negClosestToZero); if (minValue != HUGE_VAL) { @@ -251,7 +294,7 @@ void RimStimPlanColors::updateLegendData() legendConfig->setClosestToZeroValues(posClosestToZero, negClosestToZero, posClosestToZero, negClosestToZero); } - legendConfig->setTitle(cvfqt::Utils::toString(m_resultNameAndUnit())); + legendConfig->setTitle(m_resultNameAndUnit()); } } @@ -275,6 +318,28 @@ void RimStimPlanColors::updateStimPlanTemplates() const } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStimPlanColors::updateConductivityResultName() +{ + // Conductivity result name as reported from the XML file was moved to the fracture template + // Replace all conductivity names with the one and only conductivity uiName reported from by fracture template + + if (m_resultNameAndUnit().contains("conductivity", Qt::CaseInsensitive)) + { + RimFractureTemplateCollection* fractureTemplates = fractureTemplateCollection(); + for (auto resultNameAndUnit : fractureTemplates->resultNamesAndUnits()) + { + if (resultNameAndUnit.first.contains("conductivity", Qt::CaseInsensitive)) + { + QString resultNameAndUnitString = toString(resultNameAndUnit); + m_resultNameAndUnit = resultNameAndUnitString; + } + } + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -335,8 +400,30 @@ void RimStimPlanColors::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrder //-------------------------------------------------------------------------------------------------- void RimStimPlanColors::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { - uiOrdering.add(&m_resultNameAndUnit); - uiOrdering.add(&m_defaultColor); + caf::PdmUiGroup* colorGroup = uiOrdering.addNewGroup("Colors"); + colorGroup->add(&m_resultNameAndUnit); + colorGroup->add(&m_defaultColor); + + bool stimPlanExists = false; + RimProject* proj; + this->firstAncestorOrThisOfType(proj); + std::vector fracTemplates = proj->allFractureTemplates(); + + for (auto fractemplate : fracTemplates) + { + if (dynamic_cast(fractemplate)) + { + stimPlanExists = true; + break; + } + } + + if (stimPlanExists) + { + caf::PdmUiGroup* stimPlanGroup = uiOrdering.addNewGroup("StimPlan"); + stimPlanGroup->add(&m_showStimPlanMesh); + stimPlanGroup->add(&m_stimPlanCellVizMode); + } uiOrdering.skipRemainingFields(true); } @@ -357,7 +444,7 @@ QString toString(const std::pair& resultNameAndUnit) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void setDefaultResultIfStimPlan(caf::PdmField &field) +void setDefaultFractureResult(caf::PdmField &field) { RimProject* proj = RiaApplication::instance()->project(); @@ -369,9 +456,9 @@ void setDefaultResultIfStimPlan(caf::PdmField &field) { RimFractureTemplateCollection* templColl = proj->allFractureTemplateCollections().front(); - for (auto resultNameAndUnit : templColl->stimPlanResultNamesAndUnits()) + for (auto resultNameAndUnit : templColl->resultNamesAndUnits()) { - if (resultNameAndUnit.first == "CONDUCTIVITY") + if (resultNameAndUnit.first.contains(RiaDefines::conductivityResultName(), Qt::CaseInsensitive)) { field = toString(resultNameAndUnit); break; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h index f923a32137..1ff3a5735e 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanColors.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanColors.h @@ -18,7 +18,7 @@ #pragma once -#include "RimCheckableNamedObject.h" +#include "RimCheckableObject.h" #include "cafAppEnum.h" #include "cafPdmChildField.h" @@ -33,31 +33,42 @@ namespace caf { } -class RimLegendConfig; +class RimRegularLegendConfig; class RimFractureTemplateCollection; //================================================================================================== /// /// //================================================================================================== -class RimStimPlanColors : public RimCheckableNamedObject +class RimStimPlanColors : public RimCheckableObject { CAF_PDM_HEADER_INIT; +public: + enum StimPlanResultColorType + { + COLOR_INTERPOLATION, + SINGLE_ELEMENT_COLOR + }; public: RimStimPlanColors(); virtual ~RimStimPlanColors(); - RimLegendConfig* activeLegend() const; - QString resultName() const; - void setDefaultResultNameForStimPlan(); + RimRegularLegendConfig* activeLegend() const; + QString uiResultName() const; + void setDefaultResultName(); QString unit() const; cvf::Color3f defaultColor() const; + bool showStimPlanMesh() const { return m_showStimPlanMesh; } + void setShowStimPlanMesh(bool showStimPlanMesh); void loadDataAndUpdate(); void updateLegendData(); void updateStimPlanTemplates() const; + StimPlanResultColorType stimPlanResultColorType() const { return m_stimPlanCellVizMode(); }; + + void updateConductivityResultName(); protected: virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; @@ -74,6 +85,9 @@ class RimStimPlanColors : public RimCheckableNamedObject private: caf::PdmField m_defaultColor; caf::PdmField m_resultNameAndUnit; - caf::PdmChildArrayField m_legendConfigurations; + caf::PdmChildArrayField m_legendConfigurations; + caf::PdmField m_showStimPlanMesh; + caf::PdmField> m_stimPlanCellVizMode; + }; diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp index 9f58c46326..b5d54fe9b6 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.cpp @@ -18,7 +18,7 @@ #include "RimStimPlanLegendConfig.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "cafPdmUiOrdering.h" #include "cafPdmUiTreeOrdering.h" @@ -38,7 +38,7 @@ RimStimPlanLegendConfig::RimStimPlanLegendConfig() m_name.uiCapability()->setUiReadOnly(true); CAF_PDM_InitFieldNoDefault(&m_legend, "Legend", "Legend", "", "", ""); - m_legend = new RimLegendConfig; + m_legend = new RimRegularLegendConfig; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h index 7f8afa26a8..3a60a9719c 100644 --- a/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimStimPlanLegendConfig.h @@ -24,7 +24,7 @@ #include "cafPdmChildField.h" -class RimLegendConfig; +class RimRegularLegendConfig; //================================================================================================== /// @@ -50,6 +50,6 @@ class RimStimPlanLegendConfig : public caf::PdmObject private: caf::PdmField m_name; - caf::PdmChildField m_legend; + caf::PdmChildField m_legend; }; diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp index 0a00dad0c2..c5f31f6842 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp +++ b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.cpp @@ -18,8 +18,12 @@ #include "RimSummaryCalculationVariable.h" +#include "RiaApplication.h" #include "RiaSummaryCurveDefinition.h" +#include "RifEclipseSummaryAddressQMetaType.h" + +#include "RimProject.h" #include "RimSummaryAddress.h" #include "RimSummaryCalculation.h" #include "RimSummaryCase.h" @@ -85,7 +89,9 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* { RiuSummaryCurveDefSelectionDialog dlg(nullptr); - dlg.setCaseAndAddress(m_case(), m_summaryAddress->address()); + dlg.hideEnsembles(); + + readDataFromApplicationStore(&dlg); if (dlg.exec() == QDialog::Accepted) { @@ -95,6 +101,8 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* m_case = curveSelection[0].summaryCase(); m_summaryAddress->setAddress(curveSelection[0].summaryAddress()); + writeDataToApplicationStore(); + updateContainingEditor = true; } } @@ -122,7 +130,10 @@ void RimSummaryCalculationVariable::fieldChangedByUi(const caf::PdmFieldHandle* //-------------------------------------------------------------------------------------------------- QString RimSummaryCalculationVariable::summaryAddressDisplayString() const { - return RiaSummaryCurveDefinition::curveDefinitionText(m_case(), m_summaryAddress()->address()); + QString caseName; + if (m_case() ) caseName = m_case()->caseName(); + + return RiaSummaryCurveDefinition::curveDefinitionText(caseName, m_summaryAddress()->address()); } //-------------------------------------------------------------------------------------------------- @@ -164,3 +175,48 @@ void RimSummaryCalculationVariable::defineObjectEditorAttribute(QString uiConfig attr->registerPushButtonTextForFieldKeyword(m_button.keyword(), "Edit"); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationVariable::readDataFromApplicationStore(RiuSummaryCurveDefSelectionDialog* selectionDialog) const +{ + if (!selectionDialog) return; + + auto sumCase = m_case(); + auto sumAddress = m_summaryAddress->address(); + if (!sumCase && !sumAddress.isValid()) + { + QVariant var = RiaApplication::instance()->cacheDataObject("CalculatorSummaryAddress"); + + auto lastUsedAddress = var.value(); + if (lastUsedAddress.isValid()) + { + sumAddress = lastUsedAddress; + } + + QString lastUsedSummaryCaseString = RiaApplication::instance()->cacheDataObject("CalculatorSummaryCase").toString(); + + auto* lastUsedSummaryCase = dynamic_cast( + caf::PdmReferenceHelper::objectFromReference(RiaApplication::instance()->project(), lastUsedSummaryCaseString)); + if (lastUsedSummaryCase) + { + sumCase = lastUsedSummaryCase; + } + } + + selectionDialog->setCaseAndAddress(sumCase, sumAddress); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCalculationVariable::writeDataToApplicationStore() const +{ + QString refFromProjectToObject = + caf::PdmReferenceHelper::referenceFromRootToObject(RiaApplication::instance()->project(), m_case); + RiaApplication::instance()->setCacheDataObject("CalculatorSummaryCase", refFromProjectToObject); + + QVariant sumAdrVar = QVariant::fromValue(m_summaryAddress->address()); + RiaApplication::instance()->setCacheDataObject("CalculatorSummaryAddress", sumAdrVar); +} diff --git a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h index be9b9c2967..baff8ada55 100644 --- a/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h +++ b/ApplicationCode/ProjectDataModel/RimSummaryCalculationVariable.h @@ -28,6 +28,7 @@ class RimSummaryCase; class RimSummaryAddress; +class RiuSummaryCurveDefSelectionDialog; //================================================================================================== /// @@ -53,6 +54,9 @@ class RimSummaryCalculationVariable : public caf::PdmObject virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; virtual void defineObjectEditorAttribute(QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + void readDataFromApplicationStore(RiuSummaryCurveDefSelectionDialog* selectionDialog) const; + void writeDataToApplicationStore() const; + private: caf::PdmField m_name; caf::PdmProxyValueField m_summaryAddressUi; diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.cpp b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp new file mode 100644 index 0000000000..d2f05925a2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.cpp @@ -0,0 +1,394 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimTensorResults.h" + +#include "RigFemResultAddress.h" +#include "RimGeoMechCase.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" + +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" + +#include "cafAppEnum.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmUiTreeOrdering.h" + +CAF_PDM_SOURCE_INIT(RimTensorResults, "RimTensorResults"); + +namespace caf +{ +template<> +void AppEnum::setUp() +{ + addItem(RimTensorResults::WHITE_GRAY_BLACK, "WHITE_GRAY_BLACK", "White, Gray, Black"); + addItem(RimTensorResults::ORANGE_BLUE_WHITE, "ORANGE_BLUE_WHITE", "Orange, Blue, White"); + addItem(RimTensorResults::MAGENTA_BROWN_GRAY, "MAGENTA_BROWN_GRAY", "Magenta, Brown, Gray"); + addItem(RimTensorResults::RESULT_COLORS, "RESULT_COLORS", "Result Colors"); + + setDefault(RimTensorResults::WHITE_GRAY_BLACK); +} + +template<> +void AppEnum::setUp() +{ + addItem(RimTensorResults::RESULT, "RESULT", "Result"); + addItem(RimTensorResults::CONSTANT, "CONSTANT", "Constant"); + + setDefault(RimTensorResults::RESULT); +} +} // namespace caf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::RimTensorResults() +{ + CAF_PDM_InitObject("Element Tensor Results", ":/CellResult.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&arrowColorLegendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + this->arrowColorLegendConfig = new RimRegularLegendConfig(); + arrowColorLegendConfig.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_resultFieldName, "ResultVariable", QString("ST"), "Value", "", "", ""); + m_resultFieldName.uiCapability()->setUiHidden(true); + + CAF_PDM_InitField(&m_resultFieldNameUiField, "ResultVariableUI", QString("ST"), "Value", "", "", ""); + m_resultFieldNameUiField.xmlCapability()->setIOWritable(false); + m_resultFieldNameUiField.xmlCapability()->setIOReadable(false); + + CAF_PDM_InitField(&m_showTensors, "ShowTensors", false, "", "", "", ""); + + CAF_PDM_InitField(&m_principal1, "Principal1", true, "Principal 1", "", "", ""); + CAF_PDM_InitField(&m_principal2, "Principal2", true, "Principal 2", "", "", ""); + CAF_PDM_InitField(&m_principal3, "Principal3", true, "Principal 3", "", "", ""); + + CAF_PDM_InitField(&m_threshold, "Threshold", 0.0f, "Threshold", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_vectorColor, "VectorColor", "Color", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_scaleMethod, "ScaleMethod", "Scale Method", "", "", ""); + CAF_PDM_InitField(&m_sizeScale, "SizeScale", 1.0f, "Size Scale", "", "", ""); + CAF_PDM_InitField(&m_rangeMode, + "RangeType", + RimRegularLegendConfig::RangeModeEnum(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS), + "Range Type", + "", + "Switches between automatic and user defined range", + ""); + + m_resultFieldNameUiField.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + m_resultFieldNameUiField.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::~RimTensorResults() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemResultAddress RimTensorResults::selectedTensorResult() const +{ + return RigFemResultAddress(resultPositionType(), m_resultFieldName().toStdString(), ""); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::setShowTensors(bool enableTensors) +{ + m_showTensors = enableTensors; + + updateConnectedEditors(); + updateUiIconFromState(enableTensors); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showTensors() const +{ + return m_showTensors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showPrincipal1() const +{ + return m_principal1(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showPrincipal2() const +{ + return m_principal2(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimTensorResults::showPrincipal3() const +{ + return m_principal3(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimTensorResults::threshold() const +{ + return m_threshold(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RimTensorResults::sizeScale() const +{ + return m_sizeScale(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::TensorColors RimTensorResults::vectorColors() const +{ + return m_vectorColor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimTensorResults::ScaleMethod RimTensorResults::scaleMethod() const +{ + return m_scaleMethod(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::mappingRange(double* min, double* max) const +{ + *min = cvf::UNDEFINED_DOUBLE; + *max = cvf::UNDEFINED_DOUBLE; + + if (scaleMethod() == RESULT) + { + Rim3dView* view = nullptr; + firstAncestorOrThisOfType(view); + + int currentTimeStep = view->currentTimeStep(); + + RimGeoMechView* geoMechView = dynamic_cast(view); + RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + if (!resultCollection) return; + + if (m_rangeMode == RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS) + { + resultCollection->minMaxScalarValuesOverAllTensorComponents(selectedTensorResult(), min, max); + } + else if (m_rangeMode == RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP) + { + resultCollection->minMaxScalarValuesOverAllTensorComponents(selectedTensorResult(), currentTimeStep, min, max); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigFemResultPosEnum RimTensorResults::resultPositionType() +{ + return RIG_INTEGRATION_POINT; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimTensorResults::resultFieldName() const +{ + return m_resultFieldName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimTensorResults::getResultMetaDataForUIFieldSetting() +{ + std::vector fieldNames; + fieldNames.push_back("SE"); + fieldNames.push_back("ST"); + fieldNames.push_back("E"); + + return fieldNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_resultFieldNameUiField) + { + m_resultFieldName = fieldNameFromUi(m_resultFieldNameUiField); + } + else if (changedField == &m_showTensors) + { + setShowTensors(m_showTensors); + } + + RimGeoMechView* view; + firstAncestorOrThisOfType(view); + view->loadDataAndUpdate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimTensorResults::objectToggleField() +{ + return &m_showTensors; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimTensorResults::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly) +{ + QList options; + *useOptionsOnly = true; + + if (fieldNeedingOptions == &m_resultFieldNameUiField) + { + std::vector fieldCompNames = getResultMetaDataForUIFieldSetting(); + + for (size_t oIdx = 0; oIdx < fieldCompNames.size(); ++oIdx) + { + options.push_back(caf::PdmOptionItemInfo(QString::fromStdString(fieldCompNames[oIdx]), + QString::fromStdString(fieldCompNames[oIdx]))); + } + } + else if (fieldNeedingOptions == &m_rangeMode) + { + options.push_back(caf::PdmOptionItemInfo(RimRegularLegendConfig::RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS), + RimRegularLegendConfig::AUTOMATIC_ALLTIMESTEPS)); + options.push_back( + caf::PdmOptionItemInfo(RimRegularLegendConfig::RangeModeEnum::uiText(RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP), + RimRegularLegendConfig::AUTOMATIC_CURRENT_TIMESTEP)); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_resultFieldNameUiField); + + caf::PdmUiGroup* visibilityGroup = uiOrdering.addNewGroup("Visibility"); + visibilityGroup->add(&m_principal1); + visibilityGroup->add(&m_principal2); + visibilityGroup->add(&m_principal3); + visibilityGroup->add(&m_threshold); + + caf::PdmUiGroup* vectorColorsGroup = uiOrdering.addNewGroup("Vector Colors"); + vectorColorsGroup->add(&m_vectorColor); + + caf::PdmUiGroup* vectorSizeGroup = uiOrdering.addNewGroup("Vector Size"); + vectorSizeGroup->add(&m_sizeScale); + vectorSizeGroup->add(&m_scaleMethod); + + if (m_scaleMethod == RESULT) + { + vectorSizeGroup->add(&m_rangeMode); + } + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::initAfterRead() +{ + m_resultFieldNameUiField = uiFieldName(m_resultFieldName()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) +{ + if (field == &m_resultFieldNameUiField) + { + caf::PdmUiListEditorAttribute* listEditAttr = dynamic_cast(attribute); + if (listEditAttr) + { + listEditAttr->m_heightHint = 50; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimTensorResults::uiFieldName(const QString& fieldName) +{ + if (fieldName == "NE") + { + return QString("E"); + } + + return fieldName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimTensorResults::fieldNameFromUi(const QString& uiFieldName) +{ + if (uiFieldName == "E") + { + return QString("NE"); + } + + return uiFieldName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTensorResults::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName) +{ + if (m_vectorColor() != RESULT_COLORS) + { + uiTreeOrdering.skipRemainingChildren(); + } +} diff --git a/ApplicationCode/ProjectDataModel/RimTensorResults.h b/ApplicationCode/ProjectDataModel/RimTensorResults.h new file mode 100644 index 0000000000..18701d39f1 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimTensorResults.h @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include "RigFemResultPosEnum.h" +#include "RimRegularLegendConfig.h" + +#include + +#include + +class RigFemResultAddress; +class RimRegularLegendConfig; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimTensorResults : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + enum TensorColors + { + WHITE_GRAY_BLACK, + ORANGE_BLUE_WHITE, + MAGENTA_BROWN_GRAY, + RESULT_COLORS + }; + + enum ScaleMethod + { + RESULT, + CONSTANT + }; + +public: + RimTensorResults(); + virtual ~RimTensorResults(); + + RigFemResultAddress selectedTensorResult() const; + void setShowTensors(bool enableTensors); + bool showTensors() const; + bool showPrincipal1() const; + bool showPrincipal2() const; + bool showPrincipal3() const; + float threshold() const; + float sizeScale() const; + TensorColors vectorColors() const; + ScaleMethod scaleMethod() const; + + void mappingRange(double *min, double* max) const; + + static RigFemResultPosEnum resultPositionType(); + QString resultFieldName() const; + static QString uiFieldName(const QString& fieldName); + + caf::PdmChildField arrowColorLegendConfig; + +private: + std::vector getResultMetaDataForUIFieldSetting(); + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; + + static QString fieldNameFromUi(const QString& uiFieldName); + +private: + caf::PdmField m_showTensors; + + caf::PdmField m_resultFieldName; + + caf::PdmField m_resultFieldNameUiField; + + caf::PdmField m_principal1; + caf::PdmField m_principal2; + caf::PdmField m_principal3; + + caf::PdmField m_threshold; + + caf::PdmField> m_vectorColor; + + caf::PdmField> m_scaleMethod; + caf::PdmField m_sizeScale; + caf::PdmField m_rangeMode; +}; diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp index ccc902c53f..bf12807d96 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.cpp @@ -20,8 +20,11 @@ #include "RimTernaryLegendConfig.h" #include "RiaApplication.h" +#include "RiaColorTables.h" +#include "RiaPreferences.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimViewLinker.h" #include "RivTernarySaturationOverlayItem.h" @@ -37,16 +40,6 @@ CAF_PDM_SOURCE_INIT(RimTernaryLegendConfig, "RimTernaryLegendConfig"); -namespace caf { - template<> - void AppEnum::setUp() - { - addItem(RimTernaryLegendConfig::AUTOMATIC_ALLTIMESTEPS, "AUTOMATIC_ALLTIMESTEPS", "Global range"); - addItem(RimTernaryLegendConfig::AUTOMATIC_CURRENT_TIMESTEP,"AUTOMATIC_CURRENT_TIMESTEP", "Local range"); - addItem(RimTernaryLegendConfig::USER_DEFINED, "USER_DEFINED_MAX_MIN", "User defined range"); - setDefault(RimTernaryLegendConfig::AUTOMATIC_ALLTIMESTEPS); - } -} //-------------------------------------------------------------------------------------------------- /// @@ -54,7 +47,8 @@ namespace caf { RimTernaryLegendConfig::RimTernaryLegendConfig() { CAF_PDM_InitObject("Ternary Legend Definition", ":/Legend.png", "", ""); - + CAF_PDM_InitField(&m_showLegend, "ShowTernaryLegend", true, "Show Ternary Legend", "", "", ""); + m_showLegend.uiCapability()->setUiHidden(true); CAF_PDM_InitField(&precision, "Precision", 2, "Significant digits", "", "The number of significant digits displayed in the legend numbers",""); CAF_PDM_InitField(&rangeMode, "RangeType", RangeModeEnum(USER_DEFINED), "Range type", "", "Switches between automatic and user defined range on the legend", ""); @@ -74,7 +68,6 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() ternaryRangeSummary.uiCapability()->setUiEditorTypeName(caf::PdmUiTextEditor::uiEditorTypeName()); ternaryRangeSummary.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::TOP); - CAF_PDM_InitField(&userDefinedMaxValueSoil, "UserDefinedMaxSoil", 1.0, "Max", "", "Min value of the legend", ""); CAF_PDM_InitField(&userDefinedMinValueSoil, "UserDefinedMinSoil", 0.0, "Min", "", "Max value of the legend", ""); @@ -89,7 +82,7 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() m_localAutoMin.resize(3, 0.0); m_localAutoMax.resize(3, 1.0); - m_scalarMapper = new RivTernaryScalarMapper(cvf::Color3f::GRAY); + m_scalarMapper = new RivTernaryScalarMapper(RiaColorTables::undefinedCellColor()); recreateLegend(); updateLegend(); @@ -100,7 +93,6 @@ RimTernaryLegendConfig::RimTernaryLegendConfig() //-------------------------------------------------------------------------------------------------- RimTernaryLegendConfig::~RimTernaryLegendConfig() { - } //-------------------------------------------------------------------------------------------------- @@ -145,7 +137,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed updateLabelText(); updateLegend(); - RimView* view = nullptr; + RimGridView* view = nullptr; this->firstAncestorOrThisOfType(view); if (view) @@ -157,6 +149,7 @@ void RimTernaryLegendConfig::fieldChangedByUi(const caf::PdmFieldHandle* changed } view->updateCurrentTimeStepAndRedraw(); + view->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } @@ -198,6 +191,10 @@ void RimTernaryLegendConfig::updateLegend() if (!m_legend.isNull()) { m_legend->setRangeText(soilRange, sgasRange, swatRange); + + RiaApplication* app = RiaApplication::instance(); + RiaPreferences* preferences = app->preferences(); + m_legend->enableBackground(preferences->showLegendBackground()); } } @@ -243,6 +240,7 @@ void RimTernaryLegendConfig::setUiValuesFromLegendConfig(const RimTernaryLegendC { QString serializedObjectString = otherLegendConfig->writeObjectToXmlString(); this->readObjectFromXmlString(serializedObjectString, caf::PdmDefaultObjectFactory::instance()); + this->updateLegend(); } //-------------------------------------------------------------------------------------------------- @@ -318,9 +316,17 @@ void RimTernaryLegendConfig::defineUiOrdering(QString uiConfigName, caf::PdmUiOr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivTernarySaturationOverlayItem* RimTernaryLegendConfig::legend() +bool RimTernaryLegendConfig::showLegend() const { - return m_legend.p(); + return m_showLegend; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimTernaryLegendConfig::setTitle(const QString& title) +{ + m_legend->setTitle(cvfqt::Utils::toString(title)); } //-------------------------------------------------------------------------------------------------- @@ -461,8 +467,31 @@ void RimTernaryLegendConfig::updateLabelText() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() +const RivTernaryScalarMapper* RimTernaryLegendConfig::scalarMapper() const { return m_scalarMapper.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const caf::TitledOverlayFrame* RimTernaryLegendConfig::titledOverlayFrame() const +{ + return m_legend.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::TitledOverlayFrame* RimTernaryLegendConfig::titledOverlayFrame() +{ + return m_legend.p(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimTernaryLegendConfig::objectToggleField() +{ + return &m_showLegend; +} diff --git a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h index 544a980f36..3d651b318d 100644 --- a/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h +++ b/ApplicationCode/ProjectDataModel/RimTernaryLegendConfig.h @@ -19,12 +19,12 @@ #pragma once +#include "RimLegendConfig.h" + #include "cvfBase.h" #include "cvfObject.h" #include "cafAppEnum.h" -#include "cafPdmField.h" -#include "cafPdmObject.h" class RimEclipseView; class RivTernarySaturationOverlayItem; @@ -35,13 +35,11 @@ namespace cvf class OverlayItem; } - - //================================================================================================== /// /// //================================================================================================== -class RimTernaryLegendConfig : public caf::PdmObject +class RimTernaryLegendConfig : public RimLegendConfig { CAF_PDM_HEADER_INIT; @@ -53,38 +51,38 @@ class RimTernaryLegendConfig : public caf::PdmObject TERNARY_SWAT_IDX }; - enum RangeModeType - { - AUTOMATIC_ALLTIMESTEPS, - AUTOMATIC_CURRENT_TIMESTEP, - USER_DEFINED - }; - typedef caf::AppEnum RangeModeEnum; - public: RimTernaryLegendConfig(); virtual ~RimTernaryLegendConfig(); - void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); - void ternaryRanges(double& soilLower, double& soilUpper, double& sgasLower, double& sgasUpper, double& swatLower, double& swatUpper) const; + void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); + void setAutomaticRanges(TernaryArrayIndex ternaryIndex, double globalMin, double globalMax, double localMin, double localMax); - void recreateLegend(); - - RivTernarySaturationOverlayItem* legend(); - RivTernaryScalarMapper* scalarMapper(); - -protected: - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering ); - virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute); + void recreateLegend(); + bool showLegend() const; + void setTitle(const QString& title); + const RivTernaryScalarMapper* scalarMapper() const; + const caf::TitledOverlayFrame* titledOverlayFrame() const override; + caf::TitledOverlayFrame* titledOverlayFrame() override; private: - void updateLegend(); - void updateLabelText(); - double roundToNumSignificantDigits(double value, double precision); - - friend class RimViewLinker; - void setUiValuesFromLegendConfig(const RimTernaryLegendConfig* otherLegendConfig); + void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + void defineEditorAttribute(const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute) override; + caf::PdmFieldHandle* objectToggleField() override; + + void updateLegend(); + void updateLabelText(); + double roundToNumSignificantDigits(double value, double precision); + + void ternaryRanges(double& soilLower, + double& soilUpper, + double& sgasLower, + double& sgasUpper, + double& swatLower, + double& swatUpper) const; private: caf::PdmField precision; @@ -102,6 +100,8 @@ class RimTernaryLegendConfig : public caf::PdmObject caf::PdmField applyFullRangeMinMax; caf::PdmField ternaryRangeSummary; + caf::PdmField m_showLegend; + std::vector m_globalAutoMax; std::vector m_globalAutoMin; std::vector m_localAutoMax; diff --git a/ApplicationCode/ProjectDataModel/RimViewController.cpp b/ApplicationCode/ProjectDataModel/RimViewController.cpp index fa28191803..9aed000ab7 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewController.cpp @@ -39,7 +39,7 @@ #include "RimGeoMechPropertyFilterCollection.h" #include "RimGeoMechView.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewLinker.h" #include "RimViewLinkerCollection.h" @@ -48,6 +48,7 @@ #include "cafPdmUiTreeOrdering.h" #include +#include "RimIntersectionCollection.h" CAF_PDM_SOURCE_INIT(RimViewController, "ViewController"); //-------------------------------------------------------------------------------------------------- @@ -101,7 +102,7 @@ QList RimViewController::calculateValueOptions(const caf if (fieldNeedingOptions == &m_managedView) { RimProject* proj = RiaApplication::instance()->project(); - std::vector views; + std::vector views; proj->allNotLinkedViews(views); // Add currently linked view to list @@ -114,7 +115,7 @@ QList RimViewController::calculateValueOptions(const caf this->firstAncestorOrThisOfType(viewLinker); CVF_ASSERT(viewLinker); - for (RimView* view : views) + for (RimGridView* view : views) { if (view != viewLinker->masterView()) { @@ -212,7 +213,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField else if (changedField == &m_managedView) { PdmObjectHandle* prevValue = oldValue.value >().rawPtr(); - RimView* previousManagedView = dynamic_cast(prevValue); + RimGridView* previousManagedView = dynamic_cast(prevValue); RimViewController::removeOverrides(previousManagedView); setManagedView(m_managedView()); @@ -232,7 +233,7 @@ void RimViewController::fieldChangedByUi(const caf::PdmFieldHandle* changedField //-------------------------------------------------------------------------------------------------- RimEclipseView* RimViewController::managedEclipseView() const { - RimView* rimView = m_managedView; + RimGridView* rimView = m_managedView; return dynamic_cast(rimView); } @@ -242,7 +243,7 @@ RimEclipseView* RimViewController::managedEclipseView() const //-------------------------------------------------------------------------------------------------- RimGeoMechView* RimViewController::managedGeoView() const { - RimView* rimView = m_managedView; + RimGridView* rimView = m_managedView; return dynamic_cast(rimView); } @@ -254,7 +255,7 @@ void RimViewController::updateOverrides() { RimViewLinker* viewLinker = ownerViewLinker(); - RimView* masterView = viewLinker->masterView(); + RimGridView* masterView = viewLinker->masterView(); CVF_ASSERT(masterView); @@ -265,8 +266,8 @@ void RimViewController::updateOverrides() if (isVisibleCellsOveridden()) { - if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL); - if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL); + if (manEclView) manEclView->setOverridePropertyFilterCollection(nullptr); + if (manGeoView) manGeoView->setOverridePropertyFilterCollection(nullptr); m_managedView->scheduleGeometryRegen(OVERRIDDEN_CELL_VISIBILITY); m_managedView->scheduleCreateDisplayModelAndRedraw(); } @@ -284,7 +285,7 @@ void RimViewController::updateOverrides() } else { - manEclView->setOverridePropertyFilterCollection(NULL); + manEclView->setOverridePropertyFilterCollection(nullptr); } } } @@ -300,13 +301,13 @@ void RimViewController::updateOverrides() } else { - manGeoView->setOverridePropertyFilterCollection(NULL); + manGeoView->setOverridePropertyFilterCollection(nullptr); } } } } - this->updateRangeFilterOverrides(NULL); + this->updateRangeFilterOverrides(nullptr); if (manGeoView) { @@ -343,17 +344,17 @@ void RimViewController::removeOverrides() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewController::removeOverrides(RimView* view) +void RimViewController::removeOverrides(RimGridView* view) { if (view) { RimEclipseView* manEclView = dynamic_cast(view); RimGeoMechView* manGeoView = dynamic_cast(view); - if (manEclView) manEclView->setOverridePropertyFilterCollection(NULL); - if (manGeoView) manGeoView->setOverridePropertyFilterCollection(NULL); + if (manEclView) manEclView->setOverridePropertyFilterCollection(nullptr); + if (manGeoView) manGeoView->setOverridePropertyFilterCollection(nullptr); - view->setOverrideRangeFilterCollection(NULL); + view->setOverrideRangeFilterCollection(nullptr); } } @@ -362,7 +363,7 @@ void RimViewController::removeOverrides(RimView* view) //-------------------------------------------------------------------------------------------------- void RimViewController::updateOptionSensitivity() { - RimView* mainView = nullptr; + RimGridView* mainView = nullptr; { RimViewLinker* linkedViews = nullptr; @@ -448,7 +449,7 @@ void RimViewController::updateOptionSensitivity() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimViewController::managedView() const +RimGridView* RimViewController::managedView() const { return m_managedView; } @@ -456,7 +457,7 @@ RimView* RimViewController::managedView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewController::setManagedView(RimView* view) +void RimViewController::setManagedView(RimGridView* view) { m_managedView = view; @@ -557,7 +558,7 @@ void RimViewController::updateLegendDefinitions() //-------------------------------------------------------------------------------------------------- RimViewLinker* RimViewController::ownerViewLinker() const { - RimViewLinker* viewLinker = NULL; + RimViewLinker* viewLinker = nullptr; this->firstAncestorOrThisOfType(viewLinker); return viewLinker; @@ -573,10 +574,10 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() RimGeoMechView* masterGeomechView = dynamic_cast(masterView()); RimGeoMechView* dependGeomechView = managedGeoView(); - RigMainGrid* masterEclGrid = NULL; - RigMainGrid* dependEclGrid = NULL; - RigFemPart* masterFemPart = NULL; - RigFemPart* dependFemPart = NULL; + RigMainGrid* masterEclGrid = nullptr; + RigMainGrid* dependEclGrid = nullptr; + RigFemPart* masterFemPart = nullptr; + RigFemPart* dependFemPart = nullptr; if (masterEclipseView) { @@ -589,15 +590,15 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() } if (masterGeomechView && masterGeomechView->geoMechCase()->geoMechData() - && masterGeomechView->geoMechCase()->geoMechData()->femParts()->partCount()) + && masterGeomechView->femParts()->partCount()) { - masterFemPart = masterGeomechView->geoMechCase()->geoMechData()->femParts()->part(0); + masterFemPart = masterGeomechView->femParts()->part(0); } if (dependGeomechView && dependGeomechView->geoMechCase()->geoMechData() - && dependGeomechView->geoMechCase()->geoMechData()->femParts()->partCount()) + && dependGeomechView->femParts()->partCount()) { - dependFemPart = dependGeomechView->geoMechCase()->geoMechData()->femParts()->part(0); + dependFemPart = dependGeomechView->femParts()->part(0); } // If we have the correct mapping already, return it. @@ -612,7 +613,7 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() } else { - m_caseToCaseCellMapper = NULL; + m_caseToCaseCellMapper = nullptr; } } @@ -644,7 +645,7 @@ const RigCaseToCaseCellMapper* RimViewController::cellMapper() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimViewController::masterView() const +RimGridView* RimViewController::masterView() const { return ownerViewLinker()->masterView(); } @@ -688,6 +689,11 @@ void RimViewController::scheduleCreateDisplayModelAndRedrawForDependentView() co this->managedView()->scheduleCreateDisplayModelAndRedraw(); } } + + if (this->isResultColorControlled() && this->managedView() ) + { + this->managedView()->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } } //-------------------------------------------------------------------------------------------------- @@ -833,7 +839,7 @@ bool RimViewController::isRangeFilterControlPossible() const if (eclipseView->eclipseCase()->reservoirData() && geomView->geoMechCase()->geoMechData()) { RigMainGrid* eclGrid = eclipseView->eclipseCase()->reservoirData()->mainGrid(); - RigFemPart* femPart = geomView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geomView->femParts()->part(0); if (eclGrid && femPart) { @@ -865,7 +871,7 @@ bool RimViewController::isRangeFilterMappingApliccable() const if (eclipseView->eclipseCase()->eclipseCaseData() && geomView->geoMechCase() && geomView->geoMechCase()->geoMechData()) { RigMainGrid* eclGrid = eclipseView->mainGrid(); - RigFemPart* femPart = geomView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* femPart = geomView->femParts()->part(0); if (eclGrid && femPart) { @@ -954,7 +960,7 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa if (!isRangeFiltersControlled()) { - m_managedView->setOverrideRangeFilterCollection(NULL); + m_managedView->setOverrideRangeFilterCollection(nullptr); return; } @@ -982,7 +988,7 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa if (eclipseMasterView->mainGrid()) { RigMainGrid* srcEclGrid = eclipseMasterView->mainGrid(); - RigFemPart* dstFemPart = depGeomView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* dstFemPart = depGeomView->femParts()->part(0); for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx) { RimCellRangeFilter* srcRFilter = sourceFilterCollection->rangeFilters[rfIdx]; @@ -996,7 +1002,7 @@ void RimViewController::updateRangeFilterOverrides(RimCellRangeFilter* changedRa { if (depEclView->mainGrid()) { - RigFemPart* srcFemPart = geoMasterView->geoMechCase()->geoMechData()->femParts()->part(0); + RigFemPart* srcFemPart = geoMasterView->femParts()->part(0); RigMainGrid* dstEclGrid = depEclView->mainGrid(); for (size_t rfIdx = 0; rfIdx < sourceFilterCollection->rangeFilters().size(); ++rfIdx) { @@ -1028,7 +1034,7 @@ void RimViewController::applyRangeFilterCollectionByUserChoice() bool restoreOriginal = askUserToRestoreOriginalRangeFilterCollection(m_managedView->name); if (restoreOriginal) { - m_managedView->setOverrideRangeFilterCollection(NULL); + m_managedView->setOverrideRangeFilterCollection(nullptr); } else { @@ -1041,7 +1047,7 @@ void RimViewController::applyRangeFilterCollectionByUserChoice() //-------------------------------------------------------------------------------------------------- bool RimViewController::askUserToRestoreOriginalRangeFilterCollection(const QString& viewName) { - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + RimGridView* activeView = RiaApplication::instance()->activeGridView(); QMessageBox msgBox(activeView->viewer()->layoutWidget()); msgBox.setIcon(QMessageBox::Question); diff --git a/ApplicationCode/ProjectDataModel/RimViewController.h b/ApplicationCode/ProjectDataModel/RimViewController.h index e8eda82175..01003cbb7e 100644 --- a/ApplicationCode/ProjectDataModel/RimViewController.h +++ b/ApplicationCode/ProjectDataModel/RimViewController.h @@ -28,7 +28,7 @@ #include "RivCellSetEnum.h" -class RimView; +class RimGridView; class RimEclipseView; class RimGeoMechView; class RimViewLinker; @@ -49,10 +49,10 @@ class RimViewController : public caf::PdmObject bool isActive() const; - RimView* managedView() const; - void setManagedView(RimView* view); + RimGridView* managedView() const; + void setManagedView(RimGridView* view); - RimView* masterView() const; + RimGridView* masterView() const; RimViewLinker* ownerViewLinker() const; const RigCaseToCaseCellMapper* cellMapper(); @@ -102,12 +102,12 @@ class RimViewController : public caf::PdmObject RimEclipseView* managedEclipseView() const; RimGeoMechView* managedGeoView() const; - static void removeOverrides(RimView* view); + static void removeOverrides(RimGridView* view); static bool askUserToRestoreOriginalRangeFilterCollection(const QString& viewName); private: caf::PdmField m_name; - caf::PdmPtrField m_managedView; + caf::PdmPtrField m_managedView; caf::PdmField m_isActive; caf::PdmField m_syncCamera; diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp index ae2cb4687a..25dc2d4126 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.cpp @@ -33,10 +33,11 @@ #include "RimGeoMechCellColors.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" -#include "RimLegendConfig.h" +#include "RimIntersectionCollection.h" +#include "RimRegularLegendConfig.h" #include "RimProject.h" #include "RimTernaryLegendConfig.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimViewController.h" #include "RimViewLinkerCollection.h" #include "RimViewManipulator.h" @@ -83,7 +84,7 @@ RimViewLinker::~RimViewLinker(void) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateTimeStep(RimView* sourceView, int timeStep) +void RimViewLinker::updateTimeStep(RimGridView* sourceView, int timeStep) { CVF_ASSERT(sourceView); @@ -125,7 +126,7 @@ void RimViewLinker::updateTimeStep(RimView* sourceView, int timeStep) //-------------------------------------------------------------------------------------------------- void RimViewLinker::updateCellResult() { - RimView* rimView = m_masterView; + Rim3dView* rimView = m_masterView; RimEclipseView* masterEclipseView = dynamic_cast(rimView); if (masterEclipseView && masterEclipseView->cellResult()) { @@ -137,7 +138,7 @@ void RimViewLinker::updateCellResult() if (viewLink->managedView()) { - RimView* rimView = viewLink->managedView(); + Rim3dView* rimView = viewLink->managedView(); RimEclipseView* eclipseView = dynamic_cast(rimView); if (eclipseView) { @@ -152,10 +153,10 @@ void RimViewLinker::updateCellResult() eclipseView->cellResult()->legendConfig()->updateLegend(); eclipseView->cellResult()->ternaryLegendConfig()->setUiValuesFromLegendConfig(masterEclipseView->cellResult()->ternaryLegendConfig()); - eclipseView->cellResult()->ternaryLegendConfig()->updateLegend(); } eclipseView->scheduleCreateDisplayModelAndRedraw(); + eclipseView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } eclipseView->cellResult()->updateIconState(); @@ -175,7 +176,7 @@ void RimViewLinker::updateCellResult() if (viewLink->managedView()) { - RimView* rimView = viewLink->managedView(); + Rim3dView* rimView = viewLink->managedView(); RimGeoMechView* geoView = dynamic_cast(rimView); if (geoView) { @@ -190,6 +191,7 @@ void RimViewLinker::updateCellResult() } geoView->scheduleCreateDisplayModelAndRedraw(); + geoView->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } geoView->cellResult()->updateIconState(); @@ -247,7 +249,7 @@ void RimViewLinker::removeOverrides() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::allViewsForCameraSync(const RimView* source, std::vector& views) const +void RimViewLinker::allViewsForCameraSync(const RimGridView* source, std::vector& views) const { if (!isActive()) return; @@ -283,13 +285,13 @@ void RimViewLinker::updateDependentViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimViewLinker::displayNameForView(RimView* view) +QString RimViewLinker::displayNameForView(RimGridView* view) { QString displayName = "None"; if (view) { - RimCase* rimCase = NULL; + RimCase* rimCase = nullptr; view->firstAncestorOrThisOfType(rimCase); if (rimCase) { @@ -303,7 +305,7 @@ QString RimViewLinker::displayNameForView(RimView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::setMasterView(RimView* view) +void RimViewLinker::setMasterView(RimGridView* view) { RimViewController* previousViewController = view->viewController(); @@ -311,7 +313,7 @@ void RimViewLinker::setMasterView(RimView* view) if (previousViewController) { delete previousViewController; - this->m_viewControllers.removeChildObject(NULL); + this->m_viewControllers.removeChildObject(nullptr); } this->removeOverrides(); @@ -324,7 +326,7 @@ void RimViewLinker::setMasterView(RimView* view) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RimViewLinker::masterView() const +RimGridView* RimViewLinker::masterView() const { return m_masterView; } @@ -332,7 +334,7 @@ RimView* RimViewLinker::masterView() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::allViews(std::vector& views) const +void RimViewLinker::allViews(std::vector& views) const { views.push_back(m_masterView()); @@ -356,7 +358,7 @@ void RimViewLinker::initAfterRead() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ) +void RimViewLinker::updateScaleZ(RimGridView* sourceView, double scaleZ) { if (!isActive()) return; @@ -371,7 +373,7 @@ void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ) } } - std::vector views; + std::vector views; allViewsForCameraSync(sourceView, views); // Make sure scale factors are identical @@ -386,7 +388,7 @@ void RimViewLinker::updateScaleZ(RimView* sourceView, double scaleZ) //-------------------------------------------------------------------------------------------------- bool RimViewLinker::isActive() const { - RimViewLinkerCollection* viewLinkerCollection = NULL; + RimViewLinkerCollection* viewLinkerCollection = nullptr; this->firstAncestorOrThisOfType(viewLinkerCollection); if (!viewLinkerCollection) @@ -454,7 +456,7 @@ void RimViewLinker::scheduleCreateDisplayModelAndRedrawForDependentViews() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView* view) +void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimGridView* view) { CVF_ASSERT(name && icon); @@ -462,7 +464,7 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView* if (view) { - RimCase* rimCase = NULL; + RimCase* rimCase = nullptr; view->firstAncestorOrThisOfType(rimCase); if (dynamic_cast(rimCase)) @@ -487,7 +489,7 @@ void RimViewLinker::findNameAndIconFromView(QString* name, QIcon* icon, RimView* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::Vec3d& domainCoord) +void RimViewLinker::updateCursorPosition(const RimGridView* sourceView, const cvf::Vec3d& domainCoord) { RimViewController* sourceViewLink = sourceView->viewController(); if (sourceViewLink && !sourceViewLink->showCursor()) @@ -495,10 +497,10 @@ void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::V return; } - std::vector viewsToUpdate; + std::vector viewsToUpdate; allViewsForCameraSync(sourceView, viewsToUpdate); - for (RimView* destinationView : viewsToUpdate) + for (Rim3dView* destinationView : viewsToUpdate) { if (destinationView == sourceView) continue; @@ -521,7 +523,7 @@ void RimViewLinker::updateCursorPosition(const RimView* sourceView, const cvf::V //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::updateCamera(RimView* sourceView) +void RimViewLinker::updateCamera(RimGridView* sourceView) { if (!sourceView->viewer()) return; @@ -536,7 +538,7 @@ void RimViewLinker::updateCamera(RimView* sourceView) } } - std::vector viewsToUpdate; + std::vector viewsToUpdate; allViewsForCameraSync(sourceView, viewsToUpdate); RimViewManipulator::applySourceViewCameraOnDestinationViews(sourceView, viewsToUpdate); @@ -545,7 +547,7 @@ void RimViewLinker::updateCamera(RimView* sourceView) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewLinker::addDependentView(RimView* view) +void RimViewLinker::addDependentView(RimGridView* view) { CVF_ASSERT(view && view != m_masterView); diff --git a/ApplicationCode/ProjectDataModel/RimViewLinker.h b/ApplicationCode/ProjectDataModel/RimViewLinker.h index 39df28f97b..acffd56229 100644 --- a/ApplicationCode/ProjectDataModel/RimViewLinker.h +++ b/ApplicationCode/ProjectDataModel/RimViewLinker.h @@ -36,7 +36,7 @@ namespace cvf class RimViewController; class RiuViewer; -class RimView; +class RimGridView; class RimCellRangeFilter; //================================================================================================== @@ -53,18 +53,18 @@ class RimViewLinker : public caf::PdmObject bool isActive() const; - void setMasterView(RimView* view); - RimView* masterView() const; + void setMasterView(RimGridView* view); + RimGridView* masterView() const; - void addDependentView(RimView* view); + void addDependentView(RimGridView* view); void updateDependentViews(); void removeViewController(RimViewController* viewController); void updateOverrides(); - void updateCamera(RimView* sourceView); - void updateTimeStep(RimView* sourceView, int timeStep); - void updateScaleZ(RimView* sourceView, double scaleZ); + void updateCamera(RimGridView* sourceView); + void updateTimeStep(RimGridView* sourceView, int timeStep); + void updateScaleZ(RimGridView* sourceView, double scaleZ); void updateCellResult(); @@ -74,32 +74,32 @@ class RimViewLinker : public caf::PdmObject void scheduleGeometryRegenForDepViews(RivCellSetEnum geometryType); void scheduleCreateDisplayModelAndRedrawForDependentViews(); - void allViews(std::vector& views) const; + void allViews(std::vector& views) const; void updateUiNameAndIcon(); void addViewControllers(caf::PdmUiTreeOrdering& uiTreeOrdering) const; static void applyIconEnabledState(caf::PdmObject* obj, const QIcon& icon, bool disable); - static void findNameAndIconFromView(QString* name, QIcon* icon, RimView* view); + static void findNameAndIconFromView(QString* name, QIcon* icon, RimGridView* view); - void updateCursorPosition(const RimView* sourceView, const cvf::Vec3d& domainCoord); + void updateCursorPosition(const RimGridView* sourceView, const cvf::Vec3d& domainCoord); public: - static QString displayNameForView(RimView* view); + static QString displayNameForView(RimGridView* view); protected: virtual caf::PdmFieldHandle* userDescriptionField() { return &m_name; } virtual void initAfterRead(); private: - void allViewsForCameraSync(const RimView* source, std::vector& views) const; + void allViewsForCameraSync(const RimGridView* source, std::vector& views) const; void removeOverrides(); private: caf::PdmChildArrayField m_viewControllers; - caf::PdmPtrField m_masterView; + caf::PdmPtrField m_masterView; caf::PdmField m_name; QIcon m_originalIcon; }; diff --git a/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp b/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp index ac8712139c..7cd14eda25 100644 --- a/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewManipulator.cpp @@ -21,7 +21,7 @@ #include "RigMainGrid.h" #include "RimEclipseView.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimCase.h" #include "RiuViewer.h" @@ -35,7 +35,7 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimViewManipulator::applySourceViewCameraOnDestinationViews(RimView* sourceView, std::vector& destinationViews) +void RimViewManipulator::applySourceViewCameraOnDestinationViews(RimGridView* sourceView, std::vector& destinationViews) { bool setPointOfInterest = false; cvf::Vec3d sourceCamUp; @@ -72,7 +72,7 @@ void RimViewManipulator::applySourceViewCameraOnDestinationViews(RimView* source sourceSceneBB.transform(trans); } - for (RimView* destinationView : destinationViews) + for (RimGridView* destinationView : destinationViews) { if (!destinationView) continue; diff --git a/ApplicationCode/ProjectDataModel/RimViewManipulator.h b/ApplicationCode/ProjectDataModel/RimViewManipulator.h index 0c6ee4026e..c474f58ae6 100644 --- a/ApplicationCode/ProjectDataModel/RimViewManipulator.h +++ b/ApplicationCode/ProjectDataModel/RimViewManipulator.h @@ -24,12 +24,12 @@ namespace cvf { class BoundingBox; } -class RimView; +class RimGridView; class RimViewManipulator { public: - static void applySourceViewCameraOnDestinationViews(RimView* sourceView, std::vector& destinationViews); + static void applySourceViewCameraOnDestinationViews(RimGridView* sourceView, std::vector& destinationViews); private: static bool isBoundingBoxesOverlappingOrClose(const cvf::BoundingBox& sourceBB, const cvf::BoundingBox& destBB); diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp index c9d7bf5d03..b0e995cee3 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.cpp +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.cpp @@ -86,7 +86,7 @@ void RimViewWindow::updateMdiWindowVisibility() { if (viewWidget()) { - if (m_showWindow) + if (isWindowVisible()) { viewWidget()->show(); } @@ -149,7 +149,7 @@ void RimViewWindow::fieldChangedByUi(const caf::PdmFieldHandle* changedField, co { if ( changedField == &m_showWindow ) { - if (m_showWindow) + if (isWindowVisible()) { onLoadDataAndUpdate(); } @@ -198,7 +198,7 @@ void RimViewWindow::setAsMdiWindow(int mainWindowID) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#include "RimView.h" +#include "Rim3dView.h" void RimViewWindow::initAfterRead() { @@ -207,7 +207,7 @@ void RimViewWindow::initAfterRead() RimMdiWindowGeometry wg; int mainWindowID = -1; - if (dynamic_cast (this)) + if (dynamic_cast (this)) mainWindowID = 0; else mainWindowID = 1; diff --git a/ApplicationCode/ProjectDataModel/RimViewWindow.h b/ApplicationCode/ProjectDataModel/RimViewWindow.h index f869994792..3583aea248 100644 --- a/ApplicationCode/ProjectDataModel/RimViewWindow.h +++ b/ApplicationCode/ProjectDataModel/RimViewWindow.h @@ -49,6 +49,7 @@ class RimViewWindow : public caf::PdmObject void loadDataAndUpdate(); void handleMdiWindowClosed(); + void updateMdiWindowVisibility(); void setAs3DViewMdiWindow() { setAsMdiWindow(0); } void setAsPlotMdiWindow() { setAsMdiWindow(1); } @@ -64,7 +65,6 @@ class RimViewWindow : public caf::PdmObject protected: void removeMdiWindowFromMdiArea(); - void updateMdiWindowVisibility(); ///////// Interface for the Window controller friend class RimMdiWindowController; @@ -74,6 +74,7 @@ class RimViewWindow : public caf::PdmObject virtual void updateMdiWindowTitle(); // Has real default implementation virtual void deleteViewWidget() = 0; virtual void onLoadDataAndUpdate() = 0; + virtual bool isWindowVisible() { return m_showWindow();} // Virtual To allow special visibility control ////////// // Derived classes are not supposed to override this function. The intention is to always use m_showWindow diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp new file mode 100644 index 0000000000..1f5255a0c9 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.cpp @@ -0,0 +1,146 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimVirtualPerforationResults.h" + +#include "RimEclipseCase.h" +#include "RimEclipseView.h" +#include "RimRegularLegendConfig.h" + +CAF_PDM_SOURCE_INIT(RimVirtualPerforationResults, "RimVirtualPerforationResults"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVirtualPerforationResults::RimVirtualPerforationResults() +{ + // clang-format off + + QString connectionFactorUiName = "Well Connection Factors"; + + CAF_PDM_InitObject(connectionFactorUiName, ":/WellCF16x16.png", "", ""); + + CAF_PDM_InitField(&m_isActive, "ShowConnectionFactors", false, "", "", "", ""); + CAF_PDM_InitField(&m_showClosedConnections, "ShowClosedConnections", true, "Show On Closed Connections", "", "", ""); + CAF_PDM_InitField(&m_geometryScaleFactor, "GeometryScaleFactor", 2.0, "Geometry Scale Factor", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendDefinition", "Legend Definition", "", "", ""); + m_legendConfig.uiCapability()->setUiHidden(true); + + m_legendConfig = new RimRegularLegendConfig(); + m_legendConfig->setTitle(connectionFactorUiName); + + // clang-format on +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimVirtualPerforationResults::~RimVirtualPerforationResults() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimVirtualPerforationResults::showConnectionFactors() const +{ + return m_isActive(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimVirtualPerforationResults::showConnectionFactorsOnClosedConnections() const +{ + return m_showClosedConnections(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimVirtualPerforationResults::geometryScaleFactor() const +{ + return m_geometryScaleFactor(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig* RimVirtualPerforationResults::legendConfig() const +{ + return m_legendConfig(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::loadData() +{ + RimEclipseCase* eclipseCase = nullptr; + this->firstAncestorOrThisOfType(eclipseCase); + if (eclipseCase) + { + eclipseCase->computeAndGetVirtualPerforationTransmissibilities(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_isActive) + { + updateUiIconFromToggleField(); + + loadData(); + } + + RimEclipseView* eclView = nullptr; + this->firstAncestorOrThisOfTypeAsserted(eclView); + + eclView->scheduleCreateDisplayModelAndRedraw(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimVirtualPerforationResults::objectToggleField() +{ + return &m_isActive; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + uiOrdering.add(&m_geometryScaleFactor); + uiOrdering.add(&m_showClosedConnections); + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimVirtualPerforationResults::initAfterRead() +{ + updateUiIconFromToggleField(); +} diff --git a/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h new file mode 100644 index 0000000000..6f1b6abeb9 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimVirtualPerforationResults.h @@ -0,0 +1,59 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include + +class RimRegularLegendConfig; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimVirtualPerforationResults : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimVirtualPerforationResults(); + virtual ~RimVirtualPerforationResults(); + + bool showConnectionFactors() const; + bool showConnectionFactorsOnClosedConnections() const; + double geometryScaleFactor() const; + RimRegularLegendConfig* legendConfig() const; + void loadData(); + +private: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual caf::PdmFieldHandle* objectToggleField() override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void initAfterRead() override; + +private: + caf::PdmField m_isActive; + caf::PdmField m_showClosedConnections; + caf::PdmField m_geometryScaleFactor; + + caf::PdmChildField m_legendConfig; +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp new file mode 100644 index 0000000000..1cd7555830 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.cpp @@ -0,0 +1,271 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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. +// + m_addWellName {m_fieldValue=true m_defaultFieldValue=true } caf::PdmField + +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimProject.h" +#include "RimWellLogCurveNameConfig.h" +#include "Rim3dWellLogCurve.h" + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimCurveNameConfig, "RimCurveNameConfig"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCurveNameConfig::RimCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder /*= nullptr*/) + : m_configHolder(configHolder) +{ + CAF_PDM_InitObject("Curve Name Generator", "", "", ""); + + CAF_PDM_InitField(&m_isUsingAutoName, "IsUsingAutoName", true, "Generate Name Automatically", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_customName, "CustomCurveName", "Curve Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_autoName, "AutoCurveName", "Curve Name", "", "", ""); + m_autoName.registerGetMethod(this, &RimCurveNameConfig::autoName); + m_autoName.registerSetMethod(this, &RimCurveNameConfig::setCustomName); + m_autoName.xmlCapability()->disableIO(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimCurveNameConfig::~RimCurveNameConfig() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimCurveNameConfig::isUsingAutoName() const +{ + return m_isUsingAutoName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimCurveNameConfig::nameField() +{ + if (isUsingAutoName()) + { + return &m_autoName; + } + return &m_customName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCurveNameConfig::name() const +{ + if (isUsingAutoName()) + { + return m_autoName(); + } + return m_customName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmUiGroup* RimCurveNameConfig::createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name"); + nameGroup->add(&m_isUsingAutoName); + return nameGroup; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveNameConfig::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_customName) + { + m_isUsingAutoName = false; + } + + if (changedField == &m_isUsingAutoName && !isUsingAutoName()) + { + m_customName = m_configHolder->createCurveAutoName(); + } + + updateAllSettings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimCurveNameConfig::autoName() const +{ + return m_configHolder->createCurveAutoName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveNameConfig::setCustomName(const QString& name) +{ + m_isUsingAutoName = false; + m_customName = name; + updateAllSettings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCurveNameConfig::updateAllSettings() +{ + m_isUsingAutoName.uiCapability()->updateConnectedEditors(); + m_autoName.uiCapability()->updateConnectedEditors(); + m_customName.uiCapability()->updateConnectedEditors(); + + Rim3dWellLogCurve* curve; + this->firstAncestorOrThisOfTypeAsserted(curve); + curve->updateConnectedEditors(); + +} + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimWellLogExtractionCurveNameConfig, "RimWellLogExtractionCurveNameConfig"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogExtractionCurveNameConfig::RimWellLogExtractionCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder) + : RimCurveNameConfig(configHolder) +{ + CAF_PDM_InitObject("Well Log Extraction Curve Name Generator", "", "", ""); + + CAF_PDM_InitField(&m_addCaseName, "AddCaseName", false, "Add Case Name To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addProperty, "AddProperty", true, "Add Property Type To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addWellName, "AddWellName", true, "Add Well Name To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addTimestep, "AddTimeStep", true, "Add Time Step To Auto Name", "", "", ""); + CAF_PDM_InitField(&m_addDate, "AddDate", true, "Add Date To Auto Name", "", "", ""); + + m_customName = "Extraction Curve"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmUiGroup* RimWellLogExtractionCurveNameConfig::createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + caf::PdmUiGroup* nameGroup = RimCurveNameConfig::createUiGroup(uiConfigName, uiOrdering); + nameGroup->add(&m_addCaseName); + nameGroup->add(&m_addProperty); + nameGroup->add(&m_addWellName); + nameGroup->add(&m_addTimestep); + nameGroup->add(&m_addDate); + return nameGroup; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addCaseName() const +{ + return m_addCaseName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addProperty() const +{ + return m_addProperty(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addWellName() const +{ + return m_addWellName(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addTimeStep() const +{ + return m_addTimestep(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWellLogExtractionCurveNameConfig::addDate() const +{ + return m_addDate(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogExtractionCurveNameConfig::updateAllSettings() +{ + m_addCaseName.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addProperty.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addWellName.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addTimestep.uiCapability()->setUiReadOnly(!isUsingAutoName()); + m_addDate.uiCapability()->setUiReadOnly(!isUsingAutoName()); + + RimCurveNameConfig::updateAllSettings(); +} + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimWellLogFileCurveNameConfig, "RimWellLogFileCurveNameConfig"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogFileCurveNameConfig::RimWellLogFileCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder) + : RimCurveNameConfig(configHolder) +{ + CAF_PDM_InitObject("Well Log File Curve Name Generator", "", "", ""); + m_customName = "Las Curve"; +} + +//================================================================================================== +/// +/// +//================================================================================================== + +CAF_PDM_SOURCE_INIT(RimWellLogRftCurveNameConfig, "RimWellLogRftCurveNameConfig"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWellLogRftCurveNameConfig::RimWellLogRftCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder) + : RimCurveNameConfig(configHolder) +{ + CAF_PDM_InitObject("Well Log Rft Curve Name Generator", "", "", ""); + m_customName = "Rft Curve"; +} \ No newline at end of file diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h new file mode 100644 index 0000000000..0ad17339e4 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveNameConfig.h @@ -0,0 +1,115 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2015- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCurveNameConfigHolderInterface +{ +public: + virtual QString createCurveAutoName() const = 0; +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimCurveNameConfig : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); + virtual ~RimCurveNameConfig(); + bool isUsingAutoName() const; + caf::PdmFieldHandle* nameField(); + QString name() const; + virtual caf::PdmUiGroup* createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); + +protected: + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + QString autoName() const; + void setCustomName(const QString& name); + virtual void updateAllSettings(); +protected: + caf::PdmField m_isUsingAutoName; + caf::PdmField m_customName; + caf::PdmProxyValueField m_autoName; + + const RimCurveNameConfigHolderInterface* m_configHolder; +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogExtractionCurveNameConfig : public RimCurveNameConfig +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogExtractionCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); + virtual caf::PdmUiGroup* createUiGroup(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + + bool addCaseName() const; + bool addProperty() const; + bool addWellName() const; + bool addTimeStep() const; + bool addDate() const; + +protected: + virtual void updateAllSettings(); + +private: + caf::PdmField m_addCaseName; + caf::PdmField m_addProperty; + caf::PdmField m_addWellName; + caf::PdmField m_addTimestep; + caf::PdmField m_addDate; +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogFileCurveNameConfig : public RimCurveNameConfig +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogFileCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); +}; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimWellLogRftCurveNameConfig : public RimCurveNameConfig +{ + CAF_PDM_HEADER_INIT; + +public: + RimWellLogRftCurveNameConfig(const RimCurveNameConfigHolderInterface* configHolder = nullptr); +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp index d67e58d620..d53adb88dc 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.cpp @@ -183,9 +183,9 @@ RimCase* RimWellLogExtractionCurve::rimCase() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellLogExtractionCurve::setPropertiesFromView(RimView* view) +void RimWellLogExtractionCurve::setPropertiesFromView(Rim3dView* view) { - m_case = view ? view->ownerCase() : NULL; + m_case = view ? view->ownerCase() : nullptr; RimGeoMechCase* geomCase = dynamic_cast(m_case.value()); RimEclipseCase* eclipseCase = dynamic_cast(m_case.value()); @@ -657,7 +657,7 @@ void RimWellLogExtractionCurve::setLogScaleFromSelectedResult() if (resVar.toUpper().contains("PERM")) { - RimWellLogTrack* track = NULL; + RimWellLogTrack* track = nullptr; this->firstAncestorOrThisOfType(track); if (track) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h index 27578ebe5a..62f0622d1f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogExtractionCurve.h @@ -28,7 +28,7 @@ class RigWellPath; class RimCase; class RimEclipseResultDefinition; class RimGeoMechResultDefinition; -class RimView; +class Rim3dView; class RimWellPath; //================================================================================================== @@ -52,7 +52,7 @@ class RimWellLogExtractionCurve : public RimWellLogCurve void setCase(RimCase* rimCase); RimCase* rimCase() const; - void setPropertiesFromView(RimView* view); + void setPropertiesFromView(Rim3dView* view); virtual QString wellName() const; virtual QString wellLogChannelName() const; @@ -68,14 +68,14 @@ class RimWellLogExtractionCurve : public RimWellLogCurve void setEclipseResultVariable(const QString& resVarname); protected: - virtual QString createCurveAutoName(); - virtual void onLoadDataAndUpdate(bool updateParentPlot); - - virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); - virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering); - virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = ""); - virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly); - virtual void initAfterRead(); + virtual QString createCurveAutoName() override; + virtual void onLoadDataAndUpdate(bool updateParentPlot) override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool * useOptionsOnly) override; + virtual void initAfterRead() override; private: void setLogScaleFromSelectedResult(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp index 5dcb6f5049..646f975e61 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFile.cpp @@ -29,7 +29,7 @@ #include "RigWellLogFile.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "cafPdmUiDateEditor.h" @@ -89,7 +89,7 @@ RimWellLogFile::RimWellLogFile() m_invalidDateMessage.uiCapability()->setUiReadOnly(true); m_invalidDateMessage.xmlCapability()->disableIO(); - m_wellLogDataFile = NULL; + m_wellLogDataFile = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -107,7 +107,7 @@ RimWellLogFile* RimWellLogFile::readWellLogFile(const QString& logFilePath) { QFileInfo fi(logFilePath); - RimWellLogFile* wellLogFile = NULL; + RimWellLogFile* wellLogFile = nullptr; if (fi.suffix().toUpper().compare("LAS") == 0) { @@ -124,12 +124,12 @@ RimWellLogFile* RimWellLogFile::readWellLogFile(const QString& logFilePath) displayMessage += errorMessage; } - QMessageBox::warning(RiuMainWindow::instance(), - "File open error", - displayMessage); + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), + "File open error", + displayMessage); delete wellLogFile; - wellLogFile = NULL; + wellLogFile = nullptr; } } @@ -158,7 +158,7 @@ bool RimWellLogFile::readFile(QString* errorMessage) if (!m_wellLogDataFile->open(m_fileName, errorMessage)) { - m_wellLogDataFile = NULL; + m_wellLogDataFile = nullptr; return false; } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp index e77b2dcdb5..1864756ee3 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogFileCurve.cpp @@ -332,6 +332,8 @@ QList RimWellLogFileCurve::calculateValueOptions(const c //-------------------------------------------------------------------------------------------------- void RimWellLogFileCurve::initAfterRead() { + if (!m_wellPath) return; + if (m_wellPath->wellLogFiles().size() == 1) { m_wellLogFile = m_wellPath->wellLogFiles().front(); @@ -420,5 +422,10 @@ RimWellLogFile* RimWellLogFileCurve::wellLogFile() const //-------------------------------------------------------------------------------------------------- QString RimWellLogFileCurve::wellName() const { - return m_wellPath->name(); + if (m_wellPath) + { + return m_wellPath->name(); + } + + return QString(""); } diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp index 9be63af1f9..d75f5c9b9f 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlot.cpp @@ -29,7 +29,7 @@ #include "RimWellRftPlot.h" #include "RimWellPltPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuWellLogPlot.h" #include "RiuWellLogTrack.h" @@ -65,7 +65,7 @@ RimWellLogPlot::RimWellLogPlot() { CAF_PDM_InitObject("Well Log Plot", ":/WellLogPlot16x16.png", "", ""); - m_viewer = NULL; + m_viewer = nullptr; CAF_PDM_InitField(&m_userName, "PlotDescription", QString("Well Log Plot"),"Name", "", "", ""); @@ -562,10 +562,9 @@ void RimWellLogPlot::uiOrderingForVisibleDepthRange(caf::PdmUiOrdering& uiOrderi //-------------------------------------------------------------------------------------------------- void RimWellLogPlot::uiOrderingForPlot(caf::PdmUiOrdering& uiOrdering) { - RimWellRftPlot* rftp; - firstAncestorOrThisOfType(rftp); + RimWellRftPlot* rftp = rftPlot(); - if (!rftp) + if (!(rftp || pltPlot())) { uiOrdering.add(&m_depthType); } @@ -883,6 +882,7 @@ void RimWellLogPlot::updateDisabledDepthTypes() else if (isPltPlotChild()) { m_disabledDepthTypes.insert(TRUE_VERTICAL_DEPTH); + m_disabledDepthTypes.insert(PSEUDO_LENGTH); m_disabledDepthTypes.insert(CONNECTION_NUMBER); } else diff --git a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp index b1f0ac84d4..f89bf09c5a 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogPlotCollection.cpp @@ -87,7 +87,7 @@ RigEclipseWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimW { if (!(wellPath && eclCase && wellPath->wellPathGeometry() && eclCase->eclipseCaseData())) { - return NULL; + return nullptr; } RigEclipseCaseData* eclCaseData = eclCase->eclipseCaseData(); @@ -114,7 +114,7 @@ RigGeoMechWellLogExtractor* RimWellLogPlotCollection::findOrCreateExtractor(RimW { if (!(wellPath && geomCase && wellPath->wellPathGeometry() && geomCase->geoMechData())) { - return NULL; + return nullptr; } RigGeoMechCaseData* geomCaseData = geomCase->geoMechData(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp index aafbeffed8..d3c8bcbde5 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.cpp @@ -59,6 +59,7 @@ #include "qwt_scale_engine.h" #include "RiaSimWellBranchTools.h" +#include "RiaExtractionTools.h" #define RI_LOGPLOTTRACK_MINX_DEFAULT -10.0 #define RI_LOGPLOTTRACK_MAXX_DEFAULT 100.0 @@ -1040,26 +1041,6 @@ RigEclipseWellLogExtractor* RimWellLogTrack::createSimWellExtractor(RimWellLogPl eclipseCase->eclipseCaseData())); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigEclipseWellLogExtractor* RimWellLogTrack::createWellPathExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath) -{ - if (!wellLogCollection) return nullptr; - - RimEclipseCase* eclipseCase = dynamic_cast(rimCase); - return (wellLogCollection->findOrCreateExtractor(wellPath, eclipseCase)); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RigGeoMechWellLogExtractor* RimWellLogTrack::createGeoMechExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath) -{ - RimGeoMechCase* geomCase = dynamic_cast(rimCase); - return (wellLogCollection->findOrCreateExtractor(wellPath, geomCase)); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1252,9 +1233,8 @@ void RimWellLogTrack::updateFormationNamesOnPlot() } else { - eclWellLogExtractor = RimWellLogTrack::createWellPathExtractor(wellLogCollection, - m_formationCase, - m_formationWellPathForSourceCase); + eclWellLogExtractor = RiaExtractionTools::wellLogExtractorEclipseCase(m_formationWellPathForSourceCase, + dynamic_cast(m_formationCase())); } if (eclWellLogExtractor) @@ -1271,7 +1251,8 @@ void RimWellLogTrack::updateFormationNamesOnPlot() } else { - geoMechWellLogExtractor = RimWellLogTrack::createGeoMechExtractor(wellLogCollection, m_formationCase, m_formationWellPathForSourceCase); + geoMechWellLogExtractor = RiaExtractionTools::wellLogExtractorGeoMechCase(m_formationWellPathForSourceCase, + dynamic_cast(m_formationCase())); if (!geoMechWellLogExtractor) return; std::string activeFormationNamesResultName = RiaDefines::activeFormationNamesResultName().toStdString(); diff --git a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h index 500c746932..c6a7b70729 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogTrack.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogTrack.h @@ -134,8 +134,6 @@ class RimWellLogTrack : public caf::PdmObject static void simWellOptionItems(QList* options, RimCase* eclCase); static RigEclipseWellLogExtractor* createSimWellExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, const QString& simWellName, int branchIndex, bool useBranchDetection); - static RigEclipseWellLogExtractor* createWellPathExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath); - static RigGeoMechWellLogExtractor* createGeoMechExtractor(RimWellLogPlotCollection* wellLogCollection, RimCase* rimCase, RimWellPath* wellPath); static CurveSamplingPointData curveSamplingPointData(RigEclipseWellLogExtractor* extractor, RigResultAccessor* resultAccessor); static CurveSamplingPointData curveSamplingPointData(RigGeoMechWellLogExtractor* extractor, const RigFemResultAddress& resultAddress); diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.cpp b/ApplicationCode/ProjectDataModel/RimWellPath.cpp index 6c703b76b2..87ca37e852 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPath.cpp @@ -29,6 +29,8 @@ #include "RigWellPath.h" +#include "Rim3dWellLogCurve.h" +#include "Rim3dWellLogCurveCollection.h" #include "RimFishbonesMultipleSubs.h" #include "RimMainPlotCollection.h" #include "RimProject.h" @@ -42,8 +44,6 @@ #include "RiuMainWindow.h" -#include "RivWellPathPartMgr.h" - #include "cafPdmUiTreeOrdering.h" #include "cafUtils.h" @@ -130,6 +130,10 @@ RimWellPath::RimWellPath() CAF_PDM_InitFieldNoDefault(&m_wellLogFiles, "WellLogFiles", "Well Log Files", "", "", ""); m_wellLogFiles.uiCapability()->setUiTreeHidden(true); + CAF_PDM_InitFieldNoDefault(&m_3dWellLogCurves, "CollectionOf3dWellLogCurves", "3D Track", "", "", ""); + m_3dWellLogCurves = new Rim3dWellLogCurveCollection; + m_3dWellLogCurves.uiCapability()->setUiTreeHidden(true); + CAF_PDM_InitField(&m_formationKeyInFile, "WellPathFormationKeyInFile", QString(""), "Key in File", "", "", ""); m_formationKeyInFile.uiCapability()->setUiReadOnly(true); @@ -195,6 +199,23 @@ void RimWellPath::setSurveyType(QString surveyType) wellPathColor = cvf::Color3f(0.0f, 0.333f, 0.999f); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWellPath::wellPathRadius(double characteristicCellSize) const +{ + double radius = characteristicCellSize * wellPathRadiusScaleFactor(); + + RimWellPathCollection* coll = nullptr; + this->firstAncestorOrThisOfType(coll); + if (coll) + { + radius *= coll->wellPathRadiusScaleFactor(); + } + + return radius; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -246,26 +267,22 @@ const RimWellPathCompletions* RimWellPath::completions() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* RimWellPath::fractureCollection() { CVF_ASSERT(m_completions); return m_completions->fractureCollection(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES const RimWellPathFractureCollection * RimWellPath::fractureCollection() const { CVF_ASSERT(m_completions); return m_completions->fractureCollection(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -283,21 +300,6 @@ const RigWellPath* RimWellPath::wellPathGeometry() const return m_wellPath.p(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RivWellPathPartMgr* RimWellPath::partMgr() -{ - if (m_wellPathPartMgr.isNull()) - { - RimWellPathCollection* wpColl; - this->firstAncestorOrThisOfType(wpColl); - if (wpColl) m_wellPathPartMgr = new RivWellPathPartMgr(this); - } - - return m_wellPathPartMgr.p(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -515,6 +517,11 @@ void RimWellPath::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, Q uiTreeOrdering.add(&m_completions); } + if (m_3dWellLogCurves->has3dWellLogCurves()) + { + uiTreeOrdering.add(&m_3dWellLogCurves); + } + uiTreeOrdering.skipRemainingChildren(true); } @@ -794,6 +801,22 @@ const RigWellPathFormations* RimWellPath::formationsGeometry() const return m_wellPathFormations.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellPath::add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve) +{ + m_3dWellLogCurves->add3dWellLogCurve(rim3dWellLogCurve); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Rim3dWellLogCurveCollection* RimWellPath::rim3dWellLogCurveCollection() const +{ + return m_3dWellLogCurves(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/RimWellPath.h b/ApplicationCode/ProjectDataModel/RimWellPath.h index e858141232..3cc8721ed1 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPath.h +++ b/ApplicationCode/ProjectDataModel/RimWellPath.h @@ -22,6 +22,8 @@ #include "RiaEclipseUnitTools.h" +#include "Rim3dWellLogCurve.h" + #include "cafPdmField.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" @@ -41,17 +43,16 @@ class RifWellPathFormationsImporter; class RigWellPath; class RimProject; class RimWellLogFile; +class RimFractureTemplateCollection; class RimFishboneWellPathCollection; -class RivWellPathPartMgr; class RimFishbonesCollection; class RimPerforationCollection; class RimWellPathCompletions; class RigWellPathFormations; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES class RimWellPathFractureCollection; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES +class Rim3dWellLogCurveCollection; //================================================================================================== /// @@ -78,6 +79,9 @@ class RimWellPath : public caf::PdmObject bool hasFormations() const; const RigWellPathFormations* formationsGeometry() const; + void add3dWellLogCurve(Rim3dWellLogCurve* rim3dWellLogCurve); + Rim3dWellLogCurveCollection* rim3dWellLogCurveCollection() const; + virtual caf::PdmFieldHandle* userDescriptionField() override; virtual caf::PdmFieldHandle* objectToggleField() override; @@ -100,6 +104,9 @@ class RimWellPath : public caf::PdmObject caf::PdmField showWellPath; caf::PdmField wellPathColor; + + double wellPathRadius(double characteristicCellSize) const; + caf::PdmField wellPathRadiusScaleFactor; RimFishbonesCollection* fishbonesCollection(); @@ -108,16 +115,12 @@ class RimWellPath : public caf::PdmObject const RimPerforationCollection* perforationIntervalCollection() const; const RimWellPathCompletions* completions() const; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES RimWellPathFractureCollection* fractureCollection(); const RimWellPathFractureCollection* fractureCollection() const; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES RigWellPath* wellPathGeometry(); const RigWellPath* wellPathGeometry() const; - RivWellPathPartMgr* partMgr(); - bool readWellPathFile(QString * errorMessage, RifWellPathImporter* wellPathImporter); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); @@ -169,7 +172,6 @@ class RimWellPath : public caf::PdmObject cvf::ref m_wellPath; cvf::ref m_wellPathFormations; - cvf::ref m_wellPathPartMgr; caf::PdmField m_name; caf::PdmField m_wellPathFormationFilePath; @@ -177,7 +179,7 @@ class RimWellPath : public caf::PdmObject caf::PdmChildArrayField m_wellLogFiles; + caf::PdmChildField m_3dWellLogCurves; caf::PdmChildField m_wellLogFile_OBSOLETE; - }; diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp index f02e2528af..ed2ed64361 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.cpp @@ -39,13 +39,11 @@ #include "RimWellPath.h" #include "RimPerforationCollection.h" -#include "RiuMainWindow.h" +#include "Riu3DMainWindowTools.h" #include "RifWellPathFormationsImporter.h" #include "RifWellPathImporter.h" -#include "RivWellPathPartMgr.h" - #include "cafPdmUiEditorHandle.h" #include "cafProgressInfo.h" @@ -140,7 +138,7 @@ void RimWellPathCollection::readWellPathFiles() QString errorMessage; if (!wellPaths[wpIdx]->readWellPathFile(&errorMessage, m_wellPathImporter)) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage); } @@ -161,7 +159,7 @@ void RimWellPathCollection::readWellPathFiles() displayMessage += errorMessage; } - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", displayMessage); } @@ -254,7 +252,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP for (size_t wpIdx = 0; wpIdx < wellPathArray.size(); wpIdx++) { RimWellPath* wellPath = wellPathArray[wpIdx]; - wellPath->readWellPathFile(NULL, m_wellPathImporter); + wellPath->readWellPathFile(nullptr, m_wellPathImporter); progress.setProgressDescription(QString("Reading file %1").arg(wellPath->name())); @@ -264,7 +262,7 @@ void RimWellPathCollection::readAndAddWellPaths(std::vector& wellP { existingWellPath->filepath = wellPath->filepath; existingWellPath->wellPathIndexInFile = wellPath->wellPathIndexInFile; - existingWellPath->readWellPathFile(NULL, m_wellPathImporter); + existingWellPath->readWellPathFile(nullptr, m_wellPathImporter); // Let name from well path file override name from well log file existingWellPath->setName(wellPath->name()); @@ -369,7 +367,7 @@ void RimWellPathCollection::addWellPathFormations(const QStringList& filePaths) if (fileReadSuccess) { - QMessageBox::information(RiuMainWindow::instance(), "Well Picks Import", outputMessage); + QMessageBox::information(Riu3DMainWindowTools::mainWindowWidget(), "Well Picks Import", outputMessage); RiaLogging::info(outputMessage); } @@ -409,63 +407,7 @@ void RimWellPathCollection::scheduleRedrawAffectedViews() { RimProject* proj; this->firstAncestorOrThisOfType(proj); - if (proj) proj->createDisplayModelAndRedrawAllViews(); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) -{ - if (!this->isActive()) return; - if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++) - { - RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); - partMgr->appendStaticGeometryPartsToModel(model, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES -void RimWellPathCollection::appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView) -{ - if (!this->isActive()) return; - if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++) - { - RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); - partMgr->appendStaticFracturePartsToModel(model, eclView); - } -} -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellPathCollection::appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform) - -{ - if (!this->isActive()) return; - if (this->wellPathVisibility() == RimWellPathCollection::FORCE_ALL_OFF) return; - - for (size_t wIdx = 0; wIdx < this->wellPaths.size(); wIdx++) - { - RivWellPathPartMgr* partMgr = this->wellPaths[wIdx]->partMgr(); - partMgr->appendDynamicGeometryPartsToModel(model, timeStamp, characteristicCellSize, wellPathClipBoundingBox, displayCoordTransform); - } + if (proj) proj->reloadCompletionTypeResultsInAllViews(); } //-------------------------------------------------------------------------------------------------- @@ -547,7 +489,7 @@ void RimWellPathCollection::readWellPathFormationFiles() QString errorMessage; if (!wellPaths[wpIdx]->readWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter)) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage); } @@ -569,7 +511,7 @@ void RimWellPathCollection::reloadAllWellPathFormations() QString errorMessage; if (!wellPaths[wpIdx]->reloadWellPathFormationsFile(&errorMessage, m_wellPathFormationsImporter)) { - QMessageBox::warning(RiuMainWindow::instance(), + QMessageBox::warning(Riu3DMainWindowTools::mainWindowWidget(), "File open error", errorMessage); } diff --git a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h index 904b705c3d..10bef47eaa 100644 --- a/ApplicationCode/ProjectDataModel/RimWellPathCollection.h +++ b/ApplicationCode/ProjectDataModel/RimWellPathCollection.h @@ -106,21 +106,6 @@ class RimWellPathCollection : public caf::PdmObject void scheduleRedrawAffectedViews(); - void appendStaticGeometryPartsToModel(cvf::ModelBasicList* model, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); - -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES - void appendStaticFracturePartsToModel(cvf::ModelBasicList* model, - const RimEclipseView& eclView); -#endif // USE_PROTOTYPE_FEATURE_FRACTURES - - void appendDynamicGeometryPartsToModel(cvf::ModelBasicList* model, - const QDateTime& timeStamp, - double characteristicCellSize, - const cvf::BoundingBox& wellPathClipBoundingBox, - const caf::DisplayCoordTransform* displayCoordTransform); void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); bool anyWellsContainingPerforationIntervals() const; diff --git a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake index 6e5f40478d..09bc668aec 100644 --- a/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake +++ b/ApplicationCode/ProjectDataModel/Summary/CMakeLists_files.cmake @@ -1,71 +1,72 @@ -# 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}RimAsciiDataCurve.h -${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimSummaryCaseMainCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurve.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAutoName.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveFilter.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurvesCalculator.h -${CEE_CURRENT_LIST_DIR}RimSummaryFilter.h -${CEE_CURRENT_LIST_DIR}RimSummaryCurveCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlot.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlotCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryTimeAxisProperties.h -${CEE_CURRENT_LIST_DIR}RimSummaryAxisProperties.h -${CEE_CURRENT_LIST_DIR}RimObservedData.h -${CEE_CURRENT_LIST_DIR}RimObservedDataCollection.h -${CEE_CURRENT_LIST_DIR}RimSummaryObservedDataFile.h -${CEE_CURRENT_LIST_DIR}RimObservedEclipseUserData.h -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCase.h -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCurveReader.h -${CEE_CURRENT_LIST_DIR}RimSummaryAddress.h -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlot.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlotSourceStepping.h -${CEE_CURRENT_LIST_DIR}RimCsvUserData.h -${CEE_CURRENT_LIST_DIR}RimSummaryPlotNameHelper.h +${CMAKE_CURRENT_LIST_DIR}/RimAsciiDataCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimFileSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimGridSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAutoName.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryFilter.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlotCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryTimeAxisProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAxisProperties.h +${CMAKE_CURRENT_LIST_DIR}/RimObservedData.h +${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryObservedDataFile.h +${CMAKE_CURRENT_LIST_DIR}/RimObservedEclipseUserData.h +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCase.h +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCurveReader.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddress.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.h +${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.h +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.h +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RimAsciiDataCurve.cpp -${CEE_CURRENT_LIST_DIR}RimFileSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimGridSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCaseMainCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCaseCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurve.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAppearanceCalculator.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveAutoName.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveFilter.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurvesCalculator.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryFilter.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCurveCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlot.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlotCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryTimeAxisProperties.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryAxisProperties.cpp -${CEE_CURRENT_LIST_DIR}RimObservedData.cpp -${CEE_CURRENT_LIST_DIR}RimObservedDataCollection.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryObservedDataFile.cpp -${CEE_CURRENT_LIST_DIR}RimObservedEclipseUserData.cpp -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCase.cpp -${CEE_CURRENT_LIST_DIR}RimCalculatedSummaryCurveReader.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryAddress.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryCrossPlot.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlotSourceStepping.cpp -${CEE_CURRENT_LIST_DIR}RimCsvUserData.cpp -${CEE_CURRENT_LIST_DIR}RimSummaryPlotNameHelper.cpp +${CMAKE_CURRENT_LIST_DIR}/RimAsciiDataCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFileSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimGridSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseMainCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCaseCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAppearanceCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveAutoName.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurvesCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCurveCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlotCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryTimeAxisProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAxisProperties.cpp +${CMAKE_CURRENT_LIST_DIR}/RimObservedData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimObservedDataCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryObservedDataFile.cpp +${CMAKE_CURRENT_LIST_DIR}/RimObservedEclipseUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCase.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCalculatedSummaryCurveReader.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryCrossPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotSourceStepping.cpp +${CMAKE_CURRENT_LIST_DIR}/RimCsvUserData.cpp +${CMAKE_CURRENT_LIST_DIR}/RimSummaryPlotNameHelper.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSet.cpp +${CMAKE_CURRENT_LIST_DIR}/RimEnsembleCurveSetColorManager.cpp ) list(APPEND CODE_HEADER_FILES @@ -76,4 +77,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ProjectDataModel\\Summary" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ProjectDataModel\\Summary" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp b/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp index 4f4ba4d088..fee2e40c42 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimCsvUserData.cpp @@ -36,7 +36,7 @@ CAF_PDM_SOURCE_INIT(RimCsvUserData, "RimCsvUserData"); //-------------------------------------------------------------------------------------------------- RimCsvUserData::RimCsvUserData() { - CAF_PDM_InitObject("Observed CSV Data File", ":/Default.png", "", ""); + CAF_PDM_InitObject("Observed CSV Data File", ":/ObservedCSVDataFile16x16.png", "", ""); m_summaryHeaderFilename.uiCapability()->setUiName("File"); CAF_PDM_InitFieldNoDefault(&m_parseOptions, "ParseOptions", "", "", "", ""); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp new file mode 100644 index 0000000000..dd352de616 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.cpp @@ -0,0 +1,1014 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsembleCurveSet.h" + +#include "RiaApplication.h" +#include "RiaColorTables.h" + +#include "RifReaderEclipseSummary.h" + +#include "RimEnsembleCurveSetCollection.h" +#include "RimEnsembleCurveSetColorManager.h" +#include "RimProject.h" +#include "RimRegularLegendConfig.h" +#include "RimSummaryAddress.h" +#include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" +#include "RimSummaryCurve.h" +#include "RimSummaryCurveAutoName.h" +#include "RimSummaryFilter.h" +#include "RimSummaryPlot.h" + +#include "RiuPlotMainWindow.h" +#include "RiuSummaryQwtPlot.h" +#include "RiuSummaryCurveDefSelectionDialog.h" + +#include "cafPdmUiTreeOrdering.h" +#include "cafPdmUiListEditor.h" +#include "cafPdmObject.h" +#include "cafPdmUiPushButtonEditor.h" + +#include "cvfScalarMapper.h" + +#include "qwt_plot_curve.h" +#include "qwt_symbol.h" + + +//-------------------------------------------------------------------------------------------------- +/// Internal constants +//-------------------------------------------------------------------------------------------------- +#define DOUBLE_INF std::numeric_limits::infinity() + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +namespace caf +{ + template<> + void AppEnum< RimEnsembleCurveSet::ColorMode >::setUp() + { + addItem(RimEnsembleCurveSet::SINGLE_COLOR, "SINGLE_COLOR", "Single Color"); + addItem(RimEnsembleCurveSet::BY_ENSEMBLE_PARAM, "BY_ENSEMBLE_PARAM", "By Ensemble Parameter"); + setDefault(RimEnsembleCurveSet::SINGLE_COLOR); + } +} + + +CAF_PDM_SOURCE_INIT(RimEnsembleCurveSet, "RimEnsembleCurveSet"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet::RimEnsembleCurveSet() +{ + CAF_PDM_InitObject("Ensemble Curve Set", ":/EnsembleCurveSet16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_curves, "EnsembleCurveSet", "Ensemble Curve Set", "", "", ""); + m_curves.uiCapability()->setUiHidden(true); + m_curves.uiCapability()->setUiTreeChildrenHidden(false); + + CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); + m_showCurves.uiCapability()->setUiHidden(true); + + // Y Values + CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryGroup, "SummaryGroup", "Ensemble", "", "", ""); + m_yValuesSummaryGroup.uiCapability()->setUiTreeChildrenHidden(true); + m_yValuesSummaryGroup.uiCapability()->setAutoAddingOptionFromValue(false); + + CAF_PDM_InitFieldNoDefault(&m_yValuesSelectedVariableDisplayField, "SelectedVariableDisplayVar", "Vector", "", "", ""); + m_yValuesSelectedVariableDisplayField.xmlCapability()->disableIO(); + m_yValuesSelectedVariableDisplayField.uiCapability()->setUiReadOnly(true); + + CAF_PDM_InitFieldNoDefault(&m_yValuesSummaryFilter, "VarListFilter", "Filter", "", "", ""); + m_yValuesSummaryFilter.uiCapability()->setUiTreeChildrenHidden(true); + m_yValuesSummaryFilter.uiCapability()->setUiHidden(true); + + m_yValuesSummaryFilter = new RimSummaryFilter; + + CAF_PDM_InitFieldNoDefault(&m_yValuesUiFilterResultSelection, "FilterResultSelection", "Filter Result", "", "", ""); + m_yValuesUiFilterResultSelection.xmlCapability()->disableIO(); + m_yValuesUiFilterResultSelection.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); + m_yValuesUiFilterResultSelection.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_yValuesUiFilterResultSelection.uiCapability()->setAutoAddingOptionFromValue(false); + + CAF_PDM_InitFieldNoDefault(&m_yValuesCurveVariable, "SummaryAddress", "Summary Address", "", "", ""); + m_yValuesCurveVariable.uiCapability()->setUiHidden(true); + m_yValuesCurveVariable.uiCapability()->setUiTreeChildrenHidden(true); + + CAF_PDM_InitFieldNoDefault(&m_yPushButtonSelectSummaryAddress, "SelectAddress", "", "", "", ""); + caf::PdmUiPushButtonEditor::configureEditorForField(&m_yPushButtonSelectSummaryAddress); + m_yPushButtonSelectSummaryAddress = false; + + m_yValuesCurveVariable = new RimSummaryAddress; + + CAF_PDM_InitField(&m_colorMode, "ColorMode", caf::AppEnum(SINGLE_COLOR), "Coloring Mode", "", "", ""); + + CAF_PDM_InitField(&m_color, "Color", cvf::Color3f(cvf::Color3::BLACK), "Color", "", "", ""); + + CAF_PDM_InitField(&m_ensembleParameter, "EnsembleParameter", QString(""), "Ensemble Parameter", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_plotAxis, "PlotAxis", "Axis", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_legendConfig, "LegendConfig", "", "", "", ""); + m_legendConfig = new RimRegularLegendConfig(); + m_legendConfig->setColorRange( RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE ); + + CAF_PDM_InitField(&m_userDefinedName, "UserDefinedName", QString("Ensemble Curve Set"), "Curve Set Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_autoGeneratedName, "AutoGeneratedName", "Curve Set Name", "", "", ""); + m_autoGeneratedName.registerGetMethod(this, &RimEnsembleCurveSet::createAutoName); + m_autoGeneratedName.uiCapability()->setUiReadOnly(true); + m_autoGeneratedName.xmlCapability()->disableIO(); + + CAF_PDM_InitField(&m_isUsingAutoName, "AutoName", true, "Auto Name", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_summaryAddressNameTools, "SummaryAddressNameTools", "SummaryAddressNameTools", "", "", ""); + m_summaryAddressNameTools.uiCapability()->setUiHidden(true); + m_summaryAddressNameTools.uiCapability()->setUiTreeChildrenHidden(true); + + m_summaryAddressNameTools = new RimSummaryCurveAutoName; + + m_qwtPlotCurveForLegendText = new QwtPlotCurve; + m_qwtPlotCurveForLegendText->setLegendAttribute(QwtPlotCurve::LegendShowSymbol, true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet::~RimEnsembleCurveSet() +{ + m_curves.deleteAllChildObjects(); + + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfType(parentPlot); + if (parentPlot && parentPlot->qwtPlot()) + { + m_qwtPlotCurveForLegendText->detach(); + parentPlot->qwtPlot()->removeEnsembleCurveSetLegend(this); + } + + delete m_qwtPlotCurveForLegendText; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEnsembleCurveSet::isCurvesVisible() +{ + RimEnsembleCurveSetCollection* coll = nullptr; + firstAncestorOrThisOfType(coll); + return m_showCurves() && (coll ? coll->isCurveSetsVisible() : true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setColor(cvf::Color3f color) +{ + m_color = color; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::loadDataAndUpdate(bool updateParentPlot) +{ + m_yValuesSelectedVariableDisplayField = QString::fromStdString(m_yValuesCurveVariable->address().uiText()); + m_yValuesUiFilterResultSelection = m_yValuesCurveVariable->address(); + + updateAllCurves(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setParentQwtPlotNoReplot(QwtPlot* plot) +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->setParentQwtPlotNoReplot(plot); + } + + m_qwtPlotCurveForLegendText->attach(plot); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::detachQwtCurves() +{ + for (RimSummaryCurve* curve : m_curves) + { + curve->detachQwtCurve(); + } + + m_qwtPlotCurveForLegendText->detach(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::addCurve(RimSummaryCurve* curve) +{ + if (curve) + { + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot) curve->setParentQwtPlotNoReplot(plot->qwtPlot()); + + curve->setColor(m_color); + m_curves.push_back(curve); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::deleteCurve(RimSummaryCurve* curve) +{ + if (curve) + { + m_curves.removeChildObject(curve); + delete curve; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setSummaryAddress(RifEclipseSummaryAddress address) +{ + m_yValuesCurveVariable->setAddress(address); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RifEclipseSummaryAddress RimEnsembleCurveSet::summaryAddress() const +{ + return m_yValuesCurveVariable->address(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsembleCurveSet::curves() const +{ + return m_curves.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::deleteAllCurves() +{ + m_curves.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig* RimEnsembleCurveSet::legendConfig() +{ + return m_legendConfig; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::onLegendDefinitionChanged() +{ + updateCurveColors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::setSummaryCaseCollection(RimSummaryCaseCollection* sumCaseCollection) +{ + m_yValuesSummaryGroup = sumCaseCollection; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RimEnsembleCurveSet::summaryCaseCollection() const +{ + return m_yValuesSummaryGroup(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet::ColorMode RimEnsembleCurveSet::colorMode() const +{ + return m_colorMode(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet::EnsembleParameterType RimEnsembleCurveSet::currentEnsembleParameterType() const +{ + if (m_colorMode() == BY_ENSEMBLE_PARAM) + { + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + QString parameterName = m_ensembleParameter(); + + if (group && !parameterName.isEmpty() && !group->allSummaryCases().empty()) + { + bool isTextParameter = group->allSummaryCases().front()->caseRealizationParameters() != nullptr ? + group->allSummaryCases().front()->caseRealizationParameters()->parameterValue(parameterName).isText() : false; + + return isTextParameter ? TYPE_TEXT : TYPE_NUMERIC; + } + } + return TYPE_NONE; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType(plot); + CVF_ASSERT(plot); + + bool updateTextInPlot = false; + + if (changedField == &m_showCurves) + { + loadDataAndUpdate(true); + + updateConnectedEditors(); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + summaryPlot->updateConnectedEditors(); + + updateTextInPlot = true; + } + else if (changedField == &m_yValuesUiFilterResultSelection) + { + m_yValuesCurveVariable->setAddress(m_yValuesUiFilterResultSelection()); + + updateAllCurves(); + + updateTextInPlot = true; + } + else if (changedField == &m_yValuesSummaryGroup) + { + // Empty address cache + m_allAddressesCache.clear(); + updateAllCurves(); + + updateTextInPlot = true; + } + else if (changedField == &m_color) + { + updateCurveColors(); + + updateTextInPlot = true; + } + else if (changedField == &m_ensembleParameter) + { + updateLegendMappingMode(); + updateCurveColors(); + } + else if (changedField == &m_colorMode) + { + if (m_ensembleParameter().isEmpty()) + { + auto params = ensembleParameters(); + m_ensembleParameter = !params.empty() ? params.front() : ""; + } + updateCurveColors(); + + updateTextInPlot = true; + } + else if (changedField == &m_plotAxis) + { + for (RimSummaryCurve* curve : curves()) + { + curve->setLeftOrRightAxisY(m_plotAxis()); + } + + updateQwtPlotAxis(); + plot->updateAxes(); + + updateTextInPlot = true; + } + else if (changedField == &m_isUsingAutoName) + { + if (!m_isUsingAutoName) + { + m_userDefinedName = createAutoName(); + } + + updateTextInPlot = true; + } + else if (changedField == &m_userDefinedName) + { + updateTextInPlot = true; + } + else if (changedField == &m_yPushButtonSelectSummaryAddress) + { + RiuSummaryCurveDefSelectionDialog dlg(nullptr); + RimSummaryCaseCollection* candidateEnsemble = m_yValuesSummaryGroup(); + RifEclipseSummaryAddress candicateAddress = m_yValuesCurveVariable->address(); + + dlg.hideSummaryCases(); + dlg.setEnsembleAndAddress(candidateEnsemble, candicateAddress); + + if (dlg.exec() == QDialog::Accepted) + { + auto curveSelection = dlg.curveSelection(); + if (!curveSelection.empty()) + { + m_yValuesSummaryGroup = curveSelection[0].ensemble(); + m_yValuesCurveVariable->setAddress(curveSelection[0].summaryAddress()); + + this->loadDataAndUpdate(true); + + plot->updateAxes(); + plot->updatePlotTitle(); + plot->updateConnectedEditors(); + + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + mainPlotWindow->updateSummaryPlotToolBar(); + } + } + + m_yPushButtonSelectSummaryAddress = false; + } + + if (updateTextInPlot) + { + updateAllTextInPlot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) +{ + { + QString curveDataGroupName = "Summary Vector"; + caf::PdmUiGroup* curveDataGroup = uiOrdering.addNewGroupWithKeyword(curveDataGroupName, "Summary Vector Y"); + curveDataGroup->add(&m_yValuesSummaryGroup); + curveDataGroup->add(&m_yValuesSelectedVariableDisplayField); + curveDataGroup->add(&m_plotAxis); + curveDataGroup->add(&m_yPushButtonSelectSummaryAddress); + + QString curveVarSelectionGroupName = "Vector Selection Filter Y"; + caf::PdmUiGroup* curveVarSelectionGroup = curveDataGroup->addNewGroupWithKeyword("Vector Selection Filter", curveVarSelectionGroupName); + curveVarSelectionGroup->setCollapsedByDefault(true); + m_yValuesSummaryFilter->uiOrdering(uiConfigName, *curveVarSelectionGroup); + curveVarSelectionGroup->add(&m_yValuesUiFilterResultSelection); + } + + caf::PdmUiGroup* colorsGroup = uiOrdering.addNewGroup("Colors"); + m_colorMode.uiCapability()->setUiReadOnly(!m_yValuesSummaryGroup()); + colorsGroup->add(&m_colorMode); + + if (m_colorMode == SINGLE_COLOR) + { + colorsGroup->add(&m_color); + } + else if (m_colorMode == BY_ENSEMBLE_PARAM) + { + m_ensembleParameter.uiCapability()->setUiReadOnly(!m_yValuesSummaryGroup()); + colorsGroup->add(&m_ensembleParameter); + } + + { + caf::PdmUiGroup* nameGroup = uiOrdering.addNewGroup("Curve Name"); + nameGroup->setCollapsedByDefault(true); + nameGroup->add(&m_isUsingAutoName); + if (m_isUsingAutoName) + { + nameGroup->add(&m_autoGeneratedName); + m_summaryAddressNameTools->uiOrdering(uiConfigName, *nameGroup); + } + else + { + nameGroup->add(&m_userDefinedName); + } + } + + uiOrdering.skipRemainingFields(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) +{ + if (m_colorMode == BY_ENSEMBLE_PARAM) + { + uiTreeOrdering.add(m_legendConfig()); + } + uiTreeOrdering.skipRemainingChildren(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimEnsembleCurveSet::userDescriptionField() +{ + if (m_isUsingAutoName) + { + return &m_autoGeneratedName; + } + else + { + return &m_userDefinedName; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimEnsembleCurveSet::objectToggleField() +{ + return &m_showCurves; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) +{ + caf::PdmUiPushButtonEditorAttribute* attrib = dynamic_cast (attribute); + if (attrib) + { + attrib->m_buttonText = "Vector Selection Dialog"; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimEnsembleCurveSet::calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly) +{ + QList options; + + if (fieldNeedingOptions == &m_yValuesSummaryGroup) + { + RimProject* proj = RiaApplication::instance()->project(); + std::vector groups = proj->summaryGroups(); + + for (RimSummaryCaseCollection* group : groups) + { + if(group->isEnsemble()) options.push_back(caf::PdmOptionItemInfo(group->name(), group)); + } + + options.push_front(caf::PdmOptionItemInfo("None", nullptr)); + } + else if (fieldNeedingOptions == &m_colorMode) + { + auto singleColorOption = caf::AppEnum(RimEnsembleCurveSet::SINGLE_COLOR); + auto byEnsParamOption = caf::AppEnum(RimEnsembleCurveSet::BY_ENSEMBLE_PARAM); + + options.push_back(caf::PdmOptionItemInfo(singleColorOption.uiText(), RimEnsembleCurveSet::SINGLE_COLOR)); + if (!ensembleParameters().empty()) + { + options.push_back(caf::PdmOptionItemInfo(byEnsParamOption.uiText(), RimEnsembleCurveSet::BY_ENSEMBLE_PARAM)); + } + } + else if (fieldNeedingOptions == &m_ensembleParameter) + { + for (const auto& param : ensembleParameters()) + { + options.push_back(caf::PdmOptionItemInfo(param, param)); + } + } + else if (fieldNeedingOptions == &m_yValuesUiFilterResultSelection) + { + appendOptionItemsForSummaryAddresses(&options, m_yValuesSummaryGroup(), m_yValuesSummaryFilter()); + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::getOptionsForSummaryAddresses(std::map* options, + RimSummaryCase* summaryCase, + RimSummaryFilter* summaryFilter) +{ + if (summaryCase) + { + RifSummaryReaderInterface* reader = summaryCase->summaryReader(); + if (reader) + { + for (const auto& address : reader->allResultAddresses()) + { + if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; + + std::string name = address.uiText(); + QString s = QString::fromStdString(name); + options->insert(std::make_pair(s, address)); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// Optimization candidate +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::appendOptionItemsForSummaryAddresses(QList* options, + RimSummaryCaseCollection* summaryCaseGroup, + RimSummaryFilter* summaryFilter) +{ + if (!summaryCaseGroup) return; + + if (m_allAddressesCache.empty()) + { + for (RimSummaryCase* summaryCase : summaryCaseGroup->allSummaryCases()) + { + RifSummaryReaderInterface* reader = summaryCase->summaryReader(); + const std::vector addrs = reader ? reader->allResultAddresses() : std::vector(); + m_allAddressesCache.insert(addrs.begin(), addrs.end()); + } + } + + for (auto& address : m_allAddressesCache) + { + if (summaryFilter && !summaryFilter->isIncludedByFilter(address)) continue; + + std::string name = address.uiText(); + QString s = QString::fromStdString(name); + options->push_back(caf::PdmOptionItemInfo(s, QVariant::fromValue(address))); + } + + options->push_front(caf::PdmOptionItemInfo(RiaDefines::undefinedResultName(), QVariant::fromValue(RifEclipseSummaryAddress()))); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateCurveColors() +{ + if(m_colorMode == BY_ENSEMBLE_PARAM) + { + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + + QString parameterName = m_ensembleParameter(); + + { + QString legendTitle; + if (m_isUsingAutoName) + { + legendTitle = m_autoGeneratedName(); + } + else + { + legendTitle += m_userDefinedName(); + } + + legendTitle += "\n"; + legendTitle += parameterName; + + m_legendConfig->setTitle(legendTitle); + } + + if (group && !parameterName.isEmpty() && !group->allSummaryCases().empty()) + { + bool isTextParameter = group->allSummaryCases().front()->caseRealizationParameters() != nullptr ? + group->allSummaryCases().front()->caseRealizationParameters()->parameterValue(parameterName).isText() : false; + + if (isTextParameter) + { + std::set categories; + + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (rimCase->caseRealizationParameters() != nullptr) + { + RigCaseRealizationParameters::Value value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + if (value.isText()) + { + categories.insert(value.textValue()); + } + } + } + + std::vector categoryNames = std::vector(categories.begin(), categories.end()); + m_legendConfig->setNamedCategories(categoryNames); + m_legendConfig->setAutomaticRanges(0, categoryNames.size() - 1, 0, categoryNames.size() - 1); + + for (auto& curve : m_curves) + { + RimSummaryCase* rimCase = curve->summaryCaseY(); + QString tValue = rimCase->hasCaseRealizationParameters() ? + rimCase->caseRealizationParameters()->parameterValue(parameterName).textValue() : + ""; + double nValue = m_legendConfig->categoryValueFromCategoryName(tValue); + if (nValue != DOUBLE_INF) + { + int iValue = static_cast(nValue); + curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(iValue))); + } + else + { + curve->setColor(RiaColorTables::undefinedCellColor()); + } + curve->updateCurveAppearance(); + } + } + else + { + double minValue = DOUBLE_INF; + double maxValue = -DOUBLE_INF; + + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (rimCase->caseRealizationParameters() != nullptr) + { + RigCaseRealizationParameters::Value value = rimCase->caseRealizationParameters()->parameterValue(parameterName); + if (value.isNumeric()) + { + double nValue = value.numericValue(); + if (nValue != DOUBLE_INF) + { + if (nValue < minValue) minValue = nValue; + if (nValue > maxValue) maxValue = nValue; + } + } + } + } + + m_legendConfig->setAutomaticRanges(minValue, maxValue, minValue, maxValue); + + for (auto& curve : m_curves) + { + RimSummaryCase* rimCase = curve->summaryCaseY(); + double value = rimCase->hasCaseRealizationParameters() ? + rimCase->caseRealizationParameters()->parameterValue(parameterName).numericValue() : + DOUBLE_INF; + if(value != DOUBLE_INF) curve->setColor(cvf::Color3f(m_legendConfig->scalarMapper()->mapToColor(value))); + else curve->setColor(RiaColorTables::undefinedCellColor()); + curve->updateCurveAppearance(); + } + } + } + } + else if (m_colorMode == SINGLE_COLOR) + { + for (auto& curve : m_curves) + { + curve->setColor(m_color); + curve->updateCurveAppearance(); + } + } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot && plot->qwtPlot()) + { + if (m_yValuesSummaryGroup() && isCurvesVisible() && m_colorMode == BY_ENSEMBLE_PARAM && m_legendConfig->showLegend()) + { + plot->qwtPlot()->addOrUpdateEnsembleCurveSetLegend(this); + } + else + { + plot->qwtPlot()->removeEnsembleCurveSetLegend(this); + } + plot->qwtPlot()->replot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateQwtPlotAxis() +{ + for (RimSummaryCurve* curve : curves()) + { + curve->updateQwtPlotAxis(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateAllCurves() +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfType(plot); + CVF_ASSERT(plot); + + deleteAllCurves(); + + RimSummaryCaseCollection* group = m_yValuesSummaryGroup(); + RimSummaryAddress* addr = m_yValuesCurveVariable(); + if (group && plot && addr->address().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) + { + if(m_showCurves) + { + for (auto& sumCase : group->allSummaryCases()) + { + RimSummaryCurve* curve = new RimSummaryCurve(); + curve->setSummaryCaseY(sumCase); + curve->setSummaryAddressY(addr->address()); + curve->setLeftOrRightAxisY(m_plotAxis()); + + addCurve(curve); + + curve->updateCurveVisibility(true); + curve->loadDataAndUpdate(true); + + if (curve->qwtPlotCurve()) + { + curve->qwtPlotCurve()->setItemAttribute(QwtPlotItem::Legend, false); + } + } + m_yValuesSummaryFilter->updateFromAddress(addr->address()); + } + + RimSummaryPlot* plot; + firstAncestorOrThisOfType(plot); + if (plot->qwtPlot()) + { + plot->qwtPlot()->replot(); + plot->updateAxes(); + } + } + updateCurveColors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RimEnsembleCurveSet::clone() const +{ + RimEnsembleCurveSet* copy = dynamic_cast(this->xmlCapability()->copyByXmlSerialization(caf::PdmDefaultObjectFactory::instance())); + copy->m_yValuesSummaryGroup = m_yValuesSummaryGroup(); + + // Update summary case references + for (size_t i = 0; i < m_curves.size(); i++) + { + copy->m_curves[i]->setSummaryCaseY(m_curves[i]->summaryCaseY()); + } + return copy; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::showCurves(bool show) +{ + m_showCurves = show; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateAllTextInPlot() +{ + updateEnsembleLegendItem(); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + if (summaryPlot->qwtPlot()) + { + summaryPlot->updatePlotTitle(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateEnsembleLegendItem() +{ + m_qwtPlotCurveForLegendText->setTitle(name()); + + { + QwtSymbol* symbol = nullptr; + + if (m_colorMode == SINGLE_COLOR) + { + symbol = new QwtSymbol(QwtSymbol::HLine); + + QColor curveColor(m_color.value().rByte(), m_color.value().gByte(), m_color.value().bByte()); + QPen curvePen(curveColor); + curvePen.setWidth(2); + + symbol->setPen(curvePen); + symbol->setSize(6, 6); + } + else if (m_colorMode == BY_ENSEMBLE_PARAM) + { + QPixmap p = QPixmap(":/Legend.png"); + + symbol = new QwtSymbol; + symbol->setPixmap(p); + symbol->setSize(8, 8); + } + + m_qwtPlotCurveForLegendText->setSymbol(symbol); + } + + bool showLegendItem = isCurvesVisible(); + m_qwtPlotCurveForLegendText->setItemAttribute(QwtPlotItem::Legend, showLegendItem); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsembleCurveSet::ensembleParameters() const +{ + RimSummaryCaseCollection* group = m_yValuesSummaryGroup; + + std::set paramSet; + if (group) + { + for (RimSummaryCase* rimCase : group->allSummaryCases()) + { + if (rimCase->caseRealizationParameters() != nullptr) + { + auto ps = rimCase->caseRealizationParameters()->parameters(); + for (auto p : ps) paramSet.insert(p.first); + } + } + } + return std::vector(paramSet.begin(), paramSet.end()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEnsembleCurveSet::name() const +{ + QString curveSetName; + if (m_isUsingAutoName) + { + curveSetName = m_autoGeneratedName(); + } + else + { + curveSetName += m_userDefinedName(); + } + + return curveSetName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimEnsembleCurveSet::createAutoName() const +{ + RimSummaryPlot* plot = nullptr; + firstAncestorOrThisOfTypeAsserted(plot); + + QString curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelperAllCurves()); + if (curveSetName.isEmpty()) + { + curveSetName = m_summaryAddressNameTools->curveNameY(m_yValuesCurveVariable->address(), nullptr); + } + + if (curveSetName.isEmpty()) + { + curveSetName = "Name Placeholder"; + } + + return curveSetName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSet::updateLegendMappingMode() +{ + switch (currentEnsembleParameterType()) + { + case TYPE_TEXT: + if (m_legendConfig->mappingMode() != RimRegularLegendConfig::MappingType::CATEGORY_INTEGER) + m_legendConfig->setMappingMode(RimRegularLegendConfig::MappingType::CATEGORY_INTEGER); + break; + + case TYPE_NUMERIC: + if (m_legendConfig->mappingMode() == RimRegularLegendConfig::MappingType::CATEGORY_INTEGER) + m_legendConfig->setMappingMode(RimRegularLegendConfig::MappingType::LINEAR_CONTINUOUS); + break; + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h new file mode 100644 index 0000000000..a07f9b00c2 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSet.h @@ -0,0 +1,156 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#pragma once + +#include "RifEclipseSummaryAddress.h" + +#include "RiaDefines.h" + +#include "RimRegularLegendConfig.h" + +#include "cafPdmFieldCvfColor.h" +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrArrayField.h" +#include "cafPdmPtrField.h" +#include "cafAppEnum.h" + +#include "RifEclipseSummaryAddressQMetaType.h" +#include "cafPdmProxyValueField.h" + +class QwtPlot; +class QwtPlotCurve; +class RimSummaryCase; +class RimSummaryCaseCollection; +class RimSummaryCurve; +class RimSummaryAddress; +class RimSummaryFilter; +class RimSummaryPlotSourceStepping; +class RimSummaryCurveAutoName; +class QKeyEvent; + +//================================================================================================== +/// +//================================================================================================== +class RimEnsembleCurveSet : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + enum ColorMode {SINGLE_COLOR, BY_ENSEMBLE_PARAM}; + enum EnsembleParameterType {TYPE_NONE, TYPE_NUMERIC, TYPE_TEXT}; + + RimEnsembleCurveSet(); + virtual ~RimEnsembleCurveSet(); + + bool isCurvesVisible(); + void setColor(cvf::Color3f color); + + void loadDataAndUpdate(bool updateParentPlot); + void setParentQwtPlotNoReplot(QwtPlot* plot); + void detachQwtCurves(); + + void addCurve(RimSummaryCurve* curve); + void deleteCurve(RimSummaryCurve* curve); + + void setSummaryAddress(RifEclipseSummaryAddress address); + RifEclipseSummaryAddress summaryAddress() const; + std::vector curves() const; + + void deleteAllCurves(); + + RimRegularLegendConfig* legendConfig(); + void onLegendDefinitionChanged(); + + void setSummaryCaseCollection(RimSummaryCaseCollection* sumCaseCollection); + RimSummaryCaseCollection* summaryCaseCollection() const; + + ColorMode colorMode() const; + void updateEnsembleLegendItem(); + EnsembleParameterType currentEnsembleParameterType() const; + + void updateAllCurves(); + RimEnsembleCurveSet* clone() const; + void showCurves(bool show); + + void updateAllTextInPlot(); + +private: + caf::PdmFieldHandle* userDescriptionField() override; + caf::PdmFieldHandle* objectToggleField(); + virtual void defineEditorAttribute(const caf::PdmFieldHandle* field, QString uiConfigName, caf::PdmUiEditorAttribute* attribute) override; + + virtual QList calculateValueOptions(const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly); + virtual void defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) override; + virtual void defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "") override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, const QVariant& newValue) override; + + static void getOptionsForSummaryAddresses(std::map* options, + RimSummaryCase* summaryCase, + RimSummaryFilter* summaryFilter); + + void appendOptionItemsForSummaryAddresses(QList* options, + RimSummaryCaseCollection* summaryCaseGroup, + RimSummaryFilter* summaryFilter); + + void updateCurveColors(); + void updateQwtPlotAxis(); + std::vector ensembleParameters() const; + + QString name() const; + QString createAutoName() const; + + void updateLegendMappingMode(); + +private: + caf::PdmField m_showCurves; + caf::PdmChildArrayField m_curves; + + caf::PdmPointer m_currentSummaryCurve; + + caf::PdmPtrField m_yValuesSummaryGroup; + caf::PdmChildField m_yValuesCurveVariable; + caf::PdmField m_yValuesSelectedVariableDisplayField; + caf::PdmChildField m_yValuesSummaryFilter; + caf::PdmField m_yValuesUiFilterResultSelection; + caf::PdmField m_yPushButtonSelectSummaryAddress; + + caf::PdmField> m_colorMode; + caf::PdmField m_color; + caf::PdmField m_ensembleParameter; + + caf::PdmField> m_plotAxis; + + caf::PdmChildField m_legendConfig; + + caf::PdmField m_isUsingAutoName; + caf::PdmField m_userDefinedName; + caf::PdmProxyValueField m_autoGeneratedName; + caf::PdmChildField m_summaryAddressNameTools; + + std::set m_allAddressesCache; + + QwtPlotCurve* m_qwtPlotCurveForLegendText; +}; + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp new file mode 100644 index 0000000000..a51722f143 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.cpp @@ -0,0 +1,222 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsembleCurveSetCollection.h" + +#include "RiaApplication.h" +#include "RiaColorTables.h" + +#include "RifReaderEclipseSummary.h" + +#include "RimEnsembleCurveSet.h" +#include "RimProject.h" +#include "RimSummaryCase.h" +#include "RimSummaryCrossPlot.h" +#include "RimSummaryCurve.h" +#include "RimSummaryCurveAppearanceCalculator.h" +#include "RimSummaryPlot.h" +#include "RimSummaryPlotSourceStepping.h" + +#include "RiuLineSegmentQwtPlotCurve.h" +#include "RiuSummaryQwtPlot.h" + +CAF_PDM_SOURCE_INIT(RimEnsembleCurveSetCollection, "RimEnsembleCurveSetCollection"); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSetCollection::RimEnsembleCurveSetCollection() +{ + CAF_PDM_InitObject("Ensemble Curve Sets", ":/EnsembleCurveSets16x16.png", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_curveSets, "EnsembleCurveSets", "Ensemble Curve Sets", "", "", ""); + m_curveSets.uiCapability()->setUiHidden(true); + m_curveSets.uiCapability()->setUiTreeChildrenHidden(false); + + CAF_PDM_InitField(&m_showCurves, "IsActive", true, "Show Curves", "", "", ""); + m_showCurves.uiCapability()->setUiHidden(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSetCollection::~RimEnsembleCurveSetCollection() +{ + m_curveSets.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimEnsembleCurveSetCollection::isCurveSetsVisible() +{ + return m_showCurves(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::loadDataAndUpdate(bool updateParentPlot) +{ + for (RimEnsembleCurveSet* curveSet : m_curveSets) + { + curveSet->loadDataAndUpdate(updateParentPlot); + } + + if (updateParentPlot) + { + RimSummaryPlot* parentPlot; + firstAncestorOrThisOfTypeAsserted(parentPlot); + if (parentPlot->qwtPlot()) + { + parentPlot->updatePlotTitle(); + parentPlot->qwtPlot()->updateLegend(); + parentPlot->updateAxes(); + parentPlot->updateZoomInQwt(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::setParentQwtPlotAndReplot(QwtPlot* plot) +{ + for (RimEnsembleCurveSet* curveSet : m_curveSets) + { + curveSet->setParentQwtPlotNoReplot(plot); + } + + if (plot) plot->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::detachQwtCurves() +{ + for (const auto& curveSet : m_curveSets) + { + curveSet->detachQwtCurves(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSet* RimEnsembleCurveSetCollection::findRimCurveSetFromQwtCurve(const QwtPlotCurve* qwtCurve) const +{ + for (RimEnsembleCurveSet* curveSet : m_curveSets) + { + for (RimSummaryCurve* rimCurve : curveSet->curves()) + { + if (rimCurve->qwtPlotCurve() == qwtCurve) + { + return curveSet; + } + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::addCurveSet(RimEnsembleCurveSet* curveSet) +{ + + if (curveSet) + { + + m_curveSets.push_back(curveSet); + + + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::deleteCurveSet(RimEnsembleCurveSet* curveSet) +{ + if (curveSet) + { + m_curveSets.removeChildObject(curveSet); + delete curveSet; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimEnsembleCurveSetCollection::curveSets() const +{ + return m_curveSets.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RimEnsembleCurveSetCollection::curveSetCount() const +{ + return m_curveSets.size(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::deleteAllCurveSets() +{ + m_curveSets.deleteAllChildObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::setCurrentSummaryCurveSet(RimEnsembleCurveSet* curveSet) +{ + m_currentEnsembleCurveSet = curveSet; + + updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimEnsembleCurveSetCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) +{ + if (changedField == &m_showCurves) + { + loadDataAndUpdate(true); + + RimSummaryPlot* summaryPlot = nullptr; + this->firstAncestorOrThisOfTypeAsserted(summaryPlot); + summaryPlot->updateConnectedEditors(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimEnsembleCurveSetCollection::objectToggleField() +{ + return &m_showCurves; +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h new file mode 100644 index 0000000000..423479b553 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetCollection.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#pragma once + +#include "cafPdmChildArrayField.h" +#include "cafPdmChildField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +class RimEnsembleCurveSet; +class QwtPlot; +class QwtPlotCurve; + +//================================================================================================== +/// +//================================================================================================== +class RimEnsembleCurveSetCollection : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimEnsembleCurveSetCollection(); + virtual ~RimEnsembleCurveSetCollection(); + + bool isCurveSetsVisible(); + + void loadDataAndUpdate(bool updateParentPlot); + void setParentQwtPlotAndReplot(QwtPlot* plot); + void detachQwtCurves(); + + RimEnsembleCurveSet* findRimCurveSetFromQwtCurve(const QwtPlotCurve* qwtCurve) const; + + void addCurveSet(RimEnsembleCurveSet* curveSet); + void deleteCurveSet(RimEnsembleCurveSet* curveSet); + + std::vector curveSets() const; + size_t curveSetCount() const; + + void deleteAllCurveSets(); + + void setCurrentSummaryCurveSet(RimEnsembleCurveSet* curveSet); + +private: + caf::PdmFieldHandle* objectToggleField() override; + + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, const QVariant& newValue) override; + +private: + caf::PdmField m_showCurves; + caf::PdmChildArrayField m_curveSets; + + caf::PdmPointer m_currentEnsembleCurveSet; +}; + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp new file mode 100644 index 0000000000..715d78143f --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.cpp @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RimEnsembleCurveSetColorManager.h" +#include "RimEnsembleCurveSetCollection.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map RimEnsembleCurveSetColorManager::m_ensembleColorRanges( + { + { RimRegularLegendConfig::GREEN_RED, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0xff, 0x00), cvf::Color3ub(0xff, 0x00, 0x00) }) }, + { RimRegularLegendConfig::BLUE_MAGENTA, cvf::Color3ubArray({ cvf::Color3ub(0x00, 0x00, 0xff), cvf::Color3ub(0xff, 0x00, 0xff) }) }, + { RimRegularLegendConfig::RED_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xff, 0xcc, 0xcc), cvf::Color3ub(0x99, 0x00, 0x00) }) }, + { RimRegularLegendConfig::GREEN_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xff, 0xcc), cvf::Color3ub(0x00, 0x99, 0x00) }) }, + { RimRegularLegendConfig::BLUE_LIGHT_DARK, cvf::Color3ubArray({ cvf::Color3ub(0xcc, 0xcc, 0xff), cvf::Color3ub(0x00, 0x00, 0x99) }) } + }); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map& RimEnsembleCurveSetColorManager::EnsembleColorRanges() +{ + return m_ensembleColorRanges; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::DEFAULT_ENSEMBLE_COLOR_RANGE = RimRegularLegendConfig::GREEN_RED; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimRegularLegendConfig::ColorRangesType RimEnsembleCurveSetColorManager::cycledEnsembleColorRange(int index) +{ + size_t modIndex = index % m_ensembleColorRanges.size(); + + auto crIt = m_ensembleColorRanges.begin(); + for (int i = 0; i < static_cast(modIndex); ++i) ++crIt; + + return crIt->first; +} + +std::map RimEnsembleCurveSetColorManager::m_nextColorIndexes; + +std::map> RimEnsembleCurveSetColorManager::m_colorCache; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h new file mode 100644 index 0000000000..ca03e688c3 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/Summary/RimEnsembleCurveSetColorManager.h @@ -0,0 +1,54 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + + +#pragma once + +#include "RiaDefines.h" + +#include "RimRegularLegendConfig.h" +#include "RimEnsembleCurveSet.h" + +#include + +class RimEnsembleCurveSetCollection; + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RimEnsembleCurveSetColorManager +{ +public: + static const std::map& EnsembleColorRanges(); + + static const RimRegularLegendConfig::ColorRangesType DEFAULT_ENSEMBLE_COLOR_RANGE; + static RimRegularLegendConfig::ColorRangesType cycledEnsembleColorRange(int index); + + static bool isEnsembleColorRange(RimRegularLegendConfig::ColorRangesType colorRange) + { + return m_ensembleColorRanges.find(colorRange) != m_ensembleColorRanges.end(); + } + +private: + + static const std::map m_ensembleColorRanges; + + static std::map m_nextColorIndexes; + static std::map> m_colorCache; +}; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp index d8a34c1512..6d37600879 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.cpp @@ -41,7 +41,8 @@ CAF_PDM_SOURCE_INIT(RimFileSummaryCase,"FileSummaryCase"); //-------------------------------------------------------------------------------------------------- RimFileSummaryCase::RimFileSummaryCase() { - + CAF_PDM_InitField(&m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", ""); + m_includeRestartFiles.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -83,22 +84,17 @@ void RimFileSummaryCase::updateFilePathsFromProjectPath(const QString & newProje //-------------------------------------------------------------------------------------------------- void RimFileSummaryCase::createSummaryReaderInterface() { - m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename()); + m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), m_includeRestartFiles); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifReaderEclipseSummary* RimFileSummaryCase::findRelatedFilesAndCreateReader(const QString& headerFileName) +RifReaderEclipseSummary* RimFileSummaryCase::findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles) { - QString headerFileNameStd; - QStringList dataFileNames; - QString nativeSumHeadFileName = QDir::toNativeSeparators(headerFileName); - RifEclipseSummaryTools::findSummaryFiles(nativeSumHeadFileName, &headerFileNameStd, &dataFileNames); - RifReaderEclipseSummary* summaryFileReader = new RifReaderEclipseSummary; - if (!summaryFileReader->open(headerFileNameStd, dataFileNames)) + if (!summaryFileReader->open(headerFileName, includeRestartFiles)) { RiaLogging::warning(QString("Failed to open summary file %1").arg(headerFileName)); @@ -116,3 +112,11 @@ RifSummaryReaderInterface* RimFileSummaryCase::summaryReader() { return m_summaryFileReader.p(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFileSummaryCase::setIncludeRestartFiles(bool includeRestartFiles) +{ + m_includeRestartFiles = includeRestartFiles; +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h index 0b0be22fc7..8ba0c4680e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimFileSummaryCase.h @@ -20,7 +20,7 @@ #include "RimSummaryCase.h" #include "cvfObject.h" - +#include "cafPdmField.h" class RifReaderEclipseSummary; @@ -43,8 +43,11 @@ class RimFileSummaryCase: public RimSummaryCase virtual void createSummaryReaderInterface() override; virtual RifSummaryReaderInterface* summaryReader() override; - static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName); + void setIncludeRestartFiles(bool includeRestartFiles); + + static RifReaderEclipseSummary* findRelatedFilesAndCreateReader(const QString& headerFileName, bool includeRestartFiles); private: cvf::ref m_summaryFileReader; + caf::PdmField m_includeRestartFiles; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp index c43478b41e..987a545385 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.cpp @@ -51,6 +51,8 @@ RimGridSummaryCase::RimGridSummaryCase() m_eclipseGridFileName.uiCapability()->setUiReadOnly(true); m_eclipseGridFileName.xmlCapability()->setIOWritable(false); + CAF_PDM_InitField(&m_includeRestartFiles, "IncludeRestartFiles", false, "Include Restart Files", "", "", ""); + m_includeRestartFiles.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- @@ -175,7 +177,7 @@ void RimGridSummaryCase::updateFilePathsFromProjectPath(const QString & newProje //-------------------------------------------------------------------------------------------------- void RimGridSummaryCase::createSummaryReaderInterface() { - m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename()); + m_summaryFileReader = RimFileSummaryCase::findRelatedFilesAndCreateReader(this->summaryHeaderFilename(), m_includeRestartFiles); } //-------------------------------------------------------------------------------------------------- @@ -186,3 +188,22 @@ RifSummaryReaderInterface* RimGridSummaryCase::summaryReader() return m_summaryFileReader.p(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGridSummaryCase::setIncludeRestartFiles(bool includeRestartFiles) +{ + m_includeRestartFiles = includeRestartFiles; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFileSummaryCase* RimGridSummaryCase::createFileSummaryCaseCopy() +{ + RimFileSummaryCase* fileSummaryCase = new RimFileSummaryCase(); + fileSummaryCase->copyFrom(*this); + fileSummaryCase->setIncludeRestartFiles(m_includeRestartFiles()); + return fileSummaryCase; +} + diff --git a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h index cb9f594571..4242be37d8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimGridSummaryCase.h @@ -26,6 +26,7 @@ class RimEclipseCase; class RifReaderEclipseSummary; +class RimFileSummaryCase; //================================================================================================== // @@ -50,6 +51,9 @@ class RimGridSummaryCase : public RimSummaryCase virtual void createSummaryReaderInterface() override; virtual RifSummaryReaderInterface* summaryReader() override; + void setIncludeRestartFiles(bool includeRestartFiles); + + RimFileSummaryCase* createFileSummaryCaseCopy(); private: QString eclipseGridFileName() const; @@ -59,4 +63,5 @@ class RimGridSummaryCase : public RimSummaryCase caf::PdmProxyValueField m_eclipseGridFileName; cvf::ref m_summaryFileReader; + caf::PdmField m_includeRestartFiles; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp index e302d3b260..d0f6d8b149 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedDataCollection.cpp @@ -31,7 +31,8 @@ #include "RimObservedEclipseUserData.h" #include "RimSummaryObservedDataFile.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" +#include "RiuPlotMainWindow.h" #include "cafUtils.h" #include "cafPdmSettings.h" @@ -108,6 +109,18 @@ bool RimObservedDataCollection::fileExists(const QString& fileName, QString* err return true; } +void updateNewSummaryObjectCreated(caf::PdmObject* object) +{ + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(object); + RiuPlotMainWindowTools::setExpanded(object); + + caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + if (mpw) mpw->updateSummaryPlotToolBar(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -130,15 +143,10 @@ RimObservedData* RimObservedDataCollection::createAndAddRsmObservedDataFromFile( errorText->append(observedData->errorMessagesFromReader()); } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(observedData); - mainPlotWindow->setExpanded(observedData); - } + updateNewSummaryObjectCreated(observedData); this->updateConnectedEditors(); - caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + return observedData; } @@ -161,7 +169,7 @@ RimObservedData* RimObservedDataCollection::createAndAddCvsObservedDataFromFile( } parseOptions->setUiModeImport(fileName); - caf::PdmUiPropertyViewDialog propertyDialog(NULL, parseOptions, "CSV Import Options", ""); + caf::PdmUiPropertyViewDialog propertyDialog(nullptr, parseOptions, "CSV Import Options", ""); if (propertyDialog.exec() != QDialog::Accepted) { return nullptr; @@ -192,14 +200,9 @@ RimObservedData* RimObservedDataCollection::createAndAddCvsObservedDataFromFile( return nullptr; } - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); - if (mainPlotWindow) - { - mainPlotWindow->selectAsCurrentItem(userData); - mainPlotWindow->setExpanded(userData); - } + updateNewSummaryObjectCreated(observedData); this->updateConnectedEditors(); - caf::PdmUiObjectEditorHandle::updateUiAllObjectEditors(); + return observedData; } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp b/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp index bf0ad70b6e..c642ed5ed8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimObservedEclipseUserData.cpp @@ -39,7 +39,7 @@ CAF_PDM_SOURCE_INIT(RimObservedEclipseUserData, "RimObservedEclipseUserData"); //-------------------------------------------------------------------------------------------------- RimObservedEclipseUserData::RimObservedEclipseUserData() { - CAF_PDM_InitObject("Observed RSMSPEC Column Based Data File", ":/Default.png", "", ""); + CAF_PDM_InitObject("Observed RSMSPEC Column Based Data File", ":/ObservedRSMDataFile16x16.png", "", ""); m_summaryHeaderFilename.uiCapability()->setUiName("File"); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp index c9506375a0..82b66119b2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.cpp @@ -83,6 +83,7 @@ RimSummaryAxisProperties::RimSummaryAxisProperties() numberOfDecimals.uiCapability()->setUiEditorTypeName(caf::PdmUiSliderEditor::uiEditorTypeName()); + CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Set Range Automatically", "", "", ""); CAF_PDM_InitField(&isLogarithmicScaleEnabled, "LogarithmicScale", false, "Logarithmic Scale", "", "", ""); updateOptionSensitivity(); @@ -251,6 +252,22 @@ bool RimSummaryAxisProperties::showUnitText() const return m_displayUnitText(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryAxisProperties::isAutoZoom() const +{ + return m_isAutoZoom(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryAxisProperties::setAutoZoom(bool enableAutoZoom) +{ + m_isAutoZoom = enableAutoZoom; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -278,13 +295,13 @@ void RimSummaryAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* chang { if (visibleRangeMin > visibleRangeMax) visibleRangeMax = oldValue.toDouble(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &visibleRangeMin) { if (visibleRangeMin > visibleRangeMax) visibleRangeMin = oldValue.toDouble(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } if (changedField == &isLogarithmicScaleEnabled) diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h index 8b33b27e7b..2c56271a18 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryAxisProperties.h @@ -61,6 +61,8 @@ class RimSummaryAxisProperties : public caf::PdmObject bool showDescription() const; bool showAcronym() const; bool showUnitText() const; + bool isAutoZoom() const; + void setAutoZoom(bool enableAutoZoom); caf::PdmField customTitle; caf::PdmField titleFontSize; @@ -98,6 +100,7 @@ class RimSummaryAxisProperties : public caf::PdmObject caf::PdmField m_displayShortName; caf::PdmField m_displayLongName; caf::PdmField m_displayUnitText; + caf::PdmField m_isAutoZoom; caf::PdmField m_name; QwtPlot::Axis m_axis; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp index 1e5366d150..563c87501f 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.cpp @@ -25,6 +25,7 @@ #include "RimProject.h" #include "RimSummaryCaseMainCollection.h" #include "RimSummaryPlotCollection.h" +#include "RimSummaryCaseCollection.h" #include "cvfAssert.h" @@ -37,7 +38,7 @@ CAF_PDM_ABSTRACT_SOURCE_INIT(RimSummaryCase,"SummaryCase"); //-------------------------------------------------------------------------------------------------- RimSummaryCase::RimSummaryCase() { - CAF_PDM_InitObject("Summary Case",":/SummaryCase48x48.png","",""); + CAF_PDM_InitObject("Summary Case",":/SummaryCase16x16.png","",""); CAF_PDM_InitField(&m_shortName, "ShortName", QString("Display Name"), "Display Name", "", "", ""); CAF_PDM_InitField(&m_useAutoShortName, "AutoShortyName", false, "Use Auto Display Name", "", "", ""); @@ -83,6 +84,62 @@ bool RimSummaryCase::isObservedData() return m_isObservedData; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::setCaseRealizationParameters(const std::shared_ptr& crlParameters) +{ + m_crlParameters = crlParameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::shared_ptr RimSummaryCase::caseRealizationParameters() const +{ + return m_crlParameters; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCase::hasCaseRealizationParameters() const +{ + return m_crlParameters != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSummaryCaseCollection* RimSummaryCase::ensemble() const +{ + RimSummaryCaseCollection* e; + firstAncestorOrThisOfType(e); + return e; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryCase::isEnsembleCase() const +{ + return ensemble() != nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCase::copyFrom(const RimSummaryCase& rhs) +{ + m_shortName = rhs.m_shortName; + m_useAutoShortName = rhs.m_useAutoShortName; + m_summaryHeaderFilename = rhs.m_summaryHeaderFilename; + m_isObservedData = rhs.m_isObservedData; + + this->updateTreeItemName(); + this->updateOptionSensitivity(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -147,7 +204,7 @@ void RimSummaryCase::updateAutoShortName() { if(m_useAutoShortName) { - RimOilField* oilField = NULL; + RimOilField* oilField = nullptr; this->firstAncestorOrThisOfType(oilField); CVF_ASSERT(oilField); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h index ff7d9979de..44d661febd 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCase.h @@ -17,10 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////// #pragma once +#include "RigCaseRealizationParameters.h" + #include "cafPdmField.h" #include "cafPdmObject.h" +#include + class RifSummaryReaderInterface; +class RimSummaryCaseCollection; //================================================================================================== // @@ -52,6 +57,13 @@ class RimSummaryCase : public caf::PdmObject bool isObservedData(); + void setCaseRealizationParameters(const std::shared_ptr& crlParameters); + std::shared_ptr caseRealizationParameters() const; + bool hasCaseRealizationParameters() const; + RimSummaryCaseCollection* ensemble() const; + bool isEnsembleCase() const; + void copyFrom(const RimSummaryCase& rhs); + protected: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue); void updateTreeItemName(); @@ -60,6 +72,8 @@ class RimSummaryCase : public caf::PdmObject caf::PdmField m_useAutoShortName; caf::PdmField m_summaryHeaderFilename; bool m_isObservedData; + + std::shared_ptr m_crlParameters; private: virtual void initAfterRead() override; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp index 2dd30d41d9..6d962faaff 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.cpp @@ -1,82 +1,206 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017- Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RimSummaryCaseCollection.h" +#include "RimEnsembleCurveSet.h" #include "RimGridSummaryCase.h" #include "RimProject.h" #include "RimSummaryCase.h" -#include +#include "RifSummaryReaderInterface.h" -CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection,"SummaryCaseSubCollection"); +CAF_PDM_SOURCE_INIT(RimSummaryCaseCollection, "SummaryCaseSubCollection"); //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::RimSummaryCaseCollection() { - CAF_PDM_InitObject("Summary Case Group", ":/Folder.png", "", ""); + CAF_PDM_InitObject("Summary Case Group", ":/SummaryGroup16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", ""); m_cases.uiCapability()->setUiHidden(true); - CAF_PDM_InitField(&m_name, "SummaryCollectionName", QString("Case Group"), "Name", "", "", ""); + CAF_PDM_InitField(&m_name, "SummaryCollectionName", QString("Group"), "Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_nameAndItemCount, "NameCount", "Name", "", "", ""); + m_nameAndItemCount.registerGetMethod(this, &RimSummaryCaseCollection::nameAndItemCount); + m_nameAndItemCount.uiCapability()->setUiHidden(true); + m_nameAndItemCount.xmlCapability()->setIOWritable(false); + + CAF_PDM_InitField(&m_isEnsemble, "IsEnsemble", false, "Is Ensemble", "", "", ""); + m_isEnsemble.uiCapability()->setUiHidden(true); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RimSummaryCaseCollection::~RimSummaryCaseCollection() { m_cases.deleteAllChildObjects(); + updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::removeCase(RimSummaryCase* summaryCase) { m_cases.removeChildObject(summaryCase); + updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryCaseCollection::addCase(RimSummaryCase* summaryCase) { m_cases.push_back(summaryCase); + updateReferringCurveSets(); } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- std::vector RimSummaryCaseCollection::allSummaryCases() { return m_cases.childObjects(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::setName(const QString& name) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCaseCollection::name() const +{ + return m_name; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +bool RimSummaryCaseCollection::isEnsemble() const +{ + return m_isEnsemble(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::setAsEnsemble(bool isEnsemble) +{ + m_isEnsemble = isEnsemble; + updateIcon(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RimSummaryCaseCollection::calculateUnionOfSummaryAddresses() const +{ + std::set addressUnion; + + for (RimSummaryCase* currCase: m_cases) + { + if ( !currCase ) continue; + + RifSummaryReaderInterface* reader = currCase->summaryReader(); + + if ( !reader ) continue; + + const std::vector& readerAddresses = reader->allResultAddresses(); + addressUnion.insert(readerAddresses.begin(), readerAddresses.end()); + + } + + return addressUnion; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- caf::PdmFieldHandle* RimSummaryCaseCollection::userDescriptionField() { return &m_name; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::updateReferringCurveSets() const +{ + // Update curve set referring to this group + std::vector referringObjects; + objectsWithReferringPtrFields(referringObjects); + + for (PdmObjectHandle* obj : referringObjects) + { + RimEnsembleCurveSet* curveSet = dynamic_cast(obj); + if (curveSet) curveSet->updateAllCurves(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimSummaryCaseCollection::nameAndItemCount() const +{ + size_t itemCount = m_cases.size(); + if (itemCount > 20) + { + return QString("%1 (%2)").arg(m_name()).arg(itemCount); + } + + return m_name(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::updateIcon() +{ + if (m_isEnsemble) setUiIcon(QIcon(":/SummaryEnsemble16x16.png")); + else setUiIcon(QIcon(":/SummaryGroup16x16.png")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::initAfterRead() +{ + updateIcon(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseCollection::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) +{ + if (changedField == &m_isEnsemble) + { + updateIcon(); + } +} diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h index efae6f033d..7c35fa1b77 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseCollection.h @@ -1,25 +1,29 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2016- Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// + #pragma once +#include "RifEclipseSummaryAddress.h" + #include "cafPdmChildArrayField.h" #include "cafPdmField.h" #include "cafPdmObject.h" +#include "cafPdmProxyValueField.h" #include @@ -28,20 +32,31 @@ class RimSummaryCase; class RimSummaryCaseCollection : public caf::PdmObject { CAF_PDM_HEADER_INIT; + public: RimSummaryCaseCollection(); virtual ~RimSummaryCaseCollection(); - - void removeCase(RimSummaryCase* summaryCase); - void addCase(RimSummaryCase* summaryCase); + void removeCase(RimSummaryCase* summaryCase); + void addCase(RimSummaryCase* summaryCase); std::vector allSummaryCases(); - QString name() const { return m_name; } - + void setName(const QString& name); + QString name() const; + bool isEnsemble() const; + void setAsEnsemble(bool isEnsemble); + std::set calculateUnionOfSummaryAddresses() const; private: - virtual caf::PdmFieldHandle* userDescriptionField() override; + caf::PdmFieldHandle* userDescriptionField() override; + void updateReferringCurveSets() const; + QString nameAndItemCount() const; + void updateIcon(); + + virtual void initAfterRead() override; + virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) override; private: caf::PdmChildArrayField m_cases; caf::PdmField m_name; + caf::PdmProxyValueField m_nameAndItemCount; + caf::PdmField m_isEnsemble; }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp index e75b1d9797..45b2a78c0c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.cpp @@ -18,6 +18,8 @@ #include "RimSummaryCaseMainCollection.h" #include "RifEclipseSummaryTools.h" +#include "RifSummaryCaseRestartSelector.h" +#include "RifCaseRealizationParametersReader.h" #include "RimEclipseResultCase.h" #include "RimFileSummaryCase.h" @@ -28,16 +30,38 @@ #include "RimSummaryCaseCollection.h" #include +#include "cafProgressInfo.h" CAF_PDM_SOURCE_INIT(RimSummaryCaseMainCollection,"SummaryCaseCollection"); +//-------------------------------------------------------------------------------------------------- +/// Internal function +//-------------------------------------------------------------------------------------------------- +void addCaseRealizationParametersIfFound(RimSummaryCase& sumCase, const QString modelFolderOrFile) +{ + QString parametersFile = RifCaseRealizationParametersFileLocator::locate(modelFolderOrFile); + if (!parametersFile.isEmpty()) + { + RifCaseRealizationParametersReader reader(parametersFile); + + // Try parse case realization parameters + try + { + reader.parse(); + sumCase.setCaseRealizationParameters(reader.parameters()); + } + catch (...) {} + } + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RimSummaryCaseMainCollection::RimSummaryCaseMainCollection() { - CAF_PDM_InitObject("Summary Cases",":/Cases16x16.png","",""); + CAF_PDM_InitObject("Summary Cases",":/SummaryCases16x16.png","",""); CAF_PDM_InitFieldNoDefault(&m_cases, "SummaryCases", "", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_caseCollections, "SummaryCaseCollections", "", "", "", ""); @@ -58,56 +82,26 @@ RimSummaryCaseMainCollection::~RimSummaryCaseMainCollection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::createSummaryCasesFromRelevantEclipseResultCases() +RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclipseResultCase) const { - RimProject* proj = nullptr; - firstAncestorOrThisOfType(proj); - if (proj) + for (RimSummaryCase* summaryCase : m_cases) { - std::vector all3DCases; - proj->allCases(all3DCases); - for (RimCase* aCase: all3DCases) + RimGridSummaryCase* gridSummaryCase = dynamic_cast(summaryCase); + if (gridSummaryCase && gridSummaryCase->associatedEclipseCase()) { - RimEclipseResultCase* eclResCase = dynamic_cast(aCase); - if (eclResCase) + if (gridSummaryCase->associatedEclipseCase()->gridFileName() == eclipseResultCase->gridFileName()) { - // If we have no summary case corresponding to this eclipse case, - // try to create one. - bool isFound = false; - for (size_t scIdx = 0; scIdx < m_cases.size(); ++scIdx) - { - RimGridSummaryCase* grdSumCase = dynamic_cast(m_cases[scIdx]); - if (grdSumCase) - { - if (grdSumCase->associatedEclipseCase() == eclResCase) - { - isFound = true; - break; - } - } - } - - if (!isFound) - { - // Create new GridSummaryCase - createAndAddSummaryCaseFromEclipseResultCase(eclResCase); - } + return gridSummaryCase; } } } -} -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclipseResultCase) const -{ - for (RimSummaryCase* summaryCase : m_cases) + for (auto collection : m_caseCollections) { - RimGridSummaryCase* gridSummaryCase = dynamic_cast(summaryCase); - if (gridSummaryCase && gridSummaryCase->associatedEclipseCase()) + for (RimSummaryCase* sumCase : collection->allSummaryCases()) { - if (gridSummaryCase->associatedEclipseCase()->gridFileName() == eclipseResultCase->gridFileName()) + RimGridSummaryCase* gridSummaryCase = dynamic_cast(sumCase); + if (gridSummaryCase && gridSummaryCase->associatedEclipseCase()->gridFileName() == eclipseResultCase->gridFileName()) { return gridSummaryCase; } @@ -128,13 +122,27 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const for (RimSummaryCase* summaryCase : m_cases) { - RimFileSummaryCase* fileSummaryCase = dynamic_cast(summaryCase); - if (fileSummaryCase) + if (summaryCase) { - QFileInfo summaryFileInfo(fileSummaryCase->summaryHeaderFilename()); + QFileInfo summaryFileInfo(summaryCase->summaryHeaderFilename()); if (incomingFileInfo == summaryFileInfo) { - return fileSummaryCase; + return summaryCase; + } + } + } + + for (auto collection : m_caseCollections) + { + for (RimSummaryCase* summaryCase : collection->allSummaryCases()) + { + if (summaryCase) + { + QFileInfo summaryFileInfo(summaryCase->summaryHeaderFilename()); + if (incomingFileInfo == summaryFileInfo) + { + return summaryCase; + } } } } @@ -142,6 +150,44 @@ RimSummaryCase* RimSummaryCaseMainCollection::findSummaryCaseFromFileName(const return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::convertGridSummaryCasesToFileSummaryCases(RimGridSummaryCase* gridSummaryCase) +{ + RimFileSummaryCase* fileSummaryCase = gridSummaryCase->createFileSummaryCaseCopy(); + addCaseRealizationParametersIfFound(*fileSummaryCase, fileSummaryCase->summaryHeaderFilename()); + + RimSummaryCaseCollection* collection; + gridSummaryCase->firstAncestorOrThisOfType(collection); + + removeCase(gridSummaryCase); + delete gridSummaryCase; + + if (collection) + { + collection->addCase(fileSummaryCase); + collection->updateConnectedEditors(); + } + else + { + this->addCase(fileSummaryCase); + this->updateConnectedEditors(); + } + loadSummaryCaseData({ fileSummaryCase }); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryCaseMainCollection::addCases(const std::vector cases) +{ + for (RimSummaryCase* sumCase : cases) + { + addCase(sumCase); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -165,9 +211,11 @@ void RimSummaryCaseMainCollection::removeCase(RimSummaryCase* summaryCase) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCaseMainCollection::addCaseCollection(std::vector summaryCases) +void RimSummaryCaseMainCollection::addCaseCollection(std::vector summaryCases, const QString& collectionName, bool isEnsemble) { RimSummaryCaseCollection* summaryCaseCollection = new RimSummaryCaseCollection(); + if(!collectionName.isEmpty()) summaryCaseCollection->setName(collectionName); + summaryCaseCollection->setAsEnsemble(isEnsemble); for (RimSummaryCase* summaryCase : summaryCases) { @@ -255,43 +303,101 @@ std::vector RimSummaryCaseMainCollection::summaryCase //-------------------------------------------------------------------------------------------------- void RimSummaryCaseMainCollection::loadAllSummaryCaseData() { - for (RimSummaryCase* sumCase : allSummaryCases()) - { - if (sumCase) sumCase->createSummaryReaderInterface(); - } + std::vector sumCases = allSummaryCases(); + + RimSummaryCaseMainCollection::loadSummaryCaseData(sumCases); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) +void RimSummaryCaseMainCollection::loadSummaryCaseData(std::vector summaryCases) { - QString gridFileName = eclResCase->gridFileName(); - if(RifEclipseSummaryTools::hasSummaryFiles(QDir::toNativeSeparators(gridFileName))) + caf::ProgressInfo progInfo(summaryCases.size(), "Loading Summary Cases"); + + for (int cIdx = 0; cIdx < static_cast(summaryCases.size()); ++cIdx) { - RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); - this->m_cases.push_back(newSumCase); - newSumCase->setAssociatedEclipseCase(eclResCase); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); - return newSumCase; + RimSummaryCase* sumCase = summaryCases[cIdx]; + if (sumCase) + { + sumCase->createSummaryReaderInterface(); + addCaseRealizationParametersIfFound(*sumCase, sumCase->summaryHeaderFilename()); + } + + { + progInfo.incrementProgress(); + } } - return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryCaseMainCollection::createAndAddSummaryCaseFromFileName(const QString& fileName) +std::vector RimSummaryCaseMainCollection::createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos) +{ + std::vector newCases = createSummaryCasesFromFileInfos(summaryHeaderFileInfos); + addCases(newCases); + return newCases; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryCaseMainCollection::createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos, + bool showProgress) { - RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); + RimProject* project = RiaApplication::instance()->project(); + + std::vector sumCases; + + // Split into two stages to be able to use multi threading + // First stage : Create summary case objects + // Second stage : Load data + { + std::unique_ptr progress; + + if (showProgress) + { + progress.reset(new caf::ProgressInfo(summaryHeaderFileInfos.size(), "Creating summary cases")); + } + + for (const RifSummaryCaseFileResultInfo& fileInfo : summaryHeaderFileInfos) + { + RimEclipseCase* eclCase = nullptr; + QString gridCaseFile = RifEclipseSummaryTools::findGridCaseFileFromSummaryHeaderFile(fileInfo.summaryFileName()); + if (!gridCaseFile.isEmpty()) + { + eclCase = project->eclipseCaseFromGridFileName(gridCaseFile); + } + + RimGridSummaryCase* existingGridSummaryCase = dynamic_cast(findSummaryCaseFromFileName(fileInfo.summaryFileName())); + + if (eclCase && !existingGridSummaryCase) + { + RimGridSummaryCase* newSumCase = new RimGridSummaryCase(); + + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); + newSumCase->setAssociatedEclipseCase(eclCase); + newSumCase->updateOptionSensitivity(); + sumCases.push_back(newSumCase); + } + else + { + RimFileSummaryCase* newSumCase = new RimFileSummaryCase(); + + newSumCase->setIncludeRestartFiles(fileInfo.includeRestartFiles()); + newSumCase->setSummaryHeaderFileName(fileInfo.summaryFileName()); + newSumCase->updateOptionSensitivity(); + sumCases.push_back(newSumCase); + } + + if (progress != nullptr) progress->incrementProgress(); + } + } - this->m_cases.push_back(newSumCase); - newSumCase->setSummaryHeaderFileName(fileName); - newSumCase->createSummaryReaderInterface(); - newSumCase->updateOptionSensitivity(); + RimSummaryCaseMainCollection::loadSummaryCaseData(sumCases); - return newSumCase; + return sumCases; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h index d72c0720d8..45f837edd8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCaseMainCollection.h @@ -22,9 +22,11 @@ #include +class RimGridSummaryCase; class RimSummaryCase; class RimEclipseResultCase; class RimSummaryCaseCollection; +class RifSummaryCaseFileResultInfo; //================================================================================================== /// @@ -43,17 +45,18 @@ class RimSummaryCaseMainCollection : public caf::PdmObject std::vector topLevelSummaryCases() const; std::vector summaryCaseCollections() const; - void createSummaryCasesFromRelevantEclipseResultCases(); - RimSummaryCase* createAndAddSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase); - RimSummaryCase* createAndAddSummaryCaseFromFileName(const QString& fileName); - + std::vector createAndAddSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos); + std::vector createSummaryCasesFromFileInfos(const std::vector& summaryHeaderFileInfos, bool showProgress = false); + RimSummaryCase* findSummaryCaseFromEclipseResultCase(RimEclipseResultCase* eclResCase) const; RimSummaryCase* findSummaryCaseFromFileName(const QString& fileName) const; - + void convertGridSummaryCasesToFileSummaryCases(RimGridSummaryCase* gridSummaryCase); + + void addCases(const std::vector cases); void addCase(RimSummaryCase* summaryCase); void removeCase(RimSummaryCase* summaryCase); - void addCaseCollection(std::vector summaryCases); + void addCaseCollection(std::vector summaryCases, const QString& coolectionName, bool isEnsemble); void removeCaseCollection(RimSummaryCaseCollection* caseCollection); void loadAllSummaryCaseData(); @@ -62,6 +65,9 @@ class RimSummaryCaseMainCollection : public caf::PdmObject void updateFilePathsFromProjectPath(const QString& newProjectPath, const QString& oldProjectPath); +private: + static void loadSummaryCaseData(std::vector summaryCases); + private: caf::PdmChildArrayField m_cases; caf::PdmChildArrayField m_caseCollections; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp index 3ace690695..d50732f8c6 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlot.cpp @@ -26,7 +26,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryCrossPlot, "SummaryCrossPlot"); //-------------------------------------------------------------------------------------------------- RimSummaryCrossPlot::RimSummaryCrossPlot() { - CAF_PDM_InitObject("Summary Cross Plot", ":/SummaryPlotLight16x16.png", "", ""); + CAF_PDM_InitObject("Summary Cross Plot", ":/SummaryXPlotLight16x16.png", "", ""); setAsCrossPlot(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp index 88d3116d25..b1a519cdfc 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCrossPlotCollection.cpp @@ -29,7 +29,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryCrossPlotCollection, "SummaryCrossPlotCollection") //-------------------------------------------------------------------------------------------------- RimSummaryCrossPlotCollection::RimSummaryCrossPlotCollection() { - CAF_PDM_InitObject("Summary Cross Plots", ":/SummaryPlots16x16.png", "", ""); + CAF_PDM_InitObject("Summary Cross Plots", ":/SummaryXPlotsLight16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&m_summaryCrossPlots, "SummaryCrossPlots", "Summary Cross Plots", "", "", ""); m_summaryCrossPlots.uiCapability()->setUiHidden(true); @@ -89,6 +89,7 @@ void RimSummaryCrossPlotCollection::summaryPlotItemInfos(QListsetAsPlotMdiWindow(); plot->setDescription(QString("Summary Cross Plot %1").arg(m_summaryCrossPlots.size())); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index 0d0cfdefa0..fd52dbec7b 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -40,7 +40,7 @@ #include "RimTools.h" #include "RiuLineSegmentQwtPlotCurve.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuSummaryCurveDefSelectionDialog.h" #include "RiuSummaryQwtPlot.h" @@ -54,22 +54,6 @@ #include -// See also corresponding fake implementations in RimSummaryCurveFilter -QTextStream& operator << (QTextStream& str, const RifEclipseSummaryAddress& sobj) -{ - CVF_ASSERT(false); - return str; -} - -QTextStream& operator >> (QTextStream& str, RifEclipseSummaryAddress& sobj) -{ - CVF_ASSERT(false); - return str; -} - - - - CAF_PDM_SOURCE_INIT(RimSummaryCurve, "SummaryCurve"); //-------------------------------------------------------------------------------------------------- @@ -171,7 +155,7 @@ RimSummaryCurve::~RimSummaryCurve() //-------------------------------------------------------------------------------------------------- void RimSummaryCurve::setSummaryCaseY(RimSummaryCase* sumCase) { - m_yValuesSummaryCase = sumCase; + m_yValuesSummaryCase = sumCase; } //-------------------------------------------------------------------------------------------------- @@ -371,10 +355,20 @@ QString RimSummaryCurve::createCurveAutoName() RimSummaryPlot* plot = nullptr; firstAncestorOrThisOfTypeAsserted(plot); - QString curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), plot->activePlotTitleHelper()); + const RimSummaryPlotNameHelper* nameHelper = plot->activePlotTitleHelperAllCurves(); + QString curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), nameHelper); + if (curveName.isEmpty()) + { + curveName = m_curveNameConfig->curveNameY(m_yValuesCurveVariable->address(), nullptr); + } + if (isCrossPlotCurve()) { - QString curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), plot->activePlotTitleHelper()); + QString curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), nameHelper); + if (curveNameX.isEmpty()) + { + curveNameX = m_curveNameConfig->curveNameX(m_xValuesCurveVariable->address(), nullptr); + } if (!curveName.isEmpty() || !curveNameX.isEmpty()) { @@ -382,6 +376,11 @@ QString RimSummaryCurve::createCurveAutoName() } } + if (curveName.isEmpty()) + { + curveName = "Curve Name Placeholder"; + } + return curveName; } @@ -669,7 +668,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, plot->updatePlotTitle(); plot->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } else if (changedField == &m_plotAxis) @@ -699,6 +698,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, candicateAddress = m_xValuesCurveVariable->address(); } + dlg.hideEnsembles(); dlg.setCaseAndAddress(candidateCase, candicateAddress); if (dlg.exec() == QDialog::Accepted) @@ -732,6 +732,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, candicateAddress = m_yValuesCurveVariable->address(); } + dlg.hideEnsembles(); dlg.setCaseAndAddress(candidateCase, candicateAddress); if (dlg.exec() == QDialog::Accepted) @@ -800,7 +801,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, .arg(last.toString(formatString)); } - QMessageBox::warning(NULL, "Detected no overlapping time steps", description); + QMessageBox::warning(nullptr, "Detected no overlapping time steps", description); } } } @@ -813,7 +814,7 @@ void RimSummaryCurve::fieldChangedByUi(const caf::PdmFieldHandle* changedField, plot->updatePlotTitle(); plot->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h index f356d0bdfa..43a745edd8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurve.h @@ -76,7 +76,6 @@ class RimSummaryCurve : public RimPlotCurve protected: // RimPlotCurve overrides - virtual QString createCurveAutoName() override; virtual void updateZoomInParentPlot() override; virtual void onLoadDataAndUpdate(bool updateParentPlot) override; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp index 44092c21d9..e28dcbcc22 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.cpp @@ -91,14 +91,7 @@ RimSummaryCurveAppearanceCalculator::RimSummaryCurveAppearanceCalculator(const s } } - m_caseCount = m_caseToAppearanceIdxMap.size(); - m_variableCount = m_varToAppearanceIdxMap .size(); - m_wellCount = m_welToAppearanceIdxMap .size(); - m_groupCount = m_grpToAppearanceIdxMap .size(); - m_regionCount = m_regToAppearanceIdxMap .size(); - // Select the default appearance type for each data "dimension" - m_caseAppearanceType = NONE; m_varAppearanceType = NONE; m_wellAppearanceType = NONE; @@ -114,11 +107,11 @@ RimSummaryCurveAppearanceCalculator::RimSummaryCurveAppearanceCalculator(const s m_currentCurveGradient = 0.0f; m_dimensionCount = 0; - if(m_variableCount > 1) { m_varAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_caseCount > 1) { m_caseAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_wellCount > 1) { m_wellAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_groupCount > 1) { m_groupAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } - if(m_regionCount > 1) { m_regionAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_varToAppearanceIdxMap.size() > 1) { m_varAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_caseToAppearanceIdxMap.size() > 1) { m_caseAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_welToAppearanceIdxMap.size() > 1) { m_wellAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_grpToAppearanceIdxMap.size() > 1) { m_groupAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } + if(m_regToAppearanceIdxMap.size() > 1) { m_regionAppearanceType = *(unusedAppearTypes.begin()); unusedAppearTypes.erase(unusedAppearTypes.begin()); m_dimensionCount++; } if (m_dimensionCount == 0) m_varAppearanceType = COLOR; // basically one curve @@ -291,7 +284,9 @@ void RimSummaryCurveAppearanceCalculator::getDimensions(CurveAppearanceType* cas //-------------------------------------------------------------------------------------------------- void RimSummaryCurveAppearanceCalculator::setupCurveLook(RimSummaryCurve* curve) { - m_currentCurveBaseColor = cvf::Color3f(0, 0, 0); + // The gradient is from negative to positive. + // Choose default base color as the midpoint between black and white. + m_currentCurveBaseColor = cvf::Color3f(0.5f, 0.5f, 0.5f); m_currentCurveGradient = 0.0f; int caseAppearanceIdx = m_caseToAppearanceIdxMap[curve->summaryCaseY()]; @@ -305,10 +300,10 @@ void RimSummaryCurveAppearanceCalculator::setupCurveLook(RimSummaryCurve* curve) if(curve->summaryAddressY().wellGroupName().empty()) grpAppearanceIdx = -1; if(curve->summaryAddressY().regionNumber() < 0) regAppearanceIdx = -1; - setOneCurveAppearance(m_caseAppearanceType, m_caseCount, caseAppearanceIdx, curve); - setOneCurveAppearance(m_wellAppearanceType, m_wellCount, welAppearanceIdx, curve); - setOneCurveAppearance(m_groupAppearanceType, m_groupCount, grpAppearanceIdx, curve); - setOneCurveAppearance(m_regionAppearanceType, m_regionCount, regAppearanceIdx, curve); + setOneCurveAppearance(m_caseAppearanceType, m_allSummaryCaseNames.size(), caseAppearanceIdx, curve); + setOneCurveAppearance(m_wellAppearanceType, m_allSummaryWellNames.size(), welAppearanceIdx, curve); + setOneCurveAppearance(m_groupAppearanceType, m_grpToAppearanceIdxMap.size(), grpAppearanceIdx, curve); + setOneCurveAppearance(m_regionAppearanceType, m_regToAppearanceIdxMap.size(), regAppearanceIdx, curve); if (m_varAppearanceType == COLOR && m_secondCharToVarToAppearanceIdxMap.size() > 1) { @@ -353,7 +348,7 @@ void RimSummaryCurveAppearanceCalculator::setupCurveLook(RimSummaryCurve* curve) } else { - setOneCurveAppearance(m_varAppearanceType, m_variableCount, varAppearanceIdx, curve); + setOneCurveAppearance(m_varAppearanceType, m_varToAppearanceIdxMap.size(), varAppearanceIdx, curve); } curve->setColor(gradeColor(m_currentCurveBaseColor, m_currentCurveGradient)); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h index 6df22d8b2b..0980661538 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAppearanceCalculator.h @@ -67,6 +67,8 @@ class RimSummaryCurveAppearanceCalculator static RimPlotCurve::PointSymbolEnum cycledSymbol(int index); private: + template + int findMaxApperanceIndexInMap(const std::map& mapToSearch) const; void setOneCurveAppearance(CurveAppearanceType appeaType, size_t totalCount, int appeaIdx, RimSummaryCurve* curve); void updateApperanceIndices(); std::map mapNameToAppearanceIndex(CurveAppearanceType & appearance, const std::set& names); @@ -81,11 +83,6 @@ class RimSummaryCurveAppearanceCalculator cvf::Color3f m_currentCurveBaseColor; float m_currentCurveGradient; - size_t m_caseCount; - size_t m_variableCount; - size_t m_wellCount; - size_t m_groupCount; - size_t m_regionCount; int m_dimensionCount; CurveAppearanceType m_caseAppearanceType; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp index 0bd7b9f400..8a84b18399 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveAutoName.cpp @@ -20,7 +20,9 @@ #include "RifEclipseSummaryAddress.h" +#include "RimEnsembleCurveSet.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" #include "RimSummaryCurve.h" #include "RimSummaryPlotNameHelper.h" @@ -48,7 +50,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() CAF_PDM_InitField(&m_completion, "Completion", true, "I, J, K", "", "", ""); CAF_PDM_InitField(&m_aquiferNumber, "Aquifer", true, "Aquifer Number", "", "", ""); - CAF_PDM_InitField(&m_caseName, "CaseName", true, "Case Name", "", "", ""); + CAF_PDM_InitField(&m_caseName, "CaseName", true, "Case/Ensemble Name", "", "", ""); // clang-format on } @@ -57,7 +59,7 @@ RimSummaryCurveAutoName::RimSummaryCurveAutoName() /// //-------------------------------------------------------------------------------------------------- QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summaryAddress, - const RimSummaryPlotNameHelper* nameHelper) const + const RimSummaryPlotNameHelper* nameHelper) const { std::string text; @@ -80,17 +82,30 @@ QString RimSummaryCurveAutoName::curveNameY(const RifEclipseSummaryAddress& summ appendAddressDetails(text, summaryAddress, nameHelper); - if (summaryCurve) + QString caseName; + + { + RimEnsembleCurveSet* ensembleCurveSet = nullptr; + this->firstAncestorOrThisOfType(ensembleCurveSet); + if (ensembleCurveSet && ensembleCurveSet->summaryCaseCollection()) + { + caseName = ensembleCurveSet->summaryCaseCollection()->name(); + } + } + + if (caseName.isEmpty() && summaryCurve && summaryCurve->summaryCaseY()) + { + caseName = summaryCurve->summaryCaseY()->caseName(); + } + + if (!caseName.isEmpty()) { bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); if (m_caseName && !skipSubString) { - if (summaryCurve && summaryCurve->summaryCaseY()) - { - if (text.size() > 0) text += ", "; - text += summaryCurve->summaryCaseY()->caseName().toStdString(); - } + if (!text.empty()) text += ", "; + text += caseName.toStdString(); } } @@ -124,16 +139,18 @@ QString RimSummaryCurveAutoName::curveNameX(const RifEclipseSummaryAddress& summ appendAddressDetails(text, summaryAddress, nameHelper); - if (summaryCurve) + if (summaryCurve && summaryCurve->summaryCaseX()) { + QString caseName = summaryCurve->summaryCaseX()->caseName(); + bool skipSubString = nameHelper && nameHelper->isCaseInTitle(); if (m_caseName && !skipSubString) { if (summaryCurve && summaryCurve->summaryCaseX()) { - if (text.size() > 0) text += ", "; - text += summaryCurve->summaryCaseX()->caseName().toStdString(); + if (!text.empty()) text += ", "; + text += caseName.toStdString(); } } } @@ -161,7 +178,8 @@ void RimSummaryCurveAutoName::applySettings(const RimSummaryCurveAutoName& other //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipseSummaryAddress& summaryAddress, +void RimSummaryCurveAutoName::appendWellName(std::string& text, + const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const { bool skipSubString = nameHelper && nameHelper->isWellNameInTitle(); @@ -169,7 +187,7 @@ void RimSummaryCurveAutoName::appendWellName(std::string& text, const RifEclipse if (m_wellName) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += summaryAddress.wellName(); } } @@ -181,7 +199,7 @@ void RimSummaryCurveAutoName::appendLgrName(std::string& text, const RifEclipseS { if (m_lgrName) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += ":" + summaryAddress.lgrName(); } } @@ -189,7 +207,8 @@ void RimSummaryCurveAutoName::appendLgrName(std::string& text, const RifEclipseS //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifEclipseSummaryAddress& summaryAddress, +void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, + const RifEclipseSummaryAddress& summaryAddress, const RimSummaryPlotNameHelper* nameHelper) const { switch (summaryAddress.category()) @@ -198,7 +217,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE { if (m_aquiferNumber) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.aquiferNumber()); } } @@ -210,7 +229,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE bool skipSubString = nameHelper && nameHelper->isRegionInTitle(); if (!skipSubString) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.regionNumber()); } } @@ -220,7 +239,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE { if (m_regionNumber) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.regionNumber()); text += "-" + std::to_string(summaryAddress.regionNumber2()); } @@ -233,13 +252,15 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE bool skipSubString = nameHelper && nameHelper->isWellGroupNameInTitle(); if (!skipSubString) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += summaryAddress.wellGroupName(); } } } break; - case RifEclipseSummaryAddress::SUMMARY_WELL: { appendWellName(text, summaryAddress, nameHelper); + case RifEclipseSummaryAddress::SUMMARY_WELL: + { + appendWellName(text, summaryAddress, nameHelper); } break; case RifEclipseSummaryAddress::SUMMARY_WELL_COMPLETION: @@ -248,7 +269,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -267,7 +288,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -279,7 +300,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_wellSegmentNumber) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += ":" + summaryAddress.wellSegmentNumber(); } } @@ -288,7 +309,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE { if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -300,7 +321,7 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE if (m_completion) { - if (text.size() > 0) text += ":"; + if (!text.empty()) text += ":"; text += std::to_string(summaryAddress.cellI()) + ", " + std::to_string(summaryAddress.cellJ()) + ", " + std::to_string(summaryAddress.cellK()); } @@ -312,8 +333,9 @@ void RimSummaryCurveAutoName::appendAddressDetails(std::string& text, const RifE //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, - const QVariant& newValue) +void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue) { // NOTE: The curve filter is parent object of a summary curve, and the update is supposed to update // the first parent, not the grandparent. This is the reason for not using firstAncestorOrThisOfType() @@ -323,6 +345,8 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change { summaryCurve->updateCurveNameAndUpdatePlotLegend(); summaryCurve->updateConnectedEditors(); + + return; } RicSummaryCurveCreator* curveCreator = dynamic_cast(this->parentField()->ownerObject()); @@ -330,6 +354,19 @@ void RimSummaryCurveAutoName::fieldChangedByUi(const caf::PdmFieldHandle* change { curveCreator->updateCurveNames(); curveCreator->updateConnectedEditors(); + + return; + } + + { + auto ensembleCurveSet = dynamic_cast(this->parentField()->ownerObject()); + if (ensembleCurveSet) + { + ensembleCurveSet->updateAllTextInPlot(); + ensembleCurveSet->updateConnectedEditors(); + + return; + } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp index e8a7c4670e..42ec50d008 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.cpp @@ -107,6 +107,7 @@ void RimSummaryCurveCollection::loadDataAndUpdate(bool updateParentPlot) firstAncestorOrThisOfTypeAsserted(parentPlot); if ( parentPlot->qwtPlot() ) { + parentPlot->updatePlotTitle(); parentPlot->qwtPlot()->updateLegend(); parentPlot->updateAxes(); parentPlot->updateZoomInQwt(); @@ -151,7 +152,7 @@ RimSummaryCurve* RimSummaryCurveCollection::findRimCurveFromQwtCurve(const QwtPl } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -174,6 +175,7 @@ void RimSummaryCurveCollection::deleteCurve(RimSummaryCurve* curve) { m_curves.removeChildObject(curve); delete curve; + updateCaseNameHasChanged(); } } @@ -185,24 +187,6 @@ std::vector RimSummaryCurveCollection::curves() const return m_curves.childObjects(); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RimSummaryCurveCollection::visibleCurves() const -{ - std::vector visible; - - for (auto c : m_curves) - { - if (c->isCurveVisible()) - { - visible.push_back(c); - } - } - - return visible; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -249,6 +233,8 @@ void RimSummaryCurveCollection::updateCaseNameHasChanged() RimSummaryPlot* parentPlot; firstAncestorOrThisOfTypeAsserted(parentPlot); + + parentPlot->updatePlotTitle(); if (parentPlot->qwtPlot()) parentPlot->qwtPlot()->updateLegend(); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h index d53c1c9682..a1c2fd89ec 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurveCollection.h @@ -55,7 +55,6 @@ class RimSummaryCurveCollection : public caf::PdmObject void deleteCurve(RimSummaryCurve* curve); std::vector curves() const; - std::vector visibleCurves() const; void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); void deleteAllCurves(); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp index 37cba228b0..19f1259b38 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryCurvesCalculator.cpp @@ -37,11 +37,11 @@ #include //-------------------------------------------------------------------------------------------------- -// e format as [-]9.9e[+|-]999 -// E format as[-]9.9E[+| -]999 -// f format as[-]9.9 -// g use e or f format, whichever is the most concise -// G use E or f format, whichever is the most concise +// e format as [-]9.9e[+|-]999 +// E format as[-]9.9E[+| -]999 +// f format as[-]9.9 +// g use e or f format, whichever is the most concise +// G use E or f format, whichever is the most concise //-------------------------------------------------------------------------------------------------- class DecimalScaleDraw : public QwtScaleDraw diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp index c698969c9c..cfe28fde9e 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryObservedDataFile.cpp @@ -31,7 +31,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryObservedDataFile, "SummaryObservedDataFile"); //-------------------------------------------------------------------------------------------------- RimSummaryObservedDataFile::RimSummaryObservedDataFile() { - CAF_PDM_InitObject("Observed data file", ":/Default.png", "", ""); + CAF_PDM_InitObject("Observed data file", ":/ObservedDataFile16x16.png", "", ""); m_summaryHeaderFilename.uiCapability()->setUiName("File"); } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp index d4a0725535..6947a80619 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.cpp @@ -21,20 +21,24 @@ #include "RiaApplication.h" #include "RiaSummaryCurveAnalyzer.h" +#include "SummaryPlotCommands/RicSummaryCurveCreator.h" + #include "RimAsciiDataCurve.h" +#include "RimEnsembleCurveSet.h" #include "RimGridTimeHistoryCurve.h" #include "RimProject.h" #include "RimSummaryAxisProperties.h" #include "RimSummaryCase.h" #include "RimSummaryCurve.h" #include "RimSummaryCurveCollection.h" +#include "RimEnsembleCurveSetCollection.h" #include "RimSummaryCurveFilter.h" #include "RimSummaryCurvesCalculator.h" #include "RimSummaryPlotCollection.h" #include "RimSummaryPlotNameHelper.h" #include "RimSummaryTimeAxisProperties.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuSummaryQwtPlot.h" #include "cvfBase.h" @@ -79,11 +83,16 @@ RimSummaryPlot::RimSummaryPlot() CAF_PDM_InitFieldNoDefault(&m_curveFilters_OBSOLETE, "SummaryCurveFilters", "", "", "", ""); m_curveFilters_OBSOLETE.uiCapability()->setUiTreeHidden(true); - CAF_PDM_InitFieldNoDefault(&m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_summaryCurveCollection, "SummaryCurveCollection", "", "", "", ""); m_summaryCurveCollection.uiCapability()->setUiTreeHidden(true); m_summaryCurveCollection = new RimSummaryCurveCollection; - CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); + CAF_PDM_InitFieldNoDefault(&m_ensembleCurveSetCollection, "EnsembleCurveSetCollection", "", "", "", ""); + m_ensembleCurveSetCollection.uiCapability()->setUiTreeHidden(true); + m_ensembleCurveSetCollection.uiCapability()->setUiHidden(true); + m_ensembleCurveSetCollection = new RimEnsembleCurveSetCollection(); + + CAF_PDM_InitFieldNoDefault(&m_summaryCurves_OBSOLETE, "SummaryCurves", "", "", "", ""); m_summaryCurves_OBSOLETE.uiCapability()->setUiTreeHidden(true); CAF_PDM_InitFieldNoDefault(&m_gridTimeHistoryCurves, "GridTimeHistoryCurves", "", "", "", ""); @@ -111,14 +120,13 @@ RimSummaryPlot::RimSummaryPlot() m_timeAxisProperties.uiCapability()->setUiTreeHidden(true); m_timeAxisProperties = new RimSummaryTimeAxisProperties; - CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Auto Zoom", "", "", ""); - m_isAutoZoom.uiCapability()->setUiHidden(true); - - setAsPlotMdiWindow(); + CAF_PDM_InitField(&m_isAutoZoom_OBSOLETE, "AutoZoom", true, "Auto Zoom", "", "", ""); + m_isAutoZoom_OBSOLETE.uiCapability()->setUiHidden(true); + m_isAutoZoom_OBSOLETE.xmlCapability()->setIOWritable(false); m_isCrossPlot = false; - m_nameHelper.reset(new RimSummaryPlotNameHelper); + m_nameHelperAllCurves.reset(new RimSummaryPlotNameHelper); } //-------------------------------------------------------------------------------------------------- @@ -133,6 +141,7 @@ RimSummaryPlot::~RimSummaryPlot() m_summaryCurves_OBSOLETE.deleteAllChildObjects(); m_curveFilters_OBSOLETE.deleteAllChildObjects(); delete m_summaryCurveCollection; + delete m_ensembleCurveSetCollection; } //-------------------------------------------------------------------------------------------------- @@ -143,8 +152,6 @@ void RimSummaryPlot::updateAxes() updateAxis(RiaDefines::PLOT_AXIS_LEFT); updateAxis(RiaDefines::PLOT_AXIS_RIGHT); - updateZoomInQwt(); - if (m_isCrossPlot) { updateBottomXAxis(); @@ -153,6 +160,8 @@ void RimSummaryPlot::updateAxes() { updateTimeAxis(); } + + updateZoomInQwt(); } //-------------------------------------------------------------------------------------------------- @@ -176,24 +185,24 @@ RimSummaryTimeAxisProperties* RimSummaryPlot::timeAxisProperties() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::selectAxisInPropertyEditor(int axis) { - RiuMainPlotWindow* plotwindow = RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); + RiuPlotMainWindowTools::showPlotMainWindow(); if (axis == QwtPlot::yLeft) { - plotwindow->selectAsCurrentItem(m_leftYAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_leftYAxisProperties); } else if (axis == QwtPlot::yRight) { - plotwindow->selectAsCurrentItem(m_rightYAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_rightYAxisProperties); } else if (axis == QwtPlot::xBottom) { if (m_isCrossPlot) { - plotwindow->selectAsCurrentItem(m_bottomAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_bottomAxisProperties); } else { - plotwindow->selectAsCurrentItem(m_timeAxisProperties); + RiuPlotMainWindowTools::selectAsCurrentItem(m_timeAxisProperties); } } } @@ -458,6 +467,23 @@ QString RimSummaryPlot::asciiDataForPlotExport() const return out; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimSummaryPlot::summaryAndEnsembleCurves() const +{ + std::vector curves = summaryCurves(); + + for (const auto& curveSet : ensembleCurveSetCollection()->curveSets()) + { + for (const auto& curve : curveSet->curves()) + { + curves.push_back(curve); + } + } + return curves; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -495,24 +521,25 @@ RiuSummaryQwtPlot* RimSummaryPlot::qwtPlot() const //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updatePlotTitle() { + updateNameHelperWithCurveData(m_nameHelperAllCurves.get()); + if (m_useAutoPlotTitle) { - m_userDefinedPlotTitle = generatePlotTitle(m_nameHelper.get()); - - updateCurveNames(); + m_userDefinedPlotTitle = m_nameHelperAllCurves->plotTitle(); } - + + updateCurveNames(); updateMdiWindowTitle(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelper() const +const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelperAllCurves() const { if (m_useAutoPlotTitle()) { - return m_nameHelper.get(); + return m_nameHelperAllCurves.get(); } return nullptr; @@ -521,11 +548,11 @@ const RimSummaryPlotNameHelper* RimSummaryPlot::activePlotTitleHelper() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::generatedPlotTitleFromVisibleCurves() const +QString RimSummaryPlot::generatedPlotTitleFromAllCurves() const { RimSummaryPlotNameHelper nameHelper; - - return generatePlotTitle(&nameHelper); + updateNameHelperWithCurveData(&nameHelper); + return nameHelper.plotTitle(); } //-------------------------------------------------------------------------------------------------- @@ -592,43 +619,79 @@ void RimSummaryPlot::updateAxis(RiaDefines::PlotAxis plotAxis) //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateZoomForAxis(RiaDefines::PlotAxis plotAxis) { - RimSummaryAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis); - - if (yAxisProps->isLogarithmicScaleEnabled) + if (plotAxis == RiaDefines::PLOT_AXIS_BOTTOM) { - std::vector yValues; - std::vector plotCurves; - - for (RimSummaryCurve* c : visibleSummaryCurvesForAxis(plotAxis)) + if (m_isCrossPlot) { - std::vector curveValues = c->valuesY(); - yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); - plotCurves.push_back(c->qwtPlotCurve()); + if (m_bottomAxisProperties->isAutoZoom()) + { + m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true); + } + else + { + m_qwtPlot->setAxisScale(QwtPlot::xBottom, m_bottomAxisProperties->visibleRangeMin(), m_bottomAxisProperties->visibleRangeMax()); + } } - - for (RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis(plotAxis)) + else { - std::vector curveValues = c->yValues(); - yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); - plotCurves.push_back(c->qwtPlotCurve()); - } + if (m_timeAxisProperties->isAutoZoom()) + { + m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true); + } + else + { + m_qwtPlot->setAxisScale(QwtPlot::xBottom, m_timeAxisProperties->visibleRangeMin(), m_timeAxisProperties->visibleRangeMax()); + } - for (RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis(plotAxis)) - { - std::vector curveValues = c->yValues(); - yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); - plotCurves.push_back(c->qwtPlotCurve()); } - - double min, max; - RimSummaryPlotYAxisRangeCalculator calc(plotCurves, yValues); - calc.computeYRange(&min, &max); - - m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), min, max); } else { - m_qwtPlot->setAxisAutoScale(yAxisProps->qwtPlotAxisType(), true); + RimSummaryAxisProperties* yAxisProps = yAxisPropertiesLeftOrRight(plotAxis); + + if (yAxisProps->isAutoZoom()) + { + if (yAxisProps->isLogarithmicScaleEnabled) + { + std::vector yValues; + std::vector plotCurves; + + for (RimSummaryCurve* c : visibleSummaryCurvesForAxis(plotAxis)) + { + std::vector curveValues = c->valuesY(); + yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); + plotCurves.push_back(c->qwtPlotCurve()); + } + + for (RimGridTimeHistoryCurve* c : visibleTimeHistoryCurvesForAxis(plotAxis)) + { + std::vector curveValues = c->yValues(); + yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); + plotCurves.push_back(c->qwtPlotCurve()); + } + + for (RimAsciiDataCurve* c : visibleAsciiDataCurvesForAxis(plotAxis)) + { + std::vector curveValues = c->yValues(); + yValues.insert(yValues.end(), curveValues.begin(), curveValues.end()); + plotCurves.push_back(c->qwtPlotCurve()); + } + + double min, max; + RimSummaryPlotYAxisRangeCalculator calc(plotCurves, yValues); + calc.computeYRange(&min, &max); + + m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), min, max); + } + else + { + m_qwtPlot->setAxisAutoScale(yAxisProps->qwtPlotAxisType(), true); + } + } + else + { + m_qwtPlot->setAxisScale(yAxisProps->qwtPlotAxisType(), yAxisProps->visibleRangeMin(), yAxisProps->visibleRangeMax()); + } } } @@ -664,6 +727,20 @@ std::vector RimSummaryPlot::visibleSummaryCurvesForAxis(RiaDef } } } + + if (m_ensembleCurveSetCollection && m_ensembleCurveSetCollection->isCurveSetsVisible()) + { + for (RimEnsembleCurveSet* curveSet : m_ensembleCurveSetCollection->curveSets()) + { + for (RimSummaryCurve* curve : curveSet->curves()) + { + if (curve->isCurveVisible() && curve->axisY() == plotAxis) + { + curves.push_back(curve); + } + } + } + } } return curves; @@ -854,53 +931,15 @@ void RimSummaryPlot::updateCaseNameHasChanged() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInterval& rightAxis, const QwtInterval& timeAxis) -{ - m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue(); - m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue(); - m_leftYAxisProperties->updateConnectedEditors(); - - m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue(); - m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue(); - m_rightYAxisProperties->updateConnectedEditors(); - - if (m_isCrossPlot) - { - m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue(); - m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue(); - m_bottomAxisProperties->updateConnectedEditors(); - } - else - { - m_timeAxisProperties->setVisibleRangeMin(timeAxis.minValue()); - m_timeAxisProperties->setVisibleRangeMax(timeAxis.maxValue()); - m_timeAxisProperties->updateConnectedEditors(); - } - - disableAutoZoom(); -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::zoomAll() { - if (m_qwtPlot) - { - m_qwtPlot->setAxisAutoScale(QwtPlot::xBottom, true); - - updateZoomForAxis(RiaDefines::PLOT_AXIS_LEFT); - updateZoomForAxis(RiaDefines::PLOT_AXIS_RIGHT); - - m_qwtPlot->replot(); - } - - updateZoomWindowFromQwt(); + setAutoZoomForAllAxes(true); + updateZoomInQwt(); + updateAxisRangesFromQwt(); - m_isAutoZoom = true; } //-------------------------------------------------------------------------------------------------- @@ -936,7 +975,6 @@ void RimSummaryPlot::addCurveNoUpdate(RimSummaryCurve* curve) } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -946,7 +984,36 @@ void RimSummaryPlot::deleteCurve(RimSummaryCurve* curve) { if (m_summaryCurveCollection) { - m_summaryCurveCollection->deleteCurve(curve); + for (auto& c : m_summaryCurveCollection->curves()) + { + if (c == curve) + { + m_summaryCurveCollection->deleteCurve(curve); + return; + } + } + } + if (m_ensembleCurveSetCollection) + { + for (auto& curveSet : m_ensembleCurveSetCollection->curveSets()) + { + for (auto& c : curveSet->curves()) + { + if (c == curve) + { + curveSet->deleteCurve(curve); + if (curveSet->curves().empty()) + { + if (curveSet->colorMode() == RimEnsembleCurveSet::BY_ENSEMBLE_PARAM) + { + qwtPlot()->removeEnsembleCurveSetLegend(curveSet); + } + m_ensembleCurveSetCollection->deleteCurveSet(curveSet); + } + return; + } + } + } } } } @@ -962,6 +1029,14 @@ void RimSummaryPlot::deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase) } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEnsembleCurveSetCollection* RimSummaryPlot::ensembleCurveSetCollection() const +{ + return m_ensembleCurveSetCollection; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -969,6 +1044,9 @@ void RimSummaryPlot::setCurveCollection(RimSummaryCurveCollection* curveCollecti { if (curveCollection) { + // Delete current curve coll ? + + m_summaryCurveCollection = curveCollection; if (m_qwtPlot) { @@ -1078,6 +1156,8 @@ void RimSummaryPlot::fieldChangedByUi(const caf::PdmFieldHandle* changedField, c //-------------------------------------------------------------------------------------------------- QImage RimSummaryPlot::snapshotWindowContent() { +#if 0 +// This does not work with the color legend widgets. Is there a reason for doing this, and not to grab the widget ? QImage image; if (m_qwtPlot) @@ -1092,6 +1172,16 @@ QImage RimSummaryPlot::snapshotWindowContent() plotRenderer.render(m_qwtPlot, &painter, rect); } + return image; + #endif + QImage image; + + if (m_qwtPlot) + { + QPixmap pix = QPixmap::grabWidget(m_qwtPlot); + image = pix.toImage(); + } + return image; } @@ -1100,22 +1190,37 @@ QImage RimSummaryPlot::snapshotWindowContent() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::defineUiTreeOrdering(caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName /*= ""*/) { - caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add("Axes", ":/Axes16x16.png"); - - if (m_isCrossPlot) + if (uiConfigName == RicSummaryCurveCreator::CONFIGURATION_NAME) { - axisFolder->add(&m_bottomAxisProperties); + uiTreeOrdering.add(&m_summaryCurveCollection); + if (!m_isCrossPlot) + { + uiTreeOrdering.add(&m_ensembleCurveSetCollection); + } } else { - axisFolder->add(&m_timeAxisProperties); - } - axisFolder->add(&m_leftYAxisProperties); - axisFolder->add(&m_rightYAxisProperties); + caf::PdmUiTreeOrdering* axisFolder = uiTreeOrdering.add("Axes", ":/Axes16x16.png"); + + if (m_isCrossPlot) + { + axisFolder->add(&m_bottomAxisProperties); + } + else + { + axisFolder->add(&m_timeAxisProperties); + } + axisFolder->add(&m_leftYAxisProperties); + axisFolder->add(&m_rightYAxisProperties); - uiTreeOrdering.add(&m_summaryCurveCollection); - uiTreeOrdering.add(&m_gridTimeHistoryCurves); - uiTreeOrdering.add(&m_asciiDataCurves); + uiTreeOrdering.add(&m_summaryCurveCollection); + if (!m_isCrossPlot) + { + uiTreeOrdering.add(&m_ensembleCurveSetCollection); + } + uiTreeOrdering.add(&m_gridTimeHistoryCurves); + uiTreeOrdering.add(&m_asciiDataCurves); + } uiTreeOrdering.skipRemainingChildren(true); } @@ -1134,19 +1239,22 @@ void RimSummaryPlot::onLoadDataAndUpdate() m_summaryCurveCollection->loadDataAndUpdate(false); } + m_ensembleCurveSetCollection->loadDataAndUpdate(false); + for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { - curve->loadDataAndUpdate(true); + curve->loadDataAndUpdate(false); } for (RimAsciiDataCurve* curve : m_asciiDataCurves) { - curve->loadDataAndUpdate(true); + curve->loadDataAndUpdate(false); } if (m_qwtPlot) m_qwtPlot->updateLegend(); this->updateAxes(); updateZoomInQwt(); + if(m_qwtPlot) m_qwtPlot->replot(); } //-------------------------------------------------------------------------------------------------- @@ -1154,63 +1262,75 @@ void RimSummaryPlot::onLoadDataAndUpdate() //-------------------------------------------------------------------------------------------------- void RimSummaryPlot::updateZoomInQwt() { - if (!m_qwtPlot) return; - - if (m_isAutoZoom) - { - zoomAll(); - } - else + if (m_qwtPlot) { - setZoomIntervalsInQwtPlot(); + + updateZoomForAxis(RiaDefines::PLOT_AXIS_BOTTOM); + updateZoomForAxis(RiaDefines::PLOT_AXIS_LEFT); + updateZoomForAxis(RiaDefines::PLOT_AXIS_RIGHT); + + m_qwtPlot->replot(); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::setZoomIntervalsInQwtPlot() +void RimSummaryPlot::updateZoomWindowFromQwt() +{ + updateAxisRangesFromQwt(); + setAutoZoomForAllAxes(false); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlot::updateAxisRangesFromQwt() { - QwtInterval left, right, time; + if (!m_qwtPlot) return; - left.setMinValue(m_leftYAxisProperties->visibleRangeMin()); - left.setMaxValue(m_leftYAxisProperties->visibleRangeMax()); - right.setMinValue(m_rightYAxisProperties->visibleRangeMin()); - right.setMaxValue(m_rightYAxisProperties->visibleRangeMax()); + QwtInterval leftAxis, rightAxis, timeAxis; + m_qwtPlot->currentVisibleWindow(&leftAxis, &rightAxis, &timeAxis); + + m_leftYAxisProperties->visibleRangeMax = leftAxis.maxValue(); + m_leftYAxisProperties->visibleRangeMin = leftAxis.minValue(); + m_leftYAxisProperties->updateConnectedEditors(); + + m_rightYAxisProperties->visibleRangeMax = rightAxis.maxValue(); + m_rightYAxisProperties->visibleRangeMin = rightAxis.minValue(); + m_rightYAxisProperties->updateConnectedEditors(); if (m_isCrossPlot) { - time.setMinValue(m_bottomAxisProperties->visibleRangeMin()); - time.setMaxValue(m_bottomAxisProperties->visibleRangeMax()); + m_bottomAxisProperties->visibleRangeMax = timeAxis.maxValue(); + m_bottomAxisProperties->visibleRangeMin = timeAxis.minValue(); + m_bottomAxisProperties->updateConnectedEditors(); } else { - time.setMinValue(m_timeAxisProperties->visibleRangeMin()); - time.setMaxValue(m_timeAxisProperties->visibleRangeMax()); + m_timeAxisProperties->setVisibleRangeMin(timeAxis.minValue()); + m_timeAxisProperties->setVisibleRangeMax(timeAxis.maxValue()); + m_timeAxisProperties->updateConnectedEditors(); } - m_qwtPlot->setZoomWindow(left, right, time); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::updateZoomWindowFromQwt() +void RimSummaryPlot::setAutoZoomForAllAxes(bool enableAutoZoom) { - if (!m_qwtPlot) return; - - QwtInterval left, right, time; - m_qwtPlot->currentVisibleWindow(&left, &right, &time); - - setZoomWindow(left, right, time); -} + m_leftYAxisProperties->setAutoZoom(enableAutoZoom); + m_rightYAxisProperties->setAutoZoom(enableAutoZoom); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimSummaryPlot::disableAutoZoom() -{ - m_isAutoZoom = false; + if (m_isCrossPlot) + { + m_bottomAxisProperties->setAutoZoom(enableAutoZoom); + } + else + { + m_timeAxisProperties->setAutoZoom(enableAutoZoom); + } } //-------------------------------------------------------------------------------------------------- @@ -1302,7 +1422,12 @@ QWidget* RimSummaryPlot::createViewWidget(QWidget* mainWindowParent) if ( m_summaryCurveCollection ) { - m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot); + m_summaryCurveCollection->setParentQwtPlotAndReplot(m_qwtPlot); + } + + if (m_ensembleCurveSetCollection) + { + m_ensembleCurveSetCollection->setParentQwtPlotAndReplot(m_qwtPlot); } } @@ -1347,6 +1472,11 @@ void RimSummaryPlot::initAfterRead() m_summaryCurveCollection->addCurve(curve); } + if (!m_isAutoZoom_OBSOLETE()) + { + setAutoZoomForAllAxes(false); + } + RimProject* proj = nullptr; this->firstAncestorOrThisOfType(proj); if (proj) @@ -1398,40 +1528,44 @@ void RimSummaryPlot::updateMdiWindowTitle() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RimSummaryPlot::generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) const +void RimSummaryPlot::updateNameHelperWithCurveData(RimSummaryPlotNameHelper* nameHelper) const { - if (!nameHelper) return ""; + if (!nameHelper) return; + nameHelper->clear(); std::vector addresses; std::vector sumCases; + std::vector ensembleCases; if (m_summaryCurveCollection && m_summaryCurveCollection->isCurvesVisible()) { for (RimSummaryCurve* curve : m_summaryCurveCollection->curves()) { - if (curve->isCurveVisible()) + addresses.push_back(curve->summaryAddressY()); + sumCases.push_back(curve->summaryCaseY()); + + if (curve->summaryCaseX()) { - addresses.push_back(curve->summaryAddressY()); - sumCases.push_back(curve->summaryCaseY()); + sumCases.push_back(curve->summaryCaseX()); - if (curve->summaryCaseX()) + if (curve->summaryAddressX().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) { - sumCases.push_back(curve->summaryCaseX()); - - if (curve->summaryAddressX().category() != RifEclipseSummaryAddress::SUMMARY_INVALID) - { - addresses.push_back(curve->summaryAddressX()); - } + addresses.push_back(curve->summaryAddressX()); } } } } + for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) + { + addresses.push_back(curveSet->summaryAddress()); + ensembleCases.push_back(curveSet->summaryCaseCollection()); + } + nameHelper->clear(); nameHelper->appendAddresses(addresses); nameHelper->appendSummaryCases(sumCases); - - return nameHelper->plotTitle(); + nameHelper->appendEnsembleCases(ensembleCases); } //-------------------------------------------------------------------------------------------------- @@ -1443,12 +1577,14 @@ void RimSummaryPlot::updateCurveNames() { for (auto c : summaryCurves()) { - if (c->isCurveVisible()) - { - c->updateCurveNameNoLegendUpdate(); - } + c->updateCurveNameNoLegendUpdate(); } } + + for (auto curveSet : m_ensembleCurveSetCollection->curveSets()) + { + curveSet->updateEnsembleLegendItem(); + } } //-------------------------------------------------------------------------------------------------- @@ -1461,6 +1597,8 @@ void RimSummaryPlot::detachAllCurves() m_summaryCurveCollection->detachQwtCurves(); } + m_ensembleCurveSetCollection->detachQwtCurves(); + for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { curve->detachQwtCurve(); @@ -1475,7 +1613,7 @@ void RimSummaryPlot::detachAllCurves() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmObject* RimSummaryPlot::findRimCurveFromQwtCurve(const QwtPlotCurve* qwtCurve) const +caf::PdmObject* RimSummaryPlot::findRimPlotObjectFromQwtCurve(const QwtPlotCurve* qwtCurve) const { for (RimGridTimeHistoryCurve* curve : m_gridTimeHistoryCurves) { @@ -1505,7 +1643,18 @@ caf::PdmObject* RimSummaryPlot::findRimCurveFromQwtCurve(const QwtPlotCurve* qwt } } - return NULL; + if (m_ensembleCurveSetCollection) + { + RimEnsembleCurveSet* foundCurveSet = m_ensembleCurveSetCollection->findRimCurveSetFromQwtCurve(qwtCurve); + + if (foundCurveSet) + { + m_ensembleCurveSetCollection->setCurrentSummaryCurveSet(foundCurveSet); + + return foundCurveSet; + } + } + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h index b3393077f0..9049ed8373 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlot.h @@ -38,6 +38,8 @@ class RimGridTimeHistoryCurve; class RimSummaryCase; class RimSummaryCurve; class RimSummaryCurveCollection; +class RimEnsembleCurveSet; +class RimEnsembleCurveSetCollection; class RimSummaryCurveFilter_OBSOLETE; class RimSummaryTimeAxisProperties; class RimSummaryAxisProperties; @@ -73,11 +75,13 @@ class RimSummaryPlot : public RimViewWindow void setCurveCollection(RimSummaryCurveCollection* curveCollection); void deleteCurvesAssosiatedWithCase(RimSummaryCase* summaryCase); + RimEnsembleCurveSetCollection* ensembleCurveSetCollection() const; + void addGridTimeHistoryCurve(RimGridTimeHistoryCurve* curve); void addAsciiDataCruve(RimAsciiDataCurve* curve); - caf::PdmObject* findRimCurveFromQwtCurve(const QwtPlotCurve* curve) const; + caf::PdmObject* findRimPlotObjectFromQwtCurve(const QwtPlotCurve* curve) const; size_t curveCount() const; void detachAllCurves(); @@ -85,13 +89,9 @@ class RimSummaryPlot : public RimViewWindow void updateAxes(); virtual void zoomAll() override; - void setZoomWindow(const QwtInterval& leftAxis, - const QwtInterval& rightAxis, - const QwtInterval& timeAxis); void updateZoomInQwt(); void updateZoomWindowFromQwt(); - void disableAutoZoom(); bool isLogarithmicScaleEnabled(RiaDefines::PlotAxis plotAxis) const; @@ -104,6 +104,7 @@ class RimSummaryPlot : public RimViewWindow QString asciiDataForPlotExport() const; + std::vector summaryAndEnsembleCurves() const; std::vector summaryCurves() const; void deleteAllSummaryCurves(); RimSummaryCurveCollection* summaryCurveCollection() const; @@ -111,9 +112,9 @@ class RimSummaryPlot : public RimViewWindow void updatePlotTitle(); - const RimSummaryPlotNameHelper* activePlotTitleHelper() const; + const RimSummaryPlotNameHelper* activePlotTitleHelperAllCurves() const; void updateCurveNames(); - QString generatedPlotTitleFromVisibleCurves() const; + QString generatedPlotTitleFromAllCurves() const; void copyAxisPropertiesFromOther(const RimSummaryPlot& sourceSummaryPlot); @@ -125,7 +126,7 @@ class RimSummaryPlot : public RimViewWindow private: void updateMdiWindowTitle() override; - QString generatePlotTitle(RimSummaryPlotNameHelper* nameHelper) const; + void updateNameHelperWithCurveData(RimSummaryPlotNameHelper* nameHelper) const; protected: // Overridden PDM methods @@ -149,11 +150,14 @@ class RimSummaryPlot : public RimViewWindow RimSummaryAxisProperties* yAxisPropertiesLeftOrRight(RiaDefines::PlotAxis leftOrRightPlotAxis) const; void updateAxis(RiaDefines::PlotAxis plotAxis); + void updateZoomForAxis(RiaDefines::PlotAxis plotAxis); void updateTimeAxis(); void updateBottomXAxis(); - void setZoomIntervalsInQwtPlot(); + + void updateAxisRangesFromQwt(); + void setAutoZoomForAllAxes(bool enableAutoZoom); private: caf::PdmField m_showPlotTitle; @@ -164,10 +168,11 @@ class RimSummaryPlot : public RimViewWindow caf::PdmField m_userDefinedPlotTitle; caf::PdmChildArrayField m_gridTimeHistoryCurves; - caf::PdmChildField m_summaryCurveCollection; + caf::PdmChildField m_summaryCurveCollection; + caf::PdmChildField m_ensembleCurveSetCollection; + caf::PdmChildArrayField m_asciiDataCurves; - caf::PdmField m_isAutoZoom; caf::PdmChildField m_leftYAxisProperties; caf::PdmChildField m_rightYAxisProperties; @@ -179,9 +184,11 @@ class RimSummaryPlot : public RimViewWindow bool m_isCrossPlot; - std::unique_ptr m_nameHelper; + std::unique_ptr m_nameHelperAllCurves; // Obsolete fields caf::PdmChildArrayField m_summaryCurves_OBSOLETE; caf::PdmChildArrayField m_curveFilters_OBSOLETE; + caf::PdmField m_isAutoZoom_OBSOLETE; + }; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp index cf46c2c613..44fad92fd8 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotCollection.cpp @@ -28,7 +28,7 @@ CAF_PDM_SOURCE_INIT(RimSummaryPlotCollection, "SummaryPlotCollection"); //-------------------------------------------------------------------------------------------------- RimSummaryPlotCollection::RimSummaryPlotCollection() { - CAF_PDM_InitObject("Summary Plots", ":/SummaryPlots16x16.png", "", ""); + CAF_PDM_InitObject("Summary Plots", ":/SummaryPlotsLight16x16.png", "", ""); CAF_PDM_InitFieldNoDefault(&summaryPlots, "SummaryPlots", "Summary Plots", "", "", ""); summaryPlots.uiCapability()->setUiHidden(true); @@ -48,6 +48,8 @@ RimSummaryPlotCollection::~RimSummaryPlotCollection() RimSummaryPlot* RimSummaryPlotCollection::createSummaryPlotWithAutoTitle() { RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setAsPlotMdiWindow(); + plot->enableAutoPlotTitle(true); summaryPlots.push_back(plot); @@ -60,6 +62,8 @@ RimSummaryPlot* RimSummaryPlotCollection::createSummaryPlotWithAutoTitle() RimSummaryPlot* RimSummaryPlotCollection::createNamedSummaryPlot(const QString& name) { RimSummaryPlot* plot = new RimSummaryPlot(); + plot->setAsPlotMdiWindow(); + summaryPlots.push_back(plot); plot->setDescription(name); diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp index 4d480e8f7d..e7cd195bd5 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.cpp @@ -21,6 +21,8 @@ #include "RifEclipseSummaryAddress.h" #include "RimSummaryCase.h" +#include "RimSummaryCaseCollection.h" + #include "RiuSummaryVectorDescriptionMap.h" //-------------------------------------------------------------------------------------------------- @@ -29,7 +31,7 @@ RimSummaryPlotNameHelper::RimSummaryPlotNameHelper() {} //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryPlotNameHelper::clear() { @@ -51,15 +53,30 @@ void RimSummaryPlotNameHelper::appendAddresses(const std::vector& summaryCases) { m_summaryCases.clear(); - for (auto c : summaryCases) + for (auto summaryCase : summaryCases) { - m_summaryCases.insert(c); + if (summaryCase) m_summaryCases.insert(summaryCase); + } + + extractPlotTitleSubStrings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryPlotNameHelper::appendEnsembleCases(const std::vector& ensembleCases) +{ + m_ensembleCases.clear(); + + for (auto ensembleCase : ensembleCases) + { + if (ensembleCase) m_ensembleCases.insert(ensembleCase); } extractPlotTitleSubStrings(); @@ -143,7 +160,7 @@ bool RimSummaryPlotNameHelper::isRegionInTitle() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- bool RimSummaryPlotNameHelper::isCaseInTitle() const { @@ -151,7 +168,7 @@ bool RimSummaryPlotNameHelper::isCaseInTitle() const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RimSummaryPlotNameHelper::clearTitleSubStrings() { @@ -174,32 +191,46 @@ void RimSummaryPlotNameHelper::extractPlotTitleSubStrings() auto wellNames = m_analyzer.wellNames(); auto wellGroupNames = m_analyzer.wellGroupNames(); auto regions = m_analyzer.regionNumbers(); + auto categories = m_analyzer.categories(); - if (quantities.size() == 1) - { - m_titleQuantity = *(quantities.begin()); - } - - if (wellNames.size() == 1) + if (categories.size() == 1) { - m_titleWellName = *(wellNames.begin()); + if (quantities.size() == 1) + { + m_titleQuantity = *(quantities.begin()); + } + + if (wellNames.size() == 1) + { + m_titleWellName = *(wellNames.begin()); + } + + if (wellGroupNames.size() == 1) + { + m_titleWellGroupName = *(wellGroupNames.begin()); + } + + if (regions.size() == 1) + { + m_titleRegion = std::to_string(*(regions.begin())); + } } - if (wellGroupNames.size() == 1) + if (m_summaryCases.size() == 1 && m_ensembleCases.empty()) { - m_titleWellGroupName = *(wellGroupNames.begin()); - } + auto summaryCase = *(m_summaryCases.begin()); - if (regions.size() == 1) - { - m_titleRegion = std::to_string(*(regions.begin())); + if (summaryCase) + { + m_titleCaseName = summaryCase->caseName(); + } } - - // Case mane - if (m_summaryCases.size() == 1) + else if (m_ensembleCases.size() == 1 && m_summaryCases.empty()) { - auto summaryCase = *(m_summaryCases.begin()); - - m_titleCaseName = summaryCase->caseName(); + auto ensembleCase = *(m_ensembleCases.begin()); + if (ensembleCase) + { + m_titleCaseName = ensembleCase->name(); + } } } diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h index dfbde9919f..7698dada30 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotNameHelper.h @@ -29,6 +29,7 @@ class RimSummaryCurve; class RimSummaryCase; +class RimSummaryCaseCollection; //================================================================================================== // @@ -42,6 +43,7 @@ class RimSummaryPlotNameHelper void appendAddresses(const std::vector& addresses); void appendSummaryCases(const std::vector& summaryCases); + void appendEnsembleCases(const std::vector& ensembleCases); QString plotTitle() const; @@ -58,7 +60,8 @@ class RimSummaryPlotNameHelper private: RiaSummaryCurveAnalyzer m_analyzer; - std::set m_summaryCases; + std::set m_summaryCases; + std::set m_ensembleCases; std::string m_titleQuantity; std::string m_titleWellName; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp index 4f7a0169bf..bf02610c2c 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.cpp @@ -32,7 +32,7 @@ #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiItem.h" @@ -229,7 +229,7 @@ QList RimSummaryPlotSourceStepping::calculateValueOption std::vector identifierTexts; - RifSummaryReaderInterface* reader = firstSummaryReaderForVisibleCurves(); + RifSummaryReaderInterface* reader = firstSummaryReaderForCurves(); if (reader) { RiaSummaryCurveAnalyzer* analyzer = analyzerForReader(reader); @@ -253,9 +253,9 @@ QList RimSummaryPlotSourceStepping::calculateValueOption RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_FIELD; - if (curveCollection->visibleCurves().size() > 0) + if (curveCollection->curves().size() > 0) { - category = curveCollection->visibleCurves()[0]->summaryAddressY().category(); + category = curveCollection->curves()[0]->summaryAddressY().category(); } RiaSummaryCurveAnalyzer quantityAnalyzer; @@ -301,7 +301,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c { if (m_summaryCase()) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -324,7 +324,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_wellName) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -353,7 +353,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_region) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -382,7 +382,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_quantity) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -405,7 +405,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c } else if (changedField == &m_wellGroupName) { - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping()) { @@ -448,7 +448,7 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c // have been changed due to the updates in this function curveCollection->updateConnectedEditors(); - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); mainPlotWindow->updateSummaryPlotToolBar(); } } @@ -457,35 +457,21 @@ void RimSummaryPlotSourceStepping::fieldChangedByUi(const caf::PdmFieldHandle* c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RifSummaryReaderInterface* RimSummaryPlotSourceStepping::firstSummaryReaderForVisibleCurves() const -{ - RimSummaryCase* sumCase = firstSummaryCaseForVisibleCurves(); - if (sumCase) - { - return sumCase->summaryReader(); - } - - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimSummaryCase* RimSummaryPlotSourceStepping::firstSummaryCaseForVisibleCurves() const +RifSummaryReaderInterface* RimSummaryPlotSourceStepping::firstSummaryReaderForCurves() const { RimSummaryCurveCollection* curveCollection = nullptr; this->firstAncestorOrThisOfTypeAsserted(curveCollection); - for (auto curve : curveCollection->visibleCurves()) + for (auto curve : curveCollection->curves()) { if (isYAxisStepping() && curve->summaryCaseY()) { - return curve->summaryCaseY(); + return curve->summaryCaseY()->summaryReader(); } if (isXAxisStepping() && curve->summaryCaseX()) { - return curve->summaryCaseX(); + return curve->summaryCaseX()->summaryReader(); } } @@ -498,7 +484,7 @@ RimSummaryCase* RimSummaryPlotSourceStepping::firstSummaryCaseForVisibleCurves() caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() { RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses(visibleAddressesCurveCollection()); + analyzer.appendAdresses(addressesCurveCollection()); if (analyzer.wellNames().size() == 1) { @@ -521,14 +507,16 @@ caf::PdmValueField* RimSummaryPlotSourceStepping::fieldToModify() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotSourceStepping::visibleAddressesCurveCollection() const +std::set RimSummaryPlotSourceStepping::addressesCurveCollection() const { std::set addresses; RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfTypeAsserted(curveCollection); + this->firstAncestorOrThisOfType(curveCollection); - auto curves = curveCollection->visibleCurves(); + if (!curveCollection) return addresses; + + auto curves = curveCollection->curves(); for (auto c : curves) { if (isYAxisStepping()) @@ -548,14 +536,16 @@ std::set RimSummaryPlotSourceStepping::visibleAddresse //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::set RimSummaryPlotSourceStepping::visibleSummaryCasesCurveCollection() const +std::set RimSummaryPlotSourceStepping::summaryCasesCurveCollection() const { std::set sumCases; RimSummaryCurveCollection* curveCollection = nullptr; - this->firstAncestorOrThisOfTypeAsserted(curveCollection); + this->firstAncestorOrThisOfType(curveCollection); + + if (!curveCollection) return sumCases; - auto curves = curveCollection->visibleCurves(); + auto curves = curveCollection->curves(); for (auto c : curves) { if (isYAxisStepping()) @@ -585,7 +575,7 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi std::vector fields; - auto sumCases = visibleSummaryCasesCurveCollection(); + auto sumCases = summaryCasesCurveCollection(); if (sumCases.size() == 1) { RimProject* proj = RiaApplication::instance()->project(); @@ -600,7 +590,7 @@ std::vector RimSummaryPlotSourceStepping::computeVisibleFi } RiaSummaryCurveAnalyzer analyzer; - analyzer.appendAdresses(visibleAddressesCurveCollection()); + analyzer.appendAdresses(addressesCurveCollection()); RifEclipseSummaryAddress::SummaryVarCategory category = RifEclipseSummaryAddress::SUMMARY_INVALID; { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h index 866108e79d..65601060e1 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryPlotSourceStepping.h @@ -77,12 +77,11 @@ class RimSummaryPlotSourceStepping : public caf::PdmObject caf::PdmUiEditorAttribute* attribute) override; private: - RifSummaryReaderInterface* firstSummaryReaderForVisibleCurves() const; - RimSummaryCase* firstSummaryCaseForVisibleCurves() const; + RifSummaryReaderInterface* firstSummaryReaderForCurves() const; caf::PdmValueField* fieldToModify(); - std::set visibleAddressesCurveCollection() const; - std::set visibleSummaryCasesCurveCollection() const; + std::set addressesCurveCollection() const; + std::set summaryCasesCurveCollection() const; std::vector computeVisibleFieldsAndSetFieldVisibility(); bool isXAxisStepping() const; diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp index 320cd2c864..c6af806b1a 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.cpp @@ -82,6 +82,7 @@ RimSummaryTimeAxisProperties::RimSummaryTimeAxisProperties() CAF_PDM_InitField(&titleFontSize, "FontSize", 11, "Font Size", "", "", ""); CAF_PDM_InitField(&valuesFontSize, "ValuesFontSize", 11, "Font Size", "", "", ""); + CAF_PDM_InitField(&m_isAutoZoom, "AutoZoom", true, "Set Range Automatically", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_timeMode, "TimeMode", "Time Mode", "", "", ""); CAF_PDM_InitFieldNoDefault(&m_timeUnit, "TimeUnit", "Time Unit", "", "", ""); @@ -158,6 +159,22 @@ void RimSummaryTimeAxisProperties::setVisibleRangeMax(double value) auto s = m_visibleDateRangeMax().toString(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSummaryTimeAxisProperties::isAutoZoom() const +{ + return m_isAutoZoom; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSummaryTimeAxisProperties::setAutoZoom(bool enableAutoZoom) +{ + m_isAutoZoom = enableAutoZoom; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -362,7 +379,7 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c } updateTimeVisibleRange(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &m_visibleDateRangeMin) { @@ -373,12 +390,12 @@ void RimSummaryTimeAxisProperties::fieldChangedByUi(const caf::PdmFieldHandle* c } updateTimeVisibleRange(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &m_visibleTimeRangeMin || changedField == &m_visibleTimeRangeMax) { updateDateVisibleRange(); - rimSummaryPlot->disableAutoZoom(); + m_isAutoZoom = false; } else if (changedField == &m_timeMode) { diff --git a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h index b476775466..451236dca2 100644 --- a/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h +++ b/ApplicationCode/ProjectDataModel/Summary/RimSummaryTimeAxisProperties.h @@ -78,6 +78,9 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject void setVisibleRangeMin(double value); void setVisibleRangeMax(double value); + bool isAutoZoom() const; + void setAutoZoom(bool enableAutoZoom); + bool isActive() const; protected: @@ -100,4 +103,5 @@ class RimSummaryTimeAxisProperties : public caf::PdmObject caf::PdmField m_visibleDateRangeMax; caf::PdmField m_visibleTimeRangeMin; caf::PdmField m_visibleTimeRangeMax; + caf::PdmField m_isAutoZoom; }; diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake index fbf1f44934..6ba9315bff 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_files.cmake @@ -1,158 +1,138 @@ -# 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}RigActiveCellInfo.h -${CEE_CURRENT_LIST_DIR}RigCell.h -${CEE_CURRENT_LIST_DIR}RigEclipseCaseData.h -${CEE_CURRENT_LIST_DIR}RigGridBase.h -${CEE_CURRENT_LIST_DIR}RigGridManager.h -${CEE_CURRENT_LIST_DIR}RigResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.h -${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h -${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCompletionData.h -${CEE_CURRENT_LIST_DIR}RigResultModifier.h -${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.h -${CEE_CURRENT_LIST_DIR}RigFormationNames.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultAddress.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagResults.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultFrames.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagInterfaceTools.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagStatCalc.h -${CEE_CURRENT_LIST_DIR}RigFlowDiagVisibleCellsStatCalc.h -${CEE_CURRENT_LIST_DIR}RigAccWellFlowCalculator.h -${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.h -${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.h -${CEE_CURRENT_LIST_DIR}RigLocalGrid.h -${CEE_CURRENT_LIST_DIR}RigMainGrid.h -${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.h -${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.h -${CEE_CURRENT_LIST_DIR}RigSimWellData.h -${CEE_CURRENT_LIST_DIR}RigWellPath.h -${CEE_CURRENT_LIST_DIR}RigFault.h -${CEE_CURRENT_LIST_DIR}RigNNCData.h -${CEE_CURRENT_LIST_DIR}cvfGeometryTools.h -${CEE_CURRENT_LIST_DIR}cvfGeometryTools.inl -${CEE_CURRENT_LIST_DIR}RigPipeInCellEvaluator.h -${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.h -${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.h -${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.h -${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.h -${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.h -${CEE_CURRENT_LIST_DIR}RigWellLogExtractionTools.h -${CEE_CURRENT_LIST_DIR}RigHexIntersectionTools.h -${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.h -${CEE_CURRENT_LIST_DIR}RigCurveDataTools.h -${CEE_CURRENT_LIST_DIR}RigObservedData.h -${CEE_CURRENT_LIST_DIR}RigLasFileExporter.h -${CEE_CURRENT_LIST_DIR}RigSimulationWellCoordsAndMD.h -${CEE_CURRENT_LIST_DIR}RigFishbonesGeometry.h -${CEE_CURRENT_LIST_DIR}RigTesselatorTools.h -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.h -${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.h -${CEE_CURRENT_LIST_DIR}RigEclipseResultInfo.h -${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator.h -${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.h -${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.h -${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.h -${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.h -${CEE_CURRENT_LIST_DIR}RigWellPathFormations.h +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellInfo.h +${CMAKE_CURRENT_LIST_DIR}/RigCell.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseCaseData.h +${CMAKE_CURRENT_LIST_DIR}/RigGridBase.h +${CMAKE_CURRENT_LIST_DIR}/RigGridManager.h +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessorFactory.h +${CMAKE_CURRENT_LIST_DIR}/RigAllGridCellsResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellsResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCellEdgeResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigCombTransResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCombMultResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigResultModifier.h +${CMAKE_CURRENT_LIST_DIR}/RigResultModifierFactory.h +${CMAKE_CURRENT_LIST_DIR}/RigFormationNames.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultAddress.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResults.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultFrames.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagSolverInterface.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagInterfaceTools.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagVisibleCellsStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigAccWellFlowCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractor.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseWellLogExtractor.h +${CMAKE_CURRENT_LIST_DIR}/RigLocalGrid.h +${CMAKE_CURRENT_LIST_DIR}/RigMainGrid.h +${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilderMock.h +${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultsData.h +${CMAKE_CURRENT_LIST_DIR}/RigSimWellData.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPath.h +${CMAKE_CURRENT_LIST_DIR}/RigFault.h +${CMAKE_CURRENT_LIST_DIR}/RigNNCData.h +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools.inl +${CMAKE_CURRENT_LIST_DIR}/RigPipeInCellEvaluator.h +${CMAKE_CURRENT_LIST_DIR}/RigTernaryResultAccessor2d.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeVisibleCellsStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseMultiPropertyStatCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigWellLogCurveData.h +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractionTools.h +${CMAKE_CURRENT_LIST_DIR}/RigHexIntersectionTools.h +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RigCurveDataTools.h +${CMAKE_CURRENT_LIST_DIR}/RigObservedData.h +${CMAKE_CURRENT_LIST_DIR}/RigLasFileExporter.h +${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCoordsAndMD.h +${CMAKE_CURRENT_LIST_DIR}/RigFishbonesGeometry.h +${CMAKE_CURRENT_LIST_DIR}/RigTesselatorTools.h +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseResultInfo.h +${CMAKE_CURRENT_LIST_DIR}/RigTofAccumulatedPhaseFractionsCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityEquations.h +${CMAKE_CURRENT_LIST_DIR}/RigNumberOfFloodedPoreVolumesCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigWeightedMeanCalc.h +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryCurveMerger.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.h +${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.h +${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.h +${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.h +${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.h +${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.h ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_HEADER_FILES - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.h - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.h - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.h - ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.h - ${CEE_CURRENT_LIST_DIR}RigFractureGrid.h - ${CEE_CURRENT_LIST_DIR}RigFractureCell.h - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.h - ) -endif() - set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RigActiveCellInfo.cpp -${CEE_CURRENT_LIST_DIR}RigCell.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseCaseData.cpp -${CEE_CURRENT_LIST_DIR}RigGridBase.cpp -${CEE_CURRENT_LIST_DIR}RigGridManager.cpp -${CEE_CURRENT_LIST_DIR}RigResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigResultAccessorFactory.cpp -${CEE_CURRENT_LIST_DIR}RigAllGridCellsResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigActiveCellsResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCellEdgeResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp -${CEE_CURRENT_LIST_DIR}RigCombTransResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCombMultResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCompletionData.cpp -${CEE_CURRENT_LIST_DIR}RigResultModifierFactory.cpp -${CEE_CURRENT_LIST_DIR}RigFormationNames.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultAddress.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagResults.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagResultFrames.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagSolverInterface.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigFlowDiagVisibleCellsStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigAccWellFlowCalculator.cpp -${CEE_CURRENT_LIST_DIR}RigWellLogExtractor.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseWellLogExtractor.cpp -${CEE_CURRENT_LIST_DIR}RigLocalGrid.cpp -${CEE_CURRENT_LIST_DIR}RigMainGrid.cpp -${CEE_CURRENT_LIST_DIR}RigReservoirBuilderMock.cpp -${CEE_CURRENT_LIST_DIR}RigCaseCellResultsData.cpp -${CEE_CURRENT_LIST_DIR}RigSimWellData.cpp -${CEE_CURRENT_LIST_DIR}RigWellPath.cpp -${CEE_CURRENT_LIST_DIR}RigFault.cpp -${CEE_CURRENT_LIST_DIR}RigNNCData.cpp -${CEE_CURRENT_LIST_DIR}cvfGeometryTools.cpp -${CEE_CURRENT_LIST_DIR}RigTernaryResultAccessor2d.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseNativeStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseNativeVisibleCellsStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseMultiPropertyStatCalc.cpp -${CEE_CURRENT_LIST_DIR}RigWellLogCurveData.cpp -${CEE_CURRENT_LIST_DIR}RigHexIntersectionTools.cpp -${CEE_CURRENT_LIST_DIR}RigTimeHistoryResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RigCurveDataTools.cpp -${CEE_CURRENT_LIST_DIR}RigObservedData.cpp -${CEE_CURRENT_LIST_DIR}RigLasFileExporter.cpp -${CEE_CURRENT_LIST_DIR}RigSimulationWellCoordsAndMD.cpp -${CEE_CURRENT_LIST_DIR}RigFishbonesGeometry.cpp -${CEE_CURRENT_LIST_DIR}RigTesselatorTools.cpp -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools.cpp -${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools.cpp -${CEE_CURRENT_LIST_DIR}RigEclipseResultInfo.cpp -${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator.cpp -${CEE_CURRENT_LIST_DIR}RigTransmissibilityEquations.cpp -${CEE_CURRENT_LIST_DIR}RigNumberOfFloodedPoreVolumesCalculator.cpp -${CEE_CURRENT_LIST_DIR}RigWeightedMeanCalc.cpp -${CEE_CURRENT_LIST_DIR}RigTimeHistoryCurveMerger.cpp -${CEE_CURRENT_LIST_DIR}RigWellPathFormations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseCaseData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigGridBase.cpp +${CMAKE_CURRENT_LIST_DIR}/RigGridManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigResultAccessorFactory.cpp +${CMAKE_CURRENT_LIST_DIR}/RigAllGridCellsResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellsResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellEdgeResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCombTransResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCombMultResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigResultModifierFactory.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFormationNames.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultAddress.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResults.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagResultFrames.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagSolverInterface.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFlowDiagVisibleCellsStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigAccWellFlowCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseWellLogExtractor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigLocalGrid.cpp +${CMAKE_CURRENT_LIST_DIR}/RigMainGrid.cpp +${CMAKE_CURRENT_LIST_DIR}/RigReservoirBuilderMock.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCaseCellResultsData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigSimWellData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPath.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFault.cpp +${CMAKE_CURRENT_LIST_DIR}/RigNNCData.cpp +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTernaryResultAccessor2d.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseNativeVisibleCellsStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseMultiPropertyStatCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellLogCurveData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigHexIntersectionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCurveDataTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigObservedData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigLasFileExporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCoordsAndMD.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFishbonesGeometry.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTesselatorTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseResultInfo.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTofAccumulatedPhaseFractionsCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityEquations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigNumberOfFloodedPoreVolumesCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWeightedMeanCalc.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTimeHistoryCurveMerger.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathFormations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigStimPlanFractureDefinition.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFractureGrid.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFractureCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellResultPoint.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathGeometryTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCaseRealizationParameters.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigEclipseToStimPlanCellTransmissibilityCalculator.cpp - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureTransmissibilityEquations.cpp - ${CEE_CURRENT_LIST_DIR}RigStimPlanFractureDefinition.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureGrid.cpp - ${CEE_CURRENT_LIST_DIR}RigFractureCell.cpp - ${CEE_CURRENT_LIST_DIR}RigWellPathStimplanIntersector.cpp - ) -endif() - - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) @@ -161,4 +141,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ReservoirDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "ReservoirDataModel" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake b/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake index d54e923649..8de6209ac7 100644 --- a/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake +++ b/ApplicationCode/ReservoirDataModel/CMakeLists_filesNotToUnitTest.cmake @@ -1,27 +1,22 @@ -# 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}RigGeoMechWellLogExtractor.h - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.h - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapperTools.h - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.h - ${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.h - ${CEE_CURRENT_LIST_DIR}RigWellLogFile.h - ${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.h + ${CMAKE_CURRENT_LIST_DIR}/RigGeoMechWellLogExtractor.h + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapper.h + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapperTools.h + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseRangeFilterMapper.h + ${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCenterLineCalculator.h + ${CMAKE_CURRENT_LIST_DIR}/RigWellLogFile.h + ${CMAKE_CURRENT_LIST_DIR}/RigReservoirGridTools.h ) set (SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigGeoMechWellLogExtractor.cpp - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapper.cpp - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseCellMapperTools.cpp - ${CEE_CURRENT_LIST_DIR}RigCaseToCaseRangeFilterMapper.cpp - ${CEE_CURRENT_LIST_DIR}RigSimulationWellCenterLineCalculator.cpp - ${CEE_CURRENT_LIST_DIR}RigWellLogFile.cpp - ${CEE_CURRENT_LIST_DIR}RigReservoirGridTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigGeoMechWellLogExtractor.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseCellMapperTools.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigCaseToCaseRangeFilterMapper.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigSimulationWellCenterLineCalculator.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigWellLogFile.cpp + ${CMAKE_CURRENT_LIST_DIR}/RigReservoirGridTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -32,4 +27,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "ReservoirDataModel2" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_filesNotToUnitTest.cmake ) +source_group( "ReservoirDataModel2" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_filesNotToUnitTest.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake b/ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake new file mode 100644 index 0000000000..02d025e364 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/CMakeLists_files.cmake @@ -0,0 +1,31 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.h +${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.h +${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.h +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.h +${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.h +${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.h +${CMAKE_CURRENT_LIST_DIR}/RigVirtualPerforationTransmissibilities.h +) + + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RigCompletionData.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCompletionDataGridCell.cpp +${CMAKE_CURRENT_LIST_DIR}/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser.cpp +${CMAKE_CURRENT_LIST_DIR}/RigFractureTransmissibilityEquations.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathStimplanIntersector.cpp +${CMAKE_CURRENT_LIST_DIR}/RigVirtualPerforationTransmissibilities.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "ReservoirDataModel\\Completions" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp new file mode 100644 index 0000000000..c83f33515d --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.cpp @@ -0,0 +1,434 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCompletionData.h" + +#include "RiaLogging.h" + +#include "cvfAssert.h" + +#include + +#include // Needed for HUGE_VAL on Linux + +//================================================================================================== +/// +//================================================================================================== +RigCompletionData::RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue) + : m_wellName(wellName) + , m_cellIndex(cellIndex) + , m_saturation(HUGE_VAL) + , m_transmissibility(HUGE_VAL) + , m_diameter(HUGE_VAL) + , m_kh(HUGE_VAL) + , m_skinFactor(HUGE_VAL) + , m_dFactor(HUGE_VAL) + , m_direction(DIR_UNDEF) + , m_connectionState(OPEN) + , m_count(1) + , m_wpimult(HUGE_VAL) + , m_isMainBore(false) + , m_completionType(CT_UNDEFINED) + , m_firstOrderingValue(orderingValue) + , m_secondOrderingValue(HUGE_VAL) +{ +} + +//================================================================================================== +/// +//================================================================================================== +RigCompletionData::~RigCompletionData() {} + +//================================================================================================== +/// +//================================================================================================== +RigCompletionData::RigCompletionData(const RigCompletionData& other) +{ + copy(*this, other); +} + +//================================================================================================== +/// +//================================================================================================== +bool RigCompletionData::operator<(const RigCompletionData& other) const +{ + if (m_wellName != other.m_wellName) + { + return (m_wellName < other.m_wellName); + } + + if (m_completionType != other.m_completionType) + { + return (m_completionType < other.m_completionType); + } + + if (m_firstOrderingValue != other.m_firstOrderingValue) + { + return (m_firstOrderingValue < other.m_firstOrderingValue); + } + + if (m_secondOrderingValue != other.m_secondOrderingValue) + { + return (m_secondOrderingValue < other.m_secondOrderingValue); + } + + return m_cellIndex < other.m_cellIndex; +} + +//================================================================================================== +/// +//================================================================================================== +RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other) +{ + if (this != &other) + { + copy(*this, other); + } + return *this; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::setFromFracture(double transmissibility, double skinFactor, double diameter) +{ + m_completionType = FRACTURE; + m_transmissibility = transmissibility; + m_skinFactor = skinFactor; + m_diameter = diameter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setSecondOrderingValue(double orderingValue) +{ + m_secondOrderingValue = orderingValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setDiameter(double diameter) +{ + m_diameter = diameter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setTransmissibility(double transmissibility) +{ + m_transmissibility = transmissibility; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, + double skinFactor, + double diameter, + CellDirection direction, + bool isMainBore) +{ + m_completionType = FISHBONES; + m_transmissibility = transmissibility; + m_skinFactor = skinFactor; + m_diameter = diameter; + m_direction = direction; + m_isMainBore = isMainBore; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, + double skinFactor, + double diameter, + CellDirection direction) +{ + m_completionType = PERFORATION; + m_transmissibility = transmissibility; + m_skinFactor = skinFactor; + m_diameter = diameter; + m_direction = direction; + m_isMainBore = true; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, + double skinFactor, + double diameter, + CellDirection celldirection, + CompletionType completionType) +{ + m_transmissibility = transmissibility; + m_skinFactor = skinFactor; + m_diameter = diameter; + m_direction = celldirection; + m_completionType = completionType; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpimult, + double skinFactor, + double diameter, + CellDirection celldirection, + CompletionType completionType) +{ + m_wpimult = wpimult; + m_direction = celldirection; + m_completionType = completionType; + m_skinFactor = skinFactor; + m_diameter = diameter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionData::isNonDarcyFlow() const +{ + if (!isDefaultValue(m_kh)) return true; + if (!isDefaultValue(m_dFactor)) return true; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setDFactor(double dFactor) +{ + m_dFactor = dFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCompletionData::setKh(double kh) +{ + m_kh = kh; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::addMetadata(const QString& name, const QString& comment) +{ + m_metadata.push_back(RigCompletionMetaData(name, comment)); +} + +//================================================================================================== +/// +//================================================================================================== +bool RigCompletionData::isDefaultValue(double val) +{ + return val == HUGE_VAL; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigCompletionData::metadata() const +{ + return m_metadata; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RigCompletionData::wellName() const +{ + return m_wellName; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigCompletionDataGridCell& RigCompletionData::completionDataGridCell() const +{ + return m_cellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +WellConnectionState RigCompletionData::connectionState() const +{ + return m_connectionState; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::saturation() const +{ + return m_saturation; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::transmissibility() const +{ + return m_transmissibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::diameter() const +{ + return m_diameter; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::kh() const +{ + return m_kh; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::skinFactor() const +{ + return m_skinFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::dFactor() const +{ + return m_dFactor; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CellDirection RigCompletionData::direction() const +{ + return m_direction; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionData::count() const +{ + return m_count; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::wpimult() const +{ + return m_wpimult; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCompletionData::CompletionType RigCompletionData::completionType() const +{ + return m_completionType; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionData::isMainBore() const +{ + return m_isMainBore; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::firstOrderingValue() const +{ + return m_firstOrderingValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCompletionData::secondOrderingValue() const +{ + return m_secondOrderingValue; +} + +//================================================================================================== +/// +//================================================================================================== +bool RigCompletionData::onlyOneIsDefaulted(double first, double second) +{ + if (first == HUGE_VAL) + { + if (second == HUGE_VAL) + { + // Both have default values + return false; + } + else + { + // First has default value, second does not + return true; + } + } + if (second == HUGE_VAL) + { + // Second has default value, first does not + return true; + } + + // Neither has default values + return false; +} + +//================================================================================================== +/// +//================================================================================================== +void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& from) +{ + target.m_metadata = from.m_metadata; + target.m_wellName = from.m_wellName; + target.m_cellIndex = from.m_cellIndex; + target.m_connectionState = from.m_connectionState; + target.m_saturation = from.m_saturation; + target.m_transmissibility = from.m_transmissibility; + target.m_diameter = from.m_diameter; + target.m_kh = from.m_kh; + target.m_skinFactor = from.m_skinFactor; + target.m_dFactor = from.m_dFactor; + target.m_direction = from.m_direction; + target.m_isMainBore = from.m_isMainBore; + target.m_count = from.m_count; + target.m_wpimult = from.m_wpimult; + target.m_completionType = from.m_completionType; + target.m_firstOrderingValue = from.m_firstOrderingValue; + target.m_secondOrderingValue = from.m_secondOrderingValue; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h similarity index 55% rename from ApplicationCode/ReservoirDataModel/RigCompletionData.h rename to ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h index 98eb42e893..de8c255c75 100644 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionData.h @@ -18,10 +18,14 @@ #pragma once +#include "RigCompletionDataGridCell.h" + #include #include +class RimEclipseCase; + //================================================================================================== /// //================================================================================================== @@ -41,38 +45,6 @@ enum CellDirection { DIR_UNDEF, }; -//================================================================================================== -/// -//================================================================================================== -class IJKCellIndex { -public: - IJKCellIndex() {}; - IJKCellIndex(size_t i, size_t j, size_t k) : i(i), j(j), k(k) {}; - IJKCellIndex(const IJKCellIndex& other) - { - i = other.i; - j = other.j; - k = other.k; - } - - bool operator==(const IJKCellIndex& other) const - { - return i == other.i && j == other.j && k == other.k; - } - - bool operator<(const IJKCellIndex& other) const - { - if (i != other.i) return i < other.i; - if (j != other.j) return j < other.j; - if (k != other.k) return k < other.k; - return false; - } - - size_t i; - size_t j; - size_t k; -}; - //================================================================================================== /// //================================================================================================== @@ -96,61 +68,73 @@ class RigCompletionData CT_UNDEFINED }; - RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex); + RigCompletionData(const QString wellName, const RigCompletionDataGridCell& cellIndex, double orderingValue); ~RigCompletionData(); - RigCompletionData(const RigCompletionData& other); - static RigCompletionData combine(const std::vector& completions); + RigCompletionData(const RigCompletionData& other); bool operator<(const RigCompletionData& other) const; RigCompletionData& operator=(const RigCompletionData& other); - void setFromFracture(double transmissibility, double skinFactor); - - void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, - double skinFactor, + void setFromFracture(double transmissibility, double skinFactor, double diameter); + void setSecondOrderingValue(double orderingValue); + void setDiameter(double diameter); + void setTransmissibility(double transmissibility); + + void setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, + double skinFactor, + double diameter, + CellDirection direction, + bool isMainBore); + + void setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, + double skinFactor, + double diameter, + CellDirection direction); + + void setCombinedValuesExplicitTrans(double transmissibility, + double skinFactor, + double diameter, + CellDirection celldirection, + CompletionType completionType); + + void setCombinedValuesImplicitTransWPImult(double wpimult, + double skinFactor, double diameter, - CellDirection direction, - bool isMainBore); - - void setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, - double skinFactor, - double diameter, - CellDirection direction); - - void setCombinedValuesExplicitTrans(double transmissibility, - CompletionType completionType); - void setCombinedValuesImplicitTransWPImult(double wpimult, - CellDirection celldirection, - double skinFactor, - double wellDiameter, - CompletionType completionType); - - void addMetadata(const QString& name, const QString& comment); - static bool isDefaultValue(double val); - - const std::vector& metadata() const { return m_metadata; } - const QString& wellName() const { return m_wellName; } - const IJKCellIndex& cellIndex() const { return m_cellIndex; } - WellConnectionState connectionState() const { return m_connectionState; } - double saturation() const { return m_saturation; } - double transmissibility() const { return m_transmissibility; } - double diameter() const { return m_diameter; } //TODO: should be ft or m - double kh() const { return m_kh; } - double skinFactor() const { return m_skinFactor; } - double dFactor() const { return m_dFactor; } - CellDirection direction() const { return m_direction; } - size_t count() const { return m_count; } - double wpimult() const { return m_wpimult; } - CompletionType completionType() const { return m_completionType; } - bool isMainBore() const { return m_isMainBore; } - bool readyForExport() const { return m_readyForExport; } + CellDirection celldirection, + CompletionType completionType); + + bool isNonDarcyFlow() const; + void setDFactor(double dFactor); + void setKh(double kh); + + void addMetadata(const QString& name, const QString& comment); + static bool isDefaultValue(double val); + + const std::vector& metadata() const; + const QString& wellName() const; + const RigCompletionDataGridCell& completionDataGridCell() const; + WellConnectionState connectionState() const; + double saturation() const; + double transmissibility() const; + double diameter() const; //TODO: should be ft or m + double kh() const; + double skinFactor() const; + double dFactor() const; + CellDirection direction() const; + size_t count() const; + double wpimult() const; + CompletionType completionType() const; + bool isMainBore() const; + + double firstOrderingValue() const; + double secondOrderingValue() const; std::vector m_metadata; private: QString m_wellName; - IJKCellIndex m_cellIndex; + RigCompletionDataGridCell m_cellIndex; WellConnectionState m_connectionState; double m_saturation; //TODO: remove, always use default in Eclipse? double m_transmissibility; @@ -161,13 +145,15 @@ class RigCompletionData CellDirection m_direction; bool m_isMainBore; //to use mainbore for Eclipse calculation - bool m_readyForExport; size_t m_count; //TODO: Remove, usage replaced by WPImult double m_wpimult; CompletionType m_completionType; + double m_firstOrderingValue; + double m_secondOrderingValue; + private: static bool onlyOneIsDefaulted(double first, double second); static void copy(RigCompletionData& target, const RigCompletionData& from); diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp new file mode 100644 index 0000000000..5e2c3a8c2a --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.cpp @@ -0,0 +1,126 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCompletionDataGridCell.h" + +#include "RigMainGrid.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCompletionDataGridCell::RigCompletionDataGridCell() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCompletionDataGridCell::RigCompletionDataGridCell(size_t globalCellIndex, const RigMainGrid* mainGrid) + : m_globalCellIndex(globalCellIndex) +{ + if (mainGrid) + { + size_t gridLocalCellIndex; + const RigGridBase* grid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIndex, &gridLocalCellIndex); + + if (grid) + { + size_t i = 0; + size_t j = 0; + size_t k = 0; + grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); + + m_localCellIndexI = i; + m_localCellIndexJ = j; + m_localCellIndexK = k; + + if (grid != mainGrid) + { + m_lgrName = QString::fromStdString(grid->gridName()); + } + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionDataGridCell::operator==(const RigCompletionDataGridCell& other) const +{ + return m_globalCellIndex == other.m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigCompletionDataGridCell::operator<(const RigCompletionDataGridCell& other) const +{ + if (m_localCellIndexI != other.m_localCellIndexI) return m_localCellIndexI < other.m_localCellIndexI; + if (m_localCellIndexJ != other.m_localCellIndexJ) return m_localCellIndexJ < other.m_localCellIndexJ; + if (m_localCellIndexK != other.m_localCellIndexK) return m_localCellIndexK < other.m_localCellIndexK; + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::globalCellIndex() const +{ + return m_globalCellIndex; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::localCellIndexI() const +{ + return m_localCellIndexI; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::localCellIndexJ() const +{ + return m_localCellIndexJ; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigCompletionDataGridCell::localCellIndexK() const +{ + return m_localCellIndexK; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigCompletionDataGridCell::oneBasedLocalCellIndexString() const +{ + QString text = QString("[%1, %2, %3]").arg(m_localCellIndexI + 1).arg(m_localCellIndexJ + 1).arg(m_localCellIndexK + 1); + + return text; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RigCompletionDataGridCell::lgrName() const +{ + return m_lgrName; +} diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.h b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.h new file mode 100644 index 0000000000..91637fa48c --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigCompletionDataGridCell.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class RigMainGrid; + +//================================================================================================== +/// +//================================================================================================== +class RigCompletionDataGridCell +{ +public: + RigCompletionDataGridCell(); + + RigCompletionDataGridCell(size_t globalCellIndex, const RigMainGrid* mainGrid); + + bool operator==(const RigCompletionDataGridCell& other) const; + + bool operator<(const RigCompletionDataGridCell& other) const; + + size_t globalCellIndex() const; + + size_t localCellIndexI() const; + size_t localCellIndexJ() const; + size_t localCellIndexK() const; + + QString oneBasedLocalCellIndexString() const; + + QString lgrName() const; + +private: + size_t m_globalCellIndex; + QString m_lgrName; + + size_t m_localCellIndexI; + size_t m_localCellIndexJ; + size_t m_localCellIndexK; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.h b/ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.h similarity index 84% rename from ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.h rename to ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.h index cd4dcc402f..6800ebc301 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseToStimPlanCellTransmissibilityCalculator.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigEclipseToStimPlanCellTransmissibilityCalculator.h @@ -59,13 +59,11 @@ class RigEclipseToStimPlanCellTransmissibilityCalculator const QString& uiResultName); private: - RimEclipseCase* m_case; - double m_cDarcy; - double m_fractureSkinFactor; - cvf::Mat4d m_fractureTransform; - const RigFractureCell& m_stimPlanCell; - - std::vector m_globalIndeciesToContributingEclipseCells; - std::vector m_contributingEclipseCellTransmissibilities; + RimEclipseCase* m_case; + double m_cDarcy; + double m_fractureSkinFactor; + cvf::Mat4d m_fractureTransform; + const RigFractureCell& m_stimPlanCell; + std::vector m_globalIndeciesToContributingEclipseCells; + std::vector m_contributingEclipseCellTransmissibilities; }; - diff --git a/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.cpp similarity index 99% rename from ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.cpp index b92ebece1f..fd7aa599a6 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.cpp @@ -17,22 +17,12 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigFractureTransmissibilityEquations.h" + #include "cvfBase.h" #include "cvfMath.h" -#include +#include -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -double RigFractureTransmissibilityEquations::centerToEdgeFractureCellTrans(double conductivity, - double sideLengthParallellTrans, - double sideLengthNormalTrans, - double cDarcyForRelevantUnit) -{ - double transmissibility = cDarcyForRelevantUnit * conductivity * sideLengthNormalTrans / (sideLengthParallellTrans / 2); - return transmissibility; -} //-------------------------------------------------------------------------------------------------- /// @@ -130,3 +120,16 @@ double RigFractureTransmissibilityEquations::matrixToFractureTrans(double perm, CVF_ASSERT(transmissibility == transmissibility); return transmissibility; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigFractureTransmissibilityEquations::centerToEdgeFractureCellTrans(double conductivity, + double sideLengthParallellTrans, + double sideLengthNormalTrans, + double cDarcyForRelevantUnit) +{ + double transmissibility = cDarcyForRelevantUnit * conductivity * sideLengthNormalTrans / (sideLengthParallellTrans / 2); + return transmissibility; +} + diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.h b/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.h new file mode 100644 index 0000000000..48073997e0 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigFractureTransmissibilityEquations.h @@ -0,0 +1,67 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RigFractureTransmissibilityEquations +{ +public: + static double centerToCenterFractureCellTrans(double conductivityCell1, + double sideLengthParallellTransCell1, + double sideLengthNormalTransCell1, + double conductivityCell2, + double sideLengthParallellTransCell2, + double sideLengthNormalTransCell2, + double cDarcyForRelevantUnit); + + static double fractureCellToWellRadialTrans(double fractureCellConductivity, + double fractureCellSizeX, + double fractureCellSizeZ, + double wellRadius, + double skinFactor, + double cDarcyForRelevantUnit); + + static double fractureCellToWellLinearTrans(double fractureConductivity, + double fractureCellSizeX, + double fractureCellSizeZ, + double perforationLengthVertical, + double perforationLengthHorizontal, + double perforationEfficiency, + double skinfactor, + double cDarcyForRelevantUnit); + + static double matrixToFractureTrans(double permX, + double NTG, + double Ay, + double dx, + double skinfactor, + double fractureAreaWeightedlength, + double cDarcy); + +private: + static double centerToEdgeFractureCellTrans(double conductivity, + double sideLengthParallellTrans, + double sideLengthNormalTrans, + double cDarcyForRelevantUnit); + + +}; diff --git a/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp similarity index 100% rename from ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.cpp diff --git a/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.h similarity index 93% rename from ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h rename to ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.h index e8277cdd3c..7664b5f87c 100644 --- a/ApplicationCode/ReservoirDataModel/RigTransmissibilityCondenser.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigTransmissibilityCondenser.h @@ -28,6 +28,9 @@ class RigMainGrid; class RimStimPlanFractureTemplate; class RigFractureGrid; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigTransmissibilityCondenser { public: diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp new file mode 100644 index 0000000000..12a4fafd3d --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.cpp @@ -0,0 +1,195 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigVirtualPerforationTransmissibilities.h" + +#include "RigStatisticsMath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +CompletionDataFrame::CompletionDataFrame() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void CompletionDataFrame::setCompletionData(const std::vector& completions) +{ + for (auto& completion : completions) + { + auto it = m_multipleCompletionsPerEclipseCell.find(completion.completionDataGridCell()); + if (it != m_multipleCompletionsPerEclipseCell.end()) + { + it->second.push_back(completion); + } + else + { + m_multipleCompletionsPerEclipseCell.insert(std::pair>( + completion.completionDataGridCell(), std::vector{completion})); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map>& + CompletionDataFrame::multipleCompletionsPerEclipseCell() const +{ + return m_multipleCompletionsPerEclipseCell; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigVirtualPerforationTransmissibilities::RigVirtualPerforationTransmissibilities() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigVirtualPerforationTransmissibilities::~RigVirtualPerforationTransmissibilities() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVirtualPerforationTransmissibilities::setCompletionDataForWellPath( + const RimWellPath* wellPath, + const std::vector>& completionsPerTimeStep) +{ + auto item = m_mapFromWellToCompletionData.find(wellPath); + + CVF_ASSERT(item == m_mapFromWellToCompletionData.end()); + + { + std::vector values; + + for (const auto& c : completionsPerTimeStep) + { + CompletionDataFrame oneTimeStep; + oneTimeStep.setCompletionData(c); + values.push_back(oneTimeStep); + } + + auto pair = std::pair>(wellPath, values); + + m_mapFromWellToCompletionData.insert(pair); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map>& + RigVirtualPerforationTransmissibilities::multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, + size_t timeStepIndex) const +{ + static std::map> dummy; + + auto item = m_mapFromWellToCompletionData.find(wellPath); + if (item != m_mapFromWellToCompletionData.end()) + { + size_t indexToUse = timeStepIndex; + if (item->second.size() == 1) + { + indexToUse = 0; + } + + return item->second[indexToUse].multipleCompletionsPerEclipseCell(); + } + + return dummy; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVirtualPerforationTransmissibilities::setCompletionDataForSimWell( + const RigSimWellData* simWellData, + const std::vector>& completionsPerTimeStep) +{ + m_mapFromSimWellToCompletionData[simWellData] = completionsPerTimeStep; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& + RigVirtualPerforationTransmissibilities::completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const +{ + static std::vector dummayVector; + + auto item = m_mapFromSimWellToCompletionData.find(simWellData); + if (item != m_mapFromSimWellToCompletionData.end()) + { + return item->second[timeStepIndex]; + } + + return dummayVector; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigVirtualPerforationTransmissibilities::computeMinMax(double* minValue, + double* maxValue, + double* posClosestToZero, + double* negClosestToZero) const +{ + MinMaxAccumulator minMaxAccumulator; + PosNegAccumulator posNegAccumulator; + + for (const auto& item : m_mapFromWellToCompletionData) + { + auto dataForWellPath = item.second; + + for (const auto& timeStepFrame : dataForWellPath) + { + for (const auto& allCompletionsForWell : timeStepFrame.multipleCompletionsPerEclipseCell()) + { + for (const auto& completionData : allCompletionsForWell.second) + { + double transmissibility = completionData.transmissibility(); + + minMaxAccumulator.addValue(transmissibility); + posNegAccumulator.addValue(transmissibility); + } + } + } + } + + for (const auto& item : m_mapFromSimWellToCompletionData) + { + auto dataForSimWell = item.second; + + for (const auto& timeStepFrame : dataForSimWell) + { + for (const auto& completionData : timeStepFrame) + { + double transmissibility = completionData.transmissibility(); + + minMaxAccumulator.addValue(transmissibility); + posNegAccumulator.addValue(transmissibility); + } + } + } + + if (*minValue) *minValue = minMaxAccumulator.min; + if (*maxValue) *maxValue = minMaxAccumulator.max; + if (*posClosestToZero) *posClosestToZero = posNegAccumulator.pos; + if (*negClosestToZero) *negClosestToZero = posNegAccumulator.neg; +} diff --git a/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h new file mode 100644 index 0000000000..411d2a28be --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/Completions/RigVirtualPerforationTransmissibilities.h @@ -0,0 +1,73 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "RigCompletionData.h" + +#include "cvfBase.h" +#include "cvfObject.h" + +#include +#include + +class RigCompletionData; +class RigCompletionDataGridCell; +class RigSimWellData; +class RimWellPath; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class CompletionDataFrame +{ +public: + CompletionDataFrame(); + + void setCompletionData(const std::vector& completions); + + const std::map>& multipleCompletionsPerEclipseCell() const; + +private: + std::map> m_multipleCompletionsPerEclipseCell; +}; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RigVirtualPerforationTransmissibilities : public cvf::Object +{ +public: + RigVirtualPerforationTransmissibilities(); + ~RigVirtualPerforationTransmissibilities(); + + void setCompletionDataForWellPath(const RimWellPath* wellPath, const std::vector>& completionsPerTimeStep); + + const std::map>& + multipleCompletionsPerEclipseCell(const RimWellPath* wellPath, size_t timeStepIndex) const; + + void setCompletionDataForSimWell(const RigSimWellData* simWellData, const std::vector>& completionsPerTimeStep); + + const std::vector& + completionsForSimWell(const RigSimWellData* simWellData, size_t timeStepIndex) const; + + void computeMinMax(double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; +private: + std::map> m_mapFromWellToCompletionData; + std::map>> m_mapFromSimWellToCompletionData; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp b/ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.cpp similarity index 91% rename from ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp rename to ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.cpp index 46c7c821c3..78c39ad3a2 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.cpp +++ b/ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.cpp @@ -35,11 +35,14 @@ #include -RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, RimFracture* rimFracture) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, const RimFracture* rimFracture) { std::vector wellPathPoints = wellpathGeom->wellPathPointsIncludingInterpolatedIntersectionPoint(rimFracture->fractureMD()); cvf::Mat4d fractureXf = rimFracture->transformMatrix(); - double wellRadius = rimFracture->wellRadius(rimFracture->fractureUnit()); + double wellRadius = rimFracture->wellRadius(); std::vector > stpCellPolygons; { RimFractureTemplate* fractureTemplate = rimFracture->fractureTemplate(); @@ -53,13 +56,19 @@ RigWellPathStimplanIntersector::RigWellPathStimplanIntersector(const RigWellPath double perforationLength = rimFracture->perforationLength(); calculate(fractureXf, wellPathPoints, wellRadius, perforationLength, stpCellPolygons, m_stimPlanCellIdxToIntersectionInfoMap); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::map& RigWellPathStimplanIntersector::intersections() const +{ + return m_stimPlanCellIdxToIntersectionInfoMap; } //-------------------------------------------------------------------------------------------------- /// Todo: Use only the perforated parts of the well path //-------------------------------------------------------------------------------------------------- - void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf, const std::vector& wellPathPointsOrg, double wellRadius, @@ -178,7 +187,7 @@ void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf, currentIntersectingWpPart.push_back(part.back()); } - if ( currentIntersectingWpPart.size() ) + if ( !currentIntersectingWpPart.empty() ) { intersectingWellPathParts.push_back(currentIntersectingWpPart); } @@ -197,7 +206,7 @@ void RigWellPathStimplanIntersector::calculate(const cvf::Mat4d &fractureXf, RigCellGeometryTools::USE_HUGEVAL); for ( const auto& wellPathPartInCell: wellPathPartsInPolygon ) { - if ( wellPathPartInCell.size() ) + if ( !wellPathPartInCell.empty() ) { int endpointCount = 0; if ( wellPathPartInCell.front().z() != HUGE_VAL ) ++endpointCount; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h b/ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.h similarity index 84% rename from ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h rename to ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.h index cbfa003e8e..dc5d38e823 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathStimplanIntersector.h +++ b/ApplicationCode/ReservoirDataModel/Completions/RigWellPathStimplanIntersector.h @@ -29,6 +29,9 @@ class RimFracture; class RigWellPathStimplanIntersectorTester; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigWellPathStimplanIntersector { public: @@ -40,9 +43,9 @@ class RigWellPathStimplanIntersector int endpointCount; }; - RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, RimFracture * rimFracture); + RigWellPathStimplanIntersector(const RigWellPath* wellpathGeom, const RimFracture* rimFracture); - const std::map& intersections() { return m_stimPlanCellIdxToIntersectionInfoMap; } + const std::map& intersections() const; private: friend class RigWellPathStimplanIntersectorTester; @@ -57,6 +60,9 @@ class RigWellPathStimplanIntersector }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigWellPathStimplanIntersectorTester { public: diff --git a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp index f09a8d8fc8..0c51ac5257 100644 --- a/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigActiveCellsResultAccessor.cpp @@ -26,9 +26,9 @@ RigActiveCellsResultAccessor::RigActiveCellsResultAccessor(const RigGridBase* grid, const std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) - : m_grid(grid), - m_reservoirResultValues(reservoirResultValues), - m_activeCellInfo(activeCellInfo) + : m_activeCellInfo(activeCellInfo), + m_grid(grid), + m_reservoirResultValues(reservoirResultValues) { } @@ -38,7 +38,7 @@ RigActiveCellsResultAccessor::RigActiveCellsResultAccessor(const RigGridBase* gr //-------------------------------------------------------------------------------------------------- double RigActiveCellsResultAccessor::cellScalar(size_t gridLocalCellIndex) const { - if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0 ) return HUGE_VAL; + if (m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0 ) return HUGE_VAL; size_t reservoirCellIndex = m_grid->reservoirCellIndex(gridLocalCellIndex); size_t resultValueIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex); @@ -65,7 +65,7 @@ double RigActiveCellsResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, c //-------------------------------------------------------------------------------------------------- double RigActiveCellsResultAccessor::cellScalarGlobIdx(size_t reservoirCellIndex) const { - if (m_reservoirResultValues == NULL || m_reservoirResultValues->size() == 0) return HUGE_VAL; + if (m_reservoirResultValues == nullptr || m_reservoirResultValues->size() == 0) return HUGE_VAL; size_t resultValueIndex = m_activeCellInfo->cellResultIndex(reservoirCellIndex); if (resultValueIndex == cvf::UNDEFINED_SIZE_T) return HUGE_VAL; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index 8b35439fb3..f7bbe9defe 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -44,9 +44,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData) : m_activeCellInfo(NULL) +RigCaseCellResultsData::RigCaseCellResultsData(RigEclipseCaseData* ownerCaseData) : m_activeCellInfo(nullptr) { - CVF_ASSERT(ownerCaseData != NULL); + CVF_ASSERT(ownerCaseData != nullptr); CVF_ASSERT(ownerCaseData->mainGrid() != nullptr); m_ownerCaseData = ownerCaseData; @@ -633,6 +633,7 @@ void RigCaseCellResultsData::clearScalarResult(RiaDefines::ResultCatType type, c if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) return; m_cellScalarResults[scalarResultIndex].clear(); + recalculateStatistics(scalarResultIndex); //m_resultInfos[scalarResultIndex].m_resultType = RiaDefines::REMOVED; } @@ -1269,8 +1270,9 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) // Compute SGAS based on SWAT if the simulation contains no oil testAndComputeSgasForTimeStep(timeStepIndex); - size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); - size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + size_t scalarIndexSWAT = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SWAT", timeStepIndex); + size_t scalarIndexSGAS = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SGAS", timeStepIndex); + size_t scalarIndexSSOL = findOrLoadScalarResultForTimeStep(RiaDefines::DYNAMIC_NATIVE, "SSOL", timeStepIndex); // Early exit if none of SWAT or SGAS is present if (scalarIndexSWAT == cvf::UNDEFINED_SIZE_T && scalarIndexSGAS == cvf::UNDEFINED_SIZE_T) @@ -1316,15 +1318,16 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) this->cellScalarResults(soilResultScalarIndex, timeStepIndex).resize(soilResultValueCount); - std::vector* swatForTimeStep = NULL; - std::vector* sgasForTimeStep = NULL; + std::vector* swatForTimeStep = nullptr; + std::vector* sgasForTimeStep = nullptr; + std::vector* ssolForTimeStep = nullptr; if (scalarIndexSWAT != cvf::UNDEFINED_SIZE_T) { swatForTimeStep = &(this->cellScalarResults(scalarIndexSWAT, timeStepIndex)); if (swatForTimeStep->size() == 0) { - swatForTimeStep = NULL; + swatForTimeStep = nullptr; } } @@ -1333,7 +1336,16 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) sgasForTimeStep = &(this->cellScalarResults(scalarIndexSGAS, timeStepIndex)); if (sgasForTimeStep->size() == 0) { - sgasForTimeStep = NULL; + sgasForTimeStep = nullptr; + } + } + + if (scalarIndexSSOL != cvf::UNDEFINED_SIZE_T) + { + ssolForTimeStep = &(this->cellScalarResults(scalarIndexSSOL, timeStepIndex)); + if (ssolForTimeStep->size() == 0) + { + ssolForTimeStep = nullptr; } } @@ -1353,6 +1365,11 @@ void RigCaseCellResultsData::computeSOILForTimeStep(size_t timeStepIndex) soilValue -= swatForTimeStep->at(idx); } + if (ssolForTimeStep) + { + soilValue -= ssolForTimeStep->at(idx); + } + soilForTimeStep[idx] = soilValue; } } @@ -1405,13 +1422,13 @@ void RigCaseCellResultsData::testAndComputeSgasForTimeStep(size_t timeStepIndex) this->cellScalarResults(scalarIndexSGAS, timeStepIndex).resize(swatResultValueCount); - std::vector* swatForTimeStep = NULL; + std::vector* swatForTimeStep = nullptr; { swatForTimeStep = &(this->cellScalarResults(scalarIndexSWAT, timeStepIndex)); if (swatForTimeStep->size() == 0) { - swatForTimeStep = NULL; + swatForTimeStep = nullptr; } } @@ -1554,7 +1571,7 @@ void calculateConnectionGeometry(const RigCell& c1, const RigCell& c2, const std bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &intersections, - (cvf::EdgeIntersectStorage*)NULL, + (cvf::EdgeIntersectStorage*)nullptr, cvf::wrapArrayConst(&nodes), face1.data(), face2.data(), @@ -1688,7 +1705,7 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo std::vector & permResults = this->cellScalarResults(permResultIdx)[0]; std::vector & riTransResults = this->cellScalarResults(riTransResultIdx)[0]; - std::vector * ntgResults = NULL; + std::vector * ntgResults = nullptr; if (hasNTGResults) { ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]); @@ -1699,9 +1716,9 @@ void RigCaseCellResultsData::computeRiTransComponent(const QString& riTransCompo riTransResults.resize(resultValueCount); // Prepare how to index the result values: - ResultIndexFunction riTranIdxFunc = NULL; - ResultIndexFunction permIdxFunc = NULL; - ResultIndexFunction ntgIdxFunc = NULL; + ResultIndexFunction riTranIdxFunc = nullptr; + ResultIndexFunction permIdxFunc = nullptr; + ResultIndexFunction ntgIdxFunc = nullptr; { bool isPermUsingResIdx = this->isUsingGlobalActiveIndex(permResultIdx); bool isTransUsingResIdx = this->isUsingGlobalActiveIndex(riTransResultIdx); @@ -1841,17 +1858,17 @@ void RigCaseCellResultsData::computeNncCombRiTrans() std::vector & riCombTransResults = m_ownerMainGrid->nncData()->makeStaticConnectionScalarResult(RigNNCData::propertyNameRiCombTrans()); m_ownerMainGrid->nncData()->setScalarResultIndex(RigNNCData::propertyNameRiCombTrans(), riCombTransScalarResultIndex); - std::vector * ntgResults = NULL; + std::vector * ntgResults = nullptr; if (hasNTGResults) { ntgResults = &(this->cellScalarResults(ntgResultIdx)[0]); } // Prepare how to index the result values: - ResultIndexFunction permXIdxFunc = NULL; - ResultIndexFunction permYIdxFunc = NULL; - ResultIndexFunction permZIdxFunc = NULL; - ResultIndexFunction ntgIdxFunc = NULL; + ResultIndexFunction permXIdxFunc = nullptr; + ResultIndexFunction permYIdxFunc = nullptr; + ResultIndexFunction permZIdxFunc = nullptr; + ResultIndexFunction ntgIdxFunc = nullptr; { bool isPermXUsingResIdx = this->isUsingGlobalActiveIndex(permXResultIdx); bool isPermYUsingResIdx = this->isUsingGlobalActiveIndex(permYResultIdx); @@ -1884,26 +1901,27 @@ void RigCaseCellResultsData::computeNncCombRiTrans() size_t neighborResvCellIdx = nncConnections[connIdx].m_c2GlobIdx; cvf::StructGridInterface::FaceType faceId = nncConnections[connIdx].m_c1Face; - ResultIndexFunction permIdxFunc = NULL; + ResultIndexFunction permIdxFunc = nullptr; std::vector * permResults; switch (faceId) { case cvf::StructGridInterface::POS_I: case cvf::StructGridInterface::NEG_I: - permIdxFunc = permXIdxFunc; - permResults = &permXResults; - break; + permIdxFunc = permXIdxFunc; + permResults = &permXResults; + break; case cvf::StructGridInterface::POS_J: case cvf::StructGridInterface::NEG_J: - permIdxFunc = permYIdxFunc; - permResults = &permYResults; - break; + permIdxFunc = permYIdxFunc; + permResults = &permYResults; + break; case cvf::StructGridInterface::POS_K: case cvf::StructGridInterface::NEG_K: - permIdxFunc = permZIdxFunc; - permResults = &permZResults; - break; + permIdxFunc = permZIdxFunc; + permResults = &permZResults; + break; + default: break; } if (!permIdxFunc) continue; @@ -2252,12 +2270,7 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) if (!eclipseCase) return; - RimProject* project; - eclipseCase->firstAncestorOrThisOfTypeAsserted(project); - - QDateTime timeStepDate = this->timeStepDates()[timeStep]; - - RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(project, eclipseCase, m_ownerMainGrid, completionTypeResult, timeStepDate); + RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(eclipseCase, completionTypeResult, timeStep); } diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h index 222459d0fb..5d0d420319 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.h @@ -74,7 +74,7 @@ class RigCaseCellResultsData : public cvf::Object // Access meta-information about the results size_t resultCount() const; size_t timeStepCount(size_t scalarResultIndex) const; - size_t maxTimeStepCount(size_t* scalarResultIndex = NULL) const; + size_t maxTimeStepCount(size_t* scalarResultIndex = nullptr) const; QStringList resultNames(RiaDefines::ResultCatType type) const; bool isUsingGlobalActiveIndex(size_t scalarResultIndex) const; bool hasFlowDiagUsableFluxes() const; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp new file mode 100644 index 0000000000..9c24814311 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.cpp @@ -0,0 +1,111 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigCaseRealizationParameters.h" +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value::Value() : m_valueType(TYPE_NONE), m_numericValue(HUGE_VAL) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value::Value(double value) : Value() +{ + setValue(value); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value::Value(const QString& value) : Value() +{ + setValue(value); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::Value::setValue(double value) +{ + m_valueType = TYPE_NUMERIC; + m_numericValue = value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::Value::setValue(const QString& value) +{ + m_valueType = TYPE_TEXT; + m_textValue = value; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigCaseRealizationParameters::Value::numericValue() const +{ + return m_numericValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RigCaseRealizationParameters::Value::textValue() const +{ + return m_textValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::addParameter(const QString& name, double value) +{ + m_parameters[name].setValue(value); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigCaseRealizationParameters::addParameter(const QString& name, const QString& value) +{ + m_parameters[name].setValue(value); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigCaseRealizationParameters::Value RigCaseRealizationParameters::parameterValue(const QString& name) +{ + if (m_parameters.count(name) == 0) return HUGE_VAL; + return m_parameters[name]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::map RigCaseRealizationParameters::parameters() const +{ + return m_parameters; +} diff --git a/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h new file mode 100644 index 0000000000..0ad579281a --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigCaseRealizationParameters.h @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2016- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" + +#include + +#include +#include + + +//================================================================================================== +// +// +//================================================================================================== +class RigCaseRealizationParameters +{ +public: + // Internal class + class Value + { + enum ValueType { TYPE_NONE, TYPE_NUMERIC, TYPE_TEXT }; + + public: + Value(); + Value(double value); + Value(const QString& value); + + void setValue(double value); + void setValue(const QString& value); + + bool isEmpty() const { return m_valueType == TYPE_NONE; } + bool isNumeric() const { return m_valueType == TYPE_NUMERIC; } + bool isText() const { return m_valueType == TYPE_TEXT; } + + double numericValue() const; + const QString& textValue() const; + + private: + ValueType m_valueType; + double m_numericValue; + QString m_textValue; + }; + + void addParameter(const QString& name, double value); + void addParameter(const QString& name, const QString& value); + Value parameterValue(const QString& name); + + std::map parameters() const; + +private: + std::map m_parameters; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp index ed3eff7898..29f11a515d 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapper.cpp @@ -31,8 +31,8 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigMainGrid* dependentEclGrid) : m_masterGrid(masterEclGrid), m_dependentGrid(dependentEclGrid), - m_masterFemPart(NULL), - m_dependentFemPart(NULL) + m_masterFemPart(nullptr), + m_dependentFemPart(nullptr) { m_masterCellOrIntervalIndex.resize(dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT); @@ -42,10 +42,10 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, Rig /// //-------------------------------------------------------------------------------------------------- RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigMainGrid* dependentEclGrid) - : m_masterGrid(NULL), + : m_masterGrid(nullptr), m_dependentGrid(dependentEclGrid), m_masterFemPart(masterFemPart), - m_dependentFemPart(NULL) + m_dependentFemPart(nullptr) { m_masterCellOrIntervalIndex.resize(dependentEclGrid->globalCellArray().size(), cvf::UNDEFINED_INT); this->calculateEclToGeomCellMapping(dependentEclGrid, masterFemPart, false); @@ -55,8 +55,8 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigM /// //-------------------------------------------------------------------------------------------------- RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigFemPart* dependentFemPart) - : m_masterGrid(NULL), - m_dependentGrid(NULL), + : m_masterGrid(nullptr), + m_dependentGrid(nullptr), m_masterFemPart(masterFemPart), m_dependentFemPart(dependentFemPart) { @@ -69,9 +69,9 @@ RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigFemPart* masterFemPart, RigF //-------------------------------------------------------------------------------------------------- RigCaseToCaseCellMapper::RigCaseToCaseCellMapper(RigMainGrid* masterEclGrid, RigFemPart* dependentFemPart) : m_masterGrid(masterEclGrid), - m_dependentGrid(NULL), + m_dependentGrid(nullptr), m_masterFemPart(dependentFemPart), - m_dependentFemPart(NULL) + m_dependentFemPart(nullptr) { m_masterCellOrIntervalIndex.resize(dependentFemPart->elementCount(), cvf::UNDEFINED_INT); this->calculateEclToGeomCellMapping(masterEclGrid, dependentFemPart, true); @@ -87,7 +87,7 @@ const int * RigCaseToCaseCellMapper::masterCaseCellIndices(int dependentCaseRese if (seriesIndex == cvf::UNDEFINED_INT) { (*masterCaseCellIndexCount) = 0; - return NULL; + return nullptr; } if (seriesIndex < 0) diff --git a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp index 48b1219292..2ea21dd336 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseToCaseCellMapperTools.cpp @@ -41,12 +41,12 @@ class RigNeighborCornerFinder const caf::SizeTArray8* neighborIndices(int offsetI, int offsetJ, int offsetK) { - if (offsetI < 0 && m_baseI == 0) return NULL; - if (offsetJ < 0 && m_baseJ == 0) return NULL; - if (offsetK < 0 && m_baseK == 0) return NULL; - if (offsetI > 0 && m_baseI == m_mainGrid->cellCountI()-1) return NULL; - if (offsetJ > 0 && m_baseJ == m_mainGrid->cellCountJ()-1) return NULL; - if (offsetK > 0 && m_baseK == m_mainGrid->cellCountK()-1) return NULL; + if (offsetI < 0 && m_baseI == 0) return nullptr; + if (offsetJ < 0 && m_baseJ == 0) return nullptr; + if (offsetK < 0 && m_baseK == 0) return nullptr; + if (offsetI > 0 && m_baseI == m_mainGrid->cellCountI()-1) return nullptr; + if (offsetJ > 0 && m_baseJ == m_mainGrid->cellCountJ()-1) return nullptr; + if (offsetK > 0 && m_baseK == m_mainGrid->cellCountK()-1) return nullptr; size_t gridLocalCellIndex = m_mainGrid->cellIndexFromIJK(m_baseI + offsetI, m_baseJ + offsetJ, m_baseK + offsetK); const RigCell& cell = m_mainGrid->globalCellArray()[gridLocalCellIndex]; diff --git a/ApplicationCode/ReservoirDataModel/RigCell.cpp b/ApplicationCode/ReservoirDataModel/RigCell.cpp index 2fc2a1a81d..de3c29aca6 100644 --- a/ApplicationCode/ReservoirDataModel/RigCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCell.cpp @@ -38,13 +38,13 @@ static size_t undefinedCornersArray[8] = {cvf::UNDEFINED_SIZE_T, /// //-------------------------------------------------------------------------------------------------- RigCell::RigCell() : + m_gridLocalCellIndex(cvf::UNDEFINED_SIZE_T), + m_hostGrid(nullptr), + m_subGrid(nullptr), m_parentCellIndex(cvf::UNDEFINED_SIZE_T), m_mainGridCellIndex(cvf::UNDEFINED_SIZE_T), - m_subGrid(NULL), - m_hostGrid(NULL), - m_isInvalid(false), - m_gridLocalCellIndex(cvf::UNDEFINED_SIZE_T), - m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T) + m_coarseningBoxIndex(cvf::UNDEFINED_SIZE_T), + m_isInvalid(false) { memcpy(m_cornerIndices.data(), undefinedCornersArray, 8*sizeof(size_t)); @@ -309,7 +309,7 @@ cvf::Vec3d RigCell::faceNormalWithAreaLenght(cvf::StructGridInterface::FaceType //-------------------------------------------------------------------------------------------------- int RigCell::firstIntersectionPoint(const cvf::Ray& ray, cvf::Vec3d* intersectionPoint) const { - CVF_ASSERT(intersectionPoint != NULL); + CVF_ASSERT(intersectionPoint != nullptr); cvf::ubyte faceVertexIndices[4]; int face; diff --git a/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp index ed3f5cc55d..1a337fbfd8 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellEdgeResultAccessor.cpp @@ -56,7 +56,7 @@ double RigCellEdgeResultAccessor::cellScalar(size_t gridLocalCellIndex) const double RigCellEdgeResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId) const { const RigResultAccessor* resultAccessObj = m_resultAccessObjects[faceId].p(); - if (resultAccessObj != NULL) + if (resultAccessObj != nullptr) { return resultAccessObj->cellFaceScalar(gridLocalCellIndex, faceId); } @@ -82,7 +82,7 @@ double RigCellEdgeResultAccessor::cellScalarGlobIdx(size_t globCellIndex) const double RigCellEdgeResultAccessor::cellFaceScalarGlobIdx(size_t globCellIndex, cvf::StructGridInterface::FaceType faceId) const { const RigResultAccessor* resultAccessObj = m_resultAccessObjects[faceId].p(); - if (resultAccessObj != NULL) + if (resultAccessObj != nullptr) { return resultAccessObj->cellFaceScalarGlobIdx(globCellIndex, faceId); } diff --git a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp index 11902ce077..5986063465 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.cpp @@ -24,9 +24,7 @@ #include "cafHexGridIntersectionTools/cafHexGridIntersectionTools.h" #include "cvfBoundingBox.h" -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES #include "clipper/clipper.hpp" -#endif // USE_PROTOTYPE_FEATURE_FRACTURES #include @@ -222,7 +220,6 @@ double RigCellGeometryTools::polygonLengthInLocalXdirWeightedByArea(std::vector< return areaWeightedLength; } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES double clipperConversionFactor = 10000; //For transform to clipper int @@ -249,7 +246,6 @@ cvf::Vec3d fromClipperPoint(const ClipperLib::IntPoint& clipPoint) return cvf::Vec3d (clipPoint.X, clipPoint.Y, zDValue ) /clipperConversionFactor; } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -258,7 +254,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st { std::vector > clippedPolygons; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES // Convert to int for clipper library and store as clipper "path" ClipperLib::Path polygon1path; for (cvf::Vec3d& v : polygon1) @@ -289,7 +284,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st } clippedPolygons.push_back(clippedPolygon); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return clippedPolygons; } @@ -297,7 +291,6 @@ std::vector > RigCellGeometryTools::intersectPolygons(st //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES void fillInterpolatedSubjectZ(ClipperLib::IntPoint& e1bot, ClipperLib::IntPoint& e1top, ClipperLib::IntPoint& e2bot, @@ -350,7 +343,6 @@ void fillUndefinedZ(ClipperLib::IntPoint& e1bot, { pt.Z = std::numeric_limits::max(); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// Assumes x.y plane polygon. Polyline might have a Z, and the returned Z is the polyline Z, interpolated if it is clipped. @@ -361,7 +353,6 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo { std::vector > clippedPolyline; -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //Adjusting polygon to avoid clipper issue with interpolating z-values when lines crosses though polygon vertecies std::vector adjustedPolygon = ajustPolygonToAvoidIntersectionsAtVertex(polyLine, polygon); @@ -410,7 +401,6 @@ std::vector > RigCellGeometryTools::clipPolylineByPolygo } clippedPolyline.push_back(clippedPolygon); } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES return clippedPolyline; } @@ -465,6 +455,43 @@ double RigCellGeometryTools::getLengthOfPolygonAlongLine(const std::pair RigCellGeometryTools::unionOfPolygons(std::vector> polygons) +{ + // Convert to int for clipper library and store as clipper "path" + std::vector polygonPaths; + for (const std::vector& polygon : polygons) + { + polygonPaths.emplace_back(); + auto& p = polygonPaths.back(); + for (const cvf::Vec3d& pp : polygon) + { + p.push_back(toClipperPoint(pp)); + } + } + + ClipperLib::Clipper clpr; + clpr.AddPaths(polygonPaths, ClipperLib::ptSubject, true); + + ClipperLib::Paths solution; + clpr.Execute(ClipperLib::ctUnion, solution, ClipperLib::pftEvenOdd, ClipperLib::pftEvenOdd); + + // Convert back to std::vector > + std::vector unionPolygon; + for (ClipperLib::Path pathInSol : solution) + { + std::vector clippedPolygon; + for (ClipperLib::IntPoint IntPosition : pathInSol) + { + unionPolygon.push_back(fromClipperPoint(IntPosition)); + } + } + + return unionPolygon; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h index 6a1b0c00da..24fc67fbf7 100644 --- a/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCellGeometryTools.h @@ -51,6 +51,8 @@ class RigCellGeometryTools static double getLengthOfPolygonAlongLine(const std::pair& line, const std::vector& polygon); + static std::vector unionOfPolygons(std::vector> polygons); + private: static std::vector ajustPolygonToAvoidIntersectionsAtVertex(const std::vector& polyLine, const std::vector& polygon); diff --git a/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp index 4ef5d409a1..ca12be699c 100644 --- a/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCombMultResultAccessor.cpp @@ -138,6 +138,8 @@ double RigCombMultResultAccessor::nativeMultScalar(size_t gridLocalCellIndex, cv } break; } + default: + break; } // FaceScalar with value HUGE_VAL means value outside valid IJK-range. Clamp to 1.0 as this means no change in MULT factor. diff --git a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp index 6fc358ae6f..fa7485a090 100644 --- a/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCombTransResultAccessor.cpp @@ -63,7 +63,7 @@ double RigCombTransResultAccessor::cellScalar(size_t gridLocalCellIndex) const //-------------------------------------------------------------------------------------------------- double RigCombTransResultAccessor::neighborCellTran(size_t gridLocalCellIndex, cvf::StructGridInterface::FaceType faceId, const RigResultAccessor* transAccessor) const { - if (transAccessor != NULL) + if (transAccessor != nullptr) { size_t i, j, k, neighborGridCellIdx; m_grid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); @@ -134,6 +134,8 @@ double RigCombTransResultAccessor::cellFaceScalar(size_t gridLocalCellIndex, cvf return this->neighborCellTran(gridLocalCellIndex, cvf::StructGridInterface::NEG_K, m_zTransAccessor.p()); } break; + default: + break; } return HUGE_VAL; diff --git a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp b/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp deleted file mode 100644 index 030cfd857a..0000000000 --- a/ApplicationCode/ReservoirDataModel/RigCompletionData.cpp +++ /dev/null @@ -1,264 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017 Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#include "RigCompletionData.h" - -#include "RiaLogging.h" - -#include "cvfAssert.h" - -#include - -#include // Needed for HUGE_VAL on Linux - - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData::RigCompletionData(const QString wellName, const IJKCellIndex& cellIndex) - : m_wellName(wellName), - m_cellIndex(cellIndex), - m_saturation(HUGE_VAL), - m_transmissibility(HUGE_VAL), - m_diameter(HUGE_VAL), - m_kh(HUGE_VAL), - m_skinFactor(HUGE_VAL), - m_dFactor(HUGE_VAL), - m_direction(DIR_UNDEF), - m_connectionState(OPEN), - m_count(1), - m_wpimult(HUGE_VAL), - m_isMainBore(false), - m_readyForExport(false), - m_completionType(CT_UNDEFINED) -{ -} - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData::~RigCompletionData() -{ -} - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData::RigCompletionData(const RigCompletionData& other) -{ - copy(*this, other); -} - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData RigCompletionData::combine(const std::vector& completions) -{ - CVF_ASSERT(!completions.empty()); - - auto it = completions.cbegin(); - RigCompletionData result(*it); - ++it; - - for (; it != completions.cend(); ++it) - { - if (it->completionType() != result.completionType()) - { - RiaLogging::error(QString("Cannot combine completions of different types in same cell [%1, %2, %3]").arg(result.m_cellIndex.i).arg(result.m_cellIndex.j).arg(result.m_cellIndex.k)); - continue; - } - if (onlyOneIsDefaulted(result.m_transmissibility, it->m_transmissibility)) - { - RiaLogging::error("Transmissibility defaulted in one but not both, will produce erroneous result"); - } - else - { - result.m_transmissibility += it->m_transmissibility; - } - - result.m_metadata.reserve(result.m_metadata.size() + it->m_metadata.size()); - result.m_metadata.insert(result.m_metadata.end(), it->m_metadata.begin(), it->m_metadata.end()); - - result.m_count += it->m_count; - } - - return result; -} - -//================================================================================================== -/// -//================================================================================================== -bool RigCompletionData::operator<(const RigCompletionData& other) const -{ - if (m_wellName != other.m_wellName) - { - return (m_wellName < other.m_wellName); - } - - return m_cellIndex < other.m_cellIndex; -} - -//================================================================================================== -/// -//================================================================================================== -RigCompletionData& RigCompletionData::operator=(const RigCompletionData& other) -{ - if (this != &other) - { - copy(*this, other); - } - return *this; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::setFromFracture(double transmissibility, double skinFactor) -{ - m_completionType = FRACTURE; - m_transmissibility = transmissibility; - m_skinFactor = skinFactor; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::setTransAndWPImultBackgroundDataFromFishbone(double transmissibility, - double skinFactor, - double diameter, - CellDirection direction, - bool isMainBore) -{ - m_completionType = FISHBONES; - m_transmissibility = transmissibility; - m_skinFactor = skinFactor; - m_diameter = diameter; - m_direction = direction; - m_isMainBore = isMainBore; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::setTransAndWPImultBackgroundDataFromPerforation(double transmissibility, - double skinFactor, - double diameter, - CellDirection direction) -{ - m_completionType = PERFORATION; - m_transmissibility = transmissibility; - m_skinFactor = skinFactor; - m_diameter = diameter; - m_direction = direction; - m_isMainBore = true; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::setCombinedValuesExplicitTrans(double transmissibility, - CompletionType completionType) -{ - m_completionType = completionType; - m_transmissibility = transmissibility; - m_readyForExport = true; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::setCombinedValuesImplicitTransWPImult(double wpimult, - CellDirection celldirection, - double skinFactor, - double wellDiameter, - CompletionType completionType) -{ - m_wpimult = wpimult; - m_direction = celldirection; - m_completionType = completionType; - m_skinFactor = skinFactor; - m_diameter = wellDiameter; - m_readyForExport = true; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::addMetadata(const QString& name, const QString& comment) -{ - m_metadata.push_back(RigCompletionMetaData(name, comment)); -} - -//================================================================================================== -/// -//================================================================================================== -bool RigCompletionData::isDefaultValue(double val) -{ - return val == HUGE_VAL; -} - -//================================================================================================== -/// -//================================================================================================== -bool RigCompletionData::onlyOneIsDefaulted(double first, double second) -{ - if (first == HUGE_VAL) - { - if (second == HUGE_VAL) - { - // Both have default values - return false; - } - else - { - // First has default value, second does not - return true; - } - } - if (second == HUGE_VAL) - { - // Second has default value, first does not - return true; - } - - // Neither has default values - return false; -} - -//================================================================================================== -/// -//================================================================================================== -void RigCompletionData::copy(RigCompletionData& target, const RigCompletionData& from) -{ - target.m_metadata = from.m_metadata; - target.m_wellName = from.m_wellName; - target.m_cellIndex = from.m_cellIndex; - target.m_connectionState = from.m_connectionState; - target.m_saturation = from.m_saturation; - target.m_transmissibility = from.m_transmissibility; - target.m_diameter = from.m_diameter; - target.m_kh = from.m_kh; - target.m_skinFactor = from.m_skinFactor; - target.m_dFactor = from.m_dFactor; - target.m_direction = from.m_direction; - target.m_isMainBore = from.m_isMainBore; - target.m_readyForExport = from.m_readyForExport; - target.m_count = from.m_count; - target.m_wpimult = from.m_wpimult; - target.m_completionType = from.m_completionType; -} diff --git a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h index ab195f241f..0e812e5540 100644 --- a/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h +++ b/ApplicationCode/ReservoirDataModel/RigCurveDataTools.h @@ -60,8 +60,6 @@ class RigCurveDataTools static std::vector> computePolyLineStartStopIndices(const CurveIntervals& intervals); public: - // Helper methods, available as public to be able to access from unit tests - static bool isValidValue(double value, bool allowPositiveValuesOnly); }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp index 477edc830c..f826c41094 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.cpp @@ -30,6 +30,7 @@ #include "RigSimWellData.h" #include "RigSimulationWellCenterLineCalculator.h" #include "RigSimulationWellCoordsAndMD.h" +#include "RigVirtualPerforationTransmissibilities.h" #include "RigWellPath.h" #include "RimFlowPlotCollection.h" @@ -474,7 +475,7 @@ bool RigEclipseCaseData::hasSimulationWell(const QString& simWellName) const //-------------------------------------------------------------------------------------------------- std::vector RigEclipseCaseData::simulationWellBranches(const QString& simWellName, bool includeAllCellCenters, - bool useAutoDetectionOfBranches) + bool useAutoDetectionOfBranches) const { std::vector branches; @@ -519,6 +520,22 @@ std::vector RigEclipseCaseData::simulationWellBranches(const return branches; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigEclipseCaseData::setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities) +{ + m_virtualPerforationTransmissibilities = virtualPerforationTransmissibilities; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigVirtualPerforationTransmissibilities* RigEclipseCaseData::virtualPerforationTransmissibilities() const +{ + return m_virtualPerforationTransmissibilities.p(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h index 0a2f0e83d9..1b760d8cd3 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseCaseData.h @@ -47,6 +47,7 @@ class RigSimWellData; class RigCell; class RigWellPath; class RimEclipseCase; +class RigVirtualPerforationTransmissibilities; struct RigWellResultPoint; @@ -108,7 +109,10 @@ class RigEclipseCaseData : public cvf::Object std::vector simulationWellBranches(const QString& simWellName, bool includeAllCellCenters, - bool useAutoDetectionOfBranches); + bool useAutoDetectionOfBranches) const; + + void setVirtualPerforationTransmissibilities(RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities); + const RigVirtualPerforationTransmissibilities* virtualPerforationTransmissibilities() const; private: void computeActiveCellIJKBBox(); @@ -127,11 +131,13 @@ class RigEclipseCaseData : public cvf::Object cvf::ref m_activeFormationNamesData; + cvf::ref m_virtualPerforationTransmissibilities; + cvf::Collection m_simWellData; //< A WellResults object for each well in the reservoir cvf::Collection m_wellCellsInGrid; //< A bool array pr grid with one bool pr cell telling whether the cell is a well cell or not cvf::Collection m_gridCellToResultWellIndex; //< Array pr grid with index to well pr cell telling which well a cell is in RiaEclipseUnitTools::UnitSystem m_unitsType; - std::map, cvf::Collection> m_simWellBranchCache; + mutable std::map, cvf::Collection> m_simWellBranchCache; }; diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h index bab42e2063..04fd59e4d0 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeStatCalc.h @@ -71,11 +71,11 @@ class RigEclipseNativeStatCalc : public RigStatisticsCalculator // Filter out inactive cells if (!actCellInfo->isActive(cIdx)) continue; - size_t cellResultIndex = cIdx; - if (m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex)) - { - cellResultIndex = actCellInfo->cellResultIndex(cIdx); - } + size_t cellResultIndex = cIdx; + if (m_resultsData->isUsingGlobalActiveIndex(m_scalarResultIndex)) + { + cellResultIndex = actCellInfo->cellResultIndex(cIdx); + } if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size()) { diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h index afa65bded9..e67bf1daec 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseNativeVisibleCellsStatCalc.h @@ -73,11 +73,11 @@ class RigEclipseNativeVisibleCellsStatCalc : public RigStatisticsCalculator { if (!(*m_cellVisibilities)[cIdx]) continue; - size_t cellResultIndex = cIdx; - if (m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex)) - { - cellResultIndex = actCellInfo->cellResultIndex(cIdx); - } + size_t cellResultIndex = cIdx; + if (m_caseData->isUsingGlobalActiveIndex(m_scalarResultIndex)) + { + cellResultIndex = actCellInfo->cellResultIndex(cIdx); + } if (cellResultIndex != cvf::UNDEFINED_SIZE_T && cellResultIndex < values.size()) { diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index a9e2e57dca..5b5079c5bb 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -19,6 +19,8 @@ #include "RigEclipseWellLogExtractor.h" +#include "RiaLogging.h" + #include "RigEclipseCaseData.h" #include "RigMainGrid.h" #include "RigResultAccessor.h" @@ -35,13 +37,15 @@ /// //================================================================================================== -RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigEclipseCaseData* aCase, const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName) - : m_caseData(aCase), RigWellLogExtractor(wellpath, wellCaseErrorMsgName) +RigEclipseWellLogExtractor::RigEclipseWellLogExtractor(const RigEclipseCaseData* aCase, + const RigWellPath* wellpath, + const std::string& wellCaseErrorMsgName) + : RigWellLogExtractor(wellpath, wellCaseErrorMsgName) + , m_caseData(aCase) { calculateIntersection(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -49,10 +53,9 @@ void RigEclipseWellLogExtractor::calculateIntersection() { std::map uniqueIntersections; - const std::vector& nodeCoords = m_caseData->mainGrid()->nodes(); bool isCellFaceNormalsOut = m_caseData->mainGrid()->isFaceNormalsOutwards(); - if (!m_wellPath->m_wellPathPoints.size()) return ; + if (m_wellPath->m_wellPathPoints.empty()) return; for (size_t wpp = 0; wpp < m_wellPath->m_wellPathPoints.size() - 1; ++wpp) { @@ -60,42 +63,30 @@ void RigEclipseWellLogExtractor::calculateIntersection() cvf::Vec3d p1 = m_wellPath->m_wellPathPoints[wpp]; cvf::Vec3d p2 = m_wellPath->m_wellPathPoints[wpp+1]; - cvf::BoundingBox bb; bb.add(p1); bb.add(p2); - std::vector closeCells = findCloseCells(bb); - + std::vector closeCellIndices = findCloseCellIndices(bb); cvf::Vec3d hexCorners[8]; - for (size_t cIdx = 0; cIdx < closeCells.size(); ++cIdx) + for (const auto& globalCellIndex : closeCellIndices) { - const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[closeCells[cIdx]]; + const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex]; if (cell.isInvalid()) continue; - const caf::SizeTArray8& cornerIndices = cell.cornerIndices(); - - hexCorners[0] = nodeCoords[cornerIndices[0]]; - hexCorners[1] = nodeCoords[cornerIndices[1]]; - hexCorners[2] = nodeCoords[cornerIndices[2]]; - hexCorners[3] = nodeCoords[cornerIndices[3]]; - hexCorners[4] = nodeCoords[cornerIndices[4]]; - hexCorners[5] = nodeCoords[cornerIndices[5]]; - hexCorners[6] = nodeCoords[cornerIndices[6]]; - hexCorners[7] = nodeCoords[cornerIndices[7]]; + m_caseData->mainGrid()->cellCornerVertices(globalCellIndex, hexCorners); - //int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners, closeCells[cIdx], &intersections); - RigHexIntersectionTools::lineHexCellIntersection(p1, p2, hexCorners, closeCells[cIdx], &intersections); + RigHexIntersectionTools::lineHexCellIntersection(p1, p2, hexCorners, globalCellIndex, &intersections); } if (!isCellFaceNormalsOut) { - for (size_t intIdx = 0; intIdx < intersections.size(); ++intIdx) + for (auto& intersection : intersections) { - intersections[intIdx].m_isIntersectionEntering = !intersections[intIdx].m_isIntersectionEntering ; + intersection.m_isIntersectionEntering = !intersection.m_isIntersectionEntering; } } @@ -114,6 +105,63 @@ void RigEclipseWellLogExtractor::calculateIntersection() } + if (uniqueIntersections.empty() && m_wellPath->m_wellPathPoints.size() > 1) + { + // When entering this function, all well path points are either completely outside the grid + // or all well path points are inside one cell + + cvf::Vec3d firstPoint = m_wellPath->m_wellPathPoints.front(); + cvf::Vec3d lastPoint = m_wellPath->m_wellPathPoints.back(); + + { + cvf::BoundingBox bb; + bb.add(firstPoint); + + std::vector closeCellIndices = findCloseCellIndices(bb); + + cvf::Vec3d hexCorners[8]; + for (const auto& globalCellIndex : closeCellIndices) + { + const RigCell& cell = m_caseData->mainGrid()->globalCellArray()[globalCellIndex]; + + if (cell.isInvalid()) continue; + + m_caseData->mainGrid()->cellCornerVertices(globalCellIndex, hexCorners); + + if (RigHexIntersectionTools::isPointInCell(firstPoint, hexCorners)) + { + if (RigHexIntersectionTools::isPointInCell(lastPoint, hexCorners)) + { + { + // Mark the first well path point as entering the cell + + bool isEntering = true; + HexIntersectionInfo info(firstPoint, isEntering, cvf::StructGridInterface::NO_FACE, globalCellIndex); + RigMDCellIdxEnterLeaveKey enterLeaveKey(m_wellPath->m_measuredDepths.front(), globalCellIndex, isEntering); + + uniqueIntersections.insert(std::make_pair(enterLeaveKey, info)); + } + + { + // Mark the last well path point as leaving cell + + bool isEntering = false; + HexIntersectionInfo info(lastPoint, isEntering, cvf::StructGridInterface::NO_FACE, globalCellIndex); + RigMDCellIdxEnterLeaveKey enterLeaveKey(m_wellPath->m_measuredDepths.back(), globalCellIndex, isEntering); + + uniqueIntersections.insert(std::make_pair(enterLeaveKey, info)); + } + } + else + { + QString txt = "Detected two points assumed to be in the same cell, but they are in two different cells"; + RiaLogging::debug(txt); + } + } + } + } + } + this->populateReturnArrays(uniqueIntersections); } @@ -134,11 +182,10 @@ void RigEclipseWellLogExtractor::curveData(const RigResultAccessor* resultAccess } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigEclipseWellLogExtractor::findCloseCells(const cvf::BoundingBox& bb) +std::vector RigEclipseWellLogExtractor::findCloseCellIndices(const cvf::BoundingBox& bb) { std::vector closeCells; m_caseData->mainGrid()->findIntersectingCells(bb, &closeCells); @@ -155,4 +202,3 @@ cvf::Vec3d RigEclipseWellLogExtractor::calculateLengthInCell(size_t cellIndex, c return RigWellPathIntersectionTools::calculateLengthInCell(hexCorners, startPoint, endPoint); } - diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h index b30286c870..e6067d0616 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.h @@ -41,9 +41,9 @@ class RigEclipseWellLogExtractor : public RigWellLogExtractor const RigEclipseCaseData* caseData() { return m_caseData.p();} -protected: +private: void calculateIntersection(); - std::vector findCloseCells(const cvf::BoundingBox& bb); + std::vector findCloseCellIndices(const cvf::BoundingBox& bb); virtual cvf::Vec3d calculateLengthInCell(size_t cellIndex, const cvf::Vec3d& startPoint, const cvf::Vec3d& endPoint) const override; diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h index 1bb81d117b..28f2098b91 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagResultAddress.h @@ -52,8 +52,9 @@ class RigFlowDiagResultAddress RigFlowDiagResultAddress(const std::string& aVariableName, PhaseSelection phaseSelection, const std::set& someSelectedTracerNames) : variableName(aVariableName), - phaseSelection(phaseSelection), - selectedTracerNames(someSelectedTracerNames) {} + selectedTracerNames(someSelectedTracerNames), + phaseSelection(phaseSelection) + {} RigFlowDiagResultAddress(const std::string& aVariableName, PhaseSelection phaseSelection, const std::string& tracerName) : variableName(aVariableName), diff --git a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp index 7ffa197027..daf17bec06 100644 --- a/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFlowDiagSolverInterface.cpp @@ -132,7 +132,7 @@ class RigOpmFlowDiagStaticData : public cvf::Object try { - m_eclSaturationFunc.reset(new Opm::ECLSaturationFunc(*m_eclGraph, initData, true, Opm::ECLSaturationFunc::InvalidEPBehaviour::IgnorePoint)); + m_eclSaturationFunc.reset(new Opm::ECLSaturationFunc(*m_eclGraph, initData)); } catch (...) { @@ -672,11 +672,17 @@ std::vector RigFlowDiagSolverInterface // Calculate and return curves both with and without endpoint scaling and tag them accordingly // Must use two calls to achieve this - const std::array epsModeArr = { RelPermCurve::EPS_ON , RelPermCurve::EPS_OFF }; + const std::array epsModeArr = { {RelPermCurve::EPS_ON , RelPermCurve::EPS_OFF} }; for (RelPermCurve::EpsMode epsMode : epsModeArr) { const bool useEps = epsMode == RelPermCurve::EPS_ON ? true : false; - std::vector graphArr = m_opmFlowDiagStaticData->m_eclSaturationFunc->getSatFuncCurve(satFuncRequests, static_cast(activeCellIndex), useEps); + + Opm::ECLSaturationFunc::SatFuncScaling scaling; + if (!useEps) { + scaling.enable = static_cast(0); + } + scaling.invalid = Opm::SatFunc::EPSEvalInterface::InvalidEndpointBehaviour::IgnorePoint; + std::vector graphArr = m_opmFlowDiagStaticData->m_eclSaturationFunc->getSatFuncCurve(satFuncRequests, static_cast(activeCellIndex), scaling); for (size_t i = 0; i < graphArr.size(); i++) { const RelPermCurve::Ident curveIdent = curveIdentNameArr[i].first; diff --git a/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp b/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp index 666c581ac2..9da6e3faa5 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFractureCell.cpp @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 - Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -22,35 +22,80 @@ #include - //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RigFractureCell::RigFractureCell(std::vector polygon, size_t i, size_t j) + : m_polygon(polygon) + , m_i(i) + , m_j(j) + , m_concutivityValue(0.0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFractureCell::getPolygon() const +{ + return m_polygon; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigFractureCell::getConductivtyValue() const +{ + return m_concutivityValue; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureCell::getI() const +{ + return m_i; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureCell::getJ() const +{ + return m_j; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigFractureCell::hasNonZeroConductivity() const { - m_polygon = polygon; - m_i = i; - m_j = j; - m_concutivityValue = 0.0; + return m_concutivityValue > 1e-7; } //-------------------------------------------------------------------------------------------------- -/// +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureCell::setConductivityValue(double cond) +{ + m_concutivityValue = cond; +} + +//-------------------------------------------------------------------------------------------------- +/// //-------------------------------------------------------------------------------------------------- double RigFractureCell::cellSizeX() const { - //The polygon corners are always stored in the same order - if (m_polygon.size()>1) return (m_polygon[1] - m_polygon[0]).length(); + // The polygon corners are always stored in the same order + if (m_polygon.size() > 1) return (m_polygon[1] - m_polygon[0]).length(); return cvf::UNDEFINED_DOUBLE; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- double RigFractureCell::cellSizeZ() const { - if (m_polygon.size()>2) return (m_polygon[2] - m_polygon[1]).length(); + if (m_polygon.size() > 2) return (m_polygon[2] - m_polygon[1]).length(); return cvf::UNDEFINED_DOUBLE; } - - diff --git a/ApplicationCode/ReservoirDataModel/RigFractureCell.h b/ApplicationCode/ReservoirDataModel/RigFractureCell.h index 76ff63aa69..fc1a4d9907 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureCell.h +++ b/ApplicationCode/ReservoirDataModel/RigFractureCell.h @@ -33,13 +33,13 @@ class RigFractureCell public: RigFractureCell(std::vector polygon, size_t i, size_t j); - const std::vector& getPolygon() const { return m_polygon; } - double getConductivtyValue() const { return m_concutivityValue; } - size_t getI() const { return m_i; } - size_t getJ() const { return m_j; } + const std::vector& getPolygon() const; + double getConductivtyValue() const; + size_t getI() const; + size_t getJ() const; - bool hasNonZeroConductivity() const { return m_concutivityValue > 1e-7; } - void setConductivityValue(double cond) { m_concutivityValue = cond; } + bool hasNonZeroConductivity() const; + void setConductivityValue(double cond); double cellSizeX() const; double cellSizeZ() const; @@ -50,4 +50,3 @@ class RigFractureCell size_t m_i; size_t m_j; }; - diff --git a/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp b/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp index 07b5c86a5c..9ea5ba4d75 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigFractureGrid.cpp @@ -1,37 +1,78 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 - Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #include "RigFractureGrid.h" + #include "RiaLogging.h" + #include //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- RigFractureGrid::RigFractureGrid() - : m_iCellCount(0), - m_jCellCount(0) + : m_iCellCount(0) + , m_jCellCount(0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setFractureCells(std::vector fractureCells) +{ + m_fractureCells = fractureCells; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setWellCenterFractureCellIJ(std::pair wellCenterFractureCellIJ) +{ + m_wellCenterFractureCellIJ = wellCenterFractureCellIJ; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setICellCount(size_t iCellCount) +{ + m_iCellCount = iCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigFractureGrid::setJCellCount(size_t jCellCount) { + m_jCellCount = jCellCount; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const std::vector& RigFractureGrid::fractureCells() const +{ + return m_fractureCells; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- size_t RigFractureGrid::getGlobalIndexFromIJ(size_t i, size_t j) const { @@ -39,7 +80,7 @@ size_t RigFractureGrid::getGlobalIndexFromIJ(size_t i, size_t j) const } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const { @@ -50,7 +91,7 @@ const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const } else { - //TODO: Better error handling? + // TODO: Better error handling? RiaLogging::error(QString("Requesting non-existent StimPlanCell")); RiaLogging::error(QString("Returning cell 0, results will be invalid")); const RigFractureCell& cell = m_fractureCells[0]; @@ -58,4 +99,26 @@ const RigFractureCell& RigFractureGrid::cellFromIndex(size_t index) const } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureGrid::jCellCount() const +{ + return m_jCellCount; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigFractureGrid::iCellCount() const +{ + return m_iCellCount; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RigFractureGrid::fractureCellAtWellCenter() const +{ + return m_wellCenterFractureCellIJ; +} diff --git a/ApplicationCode/ReservoirDataModel/RigFractureGrid.h b/ApplicationCode/ReservoirDataModel/RigFractureGrid.h index 430b48f5a2..c4e9a89784 100644 --- a/ApplicationCode/ReservoirDataModel/RigFractureGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigFractureGrid.h @@ -31,28 +31,26 @@ class RigFractureCell; /// //================================================================================================== class RigFractureGrid : public cvf::Object - { public: RigFractureGrid(); - void setFractureCells(std::vector fractureCells) { m_fractureCells = fractureCells; } - void setWellCenterFractureCellIJ(std::pair wellCenterFractureCellIJ) { m_wellCenterFractureCellIJ = wellCenterFractureCellIJ; } - void setICellCount(size_t iCellCount) { m_iCellCount = iCellCount; } - void setJCellCount(size_t jCellCount) { m_jCellCount = jCellCount; } + void setFractureCells(std::vector fractureCells); + void setWellCenterFractureCellIJ(std::pair wellCenterFractureCellIJ); + void setICellCount(size_t iCellCount); + void setJCellCount(size_t jCellCount); - const std::vector& fractureCells() const { return m_fractureCells; } + const std::vector& fractureCells() const; size_t getGlobalIndexFromIJ(size_t i, size_t j) const; const RigFractureCell& cellFromIndex(size_t index) const; - size_t jCellCount() const { return m_jCellCount; } - size_t iCellCount() const { return m_iCellCount; } + size_t jCellCount() const; + size_t iCellCount() const; - std::pair fractureCellAtWellCenter() const { return m_wellCenterFractureCellIJ; } + std::pair fractureCellAtWellCenter() const; private: - std::vector m_fractureCells; - std::pair m_wellCenterFractureCellIJ; - size_t m_iCellCount; - size_t m_jCellCount; + std::vector m_fractureCells; + std::pair m_wellCenterFractureCellIJ; + size_t m_iCellCount; + size_t m_jCellCount; }; - diff --git a/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.h b/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.h deleted file mode 100644 index c6b02179b8..0000000000 --- a/ApplicationCode/ReservoirDataModel/RigFractureTransmissibilityEquations.h +++ /dev/null @@ -1,63 +0,0 @@ -///////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) 2017- Statoil ASA -// -// 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 -// for more details. -// -///////////////////////////////////////////////////////////////////////////////// - -#pragma once - - -class RigFractureTransmissibilityEquations -{ -public: - static double centerToEdgeFractureCellTrans(double conductivity, - double sideLengthParallellTrans, - double sideLengthNormalTrans, - double cDarcyForRelevantUnit); - - static double centerToCenterFractureCellTrans(double conductivityCell1, - double sideLengthParallellTransCell1, - double sideLengthNormalTransCell1, - double conductivityCell2, - double sideLengthParallellTransCell2, - double sideLengthNormalTransCell2, - double cDarcyForRelevantUnit); - - static double fractureCellToWellRadialTrans(double fractureCellConductivity, - double fractureCellSizeX, - double fractureCellSizeZ, - double wellRadius, - double skinFactor, - double cDarcyForRelevantUnit); - - static double fractureCellToWellLinearTrans(double fractureConductivity, - double fractureCellSizeX, - double fractureCellSizeZ, - double perforationLengthVertical, - double perforationLengthHorizontal, - double perforationEfficiency, - double skinfactor, - double cDarcyForRelevantUnit); - - static double matrixToFractureTrans(double permX, - double NTG, - double Ay, - double dx, - double skinfactor, - double fractureAreaWeightedlength, - double cDarcy); - -}; - diff --git a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp index 9c451682f3..db430a0537 100644 --- a/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGeoMechWellLogExtractor.cpp @@ -30,11 +30,15 @@ #include "RigWellPath.h" #include "cvfGeometryTools.h" #include "RigWellPathIntersectionTools.h" + //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RigGeoMechWellLogExtractor::RigGeoMechWellLogExtractor(RigGeoMechCaseData* aCase, const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName) - :m_caseData(aCase), RigWellLogExtractor(wellpath, wellCaseErrorMsgName) +RigGeoMechWellLogExtractor::RigGeoMechWellLogExtractor(RigGeoMechCaseData* aCase, + const RigWellPath* wellpath, + const std::string& wellCaseErrorMsgName) + : RigWellLogExtractor(wellpath, wellCaseErrorMsgName) + , m_caseData(aCase) { calculateIntersection(); } @@ -70,6 +74,12 @@ void RigGeoMechWellLogExtractor::curveData(const RigFemResultAddress& resAddr, i if (!(elmType == HEX8 || elmType == HEX8P)) continue; + if (convResAddr.resultPosType == RIG_ELEMENT) + { + (*values)[cpIdx] = resultValues[elmIdx]; + continue; + } + cvf::StructGridInterface::FaceType cellFace = m_intersectedCellFaces[cpIdx]; int faceNodeCount = 0; diff --git a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp index 2ae082b21f..6e42c71bfd 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridBase.cpp @@ -29,10 +29,10 @@ RigGridBase::RigGridBase(RigMainGrid* mainGrid): m_gridPointDimensions(0,0,0), - m_mainGrid(mainGrid), - m_indexToStartOfCells(0) + m_indexToStartOfCells(0), + m_mainGrid(mainGrid) { - if (mainGrid == NULL) + if (mainGrid == nullptr) { m_gridIndex = 0; m_gridId = 0; @@ -493,7 +493,7 @@ bool RigGridCellFaceVisibilityFilter::isFaceVisible(size_t i, size_t j, size_t k } // If the neighbour cell is invisible, we need to draw the face - if ((cellVisibility != NULL) && !(*cellVisibility)[neighborCellIndex]) + if ((cellVisibility != nullptr) && !(*cellVisibility)[neighborCellIndex]) { return true; } diff --git a/ApplicationCode/ReservoirDataModel/RigGridManager.cpp b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp index e52d0525e6..bd153f09cb 100644 --- a/ApplicationCode/ReservoirDataModel/RigGridManager.cpp +++ b/ApplicationCode/ReservoirDataModel/RigGridManager.cpp @@ -58,7 +58,7 @@ RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid) return mainGrid; } } - return NULL; + return nullptr; } @@ -67,7 +67,7 @@ RigMainGrid* RigGridManager::findEqualGrid(RigMainGrid* candidateGrid) //-------------------------------------------------------------------------------------------------- bool RigGridManager::isEqual(RigMainGrid* gridA, RigMainGrid* gridB) { - if (gridA == NULL || gridB == NULL) return false; + if (gridA == nullptr || gridB == nullptr) return false; if (gridA == gridB) return true; diff --git a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp index 54940ef0b8..3d51738c39 100644 --- a/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigHexIntersectionTools.cpp @@ -35,7 +35,7 @@ int RigHexIntersectionTools::lineHexCellIntersection(const cvf::Vec3d p1, const size_t hexIndex, std::vector* intersections) { - CVF_ASSERT(intersections != NULL); + CVF_ASSERT(intersections != nullptr); std::set uniqueIntersections; diff --git a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp index b6090829e8..706a5fac38 100644 --- a/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLasFileExporter.cpp @@ -92,9 +92,9 @@ class SingleLasFileMetaData { public: SingleLasFileMetaData() - : m_minimumCurveValue(HUGE_VAL), - m_rkbDiff(HUGE_VAL), - m_exportTvdrkb(false) + : m_rkbDiff(HUGE_VAL) + , m_exportTvdrkb(false) + , m_minimumCurveValue(HUGE_VAL) { } @@ -394,7 +394,7 @@ bool RigLasFileExporter::writeToFolder(const QString& exportFolder) if (caf::Utils::fileExists(fileName)) { QString txt = QString("File %1 exists.\n\nDo you want to overwrite the file?").arg(fileName); - int ret = QMessageBox::question(NULL, "LAS File Export", + int ret = QMessageBox::question(nullptr, "LAS File Export", txt, QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes); diff --git a/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp b/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp index 9b4ebbe248..652574913d 100644 --- a/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigLocalGrid.cpp @@ -22,7 +22,7 @@ RigLocalGrid::RigLocalGrid(RigMainGrid* mainGrid): RigGridBase(mainGrid), - m_parentGrid(NULL), + m_parentGrid(nullptr), m_positionInParentGrid(cvf::UNDEFINED_SIZE_T) { diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp index 11b2615fe8..adcd09cd42 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.cpp @@ -47,6 +47,33 @@ RigMainGrid::~RigMainGrid(void) { } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx) +{ + CVF_ASSERT(globalCellIdx < m_cells.size()); + RigCell& cell = m_cells[globalCellIdx]; + RigGridBase* hostGrid = cell.hostGrid(); + CVF_ASSERT(hostGrid); + *gridLocalCellIdx = cell.gridLocalCellIndex(); + return hostGrid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const RigGridBase* RigMainGrid::gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx) const +{ + CVF_ASSERT(globalCellIdx < m_cells.size()); + const RigCell& cell = m_cells[globalCellIdx]; + const RigGridBase* hostGrid = cell.hostGrid(); + CVF_ASSERT(hostGrid); + *gridLocalCellIdx = cell.gridLocalCellIndex(); + return hostGrid; +} + + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -295,7 +322,7 @@ void RigMainGrid::calculateFaults(const RigActiveCellInfo* activeCellInfo) size_t neighborReservoirCellIdx; size_t neighborGridCellIdx; size_t i, j, k; - RigGridBase* hostGrid = NULL; + RigGridBase* hostGrid = nullptr; bool firstNO_FAULTFaceForCell = true; bool isCellActive = true; @@ -313,8 +340,10 @@ void RigMainGrid::calculateFaults(const RigActiveCellInfo* activeCellInfo) // Find neighbor cell if (firstNO_FAULTFaceForCell) // To avoid doing this for every face, and only when detecting a NO_FAULT { - hostGrid = m_cells[gcIdx].hostGrid(); - hostGrid->ijkFromCellIndex(m_cells[gcIdx].gridLocalCellIndex(), &i,&j, &k); + size_t gridLocalCellIndex; + hostGrid = this->gridAndGridLocalIdxFromGlobalCellIdx(gcIdx, &gridLocalCellIndex); + + hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i,&j, &k); isCellActive = activeCellInfo->isActive(gcIdx); firstNO_FAULTFaceForCell = false; @@ -474,9 +503,9 @@ bool RigMainGrid::isFaceNormalsOutwards() const //-------------------------------------------------------------------------------------------------- const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirCellIndex, cvf::StructGridInterface::FaceType face) const { - CVF_ASSERT(m_faultsPrCellAcc.notNull()); + CVF_TIGHT_ASSERT(m_faultsPrCellAcc.notNull()); - if (face == cvf::StructGridInterface::NO_FACE) return NULL; + if (face == cvf::StructGridInterface::NO_FACE) return nullptr; int faultIdx = m_faultsPrCellAcc->faultIdx(reservoirCellIndex, face); if (faultIdx != RigFaultsPrCellAccumulator::NO_FAULT ) @@ -510,7 +539,7 @@ const RigFault* RigMainGrid::findFaultFromCellIndexAndCellFace(size_t reservoirC } } #endif - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -555,7 +584,7 @@ void RigMainGrid::buildCellSearchTree() } m_cellSearchTree = new cvf::BoundingBoxTree; - m_cellSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, NULL); + m_cellSearchTree->buildTreeFromBoundingBoxes(cellBoundingBoxes, nullptr); } } diff --git a/ApplicationCode/ReservoirDataModel/RigMainGrid.h b/ApplicationCode/ReservoirDataModel/RigMainGrid.h index 2b5b1e431f..7e1fdb6098 100644 --- a/ApplicationCode/ReservoirDataModel/RigMainGrid.h +++ b/ApplicationCode/ReservoirDataModel/RigMainGrid.h @@ -51,6 +51,9 @@ class RigMainGrid : public RigGridBase std::vector& globalCellArray() {return m_cells;} const std::vector& globalCellArray() const {return m_cells;} + RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx); + const RigGridBase* gridAndGridLocalIdxFromGlobalCellIdx(size_t globalCellIdx, size_t* gridLocalCellIdx) const; + const RigCell& cellByGridAndGridLocalCellIdx(size_t gridIdx, size_t gridLocalCellIdx) const; size_t reservoirCellIndexByGridAndGridLocalCellIndex(size_t gridIdx, size_t gridLocalCellIdx) const; diff --git a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp index ef0461f12c..9d9ce21efa 100644 --- a/ApplicationCode/ReservoirDataModel/RigNNCData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNNCData.cpp @@ -150,7 +150,7 @@ cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap(const Ri #endif - for ( char fIdx = 0; fIdx < 6; ++fIdx ) + for ( unsigned char fIdx = 0; fIdx < 6; ++fIdx ) { if ( !isPossibleNeighborInDirection[fIdx] ) { @@ -169,7 +169,7 @@ cvf::StructGridInterface::FaceType RigNNCData::calculateCellFaceOverlap(const Ri bool foundOverlap = cvf::GeometryTools::calculateOverlapPolygonOfTwoQuads( &polygon, &intersections, - (cvf::EdgeIntersectStorage*)NULL, + (cvf::EdgeIntersectStorage*)nullptr, cvf::wrapArrayConst(&mainGrid.nodes()), face1.data(), face2.data(), diff --git a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp index 09f43e0821..a59ca86f3a 100644 --- a/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigNumberOfFloodedPoreVolumesCalculator.cpp @@ -359,7 +359,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMai if (!actCellInfo->isActive(reservoirCellIndexPosINeighbour)) continue; - if (hostGrid->cell(gridLocalCellIndexPosINeighbour).subGrid() != NULL) + if (hostGrid->cell(gridLocalCellIndexPosINeighbour).subGrid() != nullptr) { //subgrid exists in cell, will be handled though NNCs continue; @@ -385,7 +385,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMai if (!actCellInfo->isActive(reservoirCellIndexPosJNeighbour)) continue; - if (hostGrid->cell(gridLocalCellIndexPosJNeighbour).subGrid() != NULL) + if (hostGrid->cell(gridLocalCellIndexPosJNeighbour).subGrid() != nullptr) { //subgrid exists in cell, will be handled though NNCs continue; @@ -412,7 +412,7 @@ void RigNumberOfFloodedPoreVolumesCalculator::distributeNeighbourCellFlow(RigMai if (!actCellInfo->isActive(reservoirCellIndexPosKNeighbour)) continue; - if (hostGrid->cell(gridLocalCellIndexPosKNeighbour).subGrid() != NULL) + if (hostGrid->cell(gridLocalCellIndexPosKNeighbour).subGrid() != nullptr) { //subgrid exists in cell, will be handled though NNCs continue; diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp index 40d287ff48..07505ad984 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirBuilderMock.cpp @@ -298,7 +298,7 @@ bool RigReservoirBuilderMock::inputProperty(RigEclipseCaseData* eclipseCase, con size_t k; /* initialize random seed: */ - srand ( time(NULL) ); + srand ( time(nullptr) ); /* generate secret number: */ int iSecret = rand() % 20 + 1; @@ -536,7 +536,7 @@ void RigReservoirBuilderMock::addFaults(RigEclipseCaseData* eclipseCase) size_t k1 = 3; size_t i2 = 2; - size_t j2 = 5; + size_t j2 = 1; size_t k2 = 4; addNnc(grid, i1, j1, k1, i2, j2, k2, nncConnections); diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp index 5ba709567a..08b6d551a5 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.cpp @@ -103,7 +103,7 @@ QString RigReservoirGridTools::gridName(RimCase* rimCase, int gridIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigActiveCellInfo* RigReservoirGridTools::activeCellInfo(RimView* rimView) +RigActiveCellInfo* RigReservoirGridTools::activeCellInfo(Rim3dView* rimView) { RimEclipseView* eclipseView = dynamic_cast(rimView); if (eclipseView) diff --git a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h index 1e56fade1b..4682a0c396 100644 --- a/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h +++ b/ApplicationCode/ReservoirDataModel/RigReservoirGridTools.h @@ -22,7 +22,7 @@ class RigActiveCellInfo; class RigFemPartCollection; class RigMainGrid; class RimCase; -class RimView; +class Rim3dView; namespace cvf { @@ -43,7 +43,7 @@ class RigReservoirGridTools static const cvf::StructGridInterface* gridByIndex(RimCase* rimCase, int gridIndex); static QString gridName(RimCase* rimCase, int gridIndex); - static RigActiveCellInfo* activeCellInfo(RimView* rimView); + static RigActiveCellInfo* activeCellInfo(Rim3dView* rimView); private: static RigMainGrid* eclipseMainGrid(RimCase* rimCase); diff --git a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp index 89172faf4c..5500061ec6 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultAccessorFactory.cpp @@ -73,13 +73,13 @@ cvf::ref RigResultAccessorFactory::createFromNameAndType(cons if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(resultType, uiResultName); if (scalarSetIndex == cvf::UNDEFINED_SIZE_T) { - return NULL; + return nullptr; } cvf::ref derivedCandidate = createDerivedResultAccessor(eclipseCase, @@ -155,13 +155,13 @@ cvf::ref RigResultAccessorFactory::createNativeFromUiResultNa if (!eclipseCase || !eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName); if (scalarSetIndex == cvf::UNDEFINED_SIZE_T) { - return NULL; + return nullptr; } return createFromResultIdx(eclipseCase, gridIndex, porosityModel, timeStepIndex, scalarSetIndex); @@ -323,10 +323,10 @@ cvf::ref RigResultAccessorFactory::createFromResultIdx(const return new RigHugeValResultAccessor; } - if (!eclipseCase) return NULL; + if (!eclipseCase) return nullptr; const RigGridBase* grid = eclipseCase->grid(gridIndex); - if (!grid) return NULL; + if (!grid) return nullptr; const std::vector< std::vector >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(resultIndex); @@ -335,7 +335,7 @@ cvf::ref RigResultAccessorFactory::createFromResultIdx(const return new RigHugeValResultAccessor; } - const std::vector* resultValues = NULL; + const std::vector* resultValues = nullptr; if (timeStepIndex < scalarSetResults.size()) { resultValues = &(scalarSetResults[timeStepIndex]); diff --git a/ApplicationCode/ReservoirDataModel/RigResultModifier.h b/ApplicationCode/ReservoirDataModel/RigResultModifier.h index 79bb36495d..93e54ce1b3 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultModifier.h +++ b/ApplicationCode/ReservoirDataModel/RigResultModifier.h @@ -66,10 +66,12 @@ class RigAllGridCellsResultModifier : public RigResultModifier class RigActiveCellsResultModifier : public RigResultModifier { public: - RigActiveCellsResultModifier(const RigGridBase* grid, std::vector* reservoirResultValues, const RigActiveCellInfo* activeCellInfo) - : m_grid(grid), - m_reservoirResultValues(reservoirResultValues), - m_activeCellInfo(activeCellInfo) + RigActiveCellsResultModifier(const RigGridBase* grid, + const RigActiveCellInfo* activeCellInfo, + std::vector* reservoirResultValues) + : m_grid(grid) + , m_activeCellInfo(activeCellInfo) + , m_reservoirResultValues(reservoirResultValues) { } @@ -85,8 +87,8 @@ class RigActiveCellsResultModifier : public RigResultModifier private: - const RigActiveCellInfo* m_activeCellInfo; const RigGridBase* m_grid; + const RigActiveCellInfo* m_activeCellInfo; std::vector* m_reservoirResultValues; }; diff --git a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp index ba772a5837..de4c947115 100644 --- a/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp +++ b/ApplicationCode/ReservoirDataModel/RigResultModifierFactory.cpp @@ -35,11 +35,11 @@ cvf::ref RigResultModifierFactory::createResultModifier(RigEc size_t timeStepIndex, QString& uiResultName) { - if (!eclipseCase) return NULL; + if (!eclipseCase) return nullptr; if (!eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } size_t scalarSetIndex = eclipseCase->results(porosityModel)->findScalarResultIndex(uiResultName); @@ -56,32 +56,32 @@ cvf::ref RigResultModifierFactory::createResultModifier(RigEc RiaDefines::PorosityModelType porosityModel, size_t timeStepIndex, size_t scalarResultIndex) { - if ( !eclipseCase ) return NULL; + if ( !eclipseCase ) return nullptr; if (!eclipseCase->results(porosityModel) || !eclipseCase->activeCellInfo(porosityModel)) { - return NULL; + return nullptr; } if (scalarResultIndex == cvf::UNDEFINED_SIZE_T) { - return NULL; + return nullptr; } RigGridBase* grid = eclipseCase->grid(gridIndex); if (!grid) { - return NULL; + return nullptr; } std::vector< std::vector >& scalarSetResults = eclipseCase->results(porosityModel)->cellScalarResults(scalarResultIndex); if (timeStepIndex >= scalarSetResults.size()) { - return NULL; + return nullptr; } - std::vector* resultValues = NULL; + std::vector* resultValues = nullptr; if (timeStepIndex < scalarSetResults.size()) { resultValues = &(scalarSetResults[timeStepIndex]); @@ -90,7 +90,7 @@ cvf::ref RigResultModifierFactory::createResultModifier(RigEc bool useGlobalActiveIndex = eclipseCase->results(porosityModel)->isUsingGlobalActiveIndex(scalarResultIndex); if (useGlobalActiveIndex) { - cvf::ref object = new RigActiveCellsResultModifier(grid, resultValues, eclipseCase->activeCellInfo(porosityModel)); + cvf::ref object = new RigActiveCellsResultModifier(grid, eclipseCase->activeCellInfo(porosityModel), resultValues); return object; } else diff --git a/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp b/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp index d58b222127..1b3072a523 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimWellData.cpp @@ -22,6 +22,14 @@ #include +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigSimWellData::RigSimWellData() + : m_isMultiSegmentWell(false) +{ +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -371,7 +379,7 @@ const RigWellResultPoint* RigWellResultFrame::findResultCell(size_t gridIndex, s return &m_wellHead; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/ReservoirDataModel/RigSimWellData.h b/ApplicationCode/ReservoirDataModel/RigSimWellData.h index d945526d14..a8fa9c58e6 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimWellData.h +++ b/ApplicationCode/ReservoirDataModel/RigSimWellData.h @@ -18,6 +18,8 @@ #pragma once +#include "RigWellResultPoint.h" + #include "cvfBase.h" #include "cvfObject.h" #include "cvfMath.h" @@ -27,162 +29,13 @@ #include -//================================================================================================== -/// Stores the info on a significant point in the well. Either a well-to-grid connection, or the -/// bottom position of a connection less well-segment -//================================================================================================== -struct RigWellResultPoint -{ - RigWellResultPoint() : - m_gridIndex(cvf::UNDEFINED_SIZE_T), - m_gridCellIndex(cvf::UNDEFINED_SIZE_T), - m_isOpen(false), - m_ertBranchId(-1), - m_ertSegmentId(-1), - m_bottomPosition(cvf::Vec3d::UNDEFINED), - m_flowRate(0.0), - m_oilRate(0.0), - m_gasRate(0.0), - m_waterRate(0.0) - { } - - bool isPointValid() const - { - return m_bottomPosition != cvf::Vec3d::UNDEFINED; - } - - bool isCell() const - { - return m_gridCellIndex != cvf::UNDEFINED_SIZE_T; - } - - bool isValid() const - { - return isCell() || isPointValid(); - } - - double flowRate() const - { - if ( isCell() && m_isOpen) - { - return m_flowRate; - } - else - { - return 0.0; - } - } - - double oilRate() const - { - if ( isCell() && m_isOpen) - { - return m_oilRate; - } - else - { - return 0.0; - } - } - - double gasRate() const - { - if ( isCell() && m_isOpen) - { - return m_gasRate; - } - else - { - return 0.0; - } - } - - double waterRate() const - { - if ( isCell() && m_isOpen) - { - return m_waterRate; - } - else - { - return 0.0; - } - } - - bool isEqual(const RigWellResultPoint& other ) const - { - return ( m_gridIndex == other.m_gridIndex - && m_gridCellIndex == other.m_gridCellIndex - && m_isOpen == other.m_isOpen - && m_ertBranchId == other.m_ertBranchId - && m_ertSegmentId == other.m_ertSegmentId - && m_flowRate == other.m_flowRate); - } - - size_t m_gridIndex; - size_t m_gridCellIndex; //< Index to cell which is included in the well - - bool m_isOpen; //< Marks the well as open or closed as of Eclipse simulation - - int m_ertBranchId; - int m_ertSegmentId; - - cvf::Vec3d m_bottomPosition; //< The estimated bottom position of the well segment, when we have no grid cell connections for the segment. - double m_flowRate; //< Total reservoir rate - double m_oilRate; //< Surface oil rate - double m_gasRate; //< Surface gas rate For Field-unit, converted to [stb/day] to allign with oil and water. - double m_waterRate; //< Surface water rate -}; - -//================================================================================================== -/// This class contains the connection information from and including a splitpoint to the end of -/// that particular branch. -//================================================================================================== -struct RigWellResultBranch -{ - RigWellResultBranch() : - m_ertBranchId(-1) - {} - - int m_ertBranchId; - std::vector m_branchResultPoints; -}; - -//================================================================================================== -/// This class contains the well information for one timestep. -/// The main content is the vector of RigWellResultBranch which contains all the simple pipe -/// sections that make up the well -//================================================================================================== -class RigWellResultFrame -{ -public: - enum WellProductionType { PRODUCER, OIL_INJECTOR, GAS_INJECTOR, WATER_INJECTOR, UNDEFINED_PRODUCTION_TYPE }; - -public: - RigWellResultFrame() : - m_isOpen(false), - m_productionType(UNDEFINED_PRODUCTION_TYPE) - { } - - const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const; - - RigWellResultPoint wellHeadOrStartCell() const; - WellProductionType m_productionType; - bool m_isOpen; - RigWellResultPoint m_wellHead; - QDateTime m_timestamp; - - std::vector m_wellResultBranches; -}; - - //================================================================================================== /// //================================================================================================== class RigSimWellData : public cvf::Object { public: - RigSimWellData() { m_isMultiSegmentWell = false; } + RigSimWellData(); void setMultiSegmentWell(bool isMultiSegmentWell); bool isMultiSegmentWell() const; diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp index 8212160165..2d47615e51 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.cpp @@ -40,25 +40,14 @@ /// The returned CellIds is one less than the number of centerline points, /// and are describing the lines between the points, starting with the first line //-------------------------------------------------------------------------------------------------- -void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) -{ - calculateWellPipeDynamicCenterline(rimWell, -1, pipeBranchesCLCoords, pipeBranchesCellIds); -} - - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(const RimSimWellInView* rimWell, - int timeStepIndex, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) +void RigSimulationWellCenterLineCalculator::calculateWellPipeStaticCenterline( + RimSimWellInView* rimWell, + std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds) { CVF_ASSERT(rimWell); - const RigSimWellData* simWellData = rimWell->simWellData(); + const RigSimWellData* simWellData = rimWell->simWellData(); RimEclipseView* eclipseView; rimWell->firstAncestorOrThisOfType(eclipseView); @@ -66,16 +55,17 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeDynamicCenterline(c CVF_ASSERT(eclipseView); RigEclipseCaseData* eclipseCaseData = eclipseView->eclipseCase()->eclipseCaseData(); - bool isAutoDetectBranches = eclipseView->wellCollection()->isAutoDetectingBranches(); + bool isAutoDetectBranches = eclipseView->wellCollection()->isAutoDetectingBranches(); - bool useAllCellCenters = rimWell->isUsingCellCenterForPipe(); + bool useAllCellCenters = rimWell->isUsingCellCenterForPipe(); + int timeStepIndex = -1; calculateWellPipeCenterlineFromWellFrame(eclipseCaseData, simWellData, timeStepIndex, isAutoDetectBranches, useAllCellCenters, - pipeBranchesCLCoords, + pipeBranchesCLCoords, pipeBranchesCellIds); } @@ -140,7 +130,7 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF cvf::Vec3d whIntermediate = whStartPos; whIntermediate.z() = (whStartPos.z() + whCell.center().z()) / 2.0; - const RigWellResultPoint* prevWellResPoint = NULL; + const RigWellResultPoint* prevWellResPoint = nullptr; // CVF_ASSERT(isMultiSegmentWell || resBranches.size() <= 1); // TODO : Consider to set isMultiSegmentWell = true; @@ -158,7 +148,7 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF const RigWellResultBranch& branch = resBranches[brIdx]; if ( !hasAnyValidDataCells(branch) ) continue; - prevWellResPoint = NULL; + prevWellResPoint = nullptr; // Find the start the MSW well-branch centerline. Normal wells are started "once" at wellhead in the code above diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h index 9a2d85a2a8..ec87e69112 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCenterLineCalculator.h @@ -19,34 +19,33 @@ #pragma once #include "RigSimWellData.h" + #include "cvfVector3.h" + #include class RigEclipseCaseData; class RimSimWellInView; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigSimulationWellCenterLineCalculator { public: - static void calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) ; - - static void calculateWellPipeDynamicCenterline(const RimSimWellInView* rimWell, - int timeStepIndex, - std::vector< std::vector >& pipeBranchesCLCoords, - std::vector< std::vector >& pipeBranchesCellIds) ; - - - static void calculateWellPipeCenterlineFromWellFrame(const RigEclipseCaseData* eclipseCaseData, - const RigSimWellData* simWellData, - int timeStepIndex, - bool isAutoDetectBranches, - bool useAllCellCenters, - std::vector> &pipeBranchesCLCoords, - std::vector> &pipeBranchesCellIds); -private: + static void calculateWellPipeStaticCenterline(RimSimWellInView* rimWell, + std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds); + + static void calculateWellPipeCenterlineFromWellFrame(const RigEclipseCaseData* eclipseCaseData, + const RigSimWellData* simWellData, + int timeStepIndex, + bool isAutoDetectBranches, + bool useAllCellCenters, + std::vector>& pipeBranchesCLCoords, + std::vector>& pipeBranchesCellIds); +private: static bool hasAnyResultCells(const std::vector &resBranches); static bool hasAnyValidDataCells(const RigWellResultBranch& branch); static void finishPipeCenterLine( std::vector< std::vector > &pipeBranchesCLCoords, const cvf::Vec3d& lastCellCenter ) ; diff --git a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp index 3a4f6fe839..9535232f91 100644 --- a/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSimulationWellCoordsAndMD.cpp @@ -92,7 +92,7 @@ double RigSimulationWellCoordsAndMD::locationAlongWellCoords(const cvf::Vec3d& p size_t closestIndex = findClosestIndex(position); - if (closestIndex != cvf::UNDEFINED_DOUBLE) + if (closestIndex != cvf::UNDEFINED_SIZE_T) { cvf::Vec3d p1 = m_wellPathPoints[closestIndex - 1]; cvf::Vec3d p2 = m_wellPathPoints[closestIndex - 0]; diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp index bf3b17d63b..8cd4e1a6fb 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.cpp @@ -18,60 +18,214 @@ #include "RigStimPlanFractureDefinition.h" -#include +#include "RiaFractureDefines.h" +#include "RiaLogging.h" -#include "cvfMath.h" -#include "RivWellFracturePartMgr.h" #include "RigFractureCell.h" -#include "RiaLogging.h" #include "RigFractureGrid.h" +#include "RigStatisticsMath.h" + +#include "RivWellFracturePartMgr.h" + +#include "cvfMath.h" + #include +//-------------------------------------------------------------------------------------------------- +/// Internal functions +//-------------------------------------------------------------------------------------------------- +size_t findMirrorXIndex(std::vector xs); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const double RigStimPlanFractureDefinition::THRESHOLD_VALUE = 1e-5; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigStimPlanFractureDefinition::RigStimPlanFractureDefinition() : + m_unitSet(RiaEclipseUnitTools::UNITS_UNKNOWN), m_topPerfTvd(HUGE_VAL), m_bottomPerfTvd(HUGE_VAL) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigStimPlanFractureDefinition::~RigStimPlanFractureDefinition() +{ + +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigStimPlanResultFrames::RigStimPlanResultFrames() +RiaEclipseUnitTools::UnitSystem RigStimPlanFractureDefinition::unitSet() const { + return m_unitSet; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigStimPlanFractureDefinition::xCount() const +{ + return m_Xs.size(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t RigStimPlanFractureDefinition::yCount() const +{ + return m_Ys.size(); +} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigStimPlanFractureDefinition::RigStimPlanFractureDefinition() : m_unitSet(RiaEclipseUnitTools::UNITS_UNKNOWN) +double RigStimPlanFractureDefinition::minDepth() const { + return -minY(); +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::maxDepth() const +{ + return -maxY(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigStimPlanFractureDefinition::~RigStimPlanFractureDefinition() +double RigStimPlanFractureDefinition::topPerfTvd() const +{ + return m_topPerfTvd; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::bottomPerfTvd() const +{ + return m_bottomPerfTvd; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::minY() const { + return m_Ys[0]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigStimPlanFractureDefinition::maxY() const +{ + return m_Ys.back(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::scaleXs(double scaleFactor) +{ + // Scale using 0 as scaling anchor + for (double& x : m_Xs) + { + x *= scaleFactor; + } +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::scaleYs(double scaleFactor, double wellPathIntersectionY) +{ + // Scale using wellPathIntersectionY as scaling anchor + for (double& y : m_Ys) + { + y = (y - wellPathIntersectionY) * scaleFactor + wellPathIntersectionY; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::setTvdToTopPerf(double topPerfTvd) +{ + m_topPerfTvd = topPerfTvd; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RigStimPlanFractureDefinition::setTvdToBottomPerf(double bottomPerfTvd) +{ + m_bottomPerfTvd = bottomPerfTvd; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigStimPlanFractureDefinition::getNegAndPosXcoords() const +void RigStimPlanFractureDefinition::generateXsFromFileXs(bool xMirrorMode) { - std::vector allXcoords; - for ( const double& xCoord : m_gridXs ) + m_xMirrorMode = xMirrorMode; + m_Xs.clear(); + + if (m_xMirrorMode) { - if ( xCoord > 1e-5 ) + size_t mirrorIndex = findMirrorXIndex(m_fileXs); + std::list xs; + + // Mirror positive X values + xs.push_back(m_fileXs[mirrorIndex]); + for (size_t i = mirrorIndex + 1; i < m_fileXs.size(); i++) { - double negXcoord = -xCoord; - allXcoords.insert(allXcoords.begin(), negXcoord); + xs.push_front(-m_fileXs[i]); + xs.push_back(m_fileXs[i]); } + m_Xs = std::vector(xs.begin(), xs.end()); } - for ( const double& xCoord : m_gridXs ) + else { - allXcoords.push_back(xCoord); + m_Xs = m_fileXs; } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector> RigStimPlanFractureDefinition::generateDataLayoutFromFileDataLayout(std::vector> fileXYData) +{ + if (m_xMirrorMode) + { + std::vector> xyData; + size_t mirrorIndex = findMirrorXIndex(m_fileXs); + + for (const auto& yData : fileXYData) + { + std::list xValues; - return allXcoords; + // Mirror positive X values + xValues.push_back(yData[mirrorIndex]); + for (size_t x = mirrorIndex + 1; x < yData.size(); x++) + { + xValues.push_front(yData[x]); + xValues.push_back(yData[x]); + } + xyData.push_back(std::vector(xValues.begin(), xValues.end())); + } + return xyData; + } + else + { + return fileXYData; + } } //-------------------------------------------------------------------------------------------------- @@ -79,13 +233,12 @@ std::vector RigStimPlanFractureDefinition::getNegAndPosXcoords() const //-------------------------------------------------------------------------------------------------- bool RigStimPlanFractureDefinition::numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep) { - size_t depths = this->depths.size(); - size_t gridXvalues = this->m_gridXs.size(); + size_t xCount = m_Xs.size(); - if ( propertyValuesAtTimestep.size() != depths ) return false; + if ( propertyValuesAtTimestep.size() != yCount()) return false; for ( std::vector valuesAtDepthVector : propertyValuesAtTimestep ) { - if ( valuesAtDepthVector.size() != gridXvalues ) return false; + if ( valuesAtDepthVector.size() != xCount ) return false; } return true; @@ -94,17 +247,16 @@ bool RigStimPlanFractureDefinition::numberOfParameterValuesOK(std::vector RigStimPlanFractureDefinition::adjustedDepthCoordsAroundWellPathPosition(double wellPathDepthAtFracture) const +std::vector RigStimPlanFractureDefinition::adjustedYCoordsAroundWellPathPosition(double wellPathIntersectionAtFractureDepth) const { - std::vector depthRelativeToWellPath; + std::vector yRelativeToWellPath; - for ( const double& depth : this->depths ) + for ( const double& y : m_Ys ) { - double adjustedDepth = depth - wellPathDepthAtFracture; - adjustedDepth = -adjustedDepth; - depthRelativeToWellPath.push_back(adjustedDepth); + double adjustedDepth = y + wellPathIntersectionAtFractureDepth; + yRelativeToWellPath.push_back(adjustedDepth); } - return depthRelativeToWellPath; + return yRelativeToWellPath; } //-------------------------------------------------------------------------------------------------- @@ -123,50 +275,93 @@ std::vector > RigStimPlanFractureDefinition::getStim } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -std::vector> RigStimPlanFractureDefinition::getMirroredDataAtTimeIndex(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const +std::vector> + RigStimPlanFractureDefinition::conductivityValuesAtTimeStep(const QString& resultName, + int activeTimeStepIndex, + RiaEclipseUnitTools::UnitSystem requiredUnitSet) const { - std::vector> notMirrordedData = this->getDataAtTimeIndex(resultName, unitName, timeStepIndex); - std::vector> mirroredData; + std::vector> conductivityValues; + + QString conductivityUnitTextOnFile; - for ( std::vector depthData : notMirrordedData ) + std::vector> propertyNamesUnitsOnFile = this->getStimPlanPropertyNamesUnits(); + for (auto properyNameUnit : propertyNamesUnitsOnFile) { - std::vector mirrordDepthData = RivWellFracturePartMgr::mirrorDataAtSingleDepth(depthData); - mirroredData.push_back(mirrordDepthData); + if (resultName == properyNameUnit.first) + { + conductivityUnitTextOnFile = properyNameUnit.second; + } } - return mirroredData; + if (conductivityUnitTextOnFile.isEmpty()) + { + RiaLogging::error("Did not find unit for conductivity on file"); + + return conductivityValues; + } + + conductivityValues = this->getDataAtTimeIndex(resultName, conductivityUnitTextOnFile, activeTimeStepIndex); + + // Convert to the conductivity unit system used by the fracture template + // The conductivity value is used in the computations of transmissibility when exporting COMPDAT, and has unit md-m or md-ft + // This unit must match the unit used to represent coordinates of the grid used for export + + QString conversionUnitText; + if (conductivityUnitTextOnFile == "md-m") + { + conversionUnitText = "m"; + } + else if (conductivityUnitTextOnFile == "md-ft") + { + conversionUnitText = "ft"; + } + + for (auto& yValues : conductivityValues) + { + for (auto& xVal : yValues) + { + if (requiredUnitSet == RiaEclipseUnitTools::UNITS_FIELD) + { + xVal = RiaEclipseUnitTools::convertToFeet(xVal, conversionUnitText); + } + else if (requiredUnitSet == RiaEclipseUnitTools::UNITS_METRIC) + { + xVal = RiaEclipseUnitTools::convertToMeter(xVal, conversionUnitText); + } + } + } + + return conductivityValues; } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -cvf::ref RigStimPlanFractureDefinition::createFractureGrid(int m_activeTimeStepIndex, - RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, - double m_wellPathDepthAtFracture) +cvf::ref RigStimPlanFractureDefinition::createFractureGrid(const QString& resultName, + int activeTimeStepIndex, + double wellPathIntersectionAtFractureDepth, + RiaEclipseUnitTools::UnitSystem requiredUnitSet) { + std::vector> conductivityValues = conductivityValuesAtTimeStep(resultName, activeTimeStepIndex, requiredUnitSet); + if (conductivityValues.empty()) + { + return nullptr; + } + std::vector stimPlanCells; std::pair wellCenterStimPlanCellIJ = std::make_pair(0, 0); bool wellCenterStimPlanCellFound = false; - QString condUnit; - if ( fractureTemplateUnit == RiaEclipseUnitTools::UNITS_METRIC ) condUnit = "md-m"; - if ( fractureTemplateUnit == RiaEclipseUnitTools::UNITS_FIELD ) condUnit = "md-ft"; - std::vector> conductivityValuesAtTimeStep = this->getMirroredDataAtTimeIndex(this->conductivityResultName(), - condUnit, - m_activeTimeStepIndex); - - std::vector depthCoordsAtNodes = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture); - std::vector xCoordsAtNodes = this->getNegAndPosXcoords(); + std::vector yCoordsAtNodes = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); + std::vector xCoordsAtNodes = this->m_Xs; std::vector xCoords; for ( int i = 0; i < static_cast(xCoordsAtNodes.size()) - 1; i++ ) xCoords.push_back((xCoordsAtNodes[i] + xCoordsAtNodes[i + 1]) / 2); std::vector depthCoords; - for ( int i = 0; i < static_cast(depthCoordsAtNodes.size()) - 1; i++ ) depthCoords.push_back((depthCoordsAtNodes[i] + depthCoordsAtNodes[i + 1]) / 2); + for ( int i = 0; i < static_cast(yCoordsAtNodes.size()) - 1; i++ ) depthCoords.push_back((yCoordsAtNodes[i] + yCoordsAtNodes[i + 1]) / 2); for ( int i = 0; i < static_cast(xCoords.size()) - 1; i++ ) { @@ -179,9 +374,9 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(int cellPolygon.push_back(cvf::Vec3d(xCoords[i], depthCoords[j + 1], 0.0)); RigFractureCell stimPlanCell(cellPolygon, i, j); - if ( conductivityValuesAtTimeStep.size() > 0 ) //Assuming vector to be of correct length, or no values + if ( conductivityValues.size() > 0 ) //Assuming vector to be of correct length, or no values { - stimPlanCell.setConductivityValue(conductivityValuesAtTimeStep[j + 1][i + 1]); + stimPlanCell.setConductivityValue(conductivityValues[j + 1][i + 1]); } else { @@ -212,13 +407,13 @@ cvf::ref RigStimPlanFractureDefinition::createFractureGrid(int RiaLogging::error("Did not find stim plan cell at well crossing!"); } - cvf::ref m_fractureGrid = new RigFractureGrid; - m_fractureGrid->setFractureCells(stimPlanCells); - m_fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ); - m_fractureGrid->setICellCount(this->getNegAndPosXcoords().size() - 2); - m_fractureGrid->setJCellCount(this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture).size() - 2); + cvf::ref fractureGrid = new RigFractureGrid; + fractureGrid->setFractureCells(stimPlanCells); + fractureGrid->setWellCenterFractureCellIJ(wellCenterStimPlanCellIJ); + fractureGrid->setICellCount(this->m_Xs.size() - 2); + fractureGrid->setJCellCount(this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth).size() - 2); - return m_fractureGrid; + return fractureGrid; } //-------------------------------------------------------------------------------------------------- @@ -229,13 +424,13 @@ std::vector RigStimPlanFractureDefinition::fractureGridResults(const QSt size_t timeStepIndex) const { std::vector fractureGridResults; - std::vector> resultValuesAtTimeStep = this->getMirroredDataAtTimeIndex(resultName, - unitName, - timeStepIndex); + const std::vector>& resultValuesAtTimeStep = this->getDataAtTimeIndex(resultName, + unitName, + timeStepIndex); - for ( int i = 0; i < static_cast(mirroredGridXCount()) - 2; i++ ) + for ( int i = 0; i < static_cast(xCount()) - 2; i++ ) { - for ( int j = 0; j < static_cast(depthCount()) - 2; j++ ) + for ( int j = 0; j < static_cast(yCount()) - 2; j++ ) { if ( j+1 < static_cast(resultValuesAtTimeStep.size()) && i+1 < static_cast(resultValuesAtTimeStep[j + 1].size()) ) { @@ -254,51 +449,26 @@ std::vector RigStimPlanFractureDefinition::fractureGridResults(const QSt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double m_wellPathDepthAtFracture, - RiaEclipseUnitTools::UnitSystem neededUnit, +void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, const QString& fractureUserName, std::vector* vertices, std::vector* triangleIndices) { - std::vector xCoords = this->getNegAndPosXcoords(); + std::vector xCoords = this->m_Xs; cvf::uint lenXcoords = static_cast(xCoords.size()); - std::vector adjustedDepths = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture); - - if ( neededUnit == m_unitSet ) - { - RiaLogging::debug(QString("No conversion necessary for %1").arg(fractureUserName)); - } - - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD ) - { - RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName)); - for ( double& value : adjustedDepths ) value = RiaEclipseUnitTools::meterToFeet(value); - for ( double& value : xCoords ) value = RiaEclipseUnitTools::meterToFeet(value); - } - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC ) - { - RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName)); - for ( double& value : adjustedDepths ) value = RiaEclipseUnitTools::feetToMeter(value); - for ( double& value : xCoords ) value = RiaEclipseUnitTools::feetToMeter(value); - } - else - { - //Should never get here... - RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(fractureUserName)); - return; - } + std::vector adjustedYs = this->adjustedYCoordsAroundWellPathPosition(wellPathIntersectionAtFractureDepth); - for ( cvf::uint k = 0; k < adjustedDepths.size(); k++ ) + for ( cvf::uint k = 0; k < adjustedYs.size(); k++ ) { for ( cvf::uint i = 0; i < lenXcoords; i++ ) { - cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedDepths[k], 0); + cvf::Vec3f node = cvf::Vec3f(xCoords[i], adjustedYs[k], 0); vertices->push_back(node); - if ( i < lenXcoords - 1 && k < adjustedDepths.size() - 1 ) + if ( i < lenXcoords - 1 && k < adjustedYs.size() - 1 ) { - if ( xCoords[i] < 1e-5 ) + if ( xCoords[i] < THRESHOLD_VALUE ) { //Upper triangle triangleIndices->push_back(i + k*lenXcoords); @@ -321,7 +491,6 @@ void RigStimPlanFractureDefinition::createFractureTriangleGeometry(double m_well triangleIndices->push_back((i + 1) + (k + 1)*lenXcoords); triangleIndices->push_back((i)+ (k + 1)*lenXcoords); } - } } } @@ -356,127 +525,32 @@ void sortPolygon(std::vector &polygon) } } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigStimPlanFractureDefinition::createFractureBorderPolygon(const QString& resultName, - const QString& resultUnit, - int m_activeTimeStepIndex, - double m_wellPathDepthAtFracture, - RiaEclipseUnitTools::UnitSystem neededUnit, - const QString& fractureUserName) +const std::vector& RigStimPlanFractureDefinition::timeSteps() const { - std::vector polygon; - - std::vector> dataAtTimeStep = this->getDataAtTimeIndex(resultName, resultUnit, m_activeTimeStepIndex); - - std::vector adjustedDepths = this->adjustedDepthCoordsAroundWellPathPosition(m_wellPathDepthAtFracture); - - for ( int k = 0; k < static_cast(dataAtTimeStep.size()); k++ ) - { - for ( int i = 0; i < static_cast(dataAtTimeStep[k].size()); i++ ) - { - if ( (dataAtTimeStep[k])[i] < 1e-7 ) //polygon should consist of nodes with value 0 - { - if ( (i > 0) && ((dataAtTimeStep[k])[(i - 1)] > 1e-7) ) //side neighbour cell different from 0 - { - polygon.push_back(cvf::Vec3f(static_cast(this->m_gridXs[i]), - static_cast(adjustedDepths[k]), 0.0f)); - } - else if ( (k < static_cast(dataAtTimeStep.size()) - 1) && ((dataAtTimeStep[k + 1])[(i)] > 1e-7) )//cell below different from 0 - { - polygon.push_back(cvf::Vec3f(static_cast(this->m_gridXs[i]), - static_cast(adjustedDepths[k]), 0.0f)); - } - else if ( (k > 0) && ((dataAtTimeStep[k - 1])[(i)] > 1e-7) )//cell above different from 0 - { - polygon.push_back(cvf::Vec3f(static_cast(this->m_gridXs[i]), - static_cast(adjustedDepths[k]), 0.0f)); - } - } - } - } - - sortPolygon(polygon); - - std::vector negPolygon; - for ( const cvf::Vec3f& node : polygon ) - { - cvf::Vec3f negNode = node; - negNode.x() = -negNode.x(); - negPolygon.insert(negPolygon.begin(), negNode); - } - - for ( const cvf::Vec3f& negNode : negPolygon ) - { - polygon.push_back(negNode); - } - - //Adding first point last - to close the polygon - if ( polygon.size()>0 ) polygon.push_back(polygon[0]); - - - if ( neededUnit == m_unitSet ) - { - RiaLogging::debug(QString("No conversion necessary for %1").arg(fractureUserName)); - } - - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_METRIC && neededUnit == RiaEclipseUnitTools::UNITS_FIELD ) - { - RiaLogging::info(QString("Converting StimPlan geometry from metric to field for fracture template %1").arg(fractureUserName)); - for ( cvf::Vec3f& node : polygon ) - { - float x = RiaEclipseUnitTools::meterToFeet(node.x()); - float y = RiaEclipseUnitTools::meterToFeet(node.y()); - float z = RiaEclipseUnitTools::meterToFeet(node.z()); - node = cvf::Vec3f(x, y, z); - } - } - else if ( m_unitSet == RiaEclipseUnitTools::UNITS_FIELD && neededUnit == RiaEclipseUnitTools::UNITS_METRIC ) - { - RiaLogging::info(QString("Converting StimPlan geometry from field to metric for fracture template %1").arg(fractureUserName)); - for ( cvf::Vec3f& node : polygon ) - { - float x = RiaEclipseUnitTools::feetToMeter(node.x()); - float y = RiaEclipseUnitTools::feetToMeter(node.y()); - float z = RiaEclipseUnitTools::feetToMeter(node.z()); - node = cvf::Vec3f(x, y, z); - } - } - else - { - //Should never get here... - RiaLogging::error(QString("Error: Could not convert units for fracture template %1").arg(fractureUserName)); - } - - - return polygon; + return m_timeSteps; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RigStimPlanFractureDefinition::timeStepExisist(double timeStepValueToCheck) +void RigStimPlanFractureDefinition::addTimeStep(double time) { - for (double timeStep : m_timeSteps) - { - if (fabs(timeStepValueToCheck - timeStep) < 1e-5) return true; - } - return false; + if (!timeStepExists(time)) m_timeSteps.push_back(time); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::reorderYgridToDepths() +bool RigStimPlanFractureDefinition::timeStepExists(double timeStepValueToCheck) { - std::vector depthsInIncreasingOrder; - for (double gridYvalue : m_gridYs) + for (double timeStep : m_timeSteps) { - depthsInIncreasingOrder.insert(depthsInIncreasingOrder.begin(), gridYvalue); + if (fabs(timeStepValueToCheck - timeStep) < THRESHOLD_VALUE) return true; } - depths = depthsInIncreasingOrder; + return false; } //-------------------------------------------------------------------------------------------------- @@ -524,20 +598,8 @@ size_t RigStimPlanFractureDefinition::resultIndex(const QString& resultName, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue, double condScalingFactor) +void RigStimPlanFractureDefinition::setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue) { - if (resultName == conductivityResultName()) - { - for (std::vector &dataAtDepth : data) - { - for (double &dataValue : dataAtDepth) - { - dataValue = dataValue * condScalingFactor; - } - } - } - - size_t resIndex = resultIndex(resultName, unit); if (resIndex != cvf::UNDEFINED_SIZE_T) @@ -574,7 +636,8 @@ const std::vector>& RigStimPlanFractureDefinition::getDataAt } } - qDebug() << "ERROR: Requested parameter does not exists in stimPlan data"; + RiaLogging::error("Requested parameter does not exists in stimPlan data"); + static std::vector> emptyVector; return emptyVector; } @@ -582,12 +645,10 @@ const std::vector>& RigStimPlanFractureDefinition::getDataAt //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, const QString& unit, - double* minValue, double* maxValue, - double* posClosestToZero, double* negClosestToZero) const +void RigStimPlanFractureDefinition::appendDataToResultStatistics(const QString& resultName, const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const { - CVF_ASSERT(minValue && maxValue && posClosestToZero && negClosestToZero); - size_t resIndex = resultIndex(resultName, unit); if (resIndex == cvf::UNDEFINED_SIZE_T) return; @@ -595,28 +656,8 @@ void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, con { for (const auto& values : timeValues) { - for (double resultValue : values) - { - if (resultValue < *minValue) - { - *minValue = resultValue; - } - - if (resultValue > *maxValue) - { - *maxValue = resultValue; - } - - if (resultValue > 0 && resultValue < *posClosestToZero) - { - *posClosestToZero = resultValue; - } - - if (resultValue < 0 && resultValue > *negClosestToZero) - { - *posClosestToZero = resultValue; - } - } + minMaxAccumulator.addData(values); + posNegAccumulator.addData(values); } } } @@ -624,28 +665,36 @@ void RigStimPlanFractureDefinition::computeMinMax(const QString& resultName, con //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RigStimPlanFractureDefinition::conductivityResultName() const +QStringList RigStimPlanFractureDefinition::conductivityResultNames() const { - static const QString conductivity_text("CONDUCTIVITY"); - static const QString conductivity_propped_text("Conductivity-Propped"); - - // By intention we have two for loops here, as "CONDUCTIVITY" has priority over "Conductivity-Propped" - for (auto stimPlanResult : m_stimPlanResults) + QStringList resultNames; + + for (const auto& stimPlanResult : m_stimPlanResults) { - if (stimPlanResult.resultName.compare(conductivity_text, Qt::CaseInsensitive) == 0) + if (stimPlanResult.resultName.contains("conductivity", Qt::CaseInsensitive)) { - return stimPlanResult.resultName; + resultNames.push_back(stimPlanResult.resultName); } } - for (auto stimPlanResult : m_stimPlanResults) + return resultNames; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +size_t findMirrorXIndex(std::vector xs) +{ + size_t mirrorIndex = cvf::UNDEFINED_SIZE_T; + + for (size_t i = 0; i < xs.size(); i++) { - if (stimPlanResult.resultName.compare(conductivity_propped_text, Qt::CaseInsensitive) == 0) + if (xs[i] > -RigStimPlanFractureDefinition::THRESHOLD_VALUE) { - return stimPlanResult.resultName; + mirrorIndex = i; + break; } } - return ""; + return mirrorIndex; } - diff --git a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h index 4d80477994..880fa6e60f 100644 --- a/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h +++ b/ApplicationCode/ReservoirDataModel/RigStimPlanFractureDefinition.h @@ -18,109 +18,120 @@ #pragma once +#include "RiaEclipseUnitTools.h" + #include "cvfBase.h" #include "cvfObject.h" +#include "cvfVector3.h" + #include #include -#include "RiaEclipseUnitTools.h" -#include "cvfVector3.h" class RigFractureGrid; +class MinMaxAccumulator; +class PosNegAccumulator; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigStimPlanResultFrames { public: - RigStimPlanResultFrames(); + RigStimPlanResultFrames() {} QString resultName; QString unit; - // Vector for each time step, for each depth and for each x-value + // Vector for each time step, for each y and for each x-value std::vector< std::vector< std::vector > > parameterValues; }; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RigStimPlanFractureDefinition: public cvf::Object { + friend class RifStimPlanXmlReader; + public: + static const double THRESHOLD_VALUE; + RigStimPlanFractureDefinition(); ~RigStimPlanFractureDefinition(); - RiaEclipseUnitTools::UnitSystem unitSet() const { return m_unitSet; } - void setUnitSet(RiaEclipseUnitTools::UnitSystem unitset) { m_unitSet = unitset;} - - size_t gridXCount() const { return m_gridXs.size();} - void setGridXs(const std::vector& gridXs) { m_gridXs = gridXs; } - - - //TODO: Consider removing gridYs or depths, - //In example file these are the same, but can there be examples where not all gridY values are included in depths? + RiaEclipseUnitTools::UnitSystem unitSet() const; + size_t xCount() const; + size_t yCount() const; + double minDepth() const; + double maxDepth() const; + double topPerfTvd() const; + double bottomPerfTvd() const; + void setTvdToTopPerf(double topPerfTvd); + void setTvdToBottomPerf(double bottomPerfTvd); - void setGridYs(const std::vector& gridYs) { m_gridYs = gridYs; } - - double minDepth() const { return depths[0]; } - double maxDepth() const { return depths.back(); } - size_t depthCount() const { return depths.size(); } - - // Grid Geometry - - std::vector getNegAndPosXcoords() const; - std::vector adjustedDepthCoordsAroundWellPathPosition(double wellPathDepthAtFracture) const; - std::vector> getMirroredDataAtTimeIndex(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const; - - - cvf::ref createFractureGrid(int m_activeTimeStepIndex, - RiaEclipseUnitTools::UnitSystemType fractureTemplateUnit, - double m_wellPathDepthAtFracture); - - - void createFractureTriangleGeometry(double m_wellPathDepthAtFracture, - RiaEclipseUnitTools::UnitSystem neededUnit, - const QString& fractureUserName, - std::vector* vertices, - std::vector* triangleIndices); - - std::vector createFractureBorderPolygon(const QString& resultName, - const QString& resultUnit, - int m_activeTimeStepIndex, - double m_wellPathDepthAtFracture, - RiaEclipseUnitTools::UnitSystem neededUnit, - const QString& fractureUserName); - // Result Access + cvf::ref createFractureGrid(const QString& resultName, + int activeTimeStepIndex, + double wellPathIntersectionAtFractureDepth, + RiaEclipseUnitTools::UnitSystem requiredUnitSet); - const std::vector& timeSteps() const { return m_timeSteps; } - void addTimeStep(double time) { if (!timeStepExisist(time)) m_timeSteps.push_back(time); } - - std::vector > getStimPlanPropertyNamesUnits() const; - bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); - size_t totalNumberTimeSteps(); - void setDataAtTimeValue(QString resultName, QString unit, std::vector> data, double timeStepValue, double condScalingFactor); - const std::vector>& getDataAtTimeIndex(const QString& resultName, const QString& unit, size_t timeStepIndex) const; - std::vector fractureGridResults(const QString& resultName, - const QString& unitName, - size_t timeStepIndex) const; - void computeMinMax(const QString& resultName, const QString& unit, double* minValue, double* maxValue, double* posClosestToZero, double* negClosestToZero) const; - - QString conductivityResultName() const; + void createFractureTriangleGeometry(double wellPathIntersectionAtFractureDepth, + const QString& fractureUserName, + std::vector* vertices, + std::vector* triangleIndices); - // Setup - void reorderYgridToDepths(); -private: - bool timeStepExisist(double timeStepValue); - size_t getTimeStepIndex(double timeStepValue); - size_t resultIndex(const QString& resultName, const QString& unit) const; - size_t mirroredGridXCount() const { return m_gridXs.size() ? m_gridXs.size() + m_gridXs.size() - 1 : 0 ;} - - RiaEclipseUnitTools::UnitSystem m_unitSet; - std::vector m_gridXs; - std::vector m_gridYs; - std::vector depths; - - std::vector m_timeSteps; - std::vector m_stimPlanResults; -}; - + const std::vector& timeSteps() const; + void addTimeStep(double time); + size_t totalNumberTimeSteps(); + std::vector> getStimPlanPropertyNamesUnits() const; + + void setDataAtTimeValue(QString resultName, + QString unit, + std::vector> data, + double timeStepValue); + + const std::vector>& getDataAtTimeIndex(const QString& resultName, + const QString& unit, + size_t timeStepIndex) const; + + std::vector fractureGridResults(const QString& resultName, const QString& unitName, size_t timeStepIndex) const; + + void appendDataToResultStatistics(const QString& resultName, + const QString& unit, + MinMaxAccumulator& minMaxAccumulator, + PosNegAccumulator& posNegAccumulator) const; + + QStringList conductivityResultNames() const; + +private: + bool timeStepExists(double timeStepValue); + size_t getTimeStepIndex(double timeStepValue); + size_t resultIndex(const QString& resultName, const QString& unit) const; + void generateXsFromFileXs(bool xMirrorMode); + std::vector> generateDataLayoutFromFileDataLayout(std::vector> rawXYData); + std::vector adjustedYCoordsAroundWellPathPosition(double wellPathIntersectionAtFractureDepth) const; + bool numberOfParameterValuesOK(std::vector> propertyValuesAtTimestep); + double minY() const; + double maxY() const; + void scaleXs(double scaleFactor); + void scaleYs(double scaleFactor, double wellPathIntersectionY); + + std::vector> conductivityValuesAtTimeStep(const QString& resultName, + int activeTimeStepIndex, + RiaEclipseUnitTools::UnitSystem requiredUnitSet) const; + +private: + RiaEclipseUnitTools::UnitSystem m_unitSet; // To be deleted + std::vector m_fileXs; + std::vector m_Ys; + std::vector m_timeSteps; + + std::vector m_stimPlanResults; + std::vector m_Xs; + bool m_xMirrorMode; + + double m_topPerfTvd; + double m_bottomPerfTvd; +}; diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h b/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h index f20a8030da..dc01c9e340 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellLogExtractionTools.h @@ -45,7 +45,12 @@ struct RigWellLogExtractionTools struct RigMDCellIdxEnterLeaveKey { - RigMDCellIdxEnterLeaveKey(double md, size_t cellIdx, bool entering): measuredDepth(md), hexIndex(cellIdx), isEnteringCell(entering){} + RigMDCellIdxEnterLeaveKey(double md, size_t cellIdx, bool entering) + : measuredDepth(md) + , hexIndex(cellIdx) + , isEnteringCell(entering) + { + } double measuredDepth; size_t hexIndex; @@ -85,7 +90,12 @@ struct RigMDCellIdxEnterLeaveKey struct RigMDEnterLeaveCellIdxKey { - RigMDEnterLeaveCellIdxKey(double md, bool entering, size_t cellIdx ): measuredDepth(md), hexIndex(cellIdx), isEnteringCell(entering){} + RigMDEnterLeaveCellIdxKey(double md, bool entering, size_t cellIdx) + : measuredDepth(md) + , isEnteringCell(entering) + , hexIndex(cellIdx) + { + } double measuredDepth; bool isEnteringCell; // As opposed to leaving. diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp index 110be82073..9d9f9d843a 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogFile.cpp @@ -58,7 +58,7 @@ static double sg_createAbsentValue(double lowestDataValue) RigWellLogFile::RigWellLogFile() : cvf::Object() { - m_wellLogFile = NULL; + m_wellLogFile = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -77,7 +77,7 @@ bool RigWellLogFile::open(const QString& fileName, QString* errorMessage) { close(); - NRLib::Well* well = NULL; + NRLib::Well* well = nullptr; try { @@ -138,7 +138,7 @@ void RigWellLogFile::close() if (m_wellLogFile) { delete m_wellLogFile; - m_wellLogFile = NULL; + m_wellLogFile = nullptr; } m_wellLogChannelNames.clear(); diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp index 401160ebac..73697b9d73 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.cpp @@ -17,9 +17,10 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RigWellPath.h" -#include "cvfGeometryTools.h" #include "cvfGeometryTools.h" +#include "cvfBoundingBox.h" +#include "cvfPlane.h" //-------------------------------------------------------------------------------------------------- /// @@ -58,39 +59,62 @@ double RigWellPath::datumElevation() const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth) const +cvf::Vec3d RigWellPath::interpolatedVectorAlongWellPath(const std::vector& vectors, + double measuredDepth, + double * horizontalLengthAlongWellToStartClipPoint /*= nullptr*/) const { - cvf::Vec3d wellPathPoint = cvf::Vec3d::ZERO; + CVF_ASSERT(vectors.size() == m_wellPathPoints.size()); + cvf::Vec3d interpolatedVector = cvf::Vec3d::ZERO; - size_t i = 0; - while (i < m_measuredDepths.size() && m_measuredDepths.at(i) < measuredDepth ) + if (horizontalLengthAlongWellToStartClipPoint) *horizontalLengthAlongWellToStartClipPoint = 0.0; + + size_t vxIdx = 0; + while ( vxIdx < m_measuredDepths.size() && m_measuredDepths.at(vxIdx) < measuredDepth ) { - i++; + if ( vxIdx > 0 && horizontalLengthAlongWellToStartClipPoint) + { + cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToStartClipPoint += segment.length(); + } + vxIdx++; } - if (m_measuredDepths.size() > i) + if ( m_measuredDepths.size() > vxIdx ) { - if (i == 0) + if ( vxIdx == 0 ) { //For measuredDepth same or lower than first point, use this first point - wellPathPoint = m_wellPathPoints.at(0); + interpolatedVector = vectors.at(0); } else { //Do interpolation - double stepsize = (measuredDepth - m_measuredDepths.at(i-1)) / - (m_measuredDepths.at(i) - m_measuredDepths.at(i - 1)); - wellPathPoint = m_wellPathPoints.at(i - 1) + stepsize * (m_wellPathPoints.at(i) - m_wellPathPoints.at(i-1)); + double segmentFraction = (measuredDepth - m_measuredDepths.at(vxIdx-1)) / + (m_measuredDepths.at(vxIdx) - m_measuredDepths.at(vxIdx - 1)); + cvf::Vec3d segment = m_wellPathPoints[vxIdx] - m_wellPathPoints[vxIdx - 1]; + interpolatedVector = (1.0 - segmentFraction) * vectors[vxIdx - 1] + segmentFraction * vectors[vxIdx]; + + if ( horizontalLengthAlongWellToStartClipPoint ) + { + segment[2] = 0.0; + *horizontalLengthAlongWellToStartClipPoint += segment.length(); + } } } else { - //Use endpoint if measuredDepth same or higher than last point - wellPathPoint = m_wellPathPoints.at(i-1); + // Use endpoint if measuredDepth same or higher than last point + interpolatedVector = vectors.at(vxIdx-1); } - return wellPathPoint; + return interpolatedVector; +} + +cvf::Vec3d RigWellPath::interpolatedPointAlongWellPath(double measuredDepth, double * horizontalLengthAlongWellToStartClipPoint /*= nullptr*/) const +{ + return interpolatedVectorAlongWellPath(m_wellPathPoints, measuredDepth, horizontalLengthAlongWellToStartClipPoint); } //-------------------------------------------------------------------------------------------------- @@ -101,13 +125,13 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const size_t closestIndex = cvf::UNDEFINED_SIZE_T; double closestDistance = cvf::UNDEFINED_DOUBLE; - for (size_t i = 1; i < m_wellPathPoints.size(); i++) + for ( size_t i = 1; i < m_wellPathPoints.size(); i++ ) { cvf::Vec3d p1 = m_wellPathPoints[i - 1]; cvf::Vec3d p2 = m_wellPathPoints[i - 0]; double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position); - if (candidateDistance < closestDistance) + if ( candidateDistance < closestDistance ) { closestDistance = candidateDistance; closestIndex = i; @@ -117,12 +141,12 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const //For vertical well (x-component of direction = 0) returned angle will be 90. double azimuthAngleDegrees = 90.0; - if (closestIndex != cvf::UNDEFINED_DOUBLE) + if ( closestIndex != cvf::UNDEFINED_DOUBLE ) { cvf::Vec3d p1; cvf::Vec3d p2; - if (closestIndex > 0) + if ( closestIndex > 0 ) { p1 = m_wellPathPoints[closestIndex - 1]; p2 = m_wellPathPoints[closestIndex - 0]; @@ -135,7 +159,7 @@ double RigWellPath::wellPathAzimuthAngle(const cvf::Vec3d& position) const cvf::Vec3d direction = p2 - p1; - if (fabs(direction.y()) > 1e-5) + if ( fabs(direction.y()) > 1e-5 ) { double atanValue = direction.x() / direction.y(); double azimuthRadians = atan(atanValue); @@ -156,22 +180,22 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c size_t closestIndex = cvf::UNDEFINED_SIZE_T; double closestDistance = cvf::UNDEFINED_DOUBLE; - for (size_t i = 1; i < m_wellPathPoints.size(); i++) + for ( size_t i = 1; i < m_wellPathPoints.size(); i++ ) { cvf::Vec3d p1 = m_wellPathPoints[i - 1]; cvf::Vec3d p2 = m_wellPathPoints[i - 0]; double candidateDistance = cvf::GeometryTools::linePointSquareDist(p1, p2, position); - if (candidateDistance < closestDistance) + if ( candidateDistance < closestDistance ) { closestDistance = candidateDistance; closestIndex = i; } } - if (closestIndex != cvf::UNDEFINED_DOUBLE) + if (closestIndex != cvf::UNDEFINED_SIZE_T) { - if (closestIndex > 0) + if ( closestIndex > 0 ) { *p1 = m_wellPathPoints[closestIndex - 1]; *p2 = m_wellPathPoints[closestIndex - 0]; @@ -187,19 +211,21 @@ void RigWellPath::twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::pair, std::vector > RigWellPath::clippedPointSubset(double startMD, double endMD) const +std::pair, std::vector > RigWellPath::clippedPointSubset(double startMD, + double endMD, + double * horizontalLengthAlongWellToStartClipPoint) const { std::pair, std::vector > pointsAndMDs; - if (m_measuredDepths.empty()) return pointsAndMDs; - if (startMD > endMD) return pointsAndMDs; + if ( m_measuredDepths.empty() ) return pointsAndMDs; + if ( startMD > endMD ) return pointsAndMDs; - pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD)); + pointsAndMDs.first.push_back(interpolatedPointAlongWellPath(startMD, horizontalLengthAlongWellToStartClipPoint)); pointsAndMDs.second.push_back(startMD); - for (size_t i = 0; i < m_measuredDepths.size(); ++i) + for ( size_t i = 0; i < m_measuredDepths.size(); ++i ) { double measuredDepth = m_measuredDepths[i]; - if (measuredDepth > startMD && measuredDepth < endMD) + if ( measuredDepth > startMD && measuredDepth < endMD ) { pointsAndMDs.first.push_back(m_wellPathPoints[i]); pointsAndMDs.second.push_back(measuredDepth); @@ -218,27 +244,27 @@ std::pair, std::vector > RigWellPath::clippedPoi std::vector RigWellPath::wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const { std::vector points; - if (m_measuredDepths.empty()) return points; + if ( m_measuredDepths.empty() ) return points; cvf::Vec3d interpolatedWellPathPoint = interpolatedPointAlongWellPath(intersectionMeasuredDepth); - for (size_t i = 0; i < m_measuredDepths.size() - 1; i++) + for ( size_t i = 0; i < m_measuredDepths.size() - 1; i++ ) { - if (m_measuredDepths[i] == intersectionMeasuredDepth) + if ( m_measuredDepths[i] == intersectionMeasuredDepth ) { points.push_back(m_wellPathPoints[i]); } - else if (m_measuredDepths[i] < intersectionMeasuredDepth) + else if ( m_measuredDepths[i] < intersectionMeasuredDepth ) { points.push_back(m_wellPathPoints[i]); - if (m_measuredDepths[i + 1] > intersectionMeasuredDepth) + if ( m_measuredDepths[i + 1] > intersectionMeasuredDepth ) { points.push_back(interpolatedWellPathPoint); } } - else if (m_measuredDepths[i] > intersectionMeasuredDepth) + else if ( m_measuredDepths[i] > intersectionMeasuredDepth ) { - if (i == 0) + if ( i == 0 ) { points.push_back(interpolatedWellPathPoint); } @@ -253,3 +279,106 @@ std::vector RigWellPath::wellPathPointsIncludingInterpolatedIntersec return points; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellPath::isAnyPointInsideBoundingBox(const std::vector& points, const cvf::BoundingBox& boundingBox) +{ + for (const cvf::Vec3d& point : points) + { + if (boundingBox.contains(point)) return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellPath::clipPolylineStartAboveZ(const std::vector& polyLine, + double maxZ, + double * horizontalLengthAlongWellToClipPoint, + size_t * indexToFirstVisibleSegment) +{ + CVF_ASSERT(horizontalLengthAlongWellToClipPoint); + CVF_ASSERT(indexToFirstVisibleSegment); + + // Find first visible point, and accumulate distance along wellpath + + *horizontalLengthAlongWellToClipPoint = 0.0; + *indexToFirstVisibleSegment = cvf::UNDEFINED_SIZE_T; + + size_t firstVisiblePointIndex = cvf::UNDEFINED_SIZE_T; + + for ( size_t vxIdx = 0 ; vxIdx < polyLine.size(); ++vxIdx ) + { + if ( polyLine[vxIdx].z() > maxZ ) + { + if ( vxIdx > 0 ) + { + cvf::Vec3d segment = polyLine[vxIdx] - polyLine[vxIdx-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToClipPoint += segment.length(); + } + } + else + { + firstVisiblePointIndex = vxIdx; + break; + } + } + + // Clip line, and add vx to the start of the clipped result + + std::vector clippedPolyLine; + + if ( firstVisiblePointIndex == cvf::UNDEFINED_SIZE_T ) + { + return clippedPolyLine; + } + + if ( firstVisiblePointIndex > 0 ) + { + + cvf::Plane topPlane; + topPlane.setFromPointAndNormal({ 0.0, 0.0, maxZ }, cvf::Vec3d::Z_AXIS); + cvf::Vec3d intersection; + + if ( topPlane.intersect(polyLine[firstVisiblePointIndex-1], + polyLine[firstVisiblePointIndex], + &intersection) ) + { + cvf::Vec3d segment = intersection - polyLine[firstVisiblePointIndex-1]; + segment[2] = 0.0; + *horizontalLengthAlongWellToClipPoint += segment.length(); + + clippedPolyLine.push_back(intersection); + } + + *indexToFirstVisibleSegment = firstVisiblePointIndex - 1; + } + else + { + *indexToFirstVisibleSegment = 0; + } + + // Add the rest of the polyline + + for ( size_t vxIdx = firstVisiblePointIndex; vxIdx < polyLine.size(); ++vxIdx ) + { + clippedPolyLine.push_back(polyLine[vxIdx]); + } + + return clippedPolyLine; +} + +const std::vector& RigWellPath::wellPathPoints() const +{ + return m_wellPathPoints; +} + +const std::vector& RigWellPath::measureDepths() const +{ + return m_measuredDepths; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigWellPath.h b/ApplicationCode/ReservoirDataModel/RigWellPath.h index 94f39b026b..7280a9a563 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPath.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPath.h @@ -23,6 +23,11 @@ #include "cvfMath.h" #include "cvfVector3.h" +namespace cvf +{ + class BoundingBox; +} + #include @@ -32,23 +37,38 @@ class RigWellPath : public cvf::Object { public: - RigWellPath(); - std::vector m_wellPathPoints; std::vector m_measuredDepths; + RigWellPath(); void setDatumElevation(double value); bool hasDatumElevation() const; double datumElevation() const; - cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth) const; + cvf::Vec3d interpolatedVectorAlongWellPath(const std::vector& vectors, + double measuredDepth, + double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; + cvf::Vec3d interpolatedPointAlongWellPath(double measuredDepth, + double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; + double wellPathAzimuthAngle(const cvf::Vec3d& position) const; void twoClosestPoints(const cvf::Vec3d& position, cvf::Vec3d* p1, cvf::Vec3d* p2) const; std::pair, std::vector > - clippedPointSubset(double startMD, double endMD) const; + clippedPointSubset(double startMD, + double endMD, + double * horizontalLengthAlongWellToStartClipPoint = nullptr) const; std::vector wellPathPointsIncludingInterpolatedIntersectionPoint(double intersectionMeasuredDepth) const; + static bool isAnyPointInsideBoundingBox(const std::vector& points, const cvf::BoundingBox& boundingBox); + + static std::vector clipPolylineStartAboveZ(const std::vector &polyLine, + double maxZ, + double * horizontalLengthAlongWellToClipPoint, + size_t * indexToFirstVisibleSegment); + const std::vector& wellPathPoints() const; + const std::vector& measureDepths() const; + private: bool m_hasDatumElevation; double m_datumElevation; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp new file mode 100644 index 0000000000..bdd4b033b4 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.cpp @@ -0,0 +1,149 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigWellPathGeometryTools.h" + +#include "RigWellPath.h" + +#include "cvfMath.h" +#include "cvfMatrix3.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RigWellPathGeometryTools::calculateLineSegmentNormals(const std::vector& vertices, + double planeAngle) +{ + std::vector pointNormals; + + if (vertices.empty()) return pointNormals; + + pointNormals.reserve(vertices.size()); + + cvf::Vec3d up(0, 0, 1); + + cvf::Vec3d dominantDirection = estimateDominantDirectionInXYPlane(vertices); + + const cvf::Vec3d projectionPlaneNormal = (up ^ dominantDirection).getNormalized(); + CVF_ASSERT(projectionPlaneNormal * dominantDirection <= std::numeric_limits::epsilon()); + + cvf::Vec3d lastNormal; + for (size_t i = 0; i < vertices.size() - 1; ++i) + { + cvf::Vec3d p1 = vertices[i]; + cvf::Vec3d p2 = vertices[i + 1]; + + cvf::Vec3d tangent = (p2 - p1).getNormalized(); + cvf::Vec3d normal(0, 0, 0); + if (cvf::Math::abs(tangent * projectionPlaneNormal) < 0.7071) + { + cvf::Vec3d projectedTangent = (tangent - (tangent * projectionPlaneNormal) * projectionPlaneNormal).getNormalized(); + normal = (projectedTangent ^ projectionPlaneNormal).getNormalized(); + normal = normal.getTransformedVector(cvf::Mat3d::fromRotation(tangent, planeAngle)); + } + pointNormals.push_back(normal); + lastNormal = normal; + } + + pointNormals.push_back(lastNormal); + + return interpolateUndefinedNormals(up, pointNormals, vertices); +} + +std::vector RigWellPathGeometryTools::interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, + const std::vector& normals, + const std::vector& vertices) +{ + std::vector interpolated(normals); + cvf::Vec3d lastNormal(0, 0, 0); + double distanceFromLast = 0.0; + + for (size_t i = 0; i < normals.size(); ++i) + { + cvf::Vec3d currentNormal = normals[i]; + bool currentInterpolated = false; + if (i > 0) + { + distanceFromLast += (vertices[i] - vertices[i - 1]).length(); + } + + if (currentNormal.length() == 0.0) // Undefined. Need to estimate from neighbors. + { + currentInterpolated = true; + currentNormal = planeNormal; // By default use the plane normal + + cvf::Vec3d nextNormal(0, 0, 0); + double distanceToNext = 0.0; + for (size_t j = i + 1; j < normals.size() && nextNormal.length() == 0.0; ++j) + { + nextNormal = normals[j]; + distanceToNext += (vertices[j] - vertices[j - 1]).length(); + } + + if (lastNormal.length() > 0.0 && nextNormal.length() > 0.0) + { + // Both last and next are acceptable, interpolate! + currentNormal = (distanceToNext * lastNormal + distanceFromLast * nextNormal).getNormalized(); + } + else if (lastNormal.length() > 0.0) + { + currentNormal = lastNormal; + } + else if (nextNormal.length() > 0.0) + { + currentNormal = nextNormal; + } + } + if (i > 0 && currentNormal * lastNormal < -std::numeric_limits::epsilon()) + { + currentNormal *= -1.0; + } + if (!currentInterpolated) + { + lastNormal = currentNormal; + distanceFromLast = 0.0; // Reset distance + } + interpolated[i] = currentNormal; + } + return interpolated; +} + +cvf::Vec3d RigWellPathGeometryTools::estimateDominantDirectionInXYPlane(const std::vector& vertices) +{ + cvf::Vec3d directionSum(0, 0, 0); + for (size_t i = 1; i < vertices.size(); ++i) + { + cvf::Vec3d vec = vertices[i] - vertices[i - 1]; + vec.z() = 0.0; + if (directionSum.length() > 0.0 && (directionSum * vec) < 0.0) + { + vec *= -1; + } + directionSum += vec; + } + + if (directionSum.length() < 1.0e-8) + { + directionSum = cvf::Vec3d(0, -1, 0); + } + + return directionSum.getNormalized(); +} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h new file mode 100644 index 0000000000..658605280b --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellPathGeometryTools.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +#include "cvfBase.h" +#include "cvfVector3.h" + +class RigWellPath; + +//================================================================================================== +/// +//================================================================================================== +class RigWellPathGeometryTools +{ +public: + enum VertexOrganization + { + LINE_SEGMENTS, + POLYLINE + }; + +public: + static std::vector calculateLineSegmentNormals(const std::vector& vertices, + double angle); +private: + static std::vector interpolateUndefinedNormals(const cvf::Vec3d& planeNormal, + const std::vector& normals, + const std::vector& vertices); + static cvf::Vec3d estimateDominantDirectionInXYPlane(const std::vector& vertices); +}; diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index a19e1f1a55..ed05ffae6c 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -20,17 +20,17 @@ #include "RiaLogging.h" -#include "RigWellPath.h" -#include "RigMainGrid.h" +#include "RigCellGeometryTools.h" #include "RigEclipseCaseData.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigMainGrid.h" +#include "RigSimulationWellCoordsAndMD.h" #include "RigWellLogExtractionTools.h" -#include "RigCellGeometryTools.h" +#include "RigWellPath.h" -#include "cvfGeometryTools.h" -#include "cvfMatrix3.h" -#include "RigEclipseWellLogExtractor.h" #include "RimEclipseCase.h" + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -57,32 +57,57 @@ std::vector RigWellPathIntersectionTools::findCell //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RigWellPathIntersectionTools::findRawHexCellIntersections(const RigMainGrid* grid, - const std::vector& coords) +std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndicesForWellPath(const RigEclipseCaseData* caseData, const RigWellPath* wellPath) { - std::vector intersections; - for (size_t i = 0; i < coords.size() - 1; ++i) + std::set globalCellIndices; + + if (caseData) { - cvf::BoundingBox bb; - bb.add(coords[i]); - bb.add(coords[i + 1]); + cvf::ref extractor = new RigEclipseWellLogExtractor(caseData, + wellPath, + caseData->ownerCase()->caseUserDescription().toStdString()); + + std::vector intersections = extractor->cellIntersectionInfosAlongWellPath(); + for (const auto& intersection : intersections) + { + globalCellIndices.insert(intersection.globCellIndex); + } + } - std::vector closeCells = findCloseCells(grid, bb); + return globalCellIndices; - std::array hexCorners; +} - for (size_t closeCell : closeCells) - { - const RigCell& cell = grid->globalCellArray()[closeCell]; - if (cell.isInvalid()) continue; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::set RigWellPathIntersectionTools::findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, + const std::vector& coords, + const std::vector& measuredDepths) +{ + std::set globalCellIndices; - grid->cellCornerVertices(closeCell, hexCorners.data()); + if (caseData) + { + cvf::ref dummyWellPath = new RigWellPath; - RigHexIntersectionTools::lineHexCellIntersection(coords[i], coords[i + 1], hexCorners.data(), closeCell, &intersections); + if (measuredDepths.size() == coords.size()) + { + dummyWellPath->m_wellPathPoints = coords; + dummyWellPath->m_measuredDepths = measuredDepths; } + else + { + RigSimulationWellCoordsAndMD helper(coords); + + dummyWellPath->m_wellPathPoints = helper.wellPathPoints(); + dummyWellPath->m_measuredDepths = helper.measuredDepths(); + } + + globalCellIndices = findIntersectedGlobalCellIndicesForWellPath(caseData, dummyWellPath.p()); } - return intersections; + return globalCellIndices; } //-------------------------------------------------------------------------------------------------- @@ -119,41 +144,3 @@ cvf::Vec3d RigWellPathIntersectionTools::calculateLengthInCell(const RigMainGrid return calculateLengthInCell(hexCorners, startPoint, endPoint); } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector RigWellPathIntersectionTools::findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb) -{ - std::vector closeCells; - grid->findIntersectingCells(bb, &closeCells); - return closeCells; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -size_t RigWellPathIntersectionTools::findCellFromCoords(const RigMainGrid* grid, const cvf::Vec3d& coords, bool* foundCell) -{ - cvf::BoundingBox bb; - bb.add(coords); - std::vector closeCells = findCloseCells(grid, bb); - std::array hexCorners; - - for (size_t closeCell : closeCells) - { - const RigCell& cell = grid->globalCellArray()[closeCell]; - if (cell.isInvalid()) continue; - - grid->cellCornerVertices(closeCell, hexCorners.data()); - - if (RigHexIntersectionTools::isPointInCell(coords, hexCorners.data())) - { - *foundCell = true; - return closeCell; - } - } - - *foundCell = false; - return 0; -} diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h index 0fcc67a5b8..c5f8cf3b81 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.h @@ -1,17 +1,17 @@ ///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2017 Statoil ASA -// +// // 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 +// +// See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// @@ -19,8 +19,8 @@ #pragma once #include "cvfBase.h" -#include "cvfVector3.h" #include "cvfBoundingBox.h" +#include "cvfVector3.h" #include @@ -31,26 +31,28 @@ struct HexIntersectionInfo; struct WellPathCellIntersectionInfo; //================================================================================================== -/// +/// //================================================================================================== class RigWellPathIntersectionTools { public: - static std::vector findCellIntersectionInfosAlongPath(const RigEclipseCaseData* caseData, + static std::vector findCellIntersectionInfosAlongPath(const RigEclipseCaseData* caseData, const std::vector& pathCoords, - const std::vector& pathMds); + const std::vector& pathMds); - static std::vector findRawHexCellIntersections(const RigMainGrid* grid, const std::vector& coords); + static std::set findIntersectedGlobalCellIndicesForWellPath(const RigEclipseCaseData* caseData, + const RigWellPath* wellPath); - static cvf::Vec3d calculateLengthInCell(const std::array& hexCorners, - const cvf::Vec3d& startPoint, - const cvf::Vec3d& endPoint); - static cvf::Vec3d calculateLengthInCell(const RigMainGrid* grid, - size_t cellIndex, - const cvf::Vec3d& startPoint, - const cvf::Vec3d& endPoint); + static std::set findIntersectedGlobalCellIndices(const RigEclipseCaseData* caseData, + const std::vector& coords, + const std::vector& measuredDepths = {}); - static std::vector findCloseCells(const RigMainGrid* grid, const cvf::BoundingBox& bb); - static size_t findCellFromCoords(const RigMainGrid* caseData, const cvf::Vec3d& coords, bool* foundCell); + static cvf::Vec3d calculateLengthInCell(const std::array& hexCorners, + const cvf::Vec3d& startPoint, + const cvf::Vec3d& endPoint); + static cvf::Vec3d calculateLengthInCell(const RigMainGrid* grid, + size_t cellIndex, + const cvf::Vec3d& startPoint, + const cvf::Vec3d& endPoint); }; diff --git a/ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp new file mode 100644 index 0000000000..dbafb10de6 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.cpp @@ -0,0 +1,146 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RigWellResultPoint.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RigWellResultPoint::RigWellResultPoint() + : m_gridIndex(cvf::UNDEFINED_SIZE_T) + , m_gridCellIndex(cvf::UNDEFINED_SIZE_T) + , m_isOpen(false) + , m_ertBranchId(-1) + , m_ertSegmentId(-1) + , m_bottomPosition(cvf::Vec3d::UNDEFINED) + , m_flowRate(0.0) + , m_oilRate(0.0) + , m_gasRate(0.0) + , m_waterRate(0.0) + , m_connectionFactor(0.0) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isPointValid() const +{ + return m_bottomPosition != cvf::Vec3d::UNDEFINED; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isCell() const +{ + return m_gridCellIndex != cvf::UNDEFINED_SIZE_T; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isValid() const +{ + return isCell() || isPointValid(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RigWellResultPoint::isEqual(const RigWellResultPoint& other) const +{ + return ( m_gridIndex == other.m_gridIndex + && m_gridCellIndex == other.m_gridCellIndex + && m_isOpen == other.m_isOpen + && m_ertBranchId == other.m_ertBranchId + && m_ertSegmentId == other.m_ertSegmentId + && m_flowRate == other.m_flowRate + && m_oilRate == other.m_oilRate + && m_gasRate == other.m_gasRate + && m_waterRate == other.m_waterRate); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::flowRate() const +{ + if (isCell() && m_isOpen) + { + return m_flowRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::oilRate() const +{ + if (isCell() && m_isOpen) + { + return m_oilRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::gasRate() const +{ + if (isCell() && m_isOpen) + { + return m_gasRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::waterRate() const +{ + if (isCell() && m_isOpen) + { + return m_waterRate; + } + else + { + return 0.0; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RigWellResultPoint::connectionFactor() const +{ + return m_connectionFactor; +} + diff --git a/ApplicationCode/ReservoirDataModel/RigWellResultPoint.h b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.h new file mode 100644 index 0000000000..8cfe5255c1 --- /dev/null +++ b/ApplicationCode/ReservoirDataModel/RigWellResultPoint.h @@ -0,0 +1,114 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2011-2012 Statoil ASA, Ceetron AS +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfVector3.h" + +#include + +#include + + +//================================================================================================== +/// Stores the info on a significant point in the well. Either a well-to-grid connection, or the +/// bottom position of a connection less well-segment +//================================================================================================== +struct RigWellResultPoint +{ + RigWellResultPoint(); + + bool isPointValid() const; + bool isCell() const; + bool isValid() const; + bool isEqual(const RigWellResultPoint& other) const; + + double flowRate() const; + double oilRate() const; + double gasRate() const; + double waterRate() const; + double connectionFactor() const; + + size_t m_gridIndex; + size_t m_gridCellIndex; //< Index to cell which is included in the well + bool m_isOpen; //< Marks the well as open or closed as of Eclipse simulation + + int m_ertBranchId; + int m_ertSegmentId; + + cvf::Vec3d m_bottomPosition; //< The estimated bottom position of the well segment, when we have no grid cell connections for + //the segment. + double m_flowRate; //< Total reservoir rate + double m_oilRate; //< Surface oil rate + double m_gasRate; //< Surface gas rate For Field-unit, converted to [stb/day] to align with oil and water. + double m_waterRate; //< Surface water rate + + double m_connectionFactor; +}; + +//================================================================================================== +/// This class contains the connection information from and including a splitpoint to the end of +/// that particular branch. +//================================================================================================== +struct RigWellResultBranch +{ + RigWellResultBranch() + : m_ertBranchId(-1) + { + } + + int m_ertBranchId; + std::vector m_branchResultPoints; +}; + +//================================================================================================== +/// This class contains the well information for one timestep. +/// The main content is the vector of RigWellResultBranch which contains all the simple pipe +/// sections that make up the well +//================================================================================================== +class RigWellResultFrame +{ +public: + enum WellProductionType + { + PRODUCER, + OIL_INJECTOR, + GAS_INJECTOR, + WATER_INJECTOR, + UNDEFINED_PRODUCTION_TYPE + }; + +public: + RigWellResultFrame() + : m_productionType(UNDEFINED_PRODUCTION_TYPE) + , m_isOpen(false) + { + } + + const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const; + + RigWellResultPoint wellHeadOrStartCell() const; + WellProductionType m_productionType; + bool m_isOpen; + RigWellResultPoint m_wellHead; + QDateTime m_timestamp; + + std::vector m_wellResultBranches; +}; + diff --git a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp index 3e0a245178..f316e305ca 100644 --- a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp +++ b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.cpp @@ -328,7 +328,7 @@ GeometryTools::inPlaneLineIntersect3D( const cvf::Vec3d& planeNormal, const cvf::Vec3d& p1, const cvf::Vec3d& p2, const cvf::Vec3d& p3, const cvf::Vec3d& p4, cvf::Vec3d* intersectionPoint, double* fractionAlongLine1, double* fractionAlongLine2, double tolerance) { - CVF_ASSERT (intersectionPoint != NULL); + CVF_ASSERT (intersectionPoint != nullptr); int Z = findClosestAxis(planeNormal); int X = (Z + 1) % 3; @@ -762,7 +762,7 @@ EarClipTesselator::EarClipTesselator(): m_X(-1), m_Y(-1), m_areaTolerance(1e-12), - m_nodeCoords(NULL) + m_nodeCoords(nullptr) { } @@ -775,7 +775,7 @@ EarClipTesselator::EarClipTesselator(): bool EarClipTesselator::calculateTriangles( std::vector* triangleIndices ) { - CVF_ASSERT(m_nodeCoords != NULL); + CVF_ASSERT(m_nodeCoords != nullptr); CVF_ASSERT(m_X > -1 && m_Y > -1); size_t numVertices = m_polygonIndices.size(); @@ -1010,7 +1010,7 @@ void FanEarClipTesselator::setCenterNode(size_t centerNodeIndex) bool FanEarClipTesselator::calculateTriangles(std::vector* triangles) { CVF_ASSERT(m_centerNodeIndex != std::numeric_limits::max()); - CVF_ASSERT(m_nodeCoords != NULL); + CVF_ASSERT(m_nodeCoords != nullptr); CVF_ASSERT(m_X > -1 && m_Y > -1); size_t nv = m_polygonIndices.size(); diff --git a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl index c11664e743..b1ecbebecd 100644 --- a/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl +++ b/ApplicationCode/ReservoirDataModel/cvfGeometryTools.inl @@ -142,7 +142,7 @@ bool GeometryTools::isPointTouchingIndexedPolygon( const cvf::Vec3d& polygonNor int yBelowVx1 = 0; const double* vtx0; - const double* vtx1 = NULL; + const double* vtx1 = nullptr; double dv0; diff --git a/ApplicationCode/Resources/Case48x48.png b/ApplicationCode/Resources/Case48x48.png index 8015d06ea7..cfab59e850 100644 Binary files a/ApplicationCode/Resources/Case48x48.png and b/ApplicationCode/Resources/Case48x48.png differ diff --git a/ApplicationCode/Resources/EclipseInput48x48.png b/ApplicationCode/Resources/EclipseInput48x48.png index 487da4807b..12038be80a 100644 Binary files a/ApplicationCode/Resources/EclipseInput48x48.png and b/ApplicationCode/Resources/EclipseInput48x48.png differ diff --git a/ApplicationCode/Resources/EnsembleCurveSet16x16.png b/ApplicationCode/Resources/EnsembleCurveSet16x16.png new file mode 100644 index 0000000000..d38c243083 Binary files /dev/null and b/ApplicationCode/Resources/EnsembleCurveSet16x16.png differ diff --git a/ApplicationCode/Resources/EnsembleCurveSets16x16.png b/ApplicationCode/Resources/EnsembleCurveSets16x16.png new file mode 100644 index 0000000000..119a1bec37 Binary files /dev/null and b/ApplicationCode/Resources/EnsembleCurveSets16x16.png differ diff --git a/ApplicationCode/Resources/Folder.png b/ApplicationCode/Resources/Folder.png index 57c2202b25..662c906b08 100644 Binary files a/ApplicationCode/Resources/Folder.png and b/ApplicationCode/Resources/Folder.png differ diff --git a/ApplicationCode/Resources/InputCase48x48.png b/ApplicationCode/Resources/InputCase48x48.png new file mode 100644 index 0000000000..c91c3721d9 Binary files /dev/null and b/ApplicationCode/Resources/InputCase48x48.png differ diff --git a/ApplicationCode/Resources/ObservedCSVDataFile16x16.png b/ApplicationCode/Resources/ObservedCSVDataFile16x16.png new file mode 100644 index 0000000000..1413da6369 Binary files /dev/null and b/ApplicationCode/Resources/ObservedCSVDataFile16x16.png differ diff --git a/ApplicationCode/Resources/ObservedDataFile16x16.png b/ApplicationCode/Resources/ObservedDataFile16x16.png new file mode 100644 index 0000000000..6de9304592 Binary files /dev/null and b/ApplicationCode/Resources/ObservedDataFile16x16.png differ diff --git a/ApplicationCode/Resources/ObservedRSMDataFile16x16.png b/ApplicationCode/Resources/ObservedRSMDataFile16x16.png new file mode 100644 index 0000000000..ea90a21d80 Binary files /dev/null and b/ApplicationCode/Resources/ObservedRSMDataFile16x16.png differ diff --git a/ApplicationCode/Resources/OctaveScriptFile16x16.png b/ApplicationCode/Resources/OctaveScriptFile16x16.png new file mode 100644 index 0000000000..93e7d25d07 Binary files /dev/null and b/ApplicationCode/Resources/OctaveScriptFile16x16.png differ diff --git a/ApplicationCode/Resources/PlotWindow24x24.png b/ApplicationCode/Resources/PlotWindow24x24.png index 6d7f5fa745..555a43eff1 100644 Binary files a/ApplicationCode/Resources/PlotWindow24x24.png and b/ApplicationCode/Resources/PlotWindow24x24.png differ diff --git a/ApplicationCode/Resources/RFTPlot16x16.png b/ApplicationCode/Resources/RFTPlot16x16.png new file mode 100644 index 0000000000..31adc3ecf8 Binary files /dev/null and b/ApplicationCode/Resources/RFTPlot16x16.png differ diff --git a/ApplicationCode/Resources/RFTPlots16x16.png b/ApplicationCode/Resources/RFTPlots16x16.png new file mode 100644 index 0000000000..553a03d68f Binary files /dev/null and b/ApplicationCode/Resources/RFTPlots16x16.png differ diff --git a/ApplicationCode/Resources/ResInsight.qrc b/ApplicationCode/Resources/ResInsight.qrc index 61faee12d5..1973989f83 100644 --- a/ApplicationCode/Resources/ResInsight.qrc +++ b/ApplicationCode/Resources/ResInsight.qrc @@ -1,112 +1,127 @@ - - AppLogo48x48.png - Default.png - NorthViewArrow.png - SouthViewArrow.png - EastViewArrow.png - WestViewArrow.png - UpViewArrow.png - DownViewArrow.png - CellFilter_Values.png - CellFilter_Range.png - CellResult.png - EdgeResult_1.png - EdgeResult_2.png - Legend.png - Plus.png - Minus.png - Save.png - Well.png - WellCollection.png - octave.png - Folder.png - EclipseInput48x48.png - Cases16x16.png - CreateGridCaseGroup16x16.png - GridCaseGroup16x16.png - Histogram16x16.png - Histograms16x16.png - ZoomAll16x16.png - draw_style_lines_24x24.png - draw_style_meshlines_24x24.png - draw_style_meshoutlines_24x24.png - draw_style_outlines_24x24.png - draw_style_surface_24x24.png - disable_lighting_24x24.png - SnapShot.png - SnapShotSave.png - SnapShotSaveViews.png - draw_style_faults_24x24.png - draw_style_faults_label_24x24.png - Case48x48.png - GridModels.png - draw_style_WellCellsToRangeFilter_24x24.png - draw_style_surface_w_fault_mesh_24x24.png - InfoBox16x16.png - GeoMechCase48x48.png - GeoMechCases48x48.png - chain.png - TileWindows24x24.png - LasFile16x16.png - WellLogTrack16x16.png - WellLogPlot16x16.png - WellLogPlots16x16.png - WellLogCurve16x16.png - CrossSection16x16.png - CrossSections16x16.png - Refresh-32.png - SummaryPlot16x16.png - SummaryPlots16x16.png - SummaryCurve16x16.png - SummaryCurveFilter16x16.png - FormationCollection16x16.png - Formations16x16.png - Parallel24x24.png - Perspective24x24.png - IntersectionBox16x16.png - IntersectionXPlane16x16.png - IntersectionYPlane16x16.png - IntersectionZPlane16x16.png - PlotWindow24x24.png - 3DWindow24x24.png - 3DView16x16.png - SummaryCase48x48.png - openFolder24x24.png - clipboard.png - Copy.png - Erase.png - LeftAxis16x16.png - RightAxis16x16.png - BottomAxis16x16.png - Axes16x16.png - FishBones16x16.png - FishBoneGroup16x16.png - FishBoneGroupFromFile16x16.png - FishBoneLateralFromFile16x16.png - PerforationInterval16x16.png - PerforationIntervals16x16.png - CompletionsSymbol16x16.png - WellAllocPlots16x16.png - WellAllocPlot16x16.png - WellFlowPlot16x16.png - WellAllocPie16x16.png - WellAllocLegend16x16.png - SummaryPlotLight16x16.png - FractureLayout16x16.png - FractureSymbol16x16.png - FractureTemplate16x16.png - FractureTemplates16x16.png - TOFAccSatPlot16x16.png - FlowCharPlot16x16.png - SplitterH.png - SplitterV.png - calculator.png - statistics.png - - - fs_CellFace.glsl - vs_CellFace.glsl - vs_2dTextureCellFace.glsl - + + AppLogo48x48.png + Default.png + NorthViewArrow.png + SouthViewArrow.png + EastViewArrow.png + WestViewArrow.png + UpViewArrow.png + DownViewArrow.png + CellFilter_Values.png + CellFilter_Range.png + CellResult.png + EdgeResult_1.png + EdgeResult_2.png + Legend.png + Plus.png + Minus.png + Save.png + Well.png + WellCollection.png + octave.png + OctaveScriptFile16x16.png + Folder.png + EclipseInput48x48.png + Cases16x16.png + SummaryCases16x16.png + SummaryEnsemble16x16.png + SummaryGroup16x16.png + CreateGridCaseGroup16x16.png + GridCaseGroup16x16.png + Histogram16x16.png + Histograms16x16.png + ZoomAll16x16.png + draw_style_lines_24x24.png + draw_style_meshlines_24x24.png + draw_style_meshoutlines_24x24.png + draw_style_outlines_24x24.png + draw_style_surface_24x24.png + disable_lighting_24x24.png + SnapShot.png + SnapShotSave.png + SnapShotSaveViews.png + draw_style_faults_24x24.png + draw_style_faults_label_24x24.png + Case48x48.png + GridModels.png + draw_style_WellCellsToRangeFilter_24x24.png + draw_style_surface_w_fault_mesh_24x24.png + InfoBox16x16.png + GeoMechCase48x48.png + GeoMechCases48x48.png + chain.png + TileWindows24x24.png + LasFile16x16.png + WellLogTrack16x16.png + WellLogPlot16x16.png + WellLogPlots16x16.png + WellLogCurve16x16.png + WellCF16x16.png + CrossSection16x16.png + CrossSections16x16.png + Refresh-32.png + SummaryPlotLight16x16.png + SummaryPlots16x16.png + SummaryPlotsLight16x16.png + SummaryCurve16x16.png + SummaryCurveFilter16x16.png + EnsembleCurveSet16x16.png + EnsembleCurveSets16x16.png + SummaryXPlotLight16x16.png + SummaryXPlotsLight16x16.png + ObservedDataFile16x16.png + ObservedRSMDataFile16x16.png + ObservedCSVDataFile16x16.png + FormationCollection16x16.png + Formations16x16.png + Parallel24x24.png + Perspective24x24.png + IntersectionBox16x16.png + IntersectionXPlane16x16.png + IntersectionYPlane16x16.png + IntersectionZPlane16x16.png + PlotWindow24x24.png + 3DWindow24x24.png + 3DView16x16.png + SummaryCase48x48.png + SummaryCase16x16.png + openFolder24x24.png + clipboard.png + Copy.png + Erase.png + LeftAxis16x16.png + RightAxis16x16.png + BottomAxis16x16.png + Axes16x16.png + FishBones16x16.png + FishBoneGroup16x16.png + FishBoneGroupFromFile16x16.png + FishBoneLateralFromFile16x16.png + PerforationInterval16x16.png + PerforationIntervals16x16.png + CompletionsSymbol16x16.png + WellAllocPlots16x16.png + WellAllocPlot16x16.png + WellFlowPlot16x16.png + WellAllocPie16x16.png + WellAllocLegend16x16.png + RFTPlot16x16.png + RFTPlots16x16.png + FractureLayout16x16.png + FractureSymbol16x16.png + FractureTemplate16x16.png + FractureTemplates16x16.png + TOFAccSatPlot16x16.png + FlowCharPlot16x16.png + SplitterH.png + SplitterV.png + calculator.png + statistics.png + + + fs_CellFace.glsl + vs_CellFace.glsl + vs_2dTextureCellFace.glsl + diff --git a/ApplicationCode/Resources/SummaryCase16x16.png b/ApplicationCode/Resources/SummaryCase16x16.png new file mode 100644 index 0000000000..a878e4321a Binary files /dev/null and b/ApplicationCode/Resources/SummaryCase16x16.png differ diff --git a/ApplicationCode/Resources/SummaryCase48x48.png b/ApplicationCode/Resources/SummaryCase48x48.png index 96c327983e..617d910f43 100644 Binary files a/ApplicationCode/Resources/SummaryCase48x48.png and b/ApplicationCode/Resources/SummaryCase48x48.png differ diff --git a/ApplicationCode/Resources/SummaryCases16x16.png b/ApplicationCode/Resources/SummaryCases16x16.png new file mode 100644 index 0000000000..5ca069bbb6 Binary files /dev/null and b/ApplicationCode/Resources/SummaryCases16x16.png differ diff --git a/ApplicationCode/Resources/SummaryEnsemble16x16.png b/ApplicationCode/Resources/SummaryEnsemble16x16.png new file mode 100644 index 0000000000..27c94b8490 Binary files /dev/null and b/ApplicationCode/Resources/SummaryEnsemble16x16.png differ diff --git a/ApplicationCode/Resources/SummaryGroup16x16.png b/ApplicationCode/Resources/SummaryGroup16x16.png new file mode 100644 index 0000000000..f0af79850a Binary files /dev/null and b/ApplicationCode/Resources/SummaryGroup16x16.png differ diff --git a/ApplicationCode/Resources/SummaryPlot16x16.png b/ApplicationCode/Resources/SummaryPlot16x16.png deleted file mode 100644 index 488bdcd47f..0000000000 Binary files a/ApplicationCode/Resources/SummaryPlot16x16.png and /dev/null differ diff --git a/ApplicationCode/Resources/SummaryPlotsLight16x16.png b/ApplicationCode/Resources/SummaryPlotsLight16x16.png new file mode 100644 index 0000000000..3042602dc6 Binary files /dev/null and b/ApplicationCode/Resources/SummaryPlotsLight16x16.png differ diff --git a/ApplicationCode/Resources/SummaryXPlotLight16x16.png b/ApplicationCode/Resources/SummaryXPlotLight16x16.png new file mode 100644 index 0000000000..7b94ff5d63 Binary files /dev/null and b/ApplicationCode/Resources/SummaryXPlotLight16x16.png differ diff --git a/ApplicationCode/Resources/SummaryXPlotsLight16x16.png b/ApplicationCode/Resources/SummaryXPlotsLight16x16.png new file mode 100644 index 0000000000..344a7a7484 Binary files /dev/null and b/ApplicationCode/Resources/SummaryXPlotsLight16x16.png differ diff --git a/ApplicationCode/Resources/WellCF16x16.png b/ApplicationCode/Resources/WellCF16x16.png new file mode 100644 index 0000000000..f9bffaf7c1 Binary files /dev/null and b/ApplicationCode/Resources/WellCF16x16.png differ diff --git a/ApplicationCode/ResultStatisticsCache/CMakeLists.txt b/ApplicationCode/ResultStatisticsCache/CMakeLists.txt index 4ac1d30def..d3385421c2 100644 --- a/ApplicationCode/ResultStatisticsCache/CMakeLists.txt +++ b/ApplicationCode/ResultStatisticsCache/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (ResultStatisticsCache) @@ -15,4 +15,11 @@ add_library( ${PROJECT_NAME} RigStatisticsMath.cpp ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries(${PROJECT_NAME} LibCore) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h index 34079596a0..e583533b9c 100644 --- a/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h +++ b/ApplicationCode/ResultStatisticsCache/RigStatisticsMath.h @@ -62,7 +62,7 @@ class RigHistogramCalculator class MinMaxAccumulator { public: - MinMaxAccumulator(double initMin = -HUGE_VAL, double initMax = HUGE_VAL): max(initMax), min(initMin) {} + MinMaxAccumulator(double initMin = HUGE_VAL, double initMax = -HUGE_VAL): max(initMax), min(initMin) {} void addData(const std::vector& values) { diff --git a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp index 9597da7501..851cc99adf 100644 --- a/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaCaseInfoCommands.cpp @@ -207,14 +207,14 @@ class RiaGetActiveCellInfo: public RiaSocketCommand if (actCellInfo->isActive(cIdx)) { RigGridBase* grid = reservoirCells[cIdx].hostGrid(); - CVF_ASSERT(grid != NULL); + CVF_ASSERT(grid != nullptr); size_t cellIndex = reservoirCells[cIdx].gridLocalCellIndex(); size_t i, j, k; grid->ijkFromCellIndex(cellIndex, &i, &j, &k); size_t pi, pj, pk; - RigGridBase* parentGrid = NULL; + RigGridBase* parentGrid = nullptr; if (grid->isMainGrid()) { @@ -227,7 +227,7 @@ class RiaGetActiveCellInfo: public RiaSocketCommand { size_t parentCellIdx = reservoirCells[cIdx].parentCellIndex(); parentGrid = (static_cast(grid))->parentGrid(); - CVF_ASSERT(parentGrid != NULL); + CVF_ASSERT(parentGrid != nullptr); parentGrid->ijkFromCellIndex(parentCellIdx, &pi, &pj, &pk); } @@ -616,7 +616,7 @@ class RiaGetSelectedCells: public RiaSocketCommand { const RiuGeoMechSelectionItem* geomechItem = static_cast(item); - geomechItem->m_view->geoMechCase()->geoMechData()->femParts()->part(geomechItem->m_gridIndex)->structGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k); + geomechItem->m_view->femParts()->part(geomechItem->m_gridIndex)->structGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k); gridIndex = geomechItem->m_gridIndex; caseId = geomechItem->m_view->geoMechCase()->caseId; } diff --git a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp index 2b62407c09..c006605691 100644 --- a/ApplicationCode/SocketInterface/RiaNNCCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaNNCCommands.cpp @@ -39,6 +39,7 @@ #include "RimEclipseInputPropertyCollection.h" #include "RimEclipsePropertyFilterCollection.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimSimWellInViewCollection.h" @@ -297,7 +298,7 @@ class RiaSetNNCProperty: public RiaSocketCommand { public: RiaSetNNCProperty() : - m_currentReservoir(NULL), + m_currentReservoir(nullptr), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_timeStepCountToRead(0), m_bytesPerTimeStepToRead(0), @@ -545,11 +546,12 @@ class RiaSetNNCProperty: public RiaSocketCommand if (m_currentReservoir->reservoirViews[i]) { // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors(); + m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors(); // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } diff --git a/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp b/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp index 2eca0d817e..3db077693b 100644 --- a/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaProjectInfoCommands.cpp @@ -171,7 +171,7 @@ class RiaGetCaseGroups : public RiaSocketCommand virtual bool interpretCommand(RiaSocketServer* server, const QList& args, QDataStream& socketStream) { RimProject* proj = RiaApplication::instance()->project(); - RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : nullptr; if (analysisModels) { std::vector groupNames; @@ -236,7 +236,7 @@ class RiaGetCases : public RiaSocketCommand } RimProject* proj = RiaApplication::instance()->project(); - RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : NULL; + RimEclipseCaseCollection* analysisModels = (proj && proj->activeOilField()) ? proj->activeOilField()->analysisModels() : nullptr; if (analysisModels) { @@ -247,7 +247,7 @@ class RiaGetCases : public RiaSocketCommand } else { - RimIdenticalGridCaseGroup* caseGroup = NULL; + RimIdenticalGridCaseGroup* caseGroup = nullptr; for (size_t i = 0; i < analysisModels->caseGroups().size(); i++) { RimIdenticalGridCaseGroup* cg = analysisModels->caseGroups()[i]; diff --git a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp index ce3749ca88..fe13dadc8c 100644 --- a/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp +++ b/ApplicationCode/SocketInterface/RiaPropertyDataCommands.cpp @@ -38,6 +38,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipseInputPropertyCollection.h" #include "RimEclipseView.h" +#include "RimIntersectionCollection.h" #include "RimReservoirCellResultsStorage.h" #include "RimGeoMechView.h" #include "RimGeoMechCase.h" @@ -73,7 +74,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand // Find the requested data size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; if (rimCase && rimCase->results(porosityModelEnum)) { @@ -86,7 +87,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand } - if (scalarResultFrames == NULL) + if (scalarResultFrames == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName)); @@ -94,7 +95,7 @@ class RiaGetActiveCellProperty: public RiaSocketCommand // Write data back : timeStepCount, bytesPrTimestep, dataForTimestep0 ... dataForTimestepN - if ( scalarResultFrames == NULL) + if ( scalarResultFrames == nullptr) { // No data available socketStream << (quint64)0 << (quint64)0 ; @@ -229,7 +230,7 @@ class RiaGetGridProperty: public RiaSocketCommand QString porosityModelName = args[4]; RimEclipseCase*rimCase = server->findReservoir(caseId); - if (rimCase == NULL) + if (rimCase == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the case with ID: \"%1\"").arg(caseId)); @@ -381,8 +382,8 @@ class RiaSetActiveCellProperty: public RiaSocketCommand { public: RiaSetActiveCellProperty() : - m_currentReservoir(NULL), - m_scalarResultsToAdd(NULL), + m_currentReservoir(nullptr), + m_scalarResultsToAdd(nullptr), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_timeStepCountToRead(0), m_bytesPerTimeStepToRead(0), @@ -408,7 +409,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand // Find the requested data, Or create a set if we are setting data and it is not found size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; if (rimCase && rimCase->results(m_porosityModelEnum)) { @@ -435,7 +436,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand } } - if (scalarResultFrames == NULL) + if (scalarResultFrames == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName)); return true; @@ -580,7 +581,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand } std::vector readBuffer; - double * internalMatrixData = NULL; + double * internalMatrixData = nullptr; if (isCoarseningActive) { @@ -634,7 +635,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand if (m_currentTimeStepNumberToRead == m_timeStepCountToRead) { - if (m_currentReservoir != NULL) + if (m_currentReservoir != nullptr) { // Create a new input property if we have an input reservoir RimEclipseInputCase* inputRes = dynamic_cast(m_currentReservoir); @@ -660,7 +661,7 @@ class RiaSetActiveCellProperty: public RiaSocketCommand // Adjust the result data if only one time step is requested so the result behaves like a static result if (m_requestedTimesteps.size() == 1 && m_currentScalarIndex != cvf::UNDEFINED_SIZE_T) { - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; scalarResultFrames = &(m_currentReservoir->results(m_porosityModelEnum)->cellScalarResults(m_currentScalarIndex)); size_t lastIndexWithDataPresent = cvf::UNDEFINED_SIZE_T; for (size_t i = 0; i < scalarResultFrames->size(); i++) @@ -685,11 +686,12 @@ class RiaSetActiveCellProperty: public RiaSocketCommand if (m_currentReservoir->reservoirViews[i]) { // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors(); + m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors(); // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); } } } @@ -726,8 +728,8 @@ class RiaSetGridProperty : public RiaSocketCommand { public: RiaSetGridProperty() : - m_currentReservoir(NULL), - m_scalarResultsToAdd(NULL), + m_currentReservoir(nullptr), + m_scalarResultsToAdd(nullptr), m_currentGridIndex(cvf::UNDEFINED_SIZE_T), m_currentScalarIndex(cvf::UNDEFINED_SIZE_T), m_timeStepCountToRead(0), @@ -801,7 +803,7 @@ class RiaSetGridProperty : public RiaSocketCommand size_t scalarResultIndex = cvf::UNDEFINED_SIZE_T; - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; if (rimCase && rimCase->results(m_porosityModelEnum)) { @@ -823,7 +825,7 @@ class RiaSetGridProperty : public RiaSocketCommand } } - if (scalarResultFrames == NULL) + if (scalarResultFrames == nullptr) { server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the %1 model property named: \"%2\"").arg(porosityModelName).arg(propertyName)); return true; @@ -997,7 +999,7 @@ class RiaSetGridProperty : public RiaSocketCommand if (m_currentTimeStepNumberToRead == m_timeStepCountToRead) { - if (m_currentReservoir != NULL) + if (m_currentReservoir != nullptr) { // Create a new input property if we have an input reservoir RimEclipseInputCase* inputRes = dynamic_cast(m_currentReservoir); @@ -1023,7 +1025,7 @@ class RiaSetGridProperty : public RiaSocketCommand // Adjust the result data if only one time step is requested so the result behaves like a static result if (m_requestedTimesteps.size() == 1 && m_currentScalarIndex != cvf::UNDEFINED_SIZE_T) { - std::vector< std::vector >* scalarResultFrames = NULL; + std::vector< std::vector >* scalarResultFrames = nullptr; scalarResultFrames = &(m_currentReservoir->results(m_porosityModelEnum)->cellScalarResults(m_currentScalarIndex)); size_t lastIndexWithDataPresent = cvf::UNDEFINED_SIZE_T; for (size_t i = 0; i < scalarResultFrames->size(); i++) @@ -1048,11 +1050,13 @@ class RiaSetGridProperty : public RiaSocketCommand if (m_currentReservoir->reservoirViews[i]) { // As new result might have been introduced, update all editors connected - m_currentReservoir->reservoirViews[i]->cellResult->updateConnectedEditors(); + m_currentReservoir->reservoirViews[i]->cellResult()->updateConnectedEditors(); // It is usually not needed to create new display model, but if any derived geometry based on generated data (from Octave) // a full display model rebuild is required m_currentReservoir->reservoirViews[i]->scheduleCreateDisplayModelAndRedraw(); + m_currentReservoir->reservoirViews[i]->crossSectionCollection()->scheduleCreateDisplayModelAndRedraw2dIntersectionViews(); + } } } diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.cpp b/ApplicationCode/SocketInterface/RiaSocketServer.cpp index 799acd25d0..ff12893afe 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketServer.cpp @@ -44,10 +44,10 @@ //-------------------------------------------------------------------------------------------------- RiaSocketServer::RiaSocketServer(QObject* parent) : QObject(parent), - m_tcpServer(NULL), - m_currentClient(NULL), + m_tcpServer(nullptr), + m_currentClient(nullptr), m_currentCommandSize(0), - m_currentCommand(NULL), + m_currentCommand(nullptr), m_currentCaseId(-1) { m_errorMessageDialog = new QErrorMessage(RiuMainWindow::instance()); @@ -145,23 +145,23 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId) // If the active mdi window is different from an Eclipse view, search through available mdi windows to find the last activated // Eclipse view. The sub windows are returned with the most recent activated window at the back. QList subWindows = RiuMainWindow::instance()->subWindowList(QMdiArea::ActivationHistoryOrder); - for (int i = subWindows.size() - 1; i > -1; i--) - { - RiuViewer* viewer = subWindows[i]->widget()->findChild(); - if (viewer) - { + for (int i = subWindows.size() - 1; i > -1; i--) + { + RiuViewer* viewer = subWindows[i]->widget()->findChild(); + if (viewer) + { RimEclipseView* riv = dynamic_cast(viewer->ownerReservoirView()); if (riv) { return riv->eclipseCase(); } - } - } + } + } } else { RimProject* project = RiaApplication::instance()->project(); - if (!project) return NULL; + if (!project) return nullptr; std::vector cases; project->allCases(cases); @@ -175,7 +175,7 @@ RimEclipseCase* RiaSocketServer::findReservoir(int caseId) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -302,7 +302,7 @@ void RiaSocketServer::terminateCurrentConnection() m_currentClient->disconnect(SIGNAL(disconnected())); m_currentClient->disconnect(SIGNAL(readyRead())); m_currentClient->deleteLater(); - m_currentClient = NULL; + m_currentClient = nullptr; } // Clean up more state: @@ -310,7 +310,7 @@ void RiaSocketServer::terminateCurrentConnection() if (m_currentCommand) { delete m_currentCommand; - m_currentCommand = NULL; + m_currentCommand = nullptr; } m_currentCommandSize = 0; @@ -341,8 +341,8 @@ void RiaSocketServer::handleNextPendingConnection() QTcpSocket* clientToHandle = m_tcpServer->nextPendingConnection(); if (clientToHandle) { - CVF_ASSERT(m_currentClient == NULL); - CVF_ASSERT(m_currentCommand == NULL); + CVF_ASSERT(m_currentClient == nullptr); + CVF_ASSERT(m_currentCommand == nullptr); m_currentClient = clientToHandle; m_currentCommandSize = 0; diff --git a/ApplicationCode/SocketInterface/RiaSocketServer.h b/ApplicationCode/SocketInterface/RiaSocketServer.h index 0f4d0878d1..c556cbebc8 100644 --- a/ApplicationCode/SocketInterface/RiaSocketServer.h +++ b/ApplicationCode/SocketInterface/RiaSocketServer.h @@ -20,6 +20,8 @@ #pragma once +#include "RiaSocketServerDefines.h" + #include #include #include @@ -34,11 +36,9 @@ class QTimer; class RimEclipseCase; class RiaSocketCommand; -namespace riOctavePlugin -{ - const int qtDataStreamVersion = QDataStream::Qt_4_0; -} - +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- class RiaSocketServer : public QObject { Q_OBJECT @@ -47,7 +47,7 @@ class RiaSocketServer : public QObject enum ReadState {ReadingCommand, ReadingPropertyData}; public: - explicit RiaSocketServer(QObject *parent = 0); + explicit RiaSocketServer(QObject *parent = nullptr); ~RiaSocketServer(); unsigned short serverPort(); diff --git a/ApplicationCode/SocketInterface/RiaSocketServerDefines.h b/ApplicationCode/SocketInterface/RiaSocketServerDefines.h new file mode 100644 index 0000000000..542bf47484 --- /dev/null +++ b/ApplicationCode/SocketInterface/RiaSocketServerDefines.h @@ -0,0 +1,25 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include + +namespace riOctavePlugin +{ + const int qtDataStreamVersion = QDataStream::Qt_4_0; +} + diff --git a/ApplicationCode/SocketInterface/RiaSocketTools.cpp b/ApplicationCode/SocketInterface/RiaSocketTools.cpp index 54d337a241..fb4e68d822 100644 --- a/ApplicationCode/SocketInterface/RiaSocketTools.cpp +++ b/ApplicationCode/SocketInterface/RiaSocketTools.cpp @@ -49,7 +49,7 @@ //-------------------------------------------------------------------------------------------------- RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const QList& args) { - RimEclipseCase* rimCase = NULL; + RimEclipseCase* rimCase = nullptr; int caseId = -1; if (args.size() > 1) @@ -58,7 +58,7 @@ RimEclipseCase* RiaSocketTools::findCaseFromArgs(RiaSocketServer* server, const } rimCase = server->findReservoir(caseId); - if (rimCase == NULL) + if (rimCase == nullptr) { // TODO: Display error message a different place to avoid socket comm to be halted. //server->errorMessageDialog()->showMessage(RiaSocketServer::tr("ResInsight SocketServer: \n") + RiaSocketServer::tr("Could not find the Case with CaseId : \"%1\"").arg(caseId)); @@ -79,7 +79,7 @@ void RiaSocketTools::getCaseInfoFromCase(RimCase* rimCase, qint64& caseId, QStri caseName = rimCase->caseUserDescription; RimEclipseCase* eclCase = dynamic_cast (rimCase); - RimCaseCollection* caseCollection = NULL; + RimCaseCollection* caseCollection = nullptr; if (eclCase) { caseCollection = eclCase->parentCaseCollection(); diff --git a/ApplicationCode/UnitTests/CMakeLists_files.cmake b/ApplicationCode/UnitTests/CMakeLists_files.cmake index 685d3d2b24..dacb8749a3 100644 --- a/ApplicationCode/UnitTests/CMakeLists_files.cmake +++ b/ApplicationCode/UnitTests/CMakeLists_files.cmake @@ -1,49 +1,49 @@ -# 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() +CONFIGURE_FILE( ${CMAKE_CURRENT_LIST_DIR}/RiaTestDataDirectory.h.cmake + ${CMAKE_BINARY_DIR}/Generated/RiaTestDataDirectory.h +) set (SOURCE_GROUP_HEADER_FILES ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}cvfGeometryTools-Test.cpp -${CEE_CURRENT_LIST_DIR}Ert-Test.cpp -${CEE_CURRENT_LIST_DIR}RifcCommandCore-Test.cpp -${CEE_CURRENT_LIST_DIR}RifEclipseInputFileTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseOutput-Test.cpp -${CEE_CURRENT_LIST_DIR}RifReaderEclipseSummary-Test.cpp -${CEE_CURRENT_LIST_DIR}RigActiveCellInfo-Test.cpp -${CEE_CURRENT_LIST_DIR}RigReservoir-Test.cpp -${CEE_CURRENT_LIST_DIR}RigStatisticsMath-Test.cpp -${CEE_CURRENT_LIST_DIR}RigWellPathIntersectionTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RimWellLogExtractionCurveImpl-Test.cpp -${CEE_CURRENT_LIST_DIR}RivPipeGeometryGenerator-Test.cpp -${CEE_CURRENT_LIST_DIR}RivTernaryScalarMapper-Test.cpp -${CEE_CURRENT_LIST_DIR}ScalarMapper-Test.cpp -${CEE_CURRENT_LIST_DIR}WellPathAsciiFileReader-Test.cpp -${CEE_CURRENT_LIST_DIR}opm-flowdiagnostics-Test.cpp -${CEE_CURRENT_LIST_DIR}RigTofAccumulatedPhaseFractionsCalculator-Test.cpp -${CEE_CURRENT_LIST_DIR}HDF5FileReader-Test.cpp -${CEE_CURRENT_LIST_DIR}RigCellGeometryTools-Test.cpp -${CEE_CURRENT_LIST_DIR}RigHexIntersectionTools-Test.cpp -${CEE_CURRENT_LIST_DIR}ObservedDataParser-Test.cpp -${CEE_CURRENT_LIST_DIR}EclipseRftReader-Test.cpp -${CEE_CURRENT_LIST_DIR}RicExpressionParser-Test.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap-Test.cpp -${CEE_CURRENT_LIST_DIR}FixedWidthDataParser-Test.cpp -${CEE_CURRENT_LIST_DIR}RigTimeCurveHistoryMerger-Test.cpp -${CEE_CURRENT_LIST_DIR}ListKeywordsForObjectsAndFields-Test.cpp -${CEE_CURRENT_LIST_DIR}RiaProjectFileVersionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/cvfGeometryTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/Ert-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifcCommandCore-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifEclipseInputFileTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseOutput-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifReaderEclipseSummary-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigActiveCellInfo-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigReservoir-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigStatisticsMath-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellPathIntersectionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurveImpl-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RivPipeGeometryGenerator-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RivTernaryScalarMapper-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/ScalarMapper-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/WellPathAsciiFileReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/opm-flowdiagnostics-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTofAccumulatedPhaseFractionsCalculator-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/HDF5FileReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigCellGeometryTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigHexIntersectionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/ObservedDataParser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/EclipseRftReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RicExpressionParser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryVectorDescriptionMap-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/FixedWidthDataParser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTimeCurveHistoryMerger-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/ListKeywordsForObjectsAndFields-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaProjectFileVersionTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifElementPropertyTableReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RimRelocatePath-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigTransmissibilityCondenser-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaEclipseUnitTools-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaTextFileCompare-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RifCaseRealizationParametersReader-Test.cpp +${CMAKE_CURRENT_LIST_DIR}/RigWellLogExtractor-Test.cpp ) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - list (APPEND SOURCE_GROUP_SOURCE_FILES - ${CEE_CURRENT_LIST_DIR}RigTransmissibilityCondenser-Test.cpp - ) -endif() - list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES} ) @@ -52,4 +52,4 @@ list(APPEND CODE_SOURCE_FILES ${SOURCE_GROUP_SOURCE_FILES} ) -source_group( "UnitTests" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "UnitTests" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp b/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp index ea771d836f..28b849f60e 100644 --- a/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp +++ b/ApplicationCode/UnitTests/HDF5FileReader-Test.cpp @@ -12,122 +12,122 @@ //-------------------------------------------------------------------------------------------------- TEST(DISABLED_HDFTests, BasicFileRead) { - std::string file_path = "D:/ResInsight/SourSim/PKMUNK_NOV_TEST_SS.sourpre.00001"; + std::string file_path = "D:/ResInsight/SourSim/PKMUNK_NOV_TEST_SS.sourpre.00001"; - try - { - H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately + try + { + H5::Exception::dontPrint(); // Turn off auto-printing of failures to handle the errors appropriately - H5::H5File file(file_path.c_str(), H5F_ACC_RDONLY); + H5::H5File file(file_path.c_str(), H5F_ACC_RDONLY); - { - H5::Group timestep = file.openGroup("Timestep_00001"); - H5::Attribute attr = timestep.openAttribute("timestep"); + { + H5::Group timestep = file.openGroup("Timestep_00001"); + H5::Attribute attr = timestep.openAttribute("timestep"); - double timestep_value = 0.0; + double timestep_value = 0.0; - H5::DataType type = attr.getDataType(); - attr.read(type, ×tep_value); + H5::DataType type = attr.getDataType(); + attr.read(type, ×tep_value); - //std::cout << "Timestep value " << timestep_value << std::endl; - EXPECT_NEAR(timestep_value, 1.0, 1e-1); - } + //std::cout << "Timestep value " << timestep_value << std::endl; + EXPECT_NEAR(timestep_value, 1.0, 1e-1); + } - { - // Group size is not an attribute! + { + // Group size is not an attribute! - H5::Group GridFunctions = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions"); + H5::Group GridFunctions = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions"); - hsize_t group_size = GridFunctions.getNumObjs(); + hsize_t group_size = GridFunctions.getNumObjs(); - //std::cout << "GridFunctions group_size " << group_size << std::endl; - EXPECT_EQ(size_t(20), group_size); + //std::cout << "GridFunctions group_size " << group_size << std::endl; + EXPECT_EQ(size_t(20), group_size); -/* for (hsize_t i = 0; i < group_size; i++) - { - // H5std_string node_name = GridFunctions.getObjnameByIdx(i); // crashes on VS2017 due to lib/heap/runtime differences to HDF5 VS2015 lib +/* for (hsize_t i = 0; i < group_size; i++) + { + // H5std_string node_name = GridFunctions.getObjnameByIdx(i); // crashes on VS2017 due to lib/heap/runtime differences to HDF5 VS2015 lib - std::string node_name; - node_name.resize(1024); + std::string node_name; + node_name.resize(1024); - ssize_t slen = GridFunctions.getObjnameByIdx(i, &node_name[0], 1023); + ssize_t slen = GridFunctions.getObjnameByIdx(i, &node_name[0], 1023); - node_name.resize(slen + 1); + node_name.resize(slen + 1); - std::cout << "GridFunctions sub-node name " << node_name << std::endl; - } + std::cout << "GridFunctions sub-node name " << node_name << std::endl; + } */ - std::string first_subnode(1024, '\0'); + std::string first_subnode(1024, '\0'); - ssize_t slen = GridFunctions.getObjnameByIdx(0, &first_subnode[0], 1023); - first_subnode.resize(slen + 1); + ssize_t slen = GridFunctions.getObjnameByIdx(0, &first_subnode[0], 1023); + first_subnode.resize(slen + 1); - EXPECT_TRUE(first_subnode.compare(0, slen, "GridFunction_00002") == 0); - } + EXPECT_TRUE(first_subnode.compare(0, slen, "GridFunction_00002") == 0); + } - { - H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); - H5::Attribute attr = GridFunction_00002.openAttribute("limits_max"); + { + H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); + H5::Attribute attr = GridFunction_00002.openAttribute("limits_max"); - double limits_max = 0.0; - - H5::DataType type = attr.getDataType(); - attr.read(type, &limits_max); + double limits_max = 0.0; + + H5::DataType type = attr.getDataType(); + attr.read(type, &limits_max); -// std::cout << "limits_max " << limits_max << std::endl; - EXPECT_NEAR(limits_max, 0.3970204292629652, 1e-10); - } +// std::cout << "limits_max " << limits_max << std::endl; + EXPECT_NEAR(limits_max, 0.3970204292629652, 1e-10); + } - { - H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); - H5::DataSet dataset = H5::DataSet(GridFunction_00002.openDataSet("values")); + { + H5::Group GridFunction_00002 = file.openGroup("Timestep_00001/GridParts/GridPart_00000/GridFunctions/GridFunction_00002"); + H5::DataSet dataset = H5::DataSet(GridFunction_00002.openDataSet("values")); - hsize_t dims[2]; - H5::DataSpace dataspace = dataset.getSpace(); - dataspace.getSimpleExtentDims(dims, NULL); + hsize_t dims[2]; + H5::DataSpace dataspace = dataset.getSpace(); + dataspace.getSimpleExtentDims(dims, nullptr); - std::vector values; - values.resize(dims[0]); - dataset.read(values.data(), H5::PredType::NATIVE_DOUBLE); + std::vector values; + values.resize(dims[0]); + dataset.read(values.data(), H5::PredType::NATIVE_DOUBLE); -/* for (hsize_t i = 0; i < dims[0]; i++) - { - std::cout << "value " << i << " " << values[i] << std::endl; +/* for (hsize_t i = 0; i < dims[0]; i++) + { + std::cout << "value " << i << " " << values[i] << std::endl; - } + } */ - EXPECT_NEAR(values[0], 0.32356910366452146, 1e-10); - EXPECT_NEAR(values[dims[0] - 1], 0.12200070891582514, 1e-10); - } - - - - } // end of try block - - - catch (H5::FileIException error) // catch failure caused by the H5File operations - { - std::cout << error.getCDetailMsg(); - } - - catch (H5::DataSetIException error) // catch failure caused by the DataSet operations - { - std::cout << error.getCDetailMsg(); - } - - catch (H5::DataSpaceIException error) // catch failure caused by the DataSpace operations - { - std::cout << error.getCDetailMsg(); - } - - catch (H5::DataTypeIException error) // catch failure caused by the DataSpace operations - { - std::cout << error.getCDetailMsg(); - } + EXPECT_NEAR(values[0], 0.32356910366452146, 1e-10); + EXPECT_NEAR(values[dims[0] - 1], 0.12200070891582514, 1e-10); + } + + + + } // end of try block + + + catch (H5::FileIException error) // catch failure caused by the H5File operations + { + std::cout << error.getCDetailMsg(); + } + + catch (H5::DataSetIException error) // catch failure caused by the DataSet operations + { + std::cout << error.getCDetailMsg(); + } + + catch (H5::DataSpaceIException error) // catch failure caused by the DataSpace operations + { + std::cout << error.getCDetailMsg(); + } + + catch (H5::DataTypeIException error) // catch failure caused by the DataSpace operations + { + std::cout << error.getCDetailMsg(); + } } diff --git a/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp b/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp index a6faa68345..f75ad54b31 100644 --- a/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp +++ b/ApplicationCode/UnitTests/ObservedDataParser-Test.cpp @@ -299,7 +299,7 @@ TEST(RifColumnBasedRsmspecParserTest, TestTwoPages) out << " OP-1 OP-1 OP-1 OP-1 OP-1 OP-1 \n"; out << "\n"; out << "\n"; - out << "1386 2003.170 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 --comment \n"; + out << "1386 2003.170 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 --comment \n"; out << "1436 2003.307 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 --comment\n"; out << "1574 2003.685 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12\n"; out << "1636 2003.855 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12 1.0E-12\n"; diff --git a/ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp b/ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp new file mode 100644 index 0000000000..30cdad6a7d --- /dev/null +++ b/ApplicationCode/UnitTests/RiaEclipseUnitTools-Test.cpp @@ -0,0 +1,76 @@ +#include "gtest/gtest.h" + +#include "RiaEclipseUnitTools.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaEclipseUnitTools, TestConversionToMeter) +{ + double deltaRange = 1e-7; + + { + double sourceValue = RiaEclipseUnitTools::feetPerMeter(); + QString unitText = "ft"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = RiaEclipseUnitTools::feetPerMeter() * 12.0; + QString unitText = "in"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = 1.0; + QString unitText = "m"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = 100.0; + QString unitText = "cm"; + double destValue = RiaEclipseUnitTools::convertToMeter(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaEclipseUnitTools, TestConversionToFeet) +{ + double deltaRange = 1e-7; + + { + double sourceValue = 1.0; + QString unitText = "ft"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = 1.0 * 12.0; + QString unitText = "in"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = RiaEclipseUnitTools::meterPerFeet(); + QString unitText = "m"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } + + { + double sourceValue = RiaEclipseUnitTools::meterPerFeet() * 100.0; + QString unitText = "cm"; + double destValue = RiaEclipseUnitTools::convertToFeet(sourceValue, unitText); + EXPECT_NEAR(1.0, destValue, deltaRange); + } +} diff --git a/ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake b/ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake new file mode 100644 index 0000000000..cc9abc663e --- /dev/null +++ b/ApplicationCode/UnitTests/RiaTestDataDirectory.h.cmake @@ -0,0 +1,3 @@ +// Test data directory used by unit tests + +#define TEST_DATA_DIR "${CMAKE_CURRENT_LIST_DIR}/TestData" diff --git a/ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp b/ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp new file mode 100644 index 0000000000..a80e2f5a35 --- /dev/null +++ b/ApplicationCode/UnitTests/RiaTextFileCompare-Test.cpp @@ -0,0 +1,68 @@ +#include "gtest/gtest.h" + +#include "RiaRegressionTest.h" +#include "RiaTestDataDirectory.h" +#include "RiaTextFileCompare.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaTextFileCompareTest, BasicCompareWithDiff) +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + QString folderContainingDiff = regTestConfig.folderContainingDiffTool(); + + QString baseFolder = QString("%1/TextCompare/base").arg(TEST_DATA_DIR); + QString referenceFolder = QString("%1/TextCompare/reference").arg(TEST_DATA_DIR); + + RiaTextFileCompare compare(folderContainingDiff); + + bool noDifference = compare.runComparison(baseFolder, referenceFolder); + EXPECT_FALSE(noDifference); + + QString diffOutput = compare.diffOutput(); + EXPECT_FALSE(diffOutput.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaTextFileCompareTest, BasicCompareNoDiff) +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + QString folderContainingDiff = regTestConfig.folderContainingDiffTool(); + + QString baseFolder = QString("%1/TextCompare/base/folderB").arg(TEST_DATA_DIR); + QString referenceFolder = QString("%1/TextCompare/reference/folderB").arg(TEST_DATA_DIR); + + RiaTextFileCompare compare(folderContainingDiff); + + bool noDifference = compare.runComparison(baseFolder, referenceFolder); + EXPECT_TRUE(noDifference); + + QString diffOutput = compare.diffOutput(); + EXPECT_TRUE(diffOutput.isEmpty()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RiaTextFileCompareTest, BasicCompareError) +{ + RiaRegressionTest regTestConfig; + regTestConfig.readSettingsFromApplicationStore(); + QString folderContainingDiff = regTestConfig.folderContainingDiffTool(); + + QString baseFolder = QString("%1/TextCompare/baseDoesNotExist").arg(TEST_DATA_DIR); + QString referenceFolder = QString("%1/TextCompare/reference/folderB").arg(TEST_DATA_DIR); + + RiaTextFileCompare compare(folderContainingDiff); + + bool noDifference = compare.runComparison(baseFolder, referenceFolder); + EXPECT_FALSE(noDifference); + + QString error = compare.errorMessage(); + EXPECT_FALSE(error.isEmpty()); +} diff --git a/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp new file mode 100644 index 0000000000..6d4d42080b --- /dev/null +++ b/ApplicationCode/UnitTests/RicElementPropertyTableReader-Test.cpp @@ -0,0 +1,53 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifElementPropertyTableReader.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RifElementPropertyTableReader/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, BasicUsage) +{ + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(table.hasData); + + EXPECT_EQ(2, metadata.dataColumns.size()); + EXPECT_STREQ("MODULUS", metadata.dataColumns[0].toStdString().c_str()); + EXPECT_STREQ("RATIO", metadata.dataColumns[1].toStdString().c_str()); + + EXPECT_EQ(2, table.data.size()); + EXPECT_EQ(4320, table.elementIds.size()); + EXPECT_EQ(4320, table.data[0].size()); + EXPECT_EQ(4320, table.data[1].size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, ParseFailed) +{ + try + { + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE_error.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.startsWith("Number of columns mismatch")); + } +} diff --git a/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp new file mode 100644 index 0000000000..0f004f0a3d --- /dev/null +++ b/ApplicationCode/UnitTests/RifCaseRealizationParametersReader-Test.cpp @@ -0,0 +1,110 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifCaseRealizationParametersReader.h" +#include "RifFileParseTools.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RifCaseRealizationParametersReader/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, LocatorTestSuccess) +{ + QString file = RifCaseRealizationParametersFileLocator::locate(TEST_DATA_DIRECTORY + "3/2"); + QString expected = TEST_DATA_DIRECTORY + "parameters.txt"; + EXPECT_EQ(expected.toStdString(), file.toStdString()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, LocatorTestFailure) +{ + QString file = RifCaseRealizationParametersFileLocator::locate(TEST_DATA_DIRECTORY + "3/2/1"); + QString expected = ""; + EXPECT_EQ(expected.toStdString(), file.toStdString()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, SuccessfulParsing) +{ + RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters.txt"); + + try + { + reader.parse(); + + const std::shared_ptr parameters(reader.parameters()); + std::map params = parameters->parameters(); + + EXPECT_EQ(1U, params.count("LETSWOF:L_1OW")); + EXPECT_EQ(1U, params.count("LETSGOF:KRG1")); + EXPECT_EQ(1U, params.count("LOG10_MULTFLT:MULTFLT_F1")); + EXPECT_EQ(1U, params.count("TST:TEXT_PARAM")); + + EXPECT_TRUE(params["LETSWOF:L_1OW"].isNumeric()); + EXPECT_EQ(1.83555, params["LETSWOF:L_1OW"].numericValue()); + EXPECT_TRUE(params["LETSGOF:KRG1"].isNumeric()); + EXPECT_EQ(0.97, params["LETSGOF:KRG1"].numericValue()); + EXPECT_TRUE(params["TST:TEXT_PARAM"].isText()); + EXPECT_EQ(std::string("YES"), params["TST:TEXT_PARAM"].textValue().toStdString()); + } + catch (...) + { + EXPECT_TRUE(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, ParseFailed_InvalidFormat) +{ + RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_format.txt"); + + try + { + reader.parse(); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.contains("Invalid file format in line 10")); + } + catch (...) + { + EXPECT_TRUE(false); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RifCaseRealizationParametersReaderTest, ParseFailed_InvalidNumberFormat) +{ + RifCaseRealizationParametersReader reader(TEST_DATA_DIRECTORY + "parameters_invalid_number_format.txt"); + + try + { + reader.parse(); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.contains("Invalid number format in line 10")); + } + catch (...) + { + EXPECT_TRUE(false); + } +} diff --git a/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp new file mode 100644 index 0000000000..0683e25451 --- /dev/null +++ b/ApplicationCode/UnitTests/RifElementPropertyTableReader-Test.cpp @@ -0,0 +1,54 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" + +#include "RifElementPropertyTableReader.h" +#include "RifFileParseTools.h" + +#include +#include + + +static const QString TEST_DATA_DIRECTORY = QString("%1/RifElementPropertyTableReader/").arg(TEST_DATA_DIR); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, BasicUsage) +{ + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(table.hasData); + + EXPECT_EQ(2u, metadata.dataColumns.size()); + EXPECT_STREQ("MODULUS", metadata.dataColumns[0].toStdString().c_str()); + EXPECT_STREQ("RATIO", metadata.dataColumns[1].toStdString().c_str()); + + EXPECT_EQ(2u, table.data.size()); + EXPECT_EQ(4320u, table.elementIds.size()); + EXPECT_EQ(4320u, table.data[0].size()); + EXPECT_EQ(4320u, table.data[1].size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicElementPropertyTableReaderTest, ParseFailed) +{ + try + { + RifElementPropertyMetadata metadata = RifElementPropertyTableReader::readMetadata(TEST_DATA_DIRECTORY + "ELASTIC_TABLE_error.inp"); + + RifElementPropertyTable table; + RifElementPropertyTableReader::readData(&metadata, &table); + + EXPECT_TRUE(false); + } + catch (FileParseException e) + { + EXPECT_TRUE(e.message.startsWith("Number of columns mismatch")); + } +} diff --git a/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp b/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp index 7842a67e2d..4ce0cf87ae 100644 --- a/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp +++ b/ApplicationCode/UnitTests/RifcCommandCore-Test.cpp @@ -205,3 +205,63 @@ TEST(RicfCommands, TransformFileCommandObjectsToExecutableCommandObjects) delete(obj); } } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicfCommands, IgnoreCommentLines) +{ + QString commandString = R"( + replaceCase(newGridFile="/1.EGRID", caseId=1) + # replaceCase(newGridFile="/2.EGRID", caseId=2) + + openProject(path="/home/user/ResInsightProject.rsp") + replaceCase(newGridFile="/3.EGRID", caseId=3) + # replaceCase(newGridFile="/4.EGRID", caseId=4) + + exportSnapshots() + replaceCase(newGridFile="/6.EGRID", caseId=6) + replaceCase(newGridFile="/7.EGRID", caseId=7) + + closeProject() + + )"; + + QTextStream inputStream(&commandString); + RicfMessages errors; + + auto objects = RicfCommandFileReader::readCommands(inputStream, caf::PdmDefaultObjectFactory::instance(), &errors); + EXPECT_TRUE(errors.m_messages.empty()); + + EXPECT_EQ((size_t)7, objects.size()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RicfCommands, IgnoreCommentLinesShowErrorLine) +{ + QString commandString = R"( + replaceCase(newGridFile="/1.EGRID", caseId=1) + # replaceCase(newGridFile="/2.EGRID", caseId=2) + + openProject(path="/home/user/ResInsightProject.rsp") + replaceCase(newGridFile="/3.EGRID", caseId=3) + # replaceCase(newGridFile="/4.EGRID", caseId=4) + + + exportSnapshots() + sdareplaceCase(newGridFile="/6.EGRID", caseId=6) + replaceCase(newGridFile="/7.EGRID", caseId=7) + + closeProject() + + )"; + + QTextStream inputStream(&commandString); + RicfMessages errors; + + auto objects = RicfCommandFileReader::readCommands(inputStream, caf::PdmDefaultObjectFactory::instance(), &errors); + EXPECT_EQ((size_t)1, errors.m_messages.size()); + EXPECT_EQ((size_t)6, objects.size()); +} diff --git a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp index 641d7e69ff..faa0fcf4ba 100644 --- a/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp +++ b/ApplicationCode/UnitTests/RigCellGeometryTools-Test.cpp @@ -142,7 +142,6 @@ TEST(RigCellGeometryTools, findCellAverageZTest) } -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES //-------------------------------------------------------------------------------------------------- /// @@ -296,7 +295,7 @@ TEST(RigCellGeometryTools, polylinePolygonIntersectionTest2) } -#include "RigWellPathStimplanIntersector.h" +#include "Completions/RigWellPathStimplanIntersector.h" //-------------------------------------------------------------------------------------------------- /// @@ -414,4 +413,3 @@ TEST(RigWellPathStimplanIntersector, intersection) } -#endif // USE_PROTOTYPE_FEATURE_FRACTURES diff --git a/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp b/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp index 8c304e9946..d441785fa8 100644 --- a/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp +++ b/ApplicationCode/UnitTests/RigStatisticsMath-Test.cpp @@ -125,7 +125,7 @@ TEST(RigStatisticsMath, HistogramPercentiles) double min, max, range, mean, stdev; - RigStatisticsMath::calculateBasicStatistics(values, &min, &max, NULL, &range, &mean, &stdev); + RigStatisticsMath::calculateBasicStatistics(values, &min, &max, nullptr, &range, &mean, &stdev); std::vector histogram; RigHistogramCalculator histCalc(min, max, 100, &histogram); diff --git a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp index 54d7a9bcd1..db0c5949d5 100644 --- a/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp +++ b/ApplicationCode/UnitTests/RigTransmissibilityCondenser-Test.cpp @@ -18,7 +18,7 @@ #include "gtest/gtest.h" -#include "RigTransmissibilityCondenser.h" +#include "Completions/RigTransmissibilityCondenser.h" //-------------------------------------------------------------------------------------------------- /// diff --git a/ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp b/ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp new file mode 100644 index 0000000000..86abb48003 --- /dev/null +++ b/ApplicationCode/UnitTests/RigWellLogExtractor-Test.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "gtest/gtest.h" + +#include "RifReaderMockModel.h" + +#include "RigEclipseCaseData.h" +#include "RigEclipseWellLogExtractor.h" +#include "RigGridManager.h" +#include "RigMainGrid.h" +#include "RigWellPath.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RigEclipseWellLogExtractor, ShortWellPathInsideOneCell) +{ + cvf::ref reservoir = new RigEclipseCaseData(nullptr); + + { + cvf::ref mockFileInterface = new RifReaderMockModel; + + mockFileInterface->setWorldCoordinates(cvf::Vec3d(10, 10, 10), cvf::Vec3d(20, 20, 20)); + mockFileInterface->setGridPointDimensions(cvf::Vec3st(4, 5, 6)); + mockFileInterface->enableWellData(false); + + mockFileInterface->open("", reservoir.p()); + + reservoir->mainGrid()->computeCachedData(); + } + + auto cells = reservoir->mainGrid()->globalCellArray(); + EXPECT_FALSE(cells.empty()); + + auto firstCell = reservoir->mainGrid()->globalCellArray()[0]; + auto center = firstCell.center(); + + cvf::ref wellPathGeometry = new RigWellPath; + { + std::vector wellPathPoints; + std::vector mdValues; + + { + double offset = 0.0; + wellPathPoints.push_back(center); + mdValues.push_back(offset); + } + + { + double offset = 0.1; + wellPathPoints.push_back(center + cvf::Vec3d(0, 0, offset)); + mdValues.push_back(offset); + } + + wellPathGeometry->m_wellPathPoints = wellPathPoints; + wellPathGeometry->m_measuredDepths = mdValues; + } + + cvf::ref e = new RigEclipseWellLogExtractor(reservoir.p(), wellPathGeometry.p(), ""); + + auto intersections = e->cellIntersectionInfosAlongWellPath(); + EXPECT_FALSE(intersections.empty()); +} diff --git a/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp new file mode 100644 index 0000000000..7a54760e80 --- /dev/null +++ b/ApplicationCode/UnitTests/RimRelocatePath-Test.cpp @@ -0,0 +1,73 @@ +#include "gtest/gtest.h" + +#include "RiaTestDataDirectory.h" +#include "RimProject.h" + +#include "cafPdmObjectHandle.h" +#include "cafFilePath.h" + +#include + +#include + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +void fieldsByType(caf::PdmObjectHandle* object, std::vector& typedFields) +{ + if (!object) return; + + std::vector allFieldsInObject; + object->fields(allFieldsInObject); + + std::vector children; + + for (const auto& field : allFieldsInObject) + { + caf::PdmField* typedField = dynamic_cast*>(field); + if (typedField) typedFields.push_back(&typedField->v()); + + caf::PdmField< std::vector >* typedFieldInVector = dynamic_cast >*>(field); + if (typedFieldInVector) + { + for (T& typedFieldFromVector : typedFieldInVector->v()) + { + typedFields.push_back(&typedFieldFromVector); + } + } + + field->childObjects(&children); + } + + for (const auto& child : children) + { + fieldsByType(child, typedFields); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(RimRelocatePathTest, findPathsInProjectFile) +{ + QString fileName = QString("%1/RimRelocatePath/RelocatePath.rsp").arg(TEST_DATA_DIR); + + if (fileName.isEmpty()) return; + + RimProject project; + + project.fileName = fileName; + project.readFile(); + + std::vector< caf::FilePath* > filePaths; + + fieldsByType(&project, filePaths); + + for (auto filePath : filePaths) + { + std::cout << filePath->path().toStdString() << std::endl; + } +} diff --git a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp index 71ef74b9f9..b376a32205 100644 --- a/ApplicationCode/UnitTests/ScalarMapper-Test.cpp +++ b/ApplicationCode/UnitTests/ScalarMapper-Test.cpp @@ -5,6 +5,74 @@ #include #include "RigFemPartResultsCollection.h" +#include "cafTickMarkGenerator.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(ScalarMapperTest, TickMarkGenerator) +{ + EXPECT_EQ(10.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(5.5e6) ); + EXPECT_EQ(5.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(2.1e6) ); + EXPECT_EQ(2.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.1e6) ); + EXPECT_EQ(1.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.0e6) ); + EXPECT_EQ(1.0e6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.9e6) ); + + EXPECT_EQ(50.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(50.0) ); + EXPECT_EQ(50.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(21.00023) ); + EXPECT_EQ(20.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(11.2324556) ); + EXPECT_EQ(10.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(5.5) ); + EXPECT_EQ(5.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(2.1) ); + EXPECT_EQ(2.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.1) ); + EXPECT_EQ(1.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(1.0) ); + EXPECT_EQ(1.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.9) ); + EXPECT_EQ(1.0, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.7) ); + EXPECT_EQ(0.5, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.5) ); + EXPECT_EQ(0.5, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.435) ); + EXPECT_EQ(0.5, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.200001) ); + EXPECT_EQ(0.2, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.20000) ); + EXPECT_EQ(0.2, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.12) ); + EXPECT_EQ(0.1, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.056) ); + + EXPECT_EQ(0.5e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.200001e-6) ); + EXPECT_EQ(0.2e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.20000e-6) ); + EXPECT_EQ(0.2e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.12e-6) ); + EXPECT_EQ(0.1e-6, caf::TickMarkGenerator::roundUpToLog_1_2_5_10(0.056e-6) ); + + { + caf::TickMarkGenerator tickGen(1234.34521, 2346.67293, 104.2768); + + EXPECT_EQ(size_t(5), tickGen.tickMarkValues().size()); + + EXPECT_EQ(1400, tickGen.tickMarkValues()[0]); + EXPECT_EQ(1600, tickGen.tickMarkValues()[1]); + EXPECT_EQ(1800, tickGen.tickMarkValues()[2]); + EXPECT_EQ(2000, tickGen.tickMarkValues()[3]); + EXPECT_EQ(2200, tickGen.tickMarkValues()[4]); + } + { + caf::TickMarkGenerator tickGen(0.02134, 0.17829, 0.03267); + + EXPECT_EQ(size_t(3), tickGen.tickMarkValues().size()); + + EXPECT_NEAR(0.05, tickGen.tickMarkValues()[0], 1e-15); + EXPECT_NEAR(0.1, tickGen.tickMarkValues()[1], 1e-15); + EXPECT_NEAR(0.15, tickGen.tickMarkValues()[2], 1e-15); + } + + { + caf::TickMarkGenerator tickGen(0.02134, 0.0335, 0.001267); + + EXPECT_EQ(size_t(6), tickGen.tickMarkValues().size()); + + EXPECT_EQ(0.022, tickGen.tickMarkValues()[0]); + EXPECT_EQ(0.024, tickGen.tickMarkValues()[1]); + EXPECT_NEAR(0.026, tickGen.tickMarkValues()[2], 1e-15); + EXPECT_EQ(0.028, tickGen.tickMarkValues()[3]); + EXPECT_EQ(0.03, tickGen.tickMarkValues()[4]); + EXPECT_EQ(0.032, tickGen.tickMarkValues()[5]); + } +} //-------------------------------------------------------------------------------------------------- /// @@ -124,7 +192,7 @@ TEST(OffshoreSphericalCoords, OffshoreSphericalCoords) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -TEST(TensorRotation, TensorRotation) +TEST(Tensor, TensorRotation) { { @@ -232,4 +300,32 @@ TEST(TensorRotation, TensorRotation) EXPECT_NEAR(0.0f, rotT[caf::Ten3f::SYZ], 1e-4); } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(Tensor, TensorAddScale) +{ + caf::Ten3f orgT1(1.1f, 1.2f, 1.3f, 1.4f, 1.5f, 1.6f); + caf::Ten3f orgT2(1.6f, 1.5f, 1.4f, 1.3f, 1.2f, 1.1f); + + caf::Ten3f newT = orgT1 + orgT2; + + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SXX], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SYY], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SZZ], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SXY], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SZX], 1e-4); + EXPECT_NEAR(2.7f, newT[caf::Ten3f::SYZ], 1e-4); + + newT = newT*0.5; + + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SXX], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SYY], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SZZ], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SXY], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SZX], 1e-4); + EXPECT_NEAR(1.35f, newT[caf::Ten3f::SYZ], 1e-4); + } \ No newline at end of file diff --git a/ThirdParty/Ert/python/python/legacy/ert/__init__.py b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/1/dummy.txt similarity index 100% rename from ThirdParty/Ert/python/python/legacy/ert/__init__.py rename to ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/1/dummy.txt diff --git a/ThirdParty/Ert/python/tests/cwrap/__init__.py b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/dummy.txt similarity index 100% rename from ThirdParty/Ert/python/tests/cwrap/__init__.py rename to ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/2/dummy.txt diff --git a/ThirdParty/Ert/python/tests/ecl/__init__.py b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/dummy.txt similarity index 100% rename from ThirdParty/Ert/python/tests/ecl/__init__.py rename to ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/3/dummy.txt diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt new file mode 100644 index 0000000000..a98fe50a12 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters.txt @@ -0,0 +1,30 @@ +LETSWOF:L_1OW 1.83555 +LETSWOF:E_1OW 5.84645 +LETSWOF:T_1OW 1.46894 +LETSWOF:L_1WO 4.9974 +LETSWOF:E_1WO 1.59008 +LETSWOF:T_1WO 0.762342 +LETSWOF:SORW1 0.13 +LETSWOF:KRW1 0.778509 +MULTFLT:MULTFLT_F1 0.678647 +LOG10_MULTFLT:MULTFLT_F1 -0.168356 +MULTFLT:MULTFLT_F2 0.0051102 +LOG10_MULTFLT:MULTFLT_F2 -2.29156 +MULTFLT:MULTFLT_F3 0.347461 +LOG10_MULTFLT:MULTFLT_F3 -0.459093 +MULTFLT:MULTFLT_F4 0.113 +LOG10_MULTFLT:MULTFLT_F4 -0.946922 +MULTFLT:MULTFLT_F5 0.521999 +LOG10_MULTFLT:MULTFLT_F5 -0.28233 +RMSGLOBPARAMS:FWL 1708.62 +MULTZ:MULTZ_MIDREEK 3.38433e-05 +LOG10_MULTZ:MULTZ_MIDREEK -4.47053 +LETSGOF:L_1GO 2.04966 +LETSGOF:E_1GO 1.85285 +LETSGOF:T_1GO 1.39467 +LETSGOF:L_1OG 3.90509 +LETSGOF:E_1OG 4.00383 +LETSGOF:T_1OG 1.03539 +LETSGOF:SORG1 0.34 +TST:TEXT_PARAM YES +LETSGOF:KRG1 0.97 diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_format.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_format.txt new file mode 100644 index 0000000000..996f838a12 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_format.txt @@ -0,0 +1,29 @@ +LETSWOF:L_1OW 1.83555 +LETSWOF:E_1OW 5.84645 +LETSWOF:T_1OW 1.46894 +LETSWOF:L_1WO 4.9974 +LETSWOF:E_1WO 1.59008 +LETSWOF:T_1WO 0.762342 +LETSWOF:SORW1 0.13 +LETSWOF:KRW1 0.778509 +MULTFLT:MULTFLT_F1 0.678647 +LOG10_MULTFLT:MULTFLT_F1 -0.168356 ERROR +MULTFLT:MULTFLT_F2 0.0051102 +LOG10_MULTFLT:MULTFLT_F2 -2.29156 +MULTFLT:MULTFLT_F3 0.347461 +LOG10_MULTFLT:MULTFLT_F3 -0.459093 +MULTFLT:MULTFLT_F4 0.113 +LOG10_MULTFLT:MULTFLT_F4 -0.946922 +MULTFLT:MULTFLT_F5 0.521999 +LOG10_MULTFLT:MULTFLT_F5 -0.28233 +RMSGLOBPARAMS:FWL 1708.62 +MULTZ:MULTZ_MIDREEK 3.38433e-05 +LOG10_MULTZ:MULTZ_MIDREEK -4.47053 +LETSGOF:L_1GO 2.04966 +LETSGOF:E_1GO 1.85285 +LETSGOF:T_1GO 1.39467 +LETSGOF:L_1OG 3.90509 +LETSGOF:E_1OG 4.00383 +LETSGOF:T_1OG 1.03539 +LETSGOF:SORG1 0.34 +LETSGOF:KRG1 0.97 diff --git a/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_number_format.txt b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_number_format.txt new file mode 100644 index 0000000000..b171f7ece5 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifCaseRealizationParametersReader/parameters_invalid_number_format.txt @@ -0,0 +1,29 @@ +LETSWOF:L_1OW 1.83555 +LETSWOF:E_1OW 5.84645 +LETSWOF:T_1OW 1.46894 +LETSWOF:L_1WO 4.9974 +LETSWOF:E_1WO 1.59008 +LETSWOF:T_1WO 0.762342 +LETSWOF:SORW1 0.13 +LETSWOF:KRW1 0.778509 +MULTFLT:MULTFLT_F1 0.678647 +LOG10_MULTFLT:MULTFLT_F1 -0.16ERROR8356 +MULTFLT:MULTFLT_F2 0.0051102 +LOG10_MULTFLT:MULTFLT_F2 -2.29156 +MULTFLT:MULTFLT_F3 0.347461 +LOG10_MULTFLT:MULTFLT_F3 -0.459093 +MULTFLT:MULTFLT_F4 0.113 +LOG10_MULTFLT:MULTFLT_F4 -0.946922 +MULTFLT:MULTFLT_F5 0.521999 +LOG10_MULTFLT:MULTFLT_F5 -0.28233 +RMSGLOBPARAMS:FWL 1708.62 +MULTZ:MULTZ_MIDREEK 3.38433e-05 +LOG10_MULTZ:MULTZ_MIDREEK -4.47053 +LETSGOF:L_1GO 2.04966 +LETSGOF:E_1GO 1.85285 +LETSGOF:T_1GO 1.39467 +LETSGOF:L_1OG 3.90509 +LETSGOF:E_1OG 4.00383 +LETSGOF:T_1OG 1.03539 +LETSGOF:SORG1 0.34 +LETSGOF:KRG1 0.97 diff --git a/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE.inp b/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE.inp new file mode 100644 index 0000000000..7d6600ed43 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE.inp @@ -0,0 +1,4326 @@ +** ELASTIC SETTING FOR EACH ELEMENT +*Distribution Table, name=RSV_Res-1_Elastic_Table +MODULUS, RATIO +*Distribution, name=RSV_Res-1_ELASTICS, location=ELEMENT, Table=RSV_Res-1_Elastic_Table +** Description: Element-by-Element Elastic properties +, 2. +Res-1.210, 11198814808.2538, 0.19041 +Res-1.209, 11207002032.1436, 0.19063 +Res-1.208, 11222989223.0933, 0.19104 +Res-1.207, 11202549454.349, 0.19051 +Res-1.206, 11201018277.2135, 0.19047 +Res-1.205, 11199452457.2289, 0.19043 +Res-1.204, 11211165066.8084, 0.19073 +Res-1.203, 11211396173.5037, 0.19074 +Res-1.202, 11222952734.6236, 0.19104 +Res-1.201, 11212868930.9558, 0.19078 +Res-1.200, 11211827541.4726, 0.19075 +Res-1.199, 11223293389.2923, 0.19105 +Res-1.198, 11213461278.5775, 0.19079 +Res-1.197, 11212227164.9418, 0.19076 +Res-1.196, 11222290540.4229, 0.19102 +Res-1.195, 11209591214.3024, 0.19069 +Res-1.194, 11227448401.9317, 0.19116 +Res-1.193, 11218701110.7378, 0.19093 +Res-1.192, 11212290325.2544, 0.19076 +Res-1.191, 11218462357.8173, 0.19092 +Res-1.190, 11210219341.6298, 0.19071 +Res-1.189, 11217410056.2303, 0.1909 +Res-1.188, 11224201059.3023, 0.19107 +Res-1.187, 11200886151.7449, 0.19047 +Res-1.186, 11209070545.6809, 0.19068 +Res-1.185, 11208525302.8397, 0.19067 +Res-1.184, 11208029443.911, 0.19065 +Res-1.183, 11205956268.7052, 0.1906 +Res-1.182, 11203032646.1219, 0.19052 +Res-1.181, 11212779732.2076, 0.19078 +Res-1.180, 11223694446.8691, 0.19106 +Res-1.179, 11216849610.9899, 0.19088 +Res-1.178, 11203666189.6647, 0.19054 +Res-1.177, 11223110950.263, 0.19104 +Res-1.176, 11218366316.8438, 0.19092 +Res-1.175, 11199308629.4248, 0.19043 +Res-1.174, 11204107404.8935, 0.19055 +Res-1.173, 11221591221.1029, 0.191 +Res-1.172, 11198310779.2562, 0.1904 +Res-1.171, 11226329567.8196, 0.19113 +Res-1.170, 11215508691.1034, 0.19085 +Res-1.169, 11216141613.3394, 0.19086 +Res-1.168, 11216262209.1321, 0.19087 +Res-1.167, 11224888572.4446, 0.19109 +Res-1.166, 11215543405.3856, 0.19085 +Res-1.165, 11209879234.5934, 0.1907 +Res-1.164, 11198661683.8392, 0.19041 +Res-1.163, 11221659419.8899, 0.19101 +Res-1.162, 11217644939.1724, 0.1909 +Res-1.161, 11220272938.4351, 0.19097 +Res-1.160, 11219517563.9646, 0.19095 +Res-1.159, 11222601901.6144, 0.19103 +Res-1.158, 11227551848.7474, 0.19116 +Res-1.157, 11214792538.2525, 0.19083 +Res-1.156, 11220949297.0432, 0.19099 +Res-1.155, 11202237002.5308, 0.1905 +Res-1.154, 11212422032.9539, 0.19077 +Res-1.153, 11200876863.9619, 0.19047 +Res-1.152, 11199085093.8181, 0.19042 +Res-1.151, 11210721102.6531, 0.19072 +Res-1.150, 11224677747.0098, 0.19108 +Res-1.149, 11200505347.0814, 0.19046 +Res-1.148, 11210477709.1165, 0.19072 +Res-1.147, 11201790929.0597, 0.19049 +Res-1.146, 11215538617.2144, 0.19085 +Res-1.145, 11210067552.0255, 0.19071 +Res-1.144, 11226119663.3263, 0.19112 +Res-1.143, 11200558079.1704, 0.19046 +Res-1.142, 11209025034.8169, 0.19068 +Res-1.141, 11225111056.7698, 0.1911 +Res-1.140, 11207283822.5306, 0.19063 +Res-1.139, 11216396568.854, 0.19087 +Res-1.138, 11225696853.721, 0.19111 +Res-1.137, 11221821540.0987, 0.19101 +Res-1.136, 11220794943.2728, 0.19098 +Res-1.135, 11221457514.5243, 0.191 +Res-1.134, 11207200873.1928, 0.19063 +Res-1.133, 11205669058.0237, 0.19059 +Res-1.132, 11211863163.8498, 0.19075 +Res-1.131, 11211677567.1763, 0.19075 +Res-1.130, 11209369356.3868, 0.19069 +Res-1.129, 11198739894.387, 0.19041 +Res-1.128, 11209258875.0902, 0.19068 +Res-1.127, 11210271135.3011, 0.19071 +Res-1.126, 11201024868.4708, 0.19047 +Res-1.125, 11211157882.0769, 0.19073 +Res-1.124, 11218203554.1602, 0.19092 +Res-1.123, 11199588193.2274, 0.19043 +Res-1.122, 11215076550.207, 0.19084 +Res-1.121, 11210238801.7044, 0.19071 +Res-1.120, 11206683700.3163, 0.19062 +Res-1.119, 11207926137.5337, 0.19065 +Res-1.118, 11221872987.408, 0.19101 +Res-1.117, 11225794932.4499, 0.19111 +Res-1.116, 11220026437.0079, 0.19096 +Res-1.115, 11202273250.9302, 0.1905 +Res-1.114, 11211501846.5387, 0.19074 +Res-1.113, 11214337327.7756, 0.19082 +Res-1.112, 11215364146.9954, 0.19084 +Res-1.111, 11205074849.7447, 0.19058 +Res-1.110, 11208670822.9857, 0.19067 +Res-1.109, 11208556443.0933, 0.19067 +Res-1.108, 11223420197.8288, 0.19105 +Res-1.107, 11215302199.0174, 0.19084 +Res-1.106, 11213126346.6531, 0.19078 +Res-1.105, 11217009099.524, 0.19089 +Res-1.104, 11213865938.8012, 0.1908 +Res-1.103, 11217994113.817, 0.19091 +Res-1.102, 11204980205.137, 0.19057 +Res-1.101, 11216751463.2051, 0.19088 +Res-1.100, 11206944834.8203, 0.19062 +Res-1.99, 11213849177.9825, 0.1908 +Res-1.98, 11206416870.416, 0.19061 +Res-1.97, 11200174867.7047, 0.19045 +Res-1.96, 11212761772.6524, 0.19078 +Res-1.95, 11201207924.2968, 0.19048 +Res-1.94, 11221710568.74, 0.19101 +Res-1.93, 11202102792.6819, 0.1905 +Res-1.92, 11225762937.338, 0.19111 +Res-1.91, 11214313983.2092, 0.19082 +Res-1.90, 11227579653.6727, 0.19116 +Res-1.89, 11204048097.8306, 0.19055 +Res-1.88, 11222876467.402, 0.19104 +Res-1.87, 11223289800.353, 0.19105 +Res-1.86, 11222804686.0695, 0.19104 +Res-1.85, 11207547340.3029, 0.19064 +Res-1.84, 11221843076.207, 0.19101 +Res-1.83, 11219320112.1476, 0.19095 +Res-1.82, 11205244070.1516, 0.19058 +Res-1.81, 11213243977.9053, 0.19079 +Res-1.80, 11201016479.5973, 0.19047 +Res-1.79, 11226505681.5926, 0.19113 +Res-1.78, 11215171119.692, 0.19084 +Res-1.77, 11211115372.3329, 0.19073 +Res-1.76, 11211330613.8706, 0.19074 +Res-1.75, 11203582318.1003, 0.19054 +Res-1.74, 11224464824.7228, 0.19108 +Res-1.73, 11219259679.3117, 0.19094 +Res-1.72, 11228171914.0288, 0.19117 +Res-1.71, 11199769172.3056, 0.19044 +Res-1.70, 11205305168.6479, 0.19058 +Res-1.69, 11205754113.792, 0.19059 +Res-1.68, 11224082931.2902, 0.19107 +Res-1.67, 11217787662.1013, 0.19091 +Res-1.66, 11223709998.4367, 0.19106 +Res-1.65, 11213376573.6608, 0.19079 +Res-1.64, 11204036715.6354, 0.19055 +Res-1.63, 11209300792.2263, 0.19069 +Res-1.62, 11207638372.4461, 0.19064 +Res-1.61, 11209100486.9499, 0.19068 +Res-1.60, 11206412378.2822, 0.19061 +Res-1.59, 11202503021.4388, 0.19051 +Res-1.58, 11209477740.8993, 0.19069 +Res-1.57, 11222835193.1853, 0.19104 +Res-1.56, 11211083938.9801, 0.19073 +Res-1.55, 11223344531.5666, 0.19105 +Res-1.54, 11201118643.7157, 0.19047 +Res-1.53, 11225922912.0918, 0.19112 +Res-1.52, 11218110503.2337, 0.19091 +Res-1.51, 11210865400.1882, 0.19073 +Res-1.50, 11214019778.1402, 0.19081 +Res-1.49, 11204136459.2628, 0.19055 +Res-1.48, 11212356777.9461, 0.19076 +Res-1.47, 11221437772.4942, 0.191 +Res-1.46, 11207006823.5308, 0.19063 +Res-1.45, 11223791045.7213, 0.19106 +Res-1.44, 11208544765.5071, 0.19067 +Res-1.43, 11209267557.9369, 0.19068 +Res-1.42, 11221377947.9732, 0.191 +Res-1.41, 11222786142.4926, 0.19104 +Res-1.40, 11223261088.8025, 0.19105 +Res-1.39, 11223761737.1688, 0.19106 +Res-1.38, 11222172394.6506, 0.19102 +Res-1.37, 11199653513.7877, 0.19044 +Res-1.36, 11227759636.7716, 0.19116 +Res-1.35, 11199577106.677, 0.19043 +Res-1.34, 11227466938.7063, 0.19116 +Res-1.33, 11199169594.335, 0.19042 +Res-1.32, 11219335070.7259, 0.19095 +Res-1.31, 11212527697.4628, 0.19077 +Res-1.30, 11202428428.8604, 0.19051 +Res-1.29, 11201408054.3293, 0.19048 +Res-1.28, 11222583357.7417, 0.19103 +Res-1.27, 11208466914.6587, 0.19066 +Res-1.26, 11200064606.1293, 0.19045 +Res-1.25, 11199032055.973, 0.19042 +Res-1.24, 11225007889.1195, 0.19109 +Res-1.23, 11222886038.2157, 0.19104 +Res-1.22, 11205896670.776, 0.1906 +Res-1.21, 11226756542.3277, 0.19114 +Res-1.20, 11226104114.7074, 0.19112 +Res-1.19, 11213604048.4849, 0.1908 +Res-1.18, 11202801387.3778, 0.19052 +Res-1.17, 11198392587.9363, 0.1904 +Res-1.16, 11228104049.1491, 0.19117 +Res-1.15, 11212003257.6089, 0.19076 +Res-1.14, 11202458086.203, 0.19051 +Res-1.13, 11201026366.4833, 0.19047 +Res-1.12, 11202937387.2003, 0.19052 +Res-1.11, 11201932931.3114, 0.19049 +Res-1.10, 11205907751.8191, 0.1906 +Res-1.9, 11224722304.7336, 0.19109 +Res-1.8, 11213008714.3126, 0.19078 +Res-1.7, 11223186617.916, 0.19105 +Res-1.6, 11203363650.3495, 0.19053 +Res-1.5, 11200461004.0192, 0.19046 +Res-1.4, 11223167476.7341, 0.19105 +Res-1.3, 11201787633.63, 0.19049 +Res-1.2, 11216634163.6389, 0.19088 +Res-1.1, 11216793056.4137, 0.19088 +Res-1.211, 10072000000, 0.25 +Res-1.212, 10072000000, 0.25 +Res-1.213, 10072000000, 0.25 +Res-1.214, 10072000000, 0.25 +Res-1.215, 10072000000, 0.25 +Res-1.216, 10072000000, 0.25 +Res-1.217, 10216000000, 0.25 +Res-1.218, 10216000000, 0.25 +Res-1.219, 10216000000, 0.25 +Res-1.220, 10216000000, 0.25 +Res-1.221, 10216000000, 0.25 +Res-1.222, 10216000000, 0.25 +Res-1.223, 10360000000, 0.25 +Res-1.224, 10360000000, 0.25 +Res-1.225, 10360000000, 0.25 +Res-1.226, 10360000000, 0.25 +Res-1.227, 10360000000, 0.25 +Res-1.228, 10360000000, 0.25 +Res-1.229, 10504000000, 0.25 +Res-1.230, 10504000000, 0.25 +Res-1.231, 10504000000, 0.25 +Res-1.232, 10504000000, 0.25 +Res-1.233, 10504000000, 0.25 +Res-1.234, 10504000000, 0.25 +Res-1.235, 10648000000, 0.25 +Res-1.236, 10648000000, 0.25 +Res-1.237, 10648000000, 0.25 +Res-1.238, 10648000000, 0.25 +Res-1.239, 10648000000, 0.25 +Res-1.240, 10648000000, 0.25 +Res-1.241, 10072000000, 0.25 +Res-1.242, 10072000000, 0.25 +Res-1.243, 10072000000, 0.25 +Res-1.244, 10072000000, 0.25 +Res-1.245, 10072000000, 0.25 +Res-1.246, 10072000000, 0.25 +Res-1.247, 10072000000, 0.25 +Res-1.248, 10216000000, 0.25 +Res-1.249, 10216000000, 0.25 +Res-1.250, 10216000000, 0.25 +Res-1.251, 10216000000, 0.25 +Res-1.252, 10216000000, 0.25 +Res-1.253, 10216000000, 0.25 +Res-1.254, 10216000000, 0.25 +Res-1.255, 10360000000, 0.25 +Res-1.256, 10360000000, 0.25 +Res-1.257, 10360000000, 0.25 +Res-1.258, 10360000000, 0.25 +Res-1.259, 10360000000, 0.25 +Res-1.260, 10360000000, 0.25 +Res-1.261, 10360000000, 0.25 +Res-1.262, 10504000000, 0.25 +Res-1.263, 10504000000, 0.25 +Res-1.264, 10504000000, 0.25 +Res-1.265, 10504000000, 0.25 +Res-1.266, 10504000000, 0.25 +Res-1.267, 10504000000, 0.25 +Res-1.268, 10504000000, 0.25 +Res-1.269, 10648000000, 0.25 +Res-1.270, 10648000000, 0.25 +Res-1.271, 10648000000, 0.25 +Res-1.272, 10648000000, 0.25 +Res-1.273, 10648000000, 0.25 +Res-1.274, 10648000000, 0.25 +Res-1.275, 10648000000, 0.25 +Res-1.276, 10072000000, 0.25 +Res-1.277, 10216000000, 0.25 +Res-1.278, 10360000000, 0.25 +Res-1.279, 10504000000, 0.25 +Res-1.280, 10648000000, 0.25 +Res-1.281, 10072000000, 0.25 +Res-1.282, 10072000000, 0.25 +Res-1.283, 10072000000, 0.25 +Res-1.284, 10072000000, 0.25 +Res-1.285, 10072000000, 0.25 +Res-1.286, 10072000000, 0.25 +Res-1.287, 10072000000, 0.25 +Res-1.288, 10216000000, 0.25 +Res-1.289, 10216000000, 0.25 +Res-1.290, 10216000000, 0.25 +Res-1.291, 10216000000, 0.25 +Res-1.292, 10216000000, 0.25 +Res-1.293, 10216000000, 0.25 +Res-1.294, 10216000000, 0.25 +Res-1.295, 10360000000, 0.25 +Res-1.296, 10360000000, 0.25 +Res-1.297, 10360000000, 0.25 +Res-1.298, 10360000000, 0.25 +Res-1.299, 10360000000, 0.25 +Res-1.300, 10360000000, 0.25 +Res-1.301, 10360000000, 0.25 +Res-1.302, 10504000000, 0.25 +Res-1.303, 10504000000, 0.25 +Res-1.304, 10504000000, 0.25 +Res-1.305, 10504000000, 0.25 +Res-1.306, 10504000000, 0.25 +Res-1.307, 10504000000, 0.25 +Res-1.308, 10504000000, 0.25 +Res-1.309, 10648000000, 0.25 +Res-1.310, 10648000000, 0.25 +Res-1.311, 10648000000, 0.25 +Res-1.312, 10648000000, 0.25 +Res-1.313, 10648000000, 0.25 +Res-1.314, 10648000000, 0.25 +Res-1.315, 10648000000, 0.25 +Res-1.316, 10072000000, 0.25 +Res-1.317, 10216000000, 0.25 +Res-1.318, 10360000000, 0.25 +Res-1.319, 10504000000, 0.25 +Res-1.320, 10648000000, 0.25 +Res-1.321, 10072000000, 0.25 +Res-1.322, 10072000000, 0.25 +Res-1.323, 10072000000, 0.25 +Res-1.324, 10072000000, 0.25 +Res-1.325, 10072000000, 0.25 +Res-1.326, 10072000000, 0.25 +Res-1.327, 10072000000, 0.25 +Res-1.328, 10216000000, 0.25 +Res-1.329, 10216000000, 0.25 +Res-1.330, 10216000000, 0.25 +Res-1.331, 10216000000, 0.25 +Res-1.332, 10216000000, 0.25 +Res-1.333, 10216000000, 0.25 +Res-1.334, 10216000000, 0.25 +Res-1.335, 10360000000, 0.25 +Res-1.336, 10360000000, 0.25 +Res-1.337, 10360000000, 0.25 +Res-1.338, 10360000000, 0.25 +Res-1.339, 10360000000, 0.25 +Res-1.340, 10360000000, 0.25 +Res-1.341, 10360000000, 0.25 +Res-1.342, 10504000000, 0.25 +Res-1.343, 10504000000, 0.25 +Res-1.344, 10504000000, 0.25 +Res-1.345, 10504000000, 0.25 +Res-1.346, 10504000000, 0.25 +Res-1.347, 10504000000, 0.25 +Res-1.348, 10504000000, 0.25 +Res-1.349, 10648000000, 0.25 +Res-1.350, 10648000000, 0.25 +Res-1.351, 10648000000, 0.25 +Res-1.352, 10648000000, 0.25 +Res-1.353, 10648000000, 0.25 +Res-1.354, 10648000000, 0.25 +Res-1.355, 10648000000, 0.25 +Res-1.356, 10072000000, 0.25 +Res-1.357, 10216000000, 0.25 +Res-1.358, 10360000000, 0.25 +Res-1.359, 10504000000, 0.25 +Res-1.360, 10648000000, 0.25 +Res-1.361, 10072000000, 0.25 +Res-1.362, 10072000000, 0.25 +Res-1.363, 10072000000, 0.25 +Res-1.364, 10072000000, 0.25 +Res-1.365, 10072000000, 0.25 +Res-1.366, 10072000000, 0.25 +Res-1.367, 10072000000, 0.25 +Res-1.368, 10216000000, 0.25 +Res-1.369, 10216000000, 0.25 +Res-1.370, 10216000000, 0.25 +Res-1.371, 10216000000, 0.25 +Res-1.372, 10216000000, 0.25 +Res-1.373, 10216000000, 0.25 +Res-1.374, 10216000000, 0.25 +Res-1.375, 10360000000, 0.25 +Res-1.376, 10360000000, 0.25 +Res-1.377, 10360000000, 0.25 +Res-1.378, 10360000000, 0.25 +Res-1.379, 10360000000, 0.25 +Res-1.380, 10360000000, 0.25 +Res-1.381, 10360000000, 0.25 +Res-1.382, 10504000000, 0.25 +Res-1.383, 10504000000, 0.25 +Res-1.384, 10504000000, 0.25 +Res-1.385, 10504000000, 0.25 +Res-1.386, 10504000000, 0.25 +Res-1.387, 10504000000, 0.25 +Res-1.388, 10504000000, 0.25 +Res-1.389, 10648000000, 0.25 +Res-1.390, 10648000000, 0.25 +Res-1.391, 10648000000, 0.25 +Res-1.392, 10648000000, 0.25 +Res-1.393, 10648000000, 0.25 +Res-1.394, 10648000000, 0.25 +Res-1.395, 10648000000, 0.25 +Res-1.396, 10072000000, 0.25 +Res-1.397, 10216000000, 0.25 +Res-1.398, 10360000000, 0.25 +Res-1.399, 10504000000, 0.25 +Res-1.400, 10648000000, 0.25 +Res-1.401, 10072000000, 0.25 +Res-1.402, 10072000000, 0.25 +Res-1.403, 10072000000, 0.25 +Res-1.404, 10072000000, 0.25 +Res-1.405, 10072000000, 0.25 +Res-1.406, 10072000000, 0.25 +Res-1.407, 10072000000, 0.25 +Res-1.408, 10216000000, 0.25 +Res-1.409, 10216000000, 0.25 +Res-1.410, 10216000000, 0.25 +Res-1.411, 10216000000, 0.25 +Res-1.412, 10216000000, 0.25 +Res-1.413, 10216000000, 0.25 +Res-1.414, 10216000000, 0.25 +Res-1.415, 10360000000, 0.25 +Res-1.416, 10360000000, 0.25 +Res-1.417, 10360000000, 0.25 +Res-1.418, 10360000000, 0.25 +Res-1.419, 10360000000, 0.25 +Res-1.420, 10360000000, 0.25 +Res-1.421, 10360000000, 0.25 +Res-1.422, 10504000000, 0.25 +Res-1.423, 10504000000, 0.25 +Res-1.424, 10504000000, 0.25 +Res-1.425, 10504000000, 0.25 +Res-1.426, 10504000000, 0.25 +Res-1.427, 10504000000, 0.25 +Res-1.428, 10504000000, 0.25 +Res-1.429, 10648000000, 0.25 +Res-1.430, 10648000000, 0.25 +Res-1.431, 10648000000, 0.25 +Res-1.432, 10648000000, 0.25 +Res-1.433, 10648000000, 0.25 +Res-1.434, 10648000000, 0.25 +Res-1.435, 10648000000, 0.25 +Res-1.436, 10072000000, 0.25 +Res-1.437, 10216000000, 0.25 +Res-1.438, 10360000000, 0.25 +Res-1.439, 10504000000, 0.25 +Res-1.440, 10648000000, 0.25 +Res-1.441, 10072000000, 0.25 +Res-1.442, 10072000000, 0.25 +Res-1.443, 10072000000, 0.25 +Res-1.444, 10072000000, 0.25 +Res-1.445, 10072000000, 0.25 +Res-1.446, 10072000000, 0.25 +Res-1.447, 10072000000, 0.25 +Res-1.448, 10216000000, 0.25 +Res-1.449, 10216000000, 0.25 +Res-1.450, 10216000000, 0.25 +Res-1.451, 10216000000, 0.25 +Res-1.452, 10216000000, 0.25 +Res-1.453, 10216000000, 0.25 +Res-1.454, 10216000000, 0.25 +Res-1.455, 10360000000, 0.25 +Res-1.456, 10360000000, 0.25 +Res-1.457, 10360000000, 0.25 +Res-1.458, 10360000000, 0.25 +Res-1.459, 10360000000, 0.25 +Res-1.460, 10360000000, 0.25 +Res-1.461, 10360000000, 0.25 +Res-1.462, 10504000000, 0.25 +Res-1.463, 10504000000, 0.25 +Res-1.464, 10504000000, 0.25 +Res-1.465, 10504000000, 0.25 +Res-1.466, 10504000000, 0.25 +Res-1.467, 10504000000, 0.25 +Res-1.468, 10504000000, 0.25 +Res-1.469, 10648000000, 0.25 +Res-1.470, 10648000000, 0.25 +Res-1.471, 10648000000, 0.25 +Res-1.472, 10648000000, 0.25 +Res-1.473, 10648000000, 0.25 +Res-1.474, 10648000000, 0.25 +Res-1.475, 10648000000, 0.25 +Res-1.476, 10072000000, 0.25 +Res-1.477, 10216000000, 0.25 +Res-1.478, 10360000000, 0.25 +Res-1.479, 10504000000, 0.25 +Res-1.480, 10648000000, 0.25 +Res-1.481, 10072000000, 0.25 +Res-1.482, 10072000000, 0.25 +Res-1.483, 10072000000, 0.25 +Res-1.484, 10072000000, 0.25 +Res-1.485, 10072000000, 0.25 +Res-1.486, 10072000000, 0.25 +Res-1.487, 10072000000, 0.25 +Res-1.488, 10216000000, 0.25 +Res-1.489, 10216000000, 0.25 +Res-1.490, 10216000000, 0.25 +Res-1.491, 10216000000, 0.25 +Res-1.492, 10216000000, 0.25 +Res-1.493, 10216000000, 0.25 +Res-1.494, 10216000000, 0.25 +Res-1.495, 10360000000, 0.25 +Res-1.496, 10360000000, 0.25 +Res-1.497, 10360000000, 0.25 +Res-1.498, 10360000000, 0.25 +Res-1.499, 10360000000, 0.25 +Res-1.500, 10360000000, 0.25 +Res-1.501, 10360000000, 0.25 +Res-1.502, 10504000000, 0.25 +Res-1.503, 10504000000, 0.25 +Res-1.504, 10504000000, 0.25 +Res-1.505, 10504000000, 0.25 +Res-1.506, 10504000000, 0.25 +Res-1.507, 10504000000, 0.25 +Res-1.508, 10504000000, 0.25 +Res-1.509, 10648000000, 0.25 +Res-1.510, 10648000000, 0.25 +Res-1.511, 10648000000, 0.25 +Res-1.512, 10648000000, 0.25 +Res-1.513, 10648000000, 0.25 +Res-1.514, 10648000000, 0.25 +Res-1.515, 10648000000, 0.25 +Res-1.516, 10072000000, 0.25 +Res-1.517, 10216000000, 0.25 +Res-1.518, 10360000000, 0.25 +Res-1.519, 10504000000, 0.25 +Res-1.520, 10648000000, 0.25 +Res-1.521, 10072000000, 0.25 +Res-1.522, 10072000000, 0.25 +Res-1.523, 10072000000, 0.25 +Res-1.524, 10072000000, 0.25 +Res-1.525, 10072000000, 0.25 +Res-1.526, 10072000000, 0.25 +Res-1.527, 10072000000, 0.25 +Res-1.528, 10216000000, 0.25 +Res-1.529, 10216000000, 0.25 +Res-1.530, 10216000000, 0.25 +Res-1.531, 10216000000, 0.25 +Res-1.532, 10216000000, 0.25 +Res-1.533, 10216000000, 0.25 +Res-1.534, 10216000000, 0.25 +Res-1.535, 10360000000, 0.25 +Res-1.536, 10360000000, 0.25 +Res-1.537, 10360000000, 0.25 +Res-1.538, 10360000000, 0.25 +Res-1.539, 10360000000, 0.25 +Res-1.540, 10360000000, 0.25 +Res-1.541, 10360000000, 0.25 +Res-1.542, 10504000000, 0.25 +Res-1.543, 10504000000, 0.25 +Res-1.544, 10504000000, 0.25 +Res-1.545, 10504000000, 0.25 +Res-1.546, 10504000000, 0.25 +Res-1.547, 10504000000, 0.25 +Res-1.548, 10504000000, 0.25 +Res-1.549, 10648000000, 0.25 +Res-1.550, 10648000000, 0.25 +Res-1.551, 10648000000, 0.25 +Res-1.552, 10648000000, 0.25 +Res-1.553, 10648000000, 0.25 +Res-1.554, 10648000000, 0.25 +Res-1.555, 10648000000, 0.25 +Res-1.556, 10072000000, 0.25 +Res-1.557, 10216000000, 0.25 +Res-1.558, 10360000000, 0.25 +Res-1.559, 10504000000, 0.25 +Res-1.560, 10648000000, 0.25 +Res-1.561, 10072000000, 0.25 +Res-1.562, 10072000000, 0.25 +Res-1.563, 10072000000, 0.25 +Res-1.564, 10072000000, 0.25 +Res-1.565, 10072000000, 0.25 +Res-1.566, 10072000000, 0.25 +Res-1.567, 10072000000, 0.25 +Res-1.568, 10216000000, 0.25 +Res-1.569, 10216000000, 0.25 +Res-1.570, 10216000000, 0.25 +Res-1.571, 10216000000, 0.25 +Res-1.572, 10216000000, 0.25 +Res-1.573, 10216000000, 0.25 +Res-1.574, 10216000000, 0.25 +Res-1.575, 10360000000, 0.25 +Res-1.576, 10360000000, 0.25 +Res-1.577, 10360000000, 0.25 +Res-1.578, 10360000000, 0.25 +Res-1.579, 10360000000, 0.25 +Res-1.580, 10360000000, 0.25 +Res-1.581, 10360000000, 0.25 +Res-1.582, 10504000000, 0.25 +Res-1.583, 10504000000, 0.25 +Res-1.584, 10504000000, 0.25 +Res-1.585, 10504000000, 0.25 +Res-1.586, 10504000000, 0.25 +Res-1.587, 10504000000, 0.25 +Res-1.588, 10504000000, 0.25 +Res-1.589, 10648000000, 0.25 +Res-1.590, 10648000000, 0.25 +Res-1.591, 10648000000, 0.25 +Res-1.592, 10648000000, 0.25 +Res-1.593, 10648000000, 0.25 +Res-1.594, 10648000000, 0.25 +Res-1.595, 10648000000, 0.25 +Res-1.596, 10072000000, 0.25 +Res-1.597, 10216000000, 0.25 +Res-1.598, 10360000000, 0.25 +Res-1.599, 10504000000, 0.25 +Res-1.600, 10648000000, 0.25 +Res-1.601, 10072000000, 0.25 +Res-1.602, 10072000000, 0.25 +Res-1.603, 10072000000, 0.25 +Res-1.604, 10072000000, 0.25 +Res-1.605, 10072000000, 0.25 +Res-1.606, 10072000000, 0.25 +Res-1.607, 10072000000, 0.25 +Res-1.608, 10216000000, 0.25 +Res-1.609, 10216000000, 0.25 +Res-1.610, 10216000000, 0.25 +Res-1.611, 10216000000, 0.25 +Res-1.612, 10216000000, 0.25 +Res-1.613, 10216000000, 0.25 +Res-1.614, 10216000000, 0.25 +Res-1.615, 10360000000, 0.25 +Res-1.616, 10360000000, 0.25 +Res-1.617, 10360000000, 0.25 +Res-1.618, 10360000000, 0.25 +Res-1.619, 10360000000, 0.25 +Res-1.620, 10360000000, 0.25 +Res-1.621, 10360000000, 0.25 +Res-1.622, 10504000000, 0.25 +Res-1.623, 10504000000, 0.25 +Res-1.624, 10504000000, 0.25 +Res-1.625, 10504000000, 0.25 +Res-1.626, 10504000000, 0.25 +Res-1.627, 10504000000, 0.25 +Res-1.628, 10504000000, 0.25 +Res-1.629, 10648000000, 0.25 +Res-1.630, 10648000000, 0.25 +Res-1.631, 10648000000, 0.25 +Res-1.632, 10648000000, 0.25 +Res-1.633, 10648000000, 0.25 +Res-1.634, 10648000000, 0.25 +Res-1.635, 10648000000, 0.25 +Res-1.636, 10072000000, 0.25 +Res-1.637, 10216000000, 0.25 +Res-1.638, 10360000000, 0.25 +Res-1.639, 10504000000, 0.25 +Res-1.640, 10648000000, 0.25 +Res-1.641, 10072000000, 0.25 +Res-1.642, 10072000000, 0.25 +Res-1.643, 10072000000, 0.25 +Res-1.644, 10072000000, 0.25 +Res-1.645, 10072000000, 0.25 +Res-1.646, 10072000000, 0.25 +Res-1.647, 10216000000, 0.25 +Res-1.648, 10216000000, 0.25 +Res-1.649, 10216000000, 0.25 +Res-1.650, 10216000000, 0.25 +Res-1.651, 10216000000, 0.25 +Res-1.652, 10216000000, 0.25 +Res-1.653, 10360000000, 0.25 +Res-1.654, 10360000000, 0.25 +Res-1.655, 10360000000, 0.25 +Res-1.656, 10360000000, 0.25 +Res-1.657, 10360000000, 0.25 +Res-1.658, 10360000000, 0.25 +Res-1.659, 10504000000, 0.25 +Res-1.660, 10504000000, 0.25 +Res-1.661, 10504000000, 0.25 +Res-1.662, 10504000000, 0.25 +Res-1.663, 10504000000, 0.25 +Res-1.664, 10504000000, 0.25 +Res-1.665, 10648000000, 0.25 +Res-1.666, 10648000000, 0.25 +Res-1.667, 10648000000, 0.25 +Res-1.668, 10648000000, 0.25 +Res-1.669, 10648000000, 0.25 +Res-1.670, 10648000000, 0.25 +Res-1.671, 10072000000, 0.25 +Res-1.672, 10216000000, 0.25 +Res-1.673, 10360000000, 0.25 +Res-1.674, 10504000000, 0.25 +Res-1.675, 10648000000, 0.25 +Res-1.676, 10072000000, 0.25 +Res-1.677, 10216000000, 0.25 +Res-1.678, 10360000000, 0.25 +Res-1.679, 10504000000, 0.25 +Res-1.680, 10648000000, 0.25 +Res-1.681, 10072000000, 0.25 +Res-1.682, 10216000000, 0.25 +Res-1.683, 10360000000, 0.25 +Res-1.684, 10504000000, 0.25 +Res-1.685, 10648000000, 0.25 +Res-1.686, 10072000000, 0.25 +Res-1.687, 10216000000, 0.25 +Res-1.688, 10360000000, 0.25 +Res-1.689, 10504000000, 0.25 +Res-1.690, 10648000000, 0.25 +Res-1.691, 10072000000, 0.25 +Res-1.692, 10216000000, 0.25 +Res-1.693, 10360000000, 0.25 +Res-1.694, 10504000000, 0.25 +Res-1.695, 10648000000, 0.25 +Res-1.696, 10072000000, 0.25 +Res-1.697, 10216000000, 0.25 +Res-1.698, 10360000000, 0.25 +Res-1.699, 10504000000, 0.25 +Res-1.700, 10648000000, 0.25 +Res-1.701, 10072000000, 0.25 +Res-1.702, 10216000000, 0.25 +Res-1.703, 10360000000, 0.25 +Res-1.704, 10504000000, 0.25 +Res-1.705, 10648000000, 0.25 +Res-1.706, 10072000000, 0.25 +Res-1.707, 10216000000, 0.25 +Res-1.708, 10360000000, 0.25 +Res-1.709, 10504000000, 0.25 +Res-1.710, 10648000000, 0.25 +Res-1.711, 10072000000, 0.25 +Res-1.712, 10216000000, 0.25 +Res-1.713, 10360000000, 0.25 +Res-1.714, 10504000000, 0.25 +Res-1.715, 10648000000, 0.25 +Res-1.716, 10072000000, 0.25 +Res-1.717, 10216000000, 0.25 +Res-1.718, 10360000000, 0.25 +Res-1.719, 10504000000, 0.25 +Res-1.720, 10648000000, 0.25 +Res-1.721, 10072000000, 0.25 +Res-1.722, 10072000000, 0.25 +Res-1.723, 10072000000, 0.25 +Res-1.724, 10072000000, 0.25 +Res-1.725, 10072000000, 0.25 +Res-1.726, 10072000000, 0.25 +Res-1.727, 10216000000, 0.25 +Res-1.728, 10216000000, 0.25 +Res-1.729, 10216000000, 0.25 +Res-1.730, 10216000000, 0.25 +Res-1.731, 10216000000, 0.25 +Res-1.732, 10216000000, 0.25 +Res-1.733, 10360000000, 0.25 +Res-1.734, 10360000000, 0.25 +Res-1.735, 10360000000, 0.25 +Res-1.736, 10360000000, 0.25 +Res-1.737, 10360000000, 0.25 +Res-1.738, 10360000000, 0.25 +Res-1.739, 10504000000, 0.25 +Res-1.740, 10504000000, 0.25 +Res-1.741, 10504000000, 0.25 +Res-1.742, 10504000000, 0.25 +Res-1.743, 10504000000, 0.25 +Res-1.744, 10504000000, 0.25 +Res-1.745, 10648000000, 0.25 +Res-1.746, 10648000000, 0.25 +Res-1.747, 10648000000, 0.25 +Res-1.748, 10648000000, 0.25 +Res-1.749, 10648000000, 0.25 +Res-1.750, 10648000000, 0.25 +Res-1.751, 10072000000, 0.25 +Res-1.752, 10216000000, 0.25 +Res-1.753, 10360000000, 0.25 +Res-1.754, 10504000000, 0.25 +Res-1.755, 10648000000, 0.25 +Res-1.756, 10072000000, 0.25 +Res-1.757, 10216000000, 0.25 +Res-1.758, 10360000000, 0.25 +Res-1.759, 10504000000, 0.25 +Res-1.760, 10648000000, 0.25 +Res-1.761, 10072000000, 0.25 +Res-1.762, 10216000000, 0.25 +Res-1.763, 10360000000, 0.25 +Res-1.764, 10504000000, 0.25 +Res-1.765, 10648000000, 0.25 +Res-1.766, 10072000000, 0.25 +Res-1.767, 10216000000, 0.25 +Res-1.768, 10360000000, 0.25 +Res-1.769, 10504000000, 0.25 +Res-1.770, 10648000000, 0.25 +Res-1.771, 10072000000, 0.25 +Res-1.772, 10216000000, 0.25 +Res-1.773, 10360000000, 0.25 +Res-1.774, 10504000000, 0.25 +Res-1.775, 10648000000, 0.25 +Res-1.776, 10072000000, 0.25 +Res-1.777, 10216000000, 0.25 +Res-1.778, 10360000000, 0.25 +Res-1.779, 10504000000, 0.25 +Res-1.780, 10648000000, 0.25 +Res-1.781, 10072000000, 0.25 +Res-1.782, 10216000000, 0.25 +Res-1.783, 10360000000, 0.25 +Res-1.784, 10504000000, 0.25 +Res-1.785, 10648000000, 0.25 +Res-1.786, 10072000000, 0.25 +Res-1.787, 10216000000, 0.25 +Res-1.788, 10360000000, 0.25 +Res-1.789, 10504000000, 0.25 +Res-1.790, 10648000000, 0.25 +Res-1.791, 10072000000, 0.25 +Res-1.792, 10216000000, 0.25 +Res-1.793, 10360000000, 0.25 +Res-1.794, 10504000000, 0.25 +Res-1.795, 10648000000, 0.25 +Res-1.796, 10072000000, 0.25 +Res-1.797, 10216000000, 0.25 +Res-1.798, 10360000000, 0.25 +Res-1.799, 10504000000, 0.25 +Res-1.800, 10648000000, 0.25 +Res-1.801, 10072000000, 0.25 +Res-1.802, 10072000000, 0.25 +Res-1.803, 10072000000, 0.25 +Res-1.804, 10072000000, 0.25 +Res-1.805, 10072000000, 0.25 +Res-1.806, 10072000000, 0.25 +Res-1.807, 10216000000, 0.25 +Res-1.808, 10216000000, 0.25 +Res-1.809, 10216000000, 0.25 +Res-1.810, 10216000000, 0.25 +Res-1.811, 10216000000, 0.25 +Res-1.812, 10216000000, 0.25 +Res-1.813, 10360000000, 0.25 +Res-1.814, 10360000000, 0.25 +Res-1.815, 10360000000, 0.25 +Res-1.816, 10360000000, 0.25 +Res-1.817, 10360000000, 0.25 +Res-1.818, 10360000000, 0.25 +Res-1.819, 10504000000, 0.25 +Res-1.820, 10504000000, 0.25 +Res-1.821, 10504000000, 0.25 +Res-1.822, 10504000000, 0.25 +Res-1.823, 10504000000, 0.25 +Res-1.824, 10504000000, 0.25 +Res-1.825, 10648000000, 0.25 +Res-1.826, 10648000000, 0.25 +Res-1.827, 10648000000, 0.25 +Res-1.828, 10648000000, 0.25 +Res-1.829, 10648000000, 0.25 +Res-1.830, 10648000000, 0.25 +Res-1.831, 10072000000, 0.25 +Res-1.832, 10216000000, 0.25 +Res-1.833, 10360000000, 0.25 +Res-1.834, 10504000000, 0.25 +Res-1.835, 10648000000, 0.25 +Res-1.836, 10072000000, 0.25 +Res-1.837, 10216000000, 0.25 +Res-1.838, 10360000000, 0.25 +Res-1.839, 10504000000, 0.25 +Res-1.840, 10648000000, 0.25 +Res-1.841, 10072000000, 0.25 +Res-1.842, 10216000000, 0.25 +Res-1.843, 10360000000, 0.25 +Res-1.844, 10504000000, 0.25 +Res-1.845, 10648000000, 0.25 +Res-1.846, 10072000000, 0.25 +Res-1.847, 10216000000, 0.25 +Res-1.848, 10360000000, 0.25 +Res-1.849, 10504000000, 0.25 +Res-1.850, 10648000000, 0.25 +Res-1.851, 10072000000, 0.25 +Res-1.852, 10216000000, 0.25 +Res-1.853, 10360000000, 0.25 +Res-1.854, 10504000000, 0.25 +Res-1.855, 10648000000, 0.25 +Res-1.856, 10072000000, 0.25 +Res-1.857, 10216000000, 0.25 +Res-1.858, 10360000000, 0.25 +Res-1.859, 10504000000, 0.25 +Res-1.860, 10648000000, 0.25 +Res-1.861, 10072000000, 0.25 +Res-1.862, 10216000000, 0.25 +Res-1.863, 10360000000, 0.25 +Res-1.864, 10504000000, 0.25 +Res-1.865, 10648000000, 0.25 +Res-1.866, 10072000000, 0.25 +Res-1.867, 10216000000, 0.25 +Res-1.868, 10360000000, 0.25 +Res-1.869, 10504000000, 0.25 +Res-1.870, 10648000000, 0.25 +Res-1.871, 10072000000, 0.25 +Res-1.872, 10216000000, 0.25 +Res-1.873, 10360000000, 0.25 +Res-1.874, 10504000000, 0.25 +Res-1.875, 10648000000, 0.25 +Res-1.876, 10072000000, 0.25 +Res-1.877, 10216000000, 0.25 +Res-1.878, 10360000000, 0.25 +Res-1.879, 10504000000, 0.25 +Res-1.880, 10648000000, 0.25 +Res-1.881, 10072000000, 0.25 +Res-1.882, 10072000000, 0.25 +Res-1.883, 10072000000, 0.25 +Res-1.884, 10072000000, 0.25 +Res-1.885, 10072000000, 0.25 +Res-1.886, 10072000000, 0.25 +Res-1.887, 10216000000, 0.25 +Res-1.888, 10216000000, 0.25 +Res-1.889, 10216000000, 0.25 +Res-1.890, 10216000000, 0.25 +Res-1.891, 10216000000, 0.25 +Res-1.892, 10216000000, 0.25 +Res-1.893, 10360000000, 0.25 +Res-1.894, 10360000000, 0.25 +Res-1.895, 10360000000, 0.25 +Res-1.896, 10360000000, 0.25 +Res-1.897, 10360000000, 0.25 +Res-1.898, 10360000000, 0.25 +Res-1.899, 10504000000, 0.25 +Res-1.900, 10504000000, 0.25 +Res-1.901, 10504000000, 0.25 +Res-1.902, 10504000000, 0.25 +Res-1.903, 10504000000, 0.25 +Res-1.904, 10504000000, 0.25 +Res-1.905, 10648000000, 0.25 +Res-1.906, 10648000000, 0.25 +Res-1.907, 10648000000, 0.25 +Res-1.908, 10648000000, 0.25 +Res-1.909, 10648000000, 0.25 +Res-1.910, 10648000000, 0.25 +Res-1.911, 10072000000, 0.25 +Res-1.912, 10216000000, 0.25 +Res-1.913, 10360000000, 0.25 +Res-1.914, 10504000000, 0.25 +Res-1.915, 10648000000, 0.25 +Res-1.916, 10072000000, 0.25 +Res-1.917, 10216000000, 0.25 +Res-1.918, 10360000000, 0.25 +Res-1.919, 10504000000, 0.25 +Res-1.920, 10648000000, 0.25 +Res-1.921, 10072000000, 0.25 +Res-1.922, 10216000000, 0.25 +Res-1.923, 10360000000, 0.25 +Res-1.924, 10504000000, 0.25 +Res-1.925, 10648000000, 0.25 +Res-1.926, 10072000000, 0.25 +Res-1.927, 10216000000, 0.25 +Res-1.928, 10360000000, 0.25 +Res-1.929, 10504000000, 0.25 +Res-1.930, 10648000000, 0.25 +Res-1.931, 10072000000, 0.25 +Res-1.932, 10216000000, 0.25 +Res-1.933, 10360000000, 0.25 +Res-1.934, 10504000000, 0.25 +Res-1.935, 10648000000, 0.25 +Res-1.936, 10072000000, 0.25 +Res-1.937, 10216000000, 0.25 +Res-1.938, 10360000000, 0.25 +Res-1.939, 10504000000, 0.25 +Res-1.940, 10648000000, 0.25 +Res-1.941, 10072000000, 0.25 +Res-1.942, 10216000000, 0.25 +Res-1.943, 10360000000, 0.25 +Res-1.944, 10504000000, 0.25 +Res-1.945, 10648000000, 0.25 +Res-1.946, 10072000000, 0.25 +Res-1.947, 10216000000, 0.25 +Res-1.948, 10360000000, 0.25 +Res-1.949, 10504000000, 0.25 +Res-1.950, 10648000000, 0.25 +Res-1.951, 10072000000, 0.25 +Res-1.952, 10216000000, 0.25 +Res-1.953, 10360000000, 0.25 +Res-1.954, 10504000000, 0.25 +Res-1.955, 10648000000, 0.25 +Res-1.956, 10072000000, 0.25 +Res-1.957, 10216000000, 0.25 +Res-1.958, 10360000000, 0.25 +Res-1.959, 10504000000, 0.25 +Res-1.960, 10648000000, 0.25 +Res-1.961, 10072000000, 0.25 +Res-1.962, 10072000000, 0.25 +Res-1.963, 10072000000, 0.25 +Res-1.964, 10072000000, 0.25 +Res-1.965, 10072000000, 0.25 +Res-1.966, 10072000000, 0.25 +Res-1.967, 10216000000, 0.25 +Res-1.968, 10216000000, 0.25 +Res-1.969, 10216000000, 0.25 +Res-1.970, 10216000000, 0.25 +Res-1.971, 10216000000, 0.25 +Res-1.972, 10216000000, 0.25 +Res-1.973, 10360000000, 0.25 +Res-1.974, 10360000000, 0.25 +Res-1.975, 10360000000, 0.25 +Res-1.976, 10360000000, 0.25 +Res-1.977, 10360000000, 0.25 +Res-1.978, 10360000000, 0.25 +Res-1.979, 10504000000, 0.25 +Res-1.980, 10504000000, 0.25 +Res-1.981, 10504000000, 0.25 +Res-1.982, 10504000000, 0.25 +Res-1.983, 10504000000, 0.25 +Res-1.984, 10504000000, 0.25 +Res-1.985, 10648000000, 0.25 +Res-1.986, 10648000000, 0.25 +Res-1.987, 10648000000, 0.25 +Res-1.988, 10648000000, 0.25 +Res-1.989, 10648000000, 0.25 +Res-1.990, 10648000000, 0.25 +Res-1.991, 10072000000, 0.25 +Res-1.992, 10216000000, 0.25 +Res-1.993, 10360000000, 0.25 +Res-1.994, 10504000000, 0.25 +Res-1.995, 10648000000, 0.25 +Res-1.996, 10072000000, 0.25 +Res-1.997, 10216000000, 0.25 +Res-1.998, 10360000000, 0.25 +Res-1.999, 10504000000, 0.25 +Res-1.1000, 10648000000, 0.25 +Res-1.1001, 10072000000, 0.25 +Res-1.1002, 10216000000, 0.25 +Res-1.1003, 10360000000, 0.25 +Res-1.1004, 10504000000, 0.25 +Res-1.1005, 10648000000, 0.25 +Res-1.1006, 10072000000, 0.25 +Res-1.1007, 10216000000, 0.25 +Res-1.1008, 10360000000, 0.25 +Res-1.1009, 10504000000, 0.25 +Res-1.1010, 10648000000, 0.25 +Res-1.1011, 10072000000, 0.25 +Res-1.1012, 10216000000, 0.25 +Res-1.1013, 10360000000, 0.25 +Res-1.1014, 10504000000, 0.25 +Res-1.1015, 10648000000, 0.25 +Res-1.1016, 10072000000, 0.25 +Res-1.1017, 10216000000, 0.25 +Res-1.1018, 10360000000, 0.25 +Res-1.1019, 10504000000, 0.25 +Res-1.1020, 10648000000, 0.25 +Res-1.1021, 10072000000, 0.25 +Res-1.1022, 10216000000, 0.25 +Res-1.1023, 10360000000, 0.25 +Res-1.1024, 10504000000, 0.25 +Res-1.1025, 10648000000, 0.25 +Res-1.1026, 10072000000, 0.25 +Res-1.1027, 10216000000, 0.25 +Res-1.1028, 10360000000, 0.25 +Res-1.1029, 10504000000, 0.25 +Res-1.1030, 10648000000, 0.25 +Res-1.1031, 10072000000, 0.25 +Res-1.1032, 10216000000, 0.25 +Res-1.1033, 10360000000, 0.25 +Res-1.1034, 10504000000, 0.25 +Res-1.1035, 10648000000, 0.25 +Res-1.1036, 10072000000, 0.25 +Res-1.1037, 10216000000, 0.25 +Res-1.1038, 10360000000, 0.25 +Res-1.1039, 10504000000, 0.25 +Res-1.1040, 10648000000, 0.25 +Res-1.1041, 10072000000, 0.25 +Res-1.1042, 10072000000, 0.25 +Res-1.1043, 10072000000, 0.25 +Res-1.1044, 10072000000, 0.25 +Res-1.1045, 10072000000, 0.25 +Res-1.1046, 10072000000, 0.25 +Res-1.1047, 10216000000, 0.25 +Res-1.1048, 10216000000, 0.25 +Res-1.1049, 10216000000, 0.25 +Res-1.1050, 10216000000, 0.25 +Res-1.1051, 10216000000, 0.25 +Res-1.1052, 10216000000, 0.25 +Res-1.1053, 10360000000, 0.25 +Res-1.1054, 10360000000, 0.25 +Res-1.1055, 10360000000, 0.25 +Res-1.1056, 10360000000, 0.25 +Res-1.1057, 10360000000, 0.25 +Res-1.1058, 10360000000, 0.25 +Res-1.1059, 10504000000, 0.25 +Res-1.1060, 10504000000, 0.25 +Res-1.1061, 10504000000, 0.25 +Res-1.1062, 10504000000, 0.25 +Res-1.1063, 10504000000, 0.25 +Res-1.1064, 10504000000, 0.25 +Res-1.1065, 10648000000, 0.25 +Res-1.1066, 10648000000, 0.25 +Res-1.1067, 10648000000, 0.25 +Res-1.1068, 10648000000, 0.25 +Res-1.1069, 10648000000, 0.25 +Res-1.1070, 10648000000, 0.25 +Res-1.1071, 10072000000, 0.25 +Res-1.1072, 10216000000, 0.25 +Res-1.1073, 10360000000, 0.25 +Res-1.1074, 10504000000, 0.25 +Res-1.1075, 10648000000, 0.25 +Res-1.1076, 10072000000, 0.25 +Res-1.1077, 10216000000, 0.25 +Res-1.1078, 10360000000, 0.25 +Res-1.1079, 10504000000, 0.25 +Res-1.1080, 10648000000, 0.25 +Res-1.1081, 10072000000, 0.25 +Res-1.1082, 10216000000, 0.25 +Res-1.1083, 10360000000, 0.25 +Res-1.1084, 10504000000, 0.25 +Res-1.1085, 10648000000, 0.25 +Res-1.1086, 10072000000, 0.25 +Res-1.1087, 10216000000, 0.25 +Res-1.1088, 10360000000, 0.25 +Res-1.1089, 10504000000, 0.25 +Res-1.1090, 10648000000, 0.25 +Res-1.1091, 10072000000, 0.25 +Res-1.1092, 10216000000, 0.25 +Res-1.1093, 10360000000, 0.25 +Res-1.1094, 10504000000, 0.25 +Res-1.1095, 10648000000, 0.25 +Res-1.1096, 10072000000, 0.25 +Res-1.1097, 10216000000, 0.25 +Res-1.1098, 10360000000, 0.25 +Res-1.1099, 10504000000, 0.25 +Res-1.1100, 10648000000, 0.25 +Res-1.1101, 10072000000, 0.25 +Res-1.1102, 10216000000, 0.25 +Res-1.1103, 10360000000, 0.25 +Res-1.1104, 10504000000, 0.25 +Res-1.1105, 10648000000, 0.25 +Res-1.1106, 10072000000, 0.25 +Res-1.1107, 10216000000, 0.25 +Res-1.1108, 10360000000, 0.25 +Res-1.1109, 10504000000, 0.25 +Res-1.1110, 10648000000, 0.25 +Res-1.1111, 10072000000, 0.25 +Res-1.1112, 10216000000, 0.25 +Res-1.1113, 10360000000, 0.25 +Res-1.1114, 10504000000, 0.25 +Res-1.1115, 10648000000, 0.25 +Res-1.1116, 10072000000, 0.25 +Res-1.1117, 10216000000, 0.25 +Res-1.1118, 10360000000, 0.25 +Res-1.1119, 10504000000, 0.25 +Res-1.1120, 10648000000, 0.25 +Res-1.1121, 10072000000, 0.25 +Res-1.1122, 10072000000, 0.25 +Res-1.1123, 10072000000, 0.25 +Res-1.1124, 10072000000, 0.25 +Res-1.1125, 10072000000, 0.25 +Res-1.1126, 10072000000, 0.25 +Res-1.1127, 10216000000, 0.25 +Res-1.1128, 10216000000, 0.25 +Res-1.1129, 10216000000, 0.25 +Res-1.1130, 10216000000, 0.25 +Res-1.1131, 10216000000, 0.25 +Res-1.1132, 10216000000, 0.25 +Res-1.1133, 10360000000, 0.25 +Res-1.1134, 10360000000, 0.25 +Res-1.1135, 10360000000, 0.25 +Res-1.1136, 10360000000, 0.25 +Res-1.1137, 10360000000, 0.25 +Res-1.1138, 10360000000, 0.25 +Res-1.1139, 10504000000, 0.25 +Res-1.1140, 10504000000, 0.25 +Res-1.1141, 10504000000, 0.25 +Res-1.1142, 10504000000, 0.25 +Res-1.1143, 10504000000, 0.25 +Res-1.1144, 10504000000, 0.25 +Res-1.1145, 10648000000, 0.25 +Res-1.1146, 10648000000, 0.25 +Res-1.1147, 10648000000, 0.25 +Res-1.1148, 10648000000, 0.25 +Res-1.1149, 10648000000, 0.25 +Res-1.1150, 10648000000, 0.25 +Res-1.1151, 10072000000, 0.25 +Res-1.1152, 10216000000, 0.25 +Res-1.1153, 10360000000, 0.25 +Res-1.1154, 10504000000, 0.25 +Res-1.1155, 10648000000, 0.25 +Res-1.1156, 10072000000, 0.25 +Res-1.1157, 10216000000, 0.25 +Res-1.1158, 10360000000, 0.25 +Res-1.1159, 10504000000, 0.25 +Res-1.1160, 10648000000, 0.25 +Res-1.1161, 10072000000, 0.25 +Res-1.1162, 10216000000, 0.25 +Res-1.1163, 10360000000, 0.25 +Res-1.1164, 10504000000, 0.25 +Res-1.1165, 10648000000, 0.25 +Res-1.1166, 10072000000, 0.25 +Res-1.1167, 10216000000, 0.25 +Res-1.1168, 10360000000, 0.25 +Res-1.1169, 10504000000, 0.25 +Res-1.1170, 10648000000, 0.25 +Res-1.1171, 10072000000, 0.25 +Res-1.1172, 10216000000, 0.25 +Res-1.1173, 10360000000, 0.25 +Res-1.1174, 10504000000, 0.25 +Res-1.1175, 10648000000, 0.25 +Res-1.1176, 10072000000, 0.25 +Res-1.1177, 10216000000, 0.25 +Res-1.1178, 10360000000, 0.25 +Res-1.1179, 10504000000, 0.25 +Res-1.1180, 10648000000, 0.25 +Res-1.1181, 10072000000, 0.25 +Res-1.1182, 10216000000, 0.25 +Res-1.1183, 10360000000, 0.25 +Res-1.1184, 10504000000, 0.25 +Res-1.1185, 10648000000, 0.25 +Res-1.1186, 10072000000, 0.25 +Res-1.1187, 10216000000, 0.25 +Res-1.1188, 10360000000, 0.25 +Res-1.1189, 10504000000, 0.25 +Res-1.1190, 10648000000, 0.25 +Res-1.1191, 10072000000, 0.25 +Res-1.1192, 10216000000, 0.25 +Res-1.1193, 10360000000, 0.25 +Res-1.1194, 10504000000, 0.25 +Res-1.1195, 10648000000, 0.25 +Res-1.1196, 10072000000, 0.25 +Res-1.1197, 10216000000, 0.25 +Res-1.1198, 10360000000, 0.25 +Res-1.1199, 10504000000, 0.25 +Res-1.1200, 10648000000, 0.25 +Res-1.1201, 10072000000, 0.25 +Res-1.1202, 10072000000, 0.25 +Res-1.1203, 10072000000, 0.25 +Res-1.1204, 10072000000, 0.25 +Res-1.1205, 10072000000, 0.25 +Res-1.1206, 10072000000, 0.25 +Res-1.1207, 10216000000, 0.25 +Res-1.1208, 10216000000, 0.25 +Res-1.1209, 10216000000, 0.25 +Res-1.1210, 10216000000, 0.25 +Res-1.1211, 10216000000, 0.25 +Res-1.1212, 10216000000, 0.25 +Res-1.1213, 10360000000, 0.25 +Res-1.1214, 10360000000, 0.25 +Res-1.1215, 10360000000, 0.25 +Res-1.1216, 10360000000, 0.25 +Res-1.1217, 10360000000, 0.25 +Res-1.1218, 10360000000, 0.25 +Res-1.1219, 10504000000, 0.25 +Res-1.1220, 10504000000, 0.25 +Res-1.1221, 10504000000, 0.25 +Res-1.1222, 10504000000, 0.25 +Res-1.1223, 10504000000, 0.25 +Res-1.1224, 10504000000, 0.25 +Res-1.1225, 10648000000, 0.25 +Res-1.1226, 10648000000, 0.25 +Res-1.1227, 10648000000, 0.25 +Res-1.1228, 10648000000, 0.25 +Res-1.1229, 10648000000, 0.25 +Res-1.1230, 10648000000, 0.25 +Res-1.1231, 10072000000, 0.25 +Res-1.1232, 10216000000, 0.25 +Res-1.1233, 10360000000, 0.25 +Res-1.1234, 10504000000, 0.25 +Res-1.1235, 10648000000, 0.25 +Res-1.1236, 10072000000, 0.25 +Res-1.1237, 10216000000, 0.25 +Res-1.1238, 10360000000, 0.25 +Res-1.1239, 10504000000, 0.25 +Res-1.1240, 10648000000, 0.25 +Res-1.1241, 10072000000, 0.25 +Res-1.1242, 10216000000, 0.25 +Res-1.1243, 10360000000, 0.25 +Res-1.1244, 10504000000, 0.25 +Res-1.1245, 10648000000, 0.25 +Res-1.1246, 10072000000, 0.25 +Res-1.1247, 10216000000, 0.25 +Res-1.1248, 10360000000, 0.25 +Res-1.1249, 10504000000, 0.25 +Res-1.1250, 10648000000, 0.25 +Res-1.1251, 10072000000, 0.25 +Res-1.1252, 10216000000, 0.25 +Res-1.1253, 10360000000, 0.25 +Res-1.1254, 10504000000, 0.25 +Res-1.1255, 10648000000, 0.25 +Res-1.1256, 10072000000, 0.25 +Res-1.1257, 10216000000, 0.25 +Res-1.1258, 10360000000, 0.25 +Res-1.1259, 10504000000, 0.25 +Res-1.1260, 10648000000, 0.25 +Res-1.1261, 10072000000, 0.25 +Res-1.1262, 10216000000, 0.25 +Res-1.1263, 10360000000, 0.25 +Res-1.1264, 10504000000, 0.25 +Res-1.1265, 10648000000, 0.25 +Res-1.1266, 10072000000, 0.25 +Res-1.1267, 10216000000, 0.25 +Res-1.1268, 10360000000, 0.25 +Res-1.1269, 10504000000, 0.25 +Res-1.1270, 10648000000, 0.25 +Res-1.1271, 10072000000, 0.25 +Res-1.1272, 10216000000, 0.25 +Res-1.1273, 10360000000, 0.25 +Res-1.1274, 10504000000, 0.25 +Res-1.1275, 10648000000, 0.25 +Res-1.1276, 10072000000, 0.25 +Res-1.1277, 10216000000, 0.25 +Res-1.1278, 10360000000, 0.25 +Res-1.1279, 10504000000, 0.25 +Res-1.1280, 10648000000, 0.25 +Res-1.1281, 10072000000, 0.25 +Res-1.1282, 10072000000, 0.25 +Res-1.1283, 10072000000, 0.25 +Res-1.1284, 10072000000, 0.25 +Res-1.1285, 10072000000, 0.25 +Res-1.1286, 10072000000, 0.25 +Res-1.1287, 10216000000, 0.25 +Res-1.1288, 10216000000, 0.25 +Res-1.1289, 10216000000, 0.25 +Res-1.1290, 10216000000, 0.25 +Res-1.1291, 10216000000, 0.25 +Res-1.1292, 10216000000, 0.25 +Res-1.1293, 10360000000, 0.25 +Res-1.1294, 10360000000, 0.25 +Res-1.1295, 10360000000, 0.25 +Res-1.1296, 10360000000, 0.25 +Res-1.1297, 10360000000, 0.25 +Res-1.1298, 10360000000, 0.25 +Res-1.1299, 10504000000, 0.25 +Res-1.1300, 10504000000, 0.25 +Res-1.1301, 10504000000, 0.25 +Res-1.1302, 10504000000, 0.25 +Res-1.1303, 10504000000, 0.25 +Res-1.1304, 10504000000, 0.25 +Res-1.1305, 10648000000, 0.25 +Res-1.1306, 10648000000, 0.25 +Res-1.1307, 10648000000, 0.25 +Res-1.1308, 10648000000, 0.25 +Res-1.1309, 10648000000, 0.25 +Res-1.1310, 10648000000, 0.25 +Res-1.1311, 10072000000, 0.25 +Res-1.1312, 10216000000, 0.25 +Res-1.1313, 10360000000, 0.25 +Res-1.1314, 10504000000, 0.25 +Res-1.1315, 10648000000, 0.25 +Res-1.1316, 10072000000, 0.25 +Res-1.1317, 10216000000, 0.25 +Res-1.1318, 10360000000, 0.25 +Res-1.1319, 10504000000, 0.25 +Res-1.1320, 10648000000, 0.25 +Res-1.1321, 10072000000, 0.25 +Res-1.1322, 10216000000, 0.25 +Res-1.1323, 10360000000, 0.25 +Res-1.1324, 10504000000, 0.25 +Res-1.1325, 10648000000, 0.25 +Res-1.1326, 10072000000, 0.25 +Res-1.1327, 10216000000, 0.25 +Res-1.1328, 10360000000, 0.25 +Res-1.1329, 10504000000, 0.25 +Res-1.1330, 10648000000, 0.25 +Res-1.1331, 10072000000, 0.25 +Res-1.1332, 10216000000, 0.25 +Res-1.1333, 10360000000, 0.25 +Res-1.1334, 10504000000, 0.25 +Res-1.1335, 10648000000, 0.25 +Res-1.1336, 10072000000, 0.25 +Res-1.1337, 10216000000, 0.25 +Res-1.1338, 10360000000, 0.25 +Res-1.1339, 10504000000, 0.25 +Res-1.1340, 10648000000, 0.25 +Res-1.1341, 10072000000, 0.25 +Res-1.1342, 10216000000, 0.25 +Res-1.1343, 10360000000, 0.25 +Res-1.1344, 10504000000, 0.25 +Res-1.1345, 10648000000, 0.25 +Res-1.1346, 10072000000, 0.25 +Res-1.1347, 10216000000, 0.25 +Res-1.1348, 10360000000, 0.25 +Res-1.1349, 10504000000, 0.25 +Res-1.1350, 10648000000, 0.25 +Res-1.1351, 10072000000, 0.25 +Res-1.1352, 10216000000, 0.25 +Res-1.1353, 10360000000, 0.25 +Res-1.1354, 10504000000, 0.25 +Res-1.1355, 10648000000, 0.25 +Res-1.1356, 10072000000, 0.25 +Res-1.1357, 10216000000, 0.25 +Res-1.1358, 10360000000, 0.25 +Res-1.1359, 10504000000, 0.25 +Res-1.1360, 10648000000, 0.25 +Res-1.1361, 10072000000, 0.25 +Res-1.1362, 10072000000, 0.25 +Res-1.1363, 10072000000, 0.25 +Res-1.1364, 10072000000, 0.25 +Res-1.1365, 10072000000, 0.25 +Res-1.1366, 10072000000, 0.25 +Res-1.1367, 10216000000, 0.25 +Res-1.1368, 10216000000, 0.25 +Res-1.1369, 10216000000, 0.25 +Res-1.1370, 10216000000, 0.25 +Res-1.1371, 10216000000, 0.25 +Res-1.1372, 10216000000, 0.25 +Res-1.1373, 10360000000, 0.25 +Res-1.1374, 10360000000, 0.25 +Res-1.1375, 10360000000, 0.25 +Res-1.1376, 10360000000, 0.25 +Res-1.1377, 10360000000, 0.25 +Res-1.1378, 10360000000, 0.25 +Res-1.1379, 10504000000, 0.25 +Res-1.1380, 10504000000, 0.25 +Res-1.1381, 10504000000, 0.25 +Res-1.1382, 10504000000, 0.25 +Res-1.1383, 10504000000, 0.25 +Res-1.1384, 10504000000, 0.25 +Res-1.1385, 10648000000, 0.25 +Res-1.1386, 10648000000, 0.25 +Res-1.1387, 10648000000, 0.25 +Res-1.1388, 10648000000, 0.25 +Res-1.1389, 10648000000, 0.25 +Res-1.1390, 10648000000, 0.25 +Res-1.1391, 10072000000, 0.25 +Res-1.1392, 10216000000, 0.25 +Res-1.1393, 10360000000, 0.25 +Res-1.1394, 10504000000, 0.25 +Res-1.1395, 10648000000, 0.25 +Res-1.1396, 10072000000, 0.25 +Res-1.1397, 10216000000, 0.25 +Res-1.1398, 10360000000, 0.25 +Res-1.1399, 10504000000, 0.25 +Res-1.1400, 10648000000, 0.25 +Res-1.1401, 10072000000, 0.25 +Res-1.1402, 10216000000, 0.25 +Res-1.1403, 10360000000, 0.25 +Res-1.1404, 10504000000, 0.25 +Res-1.1405, 10648000000, 0.25 +Res-1.1406, 10072000000, 0.25 +Res-1.1407, 10216000000, 0.25 +Res-1.1408, 10360000000, 0.25 +Res-1.1409, 10504000000, 0.25 +Res-1.1410, 10648000000, 0.25 +Res-1.1411, 10072000000, 0.25 +Res-1.1412, 10216000000, 0.25 +Res-1.1413, 10360000000, 0.25 +Res-1.1414, 10504000000, 0.25 +Res-1.1415, 10648000000, 0.25 +Res-1.1416, 10072000000, 0.25 +Res-1.1417, 10216000000, 0.25 +Res-1.1418, 10360000000, 0.25 +Res-1.1419, 10504000000, 0.25 +Res-1.1420, 10648000000, 0.25 +Res-1.1421, 10072000000, 0.25 +Res-1.1422, 10216000000, 0.25 +Res-1.1423, 10360000000, 0.25 +Res-1.1424, 10504000000, 0.25 +Res-1.1425, 10648000000, 0.25 +Res-1.1426, 10072000000, 0.25 +Res-1.1427, 10216000000, 0.25 +Res-1.1428, 10360000000, 0.25 +Res-1.1429, 10504000000, 0.25 +Res-1.1430, 10648000000, 0.25 +Res-1.1431, 10072000000, 0.25 +Res-1.1432, 10216000000, 0.25 +Res-1.1433, 10360000000, 0.25 +Res-1.1434, 10504000000, 0.25 +Res-1.1435, 10648000000, 0.25 +Res-1.1436, 10072000000, 0.25 +Res-1.1437, 10216000000, 0.25 +Res-1.1438, 10360000000, 0.25 +Res-1.1439, 10504000000, 0.25 +Res-1.1440, 10648000000, 0.25 +Res-1.1441, 10478007200, 0.25 +Res-1.1442, 10478007200, 0.25 +Res-1.1443, 10478007200, 0.25 +Res-1.1444, 10478007200, 0.25 +Res-1.1445, 10478007200, 0.25 +Res-1.1446, 10478007200, 0.25 +Res-1.1447, 10478007200, 0.25 +Res-1.1448, 10478007200, 0.25 +Res-1.1449, 10478007200, 0.25 +Res-1.1450, 10478007200, 0.25 +Res-1.1451, 10478007200, 0.25 +Res-1.1452, 10478007200, 0.25 +Res-1.1453, 10478007200, 0.25 +Res-1.1454, 10478007200, 0.25 +Res-1.1455, 10478007200, 0.25 +Res-1.1456, 10478007200, 0.25 +Res-1.1457, 10478007200, 0.25 +Res-1.1458, 10478007200, 0.25 +Res-1.1459, 10478007200, 0.25 +Res-1.1460, 10478007200, 0.25 +Res-1.1461, 10478007200, 0.25 +Res-1.1462, 10478007200, 0.25 +Res-1.1463, 10478007200, 0.25 +Res-1.1464, 10478007200, 0.25 +Res-1.1465, 10478007200, 0.25 +Res-1.1466, 10478007200, 0.25 +Res-1.1467, 10478007200, 0.25 +Res-1.1468, 10478007200, 0.25 +Res-1.1469, 10478007200, 0.25 +Res-1.1470, 10478007200, 0.25 +Res-1.1471, 10478007200, 0.25 +Res-1.1472, 10478007200, 0.25 +Res-1.1473, 10478007200, 0.25 +Res-1.1474, 10478007200, 0.25 +Res-1.1475, 10478007200, 0.25 +Res-1.1476, 10478007200, 0.25 +Res-1.1477, 10478007200, 0.25 +Res-1.1478, 10478007200, 0.25 +Res-1.1479, 10478007200, 0.25 +Res-1.1480, 10478007200, 0.25 +Res-1.1481, 10478007200, 0.25 +Res-1.1482, 10478007200, 0.25 +Res-1.1483, 10478007200, 0.25 +Res-1.1484, 10478007200, 0.25 +Res-1.1485, 10478007200, 0.25 +Res-1.1486, 10478007200, 0.25 +Res-1.1487, 10478007200, 0.25 +Res-1.1488, 10478007200, 0.25 +Res-1.1489, 10478007200, 0.25 +Res-1.1490, 10478007200, 0.25 +Res-1.1491, 10478007200, 0.25 +Res-1.1492, 10478007200, 0.25 +Res-1.1493, 10478007200, 0.25 +Res-1.1494, 10478007200, 0.25 +Res-1.1495, 10478007200, 0.25 +Res-1.1496, 10478007200, 0.25 +Res-1.1497, 10478007200, 0.25 +Res-1.1498, 10478007200, 0.25 +Res-1.1499, 10478007200, 0.25 +Res-1.1500, 10478007200, 0.25 +Res-1.1501, 10478007200, 0.25 +Res-1.1502, 10478007200, 0.25 +Res-1.1503, 10478007200, 0.25 +Res-1.1504, 10478007200, 0.25 +Res-1.1505, 10478007200, 0.25 +Res-1.1506, 10478007200, 0.25 +Res-1.1507, 10478007200, 0.25 +Res-1.1508, 10478007200, 0.25 +Res-1.1509, 10478007200, 0.25 +Res-1.1510, 10478007200, 0.25 +Res-1.1511, 10478007200, 0.25 +Res-1.1512, 10478007200, 0.25 +Res-1.1513, 10478007200, 0.25 +Res-1.1514, 10478007200, 0.25 +Res-1.1515, 10478007200, 0.25 +Res-1.1516, 10478007200, 0.25 +Res-1.1517, 10478007200, 0.25 +Res-1.1518, 10478007200, 0.25 +Res-1.1519, 10478007200, 0.25 +Res-1.1520, 10478007200, 0.25 +Res-1.1521, 10478007200, 0.25 +Res-1.1522, 10478007200, 0.25 +Res-1.1523, 10478007200, 0.25 +Res-1.1524, 10478007200, 0.25 +Res-1.1525, 10478007200, 0.25 +Res-1.1526, 10478007200, 0.25 +Res-1.1527, 10478007200, 0.25 +Res-1.1528, 10478007200, 0.25 +Res-1.1529, 10478007200, 0.25 +Res-1.1530, 10478007200, 0.25 +Res-1.1531, 10478007200, 0.25 +Res-1.1532, 10478007200, 0.25 +Res-1.1533, 10478007200, 0.25 +Res-1.1534, 10478007200, 0.25 +Res-1.1535, 10478007200, 0.25 +Res-1.1536, 10478007200, 0.25 +Res-1.1537, 10478007200, 0.25 +Res-1.1538, 10478007200, 0.25 +Res-1.1539, 10478007200, 0.25 +Res-1.1540, 10478007200, 0.25 +Res-1.1541, 10478007200, 0.25 +Res-1.1542, 10478007200, 0.25 +Res-1.1543, 10478007200, 0.25 +Res-1.1544, 10478007200, 0.25 +Res-1.1545, 10478007200, 0.25 +Res-1.1546, 10478007200, 0.25 +Res-1.1547, 10478007200, 0.25 +Res-1.1548, 10478007200, 0.25 +Res-1.1549, 10478007200, 0.25 +Res-1.1550, 10478007200, 0.25 +Res-1.1551, 10478007200, 0.25 +Res-1.1552, 10478007200, 0.25 +Res-1.1553, 10478007200, 0.25 +Res-1.1554, 10478007200, 0.25 +Res-1.1555, 10478007200, 0.25 +Res-1.1556, 10478007200, 0.25 +Res-1.1557, 10478007200, 0.25 +Res-1.1558, 10478007200, 0.25 +Res-1.1559, 10478007200, 0.25 +Res-1.1560, 10478007200, 0.25 +Res-1.1561, 10478007200, 0.25 +Res-1.1562, 10478007200, 0.25 +Res-1.1563, 10478007200, 0.25 +Res-1.1564, 10478007200, 0.25 +Res-1.1565, 10478007200, 0.25 +Res-1.1566, 10478007200, 0.25 +Res-1.1567, 10478007200, 0.25 +Res-1.1568, 10478007200, 0.25 +Res-1.1569, 10478007200, 0.25 +Res-1.1570, 10478007200, 0.25 +Res-1.1571, 10478007200, 0.25 +Res-1.1572, 10478007200, 0.25 +Res-1.1573, 10478007200, 0.25 +Res-1.1574, 10478007200, 0.25 +Res-1.1575, 10478007200, 0.25 +Res-1.1576, 10478007200, 0.25 +Res-1.1577, 10478007200, 0.25 +Res-1.1578, 10478007200, 0.25 +Res-1.1579, 10478007200, 0.25 +Res-1.1580, 10478007200, 0.25 +Res-1.1581, 10478007200, 0.25 +Res-1.1582, 10478007200, 0.25 +Res-1.1583, 10478007200, 0.25 +Res-1.1584, 10478007200, 0.25 +Res-1.1585, 10478007200, 0.25 +Res-1.1586, 10478007200, 0.25 +Res-1.1587, 10478007200, 0.25 +Res-1.1588, 10478007200, 0.25 +Res-1.1589, 10478007200, 0.25 +Res-1.1590, 10478007200, 0.25 +Res-1.1591, 10478007200, 0.25 +Res-1.1592, 10478007200, 0.25 +Res-1.1593, 10478007200, 0.25 +Res-1.1594, 10478007200, 0.25 +Res-1.1595, 10478007200, 0.25 +Res-1.1596, 10478007200, 0.25 +Res-1.1597, 10478007200, 0.25 +Res-1.1598, 10478007200, 0.25 +Res-1.1599, 10478007200, 0.25 +Res-1.1600, 10478007200, 0.25 +Res-1.1601, 10478007200, 0.25 +Res-1.1602, 10478007200, 0.25 +Res-1.1603, 10478007200, 0.25 +Res-1.1604, 10478007200, 0.25 +Res-1.1605, 10478007200, 0.25 +Res-1.1606, 10478007200, 0.25 +Res-1.1607, 10478007200, 0.25 +Res-1.1608, 10478007200, 0.25 +Res-1.1609, 10478007200, 0.25 +Res-1.1610, 10478007200, 0.25 +Res-1.1611, 10478007200, 0.25 +Res-1.1612, 10478007200, 0.25 +Res-1.1613, 10478007200, 0.25 +Res-1.1614, 10478007200, 0.25 +Res-1.1615, 10478007200, 0.25 +Res-1.1616, 10478007200, 0.25 +Res-1.1617, 10478007200, 0.25 +Res-1.1618, 10478007200, 0.25 +Res-1.1619, 10478007200, 0.25 +Res-1.1620, 10478007200, 0.25 +Res-1.1621, 10478007200, 0.25 +Res-1.1622, 10478007200, 0.25 +Res-1.1623, 10478007200, 0.25 +Res-1.1624, 10478007200, 0.25 +Res-1.1625, 10478007200, 0.25 +Res-1.1626, 10478007200, 0.25 +Res-1.1627, 10478007200, 0.25 +Res-1.1628, 10478007200, 0.25 +Res-1.1629, 10478007200, 0.25 +Res-1.1630, 10478007200, 0.25 +Res-1.1631, 10478007200, 0.25 +Res-1.1632, 10478007200, 0.25 +Res-1.1633, 10478007200, 0.25 +Res-1.1634, 10478007200, 0.25 +Res-1.1635, 10478007200, 0.25 +Res-1.1636, 10478007200, 0.25 +Res-1.1637, 10478007200, 0.25 +Res-1.1638, 10478007200, 0.25 +Res-1.1639, 10478007200, 0.25 +Res-1.1640, 10478007200, 0.25 +Res-1.1641, 10478007200, 0.25 +Res-1.1642, 10478007200, 0.25 +Res-1.1643, 10478007200, 0.25 +Res-1.1644, 10478007200, 0.25 +Res-1.1645, 10478007200, 0.25 +Res-1.1646, 10478007200, 0.25 +Res-1.1647, 10478007200, 0.25 +Res-1.1648, 10478007200, 0.25 +Res-1.1649, 10478007200, 0.25 +Res-1.1650, 10478007200, 0.25 +Res-1.1651, 10478007200, 0.25 +Res-1.1652, 10478007200, 0.25 +Res-1.1653, 10478007200, 0.25 +Res-1.1654, 10478007200, 0.25 +Res-1.1655, 10478007200, 0.25 +Res-1.1656, 10478007200, 0.25 +Res-1.1657, 10478007200, 0.25 +Res-1.1658, 10478007200, 0.25 +Res-1.1659, 10478007200, 0.25 +Res-1.1660, 10478007200, 0.25 +Res-1.1661, 10478007200, 0.25 +Res-1.1662, 10478007200, 0.25 +Res-1.1663, 10478007200, 0.25 +Res-1.1664, 10478007200, 0.25 +Res-1.1665, 10478007200, 0.25 +Res-1.1666, 10478007200, 0.25 +Res-1.1667, 10478007200, 0.25 +Res-1.1668, 10478007200, 0.25 +Res-1.1669, 10478007200, 0.25 +Res-1.1670, 10478007200, 0.25 +Res-1.1671, 10478007200, 0.25 +Res-1.1672, 10478007200, 0.25 +Res-1.1673, 10478007200, 0.25 +Res-1.1674, 10478007200, 0.25 +Res-1.1675, 10478007200, 0.25 +Res-1.1676, 10478007200, 0.25 +Res-1.1677, 10478007200, 0.25 +Res-1.1678, 10478007200, 0.25 +Res-1.1679, 10478007200, 0.25 +Res-1.1680, 10478007200, 0.25 +Res-1.1681, 10478007200, 0.25 +Res-1.1682, 10478007200, 0.25 +Res-1.1683, 10478007200, 0.25 +Res-1.1684, 10478007200, 0.25 +Res-1.1685, 10478007200, 0.25 +Res-1.1686, 10478007200, 0.25 +Res-1.1687, 10478007200, 0.25 +Res-1.1688, 10478007200, 0.25 +Res-1.1689, 10478007200, 0.25 +Res-1.1690, 10478007200, 0.25 +Res-1.1691, 10478007200, 0.25 +Res-1.1692, 10478007200, 0.25 +Res-1.1693, 10478007200, 0.25 +Res-1.1694, 10478007200, 0.25 +Res-1.1695, 10478007200, 0.25 +Res-1.1696, 10478007200, 0.25 +Res-1.1697, 10478007200, 0.25 +Res-1.1698, 10478007200, 0.25 +Res-1.1699, 10478007200, 0.25 +Res-1.1700, 10478007200, 0.25 +Res-1.1701, 10478007200, 0.25 +Res-1.1702, 10478007200, 0.25 +Res-1.1703, 10478007200, 0.25 +Res-1.1704, 10478007200, 0.25 +Res-1.1705, 10478007200, 0.25 +Res-1.1706, 10478007200, 0.25 +Res-1.1707, 10478007200, 0.25 +Res-1.1708, 10478007200, 0.25 +Res-1.1709, 10478007200, 0.25 +Res-1.1710, 10478007200, 0.25 +Res-1.1711, 10478007200, 0.25 +Res-1.1712, 10478007200, 0.25 +Res-1.1713, 10478007200, 0.25 +Res-1.1714, 10478007200, 0.25 +Res-1.1715, 10478007200, 0.25 +Res-1.1716, 10478007200, 0.25 +Res-1.1717, 10478007200, 0.25 +Res-1.1718, 10478007200, 0.25 +Res-1.1719, 10478007200, 0.25 +Res-1.1720, 10478007200, 0.25 +Res-1.1721, 10478007200, 0.25 +Res-1.1722, 10478007200, 0.25 +Res-1.1723, 10478007200, 0.25 +Res-1.1724, 10478007200, 0.25 +Res-1.1725, 10478007200, 0.25 +Res-1.1726, 10478007200, 0.25 +Res-1.1727, 10478007200, 0.25 +Res-1.1728, 10478007200, 0.25 +Res-1.1729, 11670801700, 0.25 +Res-1.1730, 11670801700, 0.25 +Res-1.1731, 11670801700, 0.25 +Res-1.1732, 11670801700, 0.25 +Res-1.1733, 11670801700, 0.25 +Res-1.1734, 11670801700, 0.25 +Res-1.1735, 11670801700, 0.25 +Res-1.1736, 11670801700, 0.25 +Res-1.1737, 11670801700, 0.25 +Res-1.1738, 11670801700, 0.25 +Res-1.1739, 11670801700, 0.25 +Res-1.1740, 11670801700, 0.25 +Res-1.1741, 11670801700, 0.25 +Res-1.1742, 11670801700, 0.25 +Res-1.1743, 11670801700, 0.25 +Res-1.1744, 11670801700, 0.25 +Res-1.1745, 11670801700, 0.25 +Res-1.1746, 11670801700, 0.25 +Res-1.1747, 11670801700, 0.25 +Res-1.1748, 11670801700, 0.25 +Res-1.1749, 11670801700, 0.25 +Res-1.1750, 11670801700, 0.25 +Res-1.1751, 11670801700, 0.25 +Res-1.1752, 11670801700, 0.25 +Res-1.1753, 11670801700, 0.25 +Res-1.1754, 11670801700, 0.25 +Res-1.1755, 11670801700, 0.25 +Res-1.1756, 11670801700, 0.25 +Res-1.1757, 11670801700, 0.25 +Res-1.1758, 11670801700, 0.25 +Res-1.1759, 11670801700, 0.25 +Res-1.1760, 11670801700, 0.25 +Res-1.1761, 11670801700, 0.25 +Res-1.1762, 11670801700, 0.25 +Res-1.1763, 11670801700, 0.25 +Res-1.1764, 11670801700, 0.25 +Res-1.1765, 11670801700, 0.25 +Res-1.1766, 11670801700, 0.25 +Res-1.1767, 11670801700, 0.25 +Res-1.1768, 11670801700, 0.25 +Res-1.1769, 11670801700, 0.25 +Res-1.1770, 11670801700, 0.25 +Res-1.1771, 11670801700, 0.25 +Res-1.1772, 11670801700, 0.25 +Res-1.1773, 11670801700, 0.25 +Res-1.1774, 11670801700, 0.25 +Res-1.1775, 11670801700, 0.25 +Res-1.1776, 11670801700, 0.25 +Res-1.1777, 11670801700, 0.25 +Res-1.1778, 11670801700, 0.25 +Res-1.1779, 11670801700, 0.25 +Res-1.1780, 11670801700, 0.25 +Res-1.1781, 11670801700, 0.25 +Res-1.1782, 11670801700, 0.25 +Res-1.1783, 11670801700, 0.25 +Res-1.1784, 11670801700, 0.25 +Res-1.1785, 11670801700, 0.25 +Res-1.1786, 11670801700, 0.25 +Res-1.1787, 11670801700, 0.25 +Res-1.1788, 11670801700, 0.25 +Res-1.1789, 11670801700, 0.25 +Res-1.1790, 11670801700, 0.25 +Res-1.1791, 11670801700, 0.25 +Res-1.1792, 11670801700, 0.25 +Res-1.1793, 11670801700, 0.25 +Res-1.1794, 11670801700, 0.25 +Res-1.1795, 11670801700, 0.25 +Res-1.1796, 11670801700, 0.25 +Res-1.1797, 11670801700, 0.25 +Res-1.1798, 11670801700, 0.25 +Res-1.1799, 11670801700, 0.25 +Res-1.1800, 11670801700, 0.25 +Res-1.1801, 11670801700, 0.25 +Res-1.1802, 11670801700, 0.25 +Res-1.1803, 11670801700, 0.25 +Res-1.1804, 11670801700, 0.25 +Res-1.1805, 11670801700, 0.25 +Res-1.1806, 11670801700, 0.25 +Res-1.1807, 11670801700, 0.25 +Res-1.1808, 11670801700, 0.25 +Res-1.1809, 11670801700, 0.25 +Res-1.1810, 11670801700, 0.25 +Res-1.1811, 11670801700, 0.25 +Res-1.1812, 11670801700, 0.25 +Res-1.1813, 11670801700, 0.25 +Res-1.1814, 11670801700, 0.25 +Res-1.1815, 11670801700, 0.25 +Res-1.1816, 11670801700, 0.25 +Res-1.1817, 11670801700, 0.25 +Res-1.1818, 11670801700, 0.25 +Res-1.1819, 11670801700, 0.25 +Res-1.1820, 11670801700, 0.25 +Res-1.1821, 11670801700, 0.25 +Res-1.1822, 11670801700, 0.25 +Res-1.1823, 11670801700, 0.25 +Res-1.1824, 11670801700, 0.25 +Res-1.1825, 11670801700, 0.25 +Res-1.1826, 11670801700, 0.25 +Res-1.1827, 11670801700, 0.25 +Res-1.1828, 11670801700, 0.25 +Res-1.1829, 11670801700, 0.25 +Res-1.1830, 11670801700, 0.25 +Res-1.1831, 11670801700, 0.25 +Res-1.1832, 11670801700, 0.25 +Res-1.1833, 11670801700, 0.25 +Res-1.1834, 11670801700, 0.25 +Res-1.1835, 11670801700, 0.25 +Res-1.1836, 11670801700, 0.25 +Res-1.1837, 11670801700, 0.25 +Res-1.1838, 11670801700, 0.25 +Res-1.1839, 11670801700, 0.25 +Res-1.1840, 11670801700, 0.25 +Res-1.1841, 11670801700, 0.25 +Res-1.1842, 11670801700, 0.25 +Res-1.1843, 11670801700, 0.25 +Res-1.1844, 11670801700, 0.25 +Res-1.1845, 11670801700, 0.25 +Res-1.1846, 11670801700, 0.25 +Res-1.1847, 11670801700, 0.25 +Res-1.1848, 11670801700, 0.25 +Res-1.1849, 11670801700, 0.25 +Res-1.1850, 11670801700, 0.25 +Res-1.1851, 11670801700, 0.25 +Res-1.1852, 11670801700, 0.25 +Res-1.1853, 11670801700, 0.25 +Res-1.1854, 11670801700, 0.25 +Res-1.1855, 11670801700, 0.25 +Res-1.1856, 11670801700, 0.25 +Res-1.1857, 11670801700, 0.25 +Res-1.1858, 11670801700, 0.25 +Res-1.1859, 11670801700, 0.25 +Res-1.1860, 11670801700, 0.25 +Res-1.1861, 11670801700, 0.25 +Res-1.1862, 11670801700, 0.25 +Res-1.1863, 11670801700, 0.25 +Res-1.1864, 11670801700, 0.25 +Res-1.1865, 11670801700, 0.25 +Res-1.1866, 11670801700, 0.25 +Res-1.1867, 11670801700, 0.25 +Res-1.1868, 11670801700, 0.25 +Res-1.1869, 11670801700, 0.25 +Res-1.1870, 11670801700, 0.25 +Res-1.1871, 11670801700, 0.25 +Res-1.1872, 11670801700, 0.25 +Res-1.1873, 11670801700, 0.25 +Res-1.1874, 11670801700, 0.25 +Res-1.1875, 11670801700, 0.25 +Res-1.1876, 11670801700, 0.25 +Res-1.1877, 11670801700, 0.25 +Res-1.1878, 11670801700, 0.25 +Res-1.1879, 11670801700, 0.25 +Res-1.1880, 11670801700, 0.25 +Res-1.1881, 11670801700, 0.25 +Res-1.1882, 11670801700, 0.25 +Res-1.1883, 11670801700, 0.25 +Res-1.1884, 11670801700, 0.25 +Res-1.1885, 11670801700, 0.25 +Res-1.1886, 11670801700, 0.25 +Res-1.1887, 11670801700, 0.25 +Res-1.1888, 11670801700, 0.25 +Res-1.1889, 11670801700, 0.25 +Res-1.1890, 11670801700, 0.25 +Res-1.1891, 11670801700, 0.25 +Res-1.1892, 11670801700, 0.25 +Res-1.1893, 11670801700, 0.25 +Res-1.1894, 11670801700, 0.25 +Res-1.1895, 11670801700, 0.25 +Res-1.1896, 11670801700, 0.25 +Res-1.1897, 11670801700, 0.25 +Res-1.1898, 11670801700, 0.25 +Res-1.1899, 11670801700, 0.25 +Res-1.1900, 11670801700, 0.25 +Res-1.1901, 11670801700, 0.25 +Res-1.1902, 11670801700, 0.25 +Res-1.1903, 11670801700, 0.25 +Res-1.1904, 11670801700, 0.25 +Res-1.1905, 11670801700, 0.25 +Res-1.1906, 11670801700, 0.25 +Res-1.1907, 11670801700, 0.25 +Res-1.1908, 11670801700, 0.25 +Res-1.1909, 11670801700, 0.25 +Res-1.1910, 11670801700, 0.25 +Res-1.1911, 11670801700, 0.25 +Res-1.1912, 11670801700, 0.25 +Res-1.1913, 11670801700, 0.25 +Res-1.1914, 11670801700, 0.25 +Res-1.1915, 11670801700, 0.25 +Res-1.1916, 11670801700, 0.25 +Res-1.1917, 11670801700, 0.25 +Res-1.1918, 11670801700, 0.25 +Res-1.1919, 11670801700, 0.25 +Res-1.1920, 11670801700, 0.25 +Res-1.1921, 11670801700, 0.25 +Res-1.1922, 11670801700, 0.25 +Res-1.1923, 11670801700, 0.25 +Res-1.1924, 11670801700, 0.25 +Res-1.1925, 11670801700, 0.25 +Res-1.1926, 11670801700, 0.25 +Res-1.1927, 11670801700, 0.25 +Res-1.1928, 11670801700, 0.25 +Res-1.1929, 11670801700, 0.25 +Res-1.1930, 11670801700, 0.25 +Res-1.1931, 11670801700, 0.25 +Res-1.1932, 11670801700, 0.25 +Res-1.1933, 11670801700, 0.25 +Res-1.1934, 11670801700, 0.25 +Res-1.1935, 11670801700, 0.25 +Res-1.1936, 11670801700, 0.25 +Res-1.1937, 11670801700, 0.25 +Res-1.1938, 11670801700, 0.25 +Res-1.1939, 11670801700, 0.25 +Res-1.1940, 11670801700, 0.25 +Res-1.1941, 11670801700, 0.25 +Res-1.1942, 11670801700, 0.25 +Res-1.1943, 11670801700, 0.25 +Res-1.1944, 11670801700, 0.25 +Res-1.1945, 11670801700, 0.25 +Res-1.1946, 11670801700, 0.25 +Res-1.1947, 11670801700, 0.25 +Res-1.1948, 11670801700, 0.25 +Res-1.1949, 11670801700, 0.25 +Res-1.1950, 11670801700, 0.25 +Res-1.1951, 11670801700, 0.25 +Res-1.1952, 11670801700, 0.25 +Res-1.1953, 11670801700, 0.25 +Res-1.1954, 11670801700, 0.25 +Res-1.1955, 11670801700, 0.25 +Res-1.1956, 11670801700, 0.25 +Res-1.1957, 11670801700, 0.25 +Res-1.1958, 11670801700, 0.25 +Res-1.1959, 11670801700, 0.25 +Res-1.1960, 11670801700, 0.25 +Res-1.1961, 11670801700, 0.25 +Res-1.1962, 11670801700, 0.25 +Res-1.1963, 11670801700, 0.25 +Res-1.1964, 11670801700, 0.25 +Res-1.1965, 11670801700, 0.25 +Res-1.1966, 11670801700, 0.25 +Res-1.1967, 11670801700, 0.25 +Res-1.1968, 11670801700, 0.25 +Res-1.1969, 11670801700, 0.25 +Res-1.1970, 11670801700, 0.25 +Res-1.1971, 11670801700, 0.25 +Res-1.1972, 11670801700, 0.25 +Res-1.1973, 11670801700, 0.25 +Res-1.1974, 11670801700, 0.25 +Res-1.1975, 11670801700, 0.25 +Res-1.1976, 11670801700, 0.25 +Res-1.1977, 11670801700, 0.25 +Res-1.1978, 11670801700, 0.25 +Res-1.1979, 11670801700, 0.25 +Res-1.1980, 11670801700, 0.25 +Res-1.1981, 11670801700, 0.25 +Res-1.1982, 11670801700, 0.25 +Res-1.1983, 11670801700, 0.25 +Res-1.1984, 11670801700, 0.25 +Res-1.1985, 11670801700, 0.25 +Res-1.1986, 11670801700, 0.25 +Res-1.1987, 11670801700, 0.25 +Res-1.1988, 11670801700, 0.25 +Res-1.1989, 11670801700, 0.25 +Res-1.1990, 11670801700, 0.25 +Res-1.1991, 11670801700, 0.25 +Res-1.1992, 11670801700, 0.25 +Res-1.1993, 11670801700, 0.25 +Res-1.1994, 11670801700, 0.25 +Res-1.1995, 11670801700, 0.25 +Res-1.1996, 11670801700, 0.25 +Res-1.1997, 11670801700, 0.25 +Res-1.1998, 11670801700, 0.25 +Res-1.1999, 11670801700, 0.25 +Res-1.2000, 11670801700, 0.25 +Res-1.2001, 11670801700, 0.25 +Res-1.2002, 11670801700, 0.25 +Res-1.2003, 11670801700, 0.25 +Res-1.2004, 11670801700, 0.25 +Res-1.2005, 11670801700, 0.25 +Res-1.2006, 11670801700, 0.25 +Res-1.2007, 11670801700, 0.25 +Res-1.2008, 11670801700, 0.25 +Res-1.2009, 11670801700, 0.25 +Res-1.2010, 11670801700, 0.25 +Res-1.2011, 11670801700, 0.25 +Res-1.2012, 11670801700, 0.25 +Res-1.2013, 11670801700, 0.25 +Res-1.2014, 11670801700, 0.25 +Res-1.2015, 11670801700, 0.25 +Res-1.2016, 11670801700, 0.25 +Res-1.2017, 6227222750, 0.25 +Res-1.2018, 6227222750, 0.25 +Res-1.2019, 6227222750, 0.25 +Res-1.2020, 6227222750, 0.25 +Res-1.2021, 6227222750, 0.25 +Res-1.2022, 6227222750, 0.25 +Res-1.2023, 6227222750, 0.25 +Res-1.2024, 6227222750, 0.25 +Res-1.2025, 6227222750, 0.25 +Res-1.2026, 6227222750, 0.25 +Res-1.2027, 6227222750, 0.25 +Res-1.2028, 6227222750, 0.25 +Res-1.2029, 6227222750, 0.25 +Res-1.2030, 6227222750, 0.25 +Res-1.2031, 6227222750, 0.25 +Res-1.2032, 6227222750, 0.25 +Res-1.2033, 6227222750, 0.25 +Res-1.2034, 6227222750, 0.25 +Res-1.2035, 6227222750, 0.25 +Res-1.2036, 6227222750, 0.25 +Res-1.2037, 6227222750, 0.25 +Res-1.2038, 6227222750, 0.25 +Res-1.2039, 6227222750, 0.25 +Res-1.2040, 6227222750, 0.25 +Res-1.2041, 6227222750, 0.25 +Res-1.2042, 6227222750, 0.25 +Res-1.2043, 6227222750, 0.25 +Res-1.2044, 6227222750, 0.25 +Res-1.2045, 6227222750, 0.25 +Res-1.2046, 6227222750, 0.25 +Res-1.2047, 6227222750, 0.25 +Res-1.2048, 6227222750, 0.25 +Res-1.2049, 6227222750, 0.25 +Res-1.2050, 6227222750, 0.25 +Res-1.2051, 6227222750, 0.25 +Res-1.2052, 6227222750, 0.25 +Res-1.2053, 6227222750, 0.25 +Res-1.2054, 6227222750, 0.25 +Res-1.2055, 6227222750, 0.25 +Res-1.2056, 6227222750, 0.25 +Res-1.2057, 6227222750, 0.25 +Res-1.2058, 6227222750, 0.25 +Res-1.2059, 6227222750, 0.25 +Res-1.2060, 6227222750, 0.25 +Res-1.2061, 6227222750, 0.25 +Res-1.2062, 6227222750, 0.25 +Res-1.2063, 6227222750, 0.25 +Res-1.2064, 6227222750, 0.25 +Res-1.2065, 6227222750, 0.25 +Res-1.2066, 6227222750, 0.25 +Res-1.2067, 6227222750, 0.25 +Res-1.2068, 6227222750, 0.25 +Res-1.2069, 6227222750, 0.25 +Res-1.2070, 6227222750, 0.25 +Res-1.2071, 6227222750, 0.25 +Res-1.2072, 6227222750, 0.25 +Res-1.2073, 6227222750, 0.25 +Res-1.2074, 6227222750, 0.25 +Res-1.2075, 6227222750, 0.25 +Res-1.2076, 6227222750, 0.25 +Res-1.2077, 6227222750, 0.25 +Res-1.2078, 6227222750, 0.25 +Res-1.2079, 6227222750, 0.25 +Res-1.2080, 6227222750, 0.25 +Res-1.2081, 6227222750, 0.25 +Res-1.2082, 6227222750, 0.25 +Res-1.2083, 6227222750, 0.25 +Res-1.2084, 6227222750, 0.25 +Res-1.2085, 6227222750, 0.25 +Res-1.2086, 6227222750, 0.25 +Res-1.2087, 6227222750, 0.25 +Res-1.2088, 6227222750, 0.25 +Res-1.2089, 6227222750, 0.25 +Res-1.2090, 6227222750, 0.25 +Res-1.2091, 6227222750, 0.25 +Res-1.2092, 6227222750, 0.25 +Res-1.2093, 6227222750, 0.25 +Res-1.2094, 6227222750, 0.25 +Res-1.2095, 6227222750, 0.25 +Res-1.2096, 6227222750, 0.25 +Res-1.2097, 6227222750, 0.25 +Res-1.2098, 6227222750, 0.25 +Res-1.2099, 6227222750, 0.25 +Res-1.2100, 6227222750, 0.25 +Res-1.2101, 6227222750, 0.25 +Res-1.2102, 6227222750, 0.25 +Res-1.2103, 6227222750, 0.25 +Res-1.2104, 6227222750, 0.25 +Res-1.2105, 6227222750, 0.25 +Res-1.2106, 6227222750, 0.25 +Res-1.2107, 6227222750, 0.25 +Res-1.2108, 6227222750, 0.25 +Res-1.2109, 6227222750, 0.25 +Res-1.2110, 6227222750, 0.25 +Res-1.2111, 6227222750, 0.25 +Res-1.2112, 6227222750, 0.25 +Res-1.2113, 6227222750, 0.25 +Res-1.2114, 6227222750, 0.25 +Res-1.2115, 6227222750, 0.25 +Res-1.2116, 6227222750, 0.25 +Res-1.2117, 6227222750, 0.25 +Res-1.2118, 6227222750, 0.25 +Res-1.2119, 6227222750, 0.25 +Res-1.2120, 6227222750, 0.25 +Res-1.2121, 6227222750, 0.25 +Res-1.2122, 6227222750, 0.25 +Res-1.2123, 6227222750, 0.25 +Res-1.2124, 6227222750, 0.25 +Res-1.2125, 6227222750, 0.25 +Res-1.2126, 6227222750, 0.25 +Res-1.2127, 6227222750, 0.25 +Res-1.2128, 6227222750, 0.25 +Res-1.2129, 6227222750, 0.25 +Res-1.2130, 6227222750, 0.25 +Res-1.2131, 6227222750, 0.25 +Res-1.2132, 6227222750, 0.25 +Res-1.2133, 6227222750, 0.25 +Res-1.2134, 6227222750, 0.25 +Res-1.2135, 6227222750, 0.25 +Res-1.2136, 6227222750, 0.25 +Res-1.2137, 6227222750, 0.25 +Res-1.2138, 6227222750, 0.25 +Res-1.2139, 6227222750, 0.25 +Res-1.2140, 6227222750, 0.25 +Res-1.2141, 6227222750, 0.25 +Res-1.2142, 6227222750, 0.25 +Res-1.2143, 6227222750, 0.25 +Res-1.2144, 6227222750, 0.25 +Res-1.2145, 6227222750, 0.25 +Res-1.2146, 6227222750, 0.25 +Res-1.2147, 6227222750, 0.25 +Res-1.2148, 6227222750, 0.25 +Res-1.2149, 6227222750, 0.25 +Res-1.2150, 6227222750, 0.25 +Res-1.2151, 6227222750, 0.25 +Res-1.2152, 6227222750, 0.25 +Res-1.2153, 6227222750, 0.25 +Res-1.2154, 6227222750, 0.25 +Res-1.2155, 6227222750, 0.25 +Res-1.2156, 6227222750, 0.25 +Res-1.2157, 6227222750, 0.25 +Res-1.2158, 6227222750, 0.25 +Res-1.2159, 6227222750, 0.25 +Res-1.2160, 6227222750, 0.25 +Res-1.2161, 6227222750, 0.25 +Res-1.2162, 6227222750, 0.25 +Res-1.2163, 6227222750, 0.25 +Res-1.2164, 6227222750, 0.25 +Res-1.2165, 6227222750, 0.25 +Res-1.2166, 6227222750, 0.25 +Res-1.2167, 6227222750, 0.25 +Res-1.2168, 6227222750, 0.25 +Res-1.2169, 6227222750, 0.25 +Res-1.2170, 6227222750, 0.25 +Res-1.2171, 6227222750, 0.25 +Res-1.2172, 6227222750, 0.25 +Res-1.2173, 6227222750, 0.25 +Res-1.2174, 6227222750, 0.25 +Res-1.2175, 6227222750, 0.25 +Res-1.2176, 6227222750, 0.25 +Res-1.2177, 6227222750, 0.25 +Res-1.2178, 6227222750, 0.25 +Res-1.2179, 6227222750, 0.25 +Res-1.2180, 6227222750, 0.25 +Res-1.2181, 6227222750, 0.25 +Res-1.2182, 6227222750, 0.25 +Res-1.2183, 6227222750, 0.25 +Res-1.2184, 6227222750, 0.25 +Res-1.2185, 6227222750, 0.25 +Res-1.2186, 6227222750, 0.25 +Res-1.2187, 6227222750, 0.25 +Res-1.2188, 6227222750, 0.25 +Res-1.2189, 6227222750, 0.25 +Res-1.2190, 6227222750, 0.25 +Res-1.2191, 6227222750, 0.25 +Res-1.2192, 6227222750, 0.25 +Res-1.2193, 6227222750, 0.25 +Res-1.2194, 6227222750, 0.25 +Res-1.2195, 6227222750, 0.25 +Res-1.2196, 6227222750, 0.25 +Res-1.2197, 6227222750, 0.25 +Res-1.2198, 6227222750, 0.25 +Res-1.2199, 6227222750, 0.25 +Res-1.2200, 6227222750, 0.25 +Res-1.2201, 6227222750, 0.25 +Res-1.2202, 6227222750, 0.25 +Res-1.2203, 6227222750, 0.25 +Res-1.2204, 6227222750, 0.25 +Res-1.2205, 6227222750, 0.25 +Res-1.2206, 6227222750, 0.25 +Res-1.2207, 6227222750, 0.25 +Res-1.2208, 6227222750, 0.25 +Res-1.2209, 6227222750, 0.25 +Res-1.2210, 6227222750, 0.25 +Res-1.2211, 6227222750, 0.25 +Res-1.2212, 6227222750, 0.25 +Res-1.2213, 6227222750, 0.25 +Res-1.2214, 6227222750, 0.25 +Res-1.2215, 6227222750, 0.25 +Res-1.2216, 6227222750, 0.25 +Res-1.2217, 6227222750, 0.25 +Res-1.2218, 6227222750, 0.25 +Res-1.2219, 6227222750, 0.25 +Res-1.2220, 6227222750, 0.25 +Res-1.2221, 6227222750, 0.25 +Res-1.2222, 6227222750, 0.25 +Res-1.2223, 6227222750, 0.25 +Res-1.2224, 6227222750, 0.25 +Res-1.2225, 6227222750, 0.25 +Res-1.2226, 6227222750, 0.25 +Res-1.2227, 6227222750, 0.25 +Res-1.2228, 6227222750, 0.25 +Res-1.2229, 6227222750, 0.25 +Res-1.2230, 6227222750, 0.25 +Res-1.2231, 6227222750, 0.25 +Res-1.2232, 6227222750, 0.25 +Res-1.2233, 6227222750, 0.25 +Res-1.2234, 6227222750, 0.25 +Res-1.2235, 6227222750, 0.25 +Res-1.2236, 6227222750, 0.25 +Res-1.2237, 6227222750, 0.25 +Res-1.2238, 6227222750, 0.25 +Res-1.2239, 6227222750, 0.25 +Res-1.2240, 6227222750, 0.25 +Res-1.2241, 6227222750, 0.25 +Res-1.2242, 6227222750, 0.25 +Res-1.2243, 6227222750, 0.25 +Res-1.2244, 6227222750, 0.25 +Res-1.2245, 6227222750, 0.25 +Res-1.2246, 6227222750, 0.25 +Res-1.2247, 6227222750, 0.25 +Res-1.2248, 6227222750, 0.25 +Res-1.2249, 6227222750, 0.25 +Res-1.2250, 6227222750, 0.25 +Res-1.2251, 6227222750, 0.25 +Res-1.2252, 6227222750, 0.25 +Res-1.2253, 6227222750, 0.25 +Res-1.2254, 6227222750, 0.25 +Res-1.2255, 6227222750, 0.25 +Res-1.2256, 6227222750, 0.25 +Res-1.2257, 6227222750, 0.25 +Res-1.2258, 6227222750, 0.25 +Res-1.2259, 6227222750, 0.25 +Res-1.2260, 6227222750, 0.25 +Res-1.2261, 6227222750, 0.25 +Res-1.2262, 6227222750, 0.25 +Res-1.2263, 6227222750, 0.25 +Res-1.2264, 6227222750, 0.25 +Res-1.2265, 6227222750, 0.25 +Res-1.2266, 6227222750, 0.25 +Res-1.2267, 6227222750, 0.25 +Res-1.2268, 6227222750, 0.25 +Res-1.2269, 6227222750, 0.25 +Res-1.2270, 6227222750, 0.25 +Res-1.2271, 6227222750, 0.25 +Res-1.2272, 6227222750, 0.25 +Res-1.2273, 6227222750, 0.25 +Res-1.2274, 6227222750, 0.25 +Res-1.2275, 6227222750, 0.25 +Res-1.2276, 6227222750, 0.25 +Res-1.2277, 6227222750, 0.25 +Res-1.2278, 6227222750, 0.25 +Res-1.2279, 6227222750, 0.25 +Res-1.2280, 6227222750, 0.25 +Res-1.2281, 6227222750, 0.25 +Res-1.2282, 6227222750, 0.25 +Res-1.2283, 6227222750, 0.25 +Res-1.2284, 6227222750, 0.25 +Res-1.2285, 6227222750, 0.25 +Res-1.2286, 6227222750, 0.25 +Res-1.2287, 6227222750, 0.25 +Res-1.2288, 6227222750, 0.25 +Res-1.2289, 6227222750, 0.25 +Res-1.2290, 6227222750, 0.25 +Res-1.2291, 6227222750, 0.25 +Res-1.2292, 6227222750, 0.25 +Res-1.2293, 6227222750, 0.25 +Res-1.2294, 6227222750, 0.25 +Res-1.2295, 6227222750, 0.25 +Res-1.2296, 6227222750, 0.25 +Res-1.2297, 6227222750, 0.25 +Res-1.2298, 6227222750, 0.25 +Res-1.2299, 6227222750, 0.25 +Res-1.2300, 6227222750, 0.25 +Res-1.2301, 6227222750, 0.25 +Res-1.2302, 6227222750, 0.25 +Res-1.2303, 6227222750, 0.25 +Res-1.2304, 6227222750, 0.25 +Res-1.2305, 6439192352.5, 0.25 +Res-1.2306, 6439192352.5, 0.25 +Res-1.2307, 6439192352.5, 0.25 +Res-1.2308, 6439192352.5, 0.25 +Res-1.2309, 6439192352.5, 0.25 +Res-1.2310, 6439192352.5, 0.25 +Res-1.2311, 6439192352.5, 0.25 +Res-1.2312, 6439192352.5, 0.25 +Res-1.2313, 6439192352.5, 0.25 +Res-1.2314, 6439192352.5, 0.25 +Res-1.2315, 6439192352.5, 0.25 +Res-1.2316, 6439192352.5, 0.25 +Res-1.2317, 6439192352.5, 0.25 +Res-1.2318, 6439192352.5, 0.25 +Res-1.2319, 6439192352.5, 0.25 +Res-1.2320, 6439192352.5, 0.25 +Res-1.2321, 6439192352.5, 0.25 +Res-1.2322, 6439192352.5, 0.25 +Res-1.2323, 6439192352.5, 0.25 +Res-1.2324, 6439192352.5, 0.25 +Res-1.2325, 6439192352.5, 0.25 +Res-1.2326, 6439192352.5, 0.25 +Res-1.2327, 6439192352.5, 0.25 +Res-1.2328, 6439192352.5, 0.25 +Res-1.2329, 6439192352.5, 0.25 +Res-1.2330, 6439192352.5, 0.25 +Res-1.2331, 6439192352.5, 0.25 +Res-1.2332, 6439192352.5, 0.25 +Res-1.2333, 6439192352.5, 0.25 +Res-1.2334, 6439192352.5, 0.25 +Res-1.2335, 6439192352.5, 0.25 +Res-1.2336, 6439192352.5, 0.25 +Res-1.2337, 6439192352.5, 0.25 +Res-1.2338, 6439192352.5, 0.25 +Res-1.2339, 6439192352.5, 0.25 +Res-1.2340, 6439192352.5, 0.25 +Res-1.2341, 6439192352.5, 0.25 +Res-1.2342, 6439192352.5, 0.25 +Res-1.2343, 6439192352.5, 0.25 +Res-1.2344, 6439192352.5, 0.25 +Res-1.2345, 6439192352.5, 0.25 +Res-1.2346, 6439192352.5, 0.25 +Res-1.2347, 6439192352.5, 0.25 +Res-1.2348, 6439192352.5, 0.25 +Res-1.2349, 6439192352.5, 0.25 +Res-1.2350, 6439192352.5, 0.25 +Res-1.2351, 6439192352.5, 0.25 +Res-1.2352, 6439192352.5, 0.25 +Res-1.2353, 6439192352.5, 0.25 +Res-1.2354, 6439192352.5, 0.25 +Res-1.2355, 6439192352.5, 0.25 +Res-1.2356, 6439192352.5, 0.25 +Res-1.2357, 6439192352.5, 0.25 +Res-1.2358, 6439192352.5, 0.25 +Res-1.2359, 6439192352.5, 0.25 +Res-1.2360, 6439192352.5, 0.25 +Res-1.2361, 6439192352.5, 0.25 +Res-1.2362, 6439192352.5, 0.25 +Res-1.2363, 6439192352.5, 0.25 +Res-1.2364, 6439192352.5, 0.25 +Res-1.2365, 6439192352.5, 0.25 +Res-1.2366, 6439192352.5, 0.25 +Res-1.2367, 6439192352.5, 0.25 +Res-1.2368, 6439192352.5, 0.25 +Res-1.2369, 6439192352.5, 0.25 +Res-1.2370, 6439192352.5, 0.25 +Res-1.2371, 6439192352.5, 0.25 +Res-1.2372, 6439192352.5, 0.25 +Res-1.2373, 6439192352.5, 0.25 +Res-1.2374, 6439192352.5, 0.25 +Res-1.2375, 6439192352.5, 0.25 +Res-1.2376, 6439192352.5, 0.25 +Res-1.2377, 6439192352.5, 0.25 +Res-1.2378, 6439192352.5, 0.25 +Res-1.2379, 6439192352.5, 0.25 +Res-1.2380, 6439192352.5, 0.25 +Res-1.2381, 6439192352.5, 0.25 +Res-1.2382, 6439192352.5, 0.25 +Res-1.2383, 6439192352.5, 0.25 +Res-1.2384, 6439192352.5, 0.25 +Res-1.2385, 6439192352.5, 0.25 +Res-1.2386, 6439192352.5, 0.25 +Res-1.2387, 6439192352.5, 0.25 +Res-1.2388, 6439192352.5, 0.25 +Res-1.2389, 6439192352.5, 0.25 +Res-1.2390, 6439192352.5, 0.25 +Res-1.2391, 6439192352.5, 0.25 +Res-1.2392, 6439192352.5, 0.25 +Res-1.2393, 6439192352.5, 0.25 +Res-1.2394, 6439192352.5, 0.25 +Res-1.2395, 6439192352.5, 0.25 +Res-1.2396, 6439192352.5, 0.25 +Res-1.2397, 6439192352.5, 0.25 +Res-1.2398, 6439192352.5, 0.25 +Res-1.2399, 6439192352.5, 0.25 +Res-1.2400, 6439192352.5, 0.25 +Res-1.2401, 6439192352.5, 0.25 +Res-1.2402, 6439192352.5, 0.25 +Res-1.2403, 6439192352.5, 0.25 +Res-1.2404, 6439192352.5, 0.25 +Res-1.2405, 6439192352.5, 0.25 +Res-1.2406, 6439192352.5, 0.25 +Res-1.2407, 6439192352.5, 0.25 +Res-1.2408, 6439192352.5, 0.25 +Res-1.2409, 6439192352.5, 0.25 +Res-1.2410, 6439192352.5, 0.25 +Res-1.2411, 6439192352.5, 0.25 +Res-1.2412, 6439192352.5, 0.25 +Res-1.2413, 6439192352.5, 0.25 +Res-1.2414, 6439192352.5, 0.25 +Res-1.2415, 6439192352.5, 0.25 +Res-1.2416, 6439192352.5, 0.25 +Res-1.2417, 6439192352.5, 0.25 +Res-1.2418, 6439192352.5, 0.25 +Res-1.2419, 6439192352.5, 0.25 +Res-1.2420, 6439192352.5, 0.25 +Res-1.2421, 6439192352.5, 0.25 +Res-1.2422, 6439192352.5, 0.25 +Res-1.2423, 6439192352.5, 0.25 +Res-1.2424, 6439192352.5, 0.25 +Res-1.2425, 6439192352.5, 0.25 +Res-1.2426, 6439192352.5, 0.25 +Res-1.2427, 6439192352.5, 0.25 +Res-1.2428, 6439192352.5, 0.25 +Res-1.2429, 6439192352.5, 0.25 +Res-1.2430, 6439192352.5, 0.25 +Res-1.2431, 6439192352.5, 0.25 +Res-1.2432, 6439192352.5, 0.25 +Res-1.2433, 6439192352.5, 0.25 +Res-1.2434, 6439192352.5, 0.25 +Res-1.2435, 6439192352.5, 0.25 +Res-1.2436, 6439192352.5, 0.25 +Res-1.2437, 6439192352.5, 0.25 +Res-1.2438, 6439192352.5, 0.25 +Res-1.2439, 6439192352.5, 0.25 +Res-1.2440, 6439192352.5, 0.25 +Res-1.2441, 6439192352.5, 0.25 +Res-1.2442, 6439192352.5, 0.25 +Res-1.2443, 6439192352.5, 0.25 +Res-1.2444, 6439192352.5, 0.25 +Res-1.2445, 6439192352.5, 0.25 +Res-1.2446, 6439192352.5, 0.25 +Res-1.2447, 6439192352.5, 0.25 +Res-1.2448, 6439192352.5, 0.25 +Res-1.2449, 6439192352.5, 0.25 +Res-1.2450, 6439192352.5, 0.25 +Res-1.2451, 6439192352.5, 0.25 +Res-1.2452, 6439192352.5, 0.25 +Res-1.2453, 6439192352.5, 0.25 +Res-1.2454, 6439192352.5, 0.25 +Res-1.2455, 6439192352.5, 0.25 +Res-1.2456, 6439192352.5, 0.25 +Res-1.2457, 6439192352.5, 0.25 +Res-1.2458, 6439192352.5, 0.25 +Res-1.2459, 6439192352.5, 0.25 +Res-1.2460, 6439192352.5, 0.25 +Res-1.2461, 6439192352.5, 0.25 +Res-1.2462, 6439192352.5, 0.25 +Res-1.2463, 6439192352.5, 0.25 +Res-1.2464, 6439192352.5, 0.25 +Res-1.2465, 6439192352.5, 0.25 +Res-1.2466, 6439192352.5, 0.25 +Res-1.2467, 6439192352.5, 0.25 +Res-1.2468, 6439192352.5, 0.25 +Res-1.2469, 6439192352.5, 0.25 +Res-1.2470, 6439192352.5, 0.25 +Res-1.2471, 6439192352.5, 0.25 +Res-1.2472, 6439192352.5, 0.25 +Res-1.2473, 6439192352.5, 0.25 +Res-1.2474, 6439192352.5, 0.25 +Res-1.2475, 6439192352.5, 0.25 +Res-1.2476, 6439192352.5, 0.25 +Res-1.2477, 6439192352.5, 0.25 +Res-1.2478, 6439192352.5, 0.25 +Res-1.2479, 6439192352.5, 0.25 +Res-1.2480, 6439192352.5, 0.25 +Res-1.2481, 6439192352.5, 0.25 +Res-1.2482, 6439192352.5, 0.25 +Res-1.2483, 6439192352.5, 0.25 +Res-1.2484, 6439192352.5, 0.25 +Res-1.2485, 6439192352.5, 0.25 +Res-1.2486, 6439192352.5, 0.25 +Res-1.2487, 6439192352.5, 0.25 +Res-1.2488, 6439192352.5, 0.25 +Res-1.2489, 6439192352.5, 0.25 +Res-1.2490, 6439192352.5, 0.25 +Res-1.2491, 6439192352.5, 0.25 +Res-1.2492, 6439192352.5, 0.25 +Res-1.2493, 6439192352.5, 0.25 +Res-1.2494, 6439192352.5, 0.25 +Res-1.2495, 6439192352.5, 0.25 +Res-1.2496, 6439192352.5, 0.25 +Res-1.2497, 6439192352.5, 0.25 +Res-1.2498, 6439192352.5, 0.25 +Res-1.2499, 6439192352.5, 0.25 +Res-1.2500, 6439192352.5, 0.25 +Res-1.2501, 6439192352.5, 0.25 +Res-1.2502, 6439192352.5, 0.25 +Res-1.2503, 6439192352.5, 0.25 +Res-1.2504, 6439192352.5, 0.25 +Res-1.2505, 6439192352.5, 0.25 +Res-1.2506, 6439192352.5, 0.25 +Res-1.2507, 6439192352.5, 0.25 +Res-1.2508, 6439192352.5, 0.25 +Res-1.2509, 6439192352.5, 0.25 +Res-1.2510, 6439192352.5, 0.25 +Res-1.2511, 6439192352.5, 0.25 +Res-1.2512, 6439192352.5, 0.25 +Res-1.2513, 6439192352.5, 0.25 +Res-1.2514, 6439192352.5, 0.25 +Res-1.2515, 6439192352.5, 0.25 +Res-1.2516, 6439192352.5, 0.25 +Res-1.2517, 6439192352.5, 0.25 +Res-1.2518, 6439192352.5, 0.25 +Res-1.2519, 6439192352.5, 0.25 +Res-1.2520, 6439192352.5, 0.25 +Res-1.2521, 6439192352.5, 0.25 +Res-1.2522, 6439192352.5, 0.25 +Res-1.2523, 6439192352.5, 0.25 +Res-1.2524, 6439192352.5, 0.25 +Res-1.2525, 6439192352.5, 0.25 +Res-1.2526, 6439192352.5, 0.25 +Res-1.2527, 6439192352.5, 0.25 +Res-1.2528, 6439192352.5, 0.25 +Res-1.2529, 6439192352.5, 0.25 +Res-1.2530, 6439192352.5, 0.25 +Res-1.2531, 6439192352.5, 0.25 +Res-1.2532, 6439192352.5, 0.25 +Res-1.2533, 6439192352.5, 0.25 +Res-1.2534, 6439192352.5, 0.25 +Res-1.2535, 6439192352.5, 0.25 +Res-1.2536, 6439192352.5, 0.25 +Res-1.2537, 6439192352.5, 0.25 +Res-1.2538, 6439192352.5, 0.25 +Res-1.2539, 6439192352.5, 0.25 +Res-1.2540, 6439192352.5, 0.25 +Res-1.2541, 6439192352.5, 0.25 +Res-1.2542, 6439192352.5, 0.25 +Res-1.2543, 6439192352.5, 0.25 +Res-1.2544, 6439192352.5, 0.25 +Res-1.2545, 6439192352.5, 0.25 +Res-1.2546, 6439192352.5, 0.25 +Res-1.2547, 6439192352.5, 0.25 +Res-1.2548, 6439192352.5, 0.25 +Res-1.2549, 6439192352.5, 0.25 +Res-1.2550, 6439192352.5, 0.25 +Res-1.2551, 6439192352.5, 0.25 +Res-1.2552, 6439192352.5, 0.25 +Res-1.2553, 6439192352.5, 0.25 +Res-1.2554, 6439192352.5, 0.25 +Res-1.2555, 6439192352.5, 0.25 +Res-1.2556, 6439192352.5, 0.25 +Res-1.2557, 6439192352.5, 0.25 +Res-1.2558, 6439192352.5, 0.25 +Res-1.2559, 6439192352.5, 0.25 +Res-1.2560, 6439192352.5, 0.25 +Res-1.2561, 6439192352.5, 0.25 +Res-1.2562, 6439192352.5, 0.25 +Res-1.2563, 6439192352.5, 0.25 +Res-1.2564, 6439192352.5, 0.25 +Res-1.2565, 6439192352.5, 0.25 +Res-1.2566, 6439192352.5, 0.25 +Res-1.2567, 6439192352.5, 0.25 +Res-1.2568, 6439192352.5, 0.25 +Res-1.2569, 6439192352.5, 0.25 +Res-1.2570, 6439192352.5, 0.25 +Res-1.2571, 6439192352.5, 0.25 +Res-1.2572, 6439192352.5, 0.25 +Res-1.2573, 6439192352.5, 0.25 +Res-1.2574, 6439192352.5, 0.25 +Res-1.2575, 6439192352.5, 0.25 +Res-1.2576, 6439192352.5, 0.25 +Res-1.2577, 6439192352.5, 0.25 +Res-1.2578, 6439192352.5, 0.25 +Res-1.2579, 6439192352.5, 0.25 +Res-1.2580, 6439192352.5, 0.25 +Res-1.2581, 6439192352.5, 0.25 +Res-1.2582, 6439192352.5, 0.25 +Res-1.2583, 6439192352.5, 0.25 +Res-1.2584, 6439192352.5, 0.25 +Res-1.2585, 6439192352.5, 0.25 +Res-1.2586, 6439192352.5, 0.25 +Res-1.2587, 6439192352.5, 0.25 +Res-1.2588, 6439192352.5, 0.25 +Res-1.2589, 6439192352.5, 0.25 +Res-1.2590, 6439192352.5, 0.25 +Res-1.2591, 6439192352.5, 0.25 +Res-1.2592, 6439192352.5, 0.25 +Res-1.2593, 5316491363.7363, 0.25 +Res-1.2594, 5316491363.7363, 0.25 +Res-1.2595, 5316491363.7363, 0.25 +Res-1.2596, 5316491363.7363, 0.25 +Res-1.2597, 5316491363.7363, 0.25 +Res-1.2598, 5316491363.7363, 0.25 +Res-1.2599, 5316491363.7363, 0.25 +Res-1.2600, 5316491363.7363, 0.25 +Res-1.2601, 5316491363.7363, 0.25 +Res-1.2602, 5316491363.7363, 0.25 +Res-1.2603, 5316491363.7363, 0.25 +Res-1.2604, 5316491363.7363, 0.25 +Res-1.2605, 5316491363.7363, 0.25 +Res-1.2606, 5316491363.7363, 0.25 +Res-1.2607, 5316491363.7363, 0.25 +Res-1.2608, 5316491363.7363, 0.25 +Res-1.2609, 5316491363.7363, 0.25 +Res-1.2610, 5316491363.7363, 0.25 +Res-1.2611, 5316491363.7363, 0.25 +Res-1.2612, 5316491363.7363, 0.25 +Res-1.2613, 5316491363.7363, 0.25 +Res-1.2614, 5316491363.7363, 0.25 +Res-1.2615, 5316491363.7363, 0.25 +Res-1.2616, 5316491363.7363, 0.25 +Res-1.2617, 5316491363.7363, 0.25 +Res-1.2618, 5316491363.7363, 0.25 +Res-1.2619, 5316491363.7363, 0.25 +Res-1.2620, 5316491363.7363, 0.25 +Res-1.2621, 5316491363.7363, 0.25 +Res-1.2622, 5316491363.7363, 0.25 +Res-1.2623, 5316491363.7363, 0.25 +Res-1.2624, 5316491363.7363, 0.25 +Res-1.2625, 5316491363.7363, 0.25 +Res-1.2626, 5316491363.7363, 0.25 +Res-1.2627, 5316491363.7363, 0.25 +Res-1.2628, 5316491363.7363, 0.25 +Res-1.2629, 5316491363.7363, 0.25 +Res-1.2630, 5316491363.7363, 0.25 +Res-1.2631, 5316491363.7363, 0.25 +Res-1.2632, 5316491363.7363, 0.25 +Res-1.2633, 5316491363.7363, 0.25 +Res-1.2634, 5316491363.7363, 0.25 +Res-1.2635, 5316491363.7363, 0.25 +Res-1.2636, 5316491363.7363, 0.25 +Res-1.2637, 5316491363.7363, 0.25 +Res-1.2638, 5316491363.7363, 0.25 +Res-1.2639, 5316491363.7363, 0.25 +Res-1.2640, 5316491363.7363, 0.25 +Res-1.2641, 5316491363.7363, 0.25 +Res-1.2642, 5316491363.7363, 0.25 +Res-1.2643, 5316491363.7363, 0.25 +Res-1.2644, 5316491363.7363, 0.25 +Res-1.2645, 5316491363.7363, 0.25 +Res-1.2646, 5316491363.7363, 0.25 +Res-1.2647, 5316491363.7363, 0.25 +Res-1.2648, 5316491363.7363, 0.25 +Res-1.2649, 5316491363.7363, 0.25 +Res-1.2650, 5316491363.7363, 0.25 +Res-1.2651, 5316491363.7363, 0.25 +Res-1.2652, 5316491363.7363, 0.25 +Res-1.2653, 5316491363.7363, 0.25 +Res-1.2654, 5316491363.7363, 0.25 +Res-1.2655, 5316491363.7363, 0.25 +Res-1.2656, 5316491363.7363, 0.25 +Res-1.2657, 5316491363.7363, 0.25 +Res-1.2658, 5316491363.7363, 0.25 +Res-1.2659, 5316491363.7363, 0.25 +Res-1.2660, 5316491363.7363, 0.25 +Res-1.2661, 5316491363.7363, 0.25 +Res-1.2662, 5316491363.7363, 0.25 +Res-1.2663, 5316491363.7363, 0.25 +Res-1.2664, 5316491363.7363, 0.25 +Res-1.2665, 5316491363.7363, 0.25 +Res-1.2666, 5316491363.7363, 0.25 +Res-1.2667, 5316491363.7363, 0.25 +Res-1.2668, 5316491363.7363, 0.25 +Res-1.2669, 5316491363.7363, 0.25 +Res-1.2670, 5316491363.7363, 0.25 +Res-1.2671, 5316491363.7363, 0.25 +Res-1.2672, 5316491363.7363, 0.25 +Res-1.2673, 5316491363.7363, 0.25 +Res-1.2674, 5316491363.7363, 0.25 +Res-1.2675, 5316491363.7363, 0.25 +Res-1.2676, 5316491363.7363, 0.25 +Res-1.2677, 5316491363.7363, 0.25 +Res-1.2678, 5316491363.7363, 0.25 +Res-1.2679, 5316491363.7363, 0.25 +Res-1.2680, 5316491363.7363, 0.25 +Res-1.2681, 5316491363.7363, 0.25 +Res-1.2682, 5316491363.7363, 0.25 +Res-1.2683, 5316491363.7363, 0.25 +Res-1.2684, 5316491363.7363, 0.25 +Res-1.2685, 5316491363.7363, 0.25 +Res-1.2686, 5316491363.7363, 0.25 +Res-1.2687, 5316491363.7363, 0.25 +Res-1.2688, 5316491363.7363, 0.25 +Res-1.2689, 5316491363.7363, 0.25 +Res-1.2690, 5316491363.7363, 0.25 +Res-1.2691, 5316491363.7363, 0.25 +Res-1.2692, 5316491363.7363, 0.25 +Res-1.2693, 5316491363.7363, 0.25 +Res-1.2694, 5316491363.7363, 0.25 +Res-1.2695, 5316491363.7363, 0.25 +Res-1.2696, 5316491363.7363, 0.25 +Res-1.2697, 5316491363.7363, 0.25 +Res-1.2698, 5316491363.7363, 0.25 +Res-1.2699, 5316491363.7363, 0.25 +Res-1.2700, 5316491363.7363, 0.25 +Res-1.2701, 5316491363.7363, 0.25 +Res-1.2702, 5316491363.7363, 0.25 +Res-1.2703, 5316491363.7363, 0.25 +Res-1.2704, 5316491363.7363, 0.25 +Res-1.2705, 5316491363.7363, 0.25 +Res-1.2706, 5316491363.7363, 0.25 +Res-1.2707, 5316491363.7363, 0.25 +Res-1.2708, 5316491363.7363, 0.25 +Res-1.2709, 5316491363.7363, 0.25 +Res-1.2710, 5316491363.7363, 0.25 +Res-1.2711, 5316491363.7363, 0.25 +Res-1.2712, 5316491363.7363, 0.25 +Res-1.2713, 5316491363.7363, 0.25 +Res-1.2714, 5316491363.7363, 0.25 +Res-1.2715, 5316491363.7363, 0.25 +Res-1.2716, 5316491363.7363, 0.25 +Res-1.2717, 5316491363.7363, 0.25 +Res-1.2718, 5316491363.7363, 0.25 +Res-1.2719, 5316491363.7363, 0.25 +Res-1.2720, 5316491363.7363, 0.25 +Res-1.2721, 5316491363.7363, 0.25 +Res-1.2722, 5316491363.7363, 0.25 +Res-1.2723, 5316491363.7363, 0.25 +Res-1.2724, 5316491363.7363, 0.25 +Res-1.2725, 5316491363.7363, 0.25 +Res-1.2726, 5316491363.7363, 0.25 +Res-1.2727, 5316491363.7363, 0.25 +Res-1.2728, 5316491363.7363, 0.25 +Res-1.2729, 5316491363.7363, 0.25 +Res-1.2730, 5316491363.7363, 0.25 +Res-1.2731, 5316491363.7363, 0.25 +Res-1.2732, 5316491363.7363, 0.25 +Res-1.2733, 5316491363.7363, 0.25 +Res-1.2734, 5316491363.7363, 0.25 +Res-1.2735, 5316491363.7363, 0.25 +Res-1.2736, 5316491363.7363, 0.25 +Res-1.2737, 5316491363.7363, 0.25 +Res-1.2738, 5316491363.7363, 0.25 +Res-1.2739, 5316491363.7363, 0.25 +Res-1.2740, 5316491363.7363, 0.25 +Res-1.2741, 5316491363.7363, 0.25 +Res-1.2742, 5316491363.7363, 0.25 +Res-1.2743, 5316491363.7363, 0.25 +Res-1.2744, 5316491363.7363, 0.25 +Res-1.2745, 5316491363.7363, 0.25 +Res-1.2746, 5316491363.7363, 0.25 +Res-1.2747, 5316491363.7363, 0.25 +Res-1.2748, 5316491363.7363, 0.25 +Res-1.2749, 5316491363.7363, 0.25 +Res-1.2750, 5316491363.7363, 0.25 +Res-1.2751, 5316491363.7363, 0.25 +Res-1.2752, 5316491363.7363, 0.25 +Res-1.2753, 5316491363.7363, 0.25 +Res-1.2754, 5316491363.7363, 0.25 +Res-1.2755, 5316491363.7363, 0.25 +Res-1.2756, 5316491363.7363, 0.25 +Res-1.2757, 5316491363.7363, 0.25 +Res-1.2758, 5316491363.7363, 0.25 +Res-1.2759, 5316491363.7363, 0.25 +Res-1.2760, 5316491363.7363, 0.25 +Res-1.2761, 5316491363.7363, 0.25 +Res-1.2762, 5316491363.7363, 0.25 +Res-1.2763, 5316491363.7363, 0.25 +Res-1.2764, 5316491363.7363, 0.25 +Res-1.2765, 5316491363.7363, 0.25 +Res-1.2766, 5316491363.7363, 0.25 +Res-1.2767, 5316491363.7363, 0.25 +Res-1.2768, 5316491363.7363, 0.25 +Res-1.2769, 5316491363.7363, 0.25 +Res-1.2770, 5316491363.7363, 0.25 +Res-1.2771, 5316491363.7363, 0.25 +Res-1.2772, 5316491363.7363, 0.25 +Res-1.2773, 5316491363.7363, 0.25 +Res-1.2774, 5316491363.7363, 0.25 +Res-1.2775, 5316491363.7363, 0.25 +Res-1.2776, 5316491363.7363, 0.25 +Res-1.2777, 5316491363.7363, 0.25 +Res-1.2778, 5316491363.7363, 0.25 +Res-1.2779, 5316491363.7363, 0.25 +Res-1.2780, 5316491363.7363, 0.25 +Res-1.2781, 5316491363.7363, 0.25 +Res-1.2782, 5316491363.7363, 0.25 +Res-1.2783, 5316491363.7363, 0.25 +Res-1.2784, 5316491363.7363, 0.25 +Res-1.2785, 5316491363.7363, 0.25 +Res-1.2786, 5316491363.7363, 0.25 +Res-1.2787, 5316491363.7363, 0.25 +Res-1.2788, 5316491363.7363, 0.25 +Res-1.2789, 5316491363.7363, 0.25 +Res-1.2790, 5316491363.7363, 0.25 +Res-1.2791, 5316491363.7363, 0.25 +Res-1.2792, 5316491363.7363, 0.25 +Res-1.2793, 5316491363.7363, 0.25 +Res-1.2794, 5316491363.7363, 0.25 +Res-1.2795, 5316491363.7363, 0.25 +Res-1.2796, 5316491363.7363, 0.25 +Res-1.2797, 5316491363.7363, 0.25 +Res-1.2798, 5316491363.7363, 0.25 +Res-1.2799, 5316491363.7363, 0.25 +Res-1.2800, 5316491363.7363, 0.25 +Res-1.2801, 5316491363.7363, 0.25 +Res-1.2802, 5316491363.7363, 0.25 +Res-1.2803, 5316491363.7363, 0.25 +Res-1.2804, 5316491363.7363, 0.25 +Res-1.2805, 5316491363.7363, 0.25 +Res-1.2806, 5316491363.7363, 0.25 +Res-1.2807, 5316491363.7363, 0.25 +Res-1.2808, 5316491363.7363, 0.25 +Res-1.2809, 5316491363.7363, 0.25 +Res-1.2810, 5316491363.7363, 0.25 +Res-1.2811, 5316491363.7363, 0.25 +Res-1.2812, 5316491363.7363, 0.25 +Res-1.2813, 5316491363.7363, 0.25 +Res-1.2814, 5316491363.7363, 0.25 +Res-1.2815, 5316491363.7363, 0.25 +Res-1.2816, 5316491363.7363, 0.25 +Res-1.2817, 5316491363.7363, 0.25 +Res-1.2818, 5316491363.7363, 0.25 +Res-1.2819, 5316491363.7363, 0.25 +Res-1.2820, 5316491363.7363, 0.25 +Res-1.2821, 5316491363.7363, 0.25 +Res-1.2822, 5316491363.7363, 0.25 +Res-1.2823, 5316491363.7363, 0.25 +Res-1.2824, 5316491363.7363, 0.25 +Res-1.2825, 5316491363.7363, 0.25 +Res-1.2826, 5316491363.7363, 0.25 +Res-1.2827, 5316491363.7363, 0.25 +Res-1.2828, 5316491363.7363, 0.25 +Res-1.2829, 5316491363.7363, 0.25 +Res-1.2830, 5316491363.7363, 0.25 +Res-1.2831, 5316491363.7363, 0.25 +Res-1.2832, 5316491363.7363, 0.25 +Res-1.2833, 5316491363.7363, 0.25 +Res-1.2834, 5316491363.7363, 0.25 +Res-1.2835, 5316491363.7363, 0.25 +Res-1.2836, 5316491363.7363, 0.25 +Res-1.2837, 5316491363.7363, 0.25 +Res-1.2838, 5316491363.7363, 0.25 +Res-1.2839, 5316491363.7363, 0.25 +Res-1.2840, 5316491363.7363, 0.25 +Res-1.2841, 5316491363.7363, 0.25 +Res-1.2842, 5316491363.7363, 0.25 +Res-1.2843, 5316491363.7363, 0.25 +Res-1.2844, 5316491363.7363, 0.25 +Res-1.2845, 5316491363.7363, 0.25 +Res-1.2846, 5316491363.7363, 0.25 +Res-1.2847, 5316491363.7363, 0.25 +Res-1.2848, 5316491363.7363, 0.25 +Res-1.2849, 5316491363.7363, 0.25 +Res-1.2850, 5316491363.7363, 0.25 +Res-1.2851, 5316491363.7363, 0.25 +Res-1.2852, 5316491363.7363, 0.25 +Res-1.2853, 5316491363.7363, 0.25 +Res-1.2854, 5316491363.7363, 0.25 +Res-1.2855, 5316491363.7363, 0.25 +Res-1.2856, 5316491363.7363, 0.25 +Res-1.2857, 5316491363.7363, 0.25 +Res-1.2858, 5316491363.7363, 0.25 +Res-1.2859, 5316491363.7363, 0.25 +Res-1.2860, 5316491363.7363, 0.25 +Res-1.2861, 5316491363.7363, 0.25 +Res-1.2862, 5316491363.7363, 0.25 +Res-1.2863, 5316491363.7363, 0.25 +Res-1.2864, 5316491363.7363, 0.25 +Res-1.2865, 5316491363.7363, 0.25 +Res-1.2866, 5316491363.7363, 0.25 +Res-1.2867, 5316491363.7363, 0.25 +Res-1.2868, 5316491363.7363, 0.25 +Res-1.2869, 5316491363.7363, 0.25 +Res-1.2870, 5316491363.7363, 0.25 +Res-1.2871, 5316491363.7363, 0.25 +Res-1.2872, 5316491363.7363, 0.25 +Res-1.2873, 5316491363.7363, 0.25 +Res-1.2874, 5316491363.7363, 0.25 +Res-1.2875, 5316491363.7363, 0.25 +Res-1.2876, 5316491363.7363, 0.25 +Res-1.2877, 5316491363.7363, 0.25 +Res-1.2878, 5316491363.7363, 0.25 +Res-1.2879, 5316491363.7363, 0.25 +Res-1.2880, 5316491363.7363, 0.25 +Res-1.2881, 11552880115, 0.25 +Res-1.2882, 11552880115, 0.25 +Res-1.2883, 11552880115, 0.25 +Res-1.2884, 11552880115, 0.25 +Res-1.2885, 11552880115, 0.25 +Res-1.2886, 11552880115, 0.25 +Res-1.2887, 11552880115, 0.25 +Res-1.2888, 11552880115, 0.25 +Res-1.2889, 11552880115, 0.25 +Res-1.2890, 11552880115, 0.25 +Res-1.2891, 11552880115, 0.25 +Res-1.2892, 11552880115, 0.25 +Res-1.2893, 11552880115, 0.25 +Res-1.2894, 11552880115, 0.25 +Res-1.2895, 11552880115, 0.25 +Res-1.2896, 11552880115, 0.25 +Res-1.2897, 11552880115, 0.25 +Res-1.2898, 11552880115, 0.25 +Res-1.2899, 11552880115, 0.25 +Res-1.2900, 11552880115, 0.25 +Res-1.2901, 11552880115, 0.25 +Res-1.2902, 11552880115, 0.25 +Res-1.2903, 11552880115, 0.25 +Res-1.2904, 11552880115, 0.25 +Res-1.2905, 11552880115, 0.25 +Res-1.2906, 11552880115, 0.25 +Res-1.2907, 11552880115, 0.25 +Res-1.2908, 11552880115, 0.25 +Res-1.2909, 11552880115, 0.25 +Res-1.2910, 11552880115, 0.25 +Res-1.2911, 11552880115, 0.25 +Res-1.2912, 11552880115, 0.25 +Res-1.2913, 11552880115, 0.25 +Res-1.2914, 11552880115, 0.25 +Res-1.2915, 11552880115, 0.25 +Res-1.2916, 11552880115, 0.25 +Res-1.2917, 11552880115, 0.25 +Res-1.2918, 11552880115, 0.25 +Res-1.2919, 11552880115, 0.25 +Res-1.2920, 11552880115, 0.25 +Res-1.2921, 11552880115, 0.25 +Res-1.2922, 11552880115, 0.25 +Res-1.2923, 11552880115, 0.25 +Res-1.2924, 11552880115, 0.25 +Res-1.2925, 11552880115, 0.25 +Res-1.2926, 11552880115, 0.25 +Res-1.2927, 11552880115, 0.25 +Res-1.2928, 11552880115, 0.25 +Res-1.2929, 11552880115, 0.25 +Res-1.2930, 11552880115, 0.25 +Res-1.2931, 11552880115, 0.25 +Res-1.2932, 11552880115, 0.25 +Res-1.2933, 11552880115, 0.25 +Res-1.2934, 11552880115, 0.25 +Res-1.2935, 11552880115, 0.25 +Res-1.2936, 11552880115, 0.25 +Res-1.2937, 11552880115, 0.25 +Res-1.2938, 11552880115, 0.25 +Res-1.2939, 11552880115, 0.25 +Res-1.2940, 11552880115, 0.25 +Res-1.2941, 11552880115, 0.25 +Res-1.2942, 11552880115, 0.25 +Res-1.2943, 11552880115, 0.25 +Res-1.2944, 11552880115, 0.25 +Res-1.2945, 11552880115, 0.25 +Res-1.2946, 11552880115, 0.25 +Res-1.2947, 11552880115, 0.25 +Res-1.2948, 11552880115, 0.25 +Res-1.2949, 11552880115, 0.25 +Res-1.2950, 11552880115, 0.25 +Res-1.2951, 11552880115, 0.25 +Res-1.2952, 11552880115, 0.25 +Res-1.2953, 11552880115, 0.25 +Res-1.2954, 11552880115, 0.25 +Res-1.2955, 11552880115, 0.25 +Res-1.2956, 11552880115, 0.25 +Res-1.2957, 11552880115, 0.25 +Res-1.2958, 11552880115, 0.25 +Res-1.2959, 11552880115, 0.25 +Res-1.2960, 11552880115, 0.25 +Res-1.2961, 11552880115, 0.25 +Res-1.2962, 11552880115, 0.25 +Res-1.2963, 11552880115, 0.25 +Res-1.2964, 11552880115, 0.25 +Res-1.2965, 11552880115, 0.25 +Res-1.2966, 11552880115, 0.25 +Res-1.2967, 11552880115, 0.25 +Res-1.2968, 11552880115, 0.25 +Res-1.2969, 11552880115, 0.25 +Res-1.2970, 11552880115, 0.25 +Res-1.2971, 11552880115, 0.25 +Res-1.2972, 11552880115, 0.25 +Res-1.2973, 11552880115, 0.25 +Res-1.2974, 11552880115, 0.25 +Res-1.2975, 11552880115, 0.25 +Res-1.2976, 11552880115, 0.25 +Res-1.2977, 11552880115, 0.25 +Res-1.2978, 11552880115, 0.25 +Res-1.2979, 11552880115, 0.25 +Res-1.2980, 11552880115, 0.25 +Res-1.2981, 11552880115, 0.25 +Res-1.2982, 11552880115, 0.25 +Res-1.2983, 11552880115, 0.25 +Res-1.2984, 11552880115, 0.25 +Res-1.2985, 11552880115, 0.25 +Res-1.2986, 11552880115, 0.25 +Res-1.2987, 11552880115, 0.25 +Res-1.2988, 11552880115, 0.25 +Res-1.2989, 11552880115, 0.25 +Res-1.2990, 11552880115, 0.25 +Res-1.2991, 11552880115, 0.25 +Res-1.2992, 11552880115, 0.25 +Res-1.2993, 11552880115, 0.25 +Res-1.2994, 11552880115, 0.25 +Res-1.2995, 11552880115, 0.25 +Res-1.2996, 11552880115, 0.25 +Res-1.2997, 11552880115, 0.25 +Res-1.2998, 11552880115, 0.25 +Res-1.2999, 11552880115, 0.25 +Res-1.3000, 11552880115, 0.25 +Res-1.3001, 11552880115, 0.25 +Res-1.3002, 11552880115, 0.25 +Res-1.3003, 11552880115, 0.25 +Res-1.3004, 11552880115, 0.25 +Res-1.3005, 11552880115, 0.25 +Res-1.3006, 11552880115, 0.25 +Res-1.3007, 11552880115, 0.25 +Res-1.3008, 11552880115, 0.25 +Res-1.3009, 11552880115, 0.25 +Res-1.3010, 11552880115, 0.25 +Res-1.3011, 11552880115, 0.25 +Res-1.3012, 11552880115, 0.25 +Res-1.3013, 11552880115, 0.25 +Res-1.3014, 11552880115, 0.25 +Res-1.3015, 11552880115, 0.25 +Res-1.3016, 11552880115, 0.25 +Res-1.3017, 11552880115, 0.25 +Res-1.3018, 11552880115, 0.25 +Res-1.3019, 11552880115, 0.25 +Res-1.3020, 11552880115, 0.25 +Res-1.3021, 11552880115, 0.25 +Res-1.3022, 11552880115, 0.25 +Res-1.3023, 11552880115, 0.25 +Res-1.3024, 11552880115, 0.25 +Res-1.3025, 11552880115, 0.25 +Res-1.3026, 11552880115, 0.25 +Res-1.3027, 11552880115, 0.25 +Res-1.3028, 11552880115, 0.25 +Res-1.3029, 11552880115, 0.25 +Res-1.3030, 11552880115, 0.25 +Res-1.3031, 11552880115, 0.25 +Res-1.3032, 11552880115, 0.25 +Res-1.3033, 11552880115, 0.25 +Res-1.3034, 11552880115, 0.25 +Res-1.3035, 11552880115, 0.25 +Res-1.3036, 11552880115, 0.25 +Res-1.3037, 11552880115, 0.25 +Res-1.3038, 11552880115, 0.25 +Res-1.3039, 11552880115, 0.25 +Res-1.3040, 11552880115, 0.25 +Res-1.3041, 11552880115, 0.25 +Res-1.3042, 11552880115, 0.25 +Res-1.3043, 11552880115, 0.25 +Res-1.3044, 11552880115, 0.25 +Res-1.3045, 11552880115, 0.25 +Res-1.3046, 11552880115, 0.25 +Res-1.3047, 11552880115, 0.25 +Res-1.3048, 11552880115, 0.25 +Res-1.3049, 11552880115, 0.25 +Res-1.3050, 11552880115, 0.25 +Res-1.3051, 11552880115, 0.25 +Res-1.3052, 11552880115, 0.25 +Res-1.3053, 11552880115, 0.25 +Res-1.3054, 11552880115, 0.25 +Res-1.3055, 11552880115, 0.25 +Res-1.3056, 11552880115, 0.25 +Res-1.3057, 11552880115, 0.25 +Res-1.3058, 11552880115, 0.25 +Res-1.3059, 11552880115, 0.25 +Res-1.3060, 11552880115, 0.25 +Res-1.3061, 11552880115, 0.25 +Res-1.3062, 11552880115, 0.25 +Res-1.3063, 11552880115, 0.25 +Res-1.3064, 11552880115, 0.25 +Res-1.3065, 11552880115, 0.25 +Res-1.3066, 11552880115, 0.25 +Res-1.3067, 11552880115, 0.25 +Res-1.3068, 11552880115, 0.25 +Res-1.3069, 11552880115, 0.25 +Res-1.3070, 11552880115, 0.25 +Res-1.3071, 11552880115, 0.25 +Res-1.3072, 11552880115, 0.25 +Res-1.3073, 11552880115, 0.25 +Res-1.3074, 11552880115, 0.25 +Res-1.3075, 11552880115, 0.25 +Res-1.3076, 11552880115, 0.25 +Res-1.3077, 11552880115, 0.25 +Res-1.3078, 11552880115, 0.25 +Res-1.3079, 11552880115, 0.25 +Res-1.3080, 11552880115, 0.25 +Res-1.3081, 11552880115, 0.25 +Res-1.3082, 11552880115, 0.25 +Res-1.3083, 11552880115, 0.25 +Res-1.3084, 11552880115, 0.25 +Res-1.3085, 11552880115, 0.25 +Res-1.3086, 11552880115, 0.25 +Res-1.3087, 11552880115, 0.25 +Res-1.3088, 11552880115, 0.25 +Res-1.3089, 11552880115, 0.25 +Res-1.3090, 11552880115, 0.25 +Res-1.3091, 11552880115, 0.25 +Res-1.3092, 11552880115, 0.25 +Res-1.3093, 11552880115, 0.25 +Res-1.3094, 11552880115, 0.25 +Res-1.3095, 11552880115, 0.25 +Res-1.3096, 11552880115, 0.25 +Res-1.3097, 11552880115, 0.25 +Res-1.3098, 11552880115, 0.25 +Res-1.3099, 11552880115, 0.25 +Res-1.3100, 11552880115, 0.25 +Res-1.3101, 11552880115, 0.25 +Res-1.3102, 11552880115, 0.25 +Res-1.3103, 11552880115, 0.25 +Res-1.3104, 11552880115, 0.25 +Res-1.3105, 11552880115, 0.25 +Res-1.3106, 11552880115, 0.25 +Res-1.3107, 11552880115, 0.25 +Res-1.3108, 11552880115, 0.25 +Res-1.3109, 11552880115, 0.25 +Res-1.3110, 11552880115, 0.25 +Res-1.3111, 11552880115, 0.25 +Res-1.3112, 11552880115, 0.25 +Res-1.3113, 11552880115, 0.25 +Res-1.3114, 11552880115, 0.25 +Res-1.3115, 11552880115, 0.25 +Res-1.3116, 11552880115, 0.25 +Res-1.3117, 11552880115, 0.25 +Res-1.3118, 11552880115, 0.25 +Res-1.3119, 11552880115, 0.25 +Res-1.3120, 11552880115, 0.25 +Res-1.3121, 11552880115, 0.25 +Res-1.3122, 11552880115, 0.25 +Res-1.3123, 11552880115, 0.25 +Res-1.3124, 11552880115, 0.25 +Res-1.3125, 11552880115, 0.25 +Res-1.3126, 11552880115, 0.25 +Res-1.3127, 11552880115, 0.25 +Res-1.3128, 11552880115, 0.25 +Res-1.3129, 11552880115, 0.25 +Res-1.3130, 11552880115, 0.25 +Res-1.3131, 11552880115, 0.25 +Res-1.3132, 11552880115, 0.25 +Res-1.3133, 11552880115, 0.25 +Res-1.3134, 11552880115, 0.25 +Res-1.3135, 11552880115, 0.25 +Res-1.3136, 11552880115, 0.25 +Res-1.3137, 11552880115, 0.25 +Res-1.3138, 11552880115, 0.25 +Res-1.3139, 11552880115, 0.25 +Res-1.3140, 11552880115, 0.25 +Res-1.3141, 11552880115, 0.25 +Res-1.3142, 11552880115, 0.25 +Res-1.3143, 11552880115, 0.25 +Res-1.3144, 11552880115, 0.25 +Res-1.3145, 11552880115, 0.25 +Res-1.3146, 11552880115, 0.25 +Res-1.3147, 11552880115, 0.25 +Res-1.3148, 11552880115, 0.25 +Res-1.3149, 11552880115, 0.25 +Res-1.3150, 11552880115, 0.25 +Res-1.3151, 11552880115, 0.25 +Res-1.3152, 11552880115, 0.25 +Res-1.3153, 11552880115, 0.25 +Res-1.3154, 11552880115, 0.25 +Res-1.3155, 11552880115, 0.25 +Res-1.3156, 11552880115, 0.25 +Res-1.3157, 11552880115, 0.25 +Res-1.3158, 11552880115, 0.25 +Res-1.3159, 11552880115, 0.25 +Res-1.3160, 11552880115, 0.25 +Res-1.3161, 11552880115, 0.25 +Res-1.3162, 11552880115, 0.25 +Res-1.3163, 11552880115, 0.25 +Res-1.3164, 11552880115, 0.25 +Res-1.3165, 11552880115, 0.25 +Res-1.3166, 11552880115, 0.25 +Res-1.3167, 11552880115, 0.25 +Res-1.3168, 11552880115, 0.25 +Res-1.3169, 13631205565, 0.25 +Res-1.3170, 13631205565, 0.25 +Res-1.3171, 13631205565, 0.25 +Res-1.3172, 13631205565, 0.25 +Res-1.3173, 13631205565, 0.25 +Res-1.3174, 13631205565, 0.25 +Res-1.3175, 13631205565, 0.25 +Res-1.3176, 13631205565, 0.25 +Res-1.3177, 13631205565, 0.25 +Res-1.3178, 13631205565, 0.25 +Res-1.3179, 13631205565, 0.25 +Res-1.3180, 13631205565, 0.25 +Res-1.3181, 13631205565, 0.25 +Res-1.3182, 13631205565, 0.25 +Res-1.3183, 13631205565, 0.25 +Res-1.3184, 13631205565, 0.25 +Res-1.3185, 13631205565, 0.25 +Res-1.3186, 13631205565, 0.25 +Res-1.3187, 13631205565, 0.25 +Res-1.3188, 13631205565, 0.25 +Res-1.3189, 13631205565, 0.25 +Res-1.3190, 13631205565, 0.25 +Res-1.3191, 13631205565, 0.25 +Res-1.3192, 13631205565, 0.25 +Res-1.3193, 13631205565, 0.25 +Res-1.3194, 13631205565, 0.25 +Res-1.3195, 13631205565, 0.25 +Res-1.3196, 13631205565, 0.25 +Res-1.3197, 13631205565, 0.25 +Res-1.3198, 13631205565, 0.25 +Res-1.3199, 13631205565, 0.25 +Res-1.3200, 13631205565, 0.25 +Res-1.3201, 13631205565, 0.25 +Res-1.3202, 13631205565, 0.25 +Res-1.3203, 13631205565, 0.25 +Res-1.3204, 13631205565, 0.25 +Res-1.3205, 13631205565, 0.25 +Res-1.3206, 13631205565, 0.25 +Res-1.3207, 13631205565, 0.25 +Res-1.3208, 13631205565, 0.25 +Res-1.3209, 13631205565, 0.25 +Res-1.3210, 13631205565, 0.25 +Res-1.3211, 13631205565, 0.25 +Res-1.3212, 13631205565, 0.25 +Res-1.3213, 13631205565, 0.25 +Res-1.3214, 13631205565, 0.25 +Res-1.3215, 13631205565, 0.25 +Res-1.3216, 13631205565, 0.25 +Res-1.3217, 13631205565, 0.25 +Res-1.3218, 13631205565, 0.25 +Res-1.3219, 13631205565, 0.25 +Res-1.3220, 13631205565, 0.25 +Res-1.3221, 13631205565, 0.25 +Res-1.3222, 13631205565, 0.25 +Res-1.3223, 13631205565, 0.25 +Res-1.3224, 13631205565, 0.25 +Res-1.3225, 13631205565, 0.25 +Res-1.3226, 13631205565, 0.25 +Res-1.3227, 13631205565, 0.25 +Res-1.3228, 13631205565, 0.25 +Res-1.3229, 13631205565, 0.25 +Res-1.3230, 13631205565, 0.25 +Res-1.3231, 13631205565, 0.25 +Res-1.3232, 13631205565, 0.25 +Res-1.3233, 13631205565, 0.25 +Res-1.3234, 13631205565, 0.25 +Res-1.3235, 13631205565, 0.25 +Res-1.3236, 13631205565, 0.25 +Res-1.3237, 13631205565, 0.25 +Res-1.3238, 13631205565, 0.25 +Res-1.3239, 13631205565, 0.25 +Res-1.3240, 13631205565, 0.25 +Res-1.3241, 13631205565, 0.25 +Res-1.3242, 13631205565, 0.25 +Res-1.3243, 13631205565, 0.25 +Res-1.3244, 13631205565, 0.25 +Res-1.3245, 13631205565, 0.25 +Res-1.3246, 13631205565, 0.25 +Res-1.3247, 13631205565, 0.25 +Res-1.3248, 13631205565, 0.25 +Res-1.3249, 13631205565, 0.25 +Res-1.3250, 13631205565, 0.25 +Res-1.3251, 13631205565, 0.25 +Res-1.3252, 13631205565, 0.25 +Res-1.3253, 13631205565, 0.25 +Res-1.3254, 13631205565, 0.25 +Res-1.3255, 13631205565, 0.25 +Res-1.3256, 13631205565, 0.25 +Res-1.3257, 13631205565, 0.25 +Res-1.3258, 13631205565, 0.25 +Res-1.3259, 13631205565, 0.25 +Res-1.3260, 13631205565, 0.25 +Res-1.3261, 13631205565, 0.25 +Res-1.3262, 13631205565, 0.25 +Res-1.3263, 13631205565, 0.25 +Res-1.3264, 13631205565, 0.25 +Res-1.3265, 13631205565, 0.25 +Res-1.3266, 13631205565, 0.25 +Res-1.3267, 13631205565, 0.25 +Res-1.3268, 13631205565, 0.25 +Res-1.3269, 13631205565, 0.25 +Res-1.3270, 13631205565, 0.25 +Res-1.3271, 13631205565, 0.25 +Res-1.3272, 13631205565, 0.25 +Res-1.3273, 13631205565, 0.25 +Res-1.3274, 13631205565, 0.25 +Res-1.3275, 13631205565, 0.25 +Res-1.3276, 13631205565, 0.25 +Res-1.3277, 13631205565, 0.25 +Res-1.3278, 13631205565, 0.25 +Res-1.3279, 13631205565, 0.25 +Res-1.3280, 13631205565, 0.25 +Res-1.3281, 13631205565, 0.25 +Res-1.3282, 13631205565, 0.25 +Res-1.3283, 13631205565, 0.25 +Res-1.3284, 13631205565, 0.25 +Res-1.3285, 13631205565, 0.25 +Res-1.3286, 13631205565, 0.25 +Res-1.3287, 13631205565, 0.25 +Res-1.3288, 13631205565, 0.25 +Res-1.3289, 13631205565, 0.25 +Res-1.3290, 13631205565, 0.25 +Res-1.3291, 13631205565, 0.25 +Res-1.3292, 13631205565, 0.25 +Res-1.3293, 13631205565, 0.25 +Res-1.3294, 13631205565, 0.25 +Res-1.3295, 13631205565, 0.25 +Res-1.3296, 13631205565, 0.25 +Res-1.3297, 13631205565, 0.25 +Res-1.3298, 13631205565, 0.25 +Res-1.3299, 13631205565, 0.25 +Res-1.3300, 13631205565, 0.25 +Res-1.3301, 13631205565, 0.25 +Res-1.3302, 13631205565, 0.25 +Res-1.3303, 13631205565, 0.25 +Res-1.3304, 13631205565, 0.25 +Res-1.3305, 13631205565, 0.25 +Res-1.3306, 13631205565, 0.25 +Res-1.3307, 13631205565, 0.25 +Res-1.3308, 13631205565, 0.25 +Res-1.3309, 13631205565, 0.25 +Res-1.3310, 13631205565, 0.25 +Res-1.3311, 13631205565, 0.25 +Res-1.3312, 13631205565, 0.25 +Res-1.3313, 13631205565, 0.25 +Res-1.3314, 13631205565, 0.25 +Res-1.3315, 13631205565, 0.25 +Res-1.3316, 13631205565, 0.25 +Res-1.3317, 13631205565, 0.25 +Res-1.3318, 13631205565, 0.25 +Res-1.3319, 13631205565, 0.25 +Res-1.3320, 13631205565, 0.25 +Res-1.3321, 13631205565, 0.25 +Res-1.3322, 13631205565, 0.25 +Res-1.3323, 13631205565, 0.25 +Res-1.3324, 13631205565, 0.25 +Res-1.3325, 13631205565, 0.25 +Res-1.3326, 13631205565, 0.25 +Res-1.3327, 13631205565, 0.25 +Res-1.3328, 13631205565, 0.25 +Res-1.3329, 13631205565, 0.25 +Res-1.3330, 13631205565, 0.25 +Res-1.3331, 13631205565, 0.25 +Res-1.3332, 13631205565, 0.25 +Res-1.3333, 13631205565, 0.25 +Res-1.3334, 13631205565, 0.25 +Res-1.3335, 13631205565, 0.25 +Res-1.3336, 13631205565, 0.25 +Res-1.3337, 13631205565, 0.25 +Res-1.3338, 13631205565, 0.25 +Res-1.3339, 13631205565, 0.25 +Res-1.3340, 13631205565, 0.25 +Res-1.3341, 13631205565, 0.25 +Res-1.3342, 13631205565, 0.25 +Res-1.3343, 13631205565, 0.25 +Res-1.3344, 13631205565, 0.25 +Res-1.3345, 13631205565, 0.25 +Res-1.3346, 13631205565, 0.25 +Res-1.3347, 13631205565, 0.25 +Res-1.3348, 13631205565, 0.25 +Res-1.3349, 13631205565, 0.25 +Res-1.3350, 13631205565, 0.25 +Res-1.3351, 13631205565, 0.25 +Res-1.3352, 13631205565, 0.25 +Res-1.3353, 13631205565, 0.25 +Res-1.3354, 13631205565, 0.25 +Res-1.3355, 13631205565, 0.25 +Res-1.3356, 13631205565, 0.25 +Res-1.3357, 13631205565, 0.25 +Res-1.3358, 13631205565, 0.25 +Res-1.3359, 13631205565, 0.25 +Res-1.3360, 13631205565, 0.25 +Res-1.3361, 13631205565, 0.25 +Res-1.3362, 13631205565, 0.25 +Res-1.3363, 13631205565, 0.25 +Res-1.3364, 13631205565, 0.25 +Res-1.3365, 13631205565, 0.25 +Res-1.3366, 13631205565, 0.25 +Res-1.3367, 13631205565, 0.25 +Res-1.3368, 13631205565, 0.25 +Res-1.3369, 13631205565, 0.25 +Res-1.3370, 13631205565, 0.25 +Res-1.3371, 13631205565, 0.25 +Res-1.3372, 13631205565, 0.25 +Res-1.3373, 13631205565, 0.25 +Res-1.3374, 13631205565, 0.25 +Res-1.3375, 13631205565, 0.25 +Res-1.3376, 13631205565, 0.25 +Res-1.3377, 13631205565, 0.25 +Res-1.3378, 13631205565, 0.25 +Res-1.3379, 13631205565, 0.25 +Res-1.3380, 13631205565, 0.25 +Res-1.3381, 13631205565, 0.25 +Res-1.3382, 13631205565, 0.25 +Res-1.3383, 13631205565, 0.25 +Res-1.3384, 13631205565, 0.25 +Res-1.3385, 13631205565, 0.25 +Res-1.3386, 13631205565, 0.25 +Res-1.3387, 13631205565, 0.25 +Res-1.3388, 13631205565, 0.25 +Res-1.3389, 13631205565, 0.25 +Res-1.3390, 13631205565, 0.25 +Res-1.3391, 13631205565, 0.25 +Res-1.3392, 13631205565, 0.25 +Res-1.3393, 13631205565, 0.25 +Res-1.3394, 13631205565, 0.25 +Res-1.3395, 13631205565, 0.25 +Res-1.3396, 13631205565, 0.25 +Res-1.3397, 13631205565, 0.25 +Res-1.3398, 13631205565, 0.25 +Res-1.3399, 13631205565, 0.25 +Res-1.3400, 13631205565, 0.25 +Res-1.3401, 13631205565, 0.25 +Res-1.3402, 13631205565, 0.25 +Res-1.3403, 13631205565, 0.25 +Res-1.3404, 13631205565, 0.25 +Res-1.3405, 13631205565, 0.25 +Res-1.3406, 13631205565, 0.25 +Res-1.3407, 13631205565, 0.25 +Res-1.3408, 13631205565, 0.25 +Res-1.3409, 13631205565, 0.25 +Res-1.3410, 13631205565, 0.25 +Res-1.3411, 13631205565, 0.25 +Res-1.3412, 13631205565, 0.25 +Res-1.3413, 13631205565, 0.25 +Res-1.3414, 13631205565, 0.25 +Res-1.3415, 13631205565, 0.25 +Res-1.3416, 13631205565, 0.25 +Res-1.3417, 13631205565, 0.25 +Res-1.3418, 13631205565, 0.25 +Res-1.3419, 13631205565, 0.25 +Res-1.3420, 13631205565, 0.25 +Res-1.3421, 13631205565, 0.25 +Res-1.3422, 13631205565, 0.25 +Res-1.3423, 13631205565, 0.25 +Res-1.3424, 13631205565, 0.25 +Res-1.3425, 13631205565, 0.25 +Res-1.3426, 13631205565, 0.25 +Res-1.3427, 13631205565, 0.25 +Res-1.3428, 13631205565, 0.25 +Res-1.3429, 13631205565, 0.25 +Res-1.3430, 13631205565, 0.25 +Res-1.3431, 13631205565, 0.25 +Res-1.3432, 13631205565, 0.25 +Res-1.3433, 13631205565, 0.25 +Res-1.3434, 13631205565, 0.25 +Res-1.3435, 13631205565, 0.25 +Res-1.3436, 13631205565, 0.25 +Res-1.3437, 13631205565, 0.25 +Res-1.3438, 13631205565, 0.25 +Res-1.3439, 13631205565, 0.25 +Res-1.3440, 13631205565, 0.25 +Res-1.3441, 13631205565, 0.25 +Res-1.3442, 13631205565, 0.25 +Res-1.3443, 13631205565, 0.25 +Res-1.3444, 13631205565, 0.25 +Res-1.3445, 13631205565, 0.25 +Res-1.3446, 13631205565, 0.25 +Res-1.3447, 13631205565, 0.25 +Res-1.3448, 13631205565, 0.25 +Res-1.3449, 13631205565, 0.25 +Res-1.3450, 13631205565, 0.25 +Res-1.3451, 13631205565, 0.25 +Res-1.3452, 13631205565, 0.25 +Res-1.3453, 13631205565, 0.25 +Res-1.3454, 13631205565, 0.25 +Res-1.3455, 13631205565, 0.25 +Res-1.3456, 13631205565, 0.25 +Res-1.3457, 16739025760, 0.25 +Res-1.3458, 16739025760, 0.25 +Res-1.3459, 16739025760, 0.25 +Res-1.3460, 16739025760, 0.25 +Res-1.3461, 16739025760, 0.25 +Res-1.3462, 16739025760, 0.25 +Res-1.3463, 16739025760, 0.25 +Res-1.3464, 16739025760, 0.25 +Res-1.3465, 16739025760, 0.25 +Res-1.3466, 16739025760, 0.25 +Res-1.3467, 16739025760, 0.25 +Res-1.3468, 16739025760, 0.25 +Res-1.3469, 16739025760, 0.25 +Res-1.3470, 16739025760, 0.25 +Res-1.3471, 16739025760, 0.25 +Res-1.3472, 16739025760, 0.25 +Res-1.3473, 16739025760, 0.25 +Res-1.3474, 16739025760, 0.25 +Res-1.3475, 16739025760, 0.25 +Res-1.3476, 16739025760, 0.25 +Res-1.3477, 16739025760, 0.25 +Res-1.3478, 16739025760, 0.25 +Res-1.3479, 16739025760, 0.25 +Res-1.3480, 16739025760, 0.25 +Res-1.3481, 16739025760, 0.25 +Res-1.3482, 16739025760, 0.25 +Res-1.3483, 16739025760, 0.25 +Res-1.3484, 16739025760, 0.25 +Res-1.3485, 16739025760, 0.25 +Res-1.3486, 16739025760, 0.25 +Res-1.3487, 16739025760, 0.25 +Res-1.3488, 16739025760, 0.25 +Res-1.3489, 16739025760, 0.25 +Res-1.3490, 16739025760, 0.25 +Res-1.3491, 16739025760, 0.25 +Res-1.3492, 16739025760, 0.25 +Res-1.3493, 16739025760, 0.25 +Res-1.3494, 16739025760, 0.25 +Res-1.3495, 16739025760, 0.25 +Res-1.3496, 16739025760, 0.25 +Res-1.3497, 16739025760, 0.25 +Res-1.3498, 16739025760, 0.25 +Res-1.3499, 16739025760, 0.25 +Res-1.3500, 16739025760, 0.25 +Res-1.3501, 16739025760, 0.25 +Res-1.3502, 16739025760, 0.25 +Res-1.3503, 16739025760, 0.25 +Res-1.3504, 16739025760, 0.25 +Res-1.3505, 16739025760, 0.25 +Res-1.3506, 16739025760, 0.25 +Res-1.3507, 16739025760, 0.25 +Res-1.3508, 16739025760, 0.25 +Res-1.3509, 16739025760, 0.25 +Res-1.3510, 16739025760, 0.25 +Res-1.3511, 16739025760, 0.25 +Res-1.3512, 16739025760, 0.25 +Res-1.3513, 16739025760, 0.25 +Res-1.3514, 16739025760, 0.25 +Res-1.3515, 16739025760, 0.25 +Res-1.3516, 16739025760, 0.25 +Res-1.3517, 16739025760, 0.25 +Res-1.3518, 16739025760, 0.25 +Res-1.3519, 16739025760, 0.25 +Res-1.3520, 16739025760, 0.25 +Res-1.3521, 16739025760, 0.25 +Res-1.3522, 16739025760, 0.25 +Res-1.3523, 16739025760, 0.25 +Res-1.3524, 16739025760, 0.25 +Res-1.3525, 16739025760, 0.25 +Res-1.3526, 16739025760, 0.25 +Res-1.3527, 16739025760, 0.25 +Res-1.3528, 16739025760, 0.25 +Res-1.3529, 16739025760, 0.25 +Res-1.3530, 16739025760, 0.25 +Res-1.3531, 16739025760, 0.25 +Res-1.3532, 16739025760, 0.25 +Res-1.3533, 16739025760, 0.25 +Res-1.3534, 16739025760, 0.25 +Res-1.3535, 16739025760, 0.25 +Res-1.3536, 16739025760, 0.25 +Res-1.3537, 16739025760, 0.25 +Res-1.3538, 16739025760, 0.25 +Res-1.3539, 16739025760, 0.25 +Res-1.3540, 16739025760, 0.25 +Res-1.3541, 16739025760, 0.25 +Res-1.3542, 16739025760, 0.25 +Res-1.3543, 16739025760, 0.25 +Res-1.3544, 16739025760, 0.25 +Res-1.3545, 16739025760, 0.25 +Res-1.3546, 16739025760, 0.25 +Res-1.3547, 16739025760, 0.25 +Res-1.3548, 16739025760, 0.25 +Res-1.3549, 16739025760, 0.25 +Res-1.3550, 16739025760, 0.25 +Res-1.3551, 16739025760, 0.25 +Res-1.3552, 16739025760, 0.25 +Res-1.3553, 16739025760, 0.25 +Res-1.3554, 16739025760, 0.25 +Res-1.3555, 16739025760, 0.25 +Res-1.3556, 16739025760, 0.25 +Res-1.3557, 16739025760, 0.25 +Res-1.3558, 16739025760, 0.25 +Res-1.3559, 16739025760, 0.25 +Res-1.3560, 16739025760, 0.25 +Res-1.3561, 16739025760, 0.25 +Res-1.3562, 16739025760, 0.25 +Res-1.3563, 16739025760, 0.25 +Res-1.3564, 16739025760, 0.25 +Res-1.3565, 16739025760, 0.25 +Res-1.3566, 16739025760, 0.25 +Res-1.3567, 16739025760, 0.25 +Res-1.3568, 16739025760, 0.25 +Res-1.3569, 16739025760, 0.25 +Res-1.3570, 16739025760, 0.25 +Res-1.3571, 16739025760, 0.25 +Res-1.3572, 16739025760, 0.25 +Res-1.3573, 16739025760, 0.25 +Res-1.3574, 16739025760, 0.25 +Res-1.3575, 16739025760, 0.25 +Res-1.3576, 16739025760, 0.25 +Res-1.3577, 16739025760, 0.25 +Res-1.3578, 16739025760, 0.25 +Res-1.3579, 16739025760, 0.25 +Res-1.3580, 16739025760, 0.25 +Res-1.3581, 16739025760, 0.25 +Res-1.3582, 16739025760, 0.25 +Res-1.3583, 16739025760, 0.25 +Res-1.3584, 16739025760, 0.25 +Res-1.3585, 16739025760, 0.25 +Res-1.3586, 16739025760, 0.25 +Res-1.3587, 16739025760, 0.25 +Res-1.3588, 16739025760, 0.25 +Res-1.3589, 16739025760, 0.25 +Res-1.3590, 16739025760, 0.25 +Res-1.3591, 16739025760, 0.25 +Res-1.3592, 16739025760, 0.25 +Res-1.3593, 16739025760, 0.25 +Res-1.3594, 16739025760, 0.25 +Res-1.3595, 16739025760, 0.25 +Res-1.3596, 16739025760, 0.25 +Res-1.3597, 16739025760, 0.25 +Res-1.3598, 16739025760, 0.25 +Res-1.3599, 16739025760, 0.25 +Res-1.3600, 16739025760, 0.25 +Res-1.3601, 16739025760, 0.25 +Res-1.3602, 16739025760, 0.25 +Res-1.3603, 16739025760, 0.25 +Res-1.3604, 16739025760, 0.25 +Res-1.3605, 16739025760, 0.25 +Res-1.3606, 16739025760, 0.25 +Res-1.3607, 16739025760, 0.25 +Res-1.3608, 16739025760, 0.25 +Res-1.3609, 16739025760, 0.25 +Res-1.3610, 16739025760, 0.25 +Res-1.3611, 16739025760, 0.25 +Res-1.3612, 16739025760, 0.25 +Res-1.3613, 16739025760, 0.25 +Res-1.3614, 16739025760, 0.25 +Res-1.3615, 16739025760, 0.25 +Res-1.3616, 16739025760, 0.25 +Res-1.3617, 16739025760, 0.25 +Res-1.3618, 16739025760, 0.25 +Res-1.3619, 16739025760, 0.25 +Res-1.3620, 16739025760, 0.25 +Res-1.3621, 16739025760, 0.25 +Res-1.3622, 16739025760, 0.25 +Res-1.3623, 16739025760, 0.25 +Res-1.3624, 16739025760, 0.25 +Res-1.3625, 16739025760, 0.25 +Res-1.3626, 16739025760, 0.25 +Res-1.3627, 16739025760, 0.25 +Res-1.3628, 16739025760, 0.25 +Res-1.3629, 16739025760, 0.25 +Res-1.3630, 16739025760, 0.25 +Res-1.3631, 16739025760, 0.25 +Res-1.3632, 16739025760, 0.25 +Res-1.3633, 16739025760, 0.25 +Res-1.3634, 16739025760, 0.25 +Res-1.3635, 16739025760, 0.25 +Res-1.3636, 16739025760, 0.25 +Res-1.3637, 16739025760, 0.25 +Res-1.3638, 16739025760, 0.25 +Res-1.3639, 16739025760, 0.25 +Res-1.3640, 16739025760, 0.25 +Res-1.3641, 16739025760, 0.25 +Res-1.3642, 16739025760, 0.25 +Res-1.3643, 16739025760, 0.25 +Res-1.3644, 16739025760, 0.25 +Res-1.3645, 16739025760, 0.25 +Res-1.3646, 16739025760, 0.25 +Res-1.3647, 16739025760, 0.25 +Res-1.3648, 16739025760, 0.25 +Res-1.3649, 16739025760, 0.25 +Res-1.3650, 16739025760, 0.25 +Res-1.3651, 16739025760, 0.25 +Res-1.3652, 16739025760, 0.25 +Res-1.3653, 16739025760, 0.25 +Res-1.3654, 16739025760, 0.25 +Res-1.3655, 16739025760, 0.25 +Res-1.3656, 16739025760, 0.25 +Res-1.3657, 16739025760, 0.25 +Res-1.3658, 16739025760, 0.25 +Res-1.3659, 16739025760, 0.25 +Res-1.3660, 16739025760, 0.25 +Res-1.3661, 16739025760, 0.25 +Res-1.3662, 16739025760, 0.25 +Res-1.3663, 16739025760, 0.25 +Res-1.3664, 16739025760, 0.25 +Res-1.3665, 16739025760, 0.25 +Res-1.3666, 16739025760, 0.25 +Res-1.3667, 16739025760, 0.25 +Res-1.3668, 16739025760, 0.25 +Res-1.3669, 16739025760, 0.25 +Res-1.3670, 16739025760, 0.25 +Res-1.3671, 16739025760, 0.25 +Res-1.3672, 16739025760, 0.25 +Res-1.3673, 16739025760, 0.25 +Res-1.3674, 16739025760, 0.25 +Res-1.3675, 16739025760, 0.25 +Res-1.3676, 16739025760, 0.25 +Res-1.3677, 16739025760, 0.25 +Res-1.3678, 16739025760, 0.25 +Res-1.3679, 16739025760, 0.25 +Res-1.3680, 16739025760, 0.25 +Res-1.3681, 16739025760, 0.25 +Res-1.3682, 16739025760, 0.25 +Res-1.3683, 16739025760, 0.25 +Res-1.3684, 16739025760, 0.25 +Res-1.3685, 16739025760, 0.25 +Res-1.3686, 16739025760, 0.25 +Res-1.3687, 16739025760, 0.25 +Res-1.3688, 16739025760, 0.25 +Res-1.3689, 16739025760, 0.25 +Res-1.3690, 16739025760, 0.25 +Res-1.3691, 16739025760, 0.25 +Res-1.3692, 16739025760, 0.25 +Res-1.3693, 16739025760, 0.25 +Res-1.3694, 16739025760, 0.25 +Res-1.3695, 16739025760, 0.25 +Res-1.3696, 16739025760, 0.25 +Res-1.3697, 16739025760, 0.25 +Res-1.3698, 16739025760, 0.25 +Res-1.3699, 16739025760, 0.25 +Res-1.3700, 16739025760, 0.25 +Res-1.3701, 16739025760, 0.25 +Res-1.3702, 16739025760, 0.25 +Res-1.3703, 16739025760, 0.25 +Res-1.3704, 16739025760, 0.25 +Res-1.3705, 16739025760, 0.25 +Res-1.3706, 16739025760, 0.25 +Res-1.3707, 16739025760, 0.25 +Res-1.3708, 16739025760, 0.25 +Res-1.3709, 16739025760, 0.25 +Res-1.3710, 16739025760, 0.25 +Res-1.3711, 16739025760, 0.25 +Res-1.3712, 16739025760, 0.25 +Res-1.3713, 16739025760, 0.25 +Res-1.3714, 16739025760, 0.25 +Res-1.3715, 16739025760, 0.25 +Res-1.3716, 16739025760, 0.25 +Res-1.3717, 16739025760, 0.25 +Res-1.3718, 16739025760, 0.25 +Res-1.3719, 16739025760, 0.25 +Res-1.3720, 16739025760, 0.25 +Res-1.3721, 16739025760, 0.25 +Res-1.3722, 16739025760, 0.25 +Res-1.3723, 16739025760, 0.25 +Res-1.3724, 16739025760, 0.25 +Res-1.3725, 16739025760, 0.25 +Res-1.3726, 16739025760, 0.25 +Res-1.3727, 16739025760, 0.25 +Res-1.3728, 16739025760, 0.25 +Res-1.3729, 16739025760, 0.25 +Res-1.3730, 16739025760, 0.25 +Res-1.3731, 16739025760, 0.25 +Res-1.3732, 16739025760, 0.25 +Res-1.3733, 16739025760, 0.25 +Res-1.3734, 16739025760, 0.25 +Res-1.3735, 16739025760, 0.25 +Res-1.3736, 16739025760, 0.25 +Res-1.3737, 16739025760, 0.25 +Res-1.3738, 16739025760, 0.25 +Res-1.3739, 16739025760, 0.25 +Res-1.3740, 16739025760, 0.25 +Res-1.3741, 16739025760, 0.25 +Res-1.3742, 16739025760, 0.25 +Res-1.3743, 16739025760, 0.25 +Res-1.3744, 16739025760, 0.25 +Res-1.3745, 17409132100, 0.25 +Res-1.3746, 17409132100, 0.25 +Res-1.3747, 17409132100, 0.25 +Res-1.3748, 17409132100, 0.25 +Res-1.3749, 17409132100, 0.25 +Res-1.3750, 17409132100, 0.25 +Res-1.3751, 17409132100, 0.25 +Res-1.3752, 17409132100, 0.25 +Res-1.3753, 17409132100, 0.25 +Res-1.3754, 17409132100, 0.25 +Res-1.3755, 17409132100, 0.25 +Res-1.3756, 17409132100, 0.25 +Res-1.3757, 17409132100, 0.25 +Res-1.3758, 17409132100, 0.25 +Res-1.3759, 17409132100, 0.25 +Res-1.3760, 17409132100, 0.25 +Res-1.3761, 17409132100, 0.25 +Res-1.3762, 17409132100, 0.25 +Res-1.3763, 17409132100, 0.25 +Res-1.3764, 17409132100, 0.25 +Res-1.3765, 17409132100, 0.25 +Res-1.3766, 17409132100, 0.25 +Res-1.3767, 17409132100, 0.25 +Res-1.3768, 17409132100, 0.25 +Res-1.3769, 17409132100, 0.25 +Res-1.3770, 17409132100, 0.25 +Res-1.3771, 17409132100, 0.25 +Res-1.3772, 17409132100, 0.25 +Res-1.3773, 17409132100, 0.25 +Res-1.3774, 17409132100, 0.25 +Res-1.3775, 17409132100, 0.25 +Res-1.3776, 17409132100, 0.25 +Res-1.3777, 17409132100, 0.25 +Res-1.3778, 17409132100, 0.25 +Res-1.3779, 17409132100, 0.25 +Res-1.3780, 17409132100, 0.25 +Res-1.3781, 17409132100, 0.25 +Res-1.3782, 17409132100, 0.25 +Res-1.3783, 17409132100, 0.25 +Res-1.3784, 17409132100, 0.25 +Res-1.3785, 17409132100, 0.25 +Res-1.3786, 17409132100, 0.25 +Res-1.3787, 17409132100, 0.25 +Res-1.3788, 17409132100, 0.25 +Res-1.3789, 17409132100, 0.25 +Res-1.3790, 17409132100, 0.25 +Res-1.3791, 17409132100, 0.25 +Res-1.3792, 17409132100, 0.25 +Res-1.3793, 17409132100, 0.25 +Res-1.3794, 17409132100, 0.25 +Res-1.3795, 17409132100, 0.25 +Res-1.3796, 17409132100, 0.25 +Res-1.3797, 17409132100, 0.25 +Res-1.3798, 17409132100, 0.25 +Res-1.3799, 17409132100, 0.25 +Res-1.3800, 17409132100, 0.25 +Res-1.3801, 17409132100, 0.25 +Res-1.3802, 17409132100, 0.25 +Res-1.3803, 17409132100, 0.25 +Res-1.3804, 17409132100, 0.25 +Res-1.3805, 17409132100, 0.25 +Res-1.3806, 17409132100, 0.25 +Res-1.3807, 17409132100, 0.25 +Res-1.3808, 17409132100, 0.25 +Res-1.3809, 17409132100, 0.25 +Res-1.3810, 17409132100, 0.25 +Res-1.3811, 17409132100, 0.25 +Res-1.3812, 17409132100, 0.25 +Res-1.3813, 17409132100, 0.25 +Res-1.3814, 17409132100, 0.25 +Res-1.3815, 17409132100, 0.25 +Res-1.3816, 17409132100, 0.25 +Res-1.3817, 17409132100, 0.25 +Res-1.3818, 17409132100, 0.25 +Res-1.3819, 17409132100, 0.25 +Res-1.3820, 17409132100, 0.25 +Res-1.3821, 17409132100, 0.25 +Res-1.3822, 17409132100, 0.25 +Res-1.3823, 17409132100, 0.25 +Res-1.3824, 17409132100, 0.25 +Res-1.3825, 17409132100, 0.25 +Res-1.3826, 17409132100, 0.25 +Res-1.3827, 17409132100, 0.25 +Res-1.3828, 17409132100, 0.25 +Res-1.3829, 17409132100, 0.25 +Res-1.3830, 17409132100, 0.25 +Res-1.3831, 17409132100, 0.25 +Res-1.3832, 17409132100, 0.25 +Res-1.3833, 17409132100, 0.25 +Res-1.3834, 17409132100, 0.25 +Res-1.3835, 17409132100, 0.25 +Res-1.3836, 17409132100, 0.25 +Res-1.3837, 17409132100, 0.25 +Res-1.3838, 17409132100, 0.25 +Res-1.3839, 17409132100, 0.25 +Res-1.3840, 17409132100, 0.25 +Res-1.3841, 17409132100, 0.25 +Res-1.3842, 17409132100, 0.25 +Res-1.3843, 17409132100, 0.25 +Res-1.3844, 17409132100, 0.25 +Res-1.3845, 17409132100, 0.25 +Res-1.3846, 17409132100, 0.25 +Res-1.3847, 17409132100, 0.25 +Res-1.3848, 17409132100, 0.25 +Res-1.3849, 17409132100, 0.25 +Res-1.3850, 17409132100, 0.25 +Res-1.3851, 17409132100, 0.25 +Res-1.3852, 17409132100, 0.25 +Res-1.3853, 17409132100, 0.25 +Res-1.3854, 17409132100, 0.25 +Res-1.3855, 17409132100, 0.25 +Res-1.3856, 17409132100, 0.25 +Res-1.3857, 17409132100, 0.25 +Res-1.3858, 17409132100, 0.25 +Res-1.3859, 17409132100, 0.25 +Res-1.3860, 17409132100, 0.25 +Res-1.3861, 17409132100, 0.25 +Res-1.3862, 17409132100, 0.25 +Res-1.3863, 17409132100, 0.25 +Res-1.3864, 17409132100, 0.25 +Res-1.3865, 17409132100, 0.25 +Res-1.3866, 17409132100, 0.25 +Res-1.3867, 17409132100, 0.25 +Res-1.3868, 17409132100, 0.25 +Res-1.3869, 17409132100, 0.25 +Res-1.3870, 17409132100, 0.25 +Res-1.3871, 17409132100, 0.25 +Res-1.3872, 17409132100, 0.25 +Res-1.3873, 17409132100, 0.25 +Res-1.3874, 17409132100, 0.25 +Res-1.3875, 17409132100, 0.25 +Res-1.3876, 17409132100, 0.25 +Res-1.3877, 17409132100, 0.25 +Res-1.3878, 17409132100, 0.25 +Res-1.3879, 17409132100, 0.25 +Res-1.3880, 17409132100, 0.25 +Res-1.3881, 17409132100, 0.25 +Res-1.3882, 17409132100, 0.25 +Res-1.3883, 17409132100, 0.25 +Res-1.3884, 17409132100, 0.25 +Res-1.3885, 17409132100, 0.25 +Res-1.3886, 17409132100, 0.25 +Res-1.3887, 17409132100, 0.25 +Res-1.3888, 17409132100, 0.25 +Res-1.3889, 17409132100, 0.25 +Res-1.3890, 17409132100, 0.25 +Res-1.3891, 17409132100, 0.25 +Res-1.3892, 17409132100, 0.25 +Res-1.3893, 17409132100, 0.25 +Res-1.3894, 17409132100, 0.25 +Res-1.3895, 17409132100, 0.25 +Res-1.3896, 17409132100, 0.25 +Res-1.3897, 17409132100, 0.25 +Res-1.3898, 17409132100, 0.25 +Res-1.3899, 17409132100, 0.25 +Res-1.3900, 17409132100, 0.25 +Res-1.3901, 17409132100, 0.25 +Res-1.3902, 17409132100, 0.25 +Res-1.3903, 17409132100, 0.25 +Res-1.3904, 17409132100, 0.25 +Res-1.3905, 17409132100, 0.25 +Res-1.3906, 17409132100, 0.25 +Res-1.3907, 17409132100, 0.25 +Res-1.3908, 17409132100, 0.25 +Res-1.3909, 17409132100, 0.25 +Res-1.3910, 17409132100, 0.25 +Res-1.3911, 17409132100, 0.25 +Res-1.3912, 17409132100, 0.25 +Res-1.3913, 17409132100, 0.25 +Res-1.3914, 17409132100, 0.25 +Res-1.3915, 17409132100, 0.25 +Res-1.3916, 17409132100, 0.25 +Res-1.3917, 17409132100, 0.25 +Res-1.3918, 17409132100, 0.25 +Res-1.3919, 17409132100, 0.25 +Res-1.3920, 17409132100, 0.25 +Res-1.3921, 17409132100, 0.25 +Res-1.3922, 17409132100, 0.25 +Res-1.3923, 17409132100, 0.25 +Res-1.3924, 17409132100, 0.25 +Res-1.3925, 17409132100, 0.25 +Res-1.3926, 17409132100, 0.25 +Res-1.3927, 17409132100, 0.25 +Res-1.3928, 17409132100, 0.25 +Res-1.3929, 17409132100, 0.25 +Res-1.3930, 17409132100, 0.25 +Res-1.3931, 17409132100, 0.25 +Res-1.3932, 17409132100, 0.25 +Res-1.3933, 17409132100, 0.25 +Res-1.3934, 17409132100, 0.25 +Res-1.3935, 17409132100, 0.25 +Res-1.3936, 17409132100, 0.25 +Res-1.3937, 17409132100, 0.25 +Res-1.3938, 17409132100, 0.25 +Res-1.3939, 17409132100, 0.25 +Res-1.3940, 17409132100, 0.25 +Res-1.3941, 17409132100, 0.25 +Res-1.3942, 17409132100, 0.25 +Res-1.3943, 17409132100, 0.25 +Res-1.3944, 17409132100, 0.25 +Res-1.3945, 17409132100, 0.25 +Res-1.3946, 17409132100, 0.25 +Res-1.3947, 17409132100, 0.25 +Res-1.3948, 17409132100, 0.25 +Res-1.3949, 17409132100, 0.25 +Res-1.3950, 17409132100, 0.25 +Res-1.3951, 17409132100, 0.25 +Res-1.3952, 17409132100, 0.25 +Res-1.3953, 17409132100, 0.25 +Res-1.3954, 17409132100, 0.25 +Res-1.3955, 17409132100, 0.25 +Res-1.3956, 17409132100, 0.25 +Res-1.3957, 17409132100, 0.25 +Res-1.3958, 17409132100, 0.25 +Res-1.3959, 17409132100, 0.25 +Res-1.3960, 17409132100, 0.25 +Res-1.3961, 17409132100, 0.25 +Res-1.3962, 17409132100, 0.25 +Res-1.3963, 17409132100, 0.25 +Res-1.3964, 17409132100, 0.25 +Res-1.3965, 17409132100, 0.25 +Res-1.3966, 17409132100, 0.25 +Res-1.3967, 17409132100, 0.25 +Res-1.3968, 17409132100, 0.25 +Res-1.3969, 17409132100, 0.25 +Res-1.3970, 17409132100, 0.25 +Res-1.3971, 17409132100, 0.25 +Res-1.3972, 17409132100, 0.25 +Res-1.3973, 17409132100, 0.25 +Res-1.3974, 17409132100, 0.25 +Res-1.3975, 17409132100, 0.25 +Res-1.3976, 17409132100, 0.25 +Res-1.3977, 17409132100, 0.25 +Res-1.3978, 17409132100, 0.25 +Res-1.3979, 17409132100, 0.25 +Res-1.3980, 17409132100, 0.25 +Res-1.3981, 17409132100, 0.25 +Res-1.3982, 17409132100, 0.25 +Res-1.3983, 17409132100, 0.25 +Res-1.3984, 17409132100, 0.25 +Res-1.3985, 17409132100, 0.25 +Res-1.3986, 17409132100, 0.25 +Res-1.3987, 17409132100, 0.25 +Res-1.3988, 17409132100, 0.25 +Res-1.3989, 17409132100, 0.25 +Res-1.3990, 17409132100, 0.25 +Res-1.3991, 17409132100, 0.25 +Res-1.3992, 17409132100, 0.25 +Res-1.3993, 17409132100, 0.25 +Res-1.3994, 17409132100, 0.25 +Res-1.3995, 17409132100, 0.25 +Res-1.3996, 17409132100, 0.25 +Res-1.3997, 17409132100, 0.25 +Res-1.3998, 17409132100, 0.25 +Res-1.3999, 17409132100, 0.25 +Res-1.4000, 17409132100, 0.25 +Res-1.4001, 17409132100, 0.25 +Res-1.4002, 17409132100, 0.25 +Res-1.4003, 17409132100, 0.25 +Res-1.4004, 17409132100, 0.25 +Res-1.4005, 17409132100, 0.25 +Res-1.4006, 17409132100, 0.25 +Res-1.4007, 17409132100, 0.25 +Res-1.4008, 17409132100, 0.25 +Res-1.4009, 17409132100, 0.25 +Res-1.4010, 17409132100, 0.25 +Res-1.4011, 17409132100, 0.25 +Res-1.4012, 17409132100, 0.25 +Res-1.4013, 17409132100, 0.25 +Res-1.4014, 17409132100, 0.25 +Res-1.4015, 17409132100, 0.25 +Res-1.4016, 17409132100, 0.25 +Res-1.4017, 17409132100, 0.25 +Res-1.4018, 17409132100, 0.25 +Res-1.4019, 17409132100, 0.25 +Res-1.4020, 17409132100, 0.25 +Res-1.4021, 17409132100, 0.25 +Res-1.4022, 17409132100, 0.25 +Res-1.4023, 17409132100, 0.25 +Res-1.4024, 17409132100, 0.25 +Res-1.4025, 17409132100, 0.25 +Res-1.4026, 17409132100, 0.25 +Res-1.4027, 17409132100, 0.25 +Res-1.4028, 17409132100, 0.25 +Res-1.4029, 17409132100, 0.25 +Res-1.4030, 17409132100, 0.25 +Res-1.4031, 17409132100, 0.25 +Res-1.4032, 17409132100, 0.25 +Res-1.4033, 13250853676.3636, 0.25 +Res-1.4034, 13250853676.3636, 0.25 +Res-1.4035, 13250853676.3636, 0.25 +Res-1.4036, 13250853676.3636, 0.25 +Res-1.4037, 13250853676.3636, 0.25 +Res-1.4038, 13250853676.3636, 0.25 +Res-1.4039, 13250853676.3636, 0.25 +Res-1.4040, 13250853676.3636, 0.25 +Res-1.4041, 13250853676.3636, 0.25 +Res-1.4042, 13250853676.3636, 0.25 +Res-1.4043, 13250853676.3636, 0.25 +Res-1.4044, 13250853676.3636, 0.25 +Res-1.4045, 13250853676.3636, 0.25 +Res-1.4046, 13250853676.3636, 0.25 +Res-1.4047, 13250853676.3636, 0.25 +Res-1.4048, 13250853676.3636, 0.25 +Res-1.4049, 13250853676.3636, 0.25 +Res-1.4050, 13250853676.3636, 0.25 +Res-1.4051, 13250853676.3636, 0.25 +Res-1.4052, 13250853676.3636, 0.25 +Res-1.4053, 13250853676.3636, 0.25 +Res-1.4054, 13250853676.3636, 0.25 +Res-1.4055, 13250853676.3636, 0.25 +Res-1.4056, 13250853676.3636, 0.25 +Res-1.4057, 13250853676.3636, 0.25 +Res-1.4058, 13250853676.3636, 0.25 +Res-1.4059, 13250853676.3636, 0.25 +Res-1.4060, 13250853676.3636, 0.25 +Res-1.4061, 13250853676.3636, 0.25 +Res-1.4062, 13250853676.3636, 0.25 +Res-1.4063, 13250853676.3636, 0.25 +Res-1.4064, 13250853676.3636, 0.25 +Res-1.4065, 13250853676.3636, 0.25 +Res-1.4066, 13250853676.3636, 0.25 +Res-1.4067, 13250853676.3636, 0.25 +Res-1.4068, 13250853676.3636, 0.25 +Res-1.4069, 13250853676.3636, 0.25 +Res-1.4070, 13250853676.3636, 0.25 +Res-1.4071, 13250853676.3636, 0.25 +Res-1.4072, 13250853676.3636, 0.25 +Res-1.4073, 13250853676.3636, 0.25 +Res-1.4074, 13250853676.3636, 0.25 +Res-1.4075, 13250853676.3636, 0.25 +Res-1.4076, 13250853676.3636, 0.25 +Res-1.4077, 13250853676.3636, 0.25 +Res-1.4078, 13250853676.3636, 0.25 +Res-1.4079, 13250853676.3636, 0.25 +Res-1.4080, 13250853676.3636, 0.25 +Res-1.4081, 13250853676.3636, 0.25 +Res-1.4082, 13250853676.3636, 0.25 +Res-1.4083, 13250853676.3636, 0.25 +Res-1.4084, 13250853676.3636, 0.25 +Res-1.4085, 13250853676.3636, 0.25 +Res-1.4086, 13250853676.3636, 0.25 +Res-1.4087, 13250853676.3636, 0.25 +Res-1.4088, 13250853676.3636, 0.25 +Res-1.4089, 13250853676.3636, 0.25 +Res-1.4090, 13250853676.3636, 0.25 +Res-1.4091, 13250853676.3636, 0.25 +Res-1.4092, 13250853676.3636, 0.25 +Res-1.4093, 13250853676.3636, 0.25 +Res-1.4094, 13250853676.3636, 0.25 +Res-1.4095, 13250853676.3636, 0.25 +Res-1.4096, 13250853676.3636, 0.25 +Res-1.4097, 13250853676.3636, 0.25 +Res-1.4098, 13250853676.3636, 0.25 +Res-1.4099, 13250853676.3636, 0.25 +Res-1.4100, 13250853676.3636, 0.25 +Res-1.4101, 13250853676.3636, 0.25 +Res-1.4102, 13250853676.3636, 0.25 +Res-1.4103, 13250853676.3636, 0.25 +Res-1.4104, 13250853676.3636, 0.25 +Res-1.4105, 13250853676.3636, 0.25 +Res-1.4106, 13250853676.3636, 0.25 +Res-1.4107, 13250853676.3636, 0.25 +Res-1.4108, 13250853676.3636, 0.25 +Res-1.4109, 13250853676.3636, 0.25 +Res-1.4110, 13250853676.3636, 0.25 +Res-1.4111, 13250853676.3636, 0.25 +Res-1.4112, 13250853676.3636, 0.25 +Res-1.4113, 13250853676.3636, 0.25 +Res-1.4114, 13250853676.3636, 0.25 +Res-1.4115, 13250853676.3636, 0.25 +Res-1.4116, 13250853676.3636, 0.25 +Res-1.4117, 13250853676.3636, 0.25 +Res-1.4118, 13250853676.3636, 0.25 +Res-1.4119, 13250853676.3636, 0.25 +Res-1.4120, 13250853676.3636, 0.25 +Res-1.4121, 13250853676.3636, 0.25 +Res-1.4122, 13250853676.3636, 0.25 +Res-1.4123, 13250853676.3636, 0.25 +Res-1.4124, 13250853676.3636, 0.25 +Res-1.4125, 13250853676.3636, 0.25 +Res-1.4126, 13250853676.3636, 0.25 +Res-1.4127, 13250853676.3636, 0.25 +Res-1.4128, 13250853676.3636, 0.25 +Res-1.4129, 13250853676.3636, 0.25 +Res-1.4130, 13250853676.3636, 0.25 +Res-1.4131, 13250853676.3636, 0.25 +Res-1.4132, 13250853676.3636, 0.25 +Res-1.4133, 13250853676.3636, 0.25 +Res-1.4134, 13250853676.3636, 0.25 +Res-1.4135, 13250853676.3636, 0.25 +Res-1.4136, 13250853676.3636, 0.25 +Res-1.4137, 13250853676.3636, 0.25 +Res-1.4138, 13250853676.3636, 0.25 +Res-1.4139, 13250853676.3636, 0.25 +Res-1.4140, 13250853676.3636, 0.25 +Res-1.4141, 13250853676.3636, 0.25 +Res-1.4142, 13250853676.3636, 0.25 +Res-1.4143, 13250853676.3636, 0.25 +Res-1.4144, 13250853676.3636, 0.25 +Res-1.4145, 13250853676.3636, 0.25 +Res-1.4146, 13250853676.3636, 0.25 +Res-1.4147, 13250853676.3636, 0.25 +Res-1.4148, 13250853676.3636, 0.25 +Res-1.4149, 13250853676.3636, 0.25 +Res-1.4150, 13250853676.3636, 0.25 +Res-1.4151, 13250853676.3636, 0.25 +Res-1.4152, 13250853676.3636, 0.25 +Res-1.4153, 13250853676.3636, 0.25 +Res-1.4154, 13250853676.3636, 0.25 +Res-1.4155, 13250853676.3636, 0.25 +Res-1.4156, 13250853676.3636, 0.25 +Res-1.4157, 13250853676.3636, 0.25 +Res-1.4158, 13250853676.3636, 0.25 +Res-1.4159, 13250853676.3636, 0.25 +Res-1.4160, 13250853676.3636, 0.25 +Res-1.4161, 13250853676.3636, 0.25 +Res-1.4162, 13250853676.3636, 0.25 +Res-1.4163, 13250853676.3636, 0.25 +Res-1.4164, 13250853676.3636, 0.25 +Res-1.4165, 13250853676.3636, 0.25 +Res-1.4166, 13250853676.3636, 0.25 +Res-1.4167, 13250853676.3636, 0.25 +Res-1.4168, 13250853676.3636, 0.25 +Res-1.4169, 13250853676.3636, 0.25 +Res-1.4170, 13250853676.3636, 0.25 +Res-1.4171, 13250853676.3636, 0.25 +Res-1.4172, 13250853676.3636, 0.25 +Res-1.4173, 13250853676.3636, 0.25 +Res-1.4174, 13250853676.3636, 0.25 +Res-1.4175, 13250853676.3636, 0.25 +Res-1.4176, 13250853676.3636, 0.25 +Res-1.4177, 13250853676.3636, 0.25 +Res-1.4178, 13250853676.3636, 0.25 +Res-1.4179, 13250853676.3636, 0.25 +Res-1.4180, 13250853676.3636, 0.25 +Res-1.4181, 13250853676.3636, 0.25 +Res-1.4182, 13250853676.3636, 0.25 +Res-1.4183, 13250853676.3636, 0.25 +Res-1.4184, 13250853676.3636, 0.25 +Res-1.4185, 13250853676.3636, 0.25 +Res-1.4186, 13250853676.3636, 0.25 +Res-1.4187, 13250853676.3636, 0.25 +Res-1.4188, 13250853676.3636, 0.25 +Res-1.4189, 13250853676.3636, 0.25 +Res-1.4190, 13250853676.3636, 0.25 +Res-1.4191, 13250853676.3636, 0.25 +Res-1.4192, 13250853676.3636, 0.25 +Res-1.4193, 13250853676.3636, 0.25 +Res-1.4194, 13250853676.3636, 0.25 +Res-1.4195, 13250853676.3636, 0.25 +Res-1.4196, 13250853676.3636, 0.25 +Res-1.4197, 13250853676.3636, 0.25 +Res-1.4198, 13250853676.3636, 0.25 +Res-1.4199, 13250853676.3636, 0.25 +Res-1.4200, 13250853676.3636, 0.25 +Res-1.4201, 13250853676.3636, 0.25 +Res-1.4202, 13250853676.3636, 0.25 +Res-1.4203, 13250853676.3636, 0.25 +Res-1.4204, 13250853676.3636, 0.25 +Res-1.4205, 13250853676.3636, 0.25 +Res-1.4206, 13250853676.3636, 0.25 +Res-1.4207, 13250853676.3636, 0.25 +Res-1.4208, 13250853676.3636, 0.25 +Res-1.4209, 13250853676.3636, 0.25 +Res-1.4210, 13250853676.3636, 0.25 +Res-1.4211, 13250853676.3636, 0.25 +Res-1.4212, 13250853676.3636, 0.25 +Res-1.4213, 13250853676.3636, 0.25 +Res-1.4214, 13250853676.3636, 0.25 +Res-1.4215, 13250853676.3636, 0.25 +Res-1.4216, 13250853676.3636, 0.25 +Res-1.4217, 13250853676.3636, 0.25 +Res-1.4218, 13250853676.3636, 0.25 +Res-1.4219, 13250853676.3636, 0.25 +Res-1.4220, 13250853676.3636, 0.25 +Res-1.4221, 13250853676.3636, 0.25 +Res-1.4222, 13250853676.3636, 0.25 +Res-1.4223, 13250853676.3636, 0.25 +Res-1.4224, 13250853676.3636, 0.25 +Res-1.4225, 13250853676.3636, 0.25 +Res-1.4226, 13250853676.3636, 0.25 +Res-1.4227, 13250853676.3636, 0.25 +Res-1.4228, 13250853676.3636, 0.25 +Res-1.4229, 13250853676.3636, 0.25 +Res-1.4230, 13250853676.3636, 0.25 +Res-1.4231, 13250853676.3636, 0.25 +Res-1.4232, 13250853676.3636, 0.25 +Res-1.4233, 13250853676.3636, 0.25 +Res-1.4234, 13250853676.3636, 0.25 +Res-1.4235, 13250853676.3636, 0.25 +Res-1.4236, 13250853676.3636, 0.25 +Res-1.4237, 13250853676.3636, 0.25 +Res-1.4238, 13250853676.3636, 0.25 +Res-1.4239, 13250853676.3636, 0.25 +Res-1.4240, 13250853676.3636, 0.25 +Res-1.4241, 13250853676.3636, 0.25 +Res-1.4242, 13250853676.3636, 0.25 +Res-1.4243, 13250853676.3636, 0.25 +Res-1.4244, 13250853676.3636, 0.25 +Res-1.4245, 13250853676.3636, 0.25 +Res-1.4246, 13250853676.3636, 0.25 +Res-1.4247, 13250853676.3636, 0.25 +Res-1.4248, 13250853676.3636, 0.25 +Res-1.4249, 13250853676.3636, 0.25 +Res-1.4250, 13250853676.3636, 0.25 +Res-1.4251, 13250853676.3636, 0.25 +Res-1.4252, 13250853676.3636, 0.25 +Res-1.4253, 13250853676.3636, 0.25 +Res-1.4254, 13250853676.3636, 0.25 +Res-1.4255, 13250853676.3636, 0.25 +Res-1.4256, 13250853676.3636, 0.25 +Res-1.4257, 13250853676.3636, 0.25 +Res-1.4258, 13250853676.3636, 0.25 +Res-1.4259, 13250853676.3636, 0.25 +Res-1.4260, 13250853676.3636, 0.25 +Res-1.4261, 13250853676.3636, 0.25 +Res-1.4262, 13250853676.3636, 0.25 +Res-1.4263, 13250853676.3636, 0.25 +Res-1.4264, 13250853676.3636, 0.25 +Res-1.4265, 13250853676.3636, 0.25 +Res-1.4266, 13250853676.3636, 0.25 +Res-1.4267, 13250853676.3636, 0.25 +Res-1.4268, 13250853676.3636, 0.25 +Res-1.4269, 13250853676.3636, 0.25 +Res-1.4270, 13250853676.3636, 0.25 +Res-1.4271, 13250853676.3636, 0.25 +Res-1.4272, 13250853676.3636, 0.25 +Res-1.4273, 13250853676.3636, 0.25 +Res-1.4274, 13250853676.3636, 0.25 +Res-1.4275, 13250853676.3636, 0.25 +Res-1.4276, 13250853676.3636, 0.25 +Res-1.4277, 13250853676.3636, 0.25 +Res-1.4278, 13250853676.3636, 0.25 +Res-1.4279, 13250853676.3636, 0.25 +Res-1.4280, 13250853676.3636, 0.25 +Res-1.4281, 13250853676.3636, 0.25 +Res-1.4282, 13250853676.3636, 0.25 +Res-1.4283, 13250853676.3636, 0.25 +Res-1.4284, 13250853676.3636, 0.25 +Res-1.4285, 13250853676.3636, 0.25 +Res-1.4286, 13250853676.3636, 0.25 +Res-1.4287, 13250853676.3636, 0.25 +Res-1.4288, 13250853676.3636, 0.25 +Res-1.4289, 13250853676.3636, 0.25 +Res-1.4290, 13250853676.3636, 0.25 +Res-1.4291, 13250853676.3636, 0.25 +Res-1.4292, 13250853676.3636, 0.25 +Res-1.4293, 13250853676.3636, 0.25 +Res-1.4294, 13250853676.3636, 0.25 +Res-1.4295, 13250853676.3636, 0.25 +Res-1.4296, 13250853676.3636, 0.25 +Res-1.4297, 13250853676.3636, 0.25 +Res-1.4298, 13250853676.3636, 0.25 +Res-1.4299, 13250853676.3636, 0.25 +Res-1.4300, 13250853676.3636, 0.25 +Res-1.4301, 13250853676.3636, 0.25 +Res-1.4302, 13250853676.3636, 0.25 +Res-1.4303, 13250853676.3636, 0.25 +Res-1.4304, 13250853676.3636, 0.25 +Res-1.4305, 13250853676.3636, 0.25 +Res-1.4306, 13250853676.3636, 0.25 +Res-1.4307, 13250853676.3636, 0.25 +Res-1.4308, 13250853676.3636, 0.25 +Res-1.4309, 13250853676.3636, 0.25 +Res-1.4310, 13250853676.3636, 0.25 +Res-1.4311, 13250853676.3636, 0.25 +Res-1.4312, 13250853676.3636, 0.25 +Res-1.4313, 13250853676.3636, 0.25 +Res-1.4314, 13250853676.3636, 0.25 +Res-1.4315, 13250853676.3636, 0.25 +Res-1.4316, 13250853676.3636, 0.25 +Res-1.4317, 13250853676.3636, 0.25 +Res-1.4318, 13250853676.3636, 0.25 +Res-1.4319, 13250853676.3636, 0.25 +Res-1.4320, 13250853676.3636, 0.25 \ No newline at end of file diff --git a/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE_error.inp b/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE_error.inp new file mode 100644 index 0000000000..9d59069643 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RifElementPropertyTableReader/ELASTIC_TABLE_error.inp @@ -0,0 +1,4326 @@ +** ELASTIC SETTING FOR EACH ELEMENT +*Distribution Table, name=RSV_Res-1_Elastic_Table +MODULUS, RATIO +*Distribution, name=RSV_Res-1_ELASTICS, location=ELEMENT, Table=RSV_Res-1_Elastic_Table +** Description: Element-by-Element Elastic properties +, 2. +Res-1.210, 11198814808.2538, 0.19041 +Res-1.209, 11207002032.1436, 0.19063 +Res-1.208, 11222989223.0933, 0.19104 +Res-1.207, 11202549454.349, 0.19051 +Res-1.206, 11201018277.2135, 0.19047 +Res-1.205, 11199452457.2289, 0.19043 +Res-1.204, 11211165066.8084, 0.19073 +Res-1.203, 11211396173.5037, 0.19074 +Res-1.202, 11222952734.6236, 0.19104 +Res-1.201, 11212868930.9558, 0.19078, 1234 +Res-1.200, 11211827541.4726, 0.19075 +Res-1.199, 11223293389.2923, 0.19105 +Res-1.198, 11213461278.5775, 0.19079 +Res-1.197, 11212227164.9418, 0.19076 +Res-1.196, 11222290540.4229, 0.19102 +Res-1.195, 11209591214.3024, 0.19069 +Res-1.194, 11227448401.9317, 0.19116 +Res-1.193, 11218701110.7378, 0.19093 +Res-1.192, 11212290325.2544, 0.19076 +Res-1.191, 11218462357.8173, 0.19092 +Res-1.190, 11210219341.6298, 0.19071 +Res-1.189, 11217410056.2303, 0.1909 +Res-1.188, 11224201059.3023, 0.19107 +Res-1.187, 11200886151.7449, 0.19047 +Res-1.186, 11209070545.6809, 0.19068 +Res-1.185, 11208525302.8397, 0.19067 +Res-1.184, 11208029443.911, 0.19065 +Res-1.183, 11205956268.7052, 0.1906 +Res-1.182, 11203032646.1219, 0.19052 +Res-1.181, 11212779732.2076, 0.19078 +Res-1.180, 11223694446.8691, 0.19106 +Res-1.179, 11216849610.9899, 0.19088 +Res-1.178, 11203666189.6647, 0.19054 +Res-1.177, 11223110950.263, 0.19104 +Res-1.176, 11218366316.8438, 0.19092 +Res-1.175, 11199308629.4248, 0.19043 +Res-1.174, 11204107404.8935, 0.19055 +Res-1.173, 11221591221.1029, 0.191 +Res-1.172, 11198310779.2562, 0.1904 +Res-1.171, 11226329567.8196, 0.19113 +Res-1.170, 11215508691.1034, 0.19085 +Res-1.169, 11216141613.3394, 0.19086 +Res-1.168, 11216262209.1321, 0.19087 +Res-1.167, 11224888572.4446, 0.19109 +Res-1.166, 11215543405.3856, 0.19085 +Res-1.165, 11209879234.5934, 0.1907 +Res-1.164, 11198661683.8392, 0.19041 +Res-1.163, 11221659419.8899, 0.19101 +Res-1.162, 11217644939.1724, 0.1909 +Res-1.161, 11220272938.4351, 0.19097 +Res-1.160, 11219517563.9646, 0.19095 +Res-1.159, 11222601901.6144, 0.19103 +Res-1.158, 11227551848.7474, 0.19116 +Res-1.157, 11214792538.2525, 0.19083 +Res-1.156, 11220949297.0432, 0.19099 +Res-1.155, 11202237002.5308, 0.1905 +Res-1.154, 11212422032.9539, 0.19077 +Res-1.153, 11200876863.9619, 0.19047 +Res-1.152, 11199085093.8181, 0.19042 +Res-1.151, 11210721102.6531, 0.19072 +Res-1.150, 11224677747.0098, 0.19108 +Res-1.149, 11200505347.0814, 0.19046 +Res-1.148, 11210477709.1165, 0.19072 +Res-1.147, 11201790929.0597, 0.19049 +Res-1.146, 11215538617.2144, 0.19085 +Res-1.145, 11210067552.0255, 0.19071 +Res-1.144, 11226119663.3263, 0.19112 +Res-1.143, 11200558079.1704, 0.19046 +Res-1.142, 11209025034.8169, 0.19068 +Res-1.141, 11225111056.7698, 0.1911 +Res-1.140, 11207283822.5306, 0.19063 +Res-1.139, 11216396568.854, 0.19087 +Res-1.138, 11225696853.721, 0.19111 +Res-1.137, 11221821540.0987, 0.19101 +Res-1.136, 11220794943.2728, 0.19098 +Res-1.135, 11221457514.5243, 0.191 +Res-1.134, 11207200873.1928, 0.19063 +Res-1.133, 11205669058.0237, 0.19059 +Res-1.132, 11211863163.8498, 0.19075 +Res-1.131, 11211677567.1763, 0.19075 +Res-1.130, 11209369356.3868, 0.19069 +Res-1.129, 11198739894.387, 0.19041 +Res-1.128, 11209258875.0902, 0.19068 +Res-1.127, 11210271135.3011, 0.19071 +Res-1.126, 11201024868.4708, 0.19047 +Res-1.125, 11211157882.0769, 0.19073 +Res-1.124, 11218203554.1602, 0.19092 +Res-1.123, 11199588193.2274, 0.19043 +Res-1.122, 11215076550.207, 0.19084 +Res-1.121, 11210238801.7044, 0.19071 +Res-1.120, 11206683700.3163, 0.19062 +Res-1.119, 11207926137.5337, 0.19065 +Res-1.118, 11221872987.408, 0.19101 +Res-1.117, 11225794932.4499, 0.19111 +Res-1.116, 11220026437.0079, 0.19096 +Res-1.115, 11202273250.9302, 0.1905 +Res-1.114, 11211501846.5387, 0.19074 +Res-1.113, 11214337327.7756, 0.19082 +Res-1.112, 11215364146.9954, 0.19084 +Res-1.111, 11205074849.7447, 0.19058 +Res-1.110, 11208670822.9857, 0.19067 +Res-1.109, 11208556443.0933, 0.19067 +Res-1.108, 11223420197.8288, 0.19105 +Res-1.107, 11215302199.0174, 0.19084 +Res-1.106, 11213126346.6531, 0.19078 +Res-1.105, 11217009099.524, 0.19089 +Res-1.104, 11213865938.8012, 0.1908 +Res-1.103, 11217994113.817, 0.19091 +Res-1.102, 11204980205.137, 0.19057 +Res-1.101, 11216751463.2051, 0.19088 +Res-1.100, 11206944834.8203, 0.19062 +Res-1.99, 11213849177.9825, 0.1908 +Res-1.98, 11206416870.416, 0.19061 +Res-1.97, 11200174867.7047, 0.19045 +Res-1.96, 11212761772.6524, 0.19078 +Res-1.95, 11201207924.2968, 0.19048 +Res-1.94, 11221710568.74, 0.19101 +Res-1.93, 11202102792.6819, 0.1905 +Res-1.92, 11225762937.338, 0.19111 +Res-1.91, 11214313983.2092, 0.19082 +Res-1.90, 11227579653.6727, 0.19116 +Res-1.89, 11204048097.8306, 0.19055 +Res-1.88, 11222876467.402, 0.19104 +Res-1.87, 11223289800.353, 0.19105 +Res-1.86, 11222804686.0695, 0.19104 +Res-1.85, 11207547340.3029, 0.19064 +Res-1.84, 11221843076.207, 0.19101 +Res-1.83, 11219320112.1476, 0.19095 +Res-1.82, 11205244070.1516, 0.19058 +Res-1.81, 11213243977.9053, 0.19079 +Res-1.80, 11201016479.5973, 0.19047 +Res-1.79, 11226505681.5926, 0.19113 +Res-1.78, 11215171119.692, 0.19084 +Res-1.77, 11211115372.3329, 0.19073 +Res-1.76, 11211330613.8706, 0.19074 +Res-1.75, 11203582318.1003, 0.19054 +Res-1.74, 11224464824.7228, 0.19108 +Res-1.73, 11219259679.3117, 0.19094 +Res-1.72, 11228171914.0288, 0.19117 +Res-1.71, 11199769172.3056, 0.19044 +Res-1.70, 11205305168.6479, 0.19058 +Res-1.69, 11205754113.792, 0.19059 +Res-1.68, 11224082931.2902, 0.19107 +Res-1.67, 11217787662.1013, 0.19091 +Res-1.66, 11223709998.4367, 0.19106 +Res-1.65, 11213376573.6608, 0.19079 +Res-1.64, 11204036715.6354, 0.19055 +Res-1.63, 11209300792.2263, 0.19069 +Res-1.62, 11207638372.4461, 0.19064 +Res-1.61, 11209100486.9499, 0.19068 +Res-1.60, 11206412378.2822, 0.19061 +Res-1.59, 11202503021.4388, 0.19051 +Res-1.58, 11209477740.8993, 0.19069 +Res-1.57, 11222835193.1853, 0.19104 +Res-1.56, 11211083938.9801, 0.19073 +Res-1.55, 11223344531.5666, 0.19105 +Res-1.54, 11201118643.7157, 0.19047 +Res-1.53, 11225922912.0918, 0.19112 +Res-1.52, 11218110503.2337, 0.19091 +Res-1.51, 11210865400.1882, 0.19073 +Res-1.50, 11214019778.1402, 0.19081 +Res-1.49, 11204136459.2628, 0.19055 +Res-1.48, 11212356777.9461, 0.19076 +Res-1.47, 11221437772.4942, 0.191 +Res-1.46, 11207006823.5308, 0.19063 +Res-1.45, 11223791045.7213, 0.19106 +Res-1.44, 11208544765.5071, 0.19067 +Res-1.43, 11209267557.9369, 0.19068 +Res-1.42, 11221377947.9732, 0.191 +Res-1.41, 11222786142.4926, 0.19104 +Res-1.40, 11223261088.8025, 0.19105 +Res-1.39, 11223761737.1688, 0.19106 +Res-1.38, 11222172394.6506, 0.19102 +Res-1.37, 11199653513.7877, 0.19044 +Res-1.36, 11227759636.7716, 0.19116 +Res-1.35, 11199577106.677, 0.19043 +Res-1.34, 11227466938.7063, 0.19116 +Res-1.33, 11199169594.335, 0.19042 +Res-1.32, 11219335070.7259, 0.19095 +Res-1.31, 11212527697.4628, 0.19077 +Res-1.30, 11202428428.8604, 0.19051 +Res-1.29, 11201408054.3293, 0.19048 +Res-1.28, 11222583357.7417, 0.19103 +Res-1.27, 11208466914.6587, 0.19066 +Res-1.26, 11200064606.1293, 0.19045 +Res-1.25, 11199032055.973, 0.19042 +Res-1.24, 11225007889.1195, 0.19109 +Res-1.23, 11222886038.2157, 0.19104 +Res-1.22, 11205896670.776, 0.1906 +Res-1.21, 11226756542.3277, 0.19114 +Res-1.20, 11226104114.7074, 0.19112 +Res-1.19, 11213604048.4849, 0.1908 +Res-1.18, 11202801387.3778, 0.19052 +Res-1.17, 11198392587.9363, 0.1904 +Res-1.16, 11228104049.1491, 0.19117 +Res-1.15, 11212003257.6089, 0.19076 +Res-1.14, 11202458086.203, 0.19051 +Res-1.13, 11201026366.4833, 0.19047 +Res-1.12, 11202937387.2003, 0.19052 +Res-1.11, 11201932931.3114, 0.19049 +Res-1.10, 11205907751.8191, 0.1906 +Res-1.9, 11224722304.7336, 0.19109 +Res-1.8, 11213008714.3126, 0.19078 +Res-1.7, 11223186617.916, 0.19105 +Res-1.6, 11203363650.3495, 0.19053 +Res-1.5, 11200461004.0192, 0.19046 +Res-1.4, 11223167476.7341, 0.19105 +Res-1.3, 11201787633.63, 0.19049 +Res-1.2, 11216634163.6389, 0.19088 +Res-1.1, 11216793056.4137, 0.19088 +Res-1.211, 10072000000, 0.25 +Res-1.212, 10072000000, 0.25 +Res-1.213, 10072000000, 0.25 +Res-1.214, 10072000000, 0.25 +Res-1.215, 10072000000, 0.25 +Res-1.216, 10072000000, 0.25 +Res-1.217, 10216000000, 0.25 +Res-1.218, 10216000000, 0.25 +Res-1.219, 10216000000, 0.25 +Res-1.220, 10216000000, 0.25 +Res-1.221, 10216000000, 0.25 +Res-1.222, 10216000000, 0.25 +Res-1.223, 10360000000, 0.25 +Res-1.224, 10360000000, 0.25 +Res-1.225, 10360000000, 0.25 +Res-1.226, 10360000000, 0.25 +Res-1.227, 10360000000, 0.25 +Res-1.228, 10360000000, 0.25 +Res-1.229, 10504000000, 0.25 +Res-1.230, 10504000000, 0.25 +Res-1.231, 10504000000, 0.25 +Res-1.232, 10504000000, 0.25 +Res-1.233, 10504000000, 0.25 +Res-1.234, 10504000000, 0.25 +Res-1.235, 10648000000, 0.25 +Res-1.236, 10648000000, 0.25 +Res-1.237, 10648000000, 0.25 +Res-1.238, 10648000000, 0.25 +Res-1.239, 10648000000, 0.25 +Res-1.240, 10648000000, 0.25 +Res-1.241, 10072000000, 0.25 +Res-1.242, 10072000000, 0.25 +Res-1.243, 10072000000, 0.25 +Res-1.244, 10072000000, 0.25 +Res-1.245, 10072000000, 0.25 +Res-1.246, 10072000000, 0.25 +Res-1.247, 10072000000, 0.25 +Res-1.248, 10216000000, 0.25 +Res-1.249, 10216000000, 0.25 +Res-1.250, 10216000000, 0.25 +Res-1.251, 10216000000, 0.25 +Res-1.252, 10216000000, 0.25 +Res-1.253, 10216000000, 0.25 +Res-1.254, 10216000000, 0.25 +Res-1.255, 10360000000, 0.25 +Res-1.256, 10360000000, 0.25 +Res-1.257, 10360000000, 0.25 +Res-1.258, 10360000000, 0.25 +Res-1.259, 10360000000, 0.25 +Res-1.260, 10360000000, 0.25 +Res-1.261, 10360000000, 0.25 +Res-1.262, 10504000000, 0.25 +Res-1.263, 10504000000, 0.25 +Res-1.264, 10504000000, 0.25 +Res-1.265, 10504000000, 0.25 +Res-1.266, 10504000000, 0.25 +Res-1.267, 10504000000, 0.25 +Res-1.268, 10504000000, 0.25 +Res-1.269, 10648000000, 0.25 +Res-1.270, 10648000000, 0.25 +Res-1.271, 10648000000, 0.25 +Res-1.272, 10648000000, 0.25 +Res-1.273, 10648000000, 0.25 +Res-1.274, 10648000000, 0.25 +Res-1.275, 10648000000, 0.25 +Res-1.276, 10072000000, 0.25 +Res-1.277, 10216000000, 0.25 +Res-1.278, 10360000000, 0.25 +Res-1.279, 10504000000, 0.25 +Res-1.280, 10648000000, 0.25 +Res-1.281, 10072000000, 0.25 +Res-1.282, 10072000000, 0.25 +Res-1.283, 10072000000, 0.25 +Res-1.284, 10072000000, 0.25 +Res-1.285, 10072000000, 0.25 +Res-1.286, 10072000000, 0.25 +Res-1.287, 10072000000, 0.25 +Res-1.288, 10216000000, 0.25 +Res-1.289, 10216000000, 0.25 +Res-1.290, 10216000000, 0.25 +Res-1.291, 10216000000, 0.25 +Res-1.292, 10216000000, 0.25 +Res-1.293, 10216000000, 0.25 +Res-1.294, 10216000000, 0.25 +Res-1.295, 10360000000, 0.25 +Res-1.296, 10360000000, 0.25 +Res-1.297, 10360000000, 0.25 +Res-1.298, 10360000000, 0.25 +Res-1.299, 10360000000, 0.25 +Res-1.300, 10360000000, 0.25 +Res-1.301, 10360000000, 0.25 +Res-1.302, 10504000000, 0.25 +Res-1.303, 10504000000, 0.25 +Res-1.304, 10504000000, 0.25 +Res-1.305, 10504000000, 0.25 +Res-1.306, 10504000000, 0.25 +Res-1.307, 10504000000, 0.25 +Res-1.308, 10504000000, 0.25 +Res-1.309, 10648000000, 0.25 +Res-1.310, 10648000000, 0.25 +Res-1.311, 10648000000, 0.25 +Res-1.312, 10648000000, 0.25 +Res-1.313, 10648000000, 0.25 +Res-1.314, 10648000000, 0.25 +Res-1.315, 10648000000, 0.25 +Res-1.316, 10072000000, 0.25 +Res-1.317, 10216000000, 0.25 +Res-1.318, 10360000000, 0.25 +Res-1.319, 10504000000, 0.25 +Res-1.320, 10648000000, 0.25 +Res-1.321, 10072000000, 0.25 +Res-1.322, 10072000000, 0.25 +Res-1.323, 10072000000, 0.25 +Res-1.324, 10072000000, 0.25 +Res-1.325, 10072000000, 0.25 +Res-1.326, 10072000000, 0.25 +Res-1.327, 10072000000, 0.25 +Res-1.328, 10216000000, 0.25 +Res-1.329, 10216000000, 0.25 +Res-1.330, 10216000000, 0.25 +Res-1.331, 10216000000, 0.25 +Res-1.332, 10216000000, 0.25 +Res-1.333, 10216000000, 0.25 +Res-1.334, 10216000000, 0.25 +Res-1.335, 10360000000, 0.25 +Res-1.336, 10360000000, 0.25 +Res-1.337, 10360000000, 0.25 +Res-1.338, 10360000000, 0.25 +Res-1.339, 10360000000, 0.25 +Res-1.340, 10360000000, 0.25 +Res-1.341, 10360000000, 0.25 +Res-1.342, 10504000000, 0.25 +Res-1.343, 10504000000, 0.25 +Res-1.344, 10504000000, 0.25 +Res-1.345, 10504000000, 0.25 +Res-1.346, 10504000000, 0.25 +Res-1.347, 10504000000, 0.25 +Res-1.348, 10504000000, 0.25 +Res-1.349, 10648000000, 0.25 +Res-1.350, 10648000000, 0.25 +Res-1.351, 10648000000, 0.25 +Res-1.352, 10648000000, 0.25 +Res-1.353, 10648000000, 0.25 +Res-1.354, 10648000000, 0.25 +Res-1.355, 10648000000, 0.25 +Res-1.356, 10072000000, 0.25 +Res-1.357, 10216000000, 0.25 +Res-1.358, 10360000000, 0.25 +Res-1.359, 10504000000, 0.25 +Res-1.360, 10648000000, 0.25 +Res-1.361, 10072000000, 0.25 +Res-1.362, 10072000000, 0.25 +Res-1.363, 10072000000, 0.25 +Res-1.364, 10072000000, 0.25 +Res-1.365, 10072000000, 0.25 +Res-1.366, 10072000000, 0.25 +Res-1.367, 10072000000, 0.25 +Res-1.368, 10216000000, 0.25 +Res-1.369, 10216000000, 0.25 +Res-1.370, 10216000000, 0.25 +Res-1.371, 10216000000, 0.25 +Res-1.372, 10216000000, 0.25 +Res-1.373, 10216000000, 0.25 +Res-1.374, 10216000000, 0.25 +Res-1.375, 10360000000, 0.25 +Res-1.376, 10360000000, 0.25 +Res-1.377, 10360000000, 0.25 +Res-1.378, 10360000000, 0.25 +Res-1.379, 10360000000, 0.25 +Res-1.380, 10360000000, 0.25 +Res-1.381, 10360000000, 0.25 +Res-1.382, 10504000000, 0.25 +Res-1.383, 10504000000, 0.25 +Res-1.384, 10504000000, 0.25 +Res-1.385, 10504000000, 0.25 +Res-1.386, 10504000000, 0.25 +Res-1.387, 10504000000, 0.25 +Res-1.388, 10504000000, 0.25 +Res-1.389, 10648000000, 0.25 +Res-1.390, 10648000000, 0.25 +Res-1.391, 10648000000, 0.25 +Res-1.392, 10648000000, 0.25 +Res-1.393, 10648000000, 0.25 +Res-1.394, 10648000000, 0.25 +Res-1.395, 10648000000, 0.25 +Res-1.396, 10072000000, 0.25 +Res-1.397, 10216000000, 0.25 +Res-1.398, 10360000000, 0.25 +Res-1.399, 10504000000, 0.25 +Res-1.400, 10648000000, 0.25 +Res-1.401, 10072000000, 0.25 +Res-1.402, 10072000000, 0.25 +Res-1.403, 10072000000, 0.25 +Res-1.404, 10072000000, 0.25 +Res-1.405, 10072000000, 0.25 +Res-1.406, 10072000000, 0.25 +Res-1.407, 10072000000, 0.25 +Res-1.408, 10216000000, 0.25 +Res-1.409, 10216000000, 0.25 +Res-1.410, 10216000000, 0.25 +Res-1.411, 10216000000, 0.25 +Res-1.412, 10216000000, 0.25 +Res-1.413, 10216000000, 0.25 +Res-1.414, 10216000000, 0.25 +Res-1.415, 10360000000, 0.25 +Res-1.416, 10360000000, 0.25 +Res-1.417, 10360000000, 0.25 +Res-1.418, 10360000000, 0.25 +Res-1.419, 10360000000, 0.25 +Res-1.420, 10360000000, 0.25 +Res-1.421, 10360000000, 0.25 +Res-1.422, 10504000000, 0.25 +Res-1.423, 10504000000, 0.25 +Res-1.424, 10504000000, 0.25 +Res-1.425, 10504000000, 0.25 +Res-1.426, 10504000000, 0.25 +Res-1.427, 10504000000, 0.25 +Res-1.428, 10504000000, 0.25 +Res-1.429, 10648000000, 0.25 +Res-1.430, 10648000000, 0.25 +Res-1.431, 10648000000, 0.25 +Res-1.432, 10648000000, 0.25 +Res-1.433, 10648000000, 0.25 +Res-1.434, 10648000000, 0.25 +Res-1.435, 10648000000, 0.25 +Res-1.436, 10072000000, 0.25 +Res-1.437, 10216000000, 0.25 +Res-1.438, 10360000000, 0.25 +Res-1.439, 10504000000, 0.25 +Res-1.440, 10648000000, 0.25 +Res-1.441, 10072000000, 0.25 +Res-1.442, 10072000000, 0.25 +Res-1.443, 10072000000, 0.25 +Res-1.444, 10072000000, 0.25 +Res-1.445, 10072000000, 0.25 +Res-1.446, 10072000000, 0.25 +Res-1.447, 10072000000, 0.25 +Res-1.448, 10216000000, 0.25 +Res-1.449, 10216000000, 0.25 +Res-1.450, 10216000000, 0.25 +Res-1.451, 10216000000, 0.25 +Res-1.452, 10216000000, 0.25 +Res-1.453, 10216000000, 0.25 +Res-1.454, 10216000000, 0.25 +Res-1.455, 10360000000, 0.25 +Res-1.456, 10360000000, 0.25 +Res-1.457, 10360000000, 0.25 +Res-1.458, 10360000000, 0.25 +Res-1.459, 10360000000, 0.25 +Res-1.460, 10360000000, 0.25 +Res-1.461, 10360000000, 0.25 +Res-1.462, 10504000000, 0.25 +Res-1.463, 10504000000, 0.25 +Res-1.464, 10504000000, 0.25 +Res-1.465, 10504000000, 0.25 +Res-1.466, 10504000000, 0.25 +Res-1.467, 10504000000, 0.25 +Res-1.468, 10504000000, 0.25 +Res-1.469, 10648000000, 0.25 +Res-1.470, 10648000000, 0.25 +Res-1.471, 10648000000, 0.25 +Res-1.472, 10648000000, 0.25 +Res-1.473, 10648000000, 0.25 +Res-1.474, 10648000000, 0.25 +Res-1.475, 10648000000, 0.25 +Res-1.476, 10072000000, 0.25 +Res-1.477, 10216000000, 0.25 +Res-1.478, 10360000000, 0.25 +Res-1.479, 10504000000, 0.25 +Res-1.480, 10648000000, 0.25 +Res-1.481, 10072000000, 0.25 +Res-1.482, 10072000000, 0.25 +Res-1.483, 10072000000, 0.25 +Res-1.484, 10072000000, 0.25 +Res-1.485, 10072000000, 0.25 +Res-1.486, 10072000000, 0.25 +Res-1.487, 10072000000, 0.25 +Res-1.488, 10216000000, 0.25 +Res-1.489, 10216000000, 0.25 +Res-1.490, 10216000000, 0.25 +Res-1.491, 10216000000, 0.25 +Res-1.492, 10216000000, 0.25 +Res-1.493, 10216000000, 0.25 +Res-1.494, 10216000000, 0.25 +Res-1.495, 10360000000, 0.25 +Res-1.496, 10360000000, 0.25 +Res-1.497, 10360000000, 0.25 +Res-1.498, 10360000000, 0.25 +Res-1.499, 10360000000, 0.25 +Res-1.500, 10360000000, 0.25 +Res-1.501, 10360000000, 0.25 +Res-1.502, 10504000000, 0.25 +Res-1.503, 10504000000, 0.25 +Res-1.504, 10504000000, 0.25 +Res-1.505, 10504000000, 0.25 +Res-1.506, 10504000000, 0.25 +Res-1.507, 10504000000, 0.25 +Res-1.508, 10504000000, 0.25 +Res-1.509, 10648000000, 0.25 +Res-1.510, 10648000000, 0.25 +Res-1.511, 10648000000, 0.25 +Res-1.512, 10648000000, 0.25 +Res-1.513, 10648000000, 0.25 +Res-1.514, 10648000000, 0.25 +Res-1.515, 10648000000, 0.25 +Res-1.516, 10072000000, 0.25 +Res-1.517, 10216000000, 0.25 +Res-1.518, 10360000000, 0.25 +Res-1.519, 10504000000, 0.25 +Res-1.520, 10648000000, 0.25 +Res-1.521, 10072000000, 0.25 +Res-1.522, 10072000000, 0.25 +Res-1.523, 10072000000, 0.25 +Res-1.524, 10072000000, 0.25 +Res-1.525, 10072000000, 0.25 +Res-1.526, 10072000000, 0.25 +Res-1.527, 10072000000, 0.25 +Res-1.528, 10216000000, 0.25 +Res-1.529, 10216000000, 0.25 +Res-1.530, 10216000000, 0.25 +Res-1.531, 10216000000, 0.25 +Res-1.532, 10216000000, 0.25 +Res-1.533, 10216000000, 0.25 +Res-1.534, 10216000000, 0.25 +Res-1.535, 10360000000, 0.25 +Res-1.536, 10360000000, 0.25 +Res-1.537, 10360000000, 0.25 +Res-1.538, 10360000000, 0.25 +Res-1.539, 10360000000, 0.25 +Res-1.540, 10360000000, 0.25 +Res-1.541, 10360000000, 0.25 +Res-1.542, 10504000000, 0.25 +Res-1.543, 10504000000, 0.25 +Res-1.544, 10504000000, 0.25 +Res-1.545, 10504000000, 0.25 +Res-1.546, 10504000000, 0.25 +Res-1.547, 10504000000, 0.25 +Res-1.548, 10504000000, 0.25 +Res-1.549, 10648000000, 0.25 +Res-1.550, 10648000000, 0.25 +Res-1.551, 10648000000, 0.25 +Res-1.552, 10648000000, 0.25 +Res-1.553, 10648000000, 0.25 +Res-1.554, 10648000000, 0.25 +Res-1.555, 10648000000, 0.25 +Res-1.556, 10072000000, 0.25 +Res-1.557, 10216000000, 0.25 +Res-1.558, 10360000000, 0.25 +Res-1.559, 10504000000, 0.25 +Res-1.560, 10648000000, 0.25 +Res-1.561, 10072000000, 0.25 +Res-1.562, 10072000000, 0.25 +Res-1.563, 10072000000, 0.25 +Res-1.564, 10072000000, 0.25 +Res-1.565, 10072000000, 0.25 +Res-1.566, 10072000000, 0.25 +Res-1.567, 10072000000, 0.25 +Res-1.568, 10216000000, 0.25 +Res-1.569, 10216000000, 0.25 +Res-1.570, 10216000000, 0.25 +Res-1.571, 10216000000, 0.25 +Res-1.572, 10216000000, 0.25 +Res-1.573, 10216000000, 0.25 +Res-1.574, 10216000000, 0.25 +Res-1.575, 10360000000, 0.25 +Res-1.576, 10360000000, 0.25 +Res-1.577, 10360000000, 0.25 +Res-1.578, 10360000000, 0.25 +Res-1.579, 10360000000, 0.25 +Res-1.580, 10360000000, 0.25 +Res-1.581, 10360000000, 0.25 +Res-1.582, 10504000000, 0.25 +Res-1.583, 10504000000, 0.25 +Res-1.584, 10504000000, 0.25 +Res-1.585, 10504000000, 0.25 +Res-1.586, 10504000000, 0.25 +Res-1.587, 10504000000, 0.25 +Res-1.588, 10504000000, 0.25 +Res-1.589, 10648000000, 0.25 +Res-1.590, 10648000000, 0.25 +Res-1.591, 10648000000, 0.25 +Res-1.592, 10648000000, 0.25 +Res-1.593, 10648000000, 0.25 +Res-1.594, 10648000000, 0.25 +Res-1.595, 10648000000, 0.25 +Res-1.596, 10072000000, 0.25 +Res-1.597, 10216000000, 0.25 +Res-1.598, 10360000000, 0.25 +Res-1.599, 10504000000, 0.25 +Res-1.600, 10648000000, 0.25 +Res-1.601, 10072000000, 0.25 +Res-1.602, 10072000000, 0.25 +Res-1.603, 10072000000, 0.25 +Res-1.604, 10072000000, 0.25 +Res-1.605, 10072000000, 0.25 +Res-1.606, 10072000000, 0.25 +Res-1.607, 10072000000, 0.25 +Res-1.608, 10216000000, 0.25 +Res-1.609, 10216000000, 0.25 +Res-1.610, 10216000000, 0.25 +Res-1.611, 10216000000, 0.25 +Res-1.612, 10216000000, 0.25 +Res-1.613, 10216000000, 0.25 +Res-1.614, 10216000000, 0.25 +Res-1.615, 10360000000, 0.25 +Res-1.616, 10360000000, 0.25 +Res-1.617, 10360000000, 0.25 +Res-1.618, 10360000000, 0.25 +Res-1.619, 10360000000, 0.25 +Res-1.620, 10360000000, 0.25 +Res-1.621, 10360000000, 0.25 +Res-1.622, 10504000000, 0.25 +Res-1.623, 10504000000, 0.25 +Res-1.624, 10504000000, 0.25 +Res-1.625, 10504000000, 0.25 +Res-1.626, 10504000000, 0.25 +Res-1.627, 10504000000, 0.25 +Res-1.628, 10504000000, 0.25 +Res-1.629, 10648000000, 0.25 +Res-1.630, 10648000000, 0.25 +Res-1.631, 10648000000, 0.25 +Res-1.632, 10648000000, 0.25 +Res-1.633, 10648000000, 0.25 +Res-1.634, 10648000000, 0.25 +Res-1.635, 10648000000, 0.25 +Res-1.636, 10072000000, 0.25 +Res-1.637, 10216000000, 0.25 +Res-1.638, 10360000000, 0.25 +Res-1.639, 10504000000, 0.25 +Res-1.640, 10648000000, 0.25 +Res-1.641, 10072000000, 0.25 +Res-1.642, 10072000000, 0.25 +Res-1.643, 10072000000, 0.25 +Res-1.644, 10072000000, 0.25 +Res-1.645, 10072000000, 0.25 +Res-1.646, 10072000000, 0.25 +Res-1.647, 10216000000, 0.25 +Res-1.648, 10216000000, 0.25 +Res-1.649, 10216000000, 0.25 +Res-1.650, 10216000000, 0.25 +Res-1.651, 10216000000, 0.25 +Res-1.652, 10216000000, 0.25 +Res-1.653, 10360000000, 0.25 +Res-1.654, 10360000000, 0.25 +Res-1.655, 10360000000, 0.25 +Res-1.656, 10360000000, 0.25 +Res-1.657, 10360000000, 0.25 +Res-1.658, 10360000000, 0.25 +Res-1.659, 10504000000, 0.25 +Res-1.660, 10504000000, 0.25 +Res-1.661, 10504000000, 0.25 +Res-1.662, 10504000000, 0.25 +Res-1.663, 10504000000, 0.25 +Res-1.664, 10504000000, 0.25 +Res-1.665, 10648000000, 0.25 +Res-1.666, 10648000000, 0.25 +Res-1.667, 10648000000, 0.25 +Res-1.668, 10648000000, 0.25 +Res-1.669, 10648000000, 0.25 +Res-1.670, 10648000000, 0.25 +Res-1.671, 10072000000, 0.25 +Res-1.672, 10216000000, 0.25 +Res-1.673, 10360000000, 0.25 +Res-1.674, 10504000000, 0.25 +Res-1.675, 10648000000, 0.25 +Res-1.676, 10072000000, 0.25 +Res-1.677, 10216000000, 0.25 +Res-1.678, 10360000000, 0.25 +Res-1.679, 10504000000, 0.25 +Res-1.680, 10648000000, 0.25 +Res-1.681, 10072000000, 0.25 +Res-1.682, 10216000000, 0.25 +Res-1.683, 10360000000, 0.25 +Res-1.684, 10504000000, 0.25 +Res-1.685, 10648000000, 0.25 +Res-1.686, 10072000000, 0.25 +Res-1.687, 10216000000, 0.25 +Res-1.688, 10360000000, 0.25 +Res-1.689, 10504000000, 0.25 +Res-1.690, 10648000000, 0.25 +Res-1.691, 10072000000, 0.25 +Res-1.692, 10216000000, 0.25 +Res-1.693, 10360000000, 0.25 +Res-1.694, 10504000000, 0.25 +Res-1.695, 10648000000, 0.25 +Res-1.696, 10072000000, 0.25 +Res-1.697, 10216000000, 0.25 +Res-1.698, 10360000000, 0.25 +Res-1.699, 10504000000, 0.25 +Res-1.700, 10648000000, 0.25 +Res-1.701, 10072000000, 0.25 +Res-1.702, 10216000000, 0.25 +Res-1.703, 10360000000, 0.25 +Res-1.704, 10504000000, 0.25 +Res-1.705, 10648000000, 0.25 +Res-1.706, 10072000000, 0.25 +Res-1.707, 10216000000, 0.25 +Res-1.708, 10360000000, 0.25 +Res-1.709, 10504000000, 0.25 +Res-1.710, 10648000000, 0.25 +Res-1.711, 10072000000, 0.25 +Res-1.712, 10216000000, 0.25 +Res-1.713, 10360000000, 0.25 +Res-1.714, 10504000000, 0.25 +Res-1.715, 10648000000, 0.25 +Res-1.716, 10072000000, 0.25 +Res-1.717, 10216000000, 0.25 +Res-1.718, 10360000000, 0.25 +Res-1.719, 10504000000, 0.25 +Res-1.720, 10648000000, 0.25 +Res-1.721, 10072000000, 0.25 +Res-1.722, 10072000000, 0.25 +Res-1.723, 10072000000, 0.25 +Res-1.724, 10072000000, 0.25 +Res-1.725, 10072000000, 0.25 +Res-1.726, 10072000000, 0.25 +Res-1.727, 10216000000, 0.25 +Res-1.728, 10216000000, 0.25 +Res-1.729, 10216000000, 0.25 +Res-1.730, 10216000000, 0.25 +Res-1.731, 10216000000, 0.25 +Res-1.732, 10216000000, 0.25 +Res-1.733, 10360000000, 0.25 +Res-1.734, 10360000000, 0.25 +Res-1.735, 10360000000, 0.25 +Res-1.736, 10360000000, 0.25 +Res-1.737, 10360000000, 0.25 +Res-1.738, 10360000000, 0.25 +Res-1.739, 10504000000, 0.25 +Res-1.740, 10504000000, 0.25 +Res-1.741, 10504000000, 0.25 +Res-1.742, 10504000000, 0.25 +Res-1.743, 10504000000, 0.25 +Res-1.744, 10504000000, 0.25 +Res-1.745, 10648000000, 0.25 +Res-1.746, 10648000000, 0.25 +Res-1.747, 10648000000, 0.25 +Res-1.748, 10648000000, 0.25 +Res-1.749, 10648000000, 0.25 +Res-1.750, 10648000000, 0.25 +Res-1.751, 10072000000, 0.25 +Res-1.752, 10216000000, 0.25 +Res-1.753, 10360000000, 0.25 +Res-1.754, 10504000000, 0.25 +Res-1.755, 10648000000, 0.25 +Res-1.756, 10072000000, 0.25 +Res-1.757, 10216000000, 0.25 +Res-1.758, 10360000000, 0.25 +Res-1.759, 10504000000, 0.25 +Res-1.760, 10648000000, 0.25 +Res-1.761, 10072000000, 0.25 +Res-1.762, 10216000000, 0.25 +Res-1.763, 10360000000, 0.25 +Res-1.764, 10504000000, 0.25 +Res-1.765, 10648000000, 0.25 +Res-1.766, 10072000000, 0.25 +Res-1.767, 10216000000, 0.25 +Res-1.768, 10360000000, 0.25 +Res-1.769, 10504000000, 0.25 +Res-1.770, 10648000000, 0.25 +Res-1.771, 10072000000, 0.25 +Res-1.772, 10216000000, 0.25 +Res-1.773, 10360000000, 0.25 +Res-1.774, 10504000000, 0.25 +Res-1.775, 10648000000, 0.25 +Res-1.776, 10072000000, 0.25 +Res-1.777, 10216000000, 0.25 +Res-1.778, 10360000000, 0.25 +Res-1.779, 10504000000, 0.25 +Res-1.780, 10648000000, 0.25 +Res-1.781, 10072000000, 0.25 +Res-1.782, 10216000000, 0.25 +Res-1.783, 10360000000, 0.25 +Res-1.784, 10504000000, 0.25 +Res-1.785, 10648000000, 0.25 +Res-1.786, 10072000000, 0.25 +Res-1.787, 10216000000, 0.25 +Res-1.788, 10360000000, 0.25 +Res-1.789, 10504000000, 0.25 +Res-1.790, 10648000000, 0.25 +Res-1.791, 10072000000, 0.25 +Res-1.792, 10216000000, 0.25 +Res-1.793, 10360000000, 0.25 +Res-1.794, 10504000000, 0.25 +Res-1.795, 10648000000, 0.25 +Res-1.796, 10072000000, 0.25 +Res-1.797, 10216000000, 0.25 +Res-1.798, 10360000000, 0.25 +Res-1.799, 10504000000, 0.25 +Res-1.800, 10648000000, 0.25 +Res-1.801, 10072000000, 0.25 +Res-1.802, 10072000000, 0.25 +Res-1.803, 10072000000, 0.25 +Res-1.804, 10072000000, 0.25 +Res-1.805, 10072000000, 0.25 +Res-1.806, 10072000000, 0.25 +Res-1.807, 10216000000, 0.25 +Res-1.808, 10216000000, 0.25 +Res-1.809, 10216000000, 0.25 +Res-1.810, 10216000000, 0.25 +Res-1.811, 10216000000, 0.25 +Res-1.812, 10216000000, 0.25 +Res-1.813, 10360000000, 0.25 +Res-1.814, 10360000000, 0.25 +Res-1.815, 10360000000, 0.25 +Res-1.816, 10360000000, 0.25 +Res-1.817, 10360000000, 0.25 +Res-1.818, 10360000000, 0.25 +Res-1.819, 10504000000, 0.25 +Res-1.820, 10504000000, 0.25 +Res-1.821, 10504000000, 0.25 +Res-1.822, 10504000000, 0.25 +Res-1.823, 10504000000, 0.25 +Res-1.824, 10504000000, 0.25 +Res-1.825, 10648000000, 0.25 +Res-1.826, 10648000000, 0.25 +Res-1.827, 10648000000, 0.25 +Res-1.828, 10648000000, 0.25 +Res-1.829, 10648000000, 0.25 +Res-1.830, 10648000000, 0.25 +Res-1.831, 10072000000, 0.25 +Res-1.832, 10216000000, 0.25 +Res-1.833, 10360000000, 0.25 +Res-1.834, 10504000000, 0.25 +Res-1.835, 10648000000, 0.25 +Res-1.836, 10072000000, 0.25 +Res-1.837, 10216000000, 0.25 +Res-1.838, 10360000000, 0.25 +Res-1.839, 10504000000, 0.25 +Res-1.840, 10648000000, 0.25 +Res-1.841, 10072000000, 0.25 +Res-1.842, 10216000000, 0.25 +Res-1.843, 10360000000, 0.25 +Res-1.844, 10504000000, 0.25 +Res-1.845, 10648000000, 0.25 +Res-1.846, 10072000000, 0.25 +Res-1.847, 10216000000, 0.25 +Res-1.848, 10360000000, 0.25 +Res-1.849, 10504000000, 0.25 +Res-1.850, 10648000000, 0.25 +Res-1.851, 10072000000, 0.25 +Res-1.852, 10216000000, 0.25 +Res-1.853, 10360000000, 0.25 +Res-1.854, 10504000000, 0.25 +Res-1.855, 10648000000, 0.25 +Res-1.856, 10072000000, 0.25 +Res-1.857, 10216000000, 0.25 +Res-1.858, 10360000000, 0.25 +Res-1.859, 10504000000, 0.25 +Res-1.860, 10648000000, 0.25 +Res-1.861, 10072000000, 0.25 +Res-1.862, 10216000000, 0.25 +Res-1.863, 10360000000, 0.25 +Res-1.864, 10504000000, 0.25 +Res-1.865, 10648000000, 0.25 +Res-1.866, 10072000000, 0.25 +Res-1.867, 10216000000, 0.25 +Res-1.868, 10360000000, 0.25 +Res-1.869, 10504000000, 0.25 +Res-1.870, 10648000000, 0.25 +Res-1.871, 10072000000, 0.25 +Res-1.872, 10216000000, 0.25 +Res-1.873, 10360000000, 0.25 +Res-1.874, 10504000000, 0.25 +Res-1.875, 10648000000, 0.25 +Res-1.876, 10072000000, 0.25 +Res-1.877, 10216000000, 0.25 +Res-1.878, 10360000000, 0.25 +Res-1.879, 10504000000, 0.25 +Res-1.880, 10648000000, 0.25 +Res-1.881, 10072000000, 0.25 +Res-1.882, 10072000000, 0.25 +Res-1.883, 10072000000, 0.25 +Res-1.884, 10072000000, 0.25 +Res-1.885, 10072000000, 0.25 +Res-1.886, 10072000000, 0.25 +Res-1.887, 10216000000, 0.25 +Res-1.888, 10216000000, 0.25 +Res-1.889, 10216000000, 0.25 +Res-1.890, 10216000000, 0.25 +Res-1.891, 10216000000, 0.25 +Res-1.892, 10216000000, 0.25 +Res-1.893, 10360000000, 0.25 +Res-1.894, 10360000000, 0.25 +Res-1.895, 10360000000, 0.25 +Res-1.896, 10360000000, 0.25 +Res-1.897, 10360000000, 0.25 +Res-1.898, 10360000000, 0.25 +Res-1.899, 10504000000, 0.25 +Res-1.900, 10504000000, 0.25 +Res-1.901, 10504000000, 0.25 +Res-1.902, 10504000000, 0.25 +Res-1.903, 10504000000, 0.25 +Res-1.904, 10504000000, 0.25 +Res-1.905, 10648000000, 0.25 +Res-1.906, 10648000000, 0.25 +Res-1.907, 10648000000, 0.25 +Res-1.908, 10648000000, 0.25 +Res-1.909, 10648000000, 0.25 +Res-1.910, 10648000000, 0.25 +Res-1.911, 10072000000, 0.25 +Res-1.912, 10216000000, 0.25 +Res-1.913, 10360000000, 0.25 +Res-1.914, 10504000000, 0.25 +Res-1.915, 10648000000, 0.25 +Res-1.916, 10072000000, 0.25 +Res-1.917, 10216000000, 0.25 +Res-1.918, 10360000000, 0.25 +Res-1.919, 10504000000, 0.25 +Res-1.920, 10648000000, 0.25 +Res-1.921, 10072000000, 0.25 +Res-1.922, 10216000000, 0.25 +Res-1.923, 10360000000, 0.25 +Res-1.924, 10504000000, 0.25 +Res-1.925, 10648000000, 0.25 +Res-1.926, 10072000000, 0.25 +Res-1.927, 10216000000, 0.25 +Res-1.928, 10360000000, 0.25 +Res-1.929, 10504000000, 0.25 +Res-1.930, 10648000000, 0.25 +Res-1.931, 10072000000, 0.25 +Res-1.932, 10216000000, 0.25 +Res-1.933, 10360000000, 0.25 +Res-1.934, 10504000000, 0.25 +Res-1.935, 10648000000, 0.25 +Res-1.936, 10072000000, 0.25 +Res-1.937, 10216000000, 0.25 +Res-1.938, 10360000000, 0.25 +Res-1.939, 10504000000, 0.25 +Res-1.940, 10648000000, 0.25 +Res-1.941, 10072000000, 0.25 +Res-1.942, 10216000000, 0.25 +Res-1.943, 10360000000, 0.25 +Res-1.944, 10504000000, 0.25 +Res-1.945, 10648000000, 0.25 +Res-1.946, 10072000000, 0.25 +Res-1.947, 10216000000, 0.25 +Res-1.948, 10360000000, 0.25 +Res-1.949, 10504000000, 0.25 +Res-1.950, 10648000000, 0.25 +Res-1.951, 10072000000, 0.25 +Res-1.952, 10216000000, 0.25 +Res-1.953, 10360000000, 0.25 +Res-1.954, 10504000000, 0.25 +Res-1.955, 10648000000, 0.25 +Res-1.956, 10072000000, 0.25 +Res-1.957, 10216000000, 0.25 +Res-1.958, 10360000000, 0.25 +Res-1.959, 10504000000, 0.25 +Res-1.960, 10648000000, 0.25 +Res-1.961, 10072000000, 0.25 +Res-1.962, 10072000000, 0.25 +Res-1.963, 10072000000, 0.25 +Res-1.964, 10072000000, 0.25 +Res-1.965, 10072000000, 0.25 +Res-1.966, 10072000000, 0.25 +Res-1.967, 10216000000, 0.25 +Res-1.968, 10216000000, 0.25 +Res-1.969, 10216000000, 0.25 +Res-1.970, 10216000000, 0.25 +Res-1.971, 10216000000, 0.25 +Res-1.972, 10216000000, 0.25 +Res-1.973, 10360000000, 0.25 +Res-1.974, 10360000000, 0.25 +Res-1.975, 10360000000, 0.25 +Res-1.976, 10360000000, 0.25 +Res-1.977, 10360000000, 0.25 +Res-1.978, 10360000000, 0.25 +Res-1.979, 10504000000, 0.25 +Res-1.980, 10504000000, 0.25 +Res-1.981, 10504000000, 0.25 +Res-1.982, 10504000000, 0.25 +Res-1.983, 10504000000, 0.25 +Res-1.984, 10504000000, 0.25 +Res-1.985, 10648000000, 0.25 +Res-1.986, 10648000000, 0.25 +Res-1.987, 10648000000, 0.25 +Res-1.988, 10648000000, 0.25 +Res-1.989, 10648000000, 0.25 +Res-1.990, 10648000000, 0.25 +Res-1.991, 10072000000, 0.25 +Res-1.992, 10216000000, 0.25 +Res-1.993, 10360000000, 0.25 +Res-1.994, 10504000000, 0.25 +Res-1.995, 10648000000, 0.25 +Res-1.996, 10072000000, 0.25 +Res-1.997, 10216000000, 0.25 +Res-1.998, 10360000000, 0.25 +Res-1.999, 10504000000, 0.25 +Res-1.1000, 10648000000, 0.25 +Res-1.1001, 10072000000, 0.25 +Res-1.1002, 10216000000, 0.25 +Res-1.1003, 10360000000, 0.25 +Res-1.1004, 10504000000, 0.25 +Res-1.1005, 10648000000, 0.25 +Res-1.1006, 10072000000, 0.25 +Res-1.1007, 10216000000, 0.25 +Res-1.1008, 10360000000, 0.25 +Res-1.1009, 10504000000, 0.25 +Res-1.1010, 10648000000, 0.25 +Res-1.1011, 10072000000, 0.25 +Res-1.1012, 10216000000, 0.25 +Res-1.1013, 10360000000, 0.25 +Res-1.1014, 10504000000, 0.25 +Res-1.1015, 10648000000, 0.25 +Res-1.1016, 10072000000, 0.25 +Res-1.1017, 10216000000, 0.25 +Res-1.1018, 10360000000, 0.25 +Res-1.1019, 10504000000, 0.25 +Res-1.1020, 10648000000, 0.25 +Res-1.1021, 10072000000, 0.25 +Res-1.1022, 10216000000, 0.25 +Res-1.1023, 10360000000, 0.25 +Res-1.1024, 10504000000, 0.25 +Res-1.1025, 10648000000, 0.25 +Res-1.1026, 10072000000, 0.25 +Res-1.1027, 10216000000, 0.25 +Res-1.1028, 10360000000, 0.25 +Res-1.1029, 10504000000, 0.25 +Res-1.1030, 10648000000, 0.25 +Res-1.1031, 10072000000, 0.25 +Res-1.1032, 10216000000, 0.25 +Res-1.1033, 10360000000, 0.25 +Res-1.1034, 10504000000, 0.25 +Res-1.1035, 10648000000, 0.25 +Res-1.1036, 10072000000, 0.25 +Res-1.1037, 10216000000, 0.25 +Res-1.1038, 10360000000, 0.25 +Res-1.1039, 10504000000, 0.25 +Res-1.1040, 10648000000, 0.25 +Res-1.1041, 10072000000, 0.25 +Res-1.1042, 10072000000, 0.25 +Res-1.1043, 10072000000, 0.25 +Res-1.1044, 10072000000, 0.25 +Res-1.1045, 10072000000, 0.25 +Res-1.1046, 10072000000, 0.25 +Res-1.1047, 10216000000, 0.25 +Res-1.1048, 10216000000, 0.25 +Res-1.1049, 10216000000, 0.25 +Res-1.1050, 10216000000, 0.25 +Res-1.1051, 10216000000, 0.25 +Res-1.1052, 10216000000, 0.25 +Res-1.1053, 10360000000, 0.25 +Res-1.1054, 10360000000, 0.25 +Res-1.1055, 10360000000, 0.25 +Res-1.1056, 10360000000, 0.25 +Res-1.1057, 10360000000, 0.25 +Res-1.1058, 10360000000, 0.25 +Res-1.1059, 10504000000, 0.25 +Res-1.1060, 10504000000, 0.25 +Res-1.1061, 10504000000, 0.25 +Res-1.1062, 10504000000, 0.25 +Res-1.1063, 10504000000, 0.25 +Res-1.1064, 10504000000, 0.25 +Res-1.1065, 10648000000, 0.25 +Res-1.1066, 10648000000, 0.25 +Res-1.1067, 10648000000, 0.25 +Res-1.1068, 10648000000, 0.25 +Res-1.1069, 10648000000, 0.25 +Res-1.1070, 10648000000, 0.25 +Res-1.1071, 10072000000, 0.25 +Res-1.1072, 10216000000, 0.25 +Res-1.1073, 10360000000, 0.25 +Res-1.1074, 10504000000, 0.25 +Res-1.1075, 10648000000, 0.25 +Res-1.1076, 10072000000, 0.25 +Res-1.1077, 10216000000, 0.25 +Res-1.1078, 10360000000, 0.25 +Res-1.1079, 10504000000, 0.25 +Res-1.1080, 10648000000, 0.25 +Res-1.1081, 10072000000, 0.25 +Res-1.1082, 10216000000, 0.25 +Res-1.1083, 10360000000, 0.25 +Res-1.1084, 10504000000, 0.25 +Res-1.1085, 10648000000, 0.25 +Res-1.1086, 10072000000, 0.25 +Res-1.1087, 10216000000, 0.25 +Res-1.1088, 10360000000, 0.25 +Res-1.1089, 10504000000, 0.25 +Res-1.1090, 10648000000, 0.25 +Res-1.1091, 10072000000, 0.25 +Res-1.1092, 10216000000, 0.25 +Res-1.1093, 10360000000, 0.25 +Res-1.1094, 10504000000, 0.25 +Res-1.1095, 10648000000, 0.25 +Res-1.1096, 10072000000, 0.25 +Res-1.1097, 10216000000, 0.25 +Res-1.1098, 10360000000, 0.25 +Res-1.1099, 10504000000, 0.25 +Res-1.1100, 10648000000, 0.25 +Res-1.1101, 10072000000, 0.25 +Res-1.1102, 10216000000, 0.25 +Res-1.1103, 10360000000, 0.25 +Res-1.1104, 10504000000, 0.25 +Res-1.1105, 10648000000, 0.25 +Res-1.1106, 10072000000, 0.25 +Res-1.1107, 10216000000, 0.25 +Res-1.1108, 10360000000, 0.25 +Res-1.1109, 10504000000, 0.25 +Res-1.1110, 10648000000, 0.25 +Res-1.1111, 10072000000, 0.25 +Res-1.1112, 10216000000, 0.25 +Res-1.1113, 10360000000, 0.25 +Res-1.1114, 10504000000, 0.25 +Res-1.1115, 10648000000, 0.25 +Res-1.1116, 10072000000, 0.25 +Res-1.1117, 10216000000, 0.25 +Res-1.1118, 10360000000, 0.25 +Res-1.1119, 10504000000, 0.25 +Res-1.1120, 10648000000, 0.25 +Res-1.1121, 10072000000, 0.25 +Res-1.1122, 10072000000, 0.25 +Res-1.1123, 10072000000, 0.25 +Res-1.1124, 10072000000, 0.25 +Res-1.1125, 10072000000, 0.25 +Res-1.1126, 10072000000, 0.25 +Res-1.1127, 10216000000, 0.25 +Res-1.1128, 10216000000, 0.25 +Res-1.1129, 10216000000, 0.25 +Res-1.1130, 10216000000, 0.25 +Res-1.1131, 10216000000, 0.25 +Res-1.1132, 10216000000, 0.25 +Res-1.1133, 10360000000, 0.25 +Res-1.1134, 10360000000, 0.25 +Res-1.1135, 10360000000, 0.25 +Res-1.1136, 10360000000, 0.25 +Res-1.1137, 10360000000, 0.25 +Res-1.1138, 10360000000, 0.25 +Res-1.1139, 10504000000, 0.25 +Res-1.1140, 10504000000, 0.25 +Res-1.1141, 10504000000, 0.25 +Res-1.1142, 10504000000, 0.25 +Res-1.1143, 10504000000, 0.25 +Res-1.1144, 10504000000, 0.25 +Res-1.1145, 10648000000, 0.25 +Res-1.1146, 10648000000, 0.25 +Res-1.1147, 10648000000, 0.25 +Res-1.1148, 10648000000, 0.25 +Res-1.1149, 10648000000, 0.25 +Res-1.1150, 10648000000, 0.25 +Res-1.1151, 10072000000, 0.25 +Res-1.1152, 10216000000, 0.25 +Res-1.1153, 10360000000, 0.25 +Res-1.1154, 10504000000, 0.25 +Res-1.1155, 10648000000, 0.25 +Res-1.1156, 10072000000, 0.25 +Res-1.1157, 10216000000, 0.25 +Res-1.1158, 10360000000, 0.25 +Res-1.1159, 10504000000, 0.25 +Res-1.1160, 10648000000, 0.25 +Res-1.1161, 10072000000, 0.25 +Res-1.1162, 10216000000, 0.25 +Res-1.1163, 10360000000, 0.25 +Res-1.1164, 10504000000, 0.25 +Res-1.1165, 10648000000, 0.25 +Res-1.1166, 10072000000, 0.25 +Res-1.1167, 10216000000, 0.25 +Res-1.1168, 10360000000, 0.25 +Res-1.1169, 10504000000, 0.25 +Res-1.1170, 10648000000, 0.25 +Res-1.1171, 10072000000, 0.25 +Res-1.1172, 10216000000, 0.25 +Res-1.1173, 10360000000, 0.25 +Res-1.1174, 10504000000, 0.25 +Res-1.1175, 10648000000, 0.25 +Res-1.1176, 10072000000, 0.25 +Res-1.1177, 10216000000, 0.25 +Res-1.1178, 10360000000, 0.25 +Res-1.1179, 10504000000, 0.25 +Res-1.1180, 10648000000, 0.25 +Res-1.1181, 10072000000, 0.25 +Res-1.1182, 10216000000, 0.25 +Res-1.1183, 10360000000, 0.25 +Res-1.1184, 10504000000, 0.25 +Res-1.1185, 10648000000, 0.25 +Res-1.1186, 10072000000, 0.25 +Res-1.1187, 10216000000, 0.25 +Res-1.1188, 10360000000, 0.25 +Res-1.1189, 10504000000, 0.25 +Res-1.1190, 10648000000, 0.25 +Res-1.1191, 10072000000, 0.25 +Res-1.1192, 10216000000, 0.25 +Res-1.1193, 10360000000, 0.25 +Res-1.1194, 10504000000, 0.25 +Res-1.1195, 10648000000, 0.25 +Res-1.1196, 10072000000, 0.25 +Res-1.1197, 10216000000, 0.25 +Res-1.1198, 10360000000, 0.25 +Res-1.1199, 10504000000, 0.25 +Res-1.1200, 10648000000, 0.25 +Res-1.1201, 10072000000, 0.25 +Res-1.1202, 10072000000, 0.25 +Res-1.1203, 10072000000, 0.25 +Res-1.1204, 10072000000, 0.25 +Res-1.1205, 10072000000, 0.25 +Res-1.1206, 10072000000, 0.25 +Res-1.1207, 10216000000, 0.25 +Res-1.1208, 10216000000, 0.25 +Res-1.1209, 10216000000, 0.25 +Res-1.1210, 10216000000, 0.25 +Res-1.1211, 10216000000, 0.25 +Res-1.1212, 10216000000, 0.25 +Res-1.1213, 10360000000, 0.25 +Res-1.1214, 10360000000, 0.25 +Res-1.1215, 10360000000, 0.25 +Res-1.1216, 10360000000, 0.25 +Res-1.1217, 10360000000, 0.25 +Res-1.1218, 10360000000, 0.25 +Res-1.1219, 10504000000, 0.25 +Res-1.1220, 10504000000, 0.25 +Res-1.1221, 10504000000, 0.25 +Res-1.1222, 10504000000, 0.25 +Res-1.1223, 10504000000, 0.25 +Res-1.1224, 10504000000, 0.25 +Res-1.1225, 10648000000, 0.25 +Res-1.1226, 10648000000, 0.25 +Res-1.1227, 10648000000, 0.25 +Res-1.1228, 10648000000, 0.25 +Res-1.1229, 10648000000, 0.25 +Res-1.1230, 10648000000, 0.25 +Res-1.1231, 10072000000, 0.25 +Res-1.1232, 10216000000, 0.25 +Res-1.1233, 10360000000, 0.25 +Res-1.1234, 10504000000, 0.25 +Res-1.1235, 10648000000, 0.25 +Res-1.1236, 10072000000, 0.25 +Res-1.1237, 10216000000, 0.25 +Res-1.1238, 10360000000, 0.25 +Res-1.1239, 10504000000, 0.25 +Res-1.1240, 10648000000, 0.25 +Res-1.1241, 10072000000, 0.25 +Res-1.1242, 10216000000, 0.25 +Res-1.1243, 10360000000, 0.25 +Res-1.1244, 10504000000, 0.25 +Res-1.1245, 10648000000, 0.25 +Res-1.1246, 10072000000, 0.25 +Res-1.1247, 10216000000, 0.25 +Res-1.1248, 10360000000, 0.25 +Res-1.1249, 10504000000, 0.25 +Res-1.1250, 10648000000, 0.25 +Res-1.1251, 10072000000, 0.25 +Res-1.1252, 10216000000, 0.25 +Res-1.1253, 10360000000, 0.25 +Res-1.1254, 10504000000, 0.25 +Res-1.1255, 10648000000, 0.25 +Res-1.1256, 10072000000, 0.25 +Res-1.1257, 10216000000, 0.25 +Res-1.1258, 10360000000, 0.25 +Res-1.1259, 10504000000, 0.25 +Res-1.1260, 10648000000, 0.25 +Res-1.1261, 10072000000, 0.25 +Res-1.1262, 10216000000, 0.25 +Res-1.1263, 10360000000, 0.25 +Res-1.1264, 10504000000, 0.25 +Res-1.1265, 10648000000, 0.25 +Res-1.1266, 10072000000, 0.25 +Res-1.1267, 10216000000, 0.25 +Res-1.1268, 10360000000, 0.25 +Res-1.1269, 10504000000, 0.25 +Res-1.1270, 10648000000, 0.25 +Res-1.1271, 10072000000, 0.25 +Res-1.1272, 10216000000, 0.25 +Res-1.1273, 10360000000, 0.25 +Res-1.1274, 10504000000, 0.25 +Res-1.1275, 10648000000, 0.25 +Res-1.1276, 10072000000, 0.25 +Res-1.1277, 10216000000, 0.25 +Res-1.1278, 10360000000, 0.25 +Res-1.1279, 10504000000, 0.25 +Res-1.1280, 10648000000, 0.25 +Res-1.1281, 10072000000, 0.25 +Res-1.1282, 10072000000, 0.25 +Res-1.1283, 10072000000, 0.25 +Res-1.1284, 10072000000, 0.25 +Res-1.1285, 10072000000, 0.25 +Res-1.1286, 10072000000, 0.25 +Res-1.1287, 10216000000, 0.25 +Res-1.1288, 10216000000, 0.25 +Res-1.1289, 10216000000, 0.25 +Res-1.1290, 10216000000, 0.25 +Res-1.1291, 10216000000, 0.25 +Res-1.1292, 10216000000, 0.25 +Res-1.1293, 10360000000, 0.25 +Res-1.1294, 10360000000, 0.25 +Res-1.1295, 10360000000, 0.25 +Res-1.1296, 10360000000, 0.25 +Res-1.1297, 10360000000, 0.25 +Res-1.1298, 10360000000, 0.25 +Res-1.1299, 10504000000, 0.25 +Res-1.1300, 10504000000, 0.25 +Res-1.1301, 10504000000, 0.25 +Res-1.1302, 10504000000, 0.25 +Res-1.1303, 10504000000, 0.25 +Res-1.1304, 10504000000, 0.25 +Res-1.1305, 10648000000, 0.25 +Res-1.1306, 10648000000, 0.25 +Res-1.1307, 10648000000, 0.25 +Res-1.1308, 10648000000, 0.25 +Res-1.1309, 10648000000, 0.25 +Res-1.1310, 10648000000, 0.25 +Res-1.1311, 10072000000, 0.25 +Res-1.1312, 10216000000, 0.25 +Res-1.1313, 10360000000, 0.25 +Res-1.1314, 10504000000, 0.25 +Res-1.1315, 10648000000, 0.25 +Res-1.1316, 10072000000, 0.25 +Res-1.1317, 10216000000, 0.25 +Res-1.1318, 10360000000, 0.25 +Res-1.1319, 10504000000, 0.25 +Res-1.1320, 10648000000, 0.25 +Res-1.1321, 10072000000, 0.25 +Res-1.1322, 10216000000, 0.25 +Res-1.1323, 10360000000, 0.25 +Res-1.1324, 10504000000, 0.25 +Res-1.1325, 10648000000, 0.25 +Res-1.1326, 10072000000, 0.25 +Res-1.1327, 10216000000, 0.25 +Res-1.1328, 10360000000, 0.25 +Res-1.1329, 10504000000, 0.25 +Res-1.1330, 10648000000, 0.25 +Res-1.1331, 10072000000, 0.25 +Res-1.1332, 10216000000, 0.25 +Res-1.1333, 10360000000, 0.25 +Res-1.1334, 10504000000, 0.25 +Res-1.1335, 10648000000, 0.25 +Res-1.1336, 10072000000, 0.25 +Res-1.1337, 10216000000, 0.25 +Res-1.1338, 10360000000, 0.25 +Res-1.1339, 10504000000, 0.25 +Res-1.1340, 10648000000, 0.25 +Res-1.1341, 10072000000, 0.25 +Res-1.1342, 10216000000, 0.25 +Res-1.1343, 10360000000, 0.25 +Res-1.1344, 10504000000, 0.25 +Res-1.1345, 10648000000, 0.25 +Res-1.1346, 10072000000, 0.25 +Res-1.1347, 10216000000, 0.25 +Res-1.1348, 10360000000, 0.25 +Res-1.1349, 10504000000, 0.25 +Res-1.1350, 10648000000, 0.25 +Res-1.1351, 10072000000, 0.25 +Res-1.1352, 10216000000, 0.25 +Res-1.1353, 10360000000, 0.25 +Res-1.1354, 10504000000, 0.25 +Res-1.1355, 10648000000, 0.25 +Res-1.1356, 10072000000, 0.25 +Res-1.1357, 10216000000, 0.25 +Res-1.1358, 10360000000, 0.25 +Res-1.1359, 10504000000, 0.25 +Res-1.1360, 10648000000, 0.25 +Res-1.1361, 10072000000, 0.25 +Res-1.1362, 10072000000, 0.25 +Res-1.1363, 10072000000, 0.25 +Res-1.1364, 10072000000, 0.25 +Res-1.1365, 10072000000, 0.25 +Res-1.1366, 10072000000, 0.25 +Res-1.1367, 10216000000, 0.25 +Res-1.1368, 10216000000, 0.25 +Res-1.1369, 10216000000, 0.25 +Res-1.1370, 10216000000, 0.25 +Res-1.1371, 10216000000, 0.25 +Res-1.1372, 10216000000, 0.25 +Res-1.1373, 10360000000, 0.25 +Res-1.1374, 10360000000, 0.25 +Res-1.1375, 10360000000, 0.25 +Res-1.1376, 10360000000, 0.25 +Res-1.1377, 10360000000, 0.25 +Res-1.1378, 10360000000, 0.25 +Res-1.1379, 10504000000, 0.25 +Res-1.1380, 10504000000, 0.25 +Res-1.1381, 10504000000, 0.25 +Res-1.1382, 10504000000, 0.25 +Res-1.1383, 10504000000, 0.25 +Res-1.1384, 10504000000, 0.25 +Res-1.1385, 10648000000, 0.25 +Res-1.1386, 10648000000, 0.25 +Res-1.1387, 10648000000, 0.25 +Res-1.1388, 10648000000, 0.25 +Res-1.1389, 10648000000, 0.25 +Res-1.1390, 10648000000, 0.25 +Res-1.1391, 10072000000, 0.25 +Res-1.1392, 10216000000, 0.25 +Res-1.1393, 10360000000, 0.25 +Res-1.1394, 10504000000, 0.25 +Res-1.1395, 10648000000, 0.25 +Res-1.1396, 10072000000, 0.25 +Res-1.1397, 10216000000, 0.25 +Res-1.1398, 10360000000, 0.25 +Res-1.1399, 10504000000, 0.25 +Res-1.1400, 10648000000, 0.25 +Res-1.1401, 10072000000, 0.25 +Res-1.1402, 10216000000, 0.25 +Res-1.1403, 10360000000, 0.25 +Res-1.1404, 10504000000, 0.25 +Res-1.1405, 10648000000, 0.25 +Res-1.1406, 10072000000, 0.25 +Res-1.1407, 10216000000, 0.25 +Res-1.1408, 10360000000, 0.25 +Res-1.1409, 10504000000, 0.25 +Res-1.1410, 10648000000, 0.25 +Res-1.1411, 10072000000, 0.25 +Res-1.1412, 10216000000, 0.25 +Res-1.1413, 10360000000, 0.25 +Res-1.1414, 10504000000, 0.25 +Res-1.1415, 10648000000, 0.25 +Res-1.1416, 10072000000, 0.25 +Res-1.1417, 10216000000, 0.25 +Res-1.1418, 10360000000, 0.25 +Res-1.1419, 10504000000, 0.25 +Res-1.1420, 10648000000, 0.25 +Res-1.1421, 10072000000, 0.25 +Res-1.1422, 10216000000, 0.25 +Res-1.1423, 10360000000, 0.25 +Res-1.1424, 10504000000, 0.25 +Res-1.1425, 10648000000, 0.25 +Res-1.1426, 10072000000, 0.25 +Res-1.1427, 10216000000, 0.25 +Res-1.1428, 10360000000, 0.25 +Res-1.1429, 10504000000, 0.25 +Res-1.1430, 10648000000, 0.25 +Res-1.1431, 10072000000, 0.25 +Res-1.1432, 10216000000, 0.25 +Res-1.1433, 10360000000, 0.25 +Res-1.1434, 10504000000, 0.25 +Res-1.1435, 10648000000, 0.25 +Res-1.1436, 10072000000, 0.25 +Res-1.1437, 10216000000, 0.25 +Res-1.1438, 10360000000, 0.25 +Res-1.1439, 10504000000, 0.25 +Res-1.1440, 10648000000, 0.25 +Res-1.1441, 10478007200, 0.25 +Res-1.1442, 10478007200, 0.25 +Res-1.1443, 10478007200, 0.25 +Res-1.1444, 10478007200, 0.25 +Res-1.1445, 10478007200, 0.25 +Res-1.1446, 10478007200, 0.25 +Res-1.1447, 10478007200, 0.25 +Res-1.1448, 10478007200, 0.25 +Res-1.1449, 10478007200, 0.25 +Res-1.1450, 10478007200, 0.25 +Res-1.1451, 10478007200, 0.25 +Res-1.1452, 10478007200, 0.25 +Res-1.1453, 10478007200, 0.25 +Res-1.1454, 10478007200, 0.25 +Res-1.1455, 10478007200, 0.25 +Res-1.1456, 10478007200, 0.25 +Res-1.1457, 10478007200, 0.25 +Res-1.1458, 10478007200, 0.25 +Res-1.1459, 10478007200, 0.25 +Res-1.1460, 10478007200, 0.25 +Res-1.1461, 10478007200, 0.25 +Res-1.1462, 10478007200, 0.25 +Res-1.1463, 10478007200, 0.25 +Res-1.1464, 10478007200, 0.25 +Res-1.1465, 10478007200, 0.25 +Res-1.1466, 10478007200, 0.25 +Res-1.1467, 10478007200, 0.25 +Res-1.1468, 10478007200, 0.25 +Res-1.1469, 10478007200, 0.25 +Res-1.1470, 10478007200, 0.25 +Res-1.1471, 10478007200, 0.25 +Res-1.1472, 10478007200, 0.25 +Res-1.1473, 10478007200, 0.25 +Res-1.1474, 10478007200, 0.25 +Res-1.1475, 10478007200, 0.25 +Res-1.1476, 10478007200, 0.25 +Res-1.1477, 10478007200, 0.25 +Res-1.1478, 10478007200, 0.25 +Res-1.1479, 10478007200, 0.25 +Res-1.1480, 10478007200, 0.25 +Res-1.1481, 10478007200, 0.25 +Res-1.1482, 10478007200, 0.25 +Res-1.1483, 10478007200, 0.25 +Res-1.1484, 10478007200, 0.25 +Res-1.1485, 10478007200, 0.25 +Res-1.1486, 10478007200, 0.25 +Res-1.1487, 10478007200, 0.25 +Res-1.1488, 10478007200, 0.25 +Res-1.1489, 10478007200, 0.25 +Res-1.1490, 10478007200, 0.25 +Res-1.1491, 10478007200, 0.25 +Res-1.1492, 10478007200, 0.25 +Res-1.1493, 10478007200, 0.25 +Res-1.1494, 10478007200, 0.25 +Res-1.1495, 10478007200, 0.25 +Res-1.1496, 10478007200, 0.25 +Res-1.1497, 10478007200, 0.25 +Res-1.1498, 10478007200, 0.25 +Res-1.1499, 10478007200, 0.25 +Res-1.1500, 10478007200, 0.25 +Res-1.1501, 10478007200, 0.25 +Res-1.1502, 10478007200, 0.25 +Res-1.1503, 10478007200, 0.25 +Res-1.1504, 10478007200, 0.25 +Res-1.1505, 10478007200, 0.25 +Res-1.1506, 10478007200, 0.25 +Res-1.1507, 10478007200, 0.25 +Res-1.1508, 10478007200, 0.25 +Res-1.1509, 10478007200, 0.25 +Res-1.1510, 10478007200, 0.25 +Res-1.1511, 10478007200, 0.25 +Res-1.1512, 10478007200, 0.25 +Res-1.1513, 10478007200, 0.25 +Res-1.1514, 10478007200, 0.25 +Res-1.1515, 10478007200, 0.25 +Res-1.1516, 10478007200, 0.25 +Res-1.1517, 10478007200, 0.25 +Res-1.1518, 10478007200, 0.25 +Res-1.1519, 10478007200, 0.25 +Res-1.1520, 10478007200, 0.25 +Res-1.1521, 10478007200, 0.25 +Res-1.1522, 10478007200, 0.25 +Res-1.1523, 10478007200, 0.25 +Res-1.1524, 10478007200, 0.25 +Res-1.1525, 10478007200, 0.25 +Res-1.1526, 10478007200, 0.25 +Res-1.1527, 10478007200, 0.25 +Res-1.1528, 10478007200, 0.25 +Res-1.1529, 10478007200, 0.25 +Res-1.1530, 10478007200, 0.25 +Res-1.1531, 10478007200, 0.25 +Res-1.1532, 10478007200, 0.25 +Res-1.1533, 10478007200, 0.25 +Res-1.1534, 10478007200, 0.25 +Res-1.1535, 10478007200, 0.25 +Res-1.1536, 10478007200, 0.25 +Res-1.1537, 10478007200, 0.25 +Res-1.1538, 10478007200, 0.25 +Res-1.1539, 10478007200, 0.25 +Res-1.1540, 10478007200, 0.25 +Res-1.1541, 10478007200, 0.25 +Res-1.1542, 10478007200, 0.25 +Res-1.1543, 10478007200, 0.25 +Res-1.1544, 10478007200, 0.25 +Res-1.1545, 10478007200, 0.25 +Res-1.1546, 10478007200, 0.25 +Res-1.1547, 10478007200, 0.25 +Res-1.1548, 10478007200, 0.25 +Res-1.1549, 10478007200, 0.25 +Res-1.1550, 10478007200, 0.25 +Res-1.1551, 10478007200, 0.25 +Res-1.1552, 10478007200, 0.25 +Res-1.1553, 10478007200, 0.25 +Res-1.1554, 10478007200, 0.25 +Res-1.1555, 10478007200, 0.25 +Res-1.1556, 10478007200, 0.25 +Res-1.1557, 10478007200, 0.25 +Res-1.1558, 10478007200, 0.25 +Res-1.1559, 10478007200, 0.25 +Res-1.1560, 10478007200, 0.25 +Res-1.1561, 10478007200, 0.25 +Res-1.1562, 10478007200, 0.25 +Res-1.1563, 10478007200, 0.25 +Res-1.1564, 10478007200, 0.25 +Res-1.1565, 10478007200, 0.25 +Res-1.1566, 10478007200, 0.25 +Res-1.1567, 10478007200, 0.25 +Res-1.1568, 10478007200, 0.25 +Res-1.1569, 10478007200, 0.25 +Res-1.1570, 10478007200, 0.25 +Res-1.1571, 10478007200, 0.25 +Res-1.1572, 10478007200, 0.25 +Res-1.1573, 10478007200, 0.25 +Res-1.1574, 10478007200, 0.25 +Res-1.1575, 10478007200, 0.25 +Res-1.1576, 10478007200, 0.25 +Res-1.1577, 10478007200, 0.25 +Res-1.1578, 10478007200, 0.25 +Res-1.1579, 10478007200, 0.25 +Res-1.1580, 10478007200, 0.25 +Res-1.1581, 10478007200, 0.25 +Res-1.1582, 10478007200, 0.25 +Res-1.1583, 10478007200, 0.25 +Res-1.1584, 10478007200, 0.25 +Res-1.1585, 10478007200, 0.25 +Res-1.1586, 10478007200, 0.25 +Res-1.1587, 10478007200, 0.25 +Res-1.1588, 10478007200, 0.25 +Res-1.1589, 10478007200, 0.25 +Res-1.1590, 10478007200, 0.25 +Res-1.1591, 10478007200, 0.25 +Res-1.1592, 10478007200, 0.25 +Res-1.1593, 10478007200, 0.25 +Res-1.1594, 10478007200, 0.25 +Res-1.1595, 10478007200, 0.25 +Res-1.1596, 10478007200, 0.25 +Res-1.1597, 10478007200, 0.25 +Res-1.1598, 10478007200, 0.25 +Res-1.1599, 10478007200, 0.25 +Res-1.1600, 10478007200, 0.25 +Res-1.1601, 10478007200, 0.25 +Res-1.1602, 10478007200, 0.25 +Res-1.1603, 10478007200, 0.25 +Res-1.1604, 10478007200, 0.25 +Res-1.1605, 10478007200, 0.25 +Res-1.1606, 10478007200, 0.25 +Res-1.1607, 10478007200, 0.25 +Res-1.1608, 10478007200, 0.25 +Res-1.1609, 10478007200, 0.25 +Res-1.1610, 10478007200, 0.25 +Res-1.1611, 10478007200, 0.25 +Res-1.1612, 10478007200, 0.25 +Res-1.1613, 10478007200, 0.25 +Res-1.1614, 10478007200, 0.25 +Res-1.1615, 10478007200, 0.25 +Res-1.1616, 10478007200, 0.25 +Res-1.1617, 10478007200, 0.25 +Res-1.1618, 10478007200, 0.25 +Res-1.1619, 10478007200, 0.25 +Res-1.1620, 10478007200, 0.25 +Res-1.1621, 10478007200, 0.25 +Res-1.1622, 10478007200, 0.25 +Res-1.1623, 10478007200, 0.25 +Res-1.1624, 10478007200, 0.25 +Res-1.1625, 10478007200, 0.25 +Res-1.1626, 10478007200, 0.25 +Res-1.1627, 10478007200, 0.25 +Res-1.1628, 10478007200, 0.25 +Res-1.1629, 10478007200, 0.25 +Res-1.1630, 10478007200, 0.25 +Res-1.1631, 10478007200, 0.25 +Res-1.1632, 10478007200, 0.25 +Res-1.1633, 10478007200, 0.25 +Res-1.1634, 10478007200, 0.25 +Res-1.1635, 10478007200, 0.25 +Res-1.1636, 10478007200, 0.25 +Res-1.1637, 10478007200, 0.25 +Res-1.1638, 10478007200, 0.25 +Res-1.1639, 10478007200, 0.25 +Res-1.1640, 10478007200, 0.25 +Res-1.1641, 10478007200, 0.25 +Res-1.1642, 10478007200, 0.25 +Res-1.1643, 10478007200, 0.25 +Res-1.1644, 10478007200, 0.25 +Res-1.1645, 10478007200, 0.25 +Res-1.1646, 10478007200, 0.25 +Res-1.1647, 10478007200, 0.25 +Res-1.1648, 10478007200, 0.25 +Res-1.1649, 10478007200, 0.25 +Res-1.1650, 10478007200, 0.25 +Res-1.1651, 10478007200, 0.25 +Res-1.1652, 10478007200, 0.25 +Res-1.1653, 10478007200, 0.25 +Res-1.1654, 10478007200, 0.25 +Res-1.1655, 10478007200, 0.25 +Res-1.1656, 10478007200, 0.25 +Res-1.1657, 10478007200, 0.25 +Res-1.1658, 10478007200, 0.25 +Res-1.1659, 10478007200, 0.25 +Res-1.1660, 10478007200, 0.25 +Res-1.1661, 10478007200, 0.25 +Res-1.1662, 10478007200, 0.25 +Res-1.1663, 10478007200, 0.25 +Res-1.1664, 10478007200, 0.25 +Res-1.1665, 10478007200, 0.25 +Res-1.1666, 10478007200, 0.25 +Res-1.1667, 10478007200, 0.25 +Res-1.1668, 10478007200, 0.25 +Res-1.1669, 10478007200, 0.25 +Res-1.1670, 10478007200, 0.25 +Res-1.1671, 10478007200, 0.25 +Res-1.1672, 10478007200, 0.25 +Res-1.1673, 10478007200, 0.25 +Res-1.1674, 10478007200, 0.25 +Res-1.1675, 10478007200, 0.25 +Res-1.1676, 10478007200, 0.25 +Res-1.1677, 10478007200, 0.25 +Res-1.1678, 10478007200, 0.25 +Res-1.1679, 10478007200, 0.25 +Res-1.1680, 10478007200, 0.25 +Res-1.1681, 10478007200, 0.25 +Res-1.1682, 10478007200, 0.25 +Res-1.1683, 10478007200, 0.25 +Res-1.1684, 10478007200, 0.25 +Res-1.1685, 10478007200, 0.25 +Res-1.1686, 10478007200, 0.25 +Res-1.1687, 10478007200, 0.25 +Res-1.1688, 10478007200, 0.25 +Res-1.1689, 10478007200, 0.25 +Res-1.1690, 10478007200, 0.25 +Res-1.1691, 10478007200, 0.25 +Res-1.1692, 10478007200, 0.25 +Res-1.1693, 10478007200, 0.25 +Res-1.1694, 10478007200, 0.25 +Res-1.1695, 10478007200, 0.25 +Res-1.1696, 10478007200, 0.25 +Res-1.1697, 10478007200, 0.25 +Res-1.1698, 10478007200, 0.25 +Res-1.1699, 10478007200, 0.25 +Res-1.1700, 10478007200, 0.25 +Res-1.1701, 10478007200, 0.25 +Res-1.1702, 10478007200, 0.25 +Res-1.1703, 10478007200, 0.25 +Res-1.1704, 10478007200, 0.25 +Res-1.1705, 10478007200, 0.25 +Res-1.1706, 10478007200, 0.25 +Res-1.1707, 10478007200, 0.25 +Res-1.1708, 10478007200, 0.25 +Res-1.1709, 10478007200, 0.25 +Res-1.1710, 10478007200, 0.25 +Res-1.1711, 10478007200, 0.25 +Res-1.1712, 10478007200, 0.25 +Res-1.1713, 10478007200, 0.25 +Res-1.1714, 10478007200, 0.25 +Res-1.1715, 10478007200, 0.25 +Res-1.1716, 10478007200, 0.25 +Res-1.1717, 10478007200, 0.25 +Res-1.1718, 10478007200, 0.25 +Res-1.1719, 10478007200, 0.25 +Res-1.1720, 10478007200, 0.25 +Res-1.1721, 10478007200, 0.25 +Res-1.1722, 10478007200, 0.25 +Res-1.1723, 10478007200, 0.25 +Res-1.1724, 10478007200, 0.25 +Res-1.1725, 10478007200, 0.25 +Res-1.1726, 10478007200, 0.25 +Res-1.1727, 10478007200, 0.25 +Res-1.1728, 10478007200, 0.25 +Res-1.1729, 11670801700, 0.25 +Res-1.1730, 11670801700, 0.25 +Res-1.1731, 11670801700, 0.25 +Res-1.1732, 11670801700, 0.25 +Res-1.1733, 11670801700, 0.25 +Res-1.1734, 11670801700, 0.25 +Res-1.1735, 11670801700, 0.25 +Res-1.1736, 11670801700, 0.25 +Res-1.1737, 11670801700, 0.25 +Res-1.1738, 11670801700, 0.25 +Res-1.1739, 11670801700, 0.25 +Res-1.1740, 11670801700, 0.25 +Res-1.1741, 11670801700, 0.25 +Res-1.1742, 11670801700, 0.25 +Res-1.1743, 11670801700, 0.25 +Res-1.1744, 11670801700, 0.25 +Res-1.1745, 11670801700, 0.25 +Res-1.1746, 11670801700, 0.25 +Res-1.1747, 11670801700, 0.25 +Res-1.1748, 11670801700, 0.25 +Res-1.1749, 11670801700, 0.25 +Res-1.1750, 11670801700, 0.25 +Res-1.1751, 11670801700, 0.25 +Res-1.1752, 11670801700, 0.25 +Res-1.1753, 11670801700, 0.25 +Res-1.1754, 11670801700, 0.25 +Res-1.1755, 11670801700, 0.25 +Res-1.1756, 11670801700, 0.25 +Res-1.1757, 11670801700, 0.25 +Res-1.1758, 11670801700, 0.25 +Res-1.1759, 11670801700, 0.25 +Res-1.1760, 11670801700, 0.25 +Res-1.1761, 11670801700, 0.25 +Res-1.1762, 11670801700, 0.25 +Res-1.1763, 11670801700, 0.25 +Res-1.1764, 11670801700, 0.25 +Res-1.1765, 11670801700, 0.25 +Res-1.1766, 11670801700, 0.25 +Res-1.1767, 11670801700, 0.25 +Res-1.1768, 11670801700, 0.25 +Res-1.1769, 11670801700, 0.25 +Res-1.1770, 11670801700, 0.25 +Res-1.1771, 11670801700, 0.25 +Res-1.1772, 11670801700, 0.25 +Res-1.1773, 11670801700, 0.25 +Res-1.1774, 11670801700, 0.25 +Res-1.1775, 11670801700, 0.25 +Res-1.1776, 11670801700, 0.25 +Res-1.1777, 11670801700, 0.25 +Res-1.1778, 11670801700, 0.25 +Res-1.1779, 11670801700, 0.25 +Res-1.1780, 11670801700, 0.25 +Res-1.1781, 11670801700, 0.25 +Res-1.1782, 11670801700, 0.25 +Res-1.1783, 11670801700, 0.25 +Res-1.1784, 11670801700, 0.25 +Res-1.1785, 11670801700, 0.25 +Res-1.1786, 11670801700, 0.25 +Res-1.1787, 11670801700, 0.25 +Res-1.1788, 11670801700, 0.25 +Res-1.1789, 11670801700, 0.25 +Res-1.1790, 11670801700, 0.25 +Res-1.1791, 11670801700, 0.25 +Res-1.1792, 11670801700, 0.25 +Res-1.1793, 11670801700, 0.25 +Res-1.1794, 11670801700, 0.25 +Res-1.1795, 11670801700, 0.25 +Res-1.1796, 11670801700, 0.25 +Res-1.1797, 11670801700, 0.25 +Res-1.1798, 11670801700, 0.25 +Res-1.1799, 11670801700, 0.25 +Res-1.1800, 11670801700, 0.25 +Res-1.1801, 11670801700, 0.25 +Res-1.1802, 11670801700, 0.25 +Res-1.1803, 11670801700, 0.25 +Res-1.1804, 11670801700, 0.25 +Res-1.1805, 11670801700, 0.25 +Res-1.1806, 11670801700, 0.25 +Res-1.1807, 11670801700, 0.25 +Res-1.1808, 11670801700, 0.25 +Res-1.1809, 11670801700, 0.25 +Res-1.1810, 11670801700, 0.25 +Res-1.1811, 11670801700, 0.25 +Res-1.1812, 11670801700, 0.25 +Res-1.1813, 11670801700, 0.25 +Res-1.1814, 11670801700, 0.25 +Res-1.1815, 11670801700, 0.25 +Res-1.1816, 11670801700, 0.25 +Res-1.1817, 11670801700, 0.25 +Res-1.1818, 11670801700, 0.25 +Res-1.1819, 11670801700, 0.25 +Res-1.1820, 11670801700, 0.25 +Res-1.1821, 11670801700, 0.25 +Res-1.1822, 11670801700, 0.25 +Res-1.1823, 11670801700, 0.25 +Res-1.1824, 11670801700, 0.25 +Res-1.1825, 11670801700, 0.25 +Res-1.1826, 11670801700, 0.25 +Res-1.1827, 11670801700, 0.25 +Res-1.1828, 11670801700, 0.25 +Res-1.1829, 11670801700, 0.25 +Res-1.1830, 11670801700, 0.25 +Res-1.1831, 11670801700, 0.25 +Res-1.1832, 11670801700, 0.25 +Res-1.1833, 11670801700, 0.25 +Res-1.1834, 11670801700, 0.25 +Res-1.1835, 11670801700, 0.25 +Res-1.1836, 11670801700, 0.25 +Res-1.1837, 11670801700, 0.25 +Res-1.1838, 11670801700, 0.25 +Res-1.1839, 11670801700, 0.25 +Res-1.1840, 11670801700, 0.25 +Res-1.1841, 11670801700, 0.25 +Res-1.1842, 11670801700, 0.25 +Res-1.1843, 11670801700, 0.25 +Res-1.1844, 11670801700, 0.25 +Res-1.1845, 11670801700, 0.25 +Res-1.1846, 11670801700, 0.25 +Res-1.1847, 11670801700, 0.25 +Res-1.1848, 11670801700, 0.25 +Res-1.1849, 11670801700, 0.25 +Res-1.1850, 11670801700, 0.25 +Res-1.1851, 11670801700, 0.25 +Res-1.1852, 11670801700, 0.25 +Res-1.1853, 11670801700, 0.25 +Res-1.1854, 11670801700, 0.25 +Res-1.1855, 11670801700, 0.25 +Res-1.1856, 11670801700, 0.25 +Res-1.1857, 11670801700, 0.25 +Res-1.1858, 11670801700, 0.25 +Res-1.1859, 11670801700, 0.25 +Res-1.1860, 11670801700, 0.25 +Res-1.1861, 11670801700, 0.25 +Res-1.1862, 11670801700, 0.25 +Res-1.1863, 11670801700, 0.25 +Res-1.1864, 11670801700, 0.25 +Res-1.1865, 11670801700, 0.25 +Res-1.1866, 11670801700, 0.25 +Res-1.1867, 11670801700, 0.25 +Res-1.1868, 11670801700, 0.25 +Res-1.1869, 11670801700, 0.25 +Res-1.1870, 11670801700, 0.25 +Res-1.1871, 11670801700, 0.25 +Res-1.1872, 11670801700, 0.25 +Res-1.1873, 11670801700, 0.25 +Res-1.1874, 11670801700, 0.25 +Res-1.1875, 11670801700, 0.25 +Res-1.1876, 11670801700, 0.25 +Res-1.1877, 11670801700, 0.25 +Res-1.1878, 11670801700, 0.25 +Res-1.1879, 11670801700, 0.25 +Res-1.1880, 11670801700, 0.25 +Res-1.1881, 11670801700, 0.25 +Res-1.1882, 11670801700, 0.25 +Res-1.1883, 11670801700, 0.25 +Res-1.1884, 11670801700, 0.25 +Res-1.1885, 11670801700, 0.25 +Res-1.1886, 11670801700, 0.25 +Res-1.1887, 11670801700, 0.25 +Res-1.1888, 11670801700, 0.25 +Res-1.1889, 11670801700, 0.25 +Res-1.1890, 11670801700, 0.25 +Res-1.1891, 11670801700, 0.25 +Res-1.1892, 11670801700, 0.25 +Res-1.1893, 11670801700, 0.25 +Res-1.1894, 11670801700, 0.25 +Res-1.1895, 11670801700, 0.25 +Res-1.1896, 11670801700, 0.25 +Res-1.1897, 11670801700, 0.25 +Res-1.1898, 11670801700, 0.25 +Res-1.1899, 11670801700, 0.25 +Res-1.1900, 11670801700, 0.25 +Res-1.1901, 11670801700, 0.25 +Res-1.1902, 11670801700, 0.25 +Res-1.1903, 11670801700, 0.25 +Res-1.1904, 11670801700, 0.25 +Res-1.1905, 11670801700, 0.25 +Res-1.1906, 11670801700, 0.25 +Res-1.1907, 11670801700, 0.25 +Res-1.1908, 11670801700, 0.25 +Res-1.1909, 11670801700, 0.25 +Res-1.1910, 11670801700, 0.25 +Res-1.1911, 11670801700, 0.25 +Res-1.1912, 11670801700, 0.25 +Res-1.1913, 11670801700, 0.25 +Res-1.1914, 11670801700, 0.25 +Res-1.1915, 11670801700, 0.25 +Res-1.1916, 11670801700, 0.25 +Res-1.1917, 11670801700, 0.25 +Res-1.1918, 11670801700, 0.25 +Res-1.1919, 11670801700, 0.25 +Res-1.1920, 11670801700, 0.25 +Res-1.1921, 11670801700, 0.25 +Res-1.1922, 11670801700, 0.25 +Res-1.1923, 11670801700, 0.25 +Res-1.1924, 11670801700, 0.25 +Res-1.1925, 11670801700, 0.25 +Res-1.1926, 11670801700, 0.25 +Res-1.1927, 11670801700, 0.25 +Res-1.1928, 11670801700, 0.25 +Res-1.1929, 11670801700, 0.25 +Res-1.1930, 11670801700, 0.25 +Res-1.1931, 11670801700, 0.25 +Res-1.1932, 11670801700, 0.25 +Res-1.1933, 11670801700, 0.25 +Res-1.1934, 11670801700, 0.25 +Res-1.1935, 11670801700, 0.25 +Res-1.1936, 11670801700, 0.25 +Res-1.1937, 11670801700, 0.25 +Res-1.1938, 11670801700, 0.25 +Res-1.1939, 11670801700, 0.25 +Res-1.1940, 11670801700, 0.25 +Res-1.1941, 11670801700, 0.25 +Res-1.1942, 11670801700, 0.25 +Res-1.1943, 11670801700, 0.25 +Res-1.1944, 11670801700, 0.25 +Res-1.1945, 11670801700, 0.25 +Res-1.1946, 11670801700, 0.25 +Res-1.1947, 11670801700, 0.25 +Res-1.1948, 11670801700, 0.25 +Res-1.1949, 11670801700, 0.25 +Res-1.1950, 11670801700, 0.25 +Res-1.1951, 11670801700, 0.25 +Res-1.1952, 11670801700, 0.25 +Res-1.1953, 11670801700, 0.25 +Res-1.1954, 11670801700, 0.25 +Res-1.1955, 11670801700, 0.25 +Res-1.1956, 11670801700, 0.25 +Res-1.1957, 11670801700, 0.25 +Res-1.1958, 11670801700, 0.25 +Res-1.1959, 11670801700, 0.25 +Res-1.1960, 11670801700, 0.25 +Res-1.1961, 11670801700, 0.25 +Res-1.1962, 11670801700, 0.25 +Res-1.1963, 11670801700, 0.25 +Res-1.1964, 11670801700, 0.25 +Res-1.1965, 11670801700, 0.25 +Res-1.1966, 11670801700, 0.25 +Res-1.1967, 11670801700, 0.25 +Res-1.1968, 11670801700, 0.25 +Res-1.1969, 11670801700, 0.25 +Res-1.1970, 11670801700, 0.25 +Res-1.1971, 11670801700, 0.25 +Res-1.1972, 11670801700, 0.25 +Res-1.1973, 11670801700, 0.25 +Res-1.1974, 11670801700, 0.25 +Res-1.1975, 11670801700, 0.25 +Res-1.1976, 11670801700, 0.25 +Res-1.1977, 11670801700, 0.25 +Res-1.1978, 11670801700, 0.25 +Res-1.1979, 11670801700, 0.25 +Res-1.1980, 11670801700, 0.25 +Res-1.1981, 11670801700, 0.25 +Res-1.1982, 11670801700, 0.25 +Res-1.1983, 11670801700, 0.25 +Res-1.1984, 11670801700, 0.25 +Res-1.1985, 11670801700, 0.25 +Res-1.1986, 11670801700, 0.25 +Res-1.1987, 11670801700, 0.25 +Res-1.1988, 11670801700, 0.25 +Res-1.1989, 11670801700, 0.25 +Res-1.1990, 11670801700, 0.25 +Res-1.1991, 11670801700, 0.25 +Res-1.1992, 11670801700, 0.25 +Res-1.1993, 11670801700, 0.25 +Res-1.1994, 11670801700, 0.25 +Res-1.1995, 11670801700, 0.25 +Res-1.1996, 11670801700, 0.25 +Res-1.1997, 11670801700, 0.25 +Res-1.1998, 11670801700, 0.25 +Res-1.1999, 11670801700, 0.25 +Res-1.2000, 11670801700, 0.25 +Res-1.2001, 11670801700, 0.25 +Res-1.2002, 11670801700, 0.25 +Res-1.2003, 11670801700, 0.25 +Res-1.2004, 11670801700, 0.25 +Res-1.2005, 11670801700, 0.25 +Res-1.2006, 11670801700, 0.25 +Res-1.2007, 11670801700, 0.25 +Res-1.2008, 11670801700, 0.25 +Res-1.2009, 11670801700, 0.25 +Res-1.2010, 11670801700, 0.25 +Res-1.2011, 11670801700, 0.25 +Res-1.2012, 11670801700, 0.25 +Res-1.2013, 11670801700, 0.25 +Res-1.2014, 11670801700, 0.25 +Res-1.2015, 11670801700, 0.25 +Res-1.2016, 11670801700, 0.25 +Res-1.2017, 6227222750, 0.25 +Res-1.2018, 6227222750, 0.25 +Res-1.2019, 6227222750, 0.25 +Res-1.2020, 6227222750, 0.25 +Res-1.2021, 6227222750, 0.25 +Res-1.2022, 6227222750, 0.25 +Res-1.2023, 6227222750, 0.25 +Res-1.2024, 6227222750, 0.25 +Res-1.2025, 6227222750, 0.25 +Res-1.2026, 6227222750, 0.25 +Res-1.2027, 6227222750, 0.25 +Res-1.2028, 6227222750, 0.25 +Res-1.2029, 6227222750, 0.25 +Res-1.2030, 6227222750, 0.25 +Res-1.2031, 6227222750, 0.25 +Res-1.2032, 6227222750, 0.25 +Res-1.2033, 6227222750, 0.25 +Res-1.2034, 6227222750, 0.25 +Res-1.2035, 6227222750, 0.25 +Res-1.2036, 6227222750, 0.25 +Res-1.2037, 6227222750, 0.25 +Res-1.2038, 6227222750, 0.25 +Res-1.2039, 6227222750, 0.25 +Res-1.2040, 6227222750, 0.25 +Res-1.2041, 6227222750, 0.25 +Res-1.2042, 6227222750, 0.25 +Res-1.2043, 6227222750, 0.25 +Res-1.2044, 6227222750, 0.25 +Res-1.2045, 6227222750, 0.25 +Res-1.2046, 6227222750, 0.25 +Res-1.2047, 6227222750, 0.25 +Res-1.2048, 6227222750, 0.25 +Res-1.2049, 6227222750, 0.25 +Res-1.2050, 6227222750, 0.25 +Res-1.2051, 6227222750, 0.25 +Res-1.2052, 6227222750, 0.25 +Res-1.2053, 6227222750, 0.25 +Res-1.2054, 6227222750, 0.25 +Res-1.2055, 6227222750, 0.25 +Res-1.2056, 6227222750, 0.25 +Res-1.2057, 6227222750, 0.25 +Res-1.2058, 6227222750, 0.25 +Res-1.2059, 6227222750, 0.25 +Res-1.2060, 6227222750, 0.25 +Res-1.2061, 6227222750, 0.25 +Res-1.2062, 6227222750, 0.25 +Res-1.2063, 6227222750, 0.25 +Res-1.2064, 6227222750, 0.25 +Res-1.2065, 6227222750, 0.25 +Res-1.2066, 6227222750, 0.25 +Res-1.2067, 6227222750, 0.25 +Res-1.2068, 6227222750, 0.25 +Res-1.2069, 6227222750, 0.25 +Res-1.2070, 6227222750, 0.25 +Res-1.2071, 6227222750, 0.25 +Res-1.2072, 6227222750, 0.25 +Res-1.2073, 6227222750, 0.25 +Res-1.2074, 6227222750, 0.25 +Res-1.2075, 6227222750, 0.25 +Res-1.2076, 6227222750, 0.25 +Res-1.2077, 6227222750, 0.25 +Res-1.2078, 6227222750, 0.25 +Res-1.2079, 6227222750, 0.25 +Res-1.2080, 6227222750, 0.25 +Res-1.2081, 6227222750, 0.25 +Res-1.2082, 6227222750, 0.25 +Res-1.2083, 6227222750, 0.25 +Res-1.2084, 6227222750, 0.25 +Res-1.2085, 6227222750, 0.25 +Res-1.2086, 6227222750, 0.25 +Res-1.2087, 6227222750, 0.25 +Res-1.2088, 6227222750, 0.25 +Res-1.2089, 6227222750, 0.25 +Res-1.2090, 6227222750, 0.25 +Res-1.2091, 6227222750, 0.25 +Res-1.2092, 6227222750, 0.25 +Res-1.2093, 6227222750, 0.25 +Res-1.2094, 6227222750, 0.25 +Res-1.2095, 6227222750, 0.25 +Res-1.2096, 6227222750, 0.25 +Res-1.2097, 6227222750, 0.25 +Res-1.2098, 6227222750, 0.25 +Res-1.2099, 6227222750, 0.25 +Res-1.2100, 6227222750, 0.25 +Res-1.2101, 6227222750, 0.25 +Res-1.2102, 6227222750, 0.25 +Res-1.2103, 6227222750, 0.25 +Res-1.2104, 6227222750, 0.25 +Res-1.2105, 6227222750, 0.25 +Res-1.2106, 6227222750, 0.25 +Res-1.2107, 6227222750, 0.25 +Res-1.2108, 6227222750, 0.25 +Res-1.2109, 6227222750, 0.25 +Res-1.2110, 6227222750, 0.25 +Res-1.2111, 6227222750, 0.25 +Res-1.2112, 6227222750, 0.25 +Res-1.2113, 6227222750, 0.25 +Res-1.2114, 6227222750, 0.25 +Res-1.2115, 6227222750, 0.25 +Res-1.2116, 6227222750, 0.25 +Res-1.2117, 6227222750, 0.25 +Res-1.2118, 6227222750, 0.25 +Res-1.2119, 6227222750, 0.25 +Res-1.2120, 6227222750, 0.25 +Res-1.2121, 6227222750, 0.25 +Res-1.2122, 6227222750, 0.25 +Res-1.2123, 6227222750, 0.25 +Res-1.2124, 6227222750, 0.25 +Res-1.2125, 6227222750, 0.25 +Res-1.2126, 6227222750, 0.25 +Res-1.2127, 6227222750, 0.25 +Res-1.2128, 6227222750, 0.25 +Res-1.2129, 6227222750, 0.25 +Res-1.2130, 6227222750, 0.25 +Res-1.2131, 6227222750, 0.25 +Res-1.2132, 6227222750, 0.25 +Res-1.2133, 6227222750, 0.25 +Res-1.2134, 6227222750, 0.25 +Res-1.2135, 6227222750, 0.25 +Res-1.2136, 6227222750, 0.25 +Res-1.2137, 6227222750, 0.25 +Res-1.2138, 6227222750, 0.25 +Res-1.2139, 6227222750, 0.25 +Res-1.2140, 6227222750, 0.25 +Res-1.2141, 6227222750, 0.25 +Res-1.2142, 6227222750, 0.25 +Res-1.2143, 6227222750, 0.25 +Res-1.2144, 6227222750, 0.25 +Res-1.2145, 6227222750, 0.25 +Res-1.2146, 6227222750, 0.25 +Res-1.2147, 6227222750, 0.25 +Res-1.2148, 6227222750, 0.25 +Res-1.2149, 6227222750, 0.25 +Res-1.2150, 6227222750, 0.25 +Res-1.2151, 6227222750, 0.25 +Res-1.2152, 6227222750, 0.25 +Res-1.2153, 6227222750, 0.25 +Res-1.2154, 6227222750, 0.25 +Res-1.2155, 6227222750, 0.25 +Res-1.2156, 6227222750, 0.25 +Res-1.2157, 6227222750, 0.25 +Res-1.2158, 6227222750, 0.25 +Res-1.2159, 6227222750, 0.25 +Res-1.2160, 6227222750, 0.25 +Res-1.2161, 6227222750, 0.25 +Res-1.2162, 6227222750, 0.25 +Res-1.2163, 6227222750, 0.25 +Res-1.2164, 6227222750, 0.25 +Res-1.2165, 6227222750, 0.25 +Res-1.2166, 6227222750, 0.25 +Res-1.2167, 6227222750, 0.25 +Res-1.2168, 6227222750, 0.25 +Res-1.2169, 6227222750, 0.25 +Res-1.2170, 6227222750, 0.25 +Res-1.2171, 6227222750, 0.25 +Res-1.2172, 6227222750, 0.25 +Res-1.2173, 6227222750, 0.25 +Res-1.2174, 6227222750, 0.25 +Res-1.2175, 6227222750, 0.25 +Res-1.2176, 6227222750, 0.25 +Res-1.2177, 6227222750, 0.25 +Res-1.2178, 6227222750, 0.25 +Res-1.2179, 6227222750, 0.25 +Res-1.2180, 6227222750, 0.25 +Res-1.2181, 6227222750, 0.25 +Res-1.2182, 6227222750, 0.25 +Res-1.2183, 6227222750, 0.25 +Res-1.2184, 6227222750, 0.25 +Res-1.2185, 6227222750, 0.25 +Res-1.2186, 6227222750, 0.25 +Res-1.2187, 6227222750, 0.25 +Res-1.2188, 6227222750, 0.25 +Res-1.2189, 6227222750, 0.25 +Res-1.2190, 6227222750, 0.25 +Res-1.2191, 6227222750, 0.25 +Res-1.2192, 6227222750, 0.25 +Res-1.2193, 6227222750, 0.25 +Res-1.2194, 6227222750, 0.25 +Res-1.2195, 6227222750, 0.25 +Res-1.2196, 6227222750, 0.25 +Res-1.2197, 6227222750, 0.25 +Res-1.2198, 6227222750, 0.25 +Res-1.2199, 6227222750, 0.25 +Res-1.2200, 6227222750, 0.25 +Res-1.2201, 6227222750, 0.25 +Res-1.2202, 6227222750, 0.25 +Res-1.2203, 6227222750, 0.25 +Res-1.2204, 6227222750, 0.25 +Res-1.2205, 6227222750, 0.25 +Res-1.2206, 6227222750, 0.25 +Res-1.2207, 6227222750, 0.25 +Res-1.2208, 6227222750, 0.25 +Res-1.2209, 6227222750, 0.25 +Res-1.2210, 6227222750, 0.25 +Res-1.2211, 6227222750, 0.25 +Res-1.2212, 6227222750, 0.25 +Res-1.2213, 6227222750, 0.25 +Res-1.2214, 6227222750, 0.25 +Res-1.2215, 6227222750, 0.25 +Res-1.2216, 6227222750, 0.25 +Res-1.2217, 6227222750, 0.25 +Res-1.2218, 6227222750, 0.25 +Res-1.2219, 6227222750, 0.25 +Res-1.2220, 6227222750, 0.25 +Res-1.2221, 6227222750, 0.25 +Res-1.2222, 6227222750, 0.25 +Res-1.2223, 6227222750, 0.25 +Res-1.2224, 6227222750, 0.25 +Res-1.2225, 6227222750, 0.25 +Res-1.2226, 6227222750, 0.25 +Res-1.2227, 6227222750, 0.25 +Res-1.2228, 6227222750, 0.25 +Res-1.2229, 6227222750, 0.25 +Res-1.2230, 6227222750, 0.25 +Res-1.2231, 6227222750, 0.25 +Res-1.2232, 6227222750, 0.25 +Res-1.2233, 6227222750, 0.25 +Res-1.2234, 6227222750, 0.25 +Res-1.2235, 6227222750, 0.25 +Res-1.2236, 6227222750, 0.25 +Res-1.2237, 6227222750, 0.25 +Res-1.2238, 6227222750, 0.25 +Res-1.2239, 6227222750, 0.25 +Res-1.2240, 6227222750, 0.25 +Res-1.2241, 6227222750, 0.25 +Res-1.2242, 6227222750, 0.25 +Res-1.2243, 6227222750, 0.25 +Res-1.2244, 6227222750, 0.25 +Res-1.2245, 6227222750, 0.25 +Res-1.2246, 6227222750, 0.25 +Res-1.2247, 6227222750, 0.25 +Res-1.2248, 6227222750, 0.25 +Res-1.2249, 6227222750, 0.25 +Res-1.2250, 6227222750, 0.25 +Res-1.2251, 6227222750, 0.25 +Res-1.2252, 6227222750, 0.25 +Res-1.2253, 6227222750, 0.25 +Res-1.2254, 6227222750, 0.25 +Res-1.2255, 6227222750, 0.25 +Res-1.2256, 6227222750, 0.25 +Res-1.2257, 6227222750, 0.25 +Res-1.2258, 6227222750, 0.25 +Res-1.2259, 6227222750, 0.25 +Res-1.2260, 6227222750, 0.25 +Res-1.2261, 6227222750, 0.25 +Res-1.2262, 6227222750, 0.25 +Res-1.2263, 6227222750, 0.25 +Res-1.2264, 6227222750, 0.25 +Res-1.2265, 6227222750, 0.25 +Res-1.2266, 6227222750, 0.25 +Res-1.2267, 6227222750, 0.25 +Res-1.2268, 6227222750, 0.25 +Res-1.2269, 6227222750, 0.25 +Res-1.2270, 6227222750, 0.25 +Res-1.2271, 6227222750, 0.25 +Res-1.2272, 6227222750, 0.25 +Res-1.2273, 6227222750, 0.25 +Res-1.2274, 6227222750, 0.25 +Res-1.2275, 6227222750, 0.25 +Res-1.2276, 6227222750, 0.25 +Res-1.2277, 6227222750, 0.25 +Res-1.2278, 6227222750, 0.25 +Res-1.2279, 6227222750, 0.25 +Res-1.2280, 6227222750, 0.25 +Res-1.2281, 6227222750, 0.25 +Res-1.2282, 6227222750, 0.25 +Res-1.2283, 6227222750, 0.25 +Res-1.2284, 6227222750, 0.25 +Res-1.2285, 6227222750, 0.25 +Res-1.2286, 6227222750, 0.25 +Res-1.2287, 6227222750, 0.25 +Res-1.2288, 6227222750, 0.25 +Res-1.2289, 6227222750, 0.25 +Res-1.2290, 6227222750, 0.25 +Res-1.2291, 6227222750, 0.25 +Res-1.2292, 6227222750, 0.25 +Res-1.2293, 6227222750, 0.25 +Res-1.2294, 6227222750, 0.25 +Res-1.2295, 6227222750, 0.25 +Res-1.2296, 6227222750, 0.25 +Res-1.2297, 6227222750, 0.25 +Res-1.2298, 6227222750, 0.25 +Res-1.2299, 6227222750, 0.25 +Res-1.2300, 6227222750, 0.25 +Res-1.2301, 6227222750, 0.25 +Res-1.2302, 6227222750, 0.25 +Res-1.2303, 6227222750, 0.25 +Res-1.2304, 6227222750, 0.25 +Res-1.2305, 6439192352.5, 0.25 +Res-1.2306, 6439192352.5, 0.25 +Res-1.2307, 6439192352.5, 0.25 +Res-1.2308, 6439192352.5, 0.25 +Res-1.2309, 6439192352.5, 0.25 +Res-1.2310, 6439192352.5, 0.25 +Res-1.2311, 6439192352.5, 0.25 +Res-1.2312, 6439192352.5, 0.25 +Res-1.2313, 6439192352.5, 0.25 +Res-1.2314, 6439192352.5, 0.25 +Res-1.2315, 6439192352.5, 0.25 +Res-1.2316, 6439192352.5, 0.25 +Res-1.2317, 6439192352.5, 0.25 +Res-1.2318, 6439192352.5, 0.25 +Res-1.2319, 6439192352.5, 0.25 +Res-1.2320, 6439192352.5, 0.25 +Res-1.2321, 6439192352.5, 0.25 +Res-1.2322, 6439192352.5, 0.25 +Res-1.2323, 6439192352.5, 0.25 +Res-1.2324, 6439192352.5, 0.25 +Res-1.2325, 6439192352.5, 0.25 +Res-1.2326, 6439192352.5, 0.25 +Res-1.2327, 6439192352.5, 0.25 +Res-1.2328, 6439192352.5, 0.25 +Res-1.2329, 6439192352.5, 0.25 +Res-1.2330, 6439192352.5, 0.25 +Res-1.2331, 6439192352.5, 0.25 +Res-1.2332, 6439192352.5, 0.25 +Res-1.2333, 6439192352.5, 0.25 +Res-1.2334, 6439192352.5, 0.25 +Res-1.2335, 6439192352.5, 0.25 +Res-1.2336, 6439192352.5, 0.25 +Res-1.2337, 6439192352.5, 0.25 +Res-1.2338, 6439192352.5, 0.25 +Res-1.2339, 6439192352.5, 0.25 +Res-1.2340, 6439192352.5, 0.25 +Res-1.2341, 6439192352.5, 0.25 +Res-1.2342, 6439192352.5, 0.25 +Res-1.2343, 6439192352.5, 0.25 +Res-1.2344, 6439192352.5, 0.25 +Res-1.2345, 6439192352.5, 0.25 +Res-1.2346, 6439192352.5, 0.25 +Res-1.2347, 6439192352.5, 0.25 +Res-1.2348, 6439192352.5, 0.25 +Res-1.2349, 6439192352.5, 0.25 +Res-1.2350, 6439192352.5, 0.25 +Res-1.2351, 6439192352.5, 0.25 +Res-1.2352, 6439192352.5, 0.25 +Res-1.2353, 6439192352.5, 0.25 +Res-1.2354, 6439192352.5, 0.25 +Res-1.2355, 6439192352.5, 0.25 +Res-1.2356, 6439192352.5, 0.25 +Res-1.2357, 6439192352.5, 0.25 +Res-1.2358, 6439192352.5, 0.25 +Res-1.2359, 6439192352.5, 0.25 +Res-1.2360, 6439192352.5, 0.25 +Res-1.2361, 6439192352.5, 0.25 +Res-1.2362, 6439192352.5, 0.25 +Res-1.2363, 6439192352.5, 0.25 +Res-1.2364, 6439192352.5, 0.25 +Res-1.2365, 6439192352.5, 0.25 +Res-1.2366, 6439192352.5, 0.25 +Res-1.2367, 6439192352.5, 0.25 +Res-1.2368, 6439192352.5, 0.25 +Res-1.2369, 6439192352.5, 0.25 +Res-1.2370, 6439192352.5, 0.25 +Res-1.2371, 6439192352.5, 0.25 +Res-1.2372, 6439192352.5, 0.25 +Res-1.2373, 6439192352.5, 0.25 +Res-1.2374, 6439192352.5, 0.25 +Res-1.2375, 6439192352.5, 0.25 +Res-1.2376, 6439192352.5, 0.25 +Res-1.2377, 6439192352.5, 0.25 +Res-1.2378, 6439192352.5, 0.25 +Res-1.2379, 6439192352.5, 0.25 +Res-1.2380, 6439192352.5, 0.25 +Res-1.2381, 6439192352.5, 0.25 +Res-1.2382, 6439192352.5, 0.25 +Res-1.2383, 6439192352.5, 0.25 +Res-1.2384, 6439192352.5, 0.25 +Res-1.2385, 6439192352.5, 0.25 +Res-1.2386, 6439192352.5, 0.25 +Res-1.2387, 6439192352.5, 0.25 +Res-1.2388, 6439192352.5, 0.25 +Res-1.2389, 6439192352.5, 0.25 +Res-1.2390, 6439192352.5, 0.25 +Res-1.2391, 6439192352.5, 0.25 +Res-1.2392, 6439192352.5, 0.25 +Res-1.2393, 6439192352.5, 0.25 +Res-1.2394, 6439192352.5, 0.25 +Res-1.2395, 6439192352.5, 0.25 +Res-1.2396, 6439192352.5, 0.25 +Res-1.2397, 6439192352.5, 0.25 +Res-1.2398, 6439192352.5, 0.25 +Res-1.2399, 6439192352.5, 0.25 +Res-1.2400, 6439192352.5, 0.25 +Res-1.2401, 6439192352.5, 0.25 +Res-1.2402, 6439192352.5, 0.25 +Res-1.2403, 6439192352.5, 0.25 +Res-1.2404, 6439192352.5, 0.25 +Res-1.2405, 6439192352.5, 0.25 +Res-1.2406, 6439192352.5, 0.25 +Res-1.2407, 6439192352.5, 0.25 +Res-1.2408, 6439192352.5, 0.25 +Res-1.2409, 6439192352.5, 0.25 +Res-1.2410, 6439192352.5, 0.25 +Res-1.2411, 6439192352.5, 0.25 +Res-1.2412, 6439192352.5, 0.25 +Res-1.2413, 6439192352.5, 0.25 +Res-1.2414, 6439192352.5, 0.25 +Res-1.2415, 6439192352.5, 0.25 +Res-1.2416, 6439192352.5, 0.25 +Res-1.2417, 6439192352.5, 0.25 +Res-1.2418, 6439192352.5, 0.25 +Res-1.2419, 6439192352.5, 0.25 +Res-1.2420, 6439192352.5, 0.25 +Res-1.2421, 6439192352.5, 0.25 +Res-1.2422, 6439192352.5, 0.25 +Res-1.2423, 6439192352.5, 0.25 +Res-1.2424, 6439192352.5, 0.25 +Res-1.2425, 6439192352.5, 0.25 +Res-1.2426, 6439192352.5, 0.25 +Res-1.2427, 6439192352.5, 0.25 +Res-1.2428, 6439192352.5, 0.25 +Res-1.2429, 6439192352.5, 0.25 +Res-1.2430, 6439192352.5, 0.25 +Res-1.2431, 6439192352.5, 0.25 +Res-1.2432, 6439192352.5, 0.25 +Res-1.2433, 6439192352.5, 0.25 +Res-1.2434, 6439192352.5, 0.25 +Res-1.2435, 6439192352.5, 0.25 +Res-1.2436, 6439192352.5, 0.25 +Res-1.2437, 6439192352.5, 0.25 +Res-1.2438, 6439192352.5, 0.25 +Res-1.2439, 6439192352.5, 0.25 +Res-1.2440, 6439192352.5, 0.25 +Res-1.2441, 6439192352.5, 0.25 +Res-1.2442, 6439192352.5, 0.25 +Res-1.2443, 6439192352.5, 0.25 +Res-1.2444, 6439192352.5, 0.25 +Res-1.2445, 6439192352.5, 0.25 +Res-1.2446, 6439192352.5, 0.25 +Res-1.2447, 6439192352.5, 0.25 +Res-1.2448, 6439192352.5, 0.25 +Res-1.2449, 6439192352.5, 0.25 +Res-1.2450, 6439192352.5, 0.25 +Res-1.2451, 6439192352.5, 0.25 +Res-1.2452, 6439192352.5, 0.25 +Res-1.2453, 6439192352.5, 0.25 +Res-1.2454, 6439192352.5, 0.25 +Res-1.2455, 6439192352.5, 0.25 +Res-1.2456, 6439192352.5, 0.25 +Res-1.2457, 6439192352.5, 0.25 +Res-1.2458, 6439192352.5, 0.25 +Res-1.2459, 6439192352.5, 0.25 +Res-1.2460, 6439192352.5, 0.25 +Res-1.2461, 6439192352.5, 0.25 +Res-1.2462, 6439192352.5, 0.25 +Res-1.2463, 6439192352.5, 0.25 +Res-1.2464, 6439192352.5, 0.25 +Res-1.2465, 6439192352.5, 0.25 +Res-1.2466, 6439192352.5, 0.25 +Res-1.2467, 6439192352.5, 0.25 +Res-1.2468, 6439192352.5, 0.25 +Res-1.2469, 6439192352.5, 0.25 +Res-1.2470, 6439192352.5, 0.25 +Res-1.2471, 6439192352.5, 0.25 +Res-1.2472, 6439192352.5, 0.25 +Res-1.2473, 6439192352.5, 0.25 +Res-1.2474, 6439192352.5, 0.25 +Res-1.2475, 6439192352.5, 0.25 +Res-1.2476, 6439192352.5, 0.25 +Res-1.2477, 6439192352.5, 0.25 +Res-1.2478, 6439192352.5, 0.25 +Res-1.2479, 6439192352.5, 0.25 +Res-1.2480, 6439192352.5, 0.25 +Res-1.2481, 6439192352.5, 0.25 +Res-1.2482, 6439192352.5, 0.25 +Res-1.2483, 6439192352.5, 0.25 +Res-1.2484, 6439192352.5, 0.25 +Res-1.2485, 6439192352.5, 0.25 +Res-1.2486, 6439192352.5, 0.25 +Res-1.2487, 6439192352.5, 0.25 +Res-1.2488, 6439192352.5, 0.25 +Res-1.2489, 6439192352.5, 0.25 +Res-1.2490, 6439192352.5, 0.25 +Res-1.2491, 6439192352.5, 0.25 +Res-1.2492, 6439192352.5, 0.25 +Res-1.2493, 6439192352.5, 0.25 +Res-1.2494, 6439192352.5, 0.25 +Res-1.2495, 6439192352.5, 0.25 +Res-1.2496, 6439192352.5, 0.25 +Res-1.2497, 6439192352.5, 0.25 +Res-1.2498, 6439192352.5, 0.25 +Res-1.2499, 6439192352.5, 0.25 +Res-1.2500, 6439192352.5, 0.25 +Res-1.2501, 6439192352.5, 0.25 +Res-1.2502, 6439192352.5, 0.25 +Res-1.2503, 6439192352.5, 0.25 +Res-1.2504, 6439192352.5, 0.25 +Res-1.2505, 6439192352.5, 0.25 +Res-1.2506, 6439192352.5, 0.25 +Res-1.2507, 6439192352.5, 0.25 +Res-1.2508, 6439192352.5, 0.25 +Res-1.2509, 6439192352.5, 0.25 +Res-1.2510, 6439192352.5, 0.25 +Res-1.2511, 6439192352.5, 0.25 +Res-1.2512, 6439192352.5, 0.25 +Res-1.2513, 6439192352.5, 0.25 +Res-1.2514, 6439192352.5, 0.25 +Res-1.2515, 6439192352.5, 0.25 +Res-1.2516, 6439192352.5, 0.25 +Res-1.2517, 6439192352.5, 0.25 +Res-1.2518, 6439192352.5, 0.25 +Res-1.2519, 6439192352.5, 0.25 +Res-1.2520, 6439192352.5, 0.25 +Res-1.2521, 6439192352.5, 0.25 +Res-1.2522, 6439192352.5, 0.25 +Res-1.2523, 6439192352.5, 0.25 +Res-1.2524, 6439192352.5, 0.25 +Res-1.2525, 6439192352.5, 0.25 +Res-1.2526, 6439192352.5, 0.25 +Res-1.2527, 6439192352.5, 0.25 +Res-1.2528, 6439192352.5, 0.25 +Res-1.2529, 6439192352.5, 0.25 +Res-1.2530, 6439192352.5, 0.25 +Res-1.2531, 6439192352.5, 0.25 +Res-1.2532, 6439192352.5, 0.25 +Res-1.2533, 6439192352.5, 0.25 +Res-1.2534, 6439192352.5, 0.25 +Res-1.2535, 6439192352.5, 0.25 +Res-1.2536, 6439192352.5, 0.25 +Res-1.2537, 6439192352.5, 0.25 +Res-1.2538, 6439192352.5, 0.25 +Res-1.2539, 6439192352.5, 0.25 +Res-1.2540, 6439192352.5, 0.25 +Res-1.2541, 6439192352.5, 0.25 +Res-1.2542, 6439192352.5, 0.25 +Res-1.2543, 6439192352.5, 0.25 +Res-1.2544, 6439192352.5, 0.25 +Res-1.2545, 6439192352.5, 0.25 +Res-1.2546, 6439192352.5, 0.25 +Res-1.2547, 6439192352.5, 0.25 +Res-1.2548, 6439192352.5, 0.25 +Res-1.2549, 6439192352.5, 0.25 +Res-1.2550, 6439192352.5, 0.25 +Res-1.2551, 6439192352.5, 0.25 +Res-1.2552, 6439192352.5, 0.25 +Res-1.2553, 6439192352.5, 0.25 +Res-1.2554, 6439192352.5, 0.25 +Res-1.2555, 6439192352.5, 0.25 +Res-1.2556, 6439192352.5, 0.25 +Res-1.2557, 6439192352.5, 0.25 +Res-1.2558, 6439192352.5, 0.25 +Res-1.2559, 6439192352.5, 0.25 +Res-1.2560, 6439192352.5, 0.25 +Res-1.2561, 6439192352.5, 0.25 +Res-1.2562, 6439192352.5, 0.25 +Res-1.2563, 6439192352.5, 0.25 +Res-1.2564, 6439192352.5, 0.25 +Res-1.2565, 6439192352.5, 0.25 +Res-1.2566, 6439192352.5, 0.25 +Res-1.2567, 6439192352.5, 0.25 +Res-1.2568, 6439192352.5, 0.25 +Res-1.2569, 6439192352.5, 0.25 +Res-1.2570, 6439192352.5, 0.25 +Res-1.2571, 6439192352.5, 0.25 +Res-1.2572, 6439192352.5, 0.25 +Res-1.2573, 6439192352.5, 0.25 +Res-1.2574, 6439192352.5, 0.25 +Res-1.2575, 6439192352.5, 0.25 +Res-1.2576, 6439192352.5, 0.25 +Res-1.2577, 6439192352.5, 0.25 +Res-1.2578, 6439192352.5, 0.25 +Res-1.2579, 6439192352.5, 0.25 +Res-1.2580, 6439192352.5, 0.25 +Res-1.2581, 6439192352.5, 0.25 +Res-1.2582, 6439192352.5, 0.25 +Res-1.2583, 6439192352.5, 0.25 +Res-1.2584, 6439192352.5, 0.25 +Res-1.2585, 6439192352.5, 0.25 +Res-1.2586, 6439192352.5, 0.25 +Res-1.2587, 6439192352.5, 0.25 +Res-1.2588, 6439192352.5, 0.25 +Res-1.2589, 6439192352.5, 0.25 +Res-1.2590, 6439192352.5, 0.25 +Res-1.2591, 6439192352.5, 0.25 +Res-1.2592, 6439192352.5, 0.25 +Res-1.2593, 5316491363.7363, 0.25 +Res-1.2594, 5316491363.7363, 0.25 +Res-1.2595, 5316491363.7363, 0.25 +Res-1.2596, 5316491363.7363, 0.25 +Res-1.2597, 5316491363.7363, 0.25 +Res-1.2598, 5316491363.7363, 0.25 +Res-1.2599, 5316491363.7363, 0.25 +Res-1.2600, 5316491363.7363, 0.25 +Res-1.2601, 5316491363.7363, 0.25 +Res-1.2602, 5316491363.7363, 0.25 +Res-1.2603, 5316491363.7363, 0.25 +Res-1.2604, 5316491363.7363, 0.25 +Res-1.2605, 5316491363.7363, 0.25 +Res-1.2606, 5316491363.7363, 0.25 +Res-1.2607, 5316491363.7363, 0.25 +Res-1.2608, 5316491363.7363, 0.25 +Res-1.2609, 5316491363.7363, 0.25 +Res-1.2610, 5316491363.7363, 0.25 +Res-1.2611, 5316491363.7363, 0.25 +Res-1.2612, 5316491363.7363, 0.25 +Res-1.2613, 5316491363.7363, 0.25 +Res-1.2614, 5316491363.7363, 0.25 +Res-1.2615, 5316491363.7363, 0.25 +Res-1.2616, 5316491363.7363, 0.25 +Res-1.2617, 5316491363.7363, 0.25 +Res-1.2618, 5316491363.7363, 0.25 +Res-1.2619, 5316491363.7363, 0.25 +Res-1.2620, 5316491363.7363, 0.25 +Res-1.2621, 5316491363.7363, 0.25 +Res-1.2622, 5316491363.7363, 0.25 +Res-1.2623, 5316491363.7363, 0.25 +Res-1.2624, 5316491363.7363, 0.25 +Res-1.2625, 5316491363.7363, 0.25 +Res-1.2626, 5316491363.7363, 0.25 +Res-1.2627, 5316491363.7363, 0.25 +Res-1.2628, 5316491363.7363, 0.25 +Res-1.2629, 5316491363.7363, 0.25 +Res-1.2630, 5316491363.7363, 0.25 +Res-1.2631, 5316491363.7363, 0.25 +Res-1.2632, 5316491363.7363, 0.25 +Res-1.2633, 5316491363.7363, 0.25 +Res-1.2634, 5316491363.7363, 0.25 +Res-1.2635, 5316491363.7363, 0.25 +Res-1.2636, 5316491363.7363, 0.25 +Res-1.2637, 5316491363.7363, 0.25 +Res-1.2638, 5316491363.7363, 0.25 +Res-1.2639, 5316491363.7363, 0.25 +Res-1.2640, 5316491363.7363, 0.25 +Res-1.2641, 5316491363.7363, 0.25 +Res-1.2642, 5316491363.7363, 0.25 +Res-1.2643, 5316491363.7363, 0.25 +Res-1.2644, 5316491363.7363, 0.25 +Res-1.2645, 5316491363.7363, 0.25 +Res-1.2646, 5316491363.7363, 0.25 +Res-1.2647, 5316491363.7363, 0.25 +Res-1.2648, 5316491363.7363, 0.25 +Res-1.2649, 5316491363.7363, 0.25 +Res-1.2650, 5316491363.7363, 0.25 +Res-1.2651, 5316491363.7363, 0.25 +Res-1.2652, 5316491363.7363, 0.25 +Res-1.2653, 5316491363.7363, 0.25 +Res-1.2654, 5316491363.7363, 0.25 +Res-1.2655, 5316491363.7363, 0.25 +Res-1.2656, 5316491363.7363, 0.25 +Res-1.2657, 5316491363.7363, 0.25 +Res-1.2658, 5316491363.7363, 0.25 +Res-1.2659, 5316491363.7363, 0.25 +Res-1.2660, 5316491363.7363, 0.25 +Res-1.2661, 5316491363.7363, 0.25 +Res-1.2662, 5316491363.7363, 0.25 +Res-1.2663, 5316491363.7363, 0.25 +Res-1.2664, 5316491363.7363, 0.25 +Res-1.2665, 5316491363.7363, 0.25 +Res-1.2666, 5316491363.7363, 0.25 +Res-1.2667, 5316491363.7363, 0.25 +Res-1.2668, 5316491363.7363, 0.25 +Res-1.2669, 5316491363.7363, 0.25 +Res-1.2670, 5316491363.7363, 0.25 +Res-1.2671, 5316491363.7363, 0.25 +Res-1.2672, 5316491363.7363, 0.25 +Res-1.2673, 5316491363.7363, 0.25 +Res-1.2674, 5316491363.7363, 0.25 +Res-1.2675, 5316491363.7363, 0.25 +Res-1.2676, 5316491363.7363, 0.25 +Res-1.2677, 5316491363.7363, 0.25 +Res-1.2678, 5316491363.7363, 0.25 +Res-1.2679, 5316491363.7363, 0.25 +Res-1.2680, 5316491363.7363, 0.25 +Res-1.2681, 5316491363.7363, 0.25 +Res-1.2682, 5316491363.7363, 0.25 +Res-1.2683, 5316491363.7363, 0.25 +Res-1.2684, 5316491363.7363, 0.25 +Res-1.2685, 5316491363.7363, 0.25 +Res-1.2686, 5316491363.7363, 0.25 +Res-1.2687, 5316491363.7363, 0.25 +Res-1.2688, 5316491363.7363, 0.25 +Res-1.2689, 5316491363.7363, 0.25 +Res-1.2690, 5316491363.7363, 0.25 +Res-1.2691, 5316491363.7363, 0.25 +Res-1.2692, 5316491363.7363, 0.25 +Res-1.2693, 5316491363.7363, 0.25 +Res-1.2694, 5316491363.7363, 0.25 +Res-1.2695, 5316491363.7363, 0.25 +Res-1.2696, 5316491363.7363, 0.25 +Res-1.2697, 5316491363.7363, 0.25 +Res-1.2698, 5316491363.7363, 0.25 +Res-1.2699, 5316491363.7363, 0.25 +Res-1.2700, 5316491363.7363, 0.25 +Res-1.2701, 5316491363.7363, 0.25 +Res-1.2702, 5316491363.7363, 0.25 +Res-1.2703, 5316491363.7363, 0.25 +Res-1.2704, 5316491363.7363, 0.25 +Res-1.2705, 5316491363.7363, 0.25 +Res-1.2706, 5316491363.7363, 0.25 +Res-1.2707, 5316491363.7363, 0.25 +Res-1.2708, 5316491363.7363, 0.25 +Res-1.2709, 5316491363.7363, 0.25 +Res-1.2710, 5316491363.7363, 0.25 +Res-1.2711, 5316491363.7363, 0.25 +Res-1.2712, 5316491363.7363, 0.25 +Res-1.2713, 5316491363.7363, 0.25 +Res-1.2714, 5316491363.7363, 0.25 +Res-1.2715, 5316491363.7363, 0.25 +Res-1.2716, 5316491363.7363, 0.25 +Res-1.2717, 5316491363.7363, 0.25 +Res-1.2718, 5316491363.7363, 0.25 +Res-1.2719, 5316491363.7363, 0.25 +Res-1.2720, 5316491363.7363, 0.25 +Res-1.2721, 5316491363.7363, 0.25 +Res-1.2722, 5316491363.7363, 0.25 +Res-1.2723, 5316491363.7363, 0.25 +Res-1.2724, 5316491363.7363, 0.25 +Res-1.2725, 5316491363.7363, 0.25 +Res-1.2726, 5316491363.7363, 0.25 +Res-1.2727, 5316491363.7363, 0.25 +Res-1.2728, 5316491363.7363, 0.25 +Res-1.2729, 5316491363.7363, 0.25 +Res-1.2730, 5316491363.7363, 0.25 +Res-1.2731, 5316491363.7363, 0.25 +Res-1.2732, 5316491363.7363, 0.25 +Res-1.2733, 5316491363.7363, 0.25 +Res-1.2734, 5316491363.7363, 0.25 +Res-1.2735, 5316491363.7363, 0.25 +Res-1.2736, 5316491363.7363, 0.25 +Res-1.2737, 5316491363.7363, 0.25 +Res-1.2738, 5316491363.7363, 0.25 +Res-1.2739, 5316491363.7363, 0.25 +Res-1.2740, 5316491363.7363, 0.25 +Res-1.2741, 5316491363.7363, 0.25 +Res-1.2742, 5316491363.7363, 0.25 +Res-1.2743, 5316491363.7363, 0.25 +Res-1.2744, 5316491363.7363, 0.25 +Res-1.2745, 5316491363.7363, 0.25 +Res-1.2746, 5316491363.7363, 0.25 +Res-1.2747, 5316491363.7363, 0.25 +Res-1.2748, 5316491363.7363, 0.25 +Res-1.2749, 5316491363.7363, 0.25 +Res-1.2750, 5316491363.7363, 0.25 +Res-1.2751, 5316491363.7363, 0.25 +Res-1.2752, 5316491363.7363, 0.25 +Res-1.2753, 5316491363.7363, 0.25 +Res-1.2754, 5316491363.7363, 0.25 +Res-1.2755, 5316491363.7363, 0.25 +Res-1.2756, 5316491363.7363, 0.25 +Res-1.2757, 5316491363.7363, 0.25 +Res-1.2758, 5316491363.7363, 0.25 +Res-1.2759, 5316491363.7363, 0.25 +Res-1.2760, 5316491363.7363, 0.25 +Res-1.2761, 5316491363.7363, 0.25 +Res-1.2762, 5316491363.7363, 0.25 +Res-1.2763, 5316491363.7363, 0.25 +Res-1.2764, 5316491363.7363, 0.25 +Res-1.2765, 5316491363.7363, 0.25 +Res-1.2766, 5316491363.7363, 0.25 +Res-1.2767, 5316491363.7363, 0.25 +Res-1.2768, 5316491363.7363, 0.25 +Res-1.2769, 5316491363.7363, 0.25 +Res-1.2770, 5316491363.7363, 0.25 +Res-1.2771, 5316491363.7363, 0.25 +Res-1.2772, 5316491363.7363, 0.25 +Res-1.2773, 5316491363.7363, 0.25 +Res-1.2774, 5316491363.7363, 0.25 +Res-1.2775, 5316491363.7363, 0.25 +Res-1.2776, 5316491363.7363, 0.25 +Res-1.2777, 5316491363.7363, 0.25 +Res-1.2778, 5316491363.7363, 0.25 +Res-1.2779, 5316491363.7363, 0.25 +Res-1.2780, 5316491363.7363, 0.25 +Res-1.2781, 5316491363.7363, 0.25 +Res-1.2782, 5316491363.7363, 0.25 +Res-1.2783, 5316491363.7363, 0.25 +Res-1.2784, 5316491363.7363, 0.25 +Res-1.2785, 5316491363.7363, 0.25 +Res-1.2786, 5316491363.7363, 0.25 +Res-1.2787, 5316491363.7363, 0.25 +Res-1.2788, 5316491363.7363, 0.25 +Res-1.2789, 5316491363.7363, 0.25 +Res-1.2790, 5316491363.7363, 0.25 +Res-1.2791, 5316491363.7363, 0.25 +Res-1.2792, 5316491363.7363, 0.25 +Res-1.2793, 5316491363.7363, 0.25 +Res-1.2794, 5316491363.7363, 0.25 +Res-1.2795, 5316491363.7363, 0.25 +Res-1.2796, 5316491363.7363, 0.25 +Res-1.2797, 5316491363.7363, 0.25 +Res-1.2798, 5316491363.7363, 0.25 +Res-1.2799, 5316491363.7363, 0.25 +Res-1.2800, 5316491363.7363, 0.25 +Res-1.2801, 5316491363.7363, 0.25 +Res-1.2802, 5316491363.7363, 0.25 +Res-1.2803, 5316491363.7363, 0.25 +Res-1.2804, 5316491363.7363, 0.25 +Res-1.2805, 5316491363.7363, 0.25 +Res-1.2806, 5316491363.7363, 0.25 +Res-1.2807, 5316491363.7363, 0.25 +Res-1.2808, 5316491363.7363, 0.25 +Res-1.2809, 5316491363.7363, 0.25 +Res-1.2810, 5316491363.7363, 0.25 +Res-1.2811, 5316491363.7363, 0.25 +Res-1.2812, 5316491363.7363, 0.25 +Res-1.2813, 5316491363.7363, 0.25 +Res-1.2814, 5316491363.7363, 0.25 +Res-1.2815, 5316491363.7363, 0.25 +Res-1.2816, 5316491363.7363, 0.25 +Res-1.2817, 5316491363.7363, 0.25 +Res-1.2818, 5316491363.7363, 0.25 +Res-1.2819, 5316491363.7363, 0.25 +Res-1.2820, 5316491363.7363, 0.25 +Res-1.2821, 5316491363.7363, 0.25 +Res-1.2822, 5316491363.7363, 0.25 +Res-1.2823, 5316491363.7363, 0.25 +Res-1.2824, 5316491363.7363, 0.25 +Res-1.2825, 5316491363.7363, 0.25 +Res-1.2826, 5316491363.7363, 0.25 +Res-1.2827, 5316491363.7363, 0.25 +Res-1.2828, 5316491363.7363, 0.25 +Res-1.2829, 5316491363.7363, 0.25 +Res-1.2830, 5316491363.7363, 0.25 +Res-1.2831, 5316491363.7363, 0.25 +Res-1.2832, 5316491363.7363, 0.25 +Res-1.2833, 5316491363.7363, 0.25 +Res-1.2834, 5316491363.7363, 0.25 +Res-1.2835, 5316491363.7363, 0.25 +Res-1.2836, 5316491363.7363, 0.25 +Res-1.2837, 5316491363.7363, 0.25 +Res-1.2838, 5316491363.7363, 0.25 +Res-1.2839, 5316491363.7363, 0.25 +Res-1.2840, 5316491363.7363, 0.25 +Res-1.2841, 5316491363.7363, 0.25 +Res-1.2842, 5316491363.7363, 0.25 +Res-1.2843, 5316491363.7363, 0.25 +Res-1.2844, 5316491363.7363, 0.25 +Res-1.2845, 5316491363.7363, 0.25 +Res-1.2846, 5316491363.7363, 0.25 +Res-1.2847, 5316491363.7363, 0.25 +Res-1.2848, 5316491363.7363, 0.25 +Res-1.2849, 5316491363.7363, 0.25 +Res-1.2850, 5316491363.7363, 0.25 +Res-1.2851, 5316491363.7363, 0.25 +Res-1.2852, 5316491363.7363, 0.25 +Res-1.2853, 5316491363.7363, 0.25 +Res-1.2854, 5316491363.7363, 0.25 +Res-1.2855, 5316491363.7363, 0.25 +Res-1.2856, 5316491363.7363, 0.25 +Res-1.2857, 5316491363.7363, 0.25 +Res-1.2858, 5316491363.7363, 0.25 +Res-1.2859, 5316491363.7363, 0.25 +Res-1.2860, 5316491363.7363, 0.25 +Res-1.2861, 5316491363.7363, 0.25 +Res-1.2862, 5316491363.7363, 0.25 +Res-1.2863, 5316491363.7363, 0.25 +Res-1.2864, 5316491363.7363, 0.25 +Res-1.2865, 5316491363.7363, 0.25 +Res-1.2866, 5316491363.7363, 0.25 +Res-1.2867, 5316491363.7363, 0.25 +Res-1.2868, 5316491363.7363, 0.25 +Res-1.2869, 5316491363.7363, 0.25 +Res-1.2870, 5316491363.7363, 0.25 +Res-1.2871, 5316491363.7363, 0.25 +Res-1.2872, 5316491363.7363, 0.25 +Res-1.2873, 5316491363.7363, 0.25 +Res-1.2874, 5316491363.7363, 0.25 +Res-1.2875, 5316491363.7363, 0.25 +Res-1.2876, 5316491363.7363, 0.25 +Res-1.2877, 5316491363.7363, 0.25 +Res-1.2878, 5316491363.7363, 0.25 +Res-1.2879, 5316491363.7363, 0.25 +Res-1.2880, 5316491363.7363, 0.25 +Res-1.2881, 11552880115, 0.25 +Res-1.2882, 11552880115, 0.25 +Res-1.2883, 11552880115, 0.25 +Res-1.2884, 11552880115, 0.25 +Res-1.2885, 11552880115, 0.25 +Res-1.2886, 11552880115, 0.25 +Res-1.2887, 11552880115, 0.25 +Res-1.2888, 11552880115, 0.25 +Res-1.2889, 11552880115, 0.25 +Res-1.2890, 11552880115, 0.25 +Res-1.2891, 11552880115, 0.25 +Res-1.2892, 11552880115, 0.25 +Res-1.2893, 11552880115, 0.25 +Res-1.2894, 11552880115, 0.25 +Res-1.2895, 11552880115, 0.25 +Res-1.2896, 11552880115, 0.25 +Res-1.2897, 11552880115, 0.25 +Res-1.2898, 11552880115, 0.25 +Res-1.2899, 11552880115, 0.25 +Res-1.2900, 11552880115, 0.25 +Res-1.2901, 11552880115, 0.25 +Res-1.2902, 11552880115, 0.25 +Res-1.2903, 11552880115, 0.25 +Res-1.2904, 11552880115, 0.25 +Res-1.2905, 11552880115, 0.25 +Res-1.2906, 11552880115, 0.25 +Res-1.2907, 11552880115, 0.25 +Res-1.2908, 11552880115, 0.25 +Res-1.2909, 11552880115, 0.25 +Res-1.2910, 11552880115, 0.25 +Res-1.2911, 11552880115, 0.25 +Res-1.2912, 11552880115, 0.25 +Res-1.2913, 11552880115, 0.25 +Res-1.2914, 11552880115, 0.25 +Res-1.2915, 11552880115, 0.25 +Res-1.2916, 11552880115, 0.25 +Res-1.2917, 11552880115, 0.25 +Res-1.2918, 11552880115, 0.25 +Res-1.2919, 11552880115, 0.25 +Res-1.2920, 11552880115, 0.25 +Res-1.2921, 11552880115, 0.25 +Res-1.2922, 11552880115, 0.25 +Res-1.2923, 11552880115, 0.25 +Res-1.2924, 11552880115, 0.25 +Res-1.2925, 11552880115, 0.25 +Res-1.2926, 11552880115, 0.25 +Res-1.2927, 11552880115, 0.25 +Res-1.2928, 11552880115, 0.25 +Res-1.2929, 11552880115, 0.25 +Res-1.2930, 11552880115, 0.25 +Res-1.2931, 11552880115, 0.25 +Res-1.2932, 11552880115, 0.25 +Res-1.2933, 11552880115, 0.25 +Res-1.2934, 11552880115, 0.25 +Res-1.2935, 11552880115, 0.25 +Res-1.2936, 11552880115, 0.25 +Res-1.2937, 11552880115, 0.25 +Res-1.2938, 11552880115, 0.25 +Res-1.2939, 11552880115, 0.25 +Res-1.2940, 11552880115, 0.25 +Res-1.2941, 11552880115, 0.25 +Res-1.2942, 11552880115, 0.25 +Res-1.2943, 11552880115, 0.25 +Res-1.2944, 11552880115, 0.25 +Res-1.2945, 11552880115, 0.25 +Res-1.2946, 11552880115, 0.25 +Res-1.2947, 11552880115, 0.25 +Res-1.2948, 11552880115, 0.25 +Res-1.2949, 11552880115, 0.25 +Res-1.2950, 11552880115, 0.25 +Res-1.2951, 11552880115, 0.25 +Res-1.2952, 11552880115, 0.25 +Res-1.2953, 11552880115, 0.25 +Res-1.2954, 11552880115, 0.25 +Res-1.2955, 11552880115, 0.25 +Res-1.2956, 11552880115, 0.25 +Res-1.2957, 11552880115, 0.25 +Res-1.2958, 11552880115, 0.25 +Res-1.2959, 11552880115, 0.25 +Res-1.2960, 11552880115, 0.25 +Res-1.2961, 11552880115, 0.25 +Res-1.2962, 11552880115, 0.25 +Res-1.2963, 11552880115, 0.25 +Res-1.2964, 11552880115, 0.25 +Res-1.2965, 11552880115, 0.25 +Res-1.2966, 11552880115, 0.25 +Res-1.2967, 11552880115, 0.25 +Res-1.2968, 11552880115, 0.25 +Res-1.2969, 11552880115, 0.25 +Res-1.2970, 11552880115, 0.25 +Res-1.2971, 11552880115, 0.25 +Res-1.2972, 11552880115, 0.25 +Res-1.2973, 11552880115, 0.25 +Res-1.2974, 11552880115, 0.25 +Res-1.2975, 11552880115, 0.25 +Res-1.2976, 11552880115, 0.25 +Res-1.2977, 11552880115, 0.25 +Res-1.2978, 11552880115, 0.25 +Res-1.2979, 11552880115, 0.25 +Res-1.2980, 11552880115, 0.25 +Res-1.2981, 11552880115, 0.25 +Res-1.2982, 11552880115, 0.25 +Res-1.2983, 11552880115, 0.25 +Res-1.2984, 11552880115, 0.25 +Res-1.2985, 11552880115, 0.25 +Res-1.2986, 11552880115, 0.25 +Res-1.2987, 11552880115, 0.25 +Res-1.2988, 11552880115, 0.25 +Res-1.2989, 11552880115, 0.25 +Res-1.2990, 11552880115, 0.25 +Res-1.2991, 11552880115, 0.25 +Res-1.2992, 11552880115, 0.25 +Res-1.2993, 11552880115, 0.25 +Res-1.2994, 11552880115, 0.25 +Res-1.2995, 11552880115, 0.25 +Res-1.2996, 11552880115, 0.25 +Res-1.2997, 11552880115, 0.25 +Res-1.2998, 11552880115, 0.25 +Res-1.2999, 11552880115, 0.25 +Res-1.3000, 11552880115, 0.25 +Res-1.3001, 11552880115, 0.25 +Res-1.3002, 11552880115, 0.25 +Res-1.3003, 11552880115, 0.25 +Res-1.3004, 11552880115, 0.25 +Res-1.3005, 11552880115, 0.25 +Res-1.3006, 11552880115, 0.25 +Res-1.3007, 11552880115, 0.25 +Res-1.3008, 11552880115, 0.25 +Res-1.3009, 11552880115, 0.25 +Res-1.3010, 11552880115, 0.25 +Res-1.3011, 11552880115, 0.25 +Res-1.3012, 11552880115, 0.25 +Res-1.3013, 11552880115, 0.25 +Res-1.3014, 11552880115, 0.25 +Res-1.3015, 11552880115, 0.25 +Res-1.3016, 11552880115, 0.25 +Res-1.3017, 11552880115, 0.25 +Res-1.3018, 11552880115, 0.25 +Res-1.3019, 11552880115, 0.25 +Res-1.3020, 11552880115, 0.25 +Res-1.3021, 11552880115, 0.25 +Res-1.3022, 11552880115, 0.25 +Res-1.3023, 11552880115, 0.25 +Res-1.3024, 11552880115, 0.25 +Res-1.3025, 11552880115, 0.25 +Res-1.3026, 11552880115, 0.25 +Res-1.3027, 11552880115, 0.25 +Res-1.3028, 11552880115, 0.25 +Res-1.3029, 11552880115, 0.25 +Res-1.3030, 11552880115, 0.25 +Res-1.3031, 11552880115, 0.25 +Res-1.3032, 11552880115, 0.25 +Res-1.3033, 11552880115, 0.25 +Res-1.3034, 11552880115, 0.25 +Res-1.3035, 11552880115, 0.25 +Res-1.3036, 11552880115, 0.25 +Res-1.3037, 11552880115, 0.25 +Res-1.3038, 11552880115, 0.25 +Res-1.3039, 11552880115, 0.25 +Res-1.3040, 11552880115, 0.25 +Res-1.3041, 11552880115, 0.25 +Res-1.3042, 11552880115, 0.25 +Res-1.3043, 11552880115, 0.25 +Res-1.3044, 11552880115, 0.25 +Res-1.3045, 11552880115, 0.25 +Res-1.3046, 11552880115, 0.25 +Res-1.3047, 11552880115, 0.25 +Res-1.3048, 11552880115, 0.25 +Res-1.3049, 11552880115, 0.25 +Res-1.3050, 11552880115, 0.25 +Res-1.3051, 11552880115, 0.25 +Res-1.3052, 11552880115, 0.25 +Res-1.3053, 11552880115, 0.25 +Res-1.3054, 11552880115, 0.25 +Res-1.3055, 11552880115, 0.25 +Res-1.3056, 11552880115, 0.25 +Res-1.3057, 11552880115, 0.25 +Res-1.3058, 11552880115, 0.25 +Res-1.3059, 11552880115, 0.25 +Res-1.3060, 11552880115, 0.25 +Res-1.3061, 11552880115, 0.25 +Res-1.3062, 11552880115, 0.25 +Res-1.3063, 11552880115, 0.25 +Res-1.3064, 11552880115, 0.25 +Res-1.3065, 11552880115, 0.25 +Res-1.3066, 11552880115, 0.25 +Res-1.3067, 11552880115, 0.25 +Res-1.3068, 11552880115, 0.25 +Res-1.3069, 11552880115, 0.25 +Res-1.3070, 11552880115, 0.25 +Res-1.3071, 11552880115, 0.25 +Res-1.3072, 11552880115, 0.25 +Res-1.3073, 11552880115, 0.25 +Res-1.3074, 11552880115, 0.25 +Res-1.3075, 11552880115, 0.25 +Res-1.3076, 11552880115, 0.25 +Res-1.3077, 11552880115, 0.25 +Res-1.3078, 11552880115, 0.25 +Res-1.3079, 11552880115, 0.25 +Res-1.3080, 11552880115, 0.25 +Res-1.3081, 11552880115, 0.25 +Res-1.3082, 11552880115, 0.25 +Res-1.3083, 11552880115, 0.25 +Res-1.3084, 11552880115, 0.25 +Res-1.3085, 11552880115, 0.25 +Res-1.3086, 11552880115, 0.25 +Res-1.3087, 11552880115, 0.25 +Res-1.3088, 11552880115, 0.25 +Res-1.3089, 11552880115, 0.25 +Res-1.3090, 11552880115, 0.25 +Res-1.3091, 11552880115, 0.25 +Res-1.3092, 11552880115, 0.25 +Res-1.3093, 11552880115, 0.25 +Res-1.3094, 11552880115, 0.25 +Res-1.3095, 11552880115, 0.25 +Res-1.3096, 11552880115, 0.25 +Res-1.3097, 11552880115, 0.25 +Res-1.3098, 11552880115, 0.25 +Res-1.3099, 11552880115, 0.25 +Res-1.3100, 11552880115, 0.25 +Res-1.3101, 11552880115, 0.25 +Res-1.3102, 11552880115, 0.25 +Res-1.3103, 11552880115, 0.25 +Res-1.3104, 11552880115, 0.25 +Res-1.3105, 11552880115, 0.25 +Res-1.3106, 11552880115, 0.25 +Res-1.3107, 11552880115, 0.25 +Res-1.3108, 11552880115, 0.25 +Res-1.3109, 11552880115, 0.25 +Res-1.3110, 11552880115, 0.25 +Res-1.3111, 11552880115, 0.25 +Res-1.3112, 11552880115, 0.25 +Res-1.3113, 11552880115, 0.25 +Res-1.3114, 11552880115, 0.25 +Res-1.3115, 11552880115, 0.25 +Res-1.3116, 11552880115, 0.25 +Res-1.3117, 11552880115, 0.25 +Res-1.3118, 11552880115, 0.25 +Res-1.3119, 11552880115, 0.25 +Res-1.3120, 11552880115, 0.25 +Res-1.3121, 11552880115, 0.25 +Res-1.3122, 11552880115, 0.25 +Res-1.3123, 11552880115, 0.25 +Res-1.3124, 11552880115, 0.25 +Res-1.3125, 11552880115, 0.25 +Res-1.3126, 11552880115, 0.25 +Res-1.3127, 11552880115, 0.25 +Res-1.3128, 11552880115, 0.25 +Res-1.3129, 11552880115, 0.25 +Res-1.3130, 11552880115, 0.25 +Res-1.3131, 11552880115, 0.25 +Res-1.3132, 11552880115, 0.25 +Res-1.3133, 11552880115, 0.25 +Res-1.3134, 11552880115, 0.25 +Res-1.3135, 11552880115, 0.25 +Res-1.3136, 11552880115, 0.25 +Res-1.3137, 11552880115, 0.25 +Res-1.3138, 11552880115, 0.25 +Res-1.3139, 11552880115, 0.25 +Res-1.3140, 11552880115, 0.25 +Res-1.3141, 11552880115, 0.25 +Res-1.3142, 11552880115, 0.25 +Res-1.3143, 11552880115, 0.25 +Res-1.3144, 11552880115, 0.25 +Res-1.3145, 11552880115, 0.25 +Res-1.3146, 11552880115, 0.25 +Res-1.3147, 11552880115, 0.25 +Res-1.3148, 11552880115, 0.25 +Res-1.3149, 11552880115, 0.25 +Res-1.3150, 11552880115, 0.25 +Res-1.3151, 11552880115, 0.25 +Res-1.3152, 11552880115, 0.25 +Res-1.3153, 11552880115, 0.25 +Res-1.3154, 11552880115, 0.25 +Res-1.3155, 11552880115, 0.25 +Res-1.3156, 11552880115, 0.25 +Res-1.3157, 11552880115, 0.25 +Res-1.3158, 11552880115, 0.25 +Res-1.3159, 11552880115, 0.25 +Res-1.3160, 11552880115, 0.25 +Res-1.3161, 11552880115, 0.25 +Res-1.3162, 11552880115, 0.25 +Res-1.3163, 11552880115, 0.25 +Res-1.3164, 11552880115, 0.25 +Res-1.3165, 11552880115, 0.25 +Res-1.3166, 11552880115, 0.25 +Res-1.3167, 11552880115, 0.25 +Res-1.3168, 11552880115, 0.25 +Res-1.3169, 13631205565, 0.25 +Res-1.3170, 13631205565, 0.25 +Res-1.3171, 13631205565, 0.25 +Res-1.3172, 13631205565, 0.25 +Res-1.3173, 13631205565, 0.25 +Res-1.3174, 13631205565, 0.25 +Res-1.3175, 13631205565, 0.25 +Res-1.3176, 13631205565, 0.25 +Res-1.3177, 13631205565, 0.25 +Res-1.3178, 13631205565, 0.25 +Res-1.3179, 13631205565, 0.25 +Res-1.3180, 13631205565, 0.25 +Res-1.3181, 13631205565, 0.25 +Res-1.3182, 13631205565, 0.25 +Res-1.3183, 13631205565, 0.25 +Res-1.3184, 13631205565, 0.25 +Res-1.3185, 13631205565, 0.25 +Res-1.3186, 13631205565, 0.25 +Res-1.3187, 13631205565, 0.25 +Res-1.3188, 13631205565, 0.25 +Res-1.3189, 13631205565, 0.25 +Res-1.3190, 13631205565, 0.25 +Res-1.3191, 13631205565, 0.25 +Res-1.3192, 13631205565, 0.25 +Res-1.3193, 13631205565, 0.25 +Res-1.3194, 13631205565, 0.25 +Res-1.3195, 13631205565, 0.25 +Res-1.3196, 13631205565, 0.25 +Res-1.3197, 13631205565, 0.25 +Res-1.3198, 13631205565, 0.25 +Res-1.3199, 13631205565, 0.25 +Res-1.3200, 13631205565, 0.25 +Res-1.3201, 13631205565, 0.25 +Res-1.3202, 13631205565, 0.25 +Res-1.3203, 13631205565, 0.25 +Res-1.3204, 13631205565, 0.25 +Res-1.3205, 13631205565, 0.25 +Res-1.3206, 13631205565, 0.25 +Res-1.3207, 13631205565, 0.25 +Res-1.3208, 13631205565, 0.25 +Res-1.3209, 13631205565, 0.25 +Res-1.3210, 13631205565, 0.25 +Res-1.3211, 13631205565, 0.25 +Res-1.3212, 13631205565, 0.25 +Res-1.3213, 13631205565, 0.25 +Res-1.3214, 13631205565, 0.25 +Res-1.3215, 13631205565, 0.25 +Res-1.3216, 13631205565, 0.25 +Res-1.3217, 13631205565, 0.25 +Res-1.3218, 13631205565, 0.25 +Res-1.3219, 13631205565, 0.25 +Res-1.3220, 13631205565, 0.25 +Res-1.3221, 13631205565, 0.25 +Res-1.3222, 13631205565, 0.25 +Res-1.3223, 13631205565, 0.25 +Res-1.3224, 13631205565, 0.25 +Res-1.3225, 13631205565, 0.25 +Res-1.3226, 13631205565, 0.25 +Res-1.3227, 13631205565, 0.25 +Res-1.3228, 13631205565, 0.25 +Res-1.3229, 13631205565, 0.25 +Res-1.3230, 13631205565, 0.25 +Res-1.3231, 13631205565, 0.25 +Res-1.3232, 13631205565, 0.25 +Res-1.3233, 13631205565, 0.25 +Res-1.3234, 13631205565, 0.25 +Res-1.3235, 13631205565, 0.25 +Res-1.3236, 13631205565, 0.25 +Res-1.3237, 13631205565, 0.25 +Res-1.3238, 13631205565, 0.25 +Res-1.3239, 13631205565, 0.25 +Res-1.3240, 13631205565, 0.25 +Res-1.3241, 13631205565, 0.25 +Res-1.3242, 13631205565, 0.25 +Res-1.3243, 13631205565, 0.25 +Res-1.3244, 13631205565, 0.25 +Res-1.3245, 13631205565, 0.25 +Res-1.3246, 13631205565, 0.25 +Res-1.3247, 13631205565, 0.25 +Res-1.3248, 13631205565, 0.25 +Res-1.3249, 13631205565, 0.25 +Res-1.3250, 13631205565, 0.25 +Res-1.3251, 13631205565, 0.25 +Res-1.3252, 13631205565, 0.25 +Res-1.3253, 13631205565, 0.25 +Res-1.3254, 13631205565, 0.25 +Res-1.3255, 13631205565, 0.25 +Res-1.3256, 13631205565, 0.25 +Res-1.3257, 13631205565, 0.25 +Res-1.3258, 13631205565, 0.25 +Res-1.3259, 13631205565, 0.25 +Res-1.3260, 13631205565, 0.25 +Res-1.3261, 13631205565, 0.25 +Res-1.3262, 13631205565, 0.25 +Res-1.3263, 13631205565, 0.25 +Res-1.3264, 13631205565, 0.25 +Res-1.3265, 13631205565, 0.25 +Res-1.3266, 13631205565, 0.25 +Res-1.3267, 13631205565, 0.25 +Res-1.3268, 13631205565, 0.25 +Res-1.3269, 13631205565, 0.25 +Res-1.3270, 13631205565, 0.25 +Res-1.3271, 13631205565, 0.25 +Res-1.3272, 13631205565, 0.25 +Res-1.3273, 13631205565, 0.25 +Res-1.3274, 13631205565, 0.25 +Res-1.3275, 13631205565, 0.25 +Res-1.3276, 13631205565, 0.25 +Res-1.3277, 13631205565, 0.25 +Res-1.3278, 13631205565, 0.25 +Res-1.3279, 13631205565, 0.25 +Res-1.3280, 13631205565, 0.25 +Res-1.3281, 13631205565, 0.25 +Res-1.3282, 13631205565, 0.25 +Res-1.3283, 13631205565, 0.25 +Res-1.3284, 13631205565, 0.25 +Res-1.3285, 13631205565, 0.25 +Res-1.3286, 13631205565, 0.25 +Res-1.3287, 13631205565, 0.25 +Res-1.3288, 13631205565, 0.25 +Res-1.3289, 13631205565, 0.25 +Res-1.3290, 13631205565, 0.25 +Res-1.3291, 13631205565, 0.25 +Res-1.3292, 13631205565, 0.25 +Res-1.3293, 13631205565, 0.25 +Res-1.3294, 13631205565, 0.25 +Res-1.3295, 13631205565, 0.25 +Res-1.3296, 13631205565, 0.25 +Res-1.3297, 13631205565, 0.25 +Res-1.3298, 13631205565, 0.25 +Res-1.3299, 13631205565, 0.25 +Res-1.3300, 13631205565, 0.25 +Res-1.3301, 13631205565, 0.25 +Res-1.3302, 13631205565, 0.25 +Res-1.3303, 13631205565, 0.25 +Res-1.3304, 13631205565, 0.25 +Res-1.3305, 13631205565, 0.25 +Res-1.3306, 13631205565, 0.25 +Res-1.3307, 13631205565, 0.25 +Res-1.3308, 13631205565, 0.25 +Res-1.3309, 13631205565, 0.25 +Res-1.3310, 13631205565, 0.25 +Res-1.3311, 13631205565, 0.25 +Res-1.3312, 13631205565, 0.25 +Res-1.3313, 13631205565, 0.25 +Res-1.3314, 13631205565, 0.25 +Res-1.3315, 13631205565, 0.25 +Res-1.3316, 13631205565, 0.25 +Res-1.3317, 13631205565, 0.25 +Res-1.3318, 13631205565, 0.25 +Res-1.3319, 13631205565, 0.25 +Res-1.3320, 13631205565, 0.25 +Res-1.3321, 13631205565, 0.25 +Res-1.3322, 13631205565, 0.25 +Res-1.3323, 13631205565, 0.25 +Res-1.3324, 13631205565, 0.25 +Res-1.3325, 13631205565, 0.25 +Res-1.3326, 13631205565, 0.25 +Res-1.3327, 13631205565, 0.25 +Res-1.3328, 13631205565, 0.25 +Res-1.3329, 13631205565, 0.25 +Res-1.3330, 13631205565, 0.25 +Res-1.3331, 13631205565, 0.25 +Res-1.3332, 13631205565, 0.25 +Res-1.3333, 13631205565, 0.25 +Res-1.3334, 13631205565, 0.25 +Res-1.3335, 13631205565, 0.25 +Res-1.3336, 13631205565, 0.25 +Res-1.3337, 13631205565, 0.25 +Res-1.3338, 13631205565, 0.25 +Res-1.3339, 13631205565, 0.25 +Res-1.3340, 13631205565, 0.25 +Res-1.3341, 13631205565, 0.25 +Res-1.3342, 13631205565, 0.25 +Res-1.3343, 13631205565, 0.25 +Res-1.3344, 13631205565, 0.25 +Res-1.3345, 13631205565, 0.25 +Res-1.3346, 13631205565, 0.25 +Res-1.3347, 13631205565, 0.25 +Res-1.3348, 13631205565, 0.25 +Res-1.3349, 13631205565, 0.25 +Res-1.3350, 13631205565, 0.25 +Res-1.3351, 13631205565, 0.25 +Res-1.3352, 13631205565, 0.25 +Res-1.3353, 13631205565, 0.25 +Res-1.3354, 13631205565, 0.25 +Res-1.3355, 13631205565, 0.25 +Res-1.3356, 13631205565, 0.25 +Res-1.3357, 13631205565, 0.25 +Res-1.3358, 13631205565, 0.25 +Res-1.3359, 13631205565, 0.25 +Res-1.3360, 13631205565, 0.25 +Res-1.3361, 13631205565, 0.25 +Res-1.3362, 13631205565, 0.25 +Res-1.3363, 13631205565, 0.25 +Res-1.3364, 13631205565, 0.25 +Res-1.3365, 13631205565, 0.25 +Res-1.3366, 13631205565, 0.25 +Res-1.3367, 13631205565, 0.25 +Res-1.3368, 13631205565, 0.25 +Res-1.3369, 13631205565, 0.25 +Res-1.3370, 13631205565, 0.25 +Res-1.3371, 13631205565, 0.25 +Res-1.3372, 13631205565, 0.25 +Res-1.3373, 13631205565, 0.25 +Res-1.3374, 13631205565, 0.25 +Res-1.3375, 13631205565, 0.25 +Res-1.3376, 13631205565, 0.25 +Res-1.3377, 13631205565, 0.25 +Res-1.3378, 13631205565, 0.25 +Res-1.3379, 13631205565, 0.25 +Res-1.3380, 13631205565, 0.25 +Res-1.3381, 13631205565, 0.25 +Res-1.3382, 13631205565, 0.25 +Res-1.3383, 13631205565, 0.25 +Res-1.3384, 13631205565, 0.25 +Res-1.3385, 13631205565, 0.25 +Res-1.3386, 13631205565, 0.25 +Res-1.3387, 13631205565, 0.25 +Res-1.3388, 13631205565, 0.25 +Res-1.3389, 13631205565, 0.25 +Res-1.3390, 13631205565, 0.25 +Res-1.3391, 13631205565, 0.25 +Res-1.3392, 13631205565, 0.25 +Res-1.3393, 13631205565, 0.25 +Res-1.3394, 13631205565, 0.25 +Res-1.3395, 13631205565, 0.25 +Res-1.3396, 13631205565, 0.25 +Res-1.3397, 13631205565, 0.25 +Res-1.3398, 13631205565, 0.25 +Res-1.3399, 13631205565, 0.25 +Res-1.3400, 13631205565, 0.25 +Res-1.3401, 13631205565, 0.25 +Res-1.3402, 13631205565, 0.25 +Res-1.3403, 13631205565, 0.25 +Res-1.3404, 13631205565, 0.25 +Res-1.3405, 13631205565, 0.25 +Res-1.3406, 13631205565, 0.25 +Res-1.3407, 13631205565, 0.25 +Res-1.3408, 13631205565, 0.25 +Res-1.3409, 13631205565, 0.25 +Res-1.3410, 13631205565, 0.25 +Res-1.3411, 13631205565, 0.25 +Res-1.3412, 13631205565, 0.25 +Res-1.3413, 13631205565, 0.25 +Res-1.3414, 13631205565, 0.25 +Res-1.3415, 13631205565, 0.25 +Res-1.3416, 13631205565, 0.25 +Res-1.3417, 13631205565, 0.25 +Res-1.3418, 13631205565, 0.25 +Res-1.3419, 13631205565, 0.25 +Res-1.3420, 13631205565, 0.25 +Res-1.3421, 13631205565, 0.25 +Res-1.3422, 13631205565, 0.25 +Res-1.3423, 13631205565, 0.25 +Res-1.3424, 13631205565, 0.25 +Res-1.3425, 13631205565, 0.25 +Res-1.3426, 13631205565, 0.25 +Res-1.3427, 13631205565, 0.25 +Res-1.3428, 13631205565, 0.25 +Res-1.3429, 13631205565, 0.25 +Res-1.3430, 13631205565, 0.25 +Res-1.3431, 13631205565, 0.25 +Res-1.3432, 13631205565, 0.25 +Res-1.3433, 13631205565, 0.25 +Res-1.3434, 13631205565, 0.25 +Res-1.3435, 13631205565, 0.25 +Res-1.3436, 13631205565, 0.25 +Res-1.3437, 13631205565, 0.25 +Res-1.3438, 13631205565, 0.25 +Res-1.3439, 13631205565, 0.25 +Res-1.3440, 13631205565, 0.25 +Res-1.3441, 13631205565, 0.25 +Res-1.3442, 13631205565, 0.25 +Res-1.3443, 13631205565, 0.25 +Res-1.3444, 13631205565, 0.25 +Res-1.3445, 13631205565, 0.25 +Res-1.3446, 13631205565, 0.25 +Res-1.3447, 13631205565, 0.25 +Res-1.3448, 13631205565, 0.25 +Res-1.3449, 13631205565, 0.25 +Res-1.3450, 13631205565, 0.25 +Res-1.3451, 13631205565, 0.25 +Res-1.3452, 13631205565, 0.25 +Res-1.3453, 13631205565, 0.25 +Res-1.3454, 13631205565, 0.25 +Res-1.3455, 13631205565, 0.25 +Res-1.3456, 13631205565, 0.25 +Res-1.3457, 16739025760, 0.25 +Res-1.3458, 16739025760, 0.25 +Res-1.3459, 16739025760, 0.25 +Res-1.3460, 16739025760, 0.25 +Res-1.3461, 16739025760, 0.25 +Res-1.3462, 16739025760, 0.25 +Res-1.3463, 16739025760, 0.25 +Res-1.3464, 16739025760, 0.25 +Res-1.3465, 16739025760, 0.25 +Res-1.3466, 16739025760, 0.25 +Res-1.3467, 16739025760, 0.25 +Res-1.3468, 16739025760, 0.25 +Res-1.3469, 16739025760, 0.25 +Res-1.3470, 16739025760, 0.25 +Res-1.3471, 16739025760, 0.25 +Res-1.3472, 16739025760, 0.25 +Res-1.3473, 16739025760, 0.25 +Res-1.3474, 16739025760, 0.25 +Res-1.3475, 16739025760, 0.25 +Res-1.3476, 16739025760, 0.25 +Res-1.3477, 16739025760, 0.25 +Res-1.3478, 16739025760, 0.25 +Res-1.3479, 16739025760, 0.25 +Res-1.3480, 16739025760, 0.25 +Res-1.3481, 16739025760, 0.25 +Res-1.3482, 16739025760, 0.25 +Res-1.3483, 16739025760, 0.25 +Res-1.3484, 16739025760, 0.25 +Res-1.3485, 16739025760, 0.25 +Res-1.3486, 16739025760, 0.25 +Res-1.3487, 16739025760, 0.25 +Res-1.3488, 16739025760, 0.25 +Res-1.3489, 16739025760, 0.25 +Res-1.3490, 16739025760, 0.25 +Res-1.3491, 16739025760, 0.25 +Res-1.3492, 16739025760, 0.25 +Res-1.3493, 16739025760, 0.25 +Res-1.3494, 16739025760, 0.25 +Res-1.3495, 16739025760, 0.25 +Res-1.3496, 16739025760, 0.25 +Res-1.3497, 16739025760, 0.25 +Res-1.3498, 16739025760, 0.25 +Res-1.3499, 16739025760, 0.25 +Res-1.3500, 16739025760, 0.25 +Res-1.3501, 16739025760, 0.25 +Res-1.3502, 16739025760, 0.25 +Res-1.3503, 16739025760, 0.25 +Res-1.3504, 16739025760, 0.25 +Res-1.3505, 16739025760, 0.25 +Res-1.3506, 16739025760, 0.25 +Res-1.3507, 16739025760, 0.25 +Res-1.3508, 16739025760, 0.25 +Res-1.3509, 16739025760, 0.25 +Res-1.3510, 16739025760, 0.25 +Res-1.3511, 16739025760, 0.25 +Res-1.3512, 16739025760, 0.25 +Res-1.3513, 16739025760, 0.25 +Res-1.3514, 16739025760, 0.25 +Res-1.3515, 16739025760, 0.25 +Res-1.3516, 16739025760, 0.25 +Res-1.3517, 16739025760, 0.25 +Res-1.3518, 16739025760, 0.25 +Res-1.3519, 16739025760, 0.25 +Res-1.3520, 16739025760, 0.25 +Res-1.3521, 16739025760, 0.25 +Res-1.3522, 16739025760, 0.25 +Res-1.3523, 16739025760, 0.25 +Res-1.3524, 16739025760, 0.25 +Res-1.3525, 16739025760, 0.25 +Res-1.3526, 16739025760, 0.25 +Res-1.3527, 16739025760, 0.25 +Res-1.3528, 16739025760, 0.25 +Res-1.3529, 16739025760, 0.25 +Res-1.3530, 16739025760, 0.25 +Res-1.3531, 16739025760, 0.25 +Res-1.3532, 16739025760, 0.25 +Res-1.3533, 16739025760, 0.25 +Res-1.3534, 16739025760, 0.25 +Res-1.3535, 16739025760, 0.25 +Res-1.3536, 16739025760, 0.25 +Res-1.3537, 16739025760, 0.25 +Res-1.3538, 16739025760, 0.25 +Res-1.3539, 16739025760, 0.25 +Res-1.3540, 16739025760, 0.25 +Res-1.3541, 16739025760, 0.25 +Res-1.3542, 16739025760, 0.25 +Res-1.3543, 16739025760, 0.25 +Res-1.3544, 16739025760, 0.25 +Res-1.3545, 16739025760, 0.25 +Res-1.3546, 16739025760, 0.25 +Res-1.3547, 16739025760, 0.25 +Res-1.3548, 16739025760, 0.25 +Res-1.3549, 16739025760, 0.25 +Res-1.3550, 16739025760, 0.25 +Res-1.3551, 16739025760, 0.25 +Res-1.3552, 16739025760, 0.25 +Res-1.3553, 16739025760, 0.25 +Res-1.3554, 16739025760, 0.25 +Res-1.3555, 16739025760, 0.25 +Res-1.3556, 16739025760, 0.25 +Res-1.3557, 16739025760, 0.25 +Res-1.3558, 16739025760, 0.25 +Res-1.3559, 16739025760, 0.25 +Res-1.3560, 16739025760, 0.25 +Res-1.3561, 16739025760, 0.25 +Res-1.3562, 16739025760, 0.25 +Res-1.3563, 16739025760, 0.25 +Res-1.3564, 16739025760, 0.25 +Res-1.3565, 16739025760, 0.25 +Res-1.3566, 16739025760, 0.25 +Res-1.3567, 16739025760, 0.25 +Res-1.3568, 16739025760, 0.25 +Res-1.3569, 16739025760, 0.25 +Res-1.3570, 16739025760, 0.25 +Res-1.3571, 16739025760, 0.25 +Res-1.3572, 16739025760, 0.25 +Res-1.3573, 16739025760, 0.25 +Res-1.3574, 16739025760, 0.25 +Res-1.3575, 16739025760, 0.25 +Res-1.3576, 16739025760, 0.25 +Res-1.3577, 16739025760, 0.25 +Res-1.3578, 16739025760, 0.25 +Res-1.3579, 16739025760, 0.25 +Res-1.3580, 16739025760, 0.25 +Res-1.3581, 16739025760, 0.25 +Res-1.3582, 16739025760, 0.25 +Res-1.3583, 16739025760, 0.25 +Res-1.3584, 16739025760, 0.25 +Res-1.3585, 16739025760, 0.25 +Res-1.3586, 16739025760, 0.25 +Res-1.3587, 16739025760, 0.25 +Res-1.3588, 16739025760, 0.25 +Res-1.3589, 16739025760, 0.25 +Res-1.3590, 16739025760, 0.25 +Res-1.3591, 16739025760, 0.25 +Res-1.3592, 16739025760, 0.25 +Res-1.3593, 16739025760, 0.25 +Res-1.3594, 16739025760, 0.25 +Res-1.3595, 16739025760, 0.25 +Res-1.3596, 16739025760, 0.25 +Res-1.3597, 16739025760, 0.25 +Res-1.3598, 16739025760, 0.25 +Res-1.3599, 16739025760, 0.25 +Res-1.3600, 16739025760, 0.25 +Res-1.3601, 16739025760, 0.25 +Res-1.3602, 16739025760, 0.25 +Res-1.3603, 16739025760, 0.25 +Res-1.3604, 16739025760, 0.25 +Res-1.3605, 16739025760, 0.25 +Res-1.3606, 16739025760, 0.25 +Res-1.3607, 16739025760, 0.25 +Res-1.3608, 16739025760, 0.25 +Res-1.3609, 16739025760, 0.25 +Res-1.3610, 16739025760, 0.25 +Res-1.3611, 16739025760, 0.25 +Res-1.3612, 16739025760, 0.25 +Res-1.3613, 16739025760, 0.25 +Res-1.3614, 16739025760, 0.25 +Res-1.3615, 16739025760, 0.25 +Res-1.3616, 16739025760, 0.25 +Res-1.3617, 16739025760, 0.25 +Res-1.3618, 16739025760, 0.25 +Res-1.3619, 16739025760, 0.25 +Res-1.3620, 16739025760, 0.25 +Res-1.3621, 16739025760, 0.25 +Res-1.3622, 16739025760, 0.25 +Res-1.3623, 16739025760, 0.25 +Res-1.3624, 16739025760, 0.25 +Res-1.3625, 16739025760, 0.25 +Res-1.3626, 16739025760, 0.25 +Res-1.3627, 16739025760, 0.25 +Res-1.3628, 16739025760, 0.25 +Res-1.3629, 16739025760, 0.25 +Res-1.3630, 16739025760, 0.25 +Res-1.3631, 16739025760, 0.25 +Res-1.3632, 16739025760, 0.25 +Res-1.3633, 16739025760, 0.25 +Res-1.3634, 16739025760, 0.25 +Res-1.3635, 16739025760, 0.25 +Res-1.3636, 16739025760, 0.25 +Res-1.3637, 16739025760, 0.25 +Res-1.3638, 16739025760, 0.25 +Res-1.3639, 16739025760, 0.25 +Res-1.3640, 16739025760, 0.25 +Res-1.3641, 16739025760, 0.25 +Res-1.3642, 16739025760, 0.25 +Res-1.3643, 16739025760, 0.25 +Res-1.3644, 16739025760, 0.25 +Res-1.3645, 16739025760, 0.25 +Res-1.3646, 16739025760, 0.25 +Res-1.3647, 16739025760, 0.25 +Res-1.3648, 16739025760, 0.25 +Res-1.3649, 16739025760, 0.25 +Res-1.3650, 16739025760, 0.25 +Res-1.3651, 16739025760, 0.25 +Res-1.3652, 16739025760, 0.25 +Res-1.3653, 16739025760, 0.25 +Res-1.3654, 16739025760, 0.25 +Res-1.3655, 16739025760, 0.25 +Res-1.3656, 16739025760, 0.25 +Res-1.3657, 16739025760, 0.25 +Res-1.3658, 16739025760, 0.25 +Res-1.3659, 16739025760, 0.25 +Res-1.3660, 16739025760, 0.25 +Res-1.3661, 16739025760, 0.25 +Res-1.3662, 16739025760, 0.25 +Res-1.3663, 16739025760, 0.25 +Res-1.3664, 16739025760, 0.25 +Res-1.3665, 16739025760, 0.25 +Res-1.3666, 16739025760, 0.25 +Res-1.3667, 16739025760, 0.25 +Res-1.3668, 16739025760, 0.25 +Res-1.3669, 16739025760, 0.25 +Res-1.3670, 16739025760, 0.25 +Res-1.3671, 16739025760, 0.25 +Res-1.3672, 16739025760, 0.25 +Res-1.3673, 16739025760, 0.25 +Res-1.3674, 16739025760, 0.25 +Res-1.3675, 16739025760, 0.25 +Res-1.3676, 16739025760, 0.25 +Res-1.3677, 16739025760, 0.25 +Res-1.3678, 16739025760, 0.25 +Res-1.3679, 16739025760, 0.25 +Res-1.3680, 16739025760, 0.25 +Res-1.3681, 16739025760, 0.25 +Res-1.3682, 16739025760, 0.25 +Res-1.3683, 16739025760, 0.25 +Res-1.3684, 16739025760, 0.25 +Res-1.3685, 16739025760, 0.25 +Res-1.3686, 16739025760, 0.25 +Res-1.3687, 16739025760, 0.25 +Res-1.3688, 16739025760, 0.25 +Res-1.3689, 16739025760, 0.25 +Res-1.3690, 16739025760, 0.25 +Res-1.3691, 16739025760, 0.25 +Res-1.3692, 16739025760, 0.25 +Res-1.3693, 16739025760, 0.25 +Res-1.3694, 16739025760, 0.25 +Res-1.3695, 16739025760, 0.25 +Res-1.3696, 16739025760, 0.25 +Res-1.3697, 16739025760, 0.25 +Res-1.3698, 16739025760, 0.25 +Res-1.3699, 16739025760, 0.25 +Res-1.3700, 16739025760, 0.25 +Res-1.3701, 16739025760, 0.25 +Res-1.3702, 16739025760, 0.25 +Res-1.3703, 16739025760, 0.25 +Res-1.3704, 16739025760, 0.25 +Res-1.3705, 16739025760, 0.25 +Res-1.3706, 16739025760, 0.25 +Res-1.3707, 16739025760, 0.25 +Res-1.3708, 16739025760, 0.25 +Res-1.3709, 16739025760, 0.25 +Res-1.3710, 16739025760, 0.25 +Res-1.3711, 16739025760, 0.25 +Res-1.3712, 16739025760, 0.25 +Res-1.3713, 16739025760, 0.25 +Res-1.3714, 16739025760, 0.25 +Res-1.3715, 16739025760, 0.25 +Res-1.3716, 16739025760, 0.25 +Res-1.3717, 16739025760, 0.25 +Res-1.3718, 16739025760, 0.25 +Res-1.3719, 16739025760, 0.25 +Res-1.3720, 16739025760, 0.25 +Res-1.3721, 16739025760, 0.25 +Res-1.3722, 16739025760, 0.25 +Res-1.3723, 16739025760, 0.25 +Res-1.3724, 16739025760, 0.25 +Res-1.3725, 16739025760, 0.25 +Res-1.3726, 16739025760, 0.25 +Res-1.3727, 16739025760, 0.25 +Res-1.3728, 16739025760, 0.25 +Res-1.3729, 16739025760, 0.25 +Res-1.3730, 16739025760, 0.25 +Res-1.3731, 16739025760, 0.25 +Res-1.3732, 16739025760, 0.25 +Res-1.3733, 16739025760, 0.25 +Res-1.3734, 16739025760, 0.25 +Res-1.3735, 16739025760, 0.25 +Res-1.3736, 16739025760, 0.25 +Res-1.3737, 16739025760, 0.25 +Res-1.3738, 16739025760, 0.25 +Res-1.3739, 16739025760, 0.25 +Res-1.3740, 16739025760, 0.25 +Res-1.3741, 16739025760, 0.25 +Res-1.3742, 16739025760, 0.25 +Res-1.3743, 16739025760, 0.25 +Res-1.3744, 16739025760, 0.25 +Res-1.3745, 17409132100, 0.25 +Res-1.3746, 17409132100, 0.25 +Res-1.3747, 17409132100, 0.25 +Res-1.3748, 17409132100, 0.25 +Res-1.3749, 17409132100, 0.25 +Res-1.3750, 17409132100, 0.25 +Res-1.3751, 17409132100, 0.25 +Res-1.3752, 17409132100, 0.25 +Res-1.3753, 17409132100, 0.25 +Res-1.3754, 17409132100, 0.25 +Res-1.3755, 17409132100, 0.25 +Res-1.3756, 17409132100, 0.25 +Res-1.3757, 17409132100, 0.25 +Res-1.3758, 17409132100, 0.25 +Res-1.3759, 17409132100, 0.25 +Res-1.3760, 17409132100, 0.25 +Res-1.3761, 17409132100, 0.25 +Res-1.3762, 17409132100, 0.25 +Res-1.3763, 17409132100, 0.25 +Res-1.3764, 17409132100, 0.25 +Res-1.3765, 17409132100, 0.25 +Res-1.3766, 17409132100, 0.25 +Res-1.3767, 17409132100, 0.25 +Res-1.3768, 17409132100, 0.25 +Res-1.3769, 17409132100, 0.25 +Res-1.3770, 17409132100, 0.25 +Res-1.3771, 17409132100, 0.25 +Res-1.3772, 17409132100, 0.25 +Res-1.3773, 17409132100, 0.25 +Res-1.3774, 17409132100, 0.25 +Res-1.3775, 17409132100, 0.25 +Res-1.3776, 17409132100, 0.25 +Res-1.3777, 17409132100, 0.25 +Res-1.3778, 17409132100, 0.25 +Res-1.3779, 17409132100, 0.25 +Res-1.3780, 17409132100, 0.25 +Res-1.3781, 17409132100, 0.25 +Res-1.3782, 17409132100, 0.25 +Res-1.3783, 17409132100, 0.25 +Res-1.3784, 17409132100, 0.25 +Res-1.3785, 17409132100, 0.25 +Res-1.3786, 17409132100, 0.25 +Res-1.3787, 17409132100, 0.25 +Res-1.3788, 17409132100, 0.25 +Res-1.3789, 17409132100, 0.25 +Res-1.3790, 17409132100, 0.25 +Res-1.3791, 17409132100, 0.25 +Res-1.3792, 17409132100, 0.25 +Res-1.3793, 17409132100, 0.25 +Res-1.3794, 17409132100, 0.25 +Res-1.3795, 17409132100, 0.25 +Res-1.3796, 17409132100, 0.25 +Res-1.3797, 17409132100, 0.25 +Res-1.3798, 17409132100, 0.25 +Res-1.3799, 17409132100, 0.25 +Res-1.3800, 17409132100, 0.25 +Res-1.3801, 17409132100, 0.25 +Res-1.3802, 17409132100, 0.25 +Res-1.3803, 17409132100, 0.25 +Res-1.3804, 17409132100, 0.25 +Res-1.3805, 17409132100, 0.25 +Res-1.3806, 17409132100, 0.25 +Res-1.3807, 17409132100, 0.25 +Res-1.3808, 17409132100, 0.25 +Res-1.3809, 17409132100, 0.25 +Res-1.3810, 17409132100, 0.25 +Res-1.3811, 17409132100, 0.25 +Res-1.3812, 17409132100, 0.25 +Res-1.3813, 17409132100, 0.25 +Res-1.3814, 17409132100, 0.25 +Res-1.3815, 17409132100, 0.25 +Res-1.3816, 17409132100, 0.25 +Res-1.3817, 17409132100, 0.25 +Res-1.3818, 17409132100, 0.25 +Res-1.3819, 17409132100, 0.25 +Res-1.3820, 17409132100, 0.25 +Res-1.3821, 17409132100, 0.25 +Res-1.3822, 17409132100, 0.25 +Res-1.3823, 17409132100, 0.25 +Res-1.3824, 17409132100, 0.25 +Res-1.3825, 17409132100, 0.25 +Res-1.3826, 17409132100, 0.25 +Res-1.3827, 17409132100, 0.25 +Res-1.3828, 17409132100, 0.25 +Res-1.3829, 17409132100, 0.25 +Res-1.3830, 17409132100, 0.25 +Res-1.3831, 17409132100, 0.25 +Res-1.3832, 17409132100, 0.25 +Res-1.3833, 17409132100, 0.25 +Res-1.3834, 17409132100, 0.25 +Res-1.3835, 17409132100, 0.25 +Res-1.3836, 17409132100, 0.25 +Res-1.3837, 17409132100, 0.25 +Res-1.3838, 17409132100, 0.25 +Res-1.3839, 17409132100, 0.25 +Res-1.3840, 17409132100, 0.25 +Res-1.3841, 17409132100, 0.25 +Res-1.3842, 17409132100, 0.25 +Res-1.3843, 17409132100, 0.25 +Res-1.3844, 17409132100, 0.25 +Res-1.3845, 17409132100, 0.25 +Res-1.3846, 17409132100, 0.25 +Res-1.3847, 17409132100, 0.25 +Res-1.3848, 17409132100, 0.25 +Res-1.3849, 17409132100, 0.25 +Res-1.3850, 17409132100, 0.25 +Res-1.3851, 17409132100, 0.25 +Res-1.3852, 17409132100, 0.25 +Res-1.3853, 17409132100, 0.25 +Res-1.3854, 17409132100, 0.25 +Res-1.3855, 17409132100, 0.25 +Res-1.3856, 17409132100, 0.25 +Res-1.3857, 17409132100, 0.25 +Res-1.3858, 17409132100, 0.25 +Res-1.3859, 17409132100, 0.25 +Res-1.3860, 17409132100, 0.25 +Res-1.3861, 17409132100, 0.25 +Res-1.3862, 17409132100, 0.25 +Res-1.3863, 17409132100, 0.25 +Res-1.3864, 17409132100, 0.25 +Res-1.3865, 17409132100, 0.25 +Res-1.3866, 17409132100, 0.25 +Res-1.3867, 17409132100, 0.25 +Res-1.3868, 17409132100, 0.25 +Res-1.3869, 17409132100, 0.25 +Res-1.3870, 17409132100, 0.25 +Res-1.3871, 17409132100, 0.25 +Res-1.3872, 17409132100, 0.25 +Res-1.3873, 17409132100, 0.25 +Res-1.3874, 17409132100, 0.25 +Res-1.3875, 17409132100, 0.25 +Res-1.3876, 17409132100, 0.25 +Res-1.3877, 17409132100, 0.25 +Res-1.3878, 17409132100, 0.25 +Res-1.3879, 17409132100, 0.25 +Res-1.3880, 17409132100, 0.25 +Res-1.3881, 17409132100, 0.25 +Res-1.3882, 17409132100, 0.25 +Res-1.3883, 17409132100, 0.25 +Res-1.3884, 17409132100, 0.25 +Res-1.3885, 17409132100, 0.25 +Res-1.3886, 17409132100, 0.25 +Res-1.3887, 17409132100, 0.25 +Res-1.3888, 17409132100, 0.25 +Res-1.3889, 17409132100, 0.25 +Res-1.3890, 17409132100, 0.25 +Res-1.3891, 17409132100, 0.25 +Res-1.3892, 17409132100, 0.25 +Res-1.3893, 17409132100, 0.25 +Res-1.3894, 17409132100, 0.25 +Res-1.3895, 17409132100, 0.25 +Res-1.3896, 17409132100, 0.25 +Res-1.3897, 17409132100, 0.25 +Res-1.3898, 17409132100, 0.25 +Res-1.3899, 17409132100, 0.25 +Res-1.3900, 17409132100, 0.25 +Res-1.3901, 17409132100, 0.25 +Res-1.3902, 17409132100, 0.25 +Res-1.3903, 17409132100, 0.25 +Res-1.3904, 17409132100, 0.25 +Res-1.3905, 17409132100, 0.25 +Res-1.3906, 17409132100, 0.25 +Res-1.3907, 17409132100, 0.25 +Res-1.3908, 17409132100, 0.25 +Res-1.3909, 17409132100, 0.25 +Res-1.3910, 17409132100, 0.25 +Res-1.3911, 17409132100, 0.25 +Res-1.3912, 17409132100, 0.25 +Res-1.3913, 17409132100, 0.25 +Res-1.3914, 17409132100, 0.25 +Res-1.3915, 17409132100, 0.25 +Res-1.3916, 17409132100, 0.25 +Res-1.3917, 17409132100, 0.25 +Res-1.3918, 17409132100, 0.25 +Res-1.3919, 17409132100, 0.25 +Res-1.3920, 17409132100, 0.25 +Res-1.3921, 17409132100, 0.25 +Res-1.3922, 17409132100, 0.25 +Res-1.3923, 17409132100, 0.25 +Res-1.3924, 17409132100, 0.25 +Res-1.3925, 17409132100, 0.25 +Res-1.3926, 17409132100, 0.25 +Res-1.3927, 17409132100, 0.25 +Res-1.3928, 17409132100, 0.25 +Res-1.3929, 17409132100, 0.25 +Res-1.3930, 17409132100, 0.25 +Res-1.3931, 17409132100, 0.25 +Res-1.3932, 17409132100, 0.25 +Res-1.3933, 17409132100, 0.25 +Res-1.3934, 17409132100, 0.25 +Res-1.3935, 17409132100, 0.25 +Res-1.3936, 17409132100, 0.25 +Res-1.3937, 17409132100, 0.25 +Res-1.3938, 17409132100, 0.25 +Res-1.3939, 17409132100, 0.25 +Res-1.3940, 17409132100, 0.25 +Res-1.3941, 17409132100, 0.25 +Res-1.3942, 17409132100, 0.25 +Res-1.3943, 17409132100, 0.25 +Res-1.3944, 17409132100, 0.25 +Res-1.3945, 17409132100, 0.25 +Res-1.3946, 17409132100, 0.25 +Res-1.3947, 17409132100, 0.25 +Res-1.3948, 17409132100, 0.25 +Res-1.3949, 17409132100, 0.25 +Res-1.3950, 17409132100, 0.25 +Res-1.3951, 17409132100, 0.25 +Res-1.3952, 17409132100, 0.25 +Res-1.3953, 17409132100, 0.25 +Res-1.3954, 17409132100, 0.25 +Res-1.3955, 17409132100, 0.25 +Res-1.3956, 17409132100, 0.25 +Res-1.3957, 17409132100, 0.25 +Res-1.3958, 17409132100, 0.25 +Res-1.3959, 17409132100, 0.25 +Res-1.3960, 17409132100, 0.25 +Res-1.3961, 17409132100, 0.25 +Res-1.3962, 17409132100, 0.25 +Res-1.3963, 17409132100, 0.25 +Res-1.3964, 17409132100, 0.25 +Res-1.3965, 17409132100, 0.25 +Res-1.3966, 17409132100, 0.25 +Res-1.3967, 17409132100, 0.25 +Res-1.3968, 17409132100, 0.25 +Res-1.3969, 17409132100, 0.25 +Res-1.3970, 17409132100, 0.25 +Res-1.3971, 17409132100, 0.25 +Res-1.3972, 17409132100, 0.25 +Res-1.3973, 17409132100, 0.25 +Res-1.3974, 17409132100, 0.25 +Res-1.3975, 17409132100, 0.25 +Res-1.3976, 17409132100, 0.25 +Res-1.3977, 17409132100, 0.25 +Res-1.3978, 17409132100, 0.25 +Res-1.3979, 17409132100, 0.25 +Res-1.3980, 17409132100, 0.25 +Res-1.3981, 17409132100, 0.25 +Res-1.3982, 17409132100, 0.25 +Res-1.3983, 17409132100, 0.25 +Res-1.3984, 17409132100, 0.25 +Res-1.3985, 17409132100, 0.25 +Res-1.3986, 17409132100, 0.25 +Res-1.3987, 17409132100, 0.25 +Res-1.3988, 17409132100, 0.25 +Res-1.3989, 17409132100, 0.25 +Res-1.3990, 17409132100, 0.25 +Res-1.3991, 17409132100, 0.25 +Res-1.3992, 17409132100, 0.25 +Res-1.3993, 17409132100, 0.25 +Res-1.3994, 17409132100, 0.25 +Res-1.3995, 17409132100, 0.25 +Res-1.3996, 17409132100, 0.25 +Res-1.3997, 17409132100, 0.25 +Res-1.3998, 17409132100, 0.25 +Res-1.3999, 17409132100, 0.25 +Res-1.4000, 17409132100, 0.25 +Res-1.4001, 17409132100, 0.25 +Res-1.4002, 17409132100, 0.25 +Res-1.4003, 17409132100, 0.25 +Res-1.4004, 17409132100, 0.25 +Res-1.4005, 17409132100, 0.25 +Res-1.4006, 17409132100, 0.25 +Res-1.4007, 17409132100, 0.25 +Res-1.4008, 17409132100, 0.25 +Res-1.4009, 17409132100, 0.25 +Res-1.4010, 17409132100, 0.25 +Res-1.4011, 17409132100, 0.25 +Res-1.4012, 17409132100, 0.25 +Res-1.4013, 17409132100, 0.25 +Res-1.4014, 17409132100, 0.25 +Res-1.4015, 17409132100, 0.25 +Res-1.4016, 17409132100, 0.25 +Res-1.4017, 17409132100, 0.25 +Res-1.4018, 17409132100, 0.25 +Res-1.4019, 17409132100, 0.25 +Res-1.4020, 17409132100, 0.25 +Res-1.4021, 17409132100, 0.25 +Res-1.4022, 17409132100, 0.25 +Res-1.4023, 17409132100, 0.25 +Res-1.4024, 17409132100, 0.25 +Res-1.4025, 17409132100, 0.25 +Res-1.4026, 17409132100, 0.25 +Res-1.4027, 17409132100, 0.25 +Res-1.4028, 17409132100, 0.25 +Res-1.4029, 17409132100, 0.25 +Res-1.4030, 17409132100, 0.25 +Res-1.4031, 17409132100, 0.25 +Res-1.4032, 17409132100, 0.25 +Res-1.4033, 13250853676.3636, 0.25 +Res-1.4034, 13250853676.3636, 0.25 +Res-1.4035, 13250853676.3636, 0.25 +Res-1.4036, 13250853676.3636, 0.25 +Res-1.4037, 13250853676.3636, 0.25 +Res-1.4038, 13250853676.3636, 0.25 +Res-1.4039, 13250853676.3636, 0.25 +Res-1.4040, 13250853676.3636, 0.25 +Res-1.4041, 13250853676.3636, 0.25 +Res-1.4042, 13250853676.3636, 0.25 +Res-1.4043, 13250853676.3636, 0.25 +Res-1.4044, 13250853676.3636, 0.25 +Res-1.4045, 13250853676.3636, 0.25 +Res-1.4046, 13250853676.3636, 0.25 +Res-1.4047, 13250853676.3636, 0.25 +Res-1.4048, 13250853676.3636, 0.25 +Res-1.4049, 13250853676.3636, 0.25 +Res-1.4050, 13250853676.3636, 0.25 +Res-1.4051, 13250853676.3636, 0.25 +Res-1.4052, 13250853676.3636, 0.25 +Res-1.4053, 13250853676.3636, 0.25 +Res-1.4054, 13250853676.3636, 0.25 +Res-1.4055, 13250853676.3636, 0.25 +Res-1.4056, 13250853676.3636, 0.25 +Res-1.4057, 13250853676.3636, 0.25 +Res-1.4058, 13250853676.3636, 0.25 +Res-1.4059, 13250853676.3636, 0.25 +Res-1.4060, 13250853676.3636, 0.25 +Res-1.4061, 13250853676.3636, 0.25 +Res-1.4062, 13250853676.3636, 0.25 +Res-1.4063, 13250853676.3636, 0.25 +Res-1.4064, 13250853676.3636, 0.25 +Res-1.4065, 13250853676.3636, 0.25 +Res-1.4066, 13250853676.3636, 0.25 +Res-1.4067, 13250853676.3636, 0.25 +Res-1.4068, 13250853676.3636, 0.25 +Res-1.4069, 13250853676.3636, 0.25 +Res-1.4070, 13250853676.3636, 0.25 +Res-1.4071, 13250853676.3636, 0.25 +Res-1.4072, 13250853676.3636, 0.25 +Res-1.4073, 13250853676.3636, 0.25 +Res-1.4074, 13250853676.3636, 0.25 +Res-1.4075, 13250853676.3636, 0.25 +Res-1.4076, 13250853676.3636, 0.25 +Res-1.4077, 13250853676.3636, 0.25 +Res-1.4078, 13250853676.3636, 0.25 +Res-1.4079, 13250853676.3636, 0.25 +Res-1.4080, 13250853676.3636, 0.25 +Res-1.4081, 13250853676.3636, 0.25 +Res-1.4082, 13250853676.3636, 0.25 +Res-1.4083, 13250853676.3636, 0.25 +Res-1.4084, 13250853676.3636, 0.25 +Res-1.4085, 13250853676.3636, 0.25 +Res-1.4086, 13250853676.3636, 0.25 +Res-1.4087, 13250853676.3636, 0.25 +Res-1.4088, 13250853676.3636, 0.25 +Res-1.4089, 13250853676.3636, 0.25 +Res-1.4090, 13250853676.3636, 0.25 +Res-1.4091, 13250853676.3636, 0.25 +Res-1.4092, 13250853676.3636, 0.25 +Res-1.4093, 13250853676.3636, 0.25 +Res-1.4094, 13250853676.3636, 0.25 +Res-1.4095, 13250853676.3636, 0.25 +Res-1.4096, 13250853676.3636, 0.25 +Res-1.4097, 13250853676.3636, 0.25 +Res-1.4098, 13250853676.3636, 0.25 +Res-1.4099, 13250853676.3636, 0.25 +Res-1.4100, 13250853676.3636, 0.25 +Res-1.4101, 13250853676.3636, 0.25 +Res-1.4102, 13250853676.3636, 0.25 +Res-1.4103, 13250853676.3636, 0.25 +Res-1.4104, 13250853676.3636, 0.25 +Res-1.4105, 13250853676.3636, 0.25 +Res-1.4106, 13250853676.3636, 0.25 +Res-1.4107, 13250853676.3636, 0.25 +Res-1.4108, 13250853676.3636, 0.25 +Res-1.4109, 13250853676.3636, 0.25 +Res-1.4110, 13250853676.3636, 0.25 +Res-1.4111, 13250853676.3636, 0.25 +Res-1.4112, 13250853676.3636, 0.25 +Res-1.4113, 13250853676.3636, 0.25 +Res-1.4114, 13250853676.3636, 0.25 +Res-1.4115, 13250853676.3636, 0.25 +Res-1.4116, 13250853676.3636, 0.25 +Res-1.4117, 13250853676.3636, 0.25 +Res-1.4118, 13250853676.3636, 0.25 +Res-1.4119, 13250853676.3636, 0.25 +Res-1.4120, 13250853676.3636, 0.25 +Res-1.4121, 13250853676.3636, 0.25 +Res-1.4122, 13250853676.3636, 0.25 +Res-1.4123, 13250853676.3636, 0.25 +Res-1.4124, 13250853676.3636, 0.25 +Res-1.4125, 13250853676.3636, 0.25 +Res-1.4126, 13250853676.3636, 0.25 +Res-1.4127, 13250853676.3636, 0.25 +Res-1.4128, 13250853676.3636, 0.25 +Res-1.4129, 13250853676.3636, 0.25 +Res-1.4130, 13250853676.3636, 0.25 +Res-1.4131, 13250853676.3636, 0.25 +Res-1.4132, 13250853676.3636, 0.25 +Res-1.4133, 13250853676.3636, 0.25 +Res-1.4134, 13250853676.3636, 0.25 +Res-1.4135, 13250853676.3636, 0.25 +Res-1.4136, 13250853676.3636, 0.25 +Res-1.4137, 13250853676.3636, 0.25 +Res-1.4138, 13250853676.3636, 0.25 +Res-1.4139, 13250853676.3636, 0.25 +Res-1.4140, 13250853676.3636, 0.25 +Res-1.4141, 13250853676.3636, 0.25 +Res-1.4142, 13250853676.3636, 0.25 +Res-1.4143, 13250853676.3636, 0.25 +Res-1.4144, 13250853676.3636, 0.25 +Res-1.4145, 13250853676.3636, 0.25 +Res-1.4146, 13250853676.3636, 0.25 +Res-1.4147, 13250853676.3636, 0.25 +Res-1.4148, 13250853676.3636, 0.25 +Res-1.4149, 13250853676.3636, 0.25 +Res-1.4150, 13250853676.3636, 0.25 +Res-1.4151, 13250853676.3636, 0.25 +Res-1.4152, 13250853676.3636, 0.25 +Res-1.4153, 13250853676.3636, 0.25 +Res-1.4154, 13250853676.3636, 0.25 +Res-1.4155, 13250853676.3636, 0.25 +Res-1.4156, 13250853676.3636, 0.25 +Res-1.4157, 13250853676.3636, 0.25 +Res-1.4158, 13250853676.3636, 0.25 +Res-1.4159, 13250853676.3636, 0.25 +Res-1.4160, 13250853676.3636, 0.25 +Res-1.4161, 13250853676.3636, 0.25 +Res-1.4162, 13250853676.3636, 0.25 +Res-1.4163, 13250853676.3636, 0.25 +Res-1.4164, 13250853676.3636, 0.25 +Res-1.4165, 13250853676.3636, 0.25 +Res-1.4166, 13250853676.3636, 0.25 +Res-1.4167, 13250853676.3636, 0.25 +Res-1.4168, 13250853676.3636, 0.25 +Res-1.4169, 13250853676.3636, 0.25 +Res-1.4170, 13250853676.3636, 0.25 +Res-1.4171, 13250853676.3636, 0.25 +Res-1.4172, 13250853676.3636, 0.25 +Res-1.4173, 13250853676.3636, 0.25 +Res-1.4174, 13250853676.3636, 0.25 +Res-1.4175, 13250853676.3636, 0.25 +Res-1.4176, 13250853676.3636, 0.25 +Res-1.4177, 13250853676.3636, 0.25 +Res-1.4178, 13250853676.3636, 0.25 +Res-1.4179, 13250853676.3636, 0.25 +Res-1.4180, 13250853676.3636, 0.25 +Res-1.4181, 13250853676.3636, 0.25 +Res-1.4182, 13250853676.3636, 0.25 +Res-1.4183, 13250853676.3636, 0.25 +Res-1.4184, 13250853676.3636, 0.25 +Res-1.4185, 13250853676.3636, 0.25 +Res-1.4186, 13250853676.3636, 0.25 +Res-1.4187, 13250853676.3636, 0.25 +Res-1.4188, 13250853676.3636, 0.25 +Res-1.4189, 13250853676.3636, 0.25 +Res-1.4190, 13250853676.3636, 0.25 +Res-1.4191, 13250853676.3636, 0.25 +Res-1.4192, 13250853676.3636, 0.25 +Res-1.4193, 13250853676.3636, 0.25 +Res-1.4194, 13250853676.3636, 0.25 +Res-1.4195, 13250853676.3636, 0.25 +Res-1.4196, 13250853676.3636, 0.25 +Res-1.4197, 13250853676.3636, 0.25 +Res-1.4198, 13250853676.3636, 0.25 +Res-1.4199, 13250853676.3636, 0.25 +Res-1.4200, 13250853676.3636, 0.25 +Res-1.4201, 13250853676.3636, 0.25 +Res-1.4202, 13250853676.3636, 0.25 +Res-1.4203, 13250853676.3636, 0.25 +Res-1.4204, 13250853676.3636, 0.25 +Res-1.4205, 13250853676.3636, 0.25 +Res-1.4206, 13250853676.3636, 0.25 +Res-1.4207, 13250853676.3636, 0.25 +Res-1.4208, 13250853676.3636, 0.25 +Res-1.4209, 13250853676.3636, 0.25 +Res-1.4210, 13250853676.3636, 0.25 +Res-1.4211, 13250853676.3636, 0.25 +Res-1.4212, 13250853676.3636, 0.25 +Res-1.4213, 13250853676.3636, 0.25 +Res-1.4214, 13250853676.3636, 0.25 +Res-1.4215, 13250853676.3636, 0.25 +Res-1.4216, 13250853676.3636, 0.25 +Res-1.4217, 13250853676.3636, 0.25 +Res-1.4218, 13250853676.3636, 0.25 +Res-1.4219, 13250853676.3636, 0.25 +Res-1.4220, 13250853676.3636, 0.25 +Res-1.4221, 13250853676.3636, 0.25 +Res-1.4222, 13250853676.3636, 0.25 +Res-1.4223, 13250853676.3636, 0.25 +Res-1.4224, 13250853676.3636, 0.25 +Res-1.4225, 13250853676.3636, 0.25 +Res-1.4226, 13250853676.3636, 0.25 +Res-1.4227, 13250853676.3636, 0.25 +Res-1.4228, 13250853676.3636, 0.25 +Res-1.4229, 13250853676.3636, 0.25 +Res-1.4230, 13250853676.3636, 0.25 +Res-1.4231, 13250853676.3636, 0.25 +Res-1.4232, 13250853676.3636, 0.25 +Res-1.4233, 13250853676.3636, 0.25 +Res-1.4234, 13250853676.3636, 0.25 +Res-1.4235, 13250853676.3636, 0.25 +Res-1.4236, 13250853676.3636, 0.25 +Res-1.4237, 13250853676.3636, 0.25 +Res-1.4238, 13250853676.3636, 0.25 +Res-1.4239, 13250853676.3636, 0.25 +Res-1.4240, 13250853676.3636, 0.25 +Res-1.4241, 13250853676.3636, 0.25 +Res-1.4242, 13250853676.3636, 0.25 +Res-1.4243, 13250853676.3636, 0.25 +Res-1.4244, 13250853676.3636, 0.25 +Res-1.4245, 13250853676.3636, 0.25 +Res-1.4246, 13250853676.3636, 0.25 +Res-1.4247, 13250853676.3636, 0.25 +Res-1.4248, 13250853676.3636, 0.25 +Res-1.4249, 13250853676.3636, 0.25 +Res-1.4250, 13250853676.3636, 0.25 +Res-1.4251, 13250853676.3636, 0.25 +Res-1.4252, 13250853676.3636, 0.25 +Res-1.4253, 13250853676.3636, 0.25 +Res-1.4254, 13250853676.3636, 0.25 +Res-1.4255, 13250853676.3636, 0.25 +Res-1.4256, 13250853676.3636, 0.25 +Res-1.4257, 13250853676.3636, 0.25 +Res-1.4258, 13250853676.3636, 0.25 +Res-1.4259, 13250853676.3636, 0.25 +Res-1.4260, 13250853676.3636, 0.25 +Res-1.4261, 13250853676.3636, 0.25 +Res-1.4262, 13250853676.3636, 0.25 +Res-1.4263, 13250853676.3636, 0.25 +Res-1.4264, 13250853676.3636, 0.25 +Res-1.4265, 13250853676.3636, 0.25 +Res-1.4266, 13250853676.3636, 0.25 +Res-1.4267, 13250853676.3636, 0.25 +Res-1.4268, 13250853676.3636, 0.25 +Res-1.4269, 13250853676.3636, 0.25 +Res-1.4270, 13250853676.3636, 0.25 +Res-1.4271, 13250853676.3636, 0.25 +Res-1.4272, 13250853676.3636, 0.25 +Res-1.4273, 13250853676.3636, 0.25 +Res-1.4274, 13250853676.3636, 0.25 +Res-1.4275, 13250853676.3636, 0.25 +Res-1.4276, 13250853676.3636, 0.25 +Res-1.4277, 13250853676.3636, 0.25 +Res-1.4278, 13250853676.3636, 0.25 +Res-1.4279, 13250853676.3636, 0.25 +Res-1.4280, 13250853676.3636, 0.25 +Res-1.4281, 13250853676.3636, 0.25 +Res-1.4282, 13250853676.3636, 0.25 +Res-1.4283, 13250853676.3636, 0.25 +Res-1.4284, 13250853676.3636, 0.25 +Res-1.4285, 13250853676.3636, 0.25 +Res-1.4286, 13250853676.3636, 0.25 +Res-1.4287, 13250853676.3636, 0.25 +Res-1.4288, 13250853676.3636, 0.25 +Res-1.4289, 13250853676.3636, 0.25 +Res-1.4290, 13250853676.3636, 0.25 +Res-1.4291, 13250853676.3636, 0.25 +Res-1.4292, 13250853676.3636, 0.25 +Res-1.4293, 13250853676.3636, 0.25 +Res-1.4294, 13250853676.3636, 0.25 +Res-1.4295, 13250853676.3636, 0.25 +Res-1.4296, 13250853676.3636, 0.25 +Res-1.4297, 13250853676.3636, 0.25 +Res-1.4298, 13250853676.3636, 0.25 +Res-1.4299, 13250853676.3636, 0.25 +Res-1.4300, 13250853676.3636, 0.25 +Res-1.4301, 13250853676.3636, 0.25 +Res-1.4302, 13250853676.3636, 0.25 +Res-1.4303, 13250853676.3636, 0.25 +Res-1.4304, 13250853676.3636, 0.25 +Res-1.4305, 13250853676.3636, 0.25 +Res-1.4306, 13250853676.3636, 0.25 +Res-1.4307, 13250853676.3636, 0.25 +Res-1.4308, 13250853676.3636, 0.25 +Res-1.4309, 13250853676.3636, 0.25 +Res-1.4310, 13250853676.3636, 0.25 +Res-1.4311, 13250853676.3636, 0.25 +Res-1.4312, 13250853676.3636, 0.25 +Res-1.4313, 13250853676.3636, 0.25 +Res-1.4314, 13250853676.3636, 0.25 +Res-1.4315, 13250853676.3636, 0.25 +Res-1.4316, 13250853676.3636, 0.25 +Res-1.4317, 13250853676.3636, 0.25 +Res-1.4318, 13250853676.3636, 0.25 +Res-1.4319, 13250853676.3636, 0.25 +Res-1.4320, 13250853676.3636, 0.25 \ No newline at end of file diff --git a/ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp b/ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp new file mode 100644 index 0000000000..9a7c58cb58 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/RimRelocatePath/RelocatePath.rsp @@ -0,0 +1,534 @@ + + + C:/Users/Rebecca Cox/Desktop/regression-tests/ProjectFiles/element_properties.rsp + 2018.01.00-dev.01 + 0 + 0 + + + + + + + + + + + + + smal_synt + -1 + + + + + 0 + 0 + TS_ALL + 1 + + + C:\Users\Rebecca Cox\Desktop\regression-tests\ModelData\smal_synt.odb + + + + + 0 + 0 + 0 + 1034 + 547 + True + + + True + View 1 + -0.594 -0.283646 -0.752801 -5819.28 -0.489311 0.870164 0.0582249 -656.548 0.638544 0.402939 -0.655668 -21775.3 0 0 0 1 + 3800 1686.01 -4633.9 + True + 5 + 0.694118 0.772549 0.870588 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + False + ALL_TIMESTEPS + ALL_CELLS + + + + + ELEMENT + Density + + False + 0 + + + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + + + True + + + E, Density, (1500 .. 2652.75) + True + INCLUDE + + + + ELEMENT + Density + + False + 0 + + + 1500 + 2652.75 + + + + + + + + + 0 + 0 + 0 + 1034 + 547 + True + + + True + View 2 + 0.843247 0.06208 -0.533929 -11599.1 -0.347573 0.820684 -0.45351 -7654.19 0.410033 0.568 0.713617 -9392.31 0 0 0 1 + 0 0 0 + True + 5 + 0.694118 0.772549 0.870588 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + False + ALL_TIMESTEPS + ALL_CELLS + + + + + ELEMENT + MODULUS + + False + 0 + + + 8 + 4 + FIXED + NORMAL + LinearContinuous + USER_DEFINED_MAX_MIN + 17.41 + 5.316 + + + + + + + + True + + + E, Young's Modulus, (10.4982 .. 17.4091) + True + INCLUDE + + + + ELEMENT + MODULUS + + False + 0 + + + 10.4982 + 17.4091 + + + + + + + + + 0 + 0 + 0 + 1034 + 547 + True + + + True + View 3 + -0.541294 0.738323 0.402342 4749.47 0.834496 0.530356 0.14946 1161.22 -0.103035 0.416655 -0.903207 -41220.3 0 0 0 1 + 3800 -744.597 -10718 + True + 5 + 0.694118 0.772549 0.870588 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + False + ALL_TIMESTEPS + ALL_CELLS + + + + + ELEMENT + RATIO + + False + 0 + + + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + + + True + + + + + + 10 + 30 + C:\Users\Rebecca Cox\Desktop\regression-tests\ModelData\DENSITY_TABLE.inp;C:\Users\Rebecca Cox\Desktop\regression-tests\ModelData\ELASTIC_TABLE.inp + + + + + + + True + True + 0.929412 0.929412 0.929412 + ALL_ON + 0.1 + True + 100 + + + + + + UNITS_METRIC + + + + + + + + + + + + + + + + + + + + + + + + + + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\InputPropTest.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\kaverage.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\kslice.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\LGRSOIL.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\SatNum.m + + + C:\gitroot\ResInsight\OctavePlugin\OctaveScripts\SoilTimeDiff.m + + + + + + + + + + True + True + UTM_FILTER_OFF + 0 + 0 + 0 + 0 + + + + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + 0 + -1 + -1 + False + + + False + + + SELECTED + + + 0.1 + True + CELLS_ACTIVE + + + + 0 + 146000 + + + + + + + + + + + + True + + + + + + + + + + + -1-110000050;-1-1100000;-1-110001050;-1-1100010;-1-1100020;-1-11000;-1-110 + 1 0;0 0;2 0;2 0 + + + True + False + + + + + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + + + + + 2 + 2 + 2 + 8 + + + + + + + UNIFIED_FILE + ALL_WELLS + TRANSMISSIBILITIES + 0 + False + True + True + True + False + + + + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt new file mode 100644 index 0000000000..d749c660ed --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderA/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt new file mode 100644 index 0000000000..d749c660ed --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/base/folderB/folderC/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt new file mode 100644 index 0000000000..8326e87343 --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderA/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text somthing has changed +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt new file mode 100644 index 0000000000..d749c660ed --- /dev/null +++ b/ApplicationCode/UnitTests/TestData/TextCompare/reference/folderB/folderC/getting_started.txt @@ -0,0 +1,12 @@ +some text + +some more text +some more text +some more text some more text some more text + +some more text +some more text +some more text +some more text + + diff --git a/ApplicationCode/UserInterface/CMakeLists_files.cmake b/ApplicationCode/UserInterface/CMakeLists_files.cmake index 58e825d702..29557d6499 100644 --- a/ApplicationCode/UserInterface/CMakeLists_files.cmake +++ b/ApplicationCode/UserInterface/CMakeLists_files.cmake @@ -1,137 +1,147 @@ -# 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}RiuCadNavigation.h -${CEE_CURRENT_LIST_DIR}RiuCursors.h -${CEE_CURRENT_LIST_DIR}RiuDragDrop.h -${CEE_CURRENT_LIST_DIR}RiuFemResultTextBuilder.h -${CEE_CURRENT_LIST_DIR}RiuGeoQuestNavigation.h -${CEE_CURRENT_LIST_DIR}RiuInterfaceToViewWindow.h -${CEE_CURRENT_LIST_DIR}RiuLineSegmentQwtPlotCurve.h -${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.h -${CEE_CURRENT_LIST_DIR}RiuMainWindow.h -${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.h -${CEE_CURRENT_LIST_DIR}RiuMdiSubWindow.h -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.h -${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.h -${CEE_CURRENT_LIST_DIR}RiuProjectPropertyView.h -${CEE_CURRENT_LIST_DIR}RiuPropertyViewTabWidget.h -${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuPvtPlotUpdater.h -${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h -${CEE_CURRENT_LIST_DIR}RiuQwtCurvePointTracker.h -${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.h -${CEE_CURRENT_LIST_DIR}RiuQwtPlotZoomer.h -${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.h -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotUpdater.h -${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h -${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuResultTextBuilder.h -${CEE_CURRENT_LIST_DIR}RiuRmsNavigation.h -${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.h -${CEE_CURRENT_LIST_DIR}RiuSelectionManager.h -${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.h -${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuTextDialog.h -${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.h -${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h -${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.h -${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.h -${CEE_CURRENT_LIST_DIR}RiuViewer.h -${CEE_CURRENT_LIST_DIR}RiuViewerCommands.h -${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.h -${CEE_CURRENT_LIST_DIR}RiuPlotAnnotationTool.h -${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.h -${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.h -${CEE_CURRENT_LIST_DIR}RiuEditPerforationCollectionWidget.h -${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h -${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellRftPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellPltPlot.h -${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.h -${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h -${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h -${CEE_CURRENT_LIST_DIR}RiuPlotObjectPicker.h -${CEE_CURRENT_LIST_DIR}RiuContextMenuLauncher.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefinitionKeywords.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelection.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionDialog.h -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionEditor.h -${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap.h -${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.h -${CEE_CURRENT_LIST_DIR}RiuTools.h +${CMAKE_CURRENT_LIST_DIR}/RiuCadNavigation.h +${CMAKE_CURRENT_LIST_DIR}/RiuCursors.h +${CMAKE_CURRENT_LIST_DIR}/RiuDragDrop.h +${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.h +${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.h +${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h +${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.h +${CMAKE_CURRENT_LIST_DIR}/RiuProjectPropertyView.h +${CMAKE_CURRENT_LIST_DIR}/RiuPropertyViewTabWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuWidgetDragger.h +${CMAKE_CURRENT_LIST_DIR}/RiuCvfOverlayItemWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotUpdater.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultTextBuilder.h +${CMAKE_CURRENT_LIST_DIR}/RiuRmsNavigation.h +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionChangedHandler.h +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuSimpleHistogramWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.h +${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuToolTipMenu.h +${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewerToViewInterface.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.h +${CMAKE_CURRENT_LIST_DIR}/RiuGeoMechXfTensorResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RiuFemTimeHistoryResultAccessor.h +${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellRftPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellPltPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuFlowCharacteristicsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuNightchartsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotObjectPicker.h +${CMAKE_CURRENT_LIST_DIR}/RiuContextMenuLauncher.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefinitionKeywords.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelection.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionEditor.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryVectorDescriptionMap.h +${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuGridStatisticsHistogramWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuTools.h +${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.h +${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.h +${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.h ) set (SOURCE_GROUP_SOURCE_FILES -${CEE_CURRENT_LIST_DIR}RiuCadNavigation.cpp -${CEE_CURRENT_LIST_DIR}RiuCursors.cpp -${CEE_CURRENT_LIST_DIR}RiuDragDrop.cpp -${CEE_CURRENT_LIST_DIR}RiuFemResultTextBuilder.cpp -${CEE_CURRENT_LIST_DIR}RiuGeoQuestNavigation.cpp -${CEE_CURRENT_LIST_DIR}RiuInterfaceToViewWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuLineSegmentQwtPlotCurve.cpp -${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuMainWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.cpp -${CEE_CURRENT_LIST_DIR}RiuMdiSubWindow.cpp -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.cpp -${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.cpp -${CEE_CURRENT_LIST_DIR}RiuProjectPropertyView.cpp -${CEE_CURRENT_LIST_DIR}RiuPropertyViewTabWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.cpp -${CEE_CURRENT_LIST_DIR}RiuPvtPlotUpdater.cpp -${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.cpp -${CEE_CURRENT_LIST_DIR}RiuQwtCurvePointTracker.cpp -${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.cpp -${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.cpp -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.cpp -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotUpdater.cpp -${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.cpp -${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuResultTextBuilder.cpp -${CEE_CURRENT_LIST_DIR}RiuRmsNavigation.cpp -${CEE_CURRENT_LIST_DIR}RiuSelectionChangedHandler.cpp -${CEE_CURRENT_LIST_DIR}RiuSelectionManager.cpp -${CEE_CURRENT_LIST_DIR}RiuSimpleHistogramWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuTextDialog.cpp -${CEE_CURRENT_LIST_DIR}RiuTimeStepChangedHandler.cpp -${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuToolTipMenu.cpp -${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.cpp -${CEE_CURRENT_LIST_DIR}RiuViewer.cpp -${CEE_CURRENT_LIST_DIR}RiuViewerCommands.cpp -${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.cpp -${CEE_CURRENT_LIST_DIR}RiuPlotAnnotationTool.cpp -${CEE_CURRENT_LIST_DIR}RiuGeoMechXfTensorResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RiuFemTimeHistoryResultAccessor.cpp -${CEE_CURRENT_LIST_DIR}RiuEditPerforationCollectionWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuWellRftPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuWellPltPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.cpp -${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuMessagePanel.cpp -${CEE_CURRENT_LIST_DIR}RiuPlotObjectPicker.cpp -${CEE_CURRENT_LIST_DIR}RiuContextMenuLauncher.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelection.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionDialog.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryCurveDefSelectionEditor.cpp -${CEE_CURRENT_LIST_DIR}RiuSummaryVectorDescriptionMap.cpp -${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.cpp -${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.cpp -${CEE_CURRENT_LIST_DIR}RiuGridStatisticsHistogramWidget.cpp -${CEE_CURRENT_LIST_DIR}RiuTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCadNavigation.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCursors.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuDragDrop.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFemResultTextBuilder.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuGeoQuestNavigation.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuInterfaceToViewWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuLineSegmentQwtPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRimQwtPlotCurve.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMdiSubWindow.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuProjectPropertyView.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPropertyViewTabWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotUpdater.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuQwtCurvePointTracker.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWidgetDragger.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCvfOverlayItemWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotUpdater.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuResultQwtPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuResultTextBuilder.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuRmsNavigation.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionChangedHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSelectionManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSimpleHistogramWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTimeStepChangedHandler.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuToolTipMenu.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuViewer.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotAnnotationTool.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuGeoMechXfTensorResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFemTimeHistoryResultAccessor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellRftPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuWellPltPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuFlowCharacteristicsPlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuNightchartsWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotObjectPicker.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuContextMenuLauncher.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelection.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionDialog.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryCurveDefSelectionEditor.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryVectorDescriptionMap.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuGridStatisticsHistogramWidget.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindowTools.cpp +${CMAKE_CURRENT_LIST_DIR}/Riu3DMainWindowTools.cpp +${CMAKE_CURRENT_LIST_DIR}/RiuDockWidgetTools.cpp ) list(APPEND CODE_HEADER_FILES @@ -143,40 +153,43 @@ ${SOURCE_GROUP_SOURCE_FILES} ) list(APPEND QT_MOC_HEADERS -${CEE_CURRENT_LIST_DIR}RiuMainWindowBase.h -${CEE_CURRENT_LIST_DIR}RiuMainWindow.h -${CEE_CURRENT_LIST_DIR}RiuMainPlotWindow.h -${CEE_CURRENT_LIST_DIR}RiuPvtPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuRelativePermeabilityPlotPanel.h -${CEE_CURRENT_LIST_DIR}RiuResultInfoPanel.h -${CEE_CURRENT_LIST_DIR}RiuResultQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuTextDialog.h -${CEE_CURRENT_LIST_DIR}RiuViewer.h -${CEE_CURRENT_LIST_DIR}RiuProcessMonitor.h -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.h -${CEE_CURRENT_LIST_DIR}RiuViewerCommands.h -${CEE_CURRENT_LIST_DIR}RiuTreeViewEventFilter.h -${CEE_CURRENT_LIST_DIR}RiuWellLogPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellLogTrack.h -${CEE_CURRENT_LIST_DIR}RiuRecentFileActionProvider.h -${CEE_CURRENT_LIST_DIR}RiuSummaryQwtPlot.h -${CEE_CURRENT_LIST_DIR}RiuTofAccumulatedPhaseFractionsPlot.h -${CEE_CURRENT_LIST_DIR}RiuQwtScalePicker.h -${CEE_CURRENT_LIST_DIR}RiuQwtPlotWheelZoomer.h -${CEE_CURRENT_LIST_DIR}RiuEditPerforationCollectionWidget.h -${CEE_CURRENT_LIST_DIR}RiuExportMultipleSnapshotsWidget.h -${CEE_CURRENT_LIST_DIR}RiuWellAllocationPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellRftPlot.h -${CEE_CURRENT_LIST_DIR}RiuWellPltPlot.h -${CEE_CURRENT_LIST_DIR}RiuFlowCharacteristicsPlot.h -${CEE_CURRENT_LIST_DIR}RiuNightchartsWidget.h -${CEE_CURRENT_LIST_DIR}RiuMessagePanel.h -${CEE_CURRENT_LIST_DIR}RiuExpressionContextMenuManager.h -${CEE_CURRENT_LIST_DIR}RiuCalculationsContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindowBase.h +${CMAKE_CURRENT_LIST_DIR}/RiuMainWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuPlotMainWindow.h +${CMAKE_CURRENT_LIST_DIR}/RiuPvtPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuRelativePermeabilityPlotPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultInfoPanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuResultQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuTextDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewer.h +${CMAKE_CURRENT_LIST_DIR}/RiuProcessMonitor.h +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.h +${CMAKE_CURRENT_LIST_DIR}/RiuViewerCommands.h +${CMAKE_CURRENT_LIST_DIR}/RiuTreeViewEventFilter.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellLogTrack.h +${CMAKE_CURRENT_LIST_DIR}/RiuRecentFileActionProvider.h +${CMAKE_CURRENT_LIST_DIR}/RiuSummaryQwtPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuTofAccumulatedPhaseFractionsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtScalePicker.h +${CMAKE_CURRENT_LIST_DIR}/RiuQwtPlotWheelZoomer.h +${CMAKE_CURRENT_LIST_DIR}/RiuWidgetDragger.h +${CMAKE_CURRENT_LIST_DIR}/RiuCvfOverlayItemWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuEditPerforationCollectionWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuExportMultipleSnapshotsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellAllocationPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellRftPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuWellPltPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuFlowCharacteristicsPlot.h +${CMAKE_CURRENT_LIST_DIR}/RiuNightchartsWidget.h +${CMAKE_CURRENT_LIST_DIR}/RiuMessagePanel.h +${CMAKE_CURRENT_LIST_DIR}/RiuExpressionContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuCalculationsContextMenuManager.h +${CMAKE_CURRENT_LIST_DIR}/RiuMohrsCirclePlot.h ) list(APPEND QT_UI_FILES -${CEE_CURRENT_LIST_DIR}RiuMultiCaseImportDialog.ui +${CMAKE_CURRENT_LIST_DIR}/RiuMultiCaseImportDialog.ui ) -source_group( "UserInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CEE_CURRENT_LIST_DIR}CMakeLists_files.cmake ) +source_group( "UserInterface" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp b/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp new file mode 100644 index 0000000000..6db4df1274 --- /dev/null +++ b/ApplicationCode/UserInterface/Riu3DMainWindowTools.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "Riu3DMainWindowTools.h" +#include "RiuMainWindow.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QWidget* Riu3DMainWindowTools::mainWindowWidget() +{ + return RiuMainWindow::instance(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riu3DMainWindowTools::setActiveViewer(QWidget* subWindow) +{ + RiuMainWindow::instance()->setActiveViewer(subWindow); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riu3DMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/) +{ + RiuMainWindow::instance()->setExpanded(uiItem, expanded); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void Riu3DMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/) +{ + RiuMainWindow::instance()->selectAsCurrentItem(object, allowActiveViewChange); +} + + + diff --git a/ApplicationCode/UserInterface/Riu3DMainWindowTools.h b/ApplicationCode/UserInterface/Riu3DMainWindowTools.h new file mode 100644 index 0000000000..5f4f4e4ca2 --- /dev/null +++ b/ApplicationCode/UserInterface/Riu3DMainWindowTools.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QWidget; + +namespace caf +{ + class PdmUiItem; + class PdmObject; +} + +class Riu3DMainWindowTools +{ +public: + static QWidget* mainWindowWidget(); + static void setActiveViewer(QWidget* subWindow) ; + static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); +}; diff --git a/ApplicationCode/UserInterface/RiuCadNavigation.cpp b/ApplicationCode/UserInterface/RiuCadNavigation.cpp index 721b1ad323..26a5869a62 100644 --- a/ApplicationCode/UserInterface/RiuCadNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuCadNavigation.cpp @@ -59,7 +59,7 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier) + if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); @@ -98,7 +98,7 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) m_trackball->endNavigation(); m_isNavigating = false; - if (m_hasMovedMouseDuringNavigation) isEventHandled = true; + if (m_hasMovedMouseDuringNavigation) isEventHandled = true; m_hasMovedMouseDuringNavigation = false; } @@ -149,6 +149,8 @@ bool RiuCadNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h b/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h index d8a130cf57..f12c64f7a4 100644 --- a/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h +++ b/ApplicationCode/UserInterface/RiuCalculationsContextMenuManager.h @@ -43,17 +43,17 @@ class RiuCalculationsContextMenuManager : public QObject public: RiuCalculationsContextMenuManager() { } - void attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc); + void attachWidget(QWidget* widget, RicSummaryCurveCalculator* curveCalc); public slots: - void slotMenuItems(QPoint point); + void slotMenuItems(QPoint point); private slots: - void slotCreateCalculationCopy(); + void slotCreateCalculationCopy(); private: - QPointer m_widget; + QPointer m_widget; RicSummaryCurveCalculator* m_curveCalc; - int m_textPosition; + int m_textPosition; std::map> m_actionCache; }; diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp new file mode 100644 index 0000000000..46b015fd43 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.cpp @@ -0,0 +1,134 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuCvfOverlayItemWidget.h" + +#include "RiaApplication.h" + +#include "cafViewer.h" + +#include "cvfqtUtils.h" +#include "cvfRenderSequence.h" +#include "cvfFramebufferObject.h" +#include "cvfRenderbufferObject.h" +#include "cvfRendering.h" +#include "cvfCamera.h" + +#include +#include +#include +#include +#include +#include +#include + +#include "glew/GL/glew.h" +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuCvfOverlayItemWidget::RiuCvfOverlayItemWidget(QWidget* parent/*=0*/) +: QWidget(parent) +{ + auto hblayout = new QHBoxLayout(this); + hblayout->setMargin(0); + hblayout->setSpacing(0); + + this->setLayout(hblayout); + m_overlayItemLabel = new QLabel(this); + this->layout()->addWidget(m_overlayItemLabel); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuCvfOverlayItemWidget::~RiuCvfOverlayItemWidget() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuCvfOverlayItemWidget::updateFromOverlyItem( cvf::OverlayItem * item) +{ + // Use the render size of the overlayItem (sizeHint should be renamed) + + unsigned int width = item->sizeHint().x(); + unsigned int height = item->sizeHint().y(); + + QGLFormat glFormat; + glFormat.setDirectRendering(RiaApplication::instance()->useShaders()); + + caf::Viewer* viewer = new caf::Viewer(glFormat, nullptr); + cvf::OpenGLContext* cvfOglContext = viewer->cvfOpenGLContext(); + viewer->resize(width, height); + + // Create a rendering + + cvf::ref rendering = new cvf::Rendering; + item->setLayoutFixedPosition({0,0}); + rendering->addOverlayItem(item); + + + rendering->camera()->setViewport(0,0,width, height); + rendering->camera()->viewport()->setClearColor({1,1,1,0}); + + cvf::ref renderingSequence = new cvf::RenderSequence; + renderingSequence->addRendering(rendering.p()); + + if (RiaApplication::instance()->useShaders()) + { + // Set up frame and render buffers + + cvf::ref fbo = new cvf::FramebufferObject; + + cvf::ref rboColor = new cvf::RenderbufferObject(cvf::RenderbufferObject::RGBA, width, height); + cvf::ref rboDepth = new cvf::RenderbufferObject(cvf::RenderbufferObject::DEPTH_COMPONENT24, width, height); + + fbo->attachDepthRenderbuffer(rboDepth.p()); + fbo->attachColorRenderbuffer(0, rboColor.p()); + + fbo->applyOpenGL(cvfOglContext); + rendering->setTargetFramebuffer(fbo.p()); + fbo->bind(cvfOglContext); + } + + renderingSequence->render(cvfOglContext); + + // Read data from framebuffer + + cvf::UByteArray arr(4*width*height); + glReadPixels(0, 0, static_cast(width), static_cast(height), GL_RGBA, GL_UNSIGNED_BYTE, arr.ptr()); + + // Create a cvf texture image + + cvf::ref img = new cvf::TextureImage; + img->setData(arr.ptr(), width, height); + + QImage image = cvfqt::Utils::toQImage(*img.p()); + //image.save("jjsLegendImageTest.png"); + + QPixmap pixmap = QPixmap::fromImage(image); + + delete viewer; + + m_overlayItemLabel->setPixmap(pixmap); + this->setMinimumSize(QSize(width, height)); + this->resize(QSize(width, height)); + +} diff --git a/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h new file mode 100644 index 0000000000..46f670b479 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuCvfOverlayItemWidget.h @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include + +class QLabel; +namespace cvf +{ + class OverlayItem; +} + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuCvfOverlayItemWidget : public QWidget +{ + Q_OBJECT +public: + explicit RiuCvfOverlayItemWidget(QWidget* parent = nullptr); + ~RiuCvfOverlayItemWidget(); + + void updateFromOverlyItem( cvf::OverlayItem * item); + + // virtual QSize sizeHint() const override; + // virtual QSize minimumSizeHint() const override; + +protected: + QLabel* m_overlayItemLabel; +}; diff --git a/ApplicationCode/UserInterface/RiuDockWidgetTools.cpp b/ApplicationCode/UserInterface/RiuDockWidgetTools.cpp new file mode 100644 index 0000000000..36dc01aff6 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuDockWidgetTools.cpp @@ -0,0 +1,290 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuDockWidgetTools.h" + +#include "RimEclipseView.h" +#include "RimGeoMechView.h" + +#include "RiuMainWindow.h" + +#include "cvfAssert.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuDockWidgetTools::RiuDockWidgetTools() +{ + loadDockWidgetsState(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuDockWidgetTools* RiuDockWidgetTools::instance() +{ + static RiuDockWidgetTools staticInstance; + + return &staticInstance; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::projectTreeName() const +{ + return "dockProjectTree"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::propertyEditorName() const +{ + return "dockpropertyEditor"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::resultInfoName() const +{ + return "dockResultInfo"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::processMonitorName() const +{ + return "dockProcessMonitor"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::resultPlotName() const +{ + return "dockResultPlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::relPermPlotName() const +{ + return "dockRelPermPlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::pvtPlotName() const +{ + return "dockPvtPlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::mohrsCirclePlotName() const +{ + return "dockMohrsCirclePlot"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuDockWidgetTools::messagesName() const +{ + return "dockMessages"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QDockWidget* RiuDockWidgetTools::findDockWidget(const QObject* parent, const QString& dockWidgetName) +{ + QList dockWidgets = parent->findChildren(); + + for (QDockWidget* dock : dockWidgets) + { + if (dock->objectName() == dockWidgetName) + { + return dock; + } + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QAction* RiuDockWidgetTools::toggleActionForWidget(const QObject* parent, const QString& dockWidgetName) +{ + auto w = RiuDockWidgetTools::findDockWidget(parent, dockWidgetName); + CVF_ASSERT(w); + + return w->toggleViewAction(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::setVisibleDockingWindowsForEclipse() +{ + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + + { + QDockWidget* dockWidget = findDockWidget(mainWindow, RiuDockWidgetTools::mohrsCirclePlotName()); + if (dockWidget) + { + dockWidget->hide(); + } + } + + RiuDockWidgetTools::instance()->trySetDockWidgetVisibility(mainWindow, RiuDockWidgetTools::relPermPlotName(), true); + RiuDockWidgetTools::instance()->trySetDockWidgetVisibility(mainWindow, RiuDockWidgetTools::pvtPlotName(), true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::setVisibleDockingWindowsForGeoMech() +{ + RiuMainWindow* mainWindow = RiuMainWindow::instance(); + + RiuDockWidgetTools::instance()->trySetDockWidgetVisibility(mainWindow, RiuDockWidgetTools::mohrsCirclePlotName(), false); + + { + QDockWidget* dockWidget = findDockWidget(mainWindow, RiuDockWidgetTools::relPermPlotName()); + if (dockWidget) + { + dockWidget->hide(); + } + } + + { + QDockWidget* dockWidget = findDockWidget(mainWindow, RiuDockWidgetTools::pvtPlotName()); + if (dockWidget) + { + dockWidget->hide(); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::trySetDockWidgetVisibility(const QObject* parent, const QString& dockWidgetName, bool isVisible) +{ + QDockWidget* dockWidget = findDockWidget(parent, dockWidgetName); + if (dockWidget) + { + bool unifiedIsVisible = isVisible; + + auto state = visibilityForWidget(dockWidgetName); + if (state != RiuDockWidgetTools::USER_DEFINED_UNKNOWN) + { + if (state == RiuDockWidgetTools::USER_DEFINED_ON) + { + unifiedIsVisible = true; + } + else if (state == RiuDockWidgetTools::USER_DEFINED_OFF) + { + unifiedIsVisible = false; + } + } + + dockWidget->setVisible(unifiedIsVisible); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuDockWidgetTools::UserDefinedVisibility RiuDockWidgetTools::visibilityForWidget(const QString& objectName) +{ + RiuDockWidgetTools::UserDefinedVisibility visibility = USER_DEFINED_UNKNOWN; + + auto windowStateIt = m_userDefinedDockWidgetVisibility.find(objectName); + if (windowStateIt != m_userDefinedDockWidgetVisibility.end()) + { + bool isVisible = windowStateIt.value().toBool(); + if (isVisible) + { + visibility = USER_DEFINED_ON; + } + else + { + visibility = USER_DEFINED_OFF; + } + } + + return visibility; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::setDockWidgetVisibility(const QString& dockingWindowName, bool isVisible) +{ + m_userDefinedDockWidgetVisibility[dockingWindowName] = isVisible; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::loadDockWidgetsState() +{ + // Company and appname set through QCoreApplication + QSettings settings; + + m_userDefinedDockWidgetVisibility = settings.value("dockWindowStates").toMap(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::saveDockWidgetsState() +{ + // Company and appname set through QCoreApplication + QSettings settings; + + QVariant v(m_userDefinedDockWidgetVisibility); + settings.setValue("dockWindowStates", v); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuDockWidgetTools::changeDockWidgetVisibilityBasedOnView(Rim3dView* view) +{ + if (dynamic_cast(view)) + { + setVisibleDockingWindowsForEclipse(); + } + else if (dynamic_cast(view)) + { + setVisibleDockingWindowsForGeoMech(); + } +} diff --git a/ApplicationCode/UserInterface/RiuDockWidgetTools.h b/ApplicationCode/UserInterface/RiuDockWidgetTools.h new file mode 100644 index 0000000000..7e071d67e4 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuDockWidgetTools.h @@ -0,0 +1,74 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include +#include +#include + +class QDockWidget; +class QObject; +class QAction; + +class Rim3dView; + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuDockWidgetTools +{ +public: + static RiuDockWidgetTools* instance(); + + QString projectTreeName() const; + QString propertyEditorName() const; + QString resultInfoName() const; + QString processMonitorName() const; + QString resultPlotName() const; + QString relPermPlotName() const; + QString pvtPlotName() const; + QString messagesName() const; + QString mohrsCirclePlotName() const; + + QAction* toggleActionForWidget(const QObject* parent, const QString& dockWidgetName); + void setDockWidgetVisibility(const QString& dockWidgetName, bool isVisible); + void changeDockWidgetVisibilityBasedOnView(Rim3dView* view); + void saveDockWidgetsState(); + +private: + enum UserDefinedVisibility + { + USER_DEFINED_ON, + USER_DEFINED_OFF, + USER_DEFINED_UNKNOWN + }; + + RiuDockWidgetTools(); + void setVisibleDockingWindowsForEclipse(); + void setVisibleDockingWindowsForGeoMech(); + void loadDockWidgetsState(); + UserDefinedVisibility visibilityForWidget(const QString& dockWidgetName); + static QDockWidget* findDockWidget(const QObject* parent, const QString& dockWidgetName); + void trySetDockWidgetVisibility(const QObject* parent, const QString& dockWidgetName, bool isVisible); + +private: + QMap m_userDefinedDockWidgetVisibility; +}; diff --git a/ApplicationCode/UserInterface/RiuDragDrop.cpp b/ApplicationCode/UserInterface/RiuDragDrop.cpp index b41d7b1561..768cee7c93 100644 --- a/ApplicationCode/UserInterface/RiuDragDrop.cpp +++ b/ApplicationCode/UserInterface/RiuDragDrop.cpp @@ -145,7 +145,7 @@ Qt::DropActions RiuDragDrop::supportedDropActions() const //-------------------------------------------------------------------------------------------------- Qt::ItemFlags RiuDragDrop::flags(const QModelIndex &index) const { - Qt::ItemFlags itemflags = 0; + Qt::ItemFlags itemflags = nullptr; if (index.isValid()) { @@ -399,7 +399,7 @@ bool RiuDragDrop::handleWellLogPlotTrackDrop(Qt::DropAction action, caf::PdmObje { if (action == Qt::MoveAction) { - RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(trackTarget, wellLogPlotCurves, NULL); + RicWellLogPlotTrackFeatureImpl::moveCurvesToWellLogPlotTrack(trackTarget, wellLogPlotCurves, nullptr); return true; } } @@ -429,7 +429,7 @@ bool RiuDragDrop::handleWellLogPlotDrop(Qt::DropAction action, caf::PdmObjectGro { if (action == Qt::MoveAction) { - RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, NULL); + RicWellLogPlotTrackFeatureImpl::moveTracksToWellLogPlot(wellLogPlotTarget, wellLogPlotTracks, nullptr); return true; } } diff --git a/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp b/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp index d93d3b32ca..273d6f655a 100644 --- a/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp +++ b/ApplicationCode/UserInterface/RiuExportMultipleSnapshotsWidget.cpp @@ -27,7 +27,7 @@ #include "RimEclipseView.h" #include "RimMultiSnapshotDefinition.h" #include "RimProject.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RiuTools.h" @@ -138,7 +138,7 @@ void RiuExportMultipleSnapshotsWidget::addSnapshotItemFromActiveView() { if (!m_rimProject) return; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); if (activeView) { RimMultiSnapshotDefinition* multiSnapshot = new RimMultiSnapshotDefinition(); @@ -147,8 +147,8 @@ void RiuExportMultipleSnapshotsWidget::addSnapshotItemFromActiveView() RimEclipseView* eclipseView = dynamic_cast(activeView); if (eclipseView) { - multiSnapshot->eclipseResultType = eclipseView->cellResult->resultType(); - multiSnapshot->selectedEclipseResults.v().push_back(eclipseView->cellResult->resultVariable()); + multiSnapshot->eclipseResultType = eclipseView->cellResult()->resultType(); + multiSnapshot->selectedEclipseResults.v().push_back(eclipseView->cellResult()->resultVariable()); } multiSnapshot->timeStepStart = activeView->currentTimeStep(); diff --git a/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h b/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h index 13721c5256..be54ed5a46 100644 --- a/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h +++ b/ApplicationCode/UserInterface/RiuExpressionContextMenuManager.h @@ -39,18 +39,18 @@ class RiuExpressionContextMenuManager : public QObject static const std::map> MENU_MAP; public: - RiuExpressionContextMenuManager() { } + RiuExpressionContextMenuManager() { } - void attachTextEdit(QTextEdit* textEdit); + void attachTextEdit(QTextEdit* textEdit); public slots: - void slotMenuItems(QPoint point); + void slotMenuItems(QPoint point); private slots: - void slotShowText(); + void slotShowText(); private: - QPointer m_textEdit; - int m_textPosition; + QPointer m_textEdit; + int m_textPosition; std::map> m_actionCache; }; diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp index 3f996f5af0..d0fcd44f82 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.cpp @@ -25,12 +25,19 @@ #include "RigFemPartResultsCollection.h" #include "RigFormationNames.h" #include "RigGeoMechCaseData.h" + +#include "Rim2dIntersectionView.h" #include "RimFormationNames.h" #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" + #include "RiuGeoMechXfTensorResultAccessor.h" +#include "RivIntersectionPartMgr.h" + +#include "cafDisplayCoordTransform.h" + //-------------------------------------------------------------------------------------------------- @@ -70,6 +77,14 @@ void RiuFemResultTextBuilder::setIntersectionTriangle(const std::arraycellResultResultDefinition()); + RimGeoMechResultDefinition* cellResultDefinition = m_reservoirView->cellResultResultDefinition(); + + text = closestNodeResultText(cellResultDefinition); if (!text.isEmpty()) text += "\n"; @@ -94,7 +111,10 @@ QString RiuFemResultTextBuilder::mainResultText() appendDetails(text, formationDetails()); text += "\n"; - appendDetails(text, gridResultDetails()); + if (cellResultDefinition->resultPositionType() != RIG_ELEMENT) + { + appendDetails(text, gridResultDetails()); + } return text; } @@ -114,7 +134,9 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator) RigFemPart* femPart = geomData->femParts()->part(m_gridIndex); int elementId = femPart->elmId(m_cellIndex); - text += QString("Element : Id[%1]").arg(elementId); + auto elementType = femPart->elementType(m_cellIndex); + + text += QString("Element : Id[%1], Type[%2]").arg(elementId).arg(RigFemTypes::elementTypeText(elementType)); size_t i = 0; size_t j = 0; @@ -126,20 +148,30 @@ QString RiuFemResultTextBuilder::geometrySelectionText(QString itemSeparator) j++; k++; - cvf::Vec3d domainCoord = m_intersectionPoint; // + geomCase->femParts()->displayModelOffset(); - - //cvf::StructGridInterface::FaceEnum faceEnum(m_face); - - //QString faceText = faceEnum.text(); - - //text += QString("Face : %1").arg(faceText) + itemSeparator; - //text += QString("Fem Part %1").arg(m_gridIndex) + itemSeparator; text += QString(", ijk[%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + if (m_2dIntersectionView) + { + formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPoint.x()); + text += formattedText + itemSeparator; + + cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + cvf::ref transForm = m_reservoirView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); - text += formattedText; + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + text += formattedText; + } } } } @@ -185,12 +217,15 @@ QString RiuFemResultTextBuilder::formationDetails() size_t k = cvf::UNDEFINED_SIZE_T; { - RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); - if(geomData) + if ( m_reservoirView->geoMechCase() ) { - size_t i = 0; - size_t j = 0; - geomData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k); + RigGeoMechCaseData* geomData = m_reservoirView->geoMechCase()->geoMechData(); + if ( geomData ) + { + size_t i = 0; + size_t j = 0; + geomData->femParts()->part(m_gridIndex)->structGrid()->ijkFromCellIndex(m_cellIndex, &i, &j, &k); + } } } @@ -244,9 +279,12 @@ void RiuFemResultTextBuilder::appendTextFromResultColors(RigGeoMechCaseData* geo int nodeIdx = elmentConn[lNodeIdx]; if (resultDefinition->resultPositionType() == RIG_NODAL) { - scalarValue = scalarResults[nodeIdx]; } + else if (resultDefinition->resultPositionType() == RIG_ELEMENT) + { + scalarValue = scalarResults[cellIndex]; + } else { size_t resIdx = femPart->elementNodeResultIdx(cellIndex, lNodeIdx); @@ -360,7 +398,11 @@ QString RiuFemResultTextBuilder::closestNodeResultText(RimGeoMechResultDefinitio float scalarValue = (resultIndex >= 0) ? scalarResults[resultIndex]: std::numeric_limits::infinity(); - if (activeResultPosition != RIG_ELEMENT_NODAL_FACE) + if (activeResultPosition == RIG_ELEMENT) + { + text.append(QString("Element result: %1\n").arg(scalarValue)); + } + else if (activeResultPosition != RIG_ELEMENT_NODAL_FACE) { text.append(QString("Closest result: N[%1], %2\n").arg(closestNodeId) .arg(scalarValue)); diff --git a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h index dd81d9bea0..9754516c9d 100644 --- a/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuFemResultTextBuilder.h @@ -30,6 +30,7 @@ class RigGeoMechCaseData; class RimEclipseCellColors; class RimGeoMechResultDefinition; class RimGeoMechView; +class Rim2dIntersectionView; namespace cvf { class Part; @@ -46,6 +47,7 @@ class RiuFemResultTextBuilder void setFace(int face); void setIntersectionPoint(cvf::Vec3d intersectionPoint); void setIntersectionTriangle(const std::array& triangle); + void set2dIntersectionView(Rim2dIntersectionView* intersectionView); QString mainResultText(); @@ -63,6 +65,7 @@ class RiuFemResultTextBuilder private: caf::PdmPointer m_reservoirView; + caf::PdmPointer m_2dIntersectionView; int m_gridIndex; int m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp index 56000fe777..dfb3b62184 100644 --- a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp +++ b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.cpp @@ -47,9 +47,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuFlowCharacteristicsPlot::RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) + { Q_ASSERT(m_plotDefinition); diff --git a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h index b2f763df59..eeaf4f902b 100644 --- a/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h +++ b/ApplicationCode/UserInterface/RiuFlowCharacteristicsPlot.h @@ -47,7 +47,7 @@ class RiuFlowCharacteristicsPlot : public QFrame, public RiuInterfaceToViewWindo { Q_OBJECT; public: - RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = NULL); + RiuFlowCharacteristicsPlot(RimFlowCharacteristicsPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuFlowCharacteristicsPlot(); void setLorenzCurve(const QStringList& dateTimeStrings, const std::vector& dateTimes, const std::vector& timeHistoryValues); diff --git a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp index 27112bb00d..25ead7cfba 100644 --- a/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuGeoQuestNavigation.cpp @@ -59,7 +59,7 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::LeftButton) + if (me->button() == Qt::LeftButton && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic); @@ -160,6 +160,8 @@ bool RiuGeoQuestNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h b/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h index e3b24e3ab2..d6f08839fa 100644 --- a/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuGridStatisticsHistogramWidget.h @@ -30,7 +30,7 @@ class QStringList; class RiuGridStatisticsHistogramWidget : public QWidget { public: - RiuGridStatisticsHistogramWidget( QWidget * parent = 0, Qt::WindowFlags f = 0); + RiuGridStatisticsHistogramWidget( QWidget * parent = nullptr, Qt::WindowFlags f = nullptr); void setHistogramData(double min, double max, const std::vector& histogram); void setPercentiles(double pmin, double pmax); diff --git a/ApplicationCode/UserInterface/RiuMainWindow.cpp b/ApplicationCode/UserInterface/RiuMainWindow.cpp index f8969ee52a..b0d0bfa289 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindow.cpp @@ -24,30 +24,39 @@ #include "RiaBaseDefs.h" #include "RiaPreferences.h" #include "RiaRegressionTest.h" +#include "RiaRegressionTestRunner.h" +#include "Rim2dIntersectionView.h" +#include "Rim3dView.h" +#include "RimCellEdgeColors.h" #include "RimCommandObject.h" #include "RimEclipseCase.h" +#include "RimEclipseFaultColors.h" +#include "RimEclipsePropertyFilter.h" +#include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" #include "RimFaultInViewCollection.h" #include "RimGeoMechCase.h" #include "RimGeoMechView.h" +#include "RimIntersection.h" #include "RimProject.h" #include "RimSimWellInViewCollection.h" -#include "RimView.h" +#include "RiuDockWidgetTools.h" #include "RiuDragDrop.h" #include "RiuMdiSubWindow.h" #include "RiuMessagePanel.h" +#include "RiuMohrsCirclePlot.h" #include "RiuProcessMonitor.h" #include "RiuProjectPropertyView.h" #include "RiuPropertyViewTabWidget.h" +#include "RiuPvtPlotPanel.h" +#include "RiuRelativePermeabilityPlotPanel.h" #include "RiuResultInfoPanel.h" #include "RiuResultQwtPlot.h" #include "RiuToolTipMenu.h" #include "RiuTreeViewEventFilter.h" #include "RiuViewer.h" -#include "RiuRelativePermeabilityPlotPanel.h" -#include "RiuPvtPlotPanel.h" #include "cafAnimationToolBar.h" #include "cafCmdExecCommandManager.h" @@ -75,15 +84,12 @@ #include #include #include +#include #include #include #include -#define DOCK_PANEL_NAME_PROCESS_MONITOR "dockProcessMonitor" - - - //================================================================================================== /// /// \class RiuMainWindow @@ -93,20 +99,21 @@ //================================================================================================== -RiuMainWindow* RiuMainWindow::sm_mainWindowInstance = NULL; +RiuMainWindow* RiuMainWindow::sm_mainWindowInstance = nullptr; //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuMainWindow::RiuMainWindow() - : m_pdmRoot(NULL), - m_mainViewer(NULL), - m_relPermPlotPanel(NULL), - m_pvtPlotPanel(NULL), - m_windowMenu(NULL), + : m_pdmRoot(nullptr), + m_mainViewer(nullptr), + m_relPermPlotPanel(nullptr), + m_pvtPlotPanel(nullptr), + m_mohrsCirclePlot(nullptr), + m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) { - CVF_ASSERT(sm_mainWindowInstance == NULL); + CVF_ASSERT(sm_mainWindowInstance == nullptr); m_mdiArea = new QMdiArea; m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); @@ -143,6 +150,14 @@ RiuMainWindow* RiuMainWindow::instance() return sm_mainWindowInstance; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiuMainWindow::mainWindowName() +{ + return "RiuMainWindow"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -162,10 +177,15 @@ void RiuMainWindow::initializeGuiNewProjectLoaded() } m_processMonitor->slotClearTextEdit(); + + if (statusBar() && !RiaRegressionTestRunner::instance()->isRunningRegressionTests()) + { + statusBar()->showMessage("Ready ..."); + } } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- void RiuMainWindow::cleanupGuiCaseClose() { @@ -176,10 +196,11 @@ void RiuMainWindow::cleanupGuiCaseClose() m_resultQwtPlot->deleteAllCurves(); if (m_relPermPlotPanel) m_relPermPlotPanel->clearPlot(); if (m_pvtPlotPanel) m_pvtPlotPanel->clearPlot(); + if (m_mohrsCirclePlot) m_mohrsCirclePlot->clearPlot(); if (m_pdmUiPropertyView) { - m_pdmUiPropertyView->showProperties(NULL); + m_pdmUiPropertyView->showProperties(nullptr); } for (size_t i = 0; i < additionalProjectViews.size(); i++) @@ -187,10 +208,10 @@ void RiuMainWindow::cleanupGuiCaseClose() RiuProjectAndPropertyView* projPropView = dynamic_cast(additionalProjectViews[i]->widget()); if (projPropView) { - projPropView->showProperties(NULL); + projPropView->showProperties(nullptr); } } - m_processMonitor->startMonitorWorkProcess(NULL); + m_processMonitor->startMonitorWorkProcess(nullptr); RicEditSummaryPlotFeature* editSumCurves = dynamic_cast(caf::CmdFeatureManager::instance()->getCommandFeature("RicEditSummaryPlotFeature")); if (editSumCurves) @@ -206,7 +227,7 @@ void RiuMainWindow::cleanupGuiCaseClose() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::cleanupGuiBeforeProjectClose() { - setPdmRoot(NULL); + setPdmRoot(nullptr); cleanupGuiCaseClose(); } @@ -229,7 +250,7 @@ void RiuMainWindow::closeEvent(QCloseEvent* event) return; } - saveWinGeoAndDockToolBarLayout(); + app->saveWinGeoAndDockToolBarLayout(); if (!app->tryClosePlotWindow()) return; @@ -349,27 +370,40 @@ void RiuMainWindow::createMenus() fileMenu->addAction(cmdFeatureMgr->action("RicOpenLastUsedFileFeature")); fileMenu->addSeparator(); - QMenu* importMenu = fileMenu->addMenu("&Import"); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + + QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseTimeStepFilterFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); + importMenu->addSeparator(); + QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + #ifdef USE_ODB_API - importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); importMenu->addSeparator(); + QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); #endif - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addSeparator(); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data"); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + importMenu->addSeparator(); + importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); @@ -377,6 +411,7 @@ void RiuMainWindow::createMenus() exportMenu->addAction(cmdFeatureMgr->action("RicExportMultipleSnapshotsFeature")); exportMenu->addSeparator(); exportMenu->addAction(cmdFeatureMgr->action("RicSaveEclipseInputActiveVisibleCellsFeature")); + exportMenu->addAction(cmdFeatureMgr->action("RicExportCompletionsForVisibleWellPathsFeature")); fileMenu->addSeparator(); fileMenu->addAction(cmdFeatureMgr->action("RicSaveProjectFeature")); @@ -432,6 +467,7 @@ void RiuMainWindow::createMenus() testMenu->addAction(m_showRegressionTestDialog); testMenu->addAction(m_executePaintEventPerformanceTest); testMenu->addAction(cmdFeatureMgr->action("RicLaunchUnitTestsFeature")); + testMenu->addAction(cmdFeatureMgr->action("RicRunCommandFileFeature")); // Windows menu m_windowMenu = menuBar()->addMenu("&Windows"); @@ -517,6 +553,16 @@ void RiuMainWindow::createToolBars() dsToolBar->addAction(m_showWellCellsAction); } + RiaApplication* app = RiaApplication::instance(); + if (app->preferences()->showTestToolbar()) + { + QToolBar* toolbar = addToolBar(tr("Test")); + toolbar->setObjectName(toolbar->windowTitle()); + toolbar->addAction(cmdFeatureMgr->action("RicLaunchUnitTestsFeature")); + toolbar->addAction(cmdFeatureMgr->action("RicLaunchRegressionTestsFeature")); + toolbar->addAction(cmdFeatureMgr->action("RicRunCommandFileFeature")); + } + // Create animation toolbar m_animationToolBar = new caf::AnimationToolBar("Animation", this); addToolBar(m_animationToolBar); @@ -526,16 +572,36 @@ void RiuMainWindow::createToolBars() refreshDrawStyleActions(); } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- +class RiuDockWidget : public QDockWidget +{ +public: + explicit RiuDockWidget(const QString& title, QWidget* parent = 0, Qt::WindowFlags flags = 0) + : QDockWidget(title, parent, flags) + { + } + + void closeEvent(QCloseEvent* event) override + { + // This event is called when the user clicks the "x" in upper right corner to close the dock widget + RiuDockWidgetTools::instance()->setDockWidgetVisibility(objectName(), false); + + QDockWidget::closeEvent(event); + } +}; +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- void RiuMainWindow::createDockPanels() { + auto dwt = RiuDockWidgetTools::instance(); + { - QDockWidget* dockWidget = new QDockWidget("Project Tree", this); - dockWidget->setObjectName("dockWidget"); + QDockWidget* dockWidget = new RiuDockWidget("Project Tree", this); + dockWidget->setObjectName(dwt->projectTreeName()); dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas); m_projectTreeView = new caf::PdmUiTreeView(this); @@ -566,33 +632,14 @@ void RiuMainWindow::createDockPanels() connect(m_projectTreeView->treeView(), SIGNAL(customContextMenuRequested(const QPoint&)), SLOT(customMenuRequested(const QPoint&))); } -/* - { - QDockWidget* dockWidget = new QDockWidget("Undo stack", this); - dockWidget->setObjectName("dockWidget"); - dockWidget->setAllowedAreas(Qt::AllDockWidgetAreas); - - m_undoView = new QUndoView(this); - m_undoView->setStack(caf::CmdExecCommandManager::instance()->undoStack()); - //connect(caf::CmdExecCommandManager::instance()->undoStack(), SIGNAL(indexChanged(int)), SLOT(slotIndexChanged())); - - dockWidget->setWidget(m_undoView); - - addDockWidget(Qt::RightDockWidgetArea, dockWidget); - - dockWidget->hide(); - - //m_windowsMenu->addAction(dockWidget->toggleViewAction()); - } -*/ - QDockWidget* resultPlotDock = nullptr; QDockWidget* relPermPlotDock = nullptr; QDockWidget* pvtPlotDock = nullptr; + QDockWidget* mohrsCirclePlotDock = nullptr; { - QDockWidget* dockWidget = new QDockWidget("Property Editor", this); - dockWidget->setObjectName("dockWidget"); + QDockWidget* dockWidget = new RiuDockWidget("Property Editor", this); + dockWidget->setObjectName(dwt->propertyEditorName()); dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea); m_pdmUiPropertyView = new caf::PdmUiPropertyView(dockWidget); @@ -602,74 +649,100 @@ void RiuMainWindow::createDockPanels() } { - QDockWidget* dockPanel = new QDockWidget("Result Info", this); - dockPanel->setObjectName("dockResultInfoPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_resultInfoPanel = new RiuResultInfoPanel(dockPanel); - dockPanel->setWidget(m_resultInfoPanel); + QDockWidget* dockWidget = new RiuDockWidget("Result Info", this); + dockWidget->setObjectName(dwt->resultInfoName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_resultInfoPanel = new RiuResultInfoPanel(dockWidget); + dockWidget->setWidget(m_resultInfoPanel); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); } { - QDockWidget* dockPanel = new QDockWidget("Process Monitor", this); - dockPanel->setObjectName(DOCK_PANEL_NAME_PROCESS_MONITOR); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_processMonitor = new RiuProcessMonitor(dockPanel); - dockPanel->setWidget(m_processMonitor); + QDockWidget* dockWidget = new RiuDockWidget("Process Monitor", this); + dockWidget->setObjectName(dwt->processMonitorName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_processMonitor = new RiuProcessMonitor(dockWidget); + dockWidget->setWidget(m_processMonitor); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - dockPanel->hide(); + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + dockWidget->hide(); + } + + { + QDockWidget* dockWidget = new RiuDockWidget("Result Plot", this); + dockWidget->setObjectName(dwt->resultPlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_resultQwtPlot = new RiuResultQwtPlot(dockWidget); + dockWidget->setWidget(m_resultQwtPlot); + + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + resultPlotDock = dockWidget; } +#ifdef USE_ODB_API { - QDockWidget* dockPanel = new QDockWidget("Result Plot", this); - dockPanel->setObjectName("dockTimeHistoryPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_resultQwtPlot = new RiuResultQwtPlot(dockPanel); - dockPanel->setWidget(m_resultQwtPlot); + QDockWidget* dockWidget = new RiuDockWidget("Mohr's Circle Plot", this); + dockWidget->setObjectName(dwt->mohrsCirclePlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_mohrsCirclePlot = new RiuMohrsCirclePlot(dockWidget); + dockWidget->setWidget(m_mohrsCirclePlot); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - resultPlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + mohrsCirclePlotDock = dockWidget; + + dockWidget->hide(); } +#endif { - QDockWidget* dockPanel = new QDockWidget("Relative Permeability Plot", this); - dockPanel->setObjectName("dockRelativePermeabilityPlotPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_relPermPlotPanel = new RiuRelativePermeabilityPlotPanel(dockPanel); - dockPanel->setWidget(m_relPermPlotPanel); + QDockWidget* dockWidget = new RiuDockWidget("Relative Permeability Plot", this); + dockWidget->setObjectName(dwt->relPermPlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_relPermPlotPanel = new RiuRelativePermeabilityPlotPanel(dockWidget); + dockWidget->setWidget(m_relPermPlotPanel); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - relPermPlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + relPermPlotDock = dockWidget; } { - QDockWidget* dockPanel = new QDockWidget("PVT Plot", this); - dockPanel->setObjectName("dockPvtPlotPanel"); - dockPanel->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); - m_pvtPlotPanel = new RiuPvtPlotPanel(dockPanel); - dockPanel->setWidget(m_pvtPlotPanel); + QDockWidget* dockWidget = new RiuDockWidget("PVT Plot", this); + dockWidget->setObjectName(dwt->pvtPlotName()); + dockWidget->setAllowedAreas(Qt::LeftDockWidgetArea | Qt::RightDockWidgetArea | Qt::BottomDockWidgetArea); + m_pvtPlotPanel = new RiuPvtPlotPanel(dockWidget); + dockWidget->setWidget(m_pvtPlotPanel); - addDockWidget(Qt::BottomDockWidgetArea, dockPanel); - pvtPlotDock = dockPanel; + addDockWidget(Qt::BottomDockWidgetArea, dockWidget); + pvtPlotDock = dockWidget; } { - QDockWidget* dockWidget = new QDockWidget("Messages", this); - dockWidget->setObjectName("dockMessages"); + QDockWidget* dockWidget = new RiuDockWidget("Messages", this); + dockWidget->setObjectName(dwt->messagesName()); m_messagePanel = new RiuMessagePanel(dockWidget); dockWidget->setWidget(m_messagePanel); addDockWidget(Qt::BottomDockWidgetArea, dockWidget); dockWidget->hide(); } - setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); + setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); // Tabify docks tabifyDockWidget(pvtPlotDock, relPermPlotDock); +#ifdef USE_ODB_API + tabifyDockWidget(relPermPlotDock, mohrsCirclePlotDock); + tabifyDockWidget(mohrsCirclePlotDock, resultPlotDock); +#else tabifyDockWidget(relPermPlotDock, resultPlotDock); +#endif + + QList dockWidgets = findChildren(); + for (QDockWidget* dock : dockWidgets) + { + connect(dock->toggleViewAction(), SIGNAL(triggered()), SLOT(slotDockWidgetToggleViewActionTriggered())); + } } //-------------------------------------------------------------------------------------------------- @@ -701,6 +774,10 @@ void RiuMainWindow::slotRefreshFileActions() CVF_ASSERT(cmdFeatureMgr); cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")->setEnabled(projectFileExists); + + QStringList commandIdList; + commandIdList << "RicExportCompletionsForVisibleWellPathsFeature"; + cmdFeatureMgr->refreshStates(commandIdList); } @@ -719,7 +796,7 @@ void RiuMainWindow::slotRefreshEditActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotRefreshViewActions() { - bool enabled = true; + bool enabled = RiaApplication::instance()->activeGridView() != nullptr; m_viewFromNorth->setEnabled(enabled); m_viewFromSouth->setEnabled(enabled); m_viewFromEast->setEnabled(enabled); @@ -729,7 +806,13 @@ void RiuMainWindow::slotRefreshViewActions() updateScaleValue(); - caf::CmdFeatureManager::instance()->refreshEnabledState(QStringList() << "RicLinkVisibleViewsFeature" << "RicTileWindowsFeature" << "RicTogglePerspectiveViewFeature"); + QStringList commandIds; + commandIds << "RicLinkVisibleViewsFeature" + << "RicTileWindowsFeature" + << "RicTogglePerspectiveViewFeature" + << "RicViewZoomAllFeature"; + + caf::CmdFeatureManager::instance()->refreshEnabledState(commandIds); } //-------------------------------------------------------------------------------------------------- @@ -737,10 +820,12 @@ void RiuMainWindow::slotRefreshViewActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::refreshAnimationActions() { - caf::FrameAnimationControl* animationControl = NULL; - if (RiaApplication::instance()->activeReservoirView() && RiaApplication::instance()->activeReservoirView()->viewer()) + caf::FrameAnimationControl* animationControl = nullptr; + Rim3dView * activeView = RiaApplication::instance()->activeReservoirView(); + + if (activeView && activeView->viewer()) { - animationControl = RiaApplication::instance()->activeReservoirView()->viewer()->animationControl(); + animationControl = activeView->viewer()->animationControl(); } m_animationToolBar->connectAnimationControl(animationControl); @@ -750,37 +835,22 @@ void RiuMainWindow::refreshAnimationActions() int currentTimeStepIndex = 0; bool enableAnimControls = false; - RimView * activeView = RiaApplication::instance()->activeReservoirView(); if (activeView && activeView->viewer() && activeView->viewer()->frameCount()) { enableAnimControls = true; - RimEclipseView * activeRiv = dynamic_cast(activeView); - - if (activeRiv) + + if ( activeView->isTimeStepDependentDataVisible() ) { - if (activeRiv->currentGridCellResults()) - { - if (activeRiv->isTimeStepDependentDataVisible()) - { - timeStepStrings = activeRiv->eclipseCase()->timeStepStrings(); - } - else - { - timeStepStrings.push_back(tr("Static Property")); - } - } + timeStepStrings = activeView->ownerCase()->timeStepStrings(); } else { - RimGeoMechView * activeGmv = dynamic_cast(activeView); - if (activeGmv) + RimEclipseView * activeRiv = dynamic_cast(activeView); + if ( activeRiv && activeRiv->currentGridCellResults() ) { - if (activeGmv->isTimeStepDependentDataVisible()) - { - timeStepStrings = activeGmv->geoMechCase()->timeStepStrings(); - } + timeStepStrings.push_back(tr("Static Property")); } } @@ -863,7 +933,7 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -871,7 +941,7 @@ QMdiSubWindow* RiuMainWindow::findMdiSubWindow(QWidget* viewer) //-------------------------------------------------------------------------------------------------- QList RiuMainWindow::subWindowList(QMdiArea::WindowOrder order) { - return m_mdiArea->subWindowList(order); + return m_mdiArea->subWindowList(order); } //-------------------------------------------------------------------------------------------------- @@ -898,6 +968,14 @@ RiuPvtPlotPanel* RiuMainWindow::pvtPlotPanel() return m_pvtPlotPanel; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMohrsCirclePlot* RiuMainWindow::mohrsCirclePlot() +{ + return m_mohrsCirclePlot; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1077,7 +1155,7 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) // Find the activated 3D view - RimView* activatedView = NULL; + Rim3dView* activatedView = nullptr; std::vector allCases; proj->allCases(allCases); @@ -1085,14 +1163,14 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) for (size_t caseIdx = 0; caseIdx < allCases.size(); ++caseIdx) { RimCase* reservoirCase = allCases[caseIdx]; - if (reservoirCase == NULL) continue; + if (reservoirCase == nullptr) continue; - std::vector views = reservoirCase->views(); + std::vector views = reservoirCase->views(); size_t viewIdx; for (viewIdx = 0; viewIdx < views.size(); viewIdx++) { - RimView* riv = views[viewIdx]; + Rim3dView* riv = views[viewIdx]; if (riv && riv->viewer() && @@ -1106,7 +1184,7 @@ void RiuMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) } { - RimView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); + Rim3dView* previousActiveReservoirView = RiaApplication::instance()->activeReservoirView(); RiaApplication::instance()->setActiveReservoirView(activatedView); if (previousActiveReservoirView != activatedView) @@ -1204,7 +1282,7 @@ void RiuMainWindow::setActiveViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotFramerateChanged(double frameRate) { - if (RiaApplication::instance()->activeReservoirView() != NULL) + if (RiaApplication::instance()->activeReservoirView() != nullptr) { RiaApplication::instance()->activeReservoirView()->maximumFrameRate.setValueWithFieldChanged(frameRate); } @@ -1227,18 +1305,20 @@ void RiuMainWindow::slotBuildWindowActions() m_windowMenu->addAction(m_newPropertyView); m_windowMenu->addSeparator(); - QList dockWidgets = findChildren(); + auto dwt = RiuDockWidgetTools::instance(); - int i = 0; - foreach (QDockWidget* dock, dockWidgets) - { - if (dock) - { - if (i == 4) m_windowMenu->addSeparator(); - m_windowMenu->addAction(dock->toggleViewAction()); - ++i; - } - } + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->projectTreeName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->propertyEditorName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->messagesName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->processMonitorName())); + + m_windowMenu->addSeparator(); + + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->resultInfoName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->resultPlotName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->relPermPlotName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->pvtPlotName())); + m_windowMenu->addAction(dwt->toggleActionForWidget(this, dwt->mohrsCirclePlotName())); m_windowMenu->addSeparator(); QAction* cascadeWindowsAction = new QAction("Cascade Windows", this); @@ -1260,15 +1340,18 @@ void RiuMainWindow::selectedObjectsChanged() std::vector uiItems; m_projectTreeView->selectedUiItems(uiItems); - caf::PdmObjectHandle* firstSelectedObject = NULL; + caf::PdmObjectHandle* firstSelectedObject = nullptr; if (uiItems.size() == 1) { firstSelectedObject = dynamic_cast(uiItems[0]); } + + updateUiFieldsFromActiveResult(firstSelectedObject); + m_pdmUiPropertyView->showProperties(firstSelectedObject); - if (uiItems.size() == 1) + if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection) { // Find the reservoir view or the Plot that the selected item is within @@ -1281,7 +1364,7 @@ void RiuMainWindow::selectedObjectsChanged() if (!firstSelectedObject) return; // First check if we are within a RimView - RimView* selectedReservoirView = dynamic_cast(firstSelectedObject); + Rim3dView* selectedReservoirView = dynamic_cast(firstSelectedObject); if (!selectedReservoirView) { firstSelectedObject->firstAncestorOrThisOfType(selectedReservoirView); @@ -1360,42 +1443,6 @@ void RiuMainWindow::hideAllDockWindows() } } - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -/*void RiuMainWindow::slotOpenMultipleCases() -{ -#if 1 - QAction* action = caf::CmdFeatureManager::instance()->action("RicCreateGridCaseGroupFeature"); - CVF_ASSERT(action); - - action->trigger(); - -#else // Code to fast generate a test project - RiaApplication* app = RiaApplication::instance(); - - QStringList gridFileNames; - - if (1) - { - gridFileNames += RiaDefines::mockModelBasicWithResults(); - gridFileNames += RiaDefines::mockModelBasicWithResults(); - gridFileNames += RiaDefines::mockModelBasicWithResults(); - } - else - { - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID"; - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID"; - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID"; - gridFileNames += "d:/Models/Statoil/MultipleRealisations/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID"; - } - - app->addEclipseCases(gridFileNames); -#endif - -} -*/ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1428,8 +1475,9 @@ void RiuMainWindow::slotDrawStyleChanged(QAction* activatedAction) void RiuMainWindow::slotToggleHideGridCellsAction(bool hideGridCells) { if (!RiaApplication::instance()->activeReservoirView()) return; - - RiaApplication::instance()->activeReservoirView()->showGridCells(!hideGridCells); + + RimGridView* rigv = RiaApplication::instance()->activeGridView(); + if (rigv) rigv->showGridCells(!hideGridCells); } @@ -1438,10 +1486,21 @@ void RiuMainWindow::slotToggleHideGridCellsAction(bool hideGridCells) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) { - RimEclipseView* activeRiv = dynamic_cast(RiaApplication::instance()->activeReservoirView()); + Rim3dView* activeView = RiaApplication::instance()->activeReservoirView(); + + RimEclipseView* activeRiv = dynamic_cast(activeView); + if (!activeRiv) + { + Rim2dIntersectionView* isectView = dynamic_cast(activeView); + if (isectView) + { + isectView->intersection()->firstAncestorOrThisOfType(activeRiv); + } + } + if (!activeRiv) return; - activeRiv->faultCollection->showFaultLabel.setValueWithFieldChanged(showLabels); + activeRiv->faultCollection()->showFaultLabel.setValueWithFieldChanged(showLabels); refreshDrawStyleActions(); } @@ -1451,14 +1510,15 @@ void RiuMainWindow::slotToggleFaultLabelsAction(bool showLabels) //-------------------------------------------------------------------------------------------------- void RiuMainWindow::refreshDrawStyleActions() { - RimView* view = RiaApplication::instance()->activeReservoirView(); - bool enable = view != NULL; + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); + bool is3DView = view != nullptr; + bool isGridView = RiaApplication::instance()->activeGridView() != nullptr; - m_drawStyleLinesAction->setEnabled(enable); - m_drawStyleLinesSolidAction->setEnabled(enable); - m_drawStyleSurfOnlyAction->setEnabled(enable); - m_drawStyleFaultLinesSolidAction->setEnabled(enable); - m_disableLightingAction->setEnabled(enable); + m_drawStyleLinesAction->setEnabled(is3DView); + m_drawStyleLinesSolidAction->setEnabled(is3DView); + m_drawStyleSurfOnlyAction->setEnabled(is3DView); + m_drawStyleFaultLinesSolidAction->setEnabled(is3DView); + m_disableLightingAction->setEnabled(is3DView); bool lightingDisabledInView = view ? view->isLightingDisabled() : false; @@ -1466,31 +1526,45 @@ void RiuMainWindow::refreshDrawStyleActions() m_disableLightingAction->setChecked(lightingDisabledInView); m_disableLightingAction->blockSignals(false); - if (enable) + m_drawStyleHideGridCellsAction->setEnabled(isGridView); + if (isGridView) { - m_drawStyleHideGridCellsAction->setEnabled(true); m_drawStyleHideGridCellsAction->blockSignals(true); m_drawStyleHideGridCellsAction->setChecked(!view->isGridVisualizationMode()); m_drawStyleHideGridCellsAction->blockSignals(false); } RimEclipseView* eclView = dynamic_cast(view); - enable = enable && eclView; - m_toggleFaultsLabelAction->setEnabled(enable); - m_showWellCellsAction->setEnabled(enable); + bool hasEclipseView = eclView != nullptr; + m_showWellCellsAction->setEnabled(hasEclipseView); - if (enable) + if (hasEclipseView) { - m_toggleFaultsLabelAction->blockSignals(true); - m_toggleFaultsLabelAction->setChecked(eclView->faultCollection()->showFaultLabel()); - m_toggleFaultsLabelAction->blockSignals(false); - m_showWellCellsAction->blockSignals(true); eclView->wellCollection()->updateStateForVisibilityCheckboxes(); m_showWellCellsAction->setChecked(eclView->wellCollection()->showWellCells()); m_showWellCellsAction->blockSignals(false); } + + if (!eclView) + { + Rim2dIntersectionView * intView = dynamic_cast(view); + if (intView) + { + intView->intersection()->firstAncestorOrThisOfType(eclView); + } + } + + m_toggleFaultsLabelAction->setEnabled(eclView != nullptr); + + if (eclView ) + { + m_toggleFaultsLabelAction->blockSignals(true); + m_toggleFaultsLabelAction->setChecked(eclView->faultCollection()->showFaultLabel()); + m_toggleFaultsLabelAction->blockSignals(false); + } + } @@ -1499,7 +1573,7 @@ void RiuMainWindow::refreshDrawStyleActions() //-------------------------------------------------------------------------------------------------- void RiuMainWindow::slotDisableLightingAction(bool disable) { - RimView* view = RiaApplication::instance()->activeReservoirView(); + Rim3dView* view = RiaApplication::instance()->activeReservoirView(); if (view) { view->disableLighting(disable); @@ -1541,6 +1615,8 @@ void RiuMainWindow::showDockPanel(const QString &dockPanelName) if (dock && dock->objectName() == dockPanelName) { dock->show(); + dock->raise(); + return; } } @@ -1549,17 +1625,43 @@ void RiuMainWindow::showDockPanel(const QString &dockPanelName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainWindow::showProcessMonitorDockPanel() +void RiuMainWindow::updateUiFieldsFromActiveResult(caf::PdmObjectHandle* objectToUpdate) { - showDockPanel(DOCK_PANEL_NAME_PROCESS_MONITOR); + RimEclipseResultDefinition* resultDefinition = nullptr; + resultDefinition = dynamic_cast(objectToUpdate); + if (resultDefinition) + { + resultDefinition->updateUiFieldsFromActiveResult(); + } + + RimEclipsePropertyFilter* eclPropFilter = nullptr; + eclPropFilter = dynamic_cast(objectToUpdate); + if (eclPropFilter) + { + eclPropFilter->updateUiFieldsFromActiveResult(); + } + + RimEclipseFaultColors* eclFaultColors = nullptr; + eclFaultColors = dynamic_cast(objectToUpdate); + if (eclFaultColors) + { + eclFaultColors->updateUiFieldsFromActiveResult(); + } + + RimCellEdgeColors* cellEdgeColors = nullptr; + cellEdgeColors = dynamic_cast(objectToUpdate); + if (cellEdgeColors) + { + cellEdgeColors->updateUiFieldsFromActiveResult(); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainWindow::selectAsCurrentItem(const caf::PdmObject* object) +void RiuMainWindow::showProcessMonitorDockPanel() { - m_projectTreeView->selectAsCurrentItem(object); + showDockPanel(RiuDockWidgetTools::instance()->processMonitorName()); } //-------------------------------------------------------------------------------------------------- @@ -1642,9 +1744,7 @@ void RiuMainWindow::slotCreateCommandObject() void RiuMainWindow::slotShowRegressionTestDialog() { RiaRegressionTest regTestConfig; - - RiaApplication* app = RiaApplication::instance(); - caf::PdmSettings::readFieldsFromApplicationStore(®TestConfig); + regTestConfig.readSettingsFromApplicationStore(); caf::PdmUiPropertyViewDialog regressionTestDialog(this, ®TestConfig, "Regression Test", ""); regressionTestDialog.resize(QSize(600, 300)); @@ -1652,17 +1752,9 @@ void RiuMainWindow::slotShowRegressionTestDialog() if (regressionTestDialog.exec() == QDialog::Accepted) { // Write preferences using QSettings and apply them to the application - caf::PdmSettings::writeFieldsToApplicationStore(®TestConfig); - - QString currentApplicationPath = QDir::currentPath(); - - QDir::setCurrent(regTestConfig.applicationWorkingFolder); - - QStringList testFilter = regTestConfig.testFilter().split(";", QString::SkipEmptyParts); - - app->executeRegressionTests(regTestConfig.regressionTestFolder, &testFilter); + regTestConfig.writeSettingsToApplicationStore(); - QDir::setCurrent(currentApplicationPath); + RiaRegressionTestRunner::instance()->executeRegressionTests(); } } diff --git a/ApplicationCode/UserInterface/RiuMainWindow.h b/ApplicationCode/UserInterface/RiuMainWindow.h index 0d1c6f1df1..f53ea53321 100644 --- a/ApplicationCode/UserInterface/RiuMainWindow.h +++ b/ApplicationCode/UserInterface/RiuMainWindow.h @@ -23,6 +23,7 @@ #include "RiuMainWindowBase.h" #include "cafPdmUiDragDropInterface.h" +#include "cafPdmObjectHandle.h" #include #include @@ -45,6 +46,7 @@ class RiuResultQwtPlot; class RiuViewer; class RiuRelativePermeabilityPlotPanel; class RiuPvtPlotPanel; +class RiuMohrsCirclePlot; struct RimMdiWindowGeometry; @@ -76,7 +78,7 @@ class RiuMainWindow : public RiuMainWindowBase static RiuMainWindow* instance(); - virtual QString mainWindowName() { return "RiuMainWindow"; } + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); void cleanupGuiCaseClose(); @@ -91,12 +93,10 @@ class RiuMainWindow : public RiuMainWindowBase void refreshAnimationActions(); void updateScaleValue(); - caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} RiuProcessMonitor* processMonitor(); void hideAllDockWindows(); - void selectAsCurrentItem(const caf::PdmObject* object); void selectedCases(std::vector& cases); @@ -106,16 +106,17 @@ class RiuMainWindow : public RiuMainWindowBase void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); - RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer); + RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override; void tileWindows(); bool isAnyMdiSubWindowVisible(); QMdiSubWindow* findMdiSubWindow(QWidget* viewer); - QList subWindowList(QMdiArea::WindowOrder order); + QList subWindowList(QMdiArea::WindowOrder order); RiuResultQwtPlot* resultPlot(); RiuRelativePermeabilityPlotPanel* relativePermeabilityPlotPanel(); RiuPvtPlotPanel* pvtPlotPanel(); + RiuMohrsCirclePlot* mohrsCirclePlot(); RiuMessagePanel* messagePanel(); void showProcessMonitorDockPanel(); @@ -133,6 +134,8 @@ class RiuMainWindow : public RiuMainWindowBase void showDockPanel(const QString& dockPanelName); + void updateUiFieldsFromActiveResult(caf::PdmObjectHandle* objectToUpdate); + private: static RiuMainWindow* sm_mainWindowInstance; @@ -172,6 +175,7 @@ class RiuMainWindow : public RiuMainWindowBase QPointer m_messagePanel; RiuResultQwtPlot* m_resultQwtPlot; + RiuMohrsCirclePlot* m_mohrsCirclePlot; RiuRelativePermeabilityPlotPanel* m_relPermPlotPanel; RiuPvtPlotPanel* m_pvtPlotPanel; @@ -241,7 +245,6 @@ private slots: public: void setPdmRoot(caf::PdmObject* pdmRoot); private: - caf::PdmUiTreeView* m_projectTreeView; std::unique_ptr m_dragDropInterface; diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp index 0c09d6e193..93e4ac482b 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.cpp +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.cpp @@ -20,12 +20,20 @@ #include "RiaVersionInfo.h" +#include "RiuDockWidgetTools.h" + +#include "cafPdmObject.h" +#include "cafPdmUiTreeView.h" + #include +#include //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- RiuMainWindowBase::RiuMainWindowBase() + : m_projectTreeView(nullptr) + , m_allowActiveViewChangeFromSelection(true) { setDockNestingEnabled(true); } @@ -96,3 +104,42 @@ QString RiuMainWindowBase::registryFolderName() QString regFolder = QString("%1/%2").arg(versionName).arg(mainWindowName()); return regFolder; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange) +{ + m_allowActiveViewChangeFromSelection = allowActiveViewChange; + m_projectTreeView->selectAsCurrentItem(object); + m_allowActiveViewChangeFromSelection = true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) +{ + m_projectTreeView->setExpanded(uiItem, expanded); +} + +//-------------------------------------------------------------------------------------------------- +/// +/// +//-------------------------------------------------------------------------------------------------- +void RiuMainWindowBase::slotDockWidgetToggleViewActionTriggered() +{ + if (!sender()) return; + + auto dockWidget = dynamic_cast(sender()->parent()); + if (dockWidget) + { + if (dockWidget->isVisible()) + { + // Raise the dock widget to make it visible if the widget is part of a tab widget + dockWidget->raise(); + } + + RiuDockWidgetTools::instance()->setDockWidgetVisibility(dockWidget->objectName(), dockWidget->isVisible()); + } +} diff --git a/ApplicationCode/UserInterface/RiuMainWindowBase.h b/ApplicationCode/UserInterface/RiuMainWindowBase.h index 2bb580509e..bef70f453a 100644 --- a/ApplicationCode/UserInterface/RiuMainWindowBase.h +++ b/ApplicationCode/UserInterface/RiuMainWindowBase.h @@ -22,6 +22,13 @@ struct RimMdiWindowGeometry; +namespace caf +{ + class PdmObject; + class PdmUiTreeView; + class PdmUiItem; +} + //================================================================================================== /// //================================================================================================== @@ -32,18 +39,32 @@ class RiuMainWindowBase : public QMainWindow public: RiuMainWindowBase(); - virtual QString mainWindowName() = 0; + virtual QString mainWindowName() = 0; - virtual void removeViewer( QWidget* viewer ) = 0; - virtual void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry)= 0; - virtual void setActiveViewer(QWidget* subWindow) = 0; + virtual void removeViewer( QWidget* viewer ) = 0; + virtual void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry)= 0; + virtual void setActiveViewer(QWidget* subWindow) = 0; virtual RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) = 0; - void loadWinGeoAndDockToolBarLayout(); - void saveWinGeoAndDockToolBarLayout(); - void showWindow(); + void loadWinGeoAndDockToolBarLayout(); + void saveWinGeoAndDockToolBarLayout(); + void showWindow(); + + caf::PdmUiTreeView* projectTreeView() { return m_projectTreeView;} + void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + + void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + +protected slots: + void slotDockWidgetToggleViewActionTriggered(); + +protected: + caf::PdmUiTreeView* m_projectTreeView; + bool m_allowActiveViewChangeFromSelection; // To be used in selectedObjectsChanged() to control + // whether to select the corresponding active view or not + private: - QString registryFolderName(); + QString registryFolderName(); }; diff --git a/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp b/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp index fc20f0fa30..fdc16117eb 100644 --- a/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp +++ b/ApplicationCode/UserInterface/RiuMdiSubWindow.cpp @@ -21,10 +21,10 @@ #include "RiaApplication.h" #include "RimSummaryPlot.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimWellLogPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiuMainWindow.h" #include "RiuSummaryQwtPlot.h" #include "RiuViewer.h" diff --git a/ApplicationCode/UserInterface/RiuMdiSubWindow.h b/ApplicationCode/UserInterface/RiuMdiSubWindow.h index ed043f0e9f..2c21d535d8 100644 --- a/ApplicationCode/UserInterface/RiuMdiSubWindow.h +++ b/ApplicationCode/UserInterface/RiuMdiSubWindow.h @@ -25,7 +25,7 @@ class RiuMdiSubWindow : public QMdiSubWindow { public: - RiuMdiSubWindow(QWidget* parent = 0, Qt::WindowFlags flags = 0); + RiuMdiSubWindow(QWidget* parent = nullptr, Qt::WindowFlags flags = nullptr); ~RiuMdiSubWindow(); diff --git a/ApplicationCode/UserInterface/RiuMessagePanel.cpp b/ApplicationCode/UserInterface/RiuMessagePanel.cpp index 78971e9a64..c8f0ce3968 100644 --- a/ApplicationCode/UserInterface/RiuMessagePanel.cpp +++ b/ApplicationCode/UserInterface/RiuMessagePanel.cpp @@ -18,6 +18,8 @@ #include "RiuMessagePanel.h" +#include "RiaRegressionTestRunner.h" + #include #include #include @@ -71,12 +73,15 @@ void RiuMessagePanel::addMessage(RILogLevel messageLevel, const QString& msg) m_textEdit->moveCursor(QTextCursor::End); m_textEdit->ensureCursorVisible(); - if (messageLevel == RI_LL_ERROR || messageLevel == RI_LL_WARNING) + if (!RiaRegressionTestRunner::instance()->isRunningRegressionTests()) { - QDockWidget* parentDockWidget = dynamic_cast(this->parent()); - if (parentDockWidget && !parentDockWidget->isVisible()) + if (messageLevel == RI_LL_ERROR || messageLevel == RI_LL_WARNING) { - parentDockWidget->toggleViewAction()->trigger(); + QDockWidget* parentDockWidget = dynamic_cast(this->parent()); + if (parentDockWidget && !parentDockWidget->isVisible()) + { + parentDockWidget->toggleViewAction()->trigger(); + } } } } diff --git a/ApplicationCode/UserInterface/RiuMessagePanel.h b/ApplicationCode/UserInterface/RiuMessagePanel.h index 133f1c295f..7cda43dff8 100644 --- a/ApplicationCode/UserInterface/RiuMessagePanel.h +++ b/ApplicationCode/UserInterface/RiuMessagePanel.h @@ -40,7 +40,7 @@ class RiuMessagePanel : public QWidget explicit RiuMessagePanel(QDockWidget* parent); void addMessage(RILogLevel messageLevel, const QString& msg); - virtual QSize sizeHint () const; + virtual QSize sizeHint () const; private slots: void slotShowContextMenu(const QPoint& pos); diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp new file mode 100644 index 0000000000..d2908d7ef7 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.cpp @@ -0,0 +1,695 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuMohrsCirclePlot.h" + +#include "RiaColorTables.h" + +#include "RiuSelectionManager.h" +#include "RiuSummaryQwtPlot.h" + +#include "RigFemPart.h" +#include "RigFemPartCollection.h" +#include "RigFemPartGrid.h" +#include "RigFemPartResultsCollection.h" +#include "RigFemResultPosEnum.h" +#include "RigGeoMechCaseData.h" + +#include "RimGeoMechCase.h" +#include "RimGeoMechCellColors.h" +#include "RimGeoMechResultDefinition.h" +#include "RimGeoMechView.h" + +#include "cvfAssert.h" + +#include +#include +#include +#include + +#include "qwt_legend.h" +#include "qwt_plot_curve.h" +#include "qwt_plot_layout.h" +#include "qwt_plot_rescaler.h" +#include "qwt_plot_shapeitem.h" + +#include + +//================================================================================================== +/// +/// \class RiuMohrsCirclePlot +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMohrsCirclePlot::RiuMohrsCirclePlot(QWidget* parent) + : QwtPlot(parent) + , m_sourceGeoMechViewOfLastPlot(nullptr) + , m_scheduleUpdateAxisScaleTimer(nullptr) +{ + RiuSummaryQwtPlot::setCommonPlotBehaviour(this); + + enableAxis(QwtPlot::xBottom, true); + enableAxis(QwtPlot::yLeft, true); + enableAxis(QwtPlot::xTop, false); + enableAxis(QwtPlot::yRight, false); + + setAxisTitle(QwtPlot::xBottom, "Effective Normal Stress"); + setAxisTitle(QwtPlot::yLeft, "Shear Stress"); + + // The legend will be deleted in the destructor of the plot or when + // another legend is inserted. + QwtLegend* legend = new QwtLegend(this); + this->insertLegend(legend, BottomLegend); + + // this->setTitle(QString("SE")); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuMohrsCirclePlot::~RiuMohrsCirclePlot() +{ + deletePlotItems(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::appendSelection(const RiuSelectionItem* selectionItem) +{ + if (this->isVisible()) + { + m_sourceGeoMechViewOfLastPlot = nullptr; + + const RiuGeoMechSelectionItem* geoMechSelectionItem = dynamic_cast(selectionItem); + if (geoMechSelectionItem) + { + RimGeoMechView* geoMechView = geoMechSelectionItem->m_view; + CVF_ASSERT(geoMechView); + + const size_t gridIndex = geoMechSelectionItem->m_gridIndex; + const size_t cellIndex = geoMechSelectionItem->m_cellIndex; + const cvf::Color3f color = geoMechSelectionItem->m_color; + + queryData(geoMechView, gridIndex, cellIndex, cvf::Color3ub(color)); + updatePlot(); + + m_sourceGeoMechViewOfLastPlot = geoMechView; + } + } + else + { + this->clearPlot(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::clearPlot() +{ + deletePlotItems(); + + m_sourceGeoMechViewOfLastPlot = nullptr; + + this->replot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updateOnTimeStepChanged(Rim3dView* changedView) +{ + if (!this->isVisible()) + { + return; + } + + // Don't update the plot if the view that changed time step is different from the view that was the source of the current plot + RimGeoMechView* geoMechView = dynamic_cast(changedView); + if (!geoMechView || geoMechView != m_sourceGeoMechViewOfLastPlot) + { + return; + } + + std::vector mohrsCiclesInfosCopy = m_mohrsCiclesInfos; + deletePlotItems(); + + for (const MohrsCirclesInfo& mohrInfo : mohrsCiclesInfosCopy) + { + queryData(mohrInfo.view, mohrInfo.gridIndex, mohrInfo.elmIndex, mohrInfo.color); + } + + updatePlot(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuMohrsCirclePlot::sizeHint() const +{ + return QSize(100, 100); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QSize RiuMohrsCirclePlot::minimumSizeHint() const +{ + return QSize(0, 0); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo) +{ + const cvf::Vec3f& principals = mohrsCirclesInfo.principals; + + std::array, 3> mohrsCircles; + + mohrsCircles[0].first = (principals[0] - principals[2]) / 2.0; + mohrsCircles[0].second = (principals[0] + principals[2]) / 2.0; + + mohrsCircles[1].first = (principals[1] - principals[2]) / 2.0; + mohrsCircles[1].second = (principals[1] + principals[2]) / 2.0; + + mohrsCircles[2].first = (principals[0] - principals[1]) / 2.0; + mohrsCircles[2].second = (principals[0] + principals[1]) / 2.0; + + for (size_t i = 0; i < 3; i++) + { + QwtPlotShapeItem* plotItem = new QwtPlotShapeItem("Circle"); + + QPainterPath* circleDrawing = new QPainterPath(); + QPointF center(mohrsCircles[i].second, 0); + circleDrawing->addEllipse(center, mohrsCircles[i].first, mohrsCircles[i].first); + + plotItem->setPen(QColor(mohrsCirclesInfo.color.r(), mohrsCirclesInfo.color.g(), mohrsCirclesInfo.color.b())); + plotItem->setShape(*circleDrawing); + plotItem->setRenderHint(QwtPlotItem::RenderAntialiased, true); + + if (i == 0) + { + QString textBuilder; + textBuilder.append(QString("FOS: %1, ").arg(QString::number(mohrsCirclesInfo.factorOfSafety, 'f', 2))); + + textBuilder.append(QString("Element Id: %1, ijk[%2, %3, %4],") + .arg(mohrsCirclesInfo.elmIndex) + .arg(mohrsCirclesInfo.i) + .arg(mohrsCirclesInfo.j) + .arg(mohrsCirclesInfo.k)); + + textBuilder.append(QString("σ1: %1, ").arg(principals[0])); + textBuilder.append(QString("σ2: %1, ").arg(principals[1])); + textBuilder.append(QString("σ3: %1").arg(principals[2])); + + plotItem->setTitle(textBuilder); + plotItem->setItemAttribute(QwtPlotItem::Legend); + } + + plotItem->attach(this); + + m_circlePlotItems.push_back(plotItem); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deleteCircles() +{ + for (size_t i = 0; i < m_circlePlotItems.size(); i++) + { + m_circlePlotItems[i]->detach(); + delete m_circlePlotItems[i]; + } + + m_circlePlotItems.clear(); + + for (size_t i = 0; i < m_transparentCurves.size(); i++) + { + m_transparentCurves[i]->detach(); + delete m_transparentCurves[i]; + } + + m_transparentCurves.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view) +{ + if (!view) return; + + double cohesion = view->geoMechCase()->cohesion(); + double frictionAngle = view->geoMechCase()->frictionAngleDeg(); + + if (cohesion == HUGE_VAL || frictionAngle == HUGE_VAL || frictionAngle >= 90) + { + return; + } + + double xVals[2]; + double yVals[2]; + + double tanFrictionAngle = cvf::Math::abs(cvf::Math::tan(cvf::Math::toRadians(frictionAngle))); + + if (tanFrictionAngle == 0 || tanFrictionAngle == HUGE_VAL) + { + return; + } + + double x = cohesion / tanFrictionAngle; + + xVals[0] = -x; + xVals[1] = principals[0]; + + yVals[0] = 0; + yVals[1] = (cohesion / x) * (x + principals[0]); + + // If envelope for the view already exists, check if a "larger" envelope should be created + if (m_envolopePlotItems.find(view) != m_envolopePlotItems.end()) + { + if (yVals[1] <= m_envolopePlotItems[view]->maxYValue()) + { + return; + } + else + { + m_envolopePlotItems[view]->detach(); + delete m_envolopePlotItems[view]; + m_envolopePlotItems.erase(view); + } + } + + QwtPlotCurve* qwtCurve = new QwtPlotCurve(); + + qwtCurve->setSamples(xVals, yVals, 2); + + qwtCurve->setStyle(QwtPlotCurve::Lines); + qwtCurve->setRenderHint(QwtPlotItem::RenderAntialiased, true); + + const QPen curvePen(envelopeColor(view)); + qwtCurve->setPen(curvePen); + + qwtCurve->setTitle(QString("Envelope for %1, (S0: %2, Φ: %3)") + .arg(view->geoMechCase()->caseUserDescription) + .arg(cohesion) + .arg(frictionAngle)); + + qwtCurve->attach(this); + + m_envolopePlotItems[view] = qwtCurve; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deleteEnvelopes() +{ + for (const std::pair& envelope : m_envolopePlotItems) + { + envelope.second->detach(); + delete envelope.second; + } + + m_envolopePlotItems.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color) +{ + CVF_ASSERT(geoMechView); + m_sourceGeoMechViewOfLastPlot = geoMechView; + + RigFemPart* femPart = geoMechView->femParts()->part(gridIndex); + if (femPart->elementType(elmIndex) != HEX8P) return; + + int frameIdx = geoMechView->currentTimeStep(); + RigFemPartResultsCollection* resultCollection = geoMechView->geoMechCase()->geoMechData()->femPartResults(); + RigFemResultAddress address(RigFemResultPosEnum::RIG_ELEMENT_NODAL, "SE", ""); + + // TODO: All tensors are calculated every time this function is called. FIX + std::vector vertexTensors = resultCollection->tensors(address, 0, frameIdx); + if (vertexTensors.empty()) + { + return; + } + + // Calculate average tensor in element + caf::Ten3f tensorSumOfElmNodes = vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, 0)]; + for (int i = 1; i < 8; i++) + { + tensorSumOfElmNodes = tensorSumOfElmNodes + vertexTensors[femPart->elementNodeResultIdx((int)elmIndex, i)]; + } + caf::Ten3f elmTensor = tensorSumOfElmNodes * (1.0 / 8.0); + + cvf::Vec3f principals = elmTensor.calculatePrincipals(nullptr); + + if (!isValidPrincipals(principals)) + { + return; + } + + double cohesion = geoMechView->geoMechCase()->cohesion(); + double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg(); + + size_t i, j, k; + femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k); + + MohrsCirclesInfo mohrsCircle( + principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color); + + addMohrsCirclesInfo(mohrsCircle); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updatePlot() +{ + setAxesScaleAndReplot(); + // Update axis scale is called one more time because the legend which is added on a later stage may disrupt the canvas + scheduleUpdateAxisScale(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo) +{ + m_mohrsCiclesInfos.push_back(mohrsCircleInfo); + + addEnvelopeCurve(mohrsCircleInfo.principals, mohrsCircleInfo.view); + addMohrCircles(mohrsCircleInfo); + updateTransparentCurvesOnPrincipals(); +} + +//-------------------------------------------------------------------------------------------------- +/// Add a transparent curve to make tooltip available on principals crossing the x-axis +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::updateTransparentCurvesOnPrincipals() +{ + for (size_t i = 0; i < m_transparentCurves.size(); i++) + { + m_transparentCurves[i]->detach(); + delete m_transparentCurves[i]; + } + + m_transparentCurves.clear(); + + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) + { + QwtPlotCurve* transparentCurve = new QwtPlotCurve(); + + QVector qVectorPoints; + + qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[0], 0)); + qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[1], 0)); + qVectorPoints.push_back(QPointF(mohrCircleInfo.principals[2], 0)); + + transparentCurve->setSamples(qVectorPoints); + transparentCurve->setYAxis(QwtPlot::yLeft); + transparentCurve->setStyle(QwtPlotCurve::NoCurve); + transparentCurve->setLegendAttribute(QwtPlotCurve::LegendNoAttribute); + + transparentCurve->attach(this); + m_transparentCurves.push_back(transparentCurve); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiuMohrsCirclePlot::largestCircleRadiusInPlot() const +{ + double currentLargestDiameter = -HUGE_VAL; + + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) + { + if (mohrCircleInfo.principals[0] > currentLargestDiameter) + { + currentLargestDiameter = mohrCircleInfo.principals[0] - mohrCircleInfo.principals[2]; + } + } + + return currentLargestDiameter / 2; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiuMohrsCirclePlot::smallestPrincipal() const +{ + double currentSmallestPrincipal = HUGE_VAL; + + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) + { + if (mohrCircleInfo.principals[2] < currentSmallestPrincipal) + { + currentSmallestPrincipal = mohrCircleInfo.principals[2]; + } + } + + return currentSmallestPrincipal; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RiuMohrsCirclePlot::largestPrincipal() const +{ + double currentLargestPrincipal = -HUGE_VAL; + + for (const MohrsCirclesInfo& mohrCircleInfo : m_mohrsCiclesInfos) + { + if (mohrCircleInfo.principals[0] > currentLargestPrincipal) + { + currentLargestPrincipal = mohrCircleInfo.principals[0]; + } + } + + return currentLargestPrincipal; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuMohrsCirclePlot::isValidPrincipals(const cvf::Vec3f& principals) +{ + float p1 = principals[0]; + float p2 = principals[1]; + float p3 = principals[2]; + + // Inf + if (p1 == HUGE_VAL || p2 == HUGE_VAL || p3 == HUGE_VAL) + { + return false; + } + + // Nan + if ((p1 != p1) || (p2 != p2) || p3 != p3) + { + return false; + } + + // Principal rules: + if ((p1 < p2) || (p2 < p3)) + { + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +float RiuMohrsCirclePlot::calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion) +{ + if (cvf::Math::cos(frictionAngle) == 0) + { + return std::nan(""); + } + + float se1 = principals[0]; + float se3 = principals[2]; + + float tanFricAng = cvf::Math::tan(cvf::Math::toRadians(frictionAngle)); + float cohPrTanFricAngle = 1.0f * cohesion / tanFricAng; + + float dsm = RigFemPartResultsCollection::dsm(se1, se3, tanFricAng, cohPrTanFricAngle); + + return 1.0f / dsm; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QColor RiuMohrsCirclePlot::envelopeColor(RimGeoMechView* view) +{ + if (m_envolopeColors.find(view) == m_envolopeColors.end()) + { + cvf::Color3ub cvfColor = RiaColorTables::summaryCurveDefaultPaletteColors().cycledColor3ub(m_envolopeColors.size()); + + QColor color(cvfColor.r(), cvfColor.g(), cvfColor.b()); + + m_envolopeColors[view] = color; + } + + return m_envolopeColors[view]; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::deletePlotItems() +{ + m_mohrsCiclesInfos.clear(); + + deleteCircles(); + deleteEnvelopes(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::scheduleUpdateAxisScale() +{ + if (!m_scheduleUpdateAxisScaleTimer) + { + m_scheduleUpdateAxisScaleTimer = new QTimer(this); + connect(m_scheduleUpdateAxisScaleTimer, SIGNAL(timeout()), this, SLOT(setAxesScaleAndReplot())); + } + + if (!m_scheduleUpdateAxisScaleTimer->isActive()) + { + m_scheduleUpdateAxisScaleTimer->setSingleShot(true); + m_scheduleUpdateAxisScaleTimer->start(100); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::resizeEvent(QResizeEvent* e) +{ + setAxesScaleAndReplot(); + + // Update axis scale is called one more time because setAxesScaleAndReplot does not work the first + // time if the user does a very quick resizing of the window + scheduleUpdateAxisScale(); + QwtPlot::resizeEvent(e); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::idealAxesEndPoints(double* xMin, double* xMax, double* yMax) const +{ + *xMin = HUGE_VAL; + *xMax = -HUGE_VAL; + *yMax = -HUGE_VAL; + + double maxYEnvelope = -HUGE_VAL; + for (const std::pair& envelope : m_envolopePlotItems) + { + double tempMax = envelope.second->maxYValue(); + if (tempMax > maxYEnvelope) + { + maxYEnvelope = tempMax; + } + } + + *yMax = std::max(maxYEnvelope, 1.2 * largestCircleRadiusInPlot()); + + double minXEvelope = HUGE_VAL; + for (const std::pair& envelope : m_envolopePlotItems) + { + double tempMin = envelope.second->minXValue(); + if (tempMin < minXEvelope) + { + minXEvelope = tempMin; + } + } + + if (minXEvelope < 0) + { + *xMin = minXEvelope; + } + else + { + *xMin = 1.1 * smallestPrincipal(); + } + + *xMax = 1.1 * largestPrincipal(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuMohrsCirclePlot::setAxesScaleAndReplot() +{ + // yMin is always 0 + double xMin, xMax, yMax; + idealAxesEndPoints(&xMin, &xMax, &yMax); + + if (xMax == -HUGE_VAL || xMin == HUGE_VAL || yMax == -HUGE_VAL) + { + return; + } + + int canvasHeight = this->canvas()->height(); + int canvasWidth = this->canvas()->width(); + + const double minPlotWidth = xMax - xMin; + const double minPlotHeight = yMax; + + double xMaxDisplayed = xMax; + double yMaxDisplayed = yMax; + + double canvasWidthOverHeightRatio = (1.0 * canvasWidth) / (1.0 * canvasHeight); + + // widthToKeepAspectRatio increases when canvas height is increased + double widthToKeepAspectRatio = minPlotHeight * canvasWidthOverHeightRatio; + // heightToKeepAspectRatio increases when canvas width is increased + double heightToKeepAspectRatio = minPlotWidth / canvasWidthOverHeightRatio; + + if (widthToKeepAspectRatio > minPlotWidth) + { + xMaxDisplayed = widthToKeepAspectRatio + xMin; + } + else if (heightToKeepAspectRatio > minPlotHeight) + { + yMaxDisplayed = heightToKeepAspectRatio; + } + + this->setAxisScale(QwtPlot::yLeft, 0, yMaxDisplayed); + this->setAxisScale(QwtPlot::xBottom, xMin, xMaxDisplayed); + + this->replot(); +} diff --git a/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h new file mode 100644 index 0000000000..01f62c2b16 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuMohrsCirclePlot.h @@ -0,0 +1,135 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018 Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "qwt_plot.h" +#include "qwt_plot_curve.h" +#include "qwt_plot_item.h" + +#include "cafTensor3.h" + +#include "cvfColor3.h" + +#include + +class QTimer; +class QWidget; +class Rim3dView; +class RimGeoMechView; +class RiuSelectionItem; + +//================================================================================================== +// +// +// +//================================================================================================== +class RiuMohrsCirclePlot : public QwtPlot +{ + Q_OBJECT + +public: + RiuMohrsCirclePlot(QWidget* parent); + ~RiuMohrsCirclePlot(); + + void appendSelection(const RiuSelectionItem* selectionItem); + void clearPlot(); + + void updateOnTimeStepChanged(Rim3dView* changedView); + +private: + struct MohrsCirclesInfo + { + MohrsCirclesInfo(cvf::Vec3f principals, + size_t gridIndex, + size_t elmIndex, + size_t i, + size_t j, + size_t k, + RimGeoMechView* view, + double factorOfSafety, + cvf::Color3ub color) + : principals(principals) + , gridIndex(gridIndex) + , elmIndex(elmIndex) + , i(i) + , j(j) + , k(k) + , view(view) + , factorOfSafety(factorOfSafety) + , color(color) {} + + cvf::Vec3f principals; + size_t gridIndex; + size_t elmIndex; + size_t i, j, k; + RimGeoMechView* view; + double factorOfSafety; + cvf::Color3ub color; + }; + +private: + virtual QSize sizeHint() const override; + virtual QSize minimumSizeHint() const override; + virtual void resizeEvent(QResizeEvent* e) override; + + void idealAxesEndPoints(double* xMin, double* xMax, double* yMax) const; + + void addMohrCircles(const MohrsCirclesInfo& mohrsCirclesInfo); + void deleteCircles(); + + void addEnvelopeCurve(const cvf::Vec3f& principals, RimGeoMechView* view); + void deleteEnvelopes(); + + void queryData(RimGeoMechView* geoMechView, size_t gridIndex, size_t elmIndex, const cvf::Color3ub& color); + void updatePlot(); + + void addMohrsCirclesInfo(const MohrsCirclesInfo& mohrsCircleInfo); + + void updateTransparentCurvesOnPrincipals(); + + double largestCircleRadiusInPlot() const; + double smallestPrincipal() const; + double largestPrincipal() const; + + static bool isValidPrincipals(const cvf::Vec3f& principals); + + static float calculateFOS(const cvf::Vec3f& principals, double frictionAngle, double cohesion); + + QColor envelopeColor(RimGeoMechView* view); + + void deletePlotItems(); + + void scheduleUpdateAxisScale(); + +private slots: + void setAxesScaleAndReplot(); + +private: + std::vector m_circlePlotItems; + std::vector m_transparentCurves; + + std::map m_envolopePlotItems; + std::map m_envolopeColors; + + std::vector m_mohrsCiclesInfos; + + RimGeoMechView* m_sourceGeoMechViewOfLastPlot; + + QTimer* m_scheduleUpdateAxisScaleTimer; +}; diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp index e073c9df75..6611ceb0b7 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.cpp @@ -32,7 +32,9 @@ class FileListModel: public QStringListModel { public: - explicit FileListModel(QObject *parent = 0) : m_isItemsEditable(false), QStringListModel(parent) + explicit FileListModel(QObject* parent = nullptr) + : QStringListModel(parent) + , m_isItemsEditable(false) { } diff --git a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h index 4030c384eb..7ad1275cc2 100644 --- a/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h +++ b/ApplicationCode/UserInterface/RiuMultiCaseImportDialog.h @@ -37,7 +37,7 @@ class RiuMultiCaseImportDialog: public QDialog Q_OBJECT public: - explicit RiuMultiCaseImportDialog(QWidget *parent = 0); + explicit RiuMultiCaseImportDialog(QWidget *parent = nullptr); virtual ~RiuMultiCaseImportDialog(); QStringList eclipseCaseFileNames() const; diff --git a/ApplicationCode/UserInterface/RiuNightchartsWidget.h b/ApplicationCode/UserInterface/RiuNightchartsWidget.h index 378f0177d5..0a0ba6df5a 100644 --- a/ApplicationCode/UserInterface/RiuNightchartsWidget.h +++ b/ApplicationCode/UserInterface/RiuNightchartsWidget.h @@ -19,7 +19,7 @@ #pragma once -#include "nightcharts/nightcharts.h" +#include "nightcharts.h" #include "cafPdmPointer.h" @@ -31,7 +31,7 @@ class RiuNightchartsWidget : public QWidget { Q_OBJECT public: - explicit RiuNightchartsWidget(QWidget* parent = 0); + explicit RiuNightchartsWidget(QWidget* parent = nullptr); void addItem(const QString& name, const QColor& color, float value); void setType(Nightcharts::type type); diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp similarity index 85% rename from ApplicationCode/UserInterface/RiuMainPlotWindow.cpp rename to ApplicationCode/UserInterface/RiuPlotMainWindow.cpp index 190e2b0868..c80bfe031c 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.cpp +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.cpp @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "RiaApplication.h" #include "RiaBaseDefs.h" @@ -51,18 +51,11 @@ #include #include -//================================================================================================== -/// -/// \class RiuMainPlotWindow -/// -/// Contains our main window -/// -//================================================================================================== //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(NULL), m_blockSlotSubWindowActivated(false) +RiuPlotMainWindow::RiuPlotMainWindow() : m_activePlotViewWindow(nullptr), m_windowMenu(nullptr), m_blockSlotSubWindowActivated(false) { m_mdiArea = new QMdiArea; m_mdiArea->setOption(QMdiArea::DontMaximizeSubWindowOnActivation, true); @@ -86,15 +79,15 @@ RiuMainPlotWindow::RiuMainPlotWindow() : m_activePlotViewWindow(nullptr), m_wind //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QString RiuMainPlotWindow::mainWindowName() +QString RiuPlotMainWindow::mainWindowName() { - return "RiuMainPlotWindow"; + return "RiuPlotMainWindow"; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::initializeGuiNewProjectLoaded() +void RiuPlotMainWindow::initializeGuiNewProjectLoaded() { setPdmRoot(RiaApplication::instance()->project()); restoreTreeViewState(); @@ -110,13 +103,13 @@ void RiuMainPlotWindow::initializeGuiNewProjectLoaded() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::cleanupGuiBeforeProjectClose() +void RiuPlotMainWindow::cleanupGuiBeforeProjectClose() { - setPdmRoot(NULL); + setPdmRoot(nullptr); if (m_pdmUiPropertyView) { - m_pdmUiPropertyView->showProperties(NULL); + m_pdmUiPropertyView->showProperties(nullptr); } cleanUpTemporaryWidgets(); @@ -129,7 +122,7 @@ void RiuMainPlotWindow::cleanupGuiBeforeProjectClose() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::cleanUpTemporaryWidgets() +void RiuPlotMainWindow::cleanUpTemporaryWidgets() { for (QWidget* w : m_temporaryWidgets) { @@ -143,7 +136,7 @@ void RiuMainPlotWindow::cleanUpTemporaryWidgets() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::closeEvent(QCloseEvent* event) +void RiuPlotMainWindow::closeEvent(QCloseEvent* event) { RiaApplication* app = RiaApplication::instance(); @@ -158,7 +151,7 @@ void RiuMainPlotWindow::closeEvent(QCloseEvent* event) return; } - saveWinGeoAndDockToolBarLayout(); + app->saveWinGeoAndDockToolBarLayout(); if (!app->tryCloseMainWindow()) return; @@ -169,7 +162,7 @@ void RiuMainPlotWindow::closeEvent(QCloseEvent* event) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::createMenus() +void RiuPlotMainWindow::createMenus() { caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance(); @@ -184,22 +177,38 @@ void RiuMainPlotWindow::createMenus() fileMenu->addSeparator(); QMenu* importMenu = fileMenu->addMenu("&Import"); - importMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); - importMenu->addSeparator(); + + QMenu* importEclipseMenu = importMenu->addMenu(QIcon(":/Case48x48.png"), "Eclipse Cases"); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportEclipseCasesFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicImportInputEclipseCaseFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFeature")); + importEclipseMenu->addAction(cmdFeatureMgr->action("RicCreateGridCaseGroupFromFilesFeature")); + #ifdef USE_ODB_API - importMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); importMenu->addSeparator(); + QMenu* importGeoMechMenu = importMenu->addMenu(QIcon(":/GeoMechCase48x48.png"), "Geo Mechanical Cases"); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportGeoMechCaseFeature")); + importGeoMechMenu->addAction(cmdFeatureMgr->action("RicImportElementPropertyFeature")); #endif - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + importMenu->addSeparator(); + QMenu* importSummaryMenu = importMenu->addMenu(QIcon(":/SummaryCase48x48.png"), "Summary Cases"); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCaseFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryCasesFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportSummaryGroupFeature")); + importSummaryMenu->addAction(cmdFeatureMgr->action("RicImportEnsembleFeature")); + + importMenu->addSeparator(); + QMenu* importWellMenu = importMenu->addMenu(QIcon(":/Well.png"), "Well Data"); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathsImportSsihubFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellLogsImportFileFeature")); + importWellMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); + + importMenu->addSeparator(); + importMenu->addAction(cmdFeatureMgr->action("RicImportObservedDataInMenuFeature")); importMenu->addAction(cmdFeatureMgr->action("RicImportFormationNamesFeature")); - importMenu->addAction(cmdFeatureMgr->action("RicWellPathFormationsImportFileFeature")); QMenu* exportMenu = fileMenu->addMenu("&Export"); exportMenu->addAction(cmdFeatureMgr->action("RicSnapshotViewToFileFeature")); @@ -247,7 +256,7 @@ void RiuMainPlotWindow::createMenus() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName) +QStringList RiuPlotMainWindow::toolbarCommandIds(const QString& toolbarName) { QStringList commandIds; @@ -285,7 +294,7 @@ QStringList RiuMainPlotWindow::toolbarCommandIds(const QString& toolbarName) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::createToolBars() +void RiuPlotMainWindow::createToolBars() { caf::CmdFeatureManager* cmdFeatureMgr = caf::CmdFeatureManager::instance(); CVF_ASSERT(cmdFeatureMgr); @@ -315,7 +324,7 @@ void RiuMainPlotWindow::createToolBars() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::refreshToolbars() +void RiuPlotMainWindow::refreshToolbars() { QStringList allToolbarCommandNames = toolbarCommandIds(); @@ -325,7 +334,7 @@ void RiuMainPlotWindow::refreshToolbars() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::createDockPanels() +void RiuPlotMainWindow::createDockPanels() { { QDockWidget* dockWidget = new QDockWidget("Plot Project Tree", this); @@ -378,13 +387,19 @@ void RiuMainPlotWindow::createDockPanels() setCorner(Qt::BottomLeftCorner, Qt::LeftDockWidgetArea); setCorner(Qt::BottomRightCorner, Qt::BottomDockWidgetArea); + + QList dockWidgets = findChildren(); + for (QDockWidget* dock : dockWidgets) + { + connect(dock->toggleViewAction(), SIGNAL(triggered()), SLOT(slotDockWidgetToggleViewActionTriggered())); + } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QMdiSubWindow* RiuMainPlotWindow::findMdiSubWindow(QWidget* viewer) +QMdiSubWindow* RiuPlotMainWindow::findMdiSubWindow(QWidget* viewer) { QList subws = m_mdiArea->subWindowList(); int i; @@ -396,13 +411,13 @@ QMdiSubWindow* RiuMainPlotWindow::findMdiSubWindow(QWidget* viewer) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QList RiuMainPlotWindow::subWindowList(QMdiArea::WindowOrder order) +QList RiuPlotMainWindow::subWindowList(QMdiArea::WindowOrder order) { return m_mdiArea->subWindowList(order); } @@ -410,7 +425,7 @@ QList RiuMainPlotWindow::subWindowList(QMdiArea::WindowOrder ord //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::addToTemporaryWidgets(QWidget* widget) +void RiuPlotMainWindow::addToTemporaryWidgets(QWidget* widget) { CVF_ASSERT(widget); @@ -420,7 +435,7 @@ void RiuMainPlotWindow::addToTemporaryWidgets(QWidget* widget) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::updateSummaryPlotToolBar() +void RiuPlotMainWindow::updateSummaryPlotToolBar() { RimSummaryPlot* summaryPlot = dynamic_cast(m_activePlotViewWindow.p()); if (summaryPlot) @@ -442,12 +457,14 @@ void RiuMainPlotWindow::updateSummaryPlotToolBar() m_summaryPlotToolBarEditor->hide(); } + + refreshToolbars(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::removeViewer(QWidget* viewer) +void RiuPlotMainWindow::removeViewer(QWidget* viewer) { m_blockSlotSubWindowActivated = true; m_mdiArea->removeSubWindow(findMdiSubWindow(viewer)); @@ -459,7 +476,7 @@ void RiuMainPlotWindow::removeViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) +void RiuPlotMainWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) { RiuMdiSubWindow* subWin = new RiuMdiSubWindow(m_mdiArea); subWin->setAttribute(Qt::WA_DeleteOnClose); // Make sure the contained widget is destroyed when the MDI window is closed @@ -522,7 +539,7 @@ void RiuMainPlotWindow::addViewer(QWidget* viewer, const RimMdiWindowGeometry& w //-------------------------------------------------------------------------------------------------- /// This method needs to handle memory deallocation !!! //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot) +void RiuPlotMainWindow::setPdmRoot(caf::PdmObject* pdmRoot) { m_projectTreeView->setPdmItem(pdmRoot); // For debug only : m_projectTreeView->treeView()->expandAll(); @@ -532,7 +549,7 @@ void RiuMainPlotWindow::setPdmRoot(caf::PdmObject* pdmRoot) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) +void RiuPlotMainWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) { if (!subWindow) return; @@ -561,7 +578,7 @@ void RiuMainPlotWindow::slotSubWindowActivated(QMdiSubWindow* subWindow) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setActiveViewer(QWidget* viewer) +void RiuPlotMainWindow::setActiveViewer(QWidget* viewer) { m_blockSlotSubWindowActivated = true; @@ -575,30 +592,14 @@ void RiuMainPlotWindow::setActiveViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmUiTreeView* RiuMainPlotWindow::projectTreeView() -{ - return m_projectTreeView; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::slotBuildWindowActions() +void RiuPlotMainWindow::slotBuildWindowActions() { m_windowMenu->clear(); QList dockWidgets = findChildren(); - - int i = 0; - foreach (QDockWidget* dock, dockWidgets) + for (QDockWidget* dock : dockWidgets) { - if (dock) - { - if (i == 4) - m_windowMenu->addSeparator(); - m_windowMenu->addAction(dock->toggleViewAction()); - ++i; - } + m_windowMenu->addAction(dock->toggleViewAction()); } m_windowMenu->addSeparator(); @@ -616,33 +617,33 @@ void RiuMainPlotWindow::slotBuildWindowActions() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::selectedObjectsChanged() +void RiuPlotMainWindow::selectedObjectsChanged() { std::vector uiItems; m_projectTreeView->selectedUiItems(uiItems); - caf::PdmObjectHandle* firstSelectedObject = NULL; + caf::PdmObjectHandle* firstSelectedObject = nullptr; if (uiItems.size() == 1) { firstSelectedObject = dynamic_cast(uiItems[0]); } + m_pdmUiPropertyView->showProperties(firstSelectedObject); - if (uiItems.size() == 1) + if (uiItems.size() == 1 && m_allowActiveViewChangeFromSelection) { // Find the reservoir view or the Plot that the selected item is within if (!firstSelectedObject) { caf::PdmFieldHandle* selectedField = dynamic_cast(uiItems[0]); - if (selectedField) - firstSelectedObject = selectedField->ownerObject(); + if (selectedField) firstSelectedObject = selectedField->ownerObject(); } - if (!firstSelectedObject) - return; + if (!firstSelectedObject) return; + RimViewWindow* selectedWindow = dynamic_cast(firstSelectedObject); if (!selectedWindow) { @@ -676,7 +677,7 @@ void RiuMainPlotWindow::selectedObjectsChanged() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::hideAllDockWindows() +void RiuPlotMainWindow::hideAllDockWindows() { QList dockWidgets = findChildren(); @@ -689,7 +690,7 @@ void RiuMainPlotWindow::hideAllDockWindows() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::restoreTreeViewState() +void RiuPlotMainWindow::restoreTreeViewState() { if (m_projectTreeView) { @@ -710,18 +711,11 @@ void RiuMainPlotWindow::restoreTreeViewState() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::selectAsCurrentItem(caf::PdmObject* object) -{ - m_projectTreeView->selectAsCurrentItem(object); -} //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setDefaultWindowSize() +void RiuPlotMainWindow::setDefaultWindowSize() { resize(1000, 810); } @@ -729,15 +723,7 @@ void RiuMainPlotWindow::setDefaultWindowSize() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::setExpanded(const caf::PdmUiItem* uiItem, bool expanded) -{ - m_projectTreeView->setExpanded(uiItem, expanded); -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::customMenuRequested(const QPoint& pos) +void RiuPlotMainWindow::customMenuRequested(const QPoint& pos) { QMenu menu; @@ -758,7 +744,7 @@ void RiuMainPlotWindow::customMenuRequested(const QPoint& pos) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimMdiWindowGeometry RiuMainPlotWindow::windowGeometryForViewer(QWidget* viewer) +RimMdiWindowGeometry RiuPlotMainWindow::windowGeometryForViewer(QWidget* viewer) { QMdiSubWindow* mdiWindow = findMdiSubWindow(viewer); if (mdiWindow) @@ -772,7 +758,7 @@ RimMdiWindowGeometry RiuMainPlotWindow::windowGeometryForViewer(QWidget* viewer) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuMainPlotWindow::tileWindows() +void RiuPlotMainWindow::tileWindows() { // Based on workaround described here // https://forum.qt.io/topic/50053/qmdiarea-tilesubwindows-always-places-widgets-in-activationhistoryorder-in-subwindowview-mode @@ -792,7 +778,7 @@ void RiuMainPlotWindow::tileWindows() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuMainPlotWindow::isAnyMdiSubWindowVisible() +bool RiuPlotMainWindow::isAnyMdiSubWindowVisible() { return m_mdiArea->subWindowList().size() > 0; } diff --git a/ApplicationCode/UserInterface/RiuMainPlotWindow.h b/ApplicationCode/UserInterface/RiuPlotMainWindow.h similarity index 87% rename from ApplicationCode/UserInterface/RiuMainPlotWindow.h rename to ApplicationCode/UserInterface/RiuPlotMainWindow.h index 214df5ef2c..43aa9d4ada 100644 --- a/ApplicationCode/UserInterface/RiuMainPlotWindow.h +++ b/ApplicationCode/UserInterface/RiuPlotMainWindow.h @@ -48,14 +48,14 @@ namespace caf // // //================================================================================================== -class RiuMainPlotWindow : public RiuMainWindowBase +class RiuPlotMainWindow : public RiuMainWindowBase { Q_OBJECT public: - RiuMainPlotWindow(); + RiuPlotMainWindow(); - virtual QString mainWindowName(); + QString mainWindowName() override; void initializeGuiNewProjectLoaded(); void cleanupGuiBeforeProjectClose(); @@ -65,29 +65,24 @@ class RiuMainPlotWindow : public RiuMainWindowBase void addViewer(QWidget* viewer, const RimMdiWindowGeometry& windowsGeometry) override; void setActiveViewer(QWidget* subWindow) override; - caf::PdmUiTreeView* projectTreeView(); - void hideAllDockWindows(); - void selectAsCurrentItem(caf::PdmObject* object); - void setDefaultWindowSize(); - void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); RimMdiWindowGeometry windowGeometryForViewer(QWidget* viewer) override; void tileWindows(); bool isAnyMdiSubWindowVisible(); QMdiSubWindow* findMdiSubWindow(QWidget* viewer); - QList subWindowList(QMdiArea::WindowOrder order); + QList subWindowList(QMdiArea::WindowOrder order); void addToTemporaryWidgets(QWidget* widget); void updateSummaryPlotToolBar(); protected: - virtual void closeEvent(QCloseEvent* event); + void closeEvent(QCloseEvent* event) override; private: void setPdmRoot(caf::PdmObject* pdmRoot); @@ -121,7 +116,6 @@ private slots: QMenu* m_windowMenu; - caf::PdmUiTreeView* m_projectTreeView; caf::PdmUiToolBarEditor* m_summaryPlotToolBarEditor; std::unique_ptr m_dragDropInterface; diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp new file mode 100644 index 0000000000..cd161b6315 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.cpp @@ -0,0 +1,71 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuPlotMainWindowTools.h" +#include "RiaApplication.h" +#include "RiuPlotMainWindow.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::showPlotMainWindow() +{ + RiaApplication::instance()->getOrCreateAndShowMainPlotWindow(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::setActiveViewer(QWidget* subWindow) +{ + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->setActiveViewer(subWindow); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::setExpanded(const caf::PdmUiItem* uiItem, bool expanded /*= true*/) +{ + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->setExpanded(uiItem, expanded); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange /*= true*/) +{ + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->selectAsCurrentItem(object, allowActiveViewChange); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuPlotMainWindowTools::refreshToolbars() +{ + RiuPlotMainWindow* mpw = RiaApplication::instance()->mainPlotWindow(); + + if (mpw) mpw->updateSummaryPlotToolBar(); +} + + diff --git a/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h new file mode 100644 index 0000000000..6400a6467a --- /dev/null +++ b/ApplicationCode/UserInterface/RiuPlotMainWindowTools.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +class QWidget; + +namespace caf +{ + class PdmUiItem; + class PdmObject; +} + +class RiuPlotMainWindowTools +{ +public: + static void showPlotMainWindow(); + static void setActiveViewer(QWidget* subWindow) ; + static void setExpanded(const caf::PdmUiItem* uiItem, bool expanded = true); + static void selectAsCurrentItem(const caf::PdmObject* object, bool allowActiveViewChange = true); + static void refreshToolbars(); +}; + diff --git a/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp b/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp index 46c1f6d6f3..ca09f25809 100644 --- a/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp +++ b/ApplicationCode/UserInterface/RiuPlotObjectPicker.cpp @@ -19,7 +19,7 @@ #include "RiuPlotObjectPicker.h" #include "RiaApplication.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include @@ -39,7 +39,7 @@ RiuPlotObjectPicker::RiuPlotObjectPicker(QWidget* widget, caf::PdmObject* associ //-------------------------------------------------------------------------------------------------- bool RiuPlotObjectPicker::eventFilter(QObject* watchedObject, QEvent* event) { - RiuMainPlotWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); + RiuPlotMainWindow* mainPlotWindow = RiaApplication::instance()->mainPlotWindow(); if (mainPlotWindow && m_associatedObject.notNull()) { if (event->type() == QEvent::MouseButtonPress) diff --git a/ApplicationCode/UserInterface/RiuProcessMonitor.cpp b/ApplicationCode/UserInterface/RiuProcessMonitor.cpp index 96f49ca269..1254ba7ed4 100644 --- a/ApplicationCode/UserInterface/RiuProcessMonitor.cpp +++ b/ApplicationCode/UserInterface/RiuProcessMonitor.cpp @@ -35,7 +35,7 @@ RiuProcessMonitor::RiuProcessMonitor(QDockWidget* pParent) : QWidget(pParent) { - m_monitoredProcess = NULL; + m_monitoredProcess = nullptr; QLabel* pLabel = new QLabel("Status:", this); pLabel->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); @@ -112,7 +112,7 @@ void RiuProcessMonitor::startMonitorWorkProcess(caf::UiProcess* pProcess) //-------------------------------------------------------------------------------------------------- void RiuProcessMonitor::stopMonitorWorkProcess() { - m_monitoredProcess = NULL; + m_monitoredProcess = nullptr; m_terminatePushButton->setEnabled(false); diff --git a/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp b/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp index 9efd302e85..6ef24b9549 100644 --- a/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp +++ b/ApplicationCode/UserInterface/RiuProjectPropertyView.cpp @@ -92,7 +92,7 @@ RiuProjectAndPropertyView::RiuProjectAndPropertyView(QWidget* parent, Qt::Window //-------------------------------------------------------------------------------------------------- void RiuProjectAndPropertyView::setPdmItem(caf::PdmUiItem* object) { - m_propertyView->showProperties(NULL); + m_propertyView->showProperties(nullptr); m_projectTreeView->setPdmItem(object); } diff --git a/ApplicationCode/UserInterface/RiuProjectPropertyView.h b/ApplicationCode/UserInterface/RiuProjectPropertyView.h index eb2b2ea501..3b58ce40ea 100644 --- a/ApplicationCode/UserInterface/RiuProjectPropertyView.h +++ b/ApplicationCode/UserInterface/RiuProjectPropertyView.h @@ -33,7 +33,7 @@ namespace caf { class RiuProjectAndPropertyView : public QWidget { public: - RiuProjectAndPropertyView(QWidget* parent = 0, Qt::WindowFlags f = 0); + RiuProjectAndPropertyView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); void setPdmItem(caf::PdmUiItem* object); void showProperties(caf::PdmObjectHandle* object); diff --git a/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp b/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp index 4aa3cd5a86..7e7ee5632f 100644 --- a/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp +++ b/ApplicationCode/UserInterface/RiuPropertyViewTabWidget.cpp @@ -77,7 +77,7 @@ RiuPropertyViewTabWidget::~RiuPropertyViewTabWidget() { for (auto w : m_pageWidgets) { - w->showProperties(NULL); + w->showProperties(nullptr); } } diff --git a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp index cc787e7038..d9ca0f26f2 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotPanel.cpp @@ -100,7 +100,7 @@ class RiuPvtQwtPicker : public QwtPicker //-------------------------------------------------------------------------------------------------- RiuPvtPlotWidget::RiuPvtPlotWidget(RiuPvtPlotPanel* parent) : QWidget(parent), - m_trackerPlotMarker(NULL) + m_trackerPlotMarker(nullptr) { m_qwtPlot = new PvtQwtPlot(this); setPlotDefaults(m_qwtPlot); @@ -190,7 +190,7 @@ void RiuPvtPlotWidget::plotCurves(RiaEclipseUnitTools::UnitSystem unitSystem, co m_qwtPlot->detachItems(QwtPlotItem::Rtti_PlotMarker); m_qwtCurveArr.clear(); m_pvtCurveArr.clear(); - m_trackerPlotMarker = NULL; + m_trackerPlotMarker = nullptr; // Construct an auxiliary curve that connects the first point in all the input curves as a visual aid @@ -383,7 +383,7 @@ void RiuPvtPlotWidget::updateTrackerPlotMarkerAndLabelFromPicker() { m_trackerPlotMarker->detach(); delete m_trackerPlotMarker; - m_trackerPlotMarker = NULL; + m_trackerPlotMarker = nullptr; needsReplot = true; } @@ -406,7 +406,7 @@ const QwtPlotCurve* RiuPvtPlotWidget::closestCurveSample(const QPoint& cursorPos if (closestSampleIndex) *closestSampleIndex = -1; - const QwtPlotCurve* closestCurve = NULL; + const QwtPlotCurve* closestCurve = nullptr; double distMin = HUGE_VAL; int closestPointSampleIndex = -1; @@ -437,7 +437,7 @@ const QwtPlotCurve* RiuPvtPlotWidget::closestCurveSample(const QPoint& cursorPos } else { - return NULL; + return nullptr; } } diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp index af275653c7..d0126d8412 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.cpp @@ -28,9 +28,11 @@ #include "RigResultAccessorFactory.h" #include "RigCaseCellResultsData.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimEclipseView.h" #include "RimEclipseResultCase.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "cvfBase.h" //#include "cvfTrace.h" @@ -51,7 +53,7 @@ //-------------------------------------------------------------------------------------------------- RiuPvtPlotUpdater::RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel) : m_targetPlotPanel(targetPlotPanel), - m_sourceEclipseViewOfLastPlot(NULL) + m_sourceEclipseViewOfLastPlot(nullptr) { } @@ -65,11 +67,21 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selecti return; } - m_sourceEclipseViewOfLastPlot = NULL; + m_sourceEclipseViewOfLastPlot = nullptr; bool mustClearPlot = true; - const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(selectionItem); - const RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(const_cast(selectionItem)); + RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr; + + if (!eclipseSelectionItem && !eclipseView) + { + const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast(selectionItem); + if (intersectionSelItem && intersectionSelItem->eclipseSelectionItem()) + { + eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); + eclipseView = eclipseSelectionItem->m_view; + } + } if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView) { @@ -91,7 +103,7 @@ void RiuPvtPlotUpdater::updateOnSelectionChanged(const RiuSelectionItem* selecti //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuPvtPlotUpdater::updateOnTimeStepChanged(RimView* changedView) +void RiuPvtPlotUpdater::updateOnTimeStepChanged(Rim3dView* changedView) { if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible()) { @@ -126,7 +138,7 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView CVF_ASSERT(plotPanel); RimEclipseResultCase* eclipseResultCase = dynamic_cast(eclipseView.eclipseCase()); - RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : NULL; + RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface()) { size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseCaseData, gridIndex, gridLocalCellIndex); @@ -183,7 +195,7 @@ bool RiuPvtPlotUpdater::queryDataAndUpdatePlot(const RimEclipseView& eclipseView QString RiuPvtPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double pvtnum) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr; if (grid && gridLocalCellIndex < grid->cellCount()) { size_t i = 0; diff --git a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h index 5bcf60517d..bcdb18670a 100644 --- a/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuPvtPlotUpdater.h @@ -23,7 +23,7 @@ class RiuSelectionItem; class RiuPvtPlotPanel; -class RimView; +class Rim3dView; class RimEclipseView; class RigEclipseCaseData; @@ -39,7 +39,7 @@ class RiuPvtPlotUpdater RiuPvtPlotUpdater(RiuPvtPlotPanel* targetPlotPanel); void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); - void updateOnTimeStepChanged(RimView* changedView); + void updateOnTimeStepChanged(Rim3dView* changedView); private: static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuPvtPlotPanel* plotPanel); @@ -47,7 +47,7 @@ class RiuPvtPlotUpdater private: QPointer m_targetPlotPanel; - const RimView* m_sourceEclipseViewOfLastPlot; + const Rim3dView* m_sourceEclipseViewOfLastPlot; }; diff --git a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp index 3c83ce3ae8..bb9c108bd4 100644 --- a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp +++ b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.cpp @@ -32,8 +32,8 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal) - : QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal) +RiuQwtCurvePointTracker::RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal, IPlotCurveInfoTextProvider* curveInfoTextProvider) + : QwtPlotPicker(plot->canvas()), m_plot(plot), m_isMainAxisHorizontal(isMainAxisHorizontal), m_curveInfoTextProvider(curveInfoTextProvider) { this->setTrackerMode(QwtPicker::AlwaysOn); m_plotMarker = new QwtPlotMarker; @@ -91,12 +91,15 @@ QwtText RiuQwtCurvePointTracker::trackerText(const QPoint& pos) const QwtPlot::Axis relatedYAxis = QwtPlot::yLeft; QwtPlot::Axis relatedXAxis = QwtPlot::xBottom; + QString curveInfoText; QString mainAxisValueString; QString valueAxisValueString; - QPointF closestPoint = closestCurvePoint(pos, &valueAxisValueString, &mainAxisValueString, &relatedXAxis, &relatedYAxis); + QPointF closestPoint = closestCurvePoint(pos, &curveInfoText, &valueAxisValueString, &mainAxisValueString, &relatedXAxis, &relatedYAxis); if ( !closestPoint.isNull() ) { - QString str = valueAxisValueString; + QString str = !curveInfoText.isEmpty() ? + QString("%1: %2").arg(curveInfoText).arg(valueAxisValueString) : + valueAxisValueString; if ( !mainAxisValueString.isEmpty() ) { @@ -115,7 +118,12 @@ QwtText RiuQwtCurvePointTracker::trackerText(const QPoint& pos) const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition, QString* valueAxisValueString, QString* mainAxisValueString, QwtPlot::Axis* relatedXAxis, QwtPlot::Axis* relatedYAxis) const +QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition, + QString* curveInfoText, + QString* valueAxisValueString, + QString* mainAxisValueString, + QwtPlot::Axis* relatedXAxis, + QwtPlot::Axis* relatedYAxis) const { QPointF samplePoint; @@ -160,6 +168,11 @@ QPointF RiuQwtCurvePointTracker::closestCurvePoint(const QPoint& cursorPosition, else mainAxisSampleVal = samplePoint.y(); + if (curveInfoText && closestCurve && m_curveInfoTextProvider) + { + *curveInfoText = m_curveInfoTextProvider->curveInfoText(closestCurve); + } + if ( dateScaleDraw ) { QDateTime date = dateScaleDraw->toDateTime(mainAxisSampleVal); diff --git a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h index 9142950532..80a4b467f8 100644 --- a/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h +++ b/ApplicationCode/UserInterface/RiuQwtCurvePointTracker.h @@ -23,6 +23,9 @@ #include class QwtPlotMarker; +class QwtPlotCurve; +class IPlotCurveInfoTextProvider; + //-------------------------------------------------------------------------------------------------- /// Class to add mouse over-tracking of curve points with text marker @@ -30,7 +33,7 @@ class QwtPlotMarker; class RiuQwtCurvePointTracker : public QwtPlotPicker { public: - explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal); + explicit RiuQwtCurvePointTracker(QwtPlot* plot, bool isMainAxisHorizontal, IPlotCurveInfoTextProvider* curveInfoTextProvider = nullptr); ~RiuQwtCurvePointTracker(); protected: @@ -39,7 +42,8 @@ class RiuQwtCurvePointTracker : public QwtPlotPicker void removeMarkerOnFocusLeave(); virtual QwtText trackerText(const QPoint& pos) const override; - QPointF closestCurvePoint(const QPoint& cursorPosition, + QPointF closestCurvePoint(const QPoint& cursorPosition, + QString* curveInfoText, QString* valueAxisValueString, QString* mainAxisValueString, QwtPlot::Axis* relatedXAxis, @@ -51,5 +55,14 @@ class RiuQwtCurvePointTracker : public QwtPlotPicker QPointer m_plot; QwtPlotMarker* m_plotMarker; bool m_isMainAxisHorizontal; + IPlotCurveInfoTextProvider* m_curveInfoTextProvider; }; +//-------------------------------------------------------------------------------------------------- +/// Interface for retrieving curve info text +//-------------------------------------------------------------------------------------------------- +class IPlotCurveInfoTextProvider +{ +public: + virtual QString curveInfoText(QwtPlotCurve* curve) = 0; +}; diff --git a/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp b/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp index 899463ebf9..aa7b62cb1e 100644 --- a/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp +++ b/ApplicationCode/UserInterface/RiuRecentFileActionProvider.cpp @@ -19,6 +19,7 @@ #include "RiuRecentFileActionProvider.h" #include "RiaApplication.h" +#include "RiaFilePathTools.h" #include #include @@ -122,7 +123,7 @@ void RiuRecentFileActionProvider::slotOpenRecentFile() QAction* action = qobject_cast(sender()); if (action) { - QString fileName = action->data().toString(); + QString fileName = RiaFilePathTools::toInternalSeparator(action->data().toString()); RiaApplication* app = RiaApplication::instance(); if (RiaApplication::hasValidProjectFileExtension(fileName)) @@ -137,7 +138,7 @@ void RiuRecentFileActionProvider::slotOpenRecentFile() } else { - QMessageBox::warning(NULL, "File open", "Failed to import file located at\n" + fileName); + QMessageBox::warning(nullptr, "File open", "Failed to import file located at\n" + fileName); removeFileName(fileName); } diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp index 49bf3e53ac..2683be34d6 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.cpp @@ -27,9 +27,11 @@ #include "RigResultAccessorFactory.h" #include "RigCaseCellResultsData.h" -#include "RimView.h" +#include "Rim3dView.h" #include "RimEclipseView.h" #include "RimEclipseResultCase.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "cvfBase.h" //#include "cvfTrace.h" @@ -50,7 +52,7 @@ //-------------------------------------------------------------------------------------------------- RiuRelativePermeabilityPlotUpdater::RiuRelativePermeabilityPlotUpdater(RiuRelativePermeabilityPlotPanel* targetPlotPanel) : m_targetPlotPanel(targetPlotPanel), - m_sourceEclipseViewOfLastPlot(NULL) + m_sourceEclipseViewOfLastPlot(nullptr) { } @@ -65,11 +67,21 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged(const RiuSelec return; } - m_sourceEclipseViewOfLastPlot = NULL; + m_sourceEclipseViewOfLastPlot = nullptr; bool mustClearPlot = true; - const RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(selectionItem); - const RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : NULL; + RiuEclipseSelectionItem* eclipseSelectionItem = dynamic_cast(const_cast(selectionItem)); + RimEclipseView* eclipseView = eclipseSelectionItem ? eclipseSelectionItem->m_view.p() : nullptr; + + if (!eclipseSelectionItem && !eclipseView) + { + const Riu2dIntersectionSelectionItem* intersectionSelItem = dynamic_cast(selectionItem); + if (intersectionSelItem && intersectionSelItem->eclipseSelectionItem()) + { + eclipseSelectionItem = intersectionSelItem->eclipseSelectionItem(); + eclipseView = eclipseSelectionItem->m_view; + } + } if (m_targetPlotPanel->isVisible() && eclipseSelectionItem && eclipseView) { @@ -91,7 +103,7 @@ void RiuRelativePermeabilityPlotUpdater::updateOnSelectionChanged(const RiuSelec //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged(RimView* changedView) +void RiuRelativePermeabilityPlotUpdater::updateOnTimeStepChanged(Rim3dView* changedView) { if (!m_targetPlotPanel || !m_targetPlotPanel->isVisible()) { @@ -126,7 +138,7 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse CVF_ASSERT(plotPanel); RimEclipseResultCase* eclipseResultCase = dynamic_cast(eclipseView.eclipseCase()); - RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : NULL; + RigEclipseCaseData* eclipseCaseData = eclipseResultCase ? eclipseResultCase->eclipseCaseData() : nullptr; if (eclipseResultCase && eclipseCaseData && eclipseResultCase->flowDiagSolverInterface()) { size_t activeCellIndex = CellLookupHelper::mapToActiveCellIndex(eclipseCaseData, gridIndex, gridLocalCellIndex); @@ -170,7 +182,7 @@ bool RiuRelativePermeabilityPlotUpdater::queryDataAndUpdatePlot(const RimEclipse QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex, double satnum) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr; if (grid && gridLocalCellIndex < grid->cellCount()) { size_t i = 0; @@ -217,7 +229,7 @@ QString RiuRelativePermeabilityPlotUpdater::constructCellReferenceText(const Rig size_t CellLookupHelper::mapToActiveCellIndex(const RigEclipseCaseData* eclipseCaseData, size_t gridIndex, size_t gridLocalCellIndex) { const size_t gridCount = eclipseCaseData ? eclipseCaseData->gridCount() : 0; - const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : NULL; + const RigGridBase* grid = gridIndex < gridCount ? eclipseCaseData->grid(gridIndex) : nullptr; if (grid && gridLocalCellIndex < grid->cellCount()) { // Note!! diff --git a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h index 5682cbf086..b45a74cae8 100644 --- a/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h +++ b/ApplicationCode/UserInterface/RiuRelativePermeabilityPlotUpdater.h @@ -23,7 +23,7 @@ class RiuSelectionItem; class RiuRelativePermeabilityPlotPanel; -class RimView; +class Rim3dView; class RimEclipseView; class RigEclipseCaseData; @@ -39,7 +39,7 @@ class RiuRelativePermeabilityPlotUpdater RiuRelativePermeabilityPlotUpdater(RiuRelativePermeabilityPlotPanel* targetPlotPanel); void updateOnSelectionChanged(const RiuSelectionItem* selectionItem); - void updateOnTimeStepChanged(RimView* changedView); + void updateOnTimeStepChanged(Rim3dView* changedView); private: static bool queryDataAndUpdatePlot(const RimEclipseView& eclipseView, size_t gridIndex, size_t gridLocalCellIndex, RiuRelativePermeabilityPlotPanel* plotPanel); @@ -47,7 +47,7 @@ class RiuRelativePermeabilityPlotUpdater private: QPointer m_targetPlotPanel; - const RimView* m_sourceEclipseViewOfLastPlot; + const Rim3dView* m_sourceEclipseViewOfLastPlot; }; diff --git a/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp b/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp index ae65202248..bcb625f6d1 100644 --- a/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuResultQwtPlot.cpp @@ -31,7 +31,6 @@ #include "cafCmdFeatureMenuBuilder.h" #include "cvfBase.h" -#include "cvfAssert.h" #include "cvfColor3.h" #include "qwt_date_scale_draw.h" diff --git a/ApplicationCode/UserInterface/RiuResultQwtPlot.h b/ApplicationCode/UserInterface/RiuResultQwtPlot.h index 53e792c4f6..725a1c4a4d 100644 --- a/ApplicationCode/UserInterface/RiuResultQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuResultQwtPlot.h @@ -44,7 +44,7 @@ class RiuResultQwtPlot : public QwtPlot Q_OBJECT public: - explicit RiuResultQwtPlot(QWidget* parent = NULL); + explicit RiuResultQwtPlot(QWidget* parent = nullptr); virtual ~RiuResultQwtPlot(); void addCurve(const RimCase* rimCase, @@ -61,8 +61,8 @@ class RiuResultQwtPlot : public QwtPlot void deleteAllCurves(); protected: - virtual QSize sizeHint() const; - virtual QSize minimumSizeHint() const; + virtual QSize sizeHint() const override; + virtual QSize minimumSizeHint() const override; virtual void contextMenuEvent(QContextMenuEvent *) override; private: diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp index e06e48692e..d957952604 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.cpp @@ -27,15 +27,19 @@ #include "RigResultAccessorFactory.h" #include "RigSimWellData.h" +#include "Rim2dIntersectionView.h" +#include "RimIntersection.h" #include "RimCellEdgeColors.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseFaultColors.h" #include "RimEclipseView.h" #include "RimFormationNames.h" -#include "RimLegendConfig.h" +#include "RimRegularLegendConfig.h" #include "RimReservoirCellResultsStorage.h" +#include "RivIntersectionPartMgr.h" + #include "cafDisplayCoordTransform.h" @@ -57,6 +61,44 @@ RiuResultTextBuilder::RiuResultTextBuilder(RimEclipseView* reservoirView, size_t m_face = cvf::StructGridInterface::NO_FACE; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuResultTextBuilder::RiuResultTextBuilder(RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex) +{ + CVF_ASSERT(reservoirView); + + m_reservoirView = reservoirView; + + m_gridIndex = 0; + m_cellIndex = 0; + + RimEclipseCase* eclipseCase = nullptr; + reservoirView->firstAncestorOrThisOfType(eclipseCase); + if (eclipseCase && eclipseCase->eclipseCaseData()) + { + RigEclipseCaseData* caseData = eclipseCase->eclipseCaseData(); + RigMainGrid* mainGrid = caseData->mainGrid(); + + const RigCell& cell = caseData->mainGrid()->globalCellArray()[reservoirCellIndex]; + + for (size_t i = 0; i < mainGrid->gridCount(); i++) + { + if (mainGrid->gridByIndex(i) == cell.hostGrid()) + { + m_gridIndex = i; + m_cellIndex = cell.gridLocalCellIndex(); + } + } + } + + m_timeStepIndex = timeStepIndex; + + m_nncIndex = cvf::UNDEFINED_SIZE_T; + m_intersectionPoint = cvf::Vec3d::UNDEFINED; + m_face = cvf::StructGridInterface::NO_FACE; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -73,6 +115,14 @@ void RiuResultTextBuilder::setIntersectionPoint(cvf::Vec3d intersectionPoint) m_intersectionPoint = intersectionPoint; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuResultTextBuilder::set2dIntersectionView(Rim2dIntersectionView* intersectionView) +{ + m_2dIntersectionView = intersectionView; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -148,31 +198,59 @@ QString RiuResultTextBuilder::geometrySelectionText(QString itemSeparator) size_t i = 0; size_t j = 0; size_t k = 0; - if (eclipseCase->grid(m_gridIndex)->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) + + const RigGridBase* grid = eclipseCase->grid(m_gridIndex); + if (grid->ijkFromCellIndex(m_cellIndex, &i, &j, &k)) { // Adjust to 1-based Eclipse indexing i++; j++; k++; - cvf::StructGridInterface::FaceEnum faceEnum(m_face); + if (m_face != cvf::StructGridInterface::NO_FACE) + { + cvf::StructGridInterface::FaceEnum faceEnum(m_face); + + QString faceText = faceEnum.text(); - QString faceText = faceEnum.text(); + text += QString("Face : %1").arg(faceText) + itemSeparator; + } - text += QString("Face : %1").arg(faceText) + itemSeparator; - text += QString("Hit grid %1").arg(m_gridIndex) + itemSeparator; + QString gridName = QString::fromStdString(grid->gridName()); + text += QString("Grid : %1 [%2]").arg(gridName).arg(m_gridIndex) + itemSeparator; + text += QString("Cell : [%1, %2, %3]").arg(i).arg(j).arg(k) + itemSeparator; + + size_t globalCellIndex = grid->reservoirCellIndex(m_cellIndex); + text += QString("Global Cell Index : %4").arg(globalCellIndex) + itemSeparator; } } - - cvf::ref transForm = m_reservoirView->displayCoordTransform(); - cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); + if (m_intersectionPoint != cvf::Vec3d::UNDEFINED) + { + cvf::ref transForm = m_reservoirView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->translateToDomainCoord(m_intersectionPoint); - QString formattedText; - formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + QString formattedText; + if (m_2dIntersectionView) + { + formattedText.sprintf("Horizontal length from well start: %.2f", m_intersectionPoint.x()); + text += formattedText + itemSeparator; - text += formattedText; + cvf::Mat4d t = m_2dIntersectionView->flatIntersectionPartMgr()->unflattenTransformMatrix(m_intersectionPoint); + if (!t.isZero()) + { + cvf::Vec3d intPt = m_intersectionPoint.getTransformedPoint(t); + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", intPt.x(), intPt.y(), -intPt.z()); + text += formattedText; + } + } + else + { + formattedText.sprintf("Intersection point : [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + text += formattedText; + } + } } } @@ -715,7 +793,7 @@ QString RiuResultTextBuilder::cellResultText(RimEclipseCellColors* resultColors) QString resultValueText; if (resultColors->hasCategoryResult()) { - RimLegendConfig* legendConfig = resultColors->legendConfig(); + RimRegularLegendConfig* legendConfig = resultColors->legendConfig(); resultValueText += legendConfig->categoryNameFromCategoryValue(scalarValue); } diff --git a/ApplicationCode/UserInterface/RiuResultTextBuilder.h b/ApplicationCode/UserInterface/RiuResultTextBuilder.h index 7f58c8eaad..b7a7ec2467 100644 --- a/ApplicationCode/UserInterface/RiuResultTextBuilder.h +++ b/ApplicationCode/UserInterface/RiuResultTextBuilder.h @@ -26,6 +26,7 @@ class RimEclipseView; class RimEclipseCellColors; +class Rim2dIntersectionView; class QString; class RigEclipseCaseData; @@ -41,9 +42,12 @@ class RiuResultTextBuilder { public: RiuResultTextBuilder(RimEclipseView* reservoirView, size_t gridIndex, size_t cellIndex, size_t timeStepIndex); + RiuResultTextBuilder(RimEclipseView* reservoirView, size_t reservoirCellIndex, size_t timeStepIndex); + void setFace(cvf::StructGridInterface::FaceType face); void setNncIndex(size_t nncIndex); void setIntersectionPoint(cvf::Vec3d intersectionPoint); + void set2dIntersectionView(Rim2dIntersectionView* intersectionView); QString mainResultText(); @@ -69,6 +73,7 @@ class RiuResultTextBuilder private: caf::PdmPointer m_reservoirView; + caf::PdmPointer m_2dIntersectionView; size_t m_gridIndex; size_t m_cellIndex; diff --git a/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp new file mode 100644 index 0000000000..56914e98d7 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.cpp @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuRimQwtPlotCurve.h" +#include "RimPlotCurve.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuRimQwtPlotCurve::RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title /*= QString::null*/) + : RiuLineSegmentQwtPlotCurve(title) + , m_ownerRimCurve(ownerRimCurve) +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimPlotCurve * RiuRimQwtPlotCurve::ownerRimCurve() +{ + return m_ownerRimCurve; +} diff --git a/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h new file mode 100644 index 0000000000..a8cebb632a --- /dev/null +++ b/ApplicationCode/UserInterface/RiuRimQwtPlotCurve.h @@ -0,0 +1,36 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RiuLineSegmentQwtPlotCurve.h" + +#include "cafPdmPointer.h" + +class RimPlotCurve; + +class RiuRimQwtPlotCurve: public RiuLineSegmentQwtPlotCurve +{ +public: + explicit RiuRimQwtPlotCurve(RimPlotCurve* ownerRimCurve, const QString &title = QString::null); + + RimPlotCurve * ownerRimCurve(); + +private: + caf::PdmPointer m_ownerRimCurve; +}; + diff --git a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp index 2e3e0faafd..f081ec8588 100644 --- a/ApplicationCode/UserInterface/RiuRmsNavigation.cpp +++ b/ApplicationCode/UserInterface/RiuRmsNavigation.cpp @@ -59,7 +59,7 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::MidButton) + if (me->button() == Qt::MidButton && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick(me->x(), me->y(), &hic); @@ -185,6 +185,8 @@ bool RiuRmsNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp index aec9a19a0c..513c716578 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.cpp @@ -29,23 +29,26 @@ #include "RigTimeHistoryResultAccessor.h" #include "RiuFemTimeHistoryResultAccessor.h" +#include "Rim2dIntersectionView.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseView.h" #include "RimGeoMechCase.h" #include "RimGeoMechResultDefinition.h" #include "RimGeoMechView.h" +#include "RimIntersection.h" #include "RimProject.h" #include "RiuFemResultTextBuilder.h" #include "RiuMainWindow.h" +#include "RiuMohrsCirclePlot.h" +#include "RiuPvtPlotPanel.h" +#include "RiuPvtPlotUpdater.h" +#include "RiuRelativePermeabilityPlotPanel.h" +#include "RiuRelativePermeabilityPlotUpdater.h" #include "RiuResultQwtPlot.h" #include "RiuResultTextBuilder.h" #include "RiuSelectionManager.h" -#include "RiuRelativePermeabilityPlotPanel.h" -#include "RiuPvtPlotPanel.h" -#include "RiuRelativePermeabilityPlotUpdater.h" -#include "RiuPvtPlotUpdater.h" #include @@ -82,12 +85,15 @@ void RiuSelectionChangedHandler::handleSelectionDeleted() const RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); RiuRelativePermeabilityPlotUpdater* relPermPlotUpdater = RiuMainWindow::instance()->relativePermeabilityPlotPanel()->plotUpdater(); - relPermPlotUpdater->updateOnSelectionChanged(NULL); + relPermPlotUpdater->updateOnSelectionChanged(nullptr); RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); - pvtPlotUpdater->updateOnSelectionChanged(NULL); + pvtPlotUpdater->updateOnSelectionChanged(nullptr); - updateResultInfo(NULL); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->clearPlot(); + + updateResultInfo(nullptr); scheduleUpdateForAllVisibleViews(); } @@ -105,6 +111,9 @@ void RiuSelectionChangedHandler::handleItemAppended(const RiuSelectionItem* item RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnSelectionChanged(item); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->appendSelection(item); + updateResultInfo(item); scheduleUpdateForAllVisibleViews(); @@ -117,6 +126,9 @@ void RiuSelectionChangedHandler::handleSetSelectedItem(const RiuSelectionItem* i { RiuMainWindow::instance()->resultPlot()->deleteAllCurves(); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->clearPlot(); + handleItemAppended(item); } @@ -238,6 +250,21 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuGeoMechSelec } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSelectionChangedHandler::addCurveFromSelectionItem(const Riu2dIntersectionSelectionItem* selectionItem) const +{ + if (selectionItem->eclipseSelectionItem()) + { + addCurveFromSelectionItem(selectionItem->eclipseSelectionItem()); + } + else if (selectionItem->geoMechSelectionItem()) + { + addCurveFromSelectionItem(selectionItem->geoMechSelectionItem()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -255,6 +282,13 @@ void RiuSelectionChangedHandler::addCurveFromSelectionItem(const RiuSelectionIte addCurveFromSelectionItem(geomSelectionItem); } + else if (itemAdded->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT) + { + const Riu2dIntersectionSelectionItem* _2dSelectionItem = static_cast(itemAdded); + + addCurveFromSelectionItem(_2dSelectionItem); + } + } //-------------------------------------------------------------------------------------------------- @@ -265,7 +299,7 @@ void RiuSelectionChangedHandler::scheduleUpdateForAllVisibleViews() const RimProject* proj = RiaApplication::instance()->project(); if (proj) { - std::vector visibleViews; + std::vector visibleViews; proj->allVisibleViews(visibleViews); for (size_t i = 0; i < visibleViews.size(); i++) @@ -283,11 +317,22 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd QString resultInfo; QString pickInfo; - if (itemAdded != NULL) + RiuSelectionItem* selItem = const_cast(itemAdded); + if (selItem != nullptr) { - if (itemAdded->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT) + Rim2dIntersectionView* intersectionView = nullptr; + + if (selItem->type() == RiuSelectionItem::INTERSECTION_SELECTION_OBJECT) + { + const Riu2dIntersectionSelectionItem* wrapperSelItem = dynamic_cast(selItem); + intersectionView = wrapperSelItem->view(); + if (wrapperSelItem && wrapperSelItem->eclipseSelectionItem()) selItem = wrapperSelItem->eclipseSelectionItem(); + else if (wrapperSelItem && wrapperSelItem->geoMechSelectionItem()) selItem = wrapperSelItem->geoMechSelectionItem(); + } + + if (selItem->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT) { - const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast(itemAdded); + const RiuEclipseSelectionItem* eclipseSelectionItem = static_cast(selItem); RimEclipseView* eclipseView = eclipseSelectionItem->m_view.p(); @@ -295,19 +340,21 @@ void RiuSelectionChangedHandler::updateResultInfo(const RiuSelectionItem* itemAd textBuilder.setFace(eclipseSelectionItem->m_face); textBuilder.setNncIndex(eclipseSelectionItem->m_nncIndex); textBuilder.setIntersectionPoint(eclipseSelectionItem->m_localIntersectionPoint); + textBuilder.set2dIntersectionView(intersectionView); resultInfo = textBuilder.mainResultText(); pickInfo = textBuilder.geometrySelectionText(", "); } - else if (itemAdded->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT) + else if (selItem->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT) { - const RiuGeoMechSelectionItem* geomSelectionItem = static_cast(itemAdded); + const RiuGeoMechSelectionItem* geomSelectionItem = static_cast(selItem); RimGeoMechView* geomView = geomSelectionItem->m_view.p(); RiuFemResultTextBuilder textBuilder(geomView, (int)geomSelectionItem->m_gridIndex, (int)geomSelectionItem->m_cellIndex, geomView->currentTimeStep()); textBuilder.setIntersectionPoint(geomSelectionItem->m_localIntersectionPoint); textBuilder.setFace(geomSelectionItem->m_elementFace); + textBuilder.set2dIntersectionView(intersectionView); if (geomSelectionItem->m_hasIntersectionTriangle) textBuilder.setIntersectionTriangle(geomSelectionItem->m_intersectionTriangle); resultInfo = textBuilder.mainResultText(); diff --git a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h index 9d6e4c9865..f9d876e95b 100644 --- a/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h +++ b/ApplicationCode/UserInterface/RiuSelectionChangedHandler.h @@ -22,6 +22,7 @@ class RiuSelectionItem; class RiuEclipseSelectionItem; class RiuGeoMechSelectionItem; +class Riu2dIntersectionSelectionItem; //-------------------------------------------------------------------------------------------------- /// @@ -40,6 +41,7 @@ class RiuSelectionChangedHandler void addCurveFromSelectionItem(const RiuSelectionItem* itemAdded) const; void addCurveFromSelectionItem(const RiuEclipseSelectionItem* selectionItem) const; void addCurveFromSelectionItem(const RiuGeoMechSelectionItem* selectionItem) const; + void addCurveFromSelectionItem(const Riu2dIntersectionSelectionItem* selectionItem) const; void scheduleUpdateForAllVisibleViews() const; void updateResultInfo(const RiuSelectionItem* itemAdded) const; diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.cpp b/ApplicationCode/UserInterface/RiuSelectionManager.cpp index c18555d2a2..87433a276e 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.cpp +++ b/ApplicationCode/UserInterface/RiuSelectionManager.cpp @@ -19,9 +19,11 @@ #include "RiuSelectionManager.h" +#include "RimGridView.h" #include "RimEclipseView.h" #include "RimGeoMechView.h" #include "RimSimWellInView.h" +#include "Rim2dIntersectionView.h" #include "RimWellPath.h" #include "RivSimWellPipeSourceInfo.h" @@ -155,7 +157,13 @@ void RiuSelectionManager::deleteAllItemsFromSelection(int role) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, size_t nncIndex, cvf::Color3f color, cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPoint) +RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, + size_t gridIndex, + size_t cellIndex, + size_t nncIndex, + cvf::Color3f color, + cvf::StructGridInterface::FaceType face, + const cvf::Vec3d& localIntersectionPoint) : m_view(view), m_gridIndex(gridIndex), m_gridLocalCellIndex(cellIndex), @@ -169,42 +177,84 @@ RiuEclipseSelectionItem::RiuEclipseSelectionItem(RimEclipseView* view, size_t gr //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, - size_t gridIndex, - size_t cellIndex, - cvf::Color3f color, - int elementFace, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, + size_t gridIndex, + size_t cellIndex, + cvf::Color3f color, + int elementFace, const cvf::Vec3d& localIntersectionPoint) - : m_view(view), - m_gridIndex(gridIndex), - m_cellIndex(cellIndex), - m_color(color), - m_elementFace(elementFace), - m_localIntersectionPoint(localIntersectionPoint), - m_hasIntersectionTriangle(false) + : m_view(view) + , m_gridIndex(gridIndex) + , m_cellIndex(cellIndex) + , m_color(color) + , m_elementFace(elementFace) + , m_hasIntersectionTriangle(false) + , m_localIntersectionPoint(localIntersectionPoint) { } //-------------------------------------------------------------------------------------------------- -/// +/// //-------------------------------------------------------------------------------------------------- -RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, - size_t gridIndex, - size_t cellIndex, - cvf::Color3f color, - int elementFace, - const cvf::Vec3d& localIntersectionPoint, +RiuGeoMechSelectionItem::RiuGeoMechSelectionItem(RimGeoMechView* view, + size_t gridIndex, + size_t cellIndex, + cvf::Color3f color, + int elementFace, + const cvf::Vec3d& localIntersectionPoint, const std::array& intersectionTriangle) - : m_view(view), - m_gridIndex(gridIndex), - m_cellIndex(cellIndex), - m_color(color), - m_elementFace(elementFace), - m_localIntersectionPoint(localIntersectionPoint), - m_hasIntersectionTriangle(true), - m_intersectionTriangle(intersectionTriangle) + : m_view(view) + , m_gridIndex(gridIndex) + , m_cellIndex(cellIndex) + , m_color(color) + , m_elementFace(elementFace) + , m_hasIntersectionTriangle(true) + , m_intersectionTriangle(intersectionTriangle) + , m_localIntersectionPoint(localIntersectionPoint) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riu2dIntersectionSelectionItem::Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem) +{ + m_view = view; + m_eclipseSelItem = dynamic_cast(selItem); + m_geoMechSelItem = dynamic_cast(selItem); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +Riu2dIntersectionSelectionItem::~Riu2dIntersectionSelectionItem() { + if (m_eclipseSelItem) delete m_eclipseSelItem; + if (m_geoMechSelItem) delete m_geoMechSelItem; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmPointer Riu2dIntersectionSelectionItem::view() const +{ + return m_view; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuEclipseSelectionItem* Riu2dIntersectionSelectionItem::eclipseSelectionItem() const +{ + return m_eclipseSelItem; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuGeoMechSelectionItem* Riu2dIntersectionSelectionItem::geoMechSelectionItem() const +{ + return m_geoMechSelItem; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSelectionManager.h b/ApplicationCode/UserInterface/RiuSelectionManager.h index 9b2798db7a..fa19b98b7c 100644 --- a/ApplicationCode/UserInterface/RiuSelectionManager.h +++ b/ApplicationCode/UserInterface/RiuSelectionManager.h @@ -32,9 +32,11 @@ // #include "RivWellPathSourceInfo.h" // #include "RivWellPipeSourceInfo.h" +class RimGridView; class RimEclipseView; class RimGeoMechView; class RimSimWellInView; +class Rim2dIntersectionView; class RimWellPath; class RiuSelectionChangedHandler; class RiuSelectionItem; @@ -109,7 +111,8 @@ class RiuSelectionItem GEOMECH_SELECTION_OBJECT, WELLPATH_SELECTION_OBJECT, SIMWELL_SELECTION_OBJECT, - GENERAL_SELECTION_OBJECT + GENERAL_SELECTION_OBJECT, + INTERSECTION_SELECTION_OBJECT }; public: @@ -128,8 +131,13 @@ class RiuSelectionItem class RiuEclipseSelectionItem : public RiuSelectionItem { public: - explicit RiuEclipseSelectionItem(RimEclipseView* view, size_t gridIndex, size_t cellIndex, size_t nncIndex, - cvf::Color3f color, cvf::StructGridInterface::FaceType face, const cvf::Vec3d& localIntersectionPoint); + explicit RiuEclipseSelectionItem(RimEclipseView* view, + size_t gridIndex, + size_t cellIndex, + size_t nncIndex, + cvf::Color3f color, + cvf::StructGridInterface::FaceType face, + const cvf::Vec3d& localIntersectionPoint); virtual ~RiuEclipseSelectionItem() {}; @@ -190,6 +198,35 @@ class RiuGeoMechSelectionItem : public RiuSelectionItem }; +//================================================================================================== +// +// +// +//================================================================================================== +class Riu2dIntersectionSelectionItem : public RiuSelectionItem +{ +public: + explicit Riu2dIntersectionSelectionItem(Rim2dIntersectionView* view, RiuSelectionItem *selItem); + + virtual ~Riu2dIntersectionSelectionItem(); + + virtual RiuSelectionType type() const + { + return INTERSECTION_SELECTION_OBJECT; + } + +public: + caf::PdmPointer view() const; + RiuEclipseSelectionItem* eclipseSelectionItem() const; + RiuGeoMechSelectionItem* geoMechSelectionItem() const; + +private: + caf::PdmPointer m_view; + RiuEclipseSelectionItem* m_eclipseSelItem; + RiuGeoMechSelectionItem* m_geoMechSelItem; +}; + + //================================================================================================== // // @@ -199,7 +236,7 @@ class RiuWellPathSelectionItem : public RiuSelectionItem { public: explicit RiuWellPathSelectionItem(const RivWellPathSourceInfo* wellPathSourceInfo, - const cvf::Vec3d& currentPickPositionInDomainCoords, + const cvf::Vec3d& pipeCenterLineIntersectionInDomainCoords, double measuredDepth); virtual ~RiuWellPathSelectionItem() {}; diff --git a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h index d00508f152..be82643d9f 100644 --- a/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h +++ b/ApplicationCode/UserInterface/RiuSimpleHistogramWidget.h @@ -30,7 +30,7 @@ class QStringList; class RiuSimpleHistogramWidget : public QWidget { public: - RiuSimpleHistogramWidget( QWidget * parent = 0, Qt::WindowFlags f = 0); + RiuSimpleHistogramWidget( QWidget * parent = nullptr, Qt::WindowFlags f = nullptr); void setHistogramData(double min, double max, const std::vector& histogram); void setPercentiles(double pmin, double pmax); diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp index 5431cc627c..abd0941df9 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.cpp @@ -39,6 +39,8 @@ #include "RiuSummaryVectorDescriptionMap.h" #include "cafPdmUiTreeSelectionEditor.h" +//#include "cafPdmObject.h" +#include "cafPdmPointer.h" #include @@ -147,8 +149,8 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM } }, }) { - CAF_PDM_InitFieldNoDefault(&m_selectedCases, "SummaryCases", "Cases", "", "", ""); - m_selectedCases.uiCapability()->setAutoAddingOptionFromValue(false); + CAF_PDM_InitFieldNoDefault(&m_selectedSources, "SummaryCases", "Cases", "", "", ""); + m_selectedSources.uiCapability()->setAutoAddingOptionFromValue(false); CAF_PDM_InitFieldNoDefault(&m_currentSummaryCategory, "CurrentSummaryCategory", "Current Summary Category", "", "", ""); @@ -217,15 +219,17 @@ RiuSummaryCurveDefSelection::RiuSummaryCurveDefSelection() : m_identifierFieldsM itemTypes.second.back()->pdmField()->uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); } - m_selectedCases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); - m_selectedCases.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); - m_selectedCases.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); + m_selectedSources.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); + m_selectedSources.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); m_selectedSummaryCategories.uiCapability()->setUiEditorTypeName(caf::PdmUiTreeSelectionEditor::uiEditorTypeName()); m_selectedSummaryCategories.uiCapability()->setUiLabelPosition(caf::PdmUiItemInfo::HIDDEN); m_currentSummaryCategory.uiCapability()->setUiHidden(true); m_multiSelectionMode = false; + m_hideEnsembles = false; + m_hideSummaryCases = false; } //-------------------------------------------------------------------------------------------------- @@ -245,36 +249,97 @@ RiuSummaryCurveDefSelection::~RiuSummaryCurveDefSelection() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuSummaryCurveDefSelection::selectedCurveDefinitions() const +std::vector RiuSummaryCurveDefSelection::allCurveDefinitionsFromSelection() const { - std::vector caseAndAddressVector; + std::vector curveDefVector; { - std::set caseAndAddressPairs; + std::set curveDefinitions; std::set selectedAddressesFromUi = buildAddressListFromSelections(); - for (RimSummaryCase* currCase : selectedSummaryCases()) + for (SummarySource* currSource : selectedSummarySources()) { - if (currCase && currCase->summaryReader()) + std::vector sourceCases; + RimSummaryCaseCollection* ensemble = dynamic_cast(currSource); + + // Build case list + if (ensemble) + { + auto sumCases = ensemble->allSummaryCases(); + sourceCases.insert(sourceCases.end(), sumCases.begin(), sumCases.end()); + } + else { - RifSummaryReaderInterface* reader = currCase->summaryReader(); + RimSummaryCase* sourceCase = dynamic_cast(currSource); + if (sourceCase) + { + sourceCases.push_back(sourceCase); + } + } - const std::vector& readerAddresses = reader->allResultAddresses(); - for (const auto& readerAddress : readerAddresses) + for (const auto& currCase : sourceCases) + { + if (currCase && currCase->summaryReader()) { - if (selectedAddressesFromUi.count(readerAddress) > 0) + RifSummaryReaderInterface* reader = currCase->summaryReader(); + + const std::vector& readerAddresses = reader->allResultAddresses(); + for (const auto& readerAddress : readerAddresses) { - caseAndAddressPairs.insert(RiaSummaryCurveDefinition(currCase, readerAddress)); + if (selectedAddressesFromUi.count(readerAddress) > 0) + { + curveDefinitions.insert(RiaSummaryCurveDefinition(currCase, readerAddress, ensemble)); + } } } } } - std::copy(caseAndAddressPairs.begin(), caseAndAddressPairs.end(), std::back_inserter(caseAndAddressVector)); + std::copy(curveDefinitions.begin(), curveDefinitions.end(), std::back_inserter(curveDefVector)); + } + + return curveDefVector; +} + +//-------------------------------------------------------------------------------------------------- +/// One CurveDefinition pr ensemble curve set +//-------------------------------------------------------------------------------------------------- +std::vector RiuSummaryCurveDefSelection::selection() const +{ + std::vector curveDefSelection; + std::set selectedAddressesFromUi = buildAddressListFromSelections(); + for (SummarySource* currSource : selectedSummarySources()) + { + RimSummaryCaseCollection* ensemble = dynamic_cast(currSource); + RimSummaryCase* sourceCase = dynamic_cast(currSource); + if (ensemble) + { + std::set addressUnion = ensemble->calculateUnionOfSummaryAddresses(); + for ( const auto& addr : selectedAddressesFromUi) + { + if (addressUnion.count(addr)) + { + curveDefSelection.push_back(RiaSummaryCurveDefinition(nullptr, addr, ensemble)); + } + } + } + else + { + if (!(sourceCase && sourceCase->summaryReader())) continue; + + const std::vector& readerAddresses = sourceCase->summaryReader()->allResultAddresses(); + for ( const auto& addr : readerAddresses) + { + if (selectedAddressesFromUi.count(addr)) + { + curveDefSelection.push_back(RiaSummaryCurveDefinition(sourceCase, addr, nullptr)); + } + } + } } - return caseAndAddressVector; + return curveDefSelection; } //-------------------------------------------------------------------------------------------------- @@ -285,6 +350,22 @@ void RiuSummaryCurveDefSelection::setMultiSelectionMode(bool multiSelectionMode) m_multiSelectionMode = multiSelectionMode; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::hideEnsembles(bool hide) +{ + m_hideEnsembles = hide; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelection::hideSummaryCases(bool hide) +{ + m_hideSummaryCases = hide; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -296,7 +377,7 @@ void RiuSummaryCurveDefSelection::setFieldChangedHandler(const std::function& defaultCases) { RimProject* proj = RiaApplication::instance()->project(); auto allSumCases = proj->allSummaryCases(); @@ -304,10 +385,16 @@ void RiuSummaryCurveDefSelection::setDefaultSelection() { RifEclipseSummaryAddress defaultAddress = RifEclipseSummaryAddress::fieldVarAddress("FOPT"); - RiaSummaryCurveDefinition curveDef(allSumCases[0], defaultAddress); + std::vector selectTheseCases = defaultCases; + if (selectTheseCases.empty()) selectTheseCases.push_back(allSumCases[0]); + std::vector curveDefs; - curveDefs.push_back(curveDef); - + for(RimSummaryCase* c : selectTheseCases) + { + RiaSummaryCurveDefinition curveDef(c, defaultAddress); + curveDefs.push_back(curveDef); + } + setSelectedCurveDefinitions(curveDefs); } } @@ -319,15 +406,16 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions(const std::vector< { resetAllFields(); - for (const auto& caseAddressPair : curveDefinitions) + for (const auto& curveDef : curveDefinitions) { - RimSummaryCase* summaryCase = caseAddressPair.summaryCase(); - if (!summaryCase) continue; + if (!(curveDef.summaryCase() || curveDef.isEnsembleCurve()) ) continue; - RifEclipseSummaryAddress summaryAddress = caseAddressPair.summaryAddress(); + RimSummaryCase* summaryCase = curveDef.summaryCase(); + + RifEclipseSummaryAddress summaryAddress = curveDef.summaryAddress(); if (summaryAddress.category() == RifEclipseSummaryAddress::SUMMARY_INVALID) { - // If we have an invalid address, set the default adress to Field + // If we have an invalid address, set the default address to Field summaryAddress = RifEclipseSummaryAddress::fieldVarAddress(summaryAddress.quantityName()); } @@ -346,11 +434,12 @@ void RiuSummaryCurveDefSelection::setSelectedCurveDefinitions(const std::vector< } // Select case if not already selected - if (std::find(m_selectedCases.begin(), m_selectedCases.end(), summaryCase) == m_selectedCases.end()) + SummarySource* summSource = curveDef.isEnsembleCurve() ? static_cast(curveDef.ensemble()) : summaryCase; + if (std::find(m_selectedSources.begin(), m_selectedSources.end(), summSource) == m_selectedSources.end()) { if (summaryCase != calculatedSummaryCase()) { - m_selectedCases.push_back(summaryCase); + m_selectedSources.push_back(summSource); } } @@ -415,7 +504,7 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions { QList options; - if (fieldNeedingOptions == &m_selectedCases) + if (fieldNeedingOptions == &m_selectedSources) { RimProject* proj = RiaApplication::instance()->project(); std::vector topLevelCases; @@ -427,36 +516,64 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions RimSummaryCaseMainCollection* sumCaseMainColl = oilField->summaryCaseMainCollection(); if (sumCaseMainColl) { - // Top level cases - for (const auto& sumCase : sumCaseMainColl->topLevelSummaryCases()) + if (!m_hideSummaryCases) { - options.push_back(caf::PdmOptionItemInfo(sumCase->caseName(), sumCase)); + // Top level cases + for (const auto& sumCase : sumCaseMainColl->topLevelSummaryCases()) + { + options.push_back(caf::PdmOptionItemInfo(sumCase->caseName(), sumCase)); + } } - // Grouped cases - for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) + // Ensembles + if (!m_hideEnsembles) { - options.push_back(caf::PdmOptionItemInfo::createHeader(sumCaseColl->name(), true)); - - for (const auto& sumCase : sumCaseColl->allSummaryCases()) + bool ensembleHeaderCreated = false; + for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) { - auto optionItem = caf::PdmOptionItemInfo(sumCase->caseName(), sumCase); + if (!sumCaseColl->isEnsemble()) continue; + + if (!ensembleHeaderCreated) + { + options.push_back(caf::PdmOptionItemInfo::createHeader("Ensembles", true)); + ensembleHeaderCreated = true; + } + + auto optionItem = caf::PdmOptionItemInfo(sumCaseColl->name(), sumCaseColl); optionItem.setLevel(1); options.push_back(optionItem); } } - // Observed data - auto observedDataColl = oilField->observedDataCollection(); - if (observedDataColl->allObservedData().size() > 0) + if (!m_hideSummaryCases) { - options.push_back(caf::PdmOptionItemInfo::createHeader("Observed Data", true)); + // Grouped cases + for (const auto& sumCaseColl : sumCaseMainColl->summaryCaseCollections()) + { + if (sumCaseColl->isEnsemble()) continue; + + options.push_back(caf::PdmOptionItemInfo::createHeader(sumCaseColl->name(), true)); - for (const auto& obsData : observedDataColl->allObservedData()) + for (const auto& sumCase : sumCaseColl->allSummaryCases()) + { + auto optionItem = caf::PdmOptionItemInfo(sumCase->caseName(), sumCase); + optionItem.setLevel(1); + options.push_back(optionItem); + } + } + + // Observed data + auto observedDataColl = oilField->observedDataCollection(); + if (observedDataColl->allObservedData().size() > 0) { - auto optionItem = caf::PdmOptionItemInfo(obsData->caseName(), obsData); - optionItem.setLevel(1); - options.push_back(optionItem); + options.push_back(caf::PdmOptionItemInfo::createHeader("Observed Data", true)); + + for (const auto& obsData : observedDataColl->allObservedData()) + { + auto optionItem = caf::PdmOptionItemInfo(obsData->caseName(), obsData); + optionItem.setLevel(1); + options.push_back(optionItem); + } } } } @@ -569,7 +686,7 @@ QList RiuSummaryCurveDefSelection::calculateValueOptions void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::PdmUiOrdering& uiOrdering) { caf::PdmUiGroup* sourcesGroup = uiOrdering.addNewGroupWithKeyword("Sources", RiuSummaryCurveDefinitionKeywords::sources()); - sourcesGroup->add(&m_selectedCases); + sourcesGroup->add(&m_selectedSources); caf::PdmUiGroup* itemTypesGroup = uiOrdering.addNewGroupWithKeyword("Summary Types", RiuSummaryCurveDefinitionKeywords::summaryTypes()); itemTypesGroup->add(&m_selectedSummaryCategories); @@ -690,7 +807,7 @@ void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::Pd summaryiesField = m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK][1]->pdmField(); } else if (sumCategory == RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR) - { + { { caf::PdmUiGroup* myGroup = uiOrdering.addNewGroup("LGR Blocks"); myGroup->add(m_identifierFieldsMap[RifEclipseSummaryAddress::SUMMARY_BLOCK_LGR][0]->pdmField()); @@ -723,10 +840,20 @@ void RiuSummaryCurveDefSelection::defineUiOrdering(QString uiConfigName, caf::Pd std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedCases(const SummaryIdentifierAndField *identifierAndField) { std::vector cases; - for (const auto& sumCase : m_selectedCases()) + for (const auto& source : m_selectedSources()) { - if(isObservedData(sumCase)) continue; - cases.push_back(sumCase); + RimSummaryCase* sumCase = dynamic_cast(source.p()); + RimSummaryCaseCollection* ensemble = dynamic_cast(source.p()); + + if (sumCase) + { + if(!isObservedData(sumCase)) cases.push_back(sumCase); + } + else if (ensemble) + { + const auto& ensembleCases = ensemble->allSummaryCases(); + cases.insert(cases.end(), ensembleCases.begin(), ensembleCases.end()); + } } return findPossibleSummaryAddresses(cases, identifierAndField); } @@ -737,9 +864,11 @@ std::set RiuSummaryCurveDefSelection::findPossibleSumm std::set RiuSummaryCurveDefSelection::findPossibleSummaryAddressesFromSelectedObservedData(const SummaryIdentifierAndField *identifierAndField) { std::vector obsData; - for (const auto& sumCase : m_selectedCases()) + for (const auto& source : m_selectedSources()) { - if (isObservedData(sumCase)) + RimSummaryCase* sumCase = dynamic_cast(source.p()); + + if (sumCase && isObservedData(sumCase)) { obsData.push_back(sumCase); } @@ -958,7 +1087,7 @@ void RiuSummaryCurveDefSelection::defineEditorAttribute(const caf::PdmFieldHandl //-------------------------------------------------------------------------------------------------- void RiuSummaryCurveDefSelection::resetAllFields() { - m_selectedCases.clear(); + m_selectedSources.clear(); m_selectedSummaryCategories = std::vector>(); // clear all state in fields @@ -974,27 +1103,27 @@ void RiuSummaryCurveDefSelection::resetAllFields() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiuSummaryCurveDefSelection::isObservedData(RimSummaryCase *sumCase) const +bool RiuSummaryCurveDefSelection::isObservedData(const RimSummaryCase *sumCase) const { - return dynamic_cast(sumCase) != nullptr; + return dynamic_cast(sumCase) != nullptr; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -std::vector RiuSummaryCurveDefSelection::selectedSummaryCases() const +std::vector RiuSummaryCurveDefSelection::selectedSummarySources() const { - std::vector cases; + std::vector sources; - for (RimSummaryCase* currCase : m_selectedCases) + for (const auto& source : m_selectedSources) { - cases.push_back(currCase); + sources.push_back(source); } // Always add the summary case for calculated curves as this case is not displayed in UI - cases.push_back(RiuSummaryCurveDefSelection::calculatedSummaryCase()); + sources.push_back(RiuSummaryCurveDefSelection::calculatedSummaryCase()); - return cases; + return sources; } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h index 4cdda0670b..0c88bdbbc7 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelection.h @@ -33,11 +33,16 @@ #define OBSERVED_DATA_AVALUE_POSTFIX "_OBSDATA" class RimSummaryCase; +class RimSummaryCaseCollection; class RimSummaryCurveAutoName; class RimSummaryPlot; class RiaSummaryCurveDefinition; class SummaryIdentifierAndField; + +using SummarySource = caf::PdmObject; + + //================================================================================================== /// /// @@ -51,11 +56,15 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject virtual ~RiuSummaryCurveDefSelection(); void setSelectedCurveDefinitions(const std::vector& curveDefinitions); - std::vector selectedCurveDefinitions() const; + std::vector allCurveDefinitionsFromSelection() const; + std::vector selection() const; + void setMultiSelectionMode(bool multiSelectionMode); + void hideEnsembles(bool hide); + void hideSummaryCases(bool hide); void setFieldChangedHandler(const std::function& handlerFunc); - void setDefaultSelection(); + void setDefaultSelection(const std::vector& defaultCases); private: virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, @@ -86,13 +95,13 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject std::set& addressSet) const; void resetAllFields(); - bool isObservedData(RimSummaryCase *sumCase) const; + bool isObservedData(const RimSummaryCase *sumCase) const; - std::vector selectedSummaryCases() const; + std::vector selectedSummarySources() const; static RimSummaryCase* calculatedSummaryCase(); private: - caf::PdmPtrArrayField m_selectedCases; + caf::PdmPtrArrayField m_selectedSources; caf::PdmField>> m_selectedSummaryCategories; caf::PdmField> m_currentSummaryCategory; @@ -100,6 +109,9 @@ class RiuSummaryCurveDefSelection : public caf::PdmObject std::map> m_identifierFieldsMap; bool m_multiSelectionMode; + + bool m_hideEnsembles; + bool m_hideSummaryCases; std::function m_toggleChangedHandler; }; diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp index 31abcd6971..d12beebecc 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.cpp @@ -20,6 +20,8 @@ #include "RiaSummaryCurveDefinition.h" +#include "RimSummaryCaseCollection.h" + #include "RiuSummaryCurveDefSelection.h" #include "RiuSummaryCurveDefSelectionEditor.h" #include "RiuTools.h" @@ -77,9 +79,25 @@ void RiuSummaryCurveDefSelectionDialog::setCaseAndAddress(RimSummaryCase* summar { if (summaryCase) { - std::vector sumCasePairs; - sumCasePairs.push_back(RiaSummaryCurveDefinition(summaryCase, address)); - summaryAddressSelection()->setSelectedCurveDefinitions(sumCasePairs); + std::vector curveDefs; + curveDefs.push_back(RiaSummaryCurveDefinition(summaryCase, address)); + summaryAddressSelection()->setSelectedCurveDefinitions(curveDefs); + } + + summaryAddressSelection()->updateConnectedEditors(); + updateLabel(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelectionDialog::setEnsembleAndAddress(RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& address) +{ + if (ensemble) + { + std::vector curveDefs; + curveDefs.push_back(RiaSummaryCurveDefinition(nullptr, address, ensemble)); + summaryAddressSelection()->setSelectedCurveDefinitions(curveDefs); } summaryAddressSelection()->updateConnectedEditors(); @@ -91,7 +109,23 @@ void RiuSummaryCurveDefSelectionDialog::setCaseAndAddress(RimSummaryCase* summar //-------------------------------------------------------------------------------------------------- std::vector RiuSummaryCurveDefSelectionDialog::curveSelection() const { - return summaryAddressSelection()->selectedCurveDefinitions(); + return summaryAddressSelection()->selection(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelectionDialog::hideEnsembles() +{ + summaryAddressSelection()->hideEnsembles(true); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryCurveDefSelectionDialog::hideSummaryCases() +{ + summaryAddressSelection()->hideSummaryCases(true); } //-------------------------------------------------------------------------------------------------- @@ -108,7 +142,7 @@ RiuSummaryCurveDefSelection* RiuSummaryCurveDefSelectionDialog::summaryAddressSe void RiuSummaryCurveDefSelectionDialog::updateLabel() { QString curveAddressText; - std::vector sumCasePairs = this->summaryAddressSelection()->selectedCurveDefinitions(); + std::vector sumCasePairs = this->summaryAddressSelection()->selection(); if (sumCasePairs.size() == 1) { curveAddressText = sumCasePairs.front().curveDefinitionText(); diff --git a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h index c3cc896f32..f8784337fc 100644 --- a/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h +++ b/ApplicationCode/UserInterface/RiuSummaryCurveDefSelectionDialog.h @@ -40,8 +40,12 @@ class RiuSummaryCurveDefSelectionDialog : public QDialog ~RiuSummaryCurveDefSelectionDialog(); void setCaseAndAddress(RimSummaryCase* summaryCase, const RifEclipseSummaryAddress& address); + void setEnsembleAndAddress(RimSummaryCaseCollection* ensemble, const RifEclipseSummaryAddress& address); std::vector curveSelection() const; + void hideEnsembles(); + void hideSummaryCases(); + private: RiuSummaryCurveDefSelection* summaryAddressSelection() const; void updateLabel(); diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp index 7e13a3facd..f9f3ccb412 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.cpp @@ -26,7 +26,7 @@ #include "RimSummaryCurveCollection.h" #include "RimSummaryPlot.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuQwtCurvePointTracker.h" #include "RiuQwtPlotWheelZoomer.h" #include "RiuQwtPlotZoomer.h" @@ -50,8 +50,45 @@ #include #include + +#include "RiuWidgetDragger.h" +#include "RiuCvfOverlayItemWidget.h" +#include "RimEnsembleCurveSet.h" +#include "RimRegularLegendConfig.h" +#include "cafTitledOverlayFrame.h" +#include "RimEnsembleCurveSetCollection.h" +#include "RimMainPlotCollection.h" +#include "RimSummaryPlotCollection.h" +#include "RimSummaryCase.h" +#include "RiuRimQwtPlotCurve.h" +#include "RimSummaryCurve.h" + #include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class EnsembleCurveInfoTextProvider : public IPlotCurveInfoTextProvider +{ +public: + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + virtual QString curveInfoText(QwtPlotCurve* curve) override + { + RiuRimQwtPlotCurve* riuCurve = dynamic_cast(curve); + RimSummaryCurve* sumCurve = nullptr; + if (riuCurve) + { + sumCurve = dynamic_cast(riuCurve->ownerRimCurve()); + } + + return sumCurve && sumCurve->summaryCaseY() ? sumCurve->summaryCaseY()->caseName() : ""; + } +}; +static EnsembleCurveInfoTextProvider ensembleCurveInfoTextProvider; + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -158,6 +195,92 @@ void RiuSummaryQwtPlot::setZoomWindow(const QwtInterval& leftAxis, const QwtInte } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::updateEnsembleLegendLayout() +{ + const int spacing = 5; + int startMarginX = this->canvas()->pos().x() + spacing; + int startMarginY = this->canvas()->pos().y() + spacing; + + int xpos = startMarginX; + int ypos = startMarginY; + int maxColumnWidth = 0; + + if (!ownerPlotDefinition() || !ownerPlotDefinition()->ensembleCurveSetCollection()) return; + + for (RimEnsembleCurveSet * curveSet : ownerPlotDefinition()->ensembleCurveSetCollection()->curveSets()) + { + auto pairIt = m_ensembleLegendWidgets.find(curveSet); + if (pairIt != m_ensembleLegendWidgets.end()) + { + if (ypos + pairIt->second->height() + spacing > this->canvas()->height()) + { + xpos += spacing + maxColumnWidth; + ypos = startMarginY; + maxColumnWidth = 0; + } + + RiuCvfOverlayItemWidget* overlayWidget = pairIt->second; + overlayWidget->move(xpos, ypos); + + ypos += pairIt->second->height() + spacing; + maxColumnWidth = std::max(maxColumnWidth, pairIt->second->width()); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor) +{ + RiuCvfOverlayItemWidget* overlayWidget = nullptr; + + auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor); + if (it == m_ensembleLegendWidgets.end() || it->second == nullptr) + { + overlayWidget = new RiuCvfOverlayItemWidget(this); + + new RiuWidgetDragger(overlayWidget); + + m_ensembleLegendWidgets[curveSetToShowLegendFor] = overlayWidget; + + } + else + { + overlayWidget = it->second; + } + + if ( overlayWidget ) + { + caf::TitledOverlayFrame* overlyItem = curveSetToShowLegendFor->legendConfig()->titledOverlayFrame(); + overlyItem->setRenderSize(overlyItem->preferredSize()); + + overlayWidget->updateFromOverlyItem(curveSetToShowLegendFor->legendConfig()->titledOverlayFrame()); + overlayWidget->show(); + } + + this->updateEnsembleLegendLayout(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor) +{ + auto it = m_ensembleLegendWidgets.find(curveSetToShowLegendFor); + if ( it != m_ensembleLegendWidgets.end() ) + { + if ( it->second != nullptr ) it->second->deleteLater(); + + m_ensembleLegendWidgets.erase(it); + } + + this->updateEnsembleLegendLayout(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -282,7 +405,7 @@ void RiuSummaryQwtPlot::setCommonPlotBehaviour(QwtPlot* plot) plot->canvas()->installEventFilter(plot); plot->plotLayout()->setAlignCanvasToScales(true); - new RiuQwtCurvePointTracker(plot, true); + new RiuQwtCurvePointTracker(plot, true, &ensembleCurveInfoTextProvider); } //-------------------------------------------------------------------------------------------------- @@ -306,6 +429,15 @@ void RiuSummaryQwtPlot::enableDateBasedBottomXAxis(QwtPlot* plot) plot->setAxisScaleDraw(QwtPlot::xBottom, scaleDraw); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuSummaryQwtPlot::updateLayout() +{ + QwtPlot::updateLayout(); + updateEnsembleLegendLayout(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -340,7 +472,7 @@ bool RiuSummaryQwtPlot::eventFilter(QObject* watched, QEvent* event) //-------------------------------------------------------------------------------------------------- void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos) { - QwtPlotCurve* closestCurve = NULL; + QwtPlotCurve* closestCurve = nullptr; double distMin = DBL_MAX; const QwtPlotItemList& itmList = itemList(); @@ -361,14 +493,15 @@ void RiuSummaryQwtPlot::selectClosestCurve(const QPoint& pos) if(closestCurve && distMin < 20) { - caf::PdmObject* selectedCurve = m_plotDefinition->findRimCurveFromQwtCurve(closestCurve); + caf::PdmObject* selectedPlotObject = m_plotDefinition->findRimPlotObjectFromQwtCurve(closestCurve); RimProject* proj = nullptr; - selectedCurve->firstAncestorOrThisOfType(proj); + selectedPlotObject->firstAncestorOrThisOfType(proj); - if(proj && selectedCurve) + if(proj && selectedPlotObject) { - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(selectedPlotObject); } } } diff --git a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h index 1592aad790..a166206284 100644 --- a/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h +++ b/ApplicationCode/UserInterface/RiuSummaryQwtPlot.h @@ -32,8 +32,12 @@ class QwtPlotZoomer; class QwtInterval; class QwtPicker; class QwtPlotMarker; +class QwtScaleWidget; + +class RiuCvfOverlayItemWidget; class RimSummaryPlot; +class RimEnsembleCurveSet; //================================================================================================== // @@ -44,7 +48,7 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = NULL); + RiuSummaryQwtPlot(RimSummaryPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuSummaryQwtPlot(); RimSummaryPlot* ownerPlotDefinition(); @@ -61,6 +65,9 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow const QwtInterval& rightAxis, const QwtInterval& timeAxis); + void addOrUpdateEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor); + void removeEnsembleCurveSetLegend(RimEnsembleCurveSet * curveSetToShowLegendFor); + static void setCommonPlotBehaviour(QwtPlot* plot); static void enableDateBasedBottomXAxis(QwtPlot* plot); @@ -71,10 +78,12 @@ class RiuSummaryQwtPlot : public QwtPlot, public RiuInterfaceToViewWindow virtual QSize sizeHint() const override; virtual QSize minimumSizeHint() const override; virtual void contextMenuEvent(QContextMenuEvent *) override; + virtual void updateLayout() override; private: void setDefaults(); void selectClosestCurve(const QPoint& pos); + void updateEnsembleLegendLayout(); private slots: void onZoomedSlot( ); @@ -85,5 +94,8 @@ private slots: QPointer m_zoomerLeft; QPointer m_zoomerRight; + + std::map< caf::PdmPointer, QPointer > m_ensembleLegendWidgets; + }; diff --git a/ApplicationCode/UserInterface/RiuTextDialog.h b/ApplicationCode/UserInterface/RiuTextDialog.h index ea2bc4116f..7dffaa74e4 100644 --- a/ApplicationCode/UserInterface/RiuTextDialog.h +++ b/ApplicationCode/UserInterface/RiuTextDialog.h @@ -26,7 +26,7 @@ class RiuQPlainTextEdit : public QPlainTextEdit { Q_OBJECT public: - explicit RiuQPlainTextEdit(QWidget *parent = 0) : QPlainTextEdit(parent) {} + explicit RiuQPlainTextEdit(QWidget *parent = nullptr) : QPlainTextEdit(parent) {} protected: virtual void keyPressEvent(QKeyEvent *e) override; @@ -46,7 +46,7 @@ class RiuTextDialog : public QDialog Q_OBJECT public: - explicit RiuTextDialog(QWidget* parent = 0); + explicit RiuTextDialog(QWidget* parent = nullptr); void setText(const QString& text); diff --git a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp index f8cf6cf52b..e8da3853ba 100644 --- a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp +++ b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.cpp @@ -17,13 +17,15 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RiuTimeStepChangedHandler.h" + #include "RiuMainWindow.h" -#include "RiuRelativePermeabilityPlotPanel.h" -#include "RiuRelativePermeabilityPlotUpdater.h" +#include "RiuMohrsCirclePlot.h" #include "RiuPvtPlotPanel.h" #include "RiuPvtPlotUpdater.h" +#include "RiuRelativePermeabilityPlotPanel.h" +#include "RiuRelativePermeabilityPlotUpdater.h" -#include "RimView.h" +#include "Rim3dView.h" #include "cvfBase.h" #include "cvfTrace.h" @@ -60,7 +62,7 @@ RiuTimeStepChangedHandler* RiuTimeStepChangedHandler::instance() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuTimeStepChangedHandler::handleTimeStepChanged(RimView* changedView) const +void RiuTimeStepChangedHandler::handleTimeStepChanged(Rim3dView* changedView) const { //cvf::Trace::show("handleTimeStepChanged() viewName: %s timeStep:%d", changedView->name().toLatin1().data(), changedView->currentTimeStep()); //cvf::DebugTimer tim("handleTimeStepChanged()"); @@ -71,5 +73,8 @@ void RiuTimeStepChangedHandler::handleTimeStepChanged(RimView* changedView) cons RiuPvtPlotUpdater* pvtPlotUpdater = RiuMainWindow::instance()->pvtPlotPanel()->plotUpdater(); pvtPlotUpdater->updateOnTimeStepChanged(changedView); + RiuMohrsCirclePlot* mohrsCirclePlot = RiuMainWindow::instance()->mohrsCirclePlot(); + if (mohrsCirclePlot) mohrsCirclePlot->updateOnTimeStepChanged(changedView); + //tim.reportTimeMS("done"); } diff --git a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h index da961d691c..bd5c236836 100644 --- a/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h +++ b/ApplicationCode/UserInterface/RiuTimeStepChangedHandler.h @@ -18,7 +18,7 @@ #pragma once -class RimView; +class Rim3dView; //================================================================================================== @@ -31,7 +31,7 @@ class RiuTimeStepChangedHandler public: static RiuTimeStepChangedHandler* instance(); - void handleTimeStepChanged(RimView* changedView) const; + void handleTimeStepChanged(Rim3dView* changedView) const; private: RiuTimeStepChangedHandler(); diff --git a/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h b/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h index 2fbe6d15cd..ac43f8167b 100644 --- a/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h +++ b/ApplicationCode/UserInterface/RiuTofAccumulatedPhaseFractionsPlot.h @@ -43,7 +43,7 @@ class RiuTofAccumulatedPhaseFractionsPlot : public QwtPlot, public RiuInterfaceT Q_OBJECT public: - RiuTofAccumulatedPhaseFractionsPlot(RimTofAccumulatedPhaseFractionsPlot* plotDefinition, QWidget* parent = NULL); + RiuTofAccumulatedPhaseFractionsPlot(RimTofAccumulatedPhaseFractionsPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuTofAccumulatedPhaseFractionsPlot(); RimTofAccumulatedPhaseFractionsPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp b/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp index e390dc143c..094858d8ec 100644 --- a/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp +++ b/ApplicationCode/UserInterface/RiuTreeViewEventFilter.cpp @@ -30,7 +30,7 @@ #include "RimIdenticalGridCaseGroup.h" #include "RiuMainWindow.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindow.h" #include "cafCmdFeature.h" #include "cafCmdFeatureManager.h" diff --git a/ApplicationCode/UserInterface/RiuViewer.cpp b/ApplicationCode/UserInterface/RiuViewer.cpp index a3a8fcfa19..3e7ff17476 100644 --- a/ApplicationCode/UserInterface/RiuViewer.cpp +++ b/ApplicationCode/UserInterface/RiuViewer.cpp @@ -23,10 +23,12 @@ #include "RiaApplication.h" #include "RiaBaseDefs.h" #include "RiaColorTools.h" +#include "RiaPreferences.h" +#include "RiaRegressionTestRunner.h" #include "RimCase.h" #include "RimProject.h" -#include "RimView.h" +#include "RimGridView.h" #include "RimViewController.h" #include "RimViewLinker.h" @@ -39,7 +41,9 @@ #include "RiuSimpleHistogramWidget.h" #include "RiuViewerCommands.h" +#include "cafTitledOverlayFrame.h" #include "cafCategoryLegend.h" +#include "cafOverlayScalarMapperLegend.h" #include "cafCeetronPlusNavigation.h" #include "cafDisplayCoordTransform.h" #include "cafEffectGenerator.h" @@ -49,7 +53,6 @@ #include "cvfFont.h" #include "cvfOpenGLResourceManager.h" #include "cvfOverlayAxisCross.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfRenderQueueSorter.h" #include "cvfRenderSequence.h" #include "cvfRendering.h" @@ -59,6 +62,8 @@ #include #include #include +#include "WindowEdgeAxesOverlayItem/RivWindowEdgeAxesOverlayItem.h" +#include using cvf::ManipulatorTrackball; @@ -79,13 +84,14 @@ const double RI_MIN_NEARPLANE_DISTANCE = 0.1; /// //-------------------------------------------------------------------------------------------------- RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) -: caf::Viewer(format, parent) +: caf::Viewer(format, parent), m_isNavigationRotationEnabled(true) { cvf::Font* standardFont = RiaApplication::instance()->standardFont(); m_axisCross = new cvf::OverlayAxisCross(m_mainCamera.p(), standardFont); m_axisCross->setAxisLabels("X", "Y", "Z"); - m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); + m_axisCross->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_RIGHT); m_mainRendering->addOverlayItem(m_axisCross.p()); + m_showAxisCross = true; this->enableOverlyPainting(true); this->setReleaseOGLResourcesEachFrame(true); @@ -155,7 +161,7 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_viewerCommands = new RiuViewerCommands(this); - if (RiaApplication::instance()->isRunningRegressionTests()) + if (RiaRegressionTestRunner::instance()->isRunningRegressionTests()) { QFont regTestFont = m_infoLabel->font(); regTestFont.setPixelSize(11); @@ -175,6 +181,9 @@ RiuViewer::RiuViewer(const QGLFormat& format, QWidget* parent) m_gridBoxGenerator = new RivGridBoxGenerator; m_cursorPositionDomainCoords = cvf::Vec3d::UNDEFINED; + m_windowEdgeAxisOverlay = new RivWindowEdgeAxesOverlayItem(standardFont); + m_showWindowEdgeAxes = false; + } //-------------------------------------------------------------------------------------------------- @@ -186,9 +195,10 @@ RiuViewer::~RiuViewer() { m_rimView->handleMdiWindowClosed(); - m_rimView->cameraPosition = m_mainCamera->viewMatrix(); - m_rimView->cameraPointOfInterest = pointOfInterest(); + m_rimView->setCameraPosition(m_mainCamera->viewMatrix()); + m_rimView->setCameraPointOfInterest( pointOfInterest()); } + delete m_infoLabel; delete m_animationProgress; delete m_histogramWidget; @@ -297,7 +307,7 @@ void RiuViewer::slotSetCurrentFrame(int frameIndex) RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateTimeStep(m_rimView, frameIndex); + viewLinker->updateTimeStep(dynamic_cast(m_rimView.p()), frameIndex); } } } @@ -321,17 +331,11 @@ void RiuViewer::setPointOfInterest(cvf::Vec3d poi) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::setOwnerReservoirView(RimView * owner) +void RiuViewer::setOwnerReservoirView(RiuViewerToViewInterface * owner) { m_rimView = owner; - m_viewerCommands->setOwnerView(owner); - cvf::String xLabel; - cvf::String yLabel; - cvf::String zLabel; - - m_rimView->axisLabels(&xLabel, &yLabel, &zLabel); - setAxisLabels(xLabel, yLabel, zLabel); + m_viewerCommands->setOwnerView(dynamic_cast(owner)); } //-------------------------------------------------------------------------------------------------- @@ -347,27 +351,24 @@ void RiuViewer::setEnableMask(unsigned int mask) //-------------------------------------------------------------------------------------------------- void RiuViewer::paintOverlayItems(QPainter* painter) { - // No support for overlay items using SW rendering yet. - //if (!isShadersSupported()) - //{ - // return; - //} - int columnWidth = 200; + + int edgeAxisFrameBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisFrameBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; + int margin = 5; - int yPos = margin; + int yPos = margin + edgeAxisFrameBorderHeight; bool showAnimBar = false; if (isAnimationActive() && frameCount() > 1) showAnimBar = true; - //if (showAnimBar) columnWidth = CVF_MAX(columnWidth, m_animationProgress->width()); if (m_showInfoText) columnWidth = CVF_MAX(columnWidth, m_infoLabel->sizeHint().width()); - int columnPos = this->width() - columnWidth - margin; + int columnPos = this->width() - columnWidth - margin - edgeAxisFrameBorderWidth; if (showAnimBar && m_showAnimProgress) { - QString stepName = m_rimView->ownerCase()->timeStepName(currentFrameIndex()); + QString stepName = m_rimView->timeStepName(currentFrameIndex()); m_animationProgress->setFormat("Time Step: %v/%m " + stepName); m_animationProgress->setMinimum(0); m_animationProgress->setMaximum(static_cast(frameCount()) - 1); @@ -406,7 +407,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) if (m_showInfoText) // Version Label { QSize size(m_versionInfoLabel->sizeHint().width(), m_versionInfoLabel->sizeHint().height()); - QPoint pos(this->width() - size.width() - margin, this->height() - size.height() - margin); + QPoint pos(this->width() - size.width() - margin - edgeAxisFrameBorderWidth, this->height() - size.height() - margin - edgeAxisFrameBorderHeight); m_versionInfoLabel->resize(size.width(), size.height()); m_versionInfoLabel->render(painter, pos); } @@ -432,7 +433,7 @@ void RiuViewer::paintOverlayItems(QPainter* painter) painter->drawLine(centerPos.x() - markerHalfLength, centerPos.y(), centerPos.x() + markerHalfLength, centerPos.y()); } } - } + } } //-------------------------------------------------------------------------------------------------- @@ -468,6 +469,19 @@ void RiuViewer::setHistogramPercentiles(double pmin, double pmax, double mean) m_histogramWidget->setMean(mean); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::showGridBox(bool enable) +{ + this->removeStaticModel(m_gridBoxGenerator->model()); + + if (enable) + { + this->addStaticModelOnce(m_gridBoxGenerator->model()); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -494,6 +508,19 @@ void RiuViewer::mousePressEvent(QMouseEvent* event) +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Collection RiuViewer::allOverlayItems() +{ + cvf::Collection allOverLays; + for (size_t oIdx = 0; oIdx < m_mainRendering->overlayItemCount(); ++oIdx) + { + allOverLays.push_back(m_mainRendering->overlayItem(oIdx)); + } + return allOverLays; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -510,77 +537,120 @@ void RiuViewer::removeAllColorLegends() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend) +void RiuViewer::addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* addedLegend) { + RiaApplication* app = RiaApplication::instance(); + CVF_ASSERT(app); + RiaPreferences* preferences = app->preferences(); cvf::Rendering* firstRendering = m_mainRendering.p(); + CVF_ASSERT(preferences); CVF_ASSERT(firstRendering); - if (legend) + if (addedLegend) { - updateLegendTextAndTickMarkColor(legend); - - firstRendering->addOverlayItem(legend); + cvf::Color4f backgroundColor = mainCamera()->viewport()->clearColor(); + backgroundColor.a() = 0.8f; + cvf::Color3f frameColor(backgroundColor.r(), backgroundColor.g(), backgroundColor.b()); + updateLegendTextAndTickMarkColor(addedLegend); + + firstRendering->addOverlayItem(addedLegend); + addedLegend->enableBackground(preferences->showLegendBackground()); + addedLegend->setBackgroundColor(backgroundColor); + addedLegend->setBackgroundFrameColor(cvf::Color4f(RiaColorTools::computeOffsetColor(frameColor, 0.3f), 0.9f)); - m_visibleLegends.push_back(legend); + m_visibleLegends.push_back(addedLegend); } - // Category count used to switch between standard height and full height of legend - const size_t categoryThreshold = 13; + updateLegendLayout(); - std::vector categoryLegends; - std::vector overlayItems; - for (auto legend : m_visibleLegends) - { - legend->setLayout(cvf::OverlayItem::VERTICAL, cvf::OverlayItem::BOTTOM_LEFT); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::updateLegendLayout() +{ + int viewPortHeight = static_cast(m_mainCamera->viewport()->height()); + + const float maxFreeLegendHeight = 0.7f*viewPortHeight; + const int border = 3; + int edgeAxisBorderWidth = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderWidth(): 0; + int edgeAxisBorderHeight = m_showWindowEdgeAxes ? m_windowEdgeAxisOverlay->frameBorderHeight(): 0; + + int xPos = border + edgeAxisBorderWidth; + int yPos = border + edgeAxisBorderHeight; - caf::CategoryLegend* catLegend = dynamic_cast(legend.p()); - if (catLegend) + std::vector standardHeightLegends; + + // Place the legends needing the full height, and sort out the standard height legends + + for ( cvf::ref legend : m_visibleLegends ) + { + cvf::Vec2ui prefSize = legend->preferredSize(); + if (prefSize.y() > maxFreeLegendHeight) { - if (catLegend->categoryCount() > categoryThreshold) - { - categoryLegends.push_back(catLegend); - } - else - { - catLegend->setSizeHint(cvf::Vec2ui(200, 200)); - } + int legendWidth = prefSize.x(); + legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + legend->setRenderSize(cvf::Vec2ui(legendWidth, viewPortHeight - 2 * border - 2 * edgeAxisBorderHeight)); + xPos += legendWidth + border; } else { - overlayItems.push_back(legend.p()); + standardHeightLegends.push_back(legend.p()); } } - if (categoryLegends.size() > 0) - { - const int border = 3; - const int categoryWidth = 150; - - // This value is taken from OverlayAxisCross, as the axis cross is always shown in the lower left corner - const int axisCrossHeight = 120; - - int height = static_cast(m_mainCamera->viewport()->height()); - int xPos = border; + // Place the rest of the legends in columns that fits within the screen height + + int maxColumnWidht = 0; + std::vector columnLegends; - int yPos = axisCrossHeight + 2*border; + for ( caf::TitledOverlayFrame* legend : standardHeightLegends ) + { + cvf::Vec2ui prefSize = legend->preferredSize(); - for (auto catLegend : categoryLegends) + // Check if we need a new column + if ((yPos + (int)prefSize.y() + border) > viewPortHeight) { - catLegend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); - catLegend->setSizeHint(cvf::Vec2ui(categoryWidth, height - 2*border - axisCrossHeight)); + xPos += border + maxColumnWidht; + yPos = border + edgeAxisBorderHeight; - xPos += categoryWidth + border; + // Set same width to all legends in the column + for (caf::TitledOverlayFrame* legend : columnLegends ) + { + legend->setRenderSize(cvf::Vec2ui(maxColumnWidht, legend->renderSize().y())); + } + maxColumnWidht = 0; + columnLegends.clear(); } - for (auto item : overlayItems) - { - item->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + legend->setLayoutFixedPosition(cvf::Vec2i(xPos, yPos)); + legend->setRenderSize(cvf::Vec2ui(prefSize.x(), prefSize.y())); + columnLegends.push_back(legend); - yPos += item->sizeHint().y() + border; - } + yPos += legend->renderSize().y() + border; + maxColumnWidht = std::max(maxColumnWidht, (int)prefSize.x()); + } + + // Set same width to all legends in the last column + + for (caf::TitledOverlayFrame* legend : columnLegends ) + { + legend->setRenderSize(cvf::Vec2ui(maxColumnWidht, legend->renderSize().y())); } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiuViewer::enableNavigationRotation(bool enable) +{ + auto tbNavPol = dynamic_cast(m_navigationPolicy.p()); + m_isNavigationRotationEnabled = enable; + + if (tbNavPol) tbNavPol->enableRotation(m_isNavigationRotationEnabled); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -608,6 +678,8 @@ void RiuViewer::updateNavigationPolicy() CVF_ASSERT(0); break; } + + enableNavigationRotation(m_isNavigationRotationEnabled); } //-------------------------------------------------------------------------------------------------- @@ -622,7 +694,7 @@ void RiuViewer::navigationPolicyUpdate() RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); if (viewLinker) { - viewLinker->updateCamera(m_rimView); + viewLinker->updateCamera(dynamic_cast(m_rimView.p())); } } } @@ -645,7 +717,21 @@ void RiuViewer::setCurrentFrame(int frameIndex) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimView* RiuViewer::ownerReservoirView() +void RiuViewer::showAxisCross(bool enable) +{ + m_mainRendering->removeOverlayItem(m_axisCross.p()); + + if (enable) + { + m_mainRendering->addOverlayItem(m_axisCross.p()); + } + m_showAxisCross = enable; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuViewerToViewInterface* RiuViewer::ownerReservoirView() { return m_rimView; } @@ -655,7 +741,7 @@ RimView* RiuViewer::ownerReservoirView() //-------------------------------------------------------------------------------------------------- RimViewWindow* RiuViewer::ownerViewWindow() const { - return m_rimView; + return dynamic_cast( m_rimView.p()); } //-------------------------------------------------------------------------------------------------- @@ -663,8 +749,13 @@ RimViewWindow* RiuViewer::ownerViewWindow() const //-------------------------------------------------------------------------------------------------- void RiuViewer::optimizeClippingPlanes() { - m_gridBoxGenerator->updateFromCamera(mainCamera()); + if (m_showWindowEdgeAxes) + { + m_windowEdgeAxisOverlay->setDisplayCoordTransform(m_rimView->displayCoordTransform().p()); + m_windowEdgeAxisOverlay->updateFromCamera(this->mainCamera()); + } + m_gridBoxGenerator->updateFromCamera(mainCamera()); caf::Viewer::optimizeClippingPlanes(); } @@ -674,21 +765,7 @@ void RiuViewer::optimizeClippingPlanes() void RiuViewer::resizeGL(int width, int height) { caf::Viewer::resizeGL(width, height); - - bool hasCategoryLegend = false; - for (size_t i = 0; i < m_visibleLegends.size(); i++) - { - caf::CategoryLegend* categoryLegend = dynamic_cast(m_visibleLegends.at(i)); - if (categoryLegend) - { - hasCategoryLegend = true; - } - } - - if (hasCategoryLegend) - { - m_rimView->updateCurrentTimeStepAndRedraw(); - } + this->updateLegendLayout(); } //-------------------------------------------------------------------------------------------------- @@ -719,7 +796,7 @@ void RiuViewer::mouseMoveEvent(QMouseEvent* mouseEvent) cvf::ref trans = m_rimView->displayCoordTransform(); cvf::Vec3d domainCoord = trans->transformToDomainCoord(displayCoord); - viewLinker->updateCursorPosition(m_rimView, domainCoord); + viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()) , domainCoord); } } } @@ -735,43 +812,39 @@ void RiuViewer::leaveEvent(QEvent *) if (m_rimView && m_rimView->assosiatedViewLinker()) { RimViewLinker* viewLinker = m_rimView->assosiatedViewLinker(); - viewLinker->updateCursorPosition(m_rimView, cvf::Vec3d::UNDEFINED); + viewLinker->updateCursorPosition(dynamic_cast(m_rimView.p()), cvf::Vec3d::UNDEFINED); } } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewer::updateGridBoxData() +void RiuViewer::updateGridBoxData(double scaleZ, + const cvf::Vec3d& displayModelOffset, + const cvf::Color3f& backgroundColor, + const cvf::BoundingBox& domainCoordBoundingBox) { - if (ownerReservoirView() && ownerReservoirView()->ownerCase()) - { - RimView* rimView = ownerReservoirView(); - RimCase* rimCase = rimView->ownerCase(); + m_gridBoxGenerator->setScaleZ(scaleZ); + m_gridBoxGenerator->setDisplayModelOffset(displayModelOffset); + m_gridBoxGenerator->updateFromBackgroundColor(backgroundColor); + m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(domainCoordBoundingBox); - m_gridBoxGenerator->setScaleZ(rimView->scaleZ); - m_gridBoxGenerator->setDisplayModelOffset(rimCase->displayModelOffset()); - m_gridBoxGenerator->updateFromBackgroundColor(rimView->backgroundColor); - - if (rimView->showActiveCellsOnly()) - { - m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(rimCase->activeCellsBoundingBox()); - } - else - { - m_gridBoxGenerator->setGridBoxDomainCoordBoundingBox(rimCase->allCellsBoundingBox()); - } - - m_gridBoxGenerator->createGridBoxParts(); - } + m_gridBoxGenerator->createGridBoxParts(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -cvf::Model* RiuViewer::gridBoxModel() const +void RiuViewer::showEdgeTickMarks(bool enable) { - return m_gridBoxGenerator->model(); + m_mainRendering->removeOverlayItem(m_windowEdgeAxisOverlay.p()); + + if (enable) + { + m_mainRendering->addOverlayItem(m_windowEdgeAxisOverlay.p()); + } + + m_showWindowEdgeAxes = enable; } //-------------------------------------------------------------------------------------------------- @@ -811,7 +884,7 @@ cvf::OverlayItem* RiuViewer::pickFixedPositionedLegend(int winPosX, int winPosY) for (auto overlayItem : m_visibleLegends) { if (overlayItem->layoutScheme() == cvf::OverlayItem::FIXED_POSITION && - overlayItem->pick(translatedMousePosX, translatedMousePosY, overlayItem->fixedPosition(), overlayItem->sizeHint())) + overlayItem->pick(translatedMousePosX, translatedMousePosY, overlayItem->fixedPosition(), overlayItem->renderSize())) { return overlayItem.p(); } @@ -854,17 +927,17 @@ void RiuViewer::updateLegendTextAndTickMarkColor(cvf::OverlayItem* legend) cvf::Color3f contrastColor = computeContrastColor(); - cvf::OverlayScalarMapperLegend* scalarMapperLegend = dynamic_cast(legend); + caf::OverlayScalarMapperLegend* scalarMapperLegend = dynamic_cast(legend); if (scalarMapperLegend) { - scalarMapperLegend->setColor(contrastColor); + scalarMapperLegend->setTextColor(contrastColor); scalarMapperLegend->setLineColor(contrastColor); } caf::CategoryLegend* categoryLegend = dynamic_cast(legend); if (categoryLegend) { - categoryLegend->setColor(contrastColor); + categoryLegend->setTextColor(contrastColor); categoryLegend->setLineColor(contrastColor); } @@ -907,7 +980,7 @@ cvf::Color3f RiuViewer::computeContrastColor() const if (m_rimView.notNull()) { - contrastColor = RiaColorTools::constrastColor(m_rimView->backgroundColor); + contrastColor = RiaColorTools::constrastColor(m_rimView->backgroundColor()); } return contrastColor; diff --git a/ApplicationCode/UserInterface/RiuViewer.h b/ApplicationCode/UserInterface/RiuViewer.h index 353a8f3a86..c2b8eda882 100644 --- a/ApplicationCode/UserInterface/RiuViewer.h +++ b/ApplicationCode/UserInterface/RiuViewer.h @@ -20,25 +20,33 @@ #pragma once +#include "RiuViewerToViewInterface.h" #include "cafViewer.h" #include "cafPdmObject.h" #include "cafPdmPointer.h" +#include "cafPdmInterfacePointer.h" #include "cafMouseState.h" #include "cvfStructGrid.h" #include "RiuInterfaceToViewWindow.h" class RicCommandFeature; -class RimView; +class Rim3dView; class RiuSimpleHistogramWidget; class RiuViewerCommands; class RivGridBoxGenerator; +class RivWindowEdgeAxesOverlayItem; class QCDEStyle; class QLabel; class QProgressBar; +namespace caf +{ + class TitledOverlayFrame; +} + namespace cvf { class Color3f; @@ -46,6 +54,7 @@ namespace cvf class OverlayItem; class Part; class OverlayAxisCross; + class BoundingBox; } //================================================================================================== @@ -64,8 +73,8 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void setDefaultView(); cvf::Vec3d pointOfInterest(); void setPointOfInterest(cvf::Vec3d poi); - void setOwnerReservoirView(RimView * owner); - RimView* ownerReservoirView(); + void setOwnerReservoirView(RiuViewerToViewInterface * owner); + RiuViewerToViewInterface* ownerReservoirView(); RimViewWindow* ownerViewWindow() const override; void setEnableMask(unsigned int mask); @@ -75,22 +84,28 @@ class RiuViewer : public caf::Viewer, public RiuInterfaceToViewWindow void setHistogram(double min, double max, const std::vector& histogram); void setHistogramPercentiles(double pmin, double pmax, double mean); - void updateGridBoxData(); - cvf::Model* gridBoxModel() const; + void showGridBox(bool enable); + void updateGridBoxData(double scaleZ, + const cvf::Vec3d& displayModelOffset, + const cvf::Color3f& backgroundColor, + const cvf::BoundingBox& domainCoordBoundingBox); + void showEdgeTickMarks(bool enable); void updateAnnotationItems(); void showAnimationProgress(bool enable); void removeAllColorLegends(); - void addColorLegendToBottomLeftCorner(cvf::OverlayItem* legend); + void addColorLegendToBottomLeftCorner(caf::TitledOverlayFrame* legend); + void enableNavigationRotation(bool disable); void updateNavigationPolicy(); virtual void navigationPolicyUpdate(); // Override of caf::Viewer::navigationPolicyUpdate() void setCurrentFrame(int frameIndex); + void showAxisCross(bool enable); void setAxisLabels(const cvf::String& xLabel, const cvf::String& yLabel, const cvf::String& zLabel); cvf::Vec3d lastPickPositionInDomainCoords() const; @@ -112,6 +127,7 @@ public slots: virtual void leaveEvent(QEvent *) override; private: + void updateLegendLayout(); void updateTextAndTickMarkColorForOverlayItems(); void updateLegendTextAndTickMarkColor(cvf::OverlayItem* legend); @@ -139,15 +155,21 @@ public slots: QCDEStyle* m_progressBarStyle; cvf::ref m_axisCross; - cvf::Collection m_visibleLegends; + bool m_showAxisCross; + cvf::Collection m_visibleLegends; + cvf::Collection allOverlayItems(); + - caf::PdmPointer m_rimView; + caf::PdmInterfacePointer m_rimView; QPoint m_lastMousePressPosition; RiuViewerCommands* m_viewerCommands; RivGridBoxGenerator* m_gridBoxGenerator; + cvf::ref m_windowEdgeAxisOverlay; + bool m_showWindowEdgeAxes; cvf::Vec3d m_cursorPositionDomainCoords; + bool m_isNavigationRotationEnabled; }; diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.cpp b/ApplicationCode/UserInterface/RiuViewerCommands.cpp index 09583061a8..3ff7f6bd8b 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.cpp +++ b/ApplicationCode/UserInterface/RiuViewerCommands.cpp @@ -21,10 +21,12 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaDefines.h" #include "RicEclipsePropertyFilterNewExec.h" #include "RicGeoMechPropertyFilterNewExec.h" #include "RicViewerEventInterface.h" +#include "WellLogCommands/Ric3dWellLogCurveViewerEventHandler.h" #include "WellPathCommands/RicIntersectionViewerEventHandler.h" #include "WellPathCommands/RicWellPathViewerEventHandler.h" @@ -34,28 +36,33 @@ #include "RigFemPartGrid.h" #include "RigGeoMechCaseData.h" #include "RigMainGrid.h" +#include "RigVirtualPerforationTransmissibilities.h" -#include "RiaDefines.h" +#include "Rim2dIntersectionView.h" #include "RimCellEdgeColors.h" #include "RimContextCommandBuilder.h" #include "RimEclipseCase.h" #include "RimEclipseCellColors.h" #include "RimEclipseFaultColors.h" #include "RimEclipseView.h" +#include "RimEllipseFractureTemplate.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" +#include "RimFracture.h" #include "RimGeoMechCase.h" #include "RimGeoMechCellColors.h" #include "RimGeoMechView.h" #include "RimIntersection.h" #include "RimIntersectionBox.h" #include "RimLegendConfig.h" +#include "RimPerforationInterval.h" #include "RimSimWellInView.h" -#include "RimTernaryLegendConfig.h" +#include "RimStimPlanFractureTemplate.h" #include "RimViewController.h" #include "RimWellPath.h" #include "RiuMainWindow.h" +#include "RiuResultTextBuilder.h" #include "RiuSelectionManager.h" #include "RiuViewer.h" @@ -64,27 +71,32 @@ #include "RivIntersectionBoxSourceInfo.h" #include "RivIntersectionSourceInfo.h" #include "RivObjectSourceInfo.h" +#include "RivSimWellConnectionSourceInfo.h" #include "RivSimWellPipeSourceInfo.h" #include "RivSourceInfo.h" #include "RivTernarySaturationOverlayItem.h" +#include "RivWellConnectionSourceInfo.h" +#include "RivWellFracturePartMgr.h" #include "RivWellPathSourceInfo.h" #include "cafCmdExecCommandManager.h" #include "cafCmdFeatureManager.h" +#include "cafCmdFeatureMenuBuilder.h" #include "cafDisplayCoordTransform.h" +#include "cafPdmUiTreeView.h" #include "cafSelectionManager.h" -#include "cafCmdFeatureMenuBuilder.h" +#include "cafOverlayScalarMapperLegend.h" #include "cvfDrawableGeo.h" #include "cvfHitItemCollection.h" #include "cvfOverlayAxisCross.h" -#include "cvfOverlayScalarMapperLegend.h" #include "cvfPart.h" #include "cvfTransform.h" #include #include #include + #include @@ -98,17 +110,22 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) - : QObject(ownerViewer), - m_viewer(ownerViewer), - m_currentGridIdx(-1), - m_currentCellIndex(-1), - m_currentPickPositionInDomainCoords(cvf::Vec3d::UNDEFINED) +RiuViewerCommands::RiuViewerCommands(RiuViewer* ownerViewer) + : QObject(ownerViewer) + , m_currentGridIdx(-1) + , m_currentCellIndex(-1) + , m_currentFaceIndex(cvf::StructGridInterface::NO_FACE) + , m_currentPickPositionInDomainCoords(cvf::Vec3d::UNDEFINED) + , m_viewer(ownerViewer) { { m_viewerEventHandlers.push_back(dynamic_cast(RicIntersectionViewerEventHandler::instance())); } + { + m_viewerEventHandlers.push_back(dynamic_cast(Ric3dWellLogCurveViewerEventHandler::instance())); + } + { m_viewerEventHandlers.push_back(dynamic_cast(RicWellPathViewerEventHandler::instance())); } @@ -125,7 +142,7 @@ RiuViewerCommands::~RiuViewerCommands() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RiuViewerCommands::setOwnerView(RimView * owner) +void RiuViewerCommands::setOwnerView(Rim3dView * owner) { m_reservoirView = owner; } @@ -148,23 +165,47 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) cvf::Vec3d localIntersectionPoint(cvf::Vec3d::ZERO); cvf::Vec3d globalIntersectionPoint(cvf::Vec3d::ZERO); - cvf::Part* firstHitPart = nullptr; - cvf::Part* nncFirstHitPart = nullptr; + const cvf::Part* firstHitPart = nullptr; m_currentPickPositionInDomainCoords = cvf::Vec3d::UNDEFINED; + // Check type of view + RimGridView* gridView = dynamic_cast(m_reservoirView.p()); + Rim2dIntersectionView* int2dView = dynamic_cast(m_reservoirView.p()); + cvf::HitItemCollection hitItems; if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) { - extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &nncFirstHitPart, NULL); + std::vector> partAndTriangleIndexPairs; + extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, + &partAndTriangleIndexPairs, nullptr, nullptr); + + for (const auto& partTringleIndex : partAndTriangleIndexPairs) + { + if (!firstHitPart) + { + auto part = partTringleIndex.first; + const RivObjectSourceInfo* objectSourceInfo = dynamic_cast(part->sourceInfo()); + if (objectSourceInfo && dynamic_cast(objectSourceInfo->object())) + { + // Skip picking on perforation interval, display well path context menu + continue; + } + + firstHitPart = part; + firstPartTriangleIndex = partTringleIndex.second; + break; + } + } cvf::Vec3d displayModelOffset = cvf::Vec3d::ZERO; - RimView* activeView = RiaApplication::instance()->activeReservoirView(); - CVF_ASSERT(activeView); + if (m_reservoirView.p()) + { + cvf::ref transForm = m_reservoirView.p()->displayCoordTransform(); + m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint); + } - cvf::ref transForm = activeView->displayCoordTransform(); - m_currentPickPositionInDomainCoords = transForm->transformToDomainCoord(globalIntersectionPoint); } if (firstHitPart && firstPartTriangleIndex != cvf::UNDEFINED_UINT) @@ -199,8 +240,17 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) RiuSelectionItem* selItem = new RiuGeneralSelectionItem(crossSectionSourceInfo->crossSection()); RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); - menuBuilder << "RicHideIntersectionFeature"; - menuBuilder.addSeparator(); + if (gridView) + { + menuBuilder << "RicHideIntersectionFeature"; + menuBuilder.addSeparator(); + menuBuilder << "RicNewIntersectionViewFeature"; + menuBuilder.addSeparator(); + } + else if (int2dView) + { + menuBuilder << "RicSelectColorResult"; + } } else if (intersectionBoxSourceInfo) { @@ -214,50 +264,56 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); } - // IJK -slice commands - RimViewController* viewController = nullptr; - if (m_reservoirView) viewController = m_reservoirView->viewController(); - - if (!viewController || !viewController->isRangeFiltersControlled()) + if (gridView) { - size_t i, j, k; - ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); + // IJK -slice commands + RimViewController* viewController = nullptr; + if (m_reservoirView) viewController = m_reservoirView->viewController(); - QVariantList iSliceList; - iSliceList.push_back(0); - iSliceList.push_back(CVF_MAX(static_cast(i + 1), 1)); - - QVariantList jSliceList; - jSliceList.push_back(1); - jSliceList.push_back(CVF_MAX(static_cast(j + 1), 1)); + if (!viewController || !viewController->isRangeFiltersControlled()) + { + size_t i, j, k; + ijkFromCellIndex(m_currentGridIdx, m_currentCellIndex, &i, &j, &k); - QVariantList kSliceList; - kSliceList.push_back(2); - kSliceList.push_back(CVF_MAX(static_cast(k + 1), 1)); + QVariantList iSliceList; + iSliceList.push_back(0); + iSliceList.push_back(CVF_MAX(static_cast(i + 1), 1)); + iSliceList.push_back(static_cast(m_currentGridIdx)); - menuBuilder.subMenuStart("Range Filter Slice", QIcon(":/CellFilter_Range.png")); + QVariantList jSliceList; + jSliceList.push_back(1); + jSliceList.push_back(CVF_MAX(static_cast(j + 1), 1)); + jSliceList.push_back(static_cast(m_currentGridIdx)); - menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "I-slice Range Filter", iSliceList); - menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "J-slice Range Filter", jSliceList); - menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "K-slice Range Filter", kSliceList); + QVariantList kSliceList; + kSliceList.push_back(2); + kSliceList.push_back(CVF_MAX(static_cast(k + 1), 1)); + kSliceList.push_back(static_cast(m_currentGridIdx)); - menuBuilder.subMenuEnd(); - } + menuBuilder.subMenuStart("Range Filter Slice", QIcon(":/CellFilter_Range.png")); - menuBuilder << "RicEclipsePropertyFilterNewInViewFeature"; - menuBuilder << "RicGeoMechPropertyFilterNewInViewFeature"; + menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "I-slice Range Filter", iSliceList); + menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "J-slice Range Filter", jSliceList); + menuBuilder.addCmdFeatureWithUserData("RicNewSliceRangeFilterFeature", "K-slice Range Filter", kSliceList); - menuBuilder.addSeparator(); + menuBuilder.subMenuEnd(); + } - menuBuilder.subMenuStart("Intersections", QIcon(":/IntersectionXPlane16x16.png")); + menuBuilder << "RicEclipsePropertyFilterNewInViewFeature"; + menuBuilder << "RicGeoMechPropertyFilterNewInViewFeature"; - menuBuilder << "RicNewPolylineIntersectionFeature"; - menuBuilder << "RicNewAzimuthDipIntersectionFeature"; - menuBuilder << "RicIntersectionBoxAtPosFeature"; - - menuBuilder << "RicIntersectionBoxXSliceFeature"; - menuBuilder << "RicIntersectionBoxYSliceFeature"; - menuBuilder << "RicIntersectionBoxZSliceFeature"; + menuBuilder.addSeparator(); + + menuBuilder.subMenuStart("Intersections", QIcon(":/IntersectionXPlane16x16.png")); + + menuBuilder << "RicNewPolylineIntersectionFeature"; + menuBuilder << "RicNewAzimuthDipIntersectionFeature"; + menuBuilder << "RicIntersectionBoxAtPosFeature"; + + menuBuilder << "RicIntersectionBoxXSliceFeature"; + menuBuilder << "RicIntersectionBoxYSliceFeature"; + menuBuilder << "RicIntersectionBoxZSliceFeature"; + } menuBuilder.subMenuEnd(); @@ -295,10 +351,16 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) RimWellPath* wellPath = wellPathSourceInfo->wellPath(); if (wellPath) { - double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, m_currentPickPositionInDomainCoords); - cvf::Vec3d trueVerticalDepth = wellPathSourceInfo->trueVerticalDepth(firstPartTriangleIndex, globalIntersectionPoint); - RiuSelectionItem* selItem = new RiuWellPathSelectionItem(wellPathSourceInfo, trueVerticalDepth, measuredDepth); - RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); + if (firstPartTriangleIndex != cvf::UNDEFINED_UINT) + { + cvf::Vec3d pickedPositionInUTM = m_currentPickPositionInDomainCoords; + if (int2dView) pickedPositionInUTM = int2dView->transformToUtm(pickedPositionInUTM); + + double measuredDepth = wellPathSourceInfo->measuredDepth(firstPartTriangleIndex, pickedPositionInUTM); + cvf::Vec3d closestPointOnCenterLine = wellPathSourceInfo->closestPointOnCenterLine(firstPartTriangleIndex, pickedPositionInUTM); + RiuSelectionItem* selItem = new RiuWellPathSelectionItem(wellPathSourceInfo, closestPointOnCenterLine, measuredDepth); + RiuSelectionManager::instance()->setSelectedItem(selItem, RiuSelectionManager::RUI_TEMPORARY); + } //TODO: Update so these also use RiuWellPathSelectionItem caf::SelectionManager::instance()->setSelectedItem(wellPath); @@ -308,7 +370,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); - menuBuilder.subMenuStart("Well Plots", QIcon(":/SummaryPlot16x16.png")); + menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png")); menuBuilder << "RicNewRftPlotFeature"; menuBuilder << "RicNewPltPlotFeature"; @@ -321,11 +383,18 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); + menuBuilder.subMenuStart("3D Well Log Curves", QIcon(":/WellLogCurve16x16.png")); + + menuBuilder << "RicAdd3dWellLogCurveFeature"; + menuBuilder << "RicAdd3dWellLogFileCurveFeature"; + + menuBuilder.subMenuEnd(); + + menuBuilder.addSeparator(); + menuBuilder.subMenuStart("Completions", QIcon(":/FishBoneGroup16x16.png")); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewWellPathFractureAtPosFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewFishbonesSubsAtMeasuredDepthFeature"; menuBuilder << "RicNewPerforationIntervalAtMeasuredDepthFeature"; @@ -353,7 +422,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); - menuBuilder.subMenuStart("Well Plots", QIcon(":/SummaryPlot16x16.png")); + menuBuilder.subMenuStart("Well Plots", QIcon(":/WellLogTrack16x16.png")); menuBuilder << "RicNewRftPlotFeature"; menuBuilder << "RicNewPltPlotFeature"; @@ -368,9 +437,7 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) menuBuilder.addSeparator(); menuBuilder << "RicShowContributingWellsFeature"; menuBuilder.addSeparator(); -#ifdef USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder << "RicNewSimWellFractureAtPosFeature"; -#endif // USE_PROTOTYPE_FEATURE_FRACTURES menuBuilder.addSeparator(); menuBuilder << "RicNewSimWellIntersectionFeature"; } @@ -380,17 +447,31 @@ void RiuViewerCommands::displayContextMenu(QMouseEvent* event) // View Link commands if (!firstHitPart) { - menuBuilder << "RicLinkViewFeature"; - menuBuilder << "RicShowLinkOptionsFeature"; - menuBuilder << "RicSetMasterViewFeature"; - menuBuilder << "RicUnLinkViewFeature"; + if (gridView) + { + menuBuilder << "RicLinkViewFeature"; + menuBuilder << "RicShowLinkOptionsFeature"; + menuBuilder << "RicSetMasterViewFeature"; + menuBuilder << "RicUnLinkViewFeature"; + } + else if (int2dView) + { + menuBuilder << "RicSelectColorResult"; + } } - menuBuilder.addSeparator(); - menuBuilder << "RicNewGridTimeHistoryCurveFeature"; - menuBuilder << "RicShowFlowCharacteristicsPlotFeature"; - menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; - menuBuilder << "RicShowGridStatisticsFeature"; + if (gridView) + { + menuBuilder.addSeparator(); + menuBuilder << "RicNewGridTimeHistoryCurveFeature"; + menuBuilder << "RicShowFlowCharacteristicsPlotFeature"; + menuBuilder << "RicSaveEclipseInputActiveVisibleCellsFeature"; + menuBuilder << "RicShowGridStatisticsFeature"; + menuBuilder << "RicSelectColorResult"; + } + else if (int2dView) + { + } menuBuilder.appendToMenu(&menu); @@ -426,24 +507,31 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM // Extract all the above information from the pick { - cvf::Part* firstHitPart = nullptr; + const cvf::Part* firstHitPart = nullptr; uint firstPartTriangleIndex = cvf::UNDEFINED_UINT; - cvf::Part* firstNncHitPart = nullptr; + const cvf::Part* firstNncHitPart = nullptr; uint nncPartTriangleIndex = cvf::UNDEFINED_UINT; cvf::HitItemCollection hitItems; if (m_viewer->rayPick(winPosX, winPosY, &hitItems)) { - extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &firstHitPart, &firstPartTriangleIndex, &firstNncHitPart, &nncPartTriangleIndex); + std::vector> partAndTriangleIndexPairs; + extractIntersectionData(hitItems, &localIntersectionPoint, &globalIntersectionPoint, &partAndTriangleIndexPairs, &firstNncHitPart, &nncPartTriangleIndex); - cvf::ref eventObj = new RicViewerEventObject(globalIntersectionPoint, firstHitPart, firstPartTriangleIndex); - for (size_t i = 0; i < m_viewerEventHandlers.size(); i++) + if (!partAndTriangleIndexPairs.empty()) { - if (m_viewerEventHandlers[i]->handleEvent(eventObj.p())) + RicViewerEventObject viewerEventObject(globalIntersectionPoint, partAndTriangleIndexPairs, m_reservoirView); + for (size_t i = 0; i < m_viewerEventHandlers.size(); i++) { - return; + if (m_viewerEventHandlers[i]->handleEvent(viewerEventObject)) + { + return; + } } + + firstHitPart = partAndTriangleIndexPairs.front().first; + firstPartTriangleIndex = partAndTriangleIndexPairs.front().second; } } @@ -455,10 +543,60 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM const RivIntersectionSourceInfo* crossSectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); const RivSimWellPipeSourceInfo* eclipseWellSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + const RivWellConnectionSourceInfo* wellConnectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); if (rivObjectSourceInfo) { - RiuMainWindow::instance()->selectAsCurrentItem(rivObjectSourceInfo->object()); + RimFracture* fracture = dynamic_cast(rivObjectSourceInfo->object()); + + { + bool blockSelectionOfFracture = false; + if (fracture) + { + std::vector uiItems; + RiuMainWindow::instance()->projectTreeView()->selectedUiItems(uiItems); + + if (uiItems.size() == 1) + { + auto selectedFractureTemplate = dynamic_cast(uiItems[0]); + + if (selectedFractureTemplate != nullptr && selectedFractureTemplate == fracture->fractureTemplate()) + { + blockSelectionOfFracture = true; + } + } + } + + if (!blockSelectionOfFracture) + { + RiuMainWindow::instance()->selectAsCurrentItem(fracture); + } + } + + + RimStimPlanFractureTemplate* stimPlanTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; + RimEllipseFractureTemplate* ellipseTempl = fracture ? dynamic_cast(fracture->fractureTemplate()) : nullptr; + if (stimPlanTempl || ellipseTempl) + { + // Set fracture resultInfo text + QString resultInfoText; + + cvf::ref transForm = m_reservoirView->displayCoordTransform(); + cvf::Vec3d domainCoord = transForm->transformToDomainCoord(globalIntersectionPoint); + + RimEclipseView* eclView = dynamic_cast(m_reservoirView.p()); + RivWellFracturePartMgr* partMgr = fracture->fracturePartManager(); + if (eclView) resultInfoText = partMgr->resultInfoText(*eclView, domainCoord); + + // Set intersection point result text + QString intersectionPointText; + + intersectionPointText.sprintf("Intersection point : Global [E: %.2f, N: %.2f, Depth: %.2f]", domainCoord.x(), domainCoord.y(), -domainCoord.z()); + resultInfoText.append(intersectionPointText); + + // Display result info text + RiuMainWindow::instance()->setResultInfo(resultInfoText); + } } if (rivSourceInfo) @@ -485,8 +623,9 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM intersectionHit = true; intersectionTriangleHit = crossSectionSourceInfo->triangle(firstPartTriangleIndex); - RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection()); - + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + RiuMainWindow::instance()->selectAsCurrentItem(crossSectionSourceInfo->crossSection(), allowActiveViewChange); } else if (intersectionBoxSourceInfo) { @@ -499,7 +638,121 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM } else if (eclipseWellSourceInfo) { - RiuMainWindow::instance()->selectAsCurrentItem(eclipseWellSourceInfo->well()); + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + RiuMainWindow::instance()->selectAsCurrentItem(eclipseWellSourceInfo->well(), allowActiveViewChange); + } + else if (wellConnectionSourceInfo) + { + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + size_t globalCellIndex = wellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex); + + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RimEclipseCase* eclipseCase = nullptr; + eclipseView->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + if (eclipseCase->eclipseCaseData() && eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities()) + { + std::vector completionsForOneCell; + + { + auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities(); + size_t timeStep = eclipseView->currentTimeStep(); + + const auto& multipleCompletions = connectionFactors->multipleCompletionsPerEclipseCell(wellConnectionSourceInfo->wellPath(), timeStep); + + RigCompletionDataGridCell completionGridCell(globalCellIndex, eclipseCase->eclipseCaseData()->mainGrid()); + auto completionDataIt = multipleCompletions.find(completionGridCell); + if (completionDataIt != multipleCompletions.end()) + { + completionsForOneCell = completionDataIt->second; + } + } + + if (!completionsForOneCell.empty()) + { + double aggregatedConnectionFactor = 0.0; + for (const auto& completionData : completionsForOneCell) + { + aggregatedConnectionFactor += completionData.transmissibility(); + } + + QString resultInfoText; + resultInfoText += QString("Well Connection Factor : %1

").arg(aggregatedConnectionFactor); + + { + RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep()); + + resultInfoText += textBuilder.geometrySelectionText("
"); + } + + resultInfoText += "

Details :
"; + + for (const auto& completionData : completionsForOneCell) + { + for (const auto& metaData : completionData.metadata()) + { + resultInfoText += QString("Name %1 Description %2
").arg(metaData.name).arg(metaData.comment); + } + } + + RiuMainWindow::instance()->setResultInfo(resultInfoText); + } + } + } + + RiuMainWindow::instance()->selectAsCurrentItem(wellConnectionSourceInfo->wellPath(), allowActiveViewChange); + } + else if (dynamic_cast(firstHitPart->sourceInfo())) + { + const RivSimWellConnectionSourceInfo* simWellConnectionSourceInfo = dynamic_cast(firstHitPart->sourceInfo()); + + bool allowActiveViewChange = dynamic_cast(m_viewer->ownerViewWindow()) == nullptr; + + size_t globalCellIndex = simWellConnectionSourceInfo->globalCellIndexFromTriangleIndex(firstPartTriangleIndex); + double connectionFactor = simWellConnectionSourceInfo->connectionFactorFromTriangleIndex(firstPartTriangleIndex); + + RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + if (eclipseView) + { + RimEclipseCase* eclipseCase = nullptr; + eclipseView->firstAncestorOrThisOfTypeAsserted(eclipseCase); + + if (eclipseCase->eclipseCaseData() && + eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities()) + { + auto connectionFactors = eclipseCase->eclipseCaseData()->virtualPerforationTransmissibilities(); + size_t timeStep = eclipseView->currentTimeStep(); + + const auto& completionData = connectionFactors->completionsForSimWell(simWellConnectionSourceInfo->simWellInView()->simWellData(), timeStep); + + for (const auto& compData : completionData) + { + if (compData.completionDataGridCell().globalCellIndex() == globalCellIndex) + { + { + QString resultInfoText = QString("Simulation Well Connection Factor : %1

").arg(connectionFactor); + + { + RiuResultTextBuilder textBuilder(eclipseView, globalCellIndex, eclipseView->currentTimeStep()); + + resultInfoText += textBuilder.geometrySelectionText("
"); + } + + RiuMainWindow::instance()->setResultInfo(resultInfoText); + } + + break; + } + } + } + + } + + RiuMainWindow::instance()->selectAsCurrentItem(simWellConnectionSourceInfo->simWellInView(), allowActiveViewChange); } } @@ -542,27 +795,35 @@ void RiuViewerCommands::handlePickAction(int winPosX, int winPosY, Qt::KeyboardM RiuSelectionItem* selItem = nullptr; { + Rim2dIntersectionView* intersectionView = dynamic_cast(m_reservoirView.p()); RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); + + if (intersectionView) + { + intersectionView->intersection()->firstAncestorOrThisOfType(eclipseView); + intersectionView->intersection()->firstAncestorOrThisOfType(geomView); + } + if (eclipseView) { selItem = new RiuEclipseSelectionItem(eclipseView, gridIndex, cellIndex, nncIndex, curveColor, face, localIntersectionPoint); } - RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); - if (geomView ) + if (geomView) { if(intersectionHit) selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint, intersectionTriangleHit); else selItem = new RiuGeoMechSelectionItem(geomView, gridIndex, cellIndex, curveColor, gmFace, localIntersectionPoint); } - + if (intersectionView) selItem = new Riu2dIntersectionSelectionItem(intersectionView, selItem); } if (appendToSelection) { RiuSelectionManager::instance()->appendItemToSelection(selItem); } - else + else if(selItem) { RiuSelectionManager::instance()->setSelectedItem(selItem); } @@ -585,17 +846,20 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionSourceInfo* cr { CVF_ASSERT(cellIndex && gridIndex); - RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); - RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); - if (eclipseView) + RimCase* ownerCase = m_reservoirView->ownerCase(); + RimEclipseCase* eclipseCase = dynamic_cast(ownerCase); + RimGeoMechCase* geomCase = dynamic_cast(ownerCase); + if (eclipseCase) { - size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; + //RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); + RimEclipseView* eclipseView; + crossSectionSourceInfo->crossSection()->firstAncestorOrThisOfType(eclipseView); - const RigCell& cell = eclipseView->mainGrid()->globalCellArray()[globalCellIndex]; - *cellIndex = cell.gridLocalCellIndex(); - *gridIndex = cell.hostGrid()->gridIndex(); + size_t globalCellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; + const RigGridBase* hostGrid = eclipseView->mainGrid()->gridAndGridLocalIdxFromGlobalCellIdx(globalCellIndex, cellIndex); + *gridIndex = hostGrid->gridIndex(); } - else if (geomView) + else if (geomCase) { *cellIndex = crossSectionSourceInfo->triangleToCellIndex()[firstPartTriangleIndex]; *gridIndex = 0; @@ -627,13 +891,13 @@ void RiuViewerCommands::findCellAndGridIndex(const RivIntersectionBoxSourceInfo* } //-------------------------------------------------------------------------------------------------- -/// Perform picking and return the index of the face that was hit, if a drawable geo was hit +/// //-------------------------------------------------------------------------------------------------- void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hitItems, - cvf::Vec3d* localIntersectionPoint, - cvf::Vec3d* globalIntersectionPoint, - cvf::Part** firstPart, uint* firstPartFaceHit, - cvf::Part** nncPart, uint* nncPartFaceHit) + cvf::Vec3d* localIntersectionPoint, + cvf::Vec3d*globalIntersectionPoint, + std::vector>* partAndTriangleIndexPairs, + const cvf::Part** nncPart, uint* nncPartFaceHit) { CVF_ASSERT(hitItems.count() > 0); @@ -649,7 +913,7 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi } } - const cvf::HitItem* firstNonNncHitItem = nullptr; + size_t firstNonNncPartIndex = cvf::UNDEFINED_SIZE_T; cvf::Vec3d firstItemIntersectionPoint = hitItems.item(0)->intersectionPoint(); // Check if we have a close hit item with NNC data @@ -671,7 +935,10 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi // Hit items are ordered by distance from eye if (diff.lengthSquared() < pickDepthThresholdSquared) { - *nncPart = const_cast(pickedPartCandidate); + if (nncPart) + { + *nncPart = pickedPartCandidate; + } const cvf::HitDetailDrawableGeo* detail = dynamic_cast(hitItemCandidate->detail()); if (detail && nncPartFaceHit) @@ -684,58 +951,66 @@ void RiuViewerCommands::extractIntersectionData(const cvf::HitItemCollection& hi } } - if (!isNncpart && !firstNonNncHitItem) + if (!isNncpart && firstNonNncPartIndex == cvf::UNDEFINED_SIZE_T) { - firstNonNncHitItem = hitItemCandidate; - firstItemIntersectionPoint = firstNonNncHitItem->intersectionPoint(); + firstItemIntersectionPoint = hitItemCandidate->intersectionPoint(); + firstNonNncPartIndex = i; } - if (firstNonNncHitItem && *nncPart) + if (firstNonNncPartIndex != cvf::UNDEFINED_SIZE_T && nncPart && *nncPart) { break; } } - if (firstNonNncHitItem) + if (firstNonNncPartIndex != cvf::UNDEFINED_SIZE_T) { - const cvf::Part* pickedPart = firstNonNncHitItem->part(); - CVF_ASSERT(pickedPart); - *firstPart = const_cast(pickedPart); - - const cvf::Transform* xf = pickedPart->transform(); - cvf::Vec3d globalPickedPoint = firstNonNncHitItem->intersectionPoint(); - - if (globalIntersectionPoint) { - *globalIntersectionPoint = globalPickedPoint; - } + const cvf::HitItem* firstNonNncHitItem = hitItems.item(firstNonNncPartIndex); + const cvf::Part* pickedPart = firstNonNncHitItem->part(); + CVF_ASSERT(pickedPart); - if (localIntersectionPoint) - { - if (xf) + const cvf::Transform* xf = pickedPart->transform(); + const cvf::Vec3d& globalPickedPoint = firstNonNncHitItem->intersectionPoint(); + + if (globalIntersectionPoint) { - *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); + *globalIntersectionPoint = globalPickedPoint; } - else + + if (localIntersectionPoint) { - *localIntersectionPoint = globalPickedPoint; + if (xf) + { + *localIntersectionPoint = globalPickedPoint.getTransformedPoint(xf->worldTransform().getInverted()); + } + else + { + *localIntersectionPoint = globalPickedPoint; + } } } - if (firstPartFaceHit) + for (size_t i = firstNonNncPartIndex; i < hitItems.count(); i++) { - const cvf::HitDetailDrawableGeo* detail = dynamic_cast(firstNonNncHitItem->detail()); + const cvf::HitItem* hitItem = hitItems.item(i); + const cvf::Part* pickedPart = hitItem->part(); + + cvf::uint faceIndex = cvf::UNDEFINED_UINT; + const cvf::HitDetailDrawableGeo* detail = dynamic_cast(hitItem->detail()); if (detail) { - *firstPartFaceHit = detail->faceIndex(); + faceIndex = detail->faceIndex(); } + + partAndTriangleIndexPairs->push_back(std::make_pair(pickedPart, faceIndex)); } } else { if (localIntersectionPoint && nncPart && *nncPart) { - cvf::Vec3d globalPickedPoint = firstItemIntersectionPoint; + const cvf::Vec3d& globalPickedPoint = firstItemIntersectionPoint; if (globalIntersectionPoint) { @@ -770,7 +1045,7 @@ void RiuViewerCommands::ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size if (geomView && geomView->geoMechCase()) { - geomView->geoMechCase()->geoMechData()->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k); + geomView->femParts()->part(gridIdx)->structGrid()->ijkFromCellIndex(cellIndex, i, j, k); } } @@ -787,47 +1062,23 @@ bool RiuViewerCommands::handleOverlayItemPicking(int winPosX, int winPosY) if (pickedOverlayItem) { - caf::PdmObject* objToSelect = nullptr; - - RimEclipseView* eclipseView = dynamic_cast(m_reservoirView.p()); - if (eclipseView) + auto intersectionView = dynamic_cast(m_reservoirView.p()); + if (intersectionView && intersectionView->handleOverlayItemPicked(pickedOverlayItem)) { - if (eclipseView->cellResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->cellResult()->legendConfig(); - } - else if (eclipseView->cellResult()->ternaryLegendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->cellResult()->ternaryLegendConfig(); - } - else if (eclipseView->faultResultSettings()->customFaultResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->faultResultSettings()->customFaultResult()->legendConfig(); - } - else if (eclipseView->faultResultSettings()->customFaultResult()->ternaryLegendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->faultResultSettings()->customFaultResult()->ternaryLegendConfig(); - } - else if (eclipseView->cellEdgeResult()->legendConfig()->legend() == pickedOverlayItem) - { - objToSelect = eclipseView->cellEdgeResult()->legendConfig(); - } + return true; } - - RimGeoMechView* geomView = dynamic_cast(m_reservoirView.p()); - if (geomView) + else { - if (geomView->cellResult()->legendConfig()->legend() == pickedOverlayItem) + std::vector legendConfigs = m_reservoirView->legendConfigs(); + for (const auto& legendConfig : legendConfigs) { - objToSelect = geomView->cellResult()->legendConfig(); - } - } - - if (objToSelect) - { - RiuMainWindow::instance()->selectAsCurrentItem(objToSelect); + if (legendConfig && legendConfig->titledOverlayFrame() == pickedOverlayItem) + { + RiuMainWindow::instance()->selectAsCurrentItem(legendConfig); - return true; + return true; + } + } } } diff --git a/ApplicationCode/UserInterface/RiuViewerCommands.h b/ApplicationCode/UserInterface/RiuViewerCommands.h index 970cb7bf62..ae867ac110 100644 --- a/ApplicationCode/UserInterface/RiuViewerCommands.h +++ b/ApplicationCode/UserInterface/RiuViewerCommands.h @@ -29,7 +29,7 @@ class RicViewerEventInterface; class RimEclipseView; class RimGeoMechView; class RimIntersection; -class RimView; +class Rim3dView; class RiuViewer; class RivIntersectionBoxSourceInfo; class RivIntersectionSourceInfo; @@ -53,7 +53,7 @@ class RiuViewerCommands: public QObject explicit RiuViewerCommands(RiuViewer* ownerViewer); ~RiuViewerCommands(); - void setOwnerView(RimView * owner); + void setOwnerView(Rim3dView * owner); void displayContextMenu(QMouseEvent* event); void handlePickAction(int winPosX, int winPosY, Qt::KeyboardModifiers keyboardModifiers); @@ -64,20 +64,16 @@ class RiuViewerCommands: public QObject void findCellAndGridIndex(const RivIntersectionBoxSourceInfo* intersectionBoxSourceInfo, cvf::uint firstPartTriangleIndex, size_t* cellIndex, size_t* gridIndex); void ijkFromCellIndex(size_t gridIdx, size_t cellIndex, size_t* i, size_t* j, size_t* k); - void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, cvf::Part** firstPart, uint* firstPartFaceHit, cvf::Part** nncPart, uint* nncPartFaceHit); + void extractIntersectionData(const cvf::HitItemCollection& hitItems, cvf::Vec3d* localIntersectionPoint, cvf::Vec3d* globalIntersectionPoint, std::vector>* partAndTriangleIndexPairs, const cvf::Part** nncPart, uint* nncPartFaceHit); bool handleOverlayItemPicking(int winPosX, int winPosY); - size_t m_currentGridIdx; - size_t m_currentCellIndex; - cvf::StructGridInterface::FaceType m_currentFaceIndex; - cvf::Vec3d m_currentPickPositionInDomainCoords; - - caf::PdmPointer m_reservoirView; - - QPointer m_viewer; - +private: + size_t m_currentGridIdx; + size_t m_currentCellIndex; + cvf::StructGridInterface::FaceType m_currentFaceIndex; + cvf::Vec3d m_currentPickPositionInDomainCoords; + caf::PdmPointer m_reservoirView; + QPointer m_viewer; std::vector m_viewerEventHandlers; }; - - diff --git a/ApplicationCode/UserInterface/RiuViewerToViewInterface.h b/ApplicationCode/UserInterface/RiuViewerToViewInterface.h new file mode 100644 index 0000000000..a8980bc76b --- /dev/null +++ b/ApplicationCode/UserInterface/RiuViewerToViewInterface.h @@ -0,0 +1,66 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2017- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#pragma once + +#include "cvfBase.h" +#include "cvfObject.h" +#include "cvfColor3.h" +#include "cvfMatrix4.h" +#include "cvfVector3.h" + +#include + +class RimCase; +class RimViewLinker; +struct RimMdiWindowGeometry; +class RimViewController; + +namespace caf +{ + class PdmObjectHandle; + class DisplayCoordTransform; +} + + +class RiuViewerToViewInterface +{ +public: + virtual caf::PdmObjectHandle* implementingPdmObject() = 0; + + virtual void handleMdiWindowClosed() = 0; + virtual void setMdiWindowGeometry(const RimMdiWindowGeometry& windowGeometry) = 0; + + virtual void setCameraPosition(const cvf::Mat4d & cameraPosition) = 0; + virtual void setCameraPointOfInterest(const cvf::Vec3d& cameraPointOfInterest) = 0; + + virtual cvf::Color3f backgroundColor() const = 0; + virtual void selectOverlayInfoConfig() = 0; + + virtual RimViewLinker* assosiatedViewLinker() const = 0; + virtual RimViewController* viewController() const = 0; + + virtual QString timeStepName( int ) const = 0; + virtual cvf::ref displayCoordTransform() const = 0; + + virtual void setCurrentTimeStepAndUpdate(int frameIndex) = 0; + virtual void updateCurrentTimeStepAndRedraw() = 0; + virtual void updateLegends() = 0; + + virtual void endAnimation() = 0; +}; diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp index 2a9615f1ec..ecd47ffad5 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.cpp @@ -43,12 +43,12 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuWellAllocationPlot::RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) { Q_ASSERT(m_plotDefinition); - + QVBoxLayout* mainLayout = new QVBoxLayout(); this->setLayout(mainLayout); this->layout()->setMargin(0); diff --git a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h index 6fcee19707..52494bb749 100644 --- a/ApplicationCode/UserInterface/RiuWellAllocationPlot.h +++ b/ApplicationCode/UserInterface/RiuWellAllocationPlot.h @@ -45,7 +45,7 @@ class RiuWellAllocationPlot : public QFrame, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = NULL); + RiuWellAllocationPlot(RimWellAllocationPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellAllocationPlot(); RimWellAllocationPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp index 34a3f8484d..42c039695d 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.cpp @@ -46,7 +46,7 @@ /// //-------------------------------------------------------------------------------------------------- RiuWellLogPlot::RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent) - : QWidget(parent), m_scheduleUpdateChildrenLayoutTimer(NULL) + : QWidget(parent), m_scheduleUpdateChildrenLayoutTimer(nullptr) { Q_ASSERT(plotDefinition); m_plotDefinition = plotDefinition; @@ -136,7 +136,7 @@ void RiuWellLogPlot::removeTrackPlot(RiuWellLogTrack* trackPlot) CVF_ASSERT(trackIdx >= 0); m_trackPlots.removeAt(trackIdx); - trackPlot->setParent(NULL); + trackPlot->setParent(nullptr); QwtLegend* legend = m_legends[trackIdx]; m_legends.removeAt(trackIdx); diff --git a/ApplicationCode/UserInterface/RiuWellLogPlot.h b/ApplicationCode/UserInterface/RiuWellLogPlot.h index 8ef62c57a8..768bba563f 100644 --- a/ApplicationCode/UserInterface/RiuWellLogPlot.h +++ b/ApplicationCode/UserInterface/RiuWellLogPlot.h @@ -45,7 +45,7 @@ class RiuWellLogPlot : public QWidget, public RiuInterfaceToViewWindow Q_OBJECT public: - RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = NULL); + RiuWellLogPlot(RimWellLogPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellLogPlot(); RimWellLogPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp index e4f346fadf..8bf7946637 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.cpp +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.cpp @@ -25,7 +25,7 @@ #include "RimWellLogTrack.h" #include "RimWellLogCurve.h" -#include "RiuMainPlotWindow.h" +#include "RiuPlotMainWindowTools.h" #include "RiuQwtCurvePointTracker.h" #include "qwt_legend.h" @@ -196,7 +196,7 @@ bool RiuWellLogTrack::eventFilter(QObject* watched, QEvent* event) //-------------------------------------------------------------------------------------------------- void RiuWellLogTrack::selectClosestCurve(const QPoint& pos) { - QwtPlotCurve* closestCurve = NULL; + QwtPlotCurve* closestCurve = nullptr; double distMin = DBL_MAX; const QwtPlotItemList& itmList = itemList(); @@ -220,13 +220,15 @@ void RiuWellLogTrack::selectClosestCurve(const QPoint& pos) RimWellLogCurve* selectedCurve = m_plotTrackDefinition->curveDefinitionFromCurve(closestCurve); if (selectedCurve) { - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(selectedCurve); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(selectedCurve); return; } } - RiaApplication::instance()->getOrCreateAndShowMainPlotWindow()->selectAsCurrentItem(m_plotTrackDefinition); + RiuPlotMainWindowTools::showPlotMainWindow(); + RiuPlotMainWindowTools::selectAsCurrentItem(m_plotTrackDefinition); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationCode/UserInterface/RiuWellLogTrack.h b/ApplicationCode/UserInterface/RiuWellLogTrack.h index a97f8f3246..9be479e3d5 100644 --- a/ApplicationCode/UserInterface/RiuWellLogTrack.h +++ b/ApplicationCode/UserInterface/RiuWellLogTrack.h @@ -42,7 +42,7 @@ class RiuWellLogTrack : public QwtPlot Q_OBJECT public: - RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget* parent = NULL); + RiuWellLogTrack(RimWellLogTrack* plotTrackDefinition, QWidget* parent = nullptr); virtual ~RiuWellLogTrack(); void setDepthZoom(double minDepth, double maxDepth); diff --git a/ApplicationCode/UserInterface/RiuWellPltPlot.cpp b/ApplicationCode/UserInterface/RiuWellPltPlot.cpp index 222c9ea62c..defdd24b08 100644 --- a/ApplicationCode/UserInterface/RiuWellPltPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellPltPlot.cpp @@ -43,9 +43,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuWellPltPlot::RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) + { Q_ASSERT(m_plotDefinition); diff --git a/ApplicationCode/UserInterface/RiuWellPltPlot.h b/ApplicationCode/UserInterface/RiuWellPltPlot.h index f1281953d8..e571e1bf0b 100644 --- a/ApplicationCode/UserInterface/RiuWellPltPlot.h +++ b/ApplicationCode/UserInterface/RiuWellPltPlot.h @@ -45,7 +45,7 @@ class RiuWellPltPlot : public QFrame, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent = NULL); + RiuWellPltPlot(RimWellPltPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellPltPlot(); RimWellPltPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWellRftPlot.cpp b/ApplicationCode/UserInterface/RiuWellRftPlot.cpp index 37ad38f83b..c2a9d7c4e3 100644 --- a/ApplicationCode/UserInterface/RiuWellRftPlot.cpp +++ b/ApplicationCode/UserInterface/RiuWellRftPlot.cpp @@ -43,9 +43,10 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) - : m_plotDefinition(plotDefinition), - QFrame(parent) +RiuWellRftPlot::RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent) + : QFrame(parent) + , m_plotDefinition(plotDefinition) + { Q_ASSERT(m_plotDefinition); diff --git a/ApplicationCode/UserInterface/RiuWellRftPlot.h b/ApplicationCode/UserInterface/RiuWellRftPlot.h index ba23496a35..cf60df95f5 100644 --- a/ApplicationCode/UserInterface/RiuWellRftPlot.h +++ b/ApplicationCode/UserInterface/RiuWellRftPlot.h @@ -45,7 +45,7 @@ class RiuWellRftPlot : public QFrame, public RiuInterfaceToViewWindow { Q_OBJECT; public: - RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent = NULL); + RiuWellRftPlot(RimWellRftPlot* plotDefinition, QWidget* parent = nullptr); virtual ~RiuWellRftPlot(); RimWellRftPlot* ownerPlotDefinition(); diff --git a/ApplicationCode/UserInterface/RiuWidgetDragger.cpp b/ApplicationCode/UserInterface/RiuWidgetDragger.cpp new file mode 100644 index 0000000000..6b2d327178 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuWidgetDragger.cpp @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// + +#include "RiuWidgetDragger.h" +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiuWidgetDragger::RiuWidgetDragger(QWidget* widgetToMove) + : QObject(widgetToMove) + , m_widgetToMove(widgetToMove) + , m_startPos(0,0) +{ + m_widgetToMove->installEventFilter(this); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiuWidgetDragger::eventFilter(QObject * watched, QEvent * event) +{ + if (event->type() == QEvent::MouseMove) + { + QMouseEvent* mMoveEv = static_cast(event); + if (mMoveEv->buttons() & Qt::LeftButton) + { + m_widgetToMove->move( m_widgetToMove->mapToParent(mMoveEv->pos() - m_startPos)); + } + } + else if (event->type() == QEvent::MouseButtonPress) + { + QMouseEvent* mEv = static_cast(event); + m_startPos = mEv->pos(); + } + + return false; +} + diff --git a/ApplicationCode/UserInterface/RiuWidgetDragger.h b/ApplicationCode/UserInterface/RiuWidgetDragger.h new file mode 100644 index 0000000000..ea68299cd9 --- /dev/null +++ b/ApplicationCode/UserInterface/RiuWidgetDragger.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2018- Statoil ASA +// +// 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 +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include +#include +#include + +class QWidget; +class QEvent; + +class RiuWidgetDragger : public QObject +{ + Q_OBJECT +public: + RiuWidgetDragger(QWidget* widgetToMove); + + virtual bool eventFilter(QObject * watched, QEvent * event) override; + +private: + QPointer m_widgetToMove; + QPoint m_startPos; +}; + + diff --git a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt index 56cabdd553..acaa843178 100644 --- a/ApplicationCode/WellPathImportSsihub/CMakeLists.txt +++ b/ApplicationCode/WellPathImportSsihub/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (WellPathImportSsihub) @@ -11,7 +11,7 @@ set( QOBJECT_HEADERS set( QT_UI_FILES ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) qt4_wrap_ui( FORM_FILES_CPP ${QT_UI_FILES} ) endif() @@ -20,8 +20,6 @@ include_directories( ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../FileInterface - ${CMAKE_CURRENT_SOURCE_DIR}/../../Fwk/AppFwk/cafProjectDataModel - ${CMAKE_CURRENT_SOURCE_DIR}/../../Fwk/AppFwk/cafUserInterface ) @@ -43,3 +41,9 @@ add_library( ${PROJECT_NAME} ${FORM_FILES_CPP} ${HEADER_FILES} ) + +target_link_libraries ( ${PROJECT_NAME} + cafUserInterface cafPdmCvf CommonCode +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp b/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp index 544e47d2c0..dae33da0c2 100644 --- a/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp +++ b/ApplicationCode/WellPathImportSsihub/RimOilFieldEntry.cpp @@ -128,5 +128,5 @@ RimWellPathEntry* RimOilFieldEntry::find(const QString& name, RimWellPathEntry:: } } - return NULL; + return nullptr; } diff --git a/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp b/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp index 47e39f865a..19b00c39ae 100644 --- a/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp +++ b/ApplicationCode/WellPathImportSsihub/RimWellPathImport.cpp @@ -115,8 +115,8 @@ void RimWellPathImport::updateRegions(const QStringList& regionStrings, const QS for (int i = 0; i < regionStrings.size(); i++) { - RimOilRegionEntry* oilRegionEntry = NULL; - RimOilFieldEntry* oilFieldEntry = NULL; + RimOilRegionEntry* oilRegionEntry = nullptr; + RimOilFieldEntry* oilFieldEntry = nullptr; for (size_t regionIdx = 0; regionIdx < this->regions.size(); regionIdx++) { diff --git a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp index e44f32c6f5..9e5e7c66f0 100644 --- a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp +++ b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.cpp @@ -127,7 +127,7 @@ void RiuWellImportWizard::issueHttpRequestToFile(QString completeUrlText, QStrin tr("Unable to save the file %1: %2.") .arg(destinationFileName).arg(m_file->errorString())); delete m_file; - m_file = 0; + m_file = nullptr; return; } @@ -156,7 +156,7 @@ void RiuWellImportWizard::httpFinished() m_file->close(); m_file->remove(); delete m_file; - m_file = 0; + m_file = nullptr; } m_reply->deleteLater(); m_myProgressDialog->hide(); @@ -231,9 +231,9 @@ void RiuWellImportWizard::httpFinished() } m_reply->deleteLater(); - m_reply = 0; + m_reply = nullptr; delete m_file; - m_file = 0; + m_file = nullptr; if (m_currentDownloadState == DOWNLOAD_WELLS || m_currentDownloadState == DOWNLOAD_WELL_PATH) { @@ -446,7 +446,7 @@ void RiuWellImportWizard::downloadWellPaths() { WellSelectionPage* wellSelectionPage = dynamic_cast(page(m_wellSelectionPageId)); std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries(downloadEntities, NULL); + wellSelectionPage->selectedWellPathEntries(downloadEntities, nullptr); for (size_t i = 0; i < downloadEntities.size(); i++) { @@ -537,7 +537,7 @@ QStringList RiuWellImportWizard::absoluteFilePathsToWellPaths() const WellSelectionPage* wellSelectionPage = dynamic_cast(page(m_wellSelectionPageId)); std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries(downloadEntities, NULL); + wellSelectionPage->selectedWellPathEntries(downloadEntities, nullptr); for (size_t i = 0; i < downloadEntities.size(); i++) { @@ -787,7 +787,7 @@ void FieldSelectionPage::initializePage() //-------------------------------------------------------------------------------------------------- FieldSelectionPage::~FieldSelectionPage() { - m_propertyView->showProperties(NULL); + m_propertyView->showProperties(nullptr); } @@ -915,7 +915,7 @@ WellSelectionPage::~WellSelectionPage() { if (m_wellSelectionTreeView) { - m_wellSelectionTreeView->setPdmItem(NULL); + m_wellSelectionTreeView->setPdmItem(nullptr); } delete m_regionsWithVisibleWells; } @@ -926,7 +926,7 @@ WellSelectionPage::~WellSelectionPage() //-------------------------------------------------------------------------------------------------- void WellSelectionPage::selectedWellPathEntries(std::vector& downloadEntities, caf::PdmObjectHandle* objHandle) { - if (objHandle == NULL) + if (objHandle == nullptr) { objHandle = m_regionsWithVisibleWells; } @@ -968,8 +968,8 @@ void WellSelectionPage::selectedWellPathEntries(std::vector& dow //-------------------------------------------------------------------------------------------------- bool lessByDescription(const caf::PdmPointer& obj1, const caf::PdmPointer& obj2) { - caf::PdmUiFieldHandle* uiFieldHandle1 = NULL; - caf::PdmUiFieldHandle* uiFieldHandle2 = NULL; + caf::PdmUiFieldHandle* uiFieldHandle1 = nullptr; + caf::PdmUiFieldHandle* uiFieldHandle2 = nullptr; if (obj1.notNull() && obj1->uiCapability() && obj1->uiCapability()->userDescriptionField()) { @@ -1053,7 +1053,7 @@ void WellSummaryPage::updateSummaryPage() RiuWellImportWizard* wiz = dynamic_cast(wizard()); WellSelectionPage* wellSelectionPage = dynamic_cast(wiz->page(wiz->wellSelectionPageId())); std::vector downloadEntities; - wellSelectionPage->selectedWellPathEntries(downloadEntities, NULL); + wellSelectionPage->selectedWellPathEntries(downloadEntities, nullptr); for (size_t i = 0; i < downloadEntities.size(); i++) { diff --git a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h index 92043c5cf4..1fb9b20f6c 100644 --- a/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h +++ b/ApplicationCode/WellPathImportSsihub/RiuWellImportWizard.h @@ -57,7 +57,7 @@ class AuthenticationPage : public QWizardPage Q_OBJECT public: - AuthenticationPage(const QString& webServiceAddress, QWidget *parent = 0); + AuthenticationPage(const QString& webServiceAddress, QWidget *parent = nullptr); virtual void initializePage(); }; @@ -71,7 +71,7 @@ class FieldSelectionPage : public QWizardPage Q_OBJECT public: - FieldSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = 0); + FieldSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = nullptr); ~FieldSelectionPage(); virtual void initializePage(); @@ -127,7 +127,7 @@ class WellSelectionPage : public QWizardPage Q_OBJECT public: - WellSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = 0); + WellSelectionPage(RimWellPathImport* wellPathImport, QWidget* parent = nullptr); ~WellSelectionPage(); virtual void initializePage(); @@ -153,7 +153,7 @@ class WellSummaryPage : public QWizardPage Q_OBJECT public: - WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent = 0); + WellSummaryPage(RimWellPathImport* wellPathImport, QWidget* parent = nullptr); virtual void initializePage(); @@ -182,7 +182,7 @@ class RiuWellImportWizard : public QWizard enum DownloadState{ DOWNLOAD_FIELDS, DOWNLOAD_WELLS, DOWNLOAD_WELL_PATH, DOWNLOAD_UNDEFINED}; public: - RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = 0); + RiuWellImportWizard(const QString& webServiceAddress, const QString& downloadFolder, RimWellPathImport* wellPathImportObject, QWidget *parent = nullptr); ~RiuWellImportWizard(); void setCredentials(const QString& username, const QString& password); diff --git a/ApplicationCode/resinsight.desktop.in b/ApplicationCode/resinsight.desktop.in index 585886c3f8..f3d00769f0 100644 --- a/ApplicationCode/resinsight.desktop.in +++ b/ApplicationCode/resinsight.desktop.in @@ -4,7 +4,7 @@ Type=Application Terminal=false StartupNotify=true Icon=@CMAKE_INSTALL_PREFIX@/share/icons/hicolor/48x48/apps/ResInsight.png -ame=ResInsight +Name=ResInsight Comment=3D viewer and post processing tool for reservoir models Exec=@CMAKE_INSTALL_PREFIX@/bin/ResInsight Categories=Applications;Science; diff --git a/CMakeLists.txt b/CMakeLists.txt index b1df8eeada..85d449a798 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) include (CheckCSourceCompiles) project (ResInsight) @@ -278,29 +278,19 @@ list(APPEND THIRD_PARTY_LIBRARIES ) ################################################################################ -# Prototype feature Fractures +# Eigen ################################################################################ -option (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES "Enable prototype feature Fractures" ON) -mark_as_advanced(FORCE RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) +include_directories(SYSTEM ThirdParty/Eigen-Subset) -if (RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES) - - ################################################################################ - # Eigen - ################################################################################ - include_directories(SYSTEM ThirdParty/Eigen-Subset) - - ################################################################################ - # clipper - ################################################################################ - - add_subdirectory(ThirdParty/clipper) +################################################################################ +# clipper +################################################################################ - list(APPEND THIRD_PARTY_LIBRARIES - clipper - ) +add_subdirectory(ThirdParty/clipper) -endif() # RESINSIGHT_ENABLE_PROTOTYPE_FEATURE_FRACTURES +list(APPEND THIRD_PARTY_LIBRARIES + clipper +) ################################################################################ @@ -342,14 +332,6 @@ add_subdirectory(${VIZ_MODULES_FOLDER_NAME}/LibRender) add_subdirectory(${VIZ_MODULES_FOLDER_NAME}/LibViewing) add_subdirectory(${VIZ_MODULES_FOLDER_NAME}/LibGuiQt) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} -) - list(APPEND VIZ_FWK_LIBRARIES LibGuiQt LibViewing @@ -460,7 +442,7 @@ if(RESINSIGHT_BUILD_DOCUMENTATION) configure_file(Doxyfile.in ${PROJECT_BINARY_DIR}/Doxyfile @ONLY IMMEDIATE) #-- Add a custom target to run Doxygen when ever the project is built - add_custom_target (Docs ALL + add_custom_target (Docs COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/Doxyfile SOURCES ${PROJECT_BINARY_DIR}/Doxyfile) # IF you do NOT want the documentation to be generated EVERY time you build the project diff --git a/Fwk/AppFwk/CMakeLists.txt b/Fwk/AppFwk/CMakeLists.txt index dc4851c78f..0bec5a502b 100644 --- a/Fwk/AppFwk/CMakeLists.txt +++ b/Fwk/AppFwk/CMakeLists.txt @@ -2,6 +2,12 @@ cmake_minimum_required (VERSION 2.8) project (CeeApp) +if (MSVC AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 19.11)) + # VS 2017 : Disable warnings from from gtest code, using deprecated code related to TR1 + add_definitions(-D_SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING) + message("Add flag to disable warings from gtest - _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING") +endif() + find_package (Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl REQUIRED) include (${QT_USE_FILE}) diff --git a/Fwk/AppFwk/CommonCode/CMakeLists.txt b/Fwk/AppFwk/CommonCode/CMakeLists.txt index ec5a12cd61..52e5193f4d 100644 --- a/Fwk/AppFwk/CommonCode/CMakeLists.txt +++ b/Fwk/AppFwk/CommonCode/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (CommonCode) @@ -9,16 +9,6 @@ include (${QT_USE_FILE}) # Open GL find_package( OpenGL ) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - - ${cafPdmCore_SOURCE_DIR} -) - # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS cafMessagePanel.h @@ -54,3 +44,22 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibViewing + LibRender + LibGuiQt + + cafPdmCore + + ${QT_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/CommonCode/cafEffectCache.cpp b/Fwk/AppFwk/CommonCode/cafEffectCache.cpp index 18bf9e7986..64f33b3e10 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectCache.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectCache.cpp @@ -90,7 +90,7 @@ cvf::Effect* EffectCache::findEffect(const EffectGenerator* generator) } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -128,7 +128,7 @@ void EffectCache::releaseUnreferencedEffects() { if (m_effectCache[i].second.p()->refCount() <= 1 ) { - m_effectCache[i].second = NULL; + m_effectCache[i].second = nullptr; delete m_effectCache[i].first; m_effectCache[i].first = NULL; } diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp index 4916b004a5..f07976e1c7 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.cpp @@ -43,6 +43,7 @@ #include "cvfMatrixState.h" #include "cvfRenderState_FF.h" #include "cvfRenderStateBlending.h" +#include "cvfRenderStateColorMask.h" #include "cvfRenderStateCullFace.h" #include "cvfRenderStateDepth.h" #include "cvfRenderStateLine.h" @@ -214,13 +215,13 @@ cvf::ref EffectGenerator::generateUnCachedEffect() const //-------------------------------------------------------------------------------------------------- void EffectGenerator::updateEffect(cvf::Effect* effect) const { - CVF_ASSERT(effect != NULL); + CVF_ASSERT(effect != nullptr); // Clear effect - effect->setRenderStateSet(NULL); - effect->setUniformSet(NULL); - effect->setShaderProgram(NULL); + effect->setRenderStateSet(nullptr); + effect->setUniformSet(nullptr); + effect->setShaderProgram(nullptr); if (sm_renderingMode == SHADER_BASED) { @@ -259,9 +260,13 @@ void EffectGenerator::releaseUnreferencedEffects() //-------------------------------------------------------------------------------------------------- SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color4f& color, PolygonOffset polygonOffset) { + CVF_ASSERT(color.isValid()); + m_color = color; m_polygonOffset = polygonOffset; m_cullBackfaces = FC_NONE; + m_enableColorMask = true; + m_enableDepthTest = true; m_enableDepthWrite = true; m_enableLighting = true; } @@ -271,14 +276,17 @@ SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color4f& color, Polygo //-------------------------------------------------------------------------------------------------- SurfaceEffectGenerator::SurfaceEffectGenerator(const cvf::Color3f& color, PolygonOffset polygonOffset) { + CVF_ASSERT(color.isValid()); + m_color = cvf::Color4f(color, 1.0f); m_polygonOffset = polygonOffset; m_cullBackfaces = FC_NONE; + m_enableColorMask = true; + m_enableDepthTest = true; m_enableDepthWrite = true; m_enableLighting = true; } - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -369,10 +377,17 @@ void SurfaceEffectGenerator::updateCommonEffect(cvf::Effect* effect) const effect->setRenderState(faceCulling.p()); } - if (!m_enableDepthWrite) + if (!m_enableColorMask) + { + cvf::ref color = new cvf::RenderStateColorMask(m_enableColorMask); + effect->setRenderState(color.p()); + } + + if (!m_enableDepthTest || !m_enableDepthWrite) { cvf::ref depth = new cvf::RenderStateDepth; - depth->enableDepthWrite(false); + depth->enableDepthTest(m_enableDepthTest); + depth->enableDepthWrite(m_enableDepthWrite); effect->setRenderState(depth.p()); } } @@ -386,11 +401,13 @@ bool SurfaceEffectGenerator::isEqual(const EffectGenerator* other) const if (otherSurfaceEffect) { - if (m_color == otherSurfaceEffect->m_color + if (m_color == otherSurfaceEffect->m_color && m_polygonOffset == otherSurfaceEffect->m_polygonOffset + && m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces + && m_enableColorMask == otherSurfaceEffect->m_enableColorMask + && m_enableDepthTest == otherSurfaceEffect->m_enableDepthTest && m_enableDepthWrite == otherSurfaceEffect->m_enableDepthWrite - && m_enableLighting == otherSurfaceEffect->m_enableLighting - && m_cullBackfaces == otherSurfaceEffect->m_cullBackfaces) + && m_enableLighting == otherSurfaceEffect->m_enableLighting) { return true; } @@ -406,6 +423,8 @@ EffectGenerator* SurfaceEffectGenerator::copy() const { SurfaceEffectGenerator* effGen = new SurfaceEffectGenerator(m_color, m_polygonOffset); effGen->m_cullBackfaces = m_cullBackfaces; + effGen->m_enableColorMask = m_enableColorMask; + effGen->m_enableDepthTest = m_enableDepthTest; effGen->m_enableDepthWrite = m_enableDepthWrite; effGen->m_enableLighting = m_enableLighting; return effGen; @@ -629,7 +648,7 @@ EffectGenerator* ScalarMapperEffectGenerator::copy() const cvf::ref ScalarMapperEffectGenerator::addAlphaAndUndefStripes(const cvf::TextureImage* texImg, const cvf::Color3f& undefScalarColor, float opacityLevel) { - CVF_ASSERT(texImg != NULL); + CVF_ASSERT(texImg != nullptr); CVF_ASSERT(texImg->height() == 1); cvf::ref modTexImg = new cvf::TextureImage; @@ -655,9 +674,9 @@ ScalarMapperEffectGenerator::addAlphaAndUndefStripes(const cvf::TextureImage* te //-------------------------------------------------------------------------------------------------- bool ScalarMapperEffectGenerator::isImagesEqual(const cvf::TextureImage* texImg1, const cvf::TextureImage* texImg2) { - if (texImg1 == NULL && texImg2 == NULL ) return true; + if (texImg1 == nullptr && texImg2 == nullptr ) return true; - if ( texImg1 != NULL && texImg2 != NULL + if ( texImg1 != nullptr && texImg2 != nullptr && texImg1->height() == texImg2->height() && texImg1->width() == texImg2->width() && texImg1->width() > 0 && texImg1->height() > 0 @@ -987,4 +1006,58 @@ void TextEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) c } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +VectorEffectGenerator::VectorEffectGenerator() +{ + +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool VectorEffectGenerator::isEqual(const EffectGenerator* other) const +{ + const VectorEffectGenerator* otherSurfaceEffect = dynamic_cast(other); + if (otherSurfaceEffect) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +EffectGenerator* VectorEffectGenerator::copy() const +{ + VectorEffectGenerator* effGen = new VectorEffectGenerator; + + return effGen; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void VectorEffectGenerator::updateForShaderBasedRendering(cvf::Effect* effect) const +{ + cvf::ShaderProgramGenerator gen("VectorDrawerShaderProgram", cvf::ShaderSourceProvider::instance()); + gen.addVertexCode(cvf::ShaderSourceRepository::vs_VectorDrawer); + gen.addFragmentCode(cvf::ShaderSourceRepository::fs_VectorDrawer); + + cvf::ref shaderProg = gen.generate(); + shaderProg->disableUniformTrackingForUniform("u_transformationMatrix"); + shaderProg->disableUniformTrackingForUniform("u_color"); + + cvf::ref eff = effect; + eff->setShaderProgram(shaderProg.p()); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void VectorEffectGenerator::updateForFixedFunctionRendering(cvf::Effect* effect) const {} + } // End namespace caf diff --git a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h index 48768cdefc..4ed3278d02 100644 --- a/Fwk/AppFwk/CommonCode/cafEffectGenerator.h +++ b/Fwk/AppFwk/CommonCode/cafEffectGenerator.h @@ -134,6 +134,9 @@ class SurfaceEffectGenerator : public EffectGenerator SurfaceEffectGenerator(const cvf::Color3f& color, PolygonOffset polygonOffset); void setCullBackfaces(FaceCulling cullBackFaces) { m_cullBackfaces = cullBackFaces; } + + void enableColorMask(bool enableColors) { m_enableColorMask = enableColors; } + void enableDepthTest(bool enableTest) { m_enableDepthTest = enableTest; } void enableDepthWrite(bool enableWrite) { m_enableDepthWrite = enableWrite; } void enableLighting(bool enableLighting) { m_enableLighting = enableLighting; } @@ -151,6 +154,8 @@ class SurfaceEffectGenerator : public EffectGenerator cvf::Color4f m_color; PolygonOffset m_polygonOffset; FaceCulling m_cullBackfaces; + bool m_enableColorMask; + bool m_enableDepthTest; bool m_enableDepthWrite; bool m_enableLighting; }; @@ -276,4 +281,21 @@ class TextEffectGenerator : public EffectGenerator }; +//================================================================================================== +// +// VectorEffectGenerator +// +//================================================================================================== +class VectorEffectGenerator : public EffectGenerator +{ +public: + VectorEffectGenerator(); + +protected: + virtual bool isEqual(const EffectGenerator* other) const; + virtual EffectGenerator* copy() const; + + virtual void updateForShaderBasedRendering(cvf::Effect* effect) const; + virtual void updateForFixedFunctionRendering(cvf::Effect* effect) const; +}; } diff --git a/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp b/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp index 53a8ea9725..b6945ef7da 100644 --- a/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp +++ b/Fwk/AppFwk/CommonCode/cafMessagePanel.cpp @@ -45,7 +45,7 @@ namespace caf { -MessagePanel* MessagePanel::sm_messagePanelInstance = NULL; +MessagePanel* MessagePanel::sm_messagePanelInstance = nullptr; //================================================================================================== /// diff --git a/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h b/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h new file mode 100644 index 0000000000..4427334f98 --- /dev/null +++ b/Fwk/AppFwk/CommonCode/cafTickMarkGenerator.h @@ -0,0 +1,134 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## +#pragma once + + +#include +#include +#include "cafAssert.h" + +namespace caf +{ +class TickMarkGenerator +{ +public: + TickMarkGenerator(double min, double max, double minAllowedStepSize) + { + if (minAllowedStepSize < 0.0) minAllowedStepSize = -minAllowedStepSize; + + double step = roundUpToLog_1_2_5_10(minAllowedStepSize); + + double startStepCount = ceil(min / step); + + if ( startStepCount*step < (min + 0.5*minAllowedStepSize) ) + { + ++startStepCount; + } + + double tick = startStepCount*step; + double currentStepCount = startStepCount; + while ( tick < (max - 0.5*minAllowedStepSize) ) + { + m_tickMarkValues.push_back(tick); + ++currentStepCount; + tick = currentStepCount*step; + } + } + + const std::vector& tickMarkValues() { return m_tickMarkValues; } + + static double roundUpToLog_1_2_5_10(double val) + { + CAF_ASSERT(val >= 0.0); + + const static double logOf5 = log10(5.0); + const static double logOf2 = log10(2.0); + const static double logOf0_5 = log10(0.5); + const static double logOf0_2 = log10(0.2); + + double logValue = log10(val); + double intPart = 0.0; + double fraction = modf(logValue, &intPart); + + double factor = 1.0; + + if (fraction == 0.0) + { + factor = 1.0; + } + else if (fraction > 0.0) + { + if ( fraction > logOf5 ) + { + factor = 10.0; + } + else if ( fraction > logOf2 ) + { + factor = 5.0; + } + else + { + factor = 2.0; + } + } + else + { + if (fraction > logOf0_5) + { + factor = 1; + } + else if ( fraction > logOf0_2 ) + { + factor = 0.5; + } + else + { + factor = 0.2; + } + } + + double roundedValue = pow(10.0, intPart) * factor; + + return roundedValue; + } + +private: + std::vector m_tickMarkValues; +}; + +} + + diff --git a/Fwk/AppFwk/CommonCode/cafUtils.cpp b/Fwk/AppFwk/CommonCode/cafUtils.cpp index 10821837de..4922396a6c 100644 --- a/Fwk/AppFwk/CommonCode/cafUtils.cpp +++ b/Fwk/AppFwk/CommonCode/cafUtils.cpp @@ -170,7 +170,7 @@ QString Utils::indentString(int numSpacesToIndent, const QString& str) bool Utils::getSaveDirectoryAndCheckOverwriteFiles(const QString& defaultDir, std::vector fileNames, QString* saveDir) { bool overWriteFiles = false; - (*saveDir) = QFileDialog::getExistingDirectory(NULL, "Select save directory", defaultDir); + (*saveDir) = QFileDialog::getExistingDirectory(nullptr, "Select save directory", defaultDir); std::vector filesToOverwrite; for (QString fileName : fileNames) diff --git a/Fwk/AppFwk/CommonCode/cafVecIjk.cpp b/Fwk/AppFwk/CommonCode/cafVecIjk.cpp index 16d60de3b4..38c39cfc61 100644 --- a/Fwk/AppFwk/CommonCode/cafVecIjk.cpp +++ b/Fwk/AppFwk/CommonCode/cafVecIjk.cpp @@ -43,7 +43,7 @@ namespace caf { //-------------------------------------------------------------------------------------------------- VecIjk::VecIjk(size_t i, size_t j, size_t k) { - m_values = { i, j, k }; + m_values = { {i, j, k} }; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp b/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp index 708e3ad558..7e82ed2c93 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGrid.cpp @@ -198,6 +198,8 @@ void StructGridInterface::neighborIJKAtCellFace(size_t i, size_t j, size_t k, Fa case NEG_J : if (j > 0) (*nj)--; else (*nj) = cvf::UNDEFINED_SIZE_T; break; case POS_K : (*nk)++; break; case NEG_K : if (k > 0) (*nk)--; else (*nk) = cvf::UNDEFINED_SIZE_T; break; + default: + break; } } diff --git a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp index 7a724cd464..5f8e01e014 100644 --- a/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp +++ b/Fwk/AppFwk/CommonCode/cvfStructGridGeometryGenerator.cpp @@ -191,7 +191,7 @@ ref StructGridGeometryGenerator::generateSurface() CVF_ASSERT(m_vertices.notNull()); - if (m_vertices->size() == 0) return NULL; + if (m_vertices->size() == 0) return nullptr; ref geo = new DrawableGeo; geo->setFromQuadVertexArray(m_vertices.p()); @@ -208,7 +208,7 @@ ref StructGridGeometryGenerator::generateSurface() ref StructGridGeometryGenerator::createMeshDrawable() { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(m_vertices.p()); @@ -228,7 +228,7 @@ ref StructGridGeometryGenerator::createMeshDrawable() //-------------------------------------------------------------------------------------------------- ref StructGridGeometryGenerator::createOutlineMeshDrawable(double creaseAngle) { - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::OutlineEdgeExtractor ee(creaseAngle, *m_vertices); @@ -238,7 +238,7 @@ ref StructGridGeometryGenerator::createOutlineMeshDrawable(double c ref lineIndices = ee.lineIndices(); if (lineIndices->size() == 0) { - return NULL; + return nullptr; } ref prim = new PrimitiveSetIndexedUInt(PT_LINES); @@ -279,7 +279,7 @@ ref StructGridGeometryGenerator::createMeshDrawableFromSingleCell(c cvf::ref cvfVertices = new cvf::Vec3fArray; cvfVertices->assign(vertices); - if (!(cvfVertices.notNull() && cvfVertices->size() != 0)) return NULL; + if (!(cvfVertices.notNull() && cvfVertices->size() != 0)) return nullptr; ref geo = new DrawableGeo; geo->setVertexArray(cvfVertices.p()); diff --git a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt index fa400a77e2..4a4b41bffe 100644 --- a/Fwk/AppFwk/cafAnimControl/CMakeLists.txt +++ b/Fwk/AppFwk/cafAnimControl/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafAnimControl) @@ -11,7 +11,7 @@ set( QOBJECT_HEADERS cafAnimationToolBar.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -30,8 +30,21 @@ set( QRC_FILES PARENT_SCOPE ) -add_library( ${PROJECT_NAME} +set( PROJECT_FILES + cafFrameAnimationControl.h cafFrameAnimationControl.cpp + cafAnimationToolBar.h cafAnimationToolBar.cpp +) + +add_library( ${PROJECT_NAME} + ${PROJECT_FILES} ${MOC_FILES_CPP} ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc b/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc index e245321471..f599c5919c 100644 --- a/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc +++ b/Fwk/AppFwk/cafAnimControl/Resources/cafAnimControl.qrc @@ -1,16 +1,16 @@ - Play.png - Stop.png - Pause.png - StepFwd.png - StepBwd.png - SkipToEnd.png - SkipToStart.png - RepeatFromStart.png - RepeatFwdBwd.png - PlayBwd.png - Slow.png - Fast.png - + Play.png + Stop.png + Pause.png + StepFwd.png + StepBwd.png + SkipToEnd.png + SkipToStart.png + RepeatFromStart.png + RepeatFwdBwd.png + PlayBwd.png + Slow.png + Fast.png + diff --git a/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h b/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h index 208a0dac78..8f15eb0d15 100644 --- a/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h +++ b/Fwk/AppFwk/cafAnimControl/cafAnimationToolBar.h @@ -58,8 +58,8 @@ class AnimationToolBar : public QToolBar Q_OBJECT public: - explicit AnimationToolBar(QWidget *parent = 0); - AnimationToolBar(const QString &title, QWidget *parent = 0); + explicit AnimationToolBar(QWidget *parent = nullptr); + AnimationToolBar(const QString &title, QWidget *parent = nullptr); void connectAnimationControl(caf::FrameAnimationControl* animationControl); diff --git a/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h b/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h index a180548f68..5f8422ccdd 100644 --- a/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h +++ b/Fwk/AppFwk/cafAnimControl/cafFrameAnimationControl.h @@ -53,7 +53,7 @@ class FrameAnimationControl : public QObject Q_OBJECT public: - explicit FrameAnimationControl(QObject* parent = 0); + explicit FrameAnimationControl(QObject* parent = nullptr); void setNumFrames(int numFrames); int numFrames() const; diff --git a/Fwk/AppFwk/cafCommand/CMakeLists.txt b/Fwk/AppFwk/cafCommand/CMakeLists.txt index c0dcef9c9b..4ebb3c9fed 100644 --- a/Fwk/AppFwk/cafCommand/CMakeLists.txt +++ b/Fwk/AppFwk/cafCommand/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Qt find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) @@ -6,16 +6,6 @@ include (${QT_USE_FILE}) project (cafCommand) -include_directories( - ${cafProjectDataModel_SOURCE_DIR} -) - -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - . -) # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS @@ -23,7 +13,7 @@ set( QOBJECT_HEADERS cafCmdFeatureManager.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -71,4 +61,13 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + cafProjectDataModel +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp b/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp index a62872d559..2c7ae60011 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdExecCommandManager.cpp @@ -92,7 +92,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- CmdExecCommandManager::CmdExecCommandManager() { - m_commandFeatureInterface = NULL; + m_commandFeatureInterface = nullptr; m_undoStack = new QUndoStack(); } @@ -124,7 +124,7 @@ void CmdExecCommandManager::activateCommandSystem() //-------------------------------------------------------------------------------------------------- void CmdExecCommandManager::deactivateCommandSystem() { - PdmUiCommandSystemProxy::instance()->setCommandInterface(NULL); + PdmUiCommandSystemProxy::instance()->setCommandInterface(nullptr); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp index 33c50f3a7e..5eaa86f56f 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeature.cpp @@ -84,7 +84,7 @@ QAction* CmdFeature::actionWithCustomText(const QString& customText) //-------------------------------------------------------------------------------------------------- QAction* CmdFeature::actionWithUserData(const QString& customText, const QVariant& userData) { - QAction* action = NULL; + QAction* action = nullptr; std::map::iterator it; it = m_customTextToActionMap.find(customText); diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp index 0758645d05..d90c1cad7a 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureManager.cpp @@ -170,7 +170,7 @@ std::pair CmdFeatureManager::findExistingCmdFeature(const } else { - return std::make_pair(static_cast(NULL), -1); + return std::make_pair(static_cast(nullptr), -1); } } @@ -191,7 +191,7 @@ caf::CmdFeature* CmdFeatureManager::commandFeature(const std::string& commandId) return item; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp index d3e2483db8..fbd46bdb02 100644 --- a/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp +++ b/Fwk/AppFwk/cafCommand/cafCmdFeatureMenuBuilder.cpp @@ -164,7 +164,21 @@ void CmdFeatureMenuBuilder::appendToMenu(QMenu* menu) { if (menus.size() > 1) { + QMenu* completeSubMenu = menus.back(); menus.pop_back(); + + if (!menus.empty()) + { + // Remove the sub menu action if no (sub) actions are present in the sub menu + if (completeSubMenu->actions().isEmpty()) + { + QMenu* menuWithEmptySubMenu = menus.back(); + + QAction* subMenuAction = completeSubMenu->menuAction(); + + menuWithEmptySubMenu->removeAction(subMenuAction); + } + } } } else @@ -188,13 +202,18 @@ void CmdFeatureMenuBuilder::appendToMenu(QMenu* menu) CAF_ASSERT(act); + bool duplicateAct = false; for (QAction* existingAct : currentMenu->actions()) { // If action exist, continue to make sure the action is positioned at the first // location of a command ID if (existingAct == act) - continue; + { + duplicateAct = true; + break; + } } + if (duplicateAct) continue; currentMenu->addAction(const_cast(act)); } diff --git a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp index 031209f85e..b7a006c650 100644 --- a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp +++ b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdAddItemFeature.cpp @@ -65,7 +65,7 @@ namespace caf CmdExecuteCommand* CmdAddItemFeature::createExecuteCommand() { caf::PdmChildArrayFieldHandle* childArrayFieldHandle = SelectionManager::instance()->activeChildArrayFieldHandle(); - if (!childArrayFieldHandle) return NULL; + if (!childArrayFieldHandle) return nullptr; int indexAfter = -1; CmdAddItemExec* addItemExec = new CmdAddItemExec(SelectionManager::instance()->notificationCenter()); diff --git a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp index c3731af51e..09ae65ca65 100644 --- a/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp +++ b/Fwk/AppFwk/cafCommand/defaultfeatures/cafCmdDeleteItemFeature.cpp @@ -61,9 +61,9 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() SelectionManager::instance()->selectedItems(items, SelectionManager::CURRENT); caf::PdmChildArrayFieldHandle* childArrayFieldHandle = caf::SelectionManager::instance()->activeChildArrayFieldHandle(); - if (!childArrayFieldHandle) return NULL; + if (!childArrayFieldHandle) return nullptr; - caf::PdmObjectHandle* currentPdmObject = NULL; + caf::PdmObjectHandle* currentPdmObject = nullptr; for (size_t i = 0; i < items.size(); i++) { @@ -73,7 +73,7 @@ CmdExecuteCommand* CmdDeleteItemFeature::createExecuteCommand() } } - if (!currentPdmObject) return NULL; + if (!currentPdmObject) return nullptr; int indexAfter = -1; diff --git a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt index 6be4d2ef14..bafd45477d 100644 --- a/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt +++ b/Fwk/AppFwk/cafPdmCvf/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafPdmCvf) @@ -6,16 +6,6 @@ project (cafPdmCvf) find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) include (${QT_USE_FILE}) -include_directories( - ${LibCore_SOURCE_DIR} - ${cafProjectDataModel_SOURCE_DIR} - ${cafUserInterface_SOURCE_DIR} - - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} -) - - add_library( ${PROJECT_NAME} cafPdmCoreColor3f.h cafPdmUiCoreColor3f.cpp @@ -39,11 +29,15 @@ add_library( ${PROJECT_NAME} cafPdmFieldCvfMat4d.h ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries ( ${PROJECT_NAME} - cafPdmCore - cafPdmUiCore cafUserInterface - cafProjectDataModel LibCore ${QT_LIBRARIES} ) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt index 7e451984f4..aab257286e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/CMakeLists.txt @@ -6,12 +6,6 @@ project (cafProjectDataModel) find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} -) - set( PROJECT_FILES cafFactory.h cafFixedArray.h @@ -28,4 +22,14 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +target_link_libraries ( ${PROJECT_NAME} + cafPdmUiCore + cafPdmXml +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt index 1108fc67e8..40e8db36b0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafPdmCore) @@ -6,9 +6,6 @@ project (cafPdmCore) find_package ( Qt4 COMPONENTS QtCore ) include (${QT_USE_FILE}) -include_directories ( -) - set( PROJECT_FILES cafAssert.h @@ -39,17 +36,24 @@ set( PROJECT_FILES cafPdmReferenceHelper.h cafPdmUiFieldHandleInterface.h cafPdmValueField.h + cafInternalPdmValueFieldSpecializations.h cafNotificationCenter.cpp cafNotificationCenter.h cafTristate.cpp cafTristate.h + cafFilePath.cpp + cafFilePath.h ) - add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp new file mode 100644 index 0000000000..b95a274108 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.cpp @@ -0,0 +1,79 @@ +#include "cafFilePath.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::FilePath::FilePath() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::FilePath::FilePath(const QString& filePath) : m_filePath(filePath) {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString caf::FilePath::path() const +{ + return m_filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::FilePath::setPath(const QString& filePath) +{ + m_filePath = filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void caf::FilePath::operator=(const FilePath& other) +{ + m_filePath = other.m_filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool caf::FilePath::operator==(const FilePath& other) const +{ + return m_filePath == other.m_filePath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator>>(QTextStream& str, caf::FilePath& filePath) +{ + QString text; + + while (str.status() == QTextStream::Ok) + { + // Read QChar to avoid white space trimming when reading QString + QChar singleChar; + str >> singleChar; + + if (!singleChar.isNull()) + { + text += singleChar; + } + } + + filePath.setPath(text); + + return str; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator<<(QTextStream& str, const caf::FilePath& filePath) +{ + str << filePath.path(); + + return str; +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h new file mode 100644 index 0000000000..e859bfe079 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafFilePath.h @@ -0,0 +1,36 @@ +#pragma once + +#include + +class QTextStream; + +namespace caf +{ +//================================================================================================== +// +//================================================================================================== +class FilePath +{ +public: + FilePath(); + FilePath(const QString& filePath); + + QString path() const; + void setPath(const QString& valueText); + + void operator=(const FilePath& other); + bool operator==(const FilePath& other) const; + +private: + QString m_filePath; +}; + +} // end namespace caf + +//================================================================================================== +// Overload of QTextStream +//================================================================================================== +QTextStream& operator>>(QTextStream& str, caf::FilePath& filePath); +QTextStream& operator<<(QTextStream& str, const caf::FilePath& filePath); + +Q_DECLARE_METATYPE(caf::FilePath); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h index 5aa3878e38..8aef1f8988 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafInternalPdmValueFieldSpecializations.h @@ -1,6 +1,7 @@ #pragma once #include "cafAppEnum.h" +#include "cafFilePath.h" #include "cafPdmPointer.h" #include @@ -141,4 +142,27 @@ class PdmValueFieldSpecialization > } }; +//================================================================================================== +/// Partial specialization for caf::FilePath +//================================================================================================== +template <> +class PdmValueFieldSpecialization +{ +public: + static QVariant convert(const FilePath& value) + { + return QVariant(value.path()); + } + + static void setFromVariant(const QVariant& variantValue, FilePath& value) + { + value.setPath(variantValue.toString()); + } + + static bool isEqual(const QVariant& variantValue, const QVariant& variantValue2) + { + return variantValue.value() == variantValue2.value(); + } +}; + } // End of namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp index 6789e4cbdb..9f9241b29c 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafNotificationCenter.cpp @@ -95,7 +95,7 @@ void NotificationCenter::notifyObservers() { foreach(DataModelObserver* o, m_observers) { - o->handleModelNotification(NULL); + o->handleModelNotification(nullptr); } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt index e6a0882885..ca70e46c3e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) @@ -6,8 +6,7 @@ include (${QT_USE_FILE}) project ( cafPdmCore_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. + ${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp index 23175f8796..b4e51874dc 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmCore_UnitTests/cafPdmCoreBasicTest.cpp @@ -12,6 +12,8 @@ #include "cafPdmReferenceHelper.h" #include "cafPdmValueField.h" +#include + class DemoPdmObject: public caf::PdmObjectHandle { @@ -36,6 +38,7 @@ class DemoPdmObject: public caf::PdmObjectHandle this->addField(&m_memberStringField, "m_memberStringField"); + // Default values m_doubleMember = 2.1; m_intMember = 7; @@ -87,12 +90,18 @@ class InheritedDemoObj : public DemoPdmObject this->addField(&m_texts, "Texts"); this->addField(&m_childArrayField, "DemoPdmObjectects"); this->addField(&m_ptrField, "m_ptrField"); + + this->addField(&m_singleFilePath, "m_singleFilePath"); + this->addField(&m_multipleFilePath, "m_multipleFilePath"); } caf::PdmDataValueField m_texts; caf::PdmChildArrayField m_childArrayField; caf::PdmPtrField m_ptrField; + + caf::PdmDataValueField m_singleFilePath; + caf::PdmDataValueField> m_multipleFilePath; }; @@ -589,3 +598,37 @@ TEST(BaseTest, PdmPointer) } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(BaseTest, PdmFilePath) +{ + InheritedDemoObj* d = new InheritedDemoObj; + + QVariant newVal = "path with space"; + d->m_singleFilePath.setFromQVariant(newVal); + + QVariant var = d->m_singleFilePath.toQVariant(); + ASSERT_TRUE(newVal == var); + + delete d; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(BaseTest, MultiplePdmFilePath) +{ + InheritedDemoObj* d = new InheritedDemoObj; + + QString newVal = "path with space"; + d->m_multipleFilePath.v().push_back(newVal); + d->m_multipleFilePath.v().push_back(newVal); + + QVariant var = d->m_multipleFilePath.toQVariant(); + QStringList str = var.toStringList(); + + EXPECT_EQ(2, str.size()); + + delete d; +} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h index 6a06ec06d2..f0080f9eec 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmFieldHandle.h @@ -19,7 +19,7 @@ class PdmFieldCapability; class PdmFieldHandle { public: - PdmFieldHandle() { m_ownerObject = NULL; } + PdmFieldHandle() { m_ownerObject = nullptr; } virtual ~PdmFieldHandle(); QString keyword() const { return m_keyword; } @@ -45,7 +45,7 @@ class PdmFieldHandle PdmXmlFieldHandle* xmlCapability(); protected: - bool isInitializedByInitFieldMacro() const { return m_ownerObject != NULL; } + bool isInitializedByInitFieldMacro() const { return m_ownerObject != nullptr; } private: PDM_DISABLE_COPY_AND_ASSIGN(PdmFieldHandle); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h new file mode 100644 index 0000000000..2125c9fe06 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmInterfacePointer.h @@ -0,0 +1,86 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018 Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## +#pragma once + +#include "cafPdmPointer.h" + +namespace caf +{ + +template +class PdmInterfacePointer +{ +public: + inline PdmInterfacePointer () : m_iface(nullptr) { } + inline PdmInterfacePointer ( T * iface ) { *this = iface; } + inline PdmInterfacePointer ( const PdmInterfacePointer & other ) { *this = other.p();} + + T* p() const + { + if ( m_implementingPdmObject.notNull() ) + { + return m_iface; + } + else + { + return nullptr; + } + } + + PdmInterfacePointer & operator= ( T* iface ) + { + m_implementingPdmObject = nullptr; + m_iface = nullptr; + if ( iface != nullptr ) + { + m_implementingPdmObject = iface->implementingPdmObject(); + m_iface = iface; + } + return *this; + } + + bool isNull() const { return m_implementingPdmObject.isNull(); } + bool notNull() const { return m_implementingPdmObject.notNull(); } + operator T* () const { return p(); } + T* operator->() const { return p(); } + PdmInterfacePointer & operator= ( const PdmInterfacePointer& other ) { return *this = other.p();} + +private: + T* m_iface; + PdmPointer m_implementingPdmObject; +}; + +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp index 6c859f530a..ea72d25d38 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmObjectHandle.cpp @@ -24,7 +24,7 @@ PdmObjectHandle::~PdmObjectHandle() std::set::iterator it; for (it = m_pointersReferencingMe.begin(); it != m_pointersReferencingMe.end() ; ++it) { - (**it) = NULL; + (**it) = nullptr; } } @@ -41,7 +41,7 @@ void PdmObjectHandle::fields(std::vector& fields) const //-------------------------------------------------------------------------------------------------- void PdmObjectHandle::setAsParentField(PdmFieldHandle* parentField) { - CAF_ASSERT(m_parentField == NULL); + CAF_ASSERT(m_parentField == nullptr); m_parentField = parentField; } @@ -53,7 +53,7 @@ void PdmObjectHandle::removeAsParentField(PdmFieldHandle* parentField) { CAF_ASSERT(m_parentField == parentField); - m_parentField = NULL; + m_parentField = nullptr; } @@ -62,7 +62,7 @@ void PdmObjectHandle::removeAsParentField(PdmFieldHandle* parentField) //-------------------------------------------------------------------------------------------------- void PdmObjectHandle::addReferencingPtrField(PdmFieldHandle* fieldReferringToMe) { - if (fieldReferringToMe != NULL) m_referencingPtrFields.insert(fieldReferringToMe); + if (fieldReferringToMe != nullptr) m_referencingPtrFields.insert(fieldReferringToMe); } //-------------------------------------------------------------------------------------------------- @@ -70,7 +70,7 @@ void PdmObjectHandle::addReferencingPtrField(PdmFieldHandle* fieldReferringToMe) //-------------------------------------------------------------------------------------------------- void PdmObjectHandle::removeReferencingPtrField(PdmFieldHandle* fieldReferringToMe) { - if (fieldReferringToMe != NULL) m_referencingPtrFields.erase(fieldReferringToMe); + if (fieldReferringToMe != nullptr) m_referencingPtrFields.erase(fieldReferringToMe); } //-------------------------------------------------------------------------------------------------- @@ -110,7 +110,7 @@ void PdmObjectHandle::addField(PdmFieldHandle* field, const QString& keyword) field->m_ownerObject = this; CAF_ASSERT(!keyword.isEmpty()); - CAF_ASSERT(this->findField(keyword) == NULL); + CAF_ASSERT(this->findField(keyword) == nullptr); field->setKeyword(keyword); m_fields.push_back(field); @@ -134,7 +134,7 @@ PdmFieldHandle* PdmObjectHandle::findField(const QString& keyword) const } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp index b62453472e..b7442a3776 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmCore/cafPdmReferenceHelper.cpp @@ -54,7 +54,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- QString PdmReferenceHelper::referenceFromRootToObject(PdmObjectHandle* root, PdmObjectHandle* obj) { - if (obj == NULL || root == NULL) return QString(); + if (obj == nullptr || root == nullptr) return QString(); QStringList objectNames = referenceFromRootToObjectAsStringList(root, obj); @@ -67,7 +67,7 @@ QString PdmReferenceHelper::referenceFromRootToObject(PdmObjectHandle* root, Pdm //-------------------------------------------------------------------------------------------------- QString PdmReferenceHelper::referenceFromRootToField(PdmObjectHandle* root, PdmFieldHandle* field) { - if (field == NULL || root == NULL) return QString(); + if (field == nullptr || root == nullptr) return QString(); PdmObjectHandle* owner = field->ownerObject(); if (!owner) return QString(); // Should be assert ? @@ -97,7 +97,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReference(PdmObjectHandle* root, //-------------------------------------------------------------------------------------------------- PdmFieldHandle* PdmReferenceHelper::findField(PdmObjectHandle* object, const QString& fieldKeyword) { - if (object == NULL) return NULL; + if (object == nullptr) return nullptr; std::vector fields; object->fields(fields); @@ -110,7 +110,7 @@ PdmFieldHandle* PdmReferenceHelper::findField(PdmObjectHandle* object, const QSt } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -120,7 +120,7 @@ QStringList PdmReferenceHelper::referenceFromRootToObjectAsStringList(PdmObjectH { QStringList objectNames; - if (obj != NULL && root) + if (obj != nullptr && root) { if (obj == root) return objectNames; @@ -186,7 +186,7 @@ QStringList PdmReferenceHelper::referenceFromRootToObjectAsStringList(PdmObjectH PdmFieldHandle* PdmReferenceHelper::fieldFromReference(PdmObjectHandle* root, const QString& reference) { QStringList decodedReference = reference.split(" "); - if (decodedReference.size() == 0) return NULL; + if (decodedReference.size() == 0) return nullptr; QString fieldKeyword = decodedReference[0]; decodedReference.pop_front(); @@ -200,7 +200,7 @@ PdmFieldHandle* PdmReferenceHelper::fieldFromReference(PdmObjectHandle* root, co //-------------------------------------------------------------------------------------------------- PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHandle* root, const QStringList& reference) { - if (!root) return NULL; + if (!root) return nullptr; PdmObjectHandle* currentObject = root; @@ -212,7 +212,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHand PdmFieldHandle* fieldHandle = findField(currentObject, fieldKeyword); if (!fieldHandle) { - return NULL; + return nullptr; } std::vector childObjects; @@ -220,7 +220,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHand if (childObjects.size() == 0) { - return NULL; + return nullptr; } QString fieldIndex = reference.at(i++); @@ -228,12 +228,12 @@ PdmObjectHandle* PdmReferenceHelper::objectFromReferenceStringList(PdmObjectHand int index = fieldIndex.toInt(&conversionOk); if (!conversionOk) { - return NULL; + return nullptr; } if (index < 0 || index > ((int)childObjects.size()) - 1) { - return NULL; + return nullptr; } currentObject = childObjects[index]; @@ -258,7 +258,7 @@ std::vector findPathToObjectFromRoot(PdmObjectHandle* obj) } else { - currentObj = NULL; + currentObj = nullptr; } } @@ -281,7 +281,7 @@ QString PdmReferenceHelper::referenceFromFieldToObject(PdmFieldHandle* fromField std::vector toObjPath = findPathToObjectFromRoot(toObj); // Make sure the objects actually have at least one common ancestor - if (fromObjPath.front() != toObjPath.front()) return NULL; + if (fromObjPath.front() != toObjPath.front()) return nullptr; bool anchestorIsEqual = true; size_t idxToLastCommonAnchestor = 0; @@ -318,8 +318,8 @@ QString PdmReferenceHelper::referenceFromFieldToObject(PdmFieldHandle* fromField //-------------------------------------------------------------------------------------------------- PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference(PdmFieldHandle* fromField, const QString& reference) { - if (!fromField) return NULL; - if (reference.isEmpty()) return NULL; + if (!fromField) return nullptr; + if (reference.isEmpty()) return nullptr; QStringList decodedReference = reference.split(QRegExp("\\s+"), QString::SkipEmptyParts); PdmObjectHandle* lastCommonAnchestor = fromField->ownerObject(); @@ -332,7 +332,7 @@ PdmObjectHandle* PdmReferenceHelper::objectFromFieldReference(PdmFieldHandle* fr if (!parentField) { // Error: Relative object reference has an invalid number of parent levels - return NULL; + return nullptr; } lastCommonAnchestor = parentField->ownerObject(); @@ -351,7 +351,7 @@ PdmObjectHandle* PdmReferenceHelper::findRoot(PdmObjectHandle* obj) std::vector path = findPathToObjectFromRoot(obj); if (path.size()) return path[0]; - else return NULL; + else return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -365,7 +365,7 @@ PdmObjectHandle* PdmReferenceHelper::findRoot(PdmFieldHandle* field) return findRoot(ownerObject); } - return NULL; + return nullptr; } } // end namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp index 606c07c773..ca3169abf8 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmDocument.cpp @@ -135,7 +135,7 @@ void PdmDocument::writeFile(QIODevice* xmlFile) //-------------------------------------------------------------------------------------------------- void PdmDocument::updateUiIconStateRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h index f74aa9f72e..8a6821a710 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmField.h @@ -6,6 +6,7 @@ #undef PdmDataValueField #undef CAF_IS_DEFINING_PDM_FIELD +#ifndef __clang__ namespace caf { @@ -18,6 +19,7 @@ namespace caf { }; -#endif +#endif // WIN32 } +#endif // __clang__ diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h index 83cb0d2be9..4883a159c6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmObject.h @@ -139,7 +139,7 @@ namespace caf class PdmObject : public PdmObjectHandle, public PdmXmlObjectHandle, public PdmUiObjectHandle { public: - PdmObject() : PdmObjectHandle(), PdmUiObjectHandle(this, false), PdmXmlObjectHandle(this, false) {} + PdmObject() : PdmObjectHandle(), PdmXmlObjectHandle(this, false), PdmUiObjectHandle(this, false) {} virtual ~PdmObject() {} /// Adds field to the internal data structure and sets the file keyword and Ui information diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt index 4328e3caa4..45aa9428f7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/CMakeLists.txt @@ -7,8 +7,6 @@ find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) include_directories ( - - ${cafPdmCore_SOURCE_DIR} .. ) @@ -53,4 +51,13 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_link_libraries ( ${PROJECT_NAME} + cafPdmCore +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h index 387bea9263..ee2baa15cb 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafInternalPdmFieldTypeSpecializations.h @@ -186,4 +186,42 @@ class PdmUiFieldSpecialization < caf::AppEnum > }; + +//================================================================================================== +/// Partial specialization for FilePath +//================================================================================================== + +template <> +class PdmUiFieldSpecialization +{ +public: + /// Convert the field value into a QVariant + static QVariant convert(const caf::FilePath& value) + { + return PdmValueFieldSpecialization::convert(value); + } + + /// Set the field value from a QVariant + static void setFromVariant(const QVariant& variantValue, caf::FilePath& value) + { + return PdmValueFieldSpecialization::setFromVariant(variantValue, value); + } + + static bool isDataElementEqual(const QVariant& variantValue, const QVariant& variantValue2) + { + return PdmValueFieldSpecialization::isEqual(variantValue, variantValue2); + } + + /// Methods to get a list of options for a field, specialized for AppEnum + static QList valueOptions( bool* useOptionsOnly, const caf::FilePath& ) + { + return QList(); + } + + /// Methods to retrieve the possible PdmObject pointed to by a field + static void childObjects(const PdmDataValueField< caf::FilePath > & field, std::vector* objects) + { } + +}; + } // End namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp index f813767149..810ad8a96d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiCommandSystemProxy.cpp @@ -64,7 +64,7 @@ PdmUiCommandSystemProxy* PdmUiCommandSystemProxy::instance() //-------------------------------------------------------------------------------------------------- PdmUiCommandSystemProxy::PdmUiCommandSystemProxy() { - m_commandInterface = NULL; + m_commandInterface = nullptr; } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp index 2b7bf1c3d2..74009476b4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiEditorHandle.cpp @@ -43,7 +43,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -PdmUiEditorHandle::PdmUiEditorHandle() : m_pdmItem(NULL) +PdmUiEditorHandle::PdmUiEditorHandle() : m_pdmItem(nullptr) { } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h index 4f34bfbbd5..e18b411dc7 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiFieldEditorHandle.h @@ -114,9 +114,9 @@ class PdmUiFieldEditorHandle : public PdmUiEditorHandle /// Implement one of these, or both editor and label. The widgets will be used in the parent layout according to /// being "Label" Editor" or a single combined widget. - virtual QWidget* createCombinedWidget(QWidget * parent) { return NULL; } - virtual QWidget* createEditorWidget(QWidget * parent) { return NULL; } - virtual QWidget* createLabelWidget(QWidget * parent) { return NULL; } + virtual QWidget* createCombinedWidget(QWidget * parent) { return nullptr; } + virtual QWidget* createEditorWidget(QWidget * parent) { return nullptr; } + virtual QWidget* createLabelWidget(QWidget * parent) { return nullptr; } void setValueToField(const QVariant& value); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp index 7d20464388..dfe441507d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.cpp @@ -47,8 +47,8 @@ namespace caf /// //-------------------------------------------------------------------------------------------------- PdmOptionItemInfo::PdmOptionItemInfo(const QString& anOptionUiText, const QVariant& aValue, bool isReadOnly /* = false */, QIcon anIcon /* = QIcon()*/) - : m_value(aValue), - m_optionUiText(anOptionUiText), + : m_optionUiText(anOptionUiText), + m_value(aValue), m_isReadOnly(isReadOnly), m_icon(anIcon), m_level(0) @@ -341,14 +341,14 @@ PdmUiItemInfo::LabelPosType PdmUiItem::uiLabelPosition(QString uiConfigName) con const PdmUiItemInfo* PdmUiItem::configInfo(QString uiConfigName) const { - if (uiConfigName == "" || uiConfigName.isNull()) return NULL; + if (uiConfigName == "" || uiConfigName.isNull()) return nullptr; std::map::const_iterator it; it = m_configItemInfos.find(uiConfigName); if (it != m_configItemInfos.end()) return &(it->second); - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -362,7 +362,7 @@ const PdmUiItemInfo* PdmUiItem::defaultInfo() const if (it != m_configItemInfos.end()) return &(it->second); - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -395,7 +395,7 @@ PdmUiItem::~PdmUiItem() std::set::iterator it; for (it = m_editors.begin(); it != m_editors.end(); ++it) { - (*it)->m_pdmItem = NULL; + (*it)->m_pdmItem = nullptr; } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h index 4f08a63cf0..5df67078ac 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiItem.h @@ -69,10 +69,10 @@ class PdmUiItemInfo private: friend class PdmUiItem; QString m_uiName; + QIcon m_icon; QString m_toolTip; - QString m_extraDebugText; QString m_whatsThis; - QIcon m_icon; + QString m_extraDebugText; QString m_editorTypeName; ///< Use this exact type of editor to edit this UiItem int m_isHidden; ///< UiItem should be hidden. -1 means not set int m_isTreeChildrenHidden; ///< Children of UiItem should be hidden. -1 means not set @@ -191,7 +191,7 @@ bool PdmOptionItemInfo::findValues(const QList& optionList, Q class PdmUiItem { public: - PdmUiItem() : m_staticItemInfo(NULL) { } + PdmUiItem() : m_staticItemInfo(nullptr) { } virtual ~PdmUiItem(); PdmUiItem(const PdmUiItem&) = delete; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp index 4e7afdbf45..711ad73a91 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectEditorHandle.cpp @@ -104,7 +104,7 @@ PdmObjectHandle* PdmUiObjectEditorHandle::pdmObject() } else { - return NULL; + return nullptr; } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp index 7b82d496c5..38fea693ff 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.cpp @@ -25,7 +25,7 @@ PdmUiObjectHandle::PdmUiObjectHandle(PdmObjectHandle* owner, bool giveOwnership) //-------------------------------------------------------------------------------------------------- PdmUiObjectHandle* uiObj(PdmObjectHandle* obj) { - if (!obj) return NULL; + if (!obj) return nullptr; PdmUiObjectHandle* uiObject = obj->capability(); CAF_ASSERT(uiObject); return uiObject; @@ -92,7 +92,7 @@ PdmUiTreeOrdering* PdmUiObjectHandle::uiTreeOrdering(QString uiConfigName /*= "" { CAF_ASSERT(this); // This method actually is possible to call on a NULL ptr without getting a crash, so we assert instead. - PdmUiTreeOrdering* uiTreeOrdering = new PdmUiTreeOrdering(NULL, m_owner); + PdmUiTreeOrdering* uiTreeOrdering = new PdmUiTreeOrdering(nullptr, m_owner); expandUiTree(uiTreeOrdering, uiConfigName); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h index 68e6b86dd6..7bfe542b3a 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiObjectHandle.h @@ -48,10 +48,10 @@ class PdmUiObjectHandle : public PdmUiItem, public PdmObjectCapability // Virtual interface to override in subclasses to support special behaviour if needed public: // Virtual - virtual caf::PdmFieldHandle* userDescriptionField() { return NULL; } + virtual caf::PdmFieldHandle* userDescriptionField() { return nullptr; } /// Field used to toggle object on/off in UI-related uses of the object (ie checkbox in treeview) - virtual caf::PdmFieldHandle* objectToggleField() { return NULL; } + virtual caf::PdmFieldHandle* objectToggleField() { return nullptr; } /// Method to reimplement to catch when the field has changed due to setUiValue() virtual void fieldChangedByUi(const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue) {} diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp index b46913a8b9..63c76662c9 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.cpp @@ -140,13 +140,13 @@ bool PdmUiTreeOrdering::containsObject(const PdmObjectHandle* object) /// Creates an new root PdmUiTreeOrdering item, pointing at a PdmObject //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmObjectHandle* pdmObject) : - m_parentItem(NULL), - m_field(NULL), + m_object(pdmObject), + m_field(nullptr), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(pdmObject), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr), + m_parentItem(nullptr) { } @@ -154,13 +154,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(PdmObjectHandle* pdmObject) : /// Creates an new root PdmUiTreeOrdering item, pointing at a field //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering( PdmFieldHandle* pdmField ) : - m_parentItem(NULL), + m_object(nullptr), m_field(pdmField), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(NULL), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr), + m_parentItem(nullptr) { if (pdmField) m_object = pdmField->ownerObject(); } @@ -169,13 +169,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering( PdmFieldHandle* pdmField ) : /// Creates an new root PdmUiTreeOrdering item, as a display item only //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconResourceName) : - m_parentItem(NULL), - m_field(NULL), + m_object(nullptr), + m_field(nullptr), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(NULL), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr), + m_parentItem(nullptr) { m_uiItem = new PdmUiItem(); m_uiItem->setUiName(title); @@ -187,13 +187,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(const QString & title, const QString& iconR /// at the end of parents existing child list. //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent, PdmObjectHandle* pdmObject) : - m_parentItem(parent), - m_field(NULL), + m_object(pdmObject), + m_field(nullptr), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(pdmObject), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr), + m_parentItem(parent) { if (m_parentItem) { @@ -206,13 +206,13 @@ PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent, PdmObjectHandle* /// at the end of parents existing child list. //-------------------------------------------------------------------------------------------------- PdmUiTreeOrdering::PdmUiTreeOrdering(PdmUiTreeOrdering* parent , PdmFieldHandle* pdmField ) : - m_parentItem(parent), + m_object(nullptr), m_field(pdmField), + m_uiItem(nullptr), m_forgetRemainingFields(false), m_isToIgnoreSubTree(false), - m_uiItem(NULL), - m_object(NULL), - m_treeItemEditor(NULL) + m_treeItemEditor(nullptr), + m_parentItem(parent) { if (m_parentItem) { @@ -274,7 +274,7 @@ PdmUiItem* PdmUiTreeOrdering::activeItem() const if (isRepresentingObject()) return uiObj(m_object); if (isRepresentingField()) return m_field->uiCapability(); if (isDisplayItemOnly()) return m_uiItem; - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h index c9a622d248..6528a97af4 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafPdmUiTreeOrdering.h @@ -82,10 +82,10 @@ class PdmUiTreeOrdering void setIgnoreSubTree(bool doIgnoreSubTree ) { m_isToIgnoreSubTree = doIgnoreSubTree; } // Testing for the PdmItem being represented - bool isRepresentingObject() const { return !isRepresentingField() && (m_object != NULL); } - bool isRepresentingField() const { return (m_object != NULL) && (m_field != NULL);} - bool isDisplayItemOnly() const { return (m_uiItem != NULL); } - bool isValid() const { return (this->activeItem() != NULL); } + bool isRepresentingObject() const { return !isRepresentingField() && (m_object != nullptr); } + bool isRepresentingField() const { return (m_object != nullptr) && (m_field != nullptr);} + bool isDisplayItemOnly() const { return (m_uiItem != nullptr); } + bool isValid() const { return (this->activeItem() != nullptr); } // Access to the PdmItem being represented PdmUiItem* activeItem() const; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp index 9233b71ac7..42c8195fad 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.cpp @@ -119,7 +119,7 @@ PdmUiItem* SelectionManager::selectedItem(int role /*= SelectionManager::APPLICA } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -140,8 +140,8 @@ SelectionManager::SelectionManager() { m_selectionForRole.resize(UNDEFINED); - m_notificationCenter = NULL; - m_activeChildArrayFieldHandle = NULL; + m_notificationCenter = nullptr; + m_activeChildArrayFieldHandle = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h index 09adab873b..ca090c019e 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManager.h @@ -103,6 +103,22 @@ class SelectionManager } } + template + void objectsByTypeStrict(std::vector* typedObjects, int role = SelectionManager::APPLICATION_GLOBAL) + { + std::vector items; + this->selectedItems(items, role); + for (size_t i = 0; i < items.size(); i++) + { + T* obj = dynamic_cast(items[i]); + if (!obj) + { + typedObjects->clear(); + break; + } + typedObjects->push_back(obj); + } + } private: SelectionManager(); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h index f7bf694d6b..a521236751 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmUiCore/cafSelectionManagerTools.h @@ -75,4 +75,17 @@ std::vector selectedObjectsByType() return objectByType; } +//-------------------------------------------------------------------------------------------------- +/// Return all objects of given type from the selection manager. +/// If objects of different type are selected, an empty list is returned. +//-------------------------------------------------------------------------------------------------- +template +std::vector selectedObjectsByTypeStrict() +{ + std::vector objectByType; + caf::SelectionManager::instance()->objectsByTypeStrict(&objectByType); + + return objectByType; +} + } // end namespace caf diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt index c5a8585247..01fa1d3fa6 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/CMakeLists.txt @@ -8,18 +8,20 @@ include (${QT_USE_FILE}) include_directories ( .. - ${cafPdmCore_SOURCE_DIR} ) set( PROJECT_FILES cafInternalPdmFieldIoHelper.cpp cafInternalPdmFieldIoHelper.h + cafInternalPdmFilePathStreamOperators.cpp + cafInternalPdmFilePathStreamOperators.h cafInternalPdmStreamOperators.cpp cafInternalPdmStreamOperators.h cafInternalPdmXmlFieldCapability.h cafInternalPdmXmlFieldCapability.inl cafInternalPdmXmlFieldReaderWriter.cpp cafInternalPdmXmlFieldReaderWriter.h + cafPdmXmlFieldHandle.cpp cafPdmXmlFieldHandle.h cafPdmXmlObjectHandle.cpp @@ -42,4 +44,13 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +target_link_libraries ( ${PROJECT_NAME} + cafPdmCore +) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp new file mode 100644 index 0000000000..a738d16b9a --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.cpp @@ -0,0 +1,65 @@ +#include "cafInternalPdmFilePathStreamOperators.h" + +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator<<(QTextStream& str, const std::vector& filePathObjects) +{ + QStringList trimmedEntries; + + for (const auto& filePath : filePathObjects) + { + QString text = filePath.path().trimmed(); + + if (text.isEmpty()) continue; + + trimmedEntries.push_back(text); + } + + for (int i = 0; i < trimmedEntries.size(); i++) + { + str << trimmedEntries[i]; + + if (i < trimmedEntries.size() - 1) + { + str << ";"; + } + } + + return str; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QTextStream& operator>>(QTextStream& str, std::vector& filePathObjects) +{ + QString stringSeparatedBySemicolon; + + while (str.status() == QTextStream::Ok) + { + // Read QChar to avoid white space trimming when reading QString + QChar singleChar; + str >> singleChar; + + if (!singleChar.isNull()) + { + stringSeparatedBySemicolon += singleChar; + } + } + + QStringList splitBySemicolon = stringSeparatedBySemicolon.split(";"); + for (const auto& s : splitBySemicolon) + { + QString trimmed = s.trimmed(); + if (!trimmed.isEmpty()) + { + filePathObjects.push_back(trimmed); + } + } + + return str; +} + diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h new file mode 100644 index 0000000000..1e6a77daa4 --- /dev/null +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmFilePathStreamOperators.h @@ -0,0 +1,10 @@ +#pragma once + +#include "cafFilePath.h" + +#include + +#include + +QTextStream& operator << (QTextStream& str, const std::vector& sobj); +QTextStream& operator >> (QTextStream& str, std::vector& sobj); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h index 67711e2620..864294268f 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafInternalPdmXmlFieldReaderWriter.h @@ -5,6 +5,7 @@ #include #include "cafInternalPdmStreamOperators.h" +#include "cafInternalPdmFilePathStreamOperators.h" #include "cafPdmReferenceHelper.h" #include "cafInternalPdmFieldIoHelper.h" diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp index 422e3eb8b7..b6dc8b0dfe 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmDefaultObjectFactory.cpp @@ -20,7 +20,7 @@ PdmObjectHandle * PdmDefaultObjectFactory::create(const QString& classNameKeywor } else { - return NULL; + return nullptr; } } diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp index 06620a0a6a..faa6888b35 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.cpp @@ -94,7 +94,7 @@ void PdmSettings::readFieldsFromApplicationStore(caf::PdmObjectHandle* object, c //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void PdmSettings::writeFieldsToApplicationStore(caf::PdmObjectHandle* object, const QString context) +void PdmSettings::writeFieldsToApplicationStore(const caf::PdmObjectHandle* object, const QString context) { CAF_ASSERT(object); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h index 22bf3eb47a..8de5adc6ea 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmSettings.h @@ -48,7 +48,7 @@ class PdmSettings { public: static void readFieldsFromApplicationStore(caf::PdmObjectHandle* object, const QString context = ""); - static void writeFieldsToApplicationStore(caf::PdmObjectHandle* object, const QString context = ""); + static void writeFieldsToApplicationStore(const caf::PdmObjectHandle* object, const QString context = ""); }; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp index 645f8aff3a..52e6ae55de 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXmlObjectHandle.cpp @@ -28,7 +28,7 @@ PdmXmlObjectHandle::PdmXmlObjectHandle(PdmObjectHandle* owner, bool giveOwnershi //-------------------------------------------------------------------------------------------------- PdmXmlObjectHandle* xmlObj(PdmObjectHandle* obj) { - if (!obj) return NULL; + if (!obj) return nullptr; PdmXmlObjectHandle* xmlObject = obj->capability(); CAF_ASSERT(xmlObject); return xmlObject; @@ -248,7 +248,7 @@ bool PdmXmlObjectHandle::isValidXmlElementName(const QString& name) //-------------------------------------------------------------------------------------------------- void PdmXmlObjectHandle::initAfterReadRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); @@ -278,7 +278,7 @@ void PdmXmlObjectHandle::initAfterReadRecursively(PdmObjectHandle* object) //-------------------------------------------------------------------------------------------------- void PdmXmlObjectHandle::resolveReferencesRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); @@ -308,7 +308,7 @@ void PdmXmlObjectHandle::resolveReferencesRecursively(PdmObjectHandle* object) //-------------------------------------------------------------------------------------------------- void PdmXmlObjectHandle::setupBeforeSaveRecursively(PdmObjectHandle* object) { - if (object == NULL) return; + if (object == nullptr) return; std::vector fields; object->fields(fields); diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt index 7a56128283..04b8e830cc 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore ) include (${QT_USE_FILE}) @@ -6,12 +6,9 @@ include (${QT_USE_FILE}) project ( cafPdmXml_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - ${cafPdmCore_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp ) - # add the executable add_executable (${PROJECT_NAME} cafPdmXml_UnitTests.cpp @@ -24,12 +21,13 @@ add_executable (${PROJECT_NAME} message(STATUS ${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) target_link_libraries ( ${PROJECT_NAME} - cafPdmCore cafPdmXml ${QT_LIBRARIES} ${THREAD_LIBRARY} ) +source_group("" FILES ${PROJECT_FILES}) + # Copy Qt Dlls if (MSVC) set (QTLIBLIST QtCore ) diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp index ae9acc4301..ea0be7c31b 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmAdvancedTemplateTest.cpp @@ -11,6 +11,7 @@ #include "cafPdmReferenceHelper.h" #include "cafPdmXmlObjectHandle.h" #include "cafPdmXmlObjectHandleMacros.h" +#include "cafFilePath.h" #include @@ -100,6 +101,9 @@ class DemoPdmObjectA : public caf::PdmObjectHandle, public caf::PdmXmlObjectHand caf::PdmPtrField< caf::PdmObjectHandle* > m_pointerToItem; caf::PdmPtrField< caf::PdmObjectHandle* > m_pointerToDemoObj; + caf::PdmDataValueField< caf::FilePath > m_singleFilePath; + + void setDoubleMember(const double& d) { m_doubleMember = d; std::cout << "setDoubleMember" << std::endl; } double doubleMember() const { std::cout << "doubleMember" << std::endl; return m_doubleMember; } double m_doubleMember; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp index 86078bacf8..00507bb0b0 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlBasicTest.cpp @@ -198,13 +198,20 @@ class SimpleObj : public caf::PdmObjectHandle, public caf::PdmXmlObjectHandle CAF_PDM_XML_InitField(&m_position, "Position"); CAF_PDM_XML_InitField(&m_dir, "Dir"); CAF_PDM_XML_InitField(&m_up, "Up"); - } + + CAF_PDM_XML_InitField(&m_singleFilePath, "m_singleFilePath"); + CAF_PDM_XML_InitField(&m_multipleFilePath, "m_multipleFilePath"); + } caf::PdmDataValueField m_position; caf::PdmDataValueField m_dir; caf::PdmDataValueField m_up; caf::PdmProxyValueField m_proxyDouble; + caf::PdmDataValueField m_singleFilePath; + caf::PdmDataValueField> m_multipleFilePath; + + void setDoubleMember(const double& d) { m_doubleMember = d; std::cout << "setDoubleMember" << std::endl; } double doubleMember() const { std::cout << "doubleMember" << std::endl; return m_doubleMember; } @@ -349,6 +356,37 @@ TEST(BaseTest, QXMLStreamTest) tt = inputStream.readNext(); std::cout << inputStream.name().toString().toStdString() << std::endl; } +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +TEST(BaseTest, FilePathSerializing) +{ + SimpleObj* s1 = new SimpleObj; + + QString newVal = "path with space"; + s1->m_multipleFilePath.v().push_back(newVal); + s1->m_multipleFilePath.v().push_back(newVal); + + s1->m_singleFilePath = newVal; + + QString serializedString = s1->writeObjectToXmlString(); + + { + SimpleObj* ihd1 = new SimpleObj; + + QXmlStreamReader xmlStream(serializedString); + + ihd1->readObjectFromXmlString(serializedString, caf::PdmDefaultObjectFactory::instance()); + + EXPECT_EQ(2, ihd1->m_multipleFilePath.v().size()); + EXPECT_EQ(newVal.toStdString(), ihd1->m_singleFilePath().path().toStdString()); + + delete ihd1; + } + delete s1; +} -} \ No newline at end of file diff --git a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp index 50f5db1294..8b7369d21d 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp +++ b/Fwk/AppFwk/cafProjectDataModel/cafPdmXml/cafPdmXml_UnitTests/cafPdmXmlNumberTest.cpp @@ -80,7 +80,7 @@ TEST(SerializeNumbers, SimpleObjectWithDoubleValues) //-------------------------------------------------------------------------------------------------- TEST(SerializeNumbers, SimpleObjectWithFloatValues) { - float valueA = 0.123456789; + float valueA = 0.123456789f; float valueB = 123456 + valueA; QString objectAsText; diff --git a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt index 4ac2c8cec5..e1e29599ee 100644 --- a/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafProjectDataModel/cafProjectDataModel_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore QtGui ) include (${QT_USE_FILE}) @@ -6,25 +6,15 @@ include (${QT_USE_FILE}) project ( cafProjectDataModel_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. -) - -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - - ${cafProjectDataModel_SOURCE_DIR} + ${CMAKE_CURRENT_SOURCE_DIR} # required for gtest-all.cpp ) set( PROJECT_FILES cafPdmBasicTest.cpp cafProjectDataModel_UnitTests.cpp - Child.cpp - Parent.cpp - TestObj.cpp - + Child.cpp + Parent.cpp + TestObj.cpp ) # add the executable @@ -35,9 +25,6 @@ add_executable (${PROJECT_NAME} message(${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) target_link_libraries ( ${PROJECT_NAME} - cafPdmCore - cafPdmUiCore - cafPdmXml cafProjectDataModel ${QT_LIBRARIES} ${THREAD_LIBRARY} diff --git a/Fwk/AppFwk/cafTensor/CMakeLists.txt b/Fwk/AppFwk/cafTensor/CMakeLists.txt index 073a78e53a..d15a356c04 100644 --- a/Fwk/AppFwk/cafTensor/CMakeLists.txt +++ b/Fwk/AppFwk/cafTensor/CMakeLists.txt @@ -1,11 +1,7 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafTensor) -include_directories ( - ${LibCore_SOURCE_DIR} -) - set( PROJECT_FILES cafTensor3.cpp cafTensor3.h @@ -17,6 +13,11 @@ add_library( ${PROJECT_NAME} ${PROJECT_FILES} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries( ${PROJECT_NAME} LibCore ) -source_group("" FILES ${PROJECT_FILES}) \ No newline at end of file +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.h b/Fwk/AppFwk/cafTensor/cafTensor3.h index 8e3af7030c..c943821cb8 100644 --- a/Fwk/AppFwk/cafTensor/cafTensor3.h +++ b/Fwk/AppFwk/cafTensor/cafTensor3.h @@ -34,6 +34,8 @@ class Tensor3 Tensor3(const Tensor3& other); inline Tensor3& operator=(const Tensor3& rhs); + inline Tensor3 operator+(const Tensor3& rhs) const; + inline Tensor3 operator*(S scale) const; bool equals(const Tensor3& mat) const; bool operator==(const Tensor3& rhs) const; diff --git a/Fwk/AppFwk/cafTensor/cafTensor3.inl b/Fwk/AppFwk/cafTensor/cafTensor3.inl index ed24808baa..8a55e55e40 100644 --- a/Fwk/AppFwk/cafTensor/cafTensor3.inl +++ b/Fwk/AppFwk/cafTensor/cafTensor3.inl @@ -62,6 +62,42 @@ inline Tensor3& Tensor3::operator=(const Tensor3& obj) return *this; } +//-------------------------------------------------------------------------------------------------- +/// Component-wise addition +//-------------------------------------------------------------------------------------------------- +template< typename S> +Tensor3 caf::Tensor3::operator+(const Tensor3& rhs) const +{ + Tensor3 result(*this); + + result.m_tensor[0] += rhs.m_tensor[0]; + result.m_tensor[1] += rhs.m_tensor[1]; + result.m_tensor[2] += rhs.m_tensor[2]; + result.m_tensor[3] += rhs.m_tensor[3]; + result.m_tensor[4] += rhs.m_tensor[4]; + result.m_tensor[5] += rhs.m_tensor[5]; + + return result; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template< typename S> +Tensor3 caf::Tensor3::operator*(S scale) const +{ + Tensor3 result(*this); + + result.m_tensor[0] *= scale; + result.m_tensor[1] *= scale; + result.m_tensor[2] *= scale; + result.m_tensor[3] *= scale; + result.m_tensor[4] *= scale; + result.m_tensor[5] *= scale; + + return result; +} + //---------------------------------------------------------------------------------------------------- /// Check if matrices are equal using exact comparisons. diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt index f03d2a90bd..b1fa180561 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Qt find_package ( Qt4 COMPONENTS QtCore QtGui QtMain QtOpenGl ) @@ -32,11 +32,6 @@ qt4_add_resources( QRC_FILES_CPP ${QRC_FILES} ) -include_directories ( - ${cafProjectDataModel_SOURCE_DIR} - ${cafUserInterface_SOURCE_DIR} -) - if (USE_COMMAND_FRAMEWORK) include_directories ( ${cafCommand_SOURCE_DIR} @@ -45,12 +40,6 @@ if (USE_COMMAND_FRAMEWORK) endif(USE_COMMAND_FRAMEWORK) -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} -) - set( PROJECT_FILES Main.cpp MainWindow.cpp @@ -75,7 +64,6 @@ add_executable ( ${PROJECT_NAME} set (TAP_LINK_LIBRARIES cafUserInterface - cafPdmXml ${QT_LIBRARIES} ) diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp index 3982460086..9085e7bbe7 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.cpp @@ -155,7 +155,7 @@ void CustomObjectEditor::recursivelyConfigureAndUpdateTopLevelUiItems(const std: { resetCellId(); - QWidget* previousTabOrderWidget = NULL; + QWidget* previousTabOrderWidget = nullptr; for (size_t i = 0; i < topLevelUiItems.size(); ++i) { diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h index c6a945c686..cb5e88593c 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/CustomObjectEditor.h @@ -71,7 +71,7 @@ class CustomObjectEditor : public PdmUiWidgetBasedObjectEditor void defineGridLayout(int rowCount, int columnCount); // See QGridLayout::addWidget - void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = 0); + void addWidget(QWidget* widget, int row, int column, int rowSpan, int columnSpan, Qt::Alignment alignment = nullptr); void removeWidget(QWidget* widget); void addBlankCell(int row, int column); diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp index cd13ee2862..b7ef99938a 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.cpp @@ -8,11 +8,6 @@ #include "WidgetLayoutTest.h" #include "MenuItemProducer.h" -#include -#include -#include -#include -#include #include "cafAppEnum.h" @@ -23,35 +18,47 @@ #include "cafCmdFeatureManager.h" #endif +#include "cafFilePath.h" +#include "cafPdmDocument.h" #include "cafPdmObject.h" #include "cafPdmObjectGroup.h" #include "cafPdmProxyValueField.h" #include "cafPdmPtrField.h" #include "cafPdmReferenceHelper.h" +#include "cafPdmUiComboBoxEditor.h" #include "cafPdmUiFilePathEditor.h" +#include "cafPdmUiItem.h" #include "cafPdmUiListEditor.h" #include "cafPdmUiPropertyView.h" +#include "cafPdmUiPushButtonEditor.h" #include "cafPdmUiTableView.h" #include "cafPdmUiTextEditor.h" +#include "cafPdmUiTreeSelectionEditor.h" #include "cafPdmUiTreeView.h" #include "cafSelectionManager.h" -#include "cafPdmUiTreeSelectionEditor.h" -#include "cafPdmUiPushButtonEditor.h" -#include "cafPdmUiItem.h" -#include "cafPdmUiComboBoxEditor.h" +#include +#include +#include +#include +#include +#include -class DemoPdmObjectGroup : public caf::PdmObjectCollection +class DemoPdmObjectGroup : public caf::PdmDocument { CAF_PDM_HEADER_INIT; public: DemoPdmObjectGroup() { + CAF_PDM_InitFieldNoDefault(&objects, "PdmObjects", "", "", "", "") + objects.uiCapability()->setUiHidden(true); - } + +public: + caf::PdmChildArrayField objects; }; CAF_PDM_SOURCE_INIT(DemoPdmObjectGroup, "DemoPdmObjectGroup"); @@ -73,6 +80,11 @@ class SmallDemoPdmObject: public caf::PdmObject m_proxyDoubleField.registerSetMethod(this, &SmallDemoPdmObject::setDoubleMember); m_proxyDoubleField.registerGetMethod(this, &SmallDemoPdmObject::doubleMember); CAF_PDM_InitFieldNoDefault(&m_proxyDoubleField, "ProxyDouble", "Proxy Double", "", "", ""); + + CAF_PDM_InitField(&m_fileName, "FileName", caf::FilePath("filename"), "File Name", "", "", ""); + + CAF_PDM_InitFieldNoDefault(&m_fileNameList, "FileNameList", "File Name List", "", "", ""); + m_fileNameList.uiCapability()->setUiEditorTypeName(caf::PdmUiListEditor::uiEditorTypeName()); m_proxyDoubleField = 0; if (!(m_proxyDoubleField == 3)) { std::cout << "Double is not 3 " << std::endl; } @@ -92,10 +104,12 @@ class SmallDemoPdmObject: public caf::PdmObject caf::PdmField m_intField; caf::PdmField m_textField; caf::PdmProxyValueField m_proxyDoubleField; + caf::PdmField m_fileName; + caf::PdmField> m_fileNameList; caf::PdmField > m_multiSelectList; - + caf::PdmField m_toggleField; virtual caf::PdmFieldHandle* objectToggleField() { @@ -545,7 +559,7 @@ CAF_PDM_SOURCE_INIT(DemoPdmObject, "DemoPdmObject"); -MainWindow* MainWindow::sm_mainWindowInstance = NULL; +MainWindow* MainWindow::sm_mainWindowInstance = nullptr; //-------------------------------------------------------------------------------------------------- /// @@ -712,10 +726,8 @@ void MainWindow::buildTestModel() void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) { caf::PdmUiObjectHandle* uiObject = uiObj(pdmRoot); - if (uiObject) - { - m_pdmUiTreeView->setPdmItem(uiObject); - } + + m_pdmUiTreeView->setPdmItem(uiObject); connect(m_pdmUiTreeView, SIGNAL(selectionChanged()), SLOT(slotSimpleSelectionChanged())); @@ -723,7 +735,11 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) // Hack, because we know that pdmRoot is a PdmObjectGroup ... std::vector fields; - pdmRoot->fields(fields); + if (pdmRoot) + { + pdmRoot->fields(fields); + } + if (fields.size()) { caf::PdmFieldHandle* field = fields[0]; @@ -735,27 +751,37 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) } } - if (uiObject) - { - m_pdmUiTreeView2->setPdmItem(uiObject); - } + m_pdmUiTreeView2->setPdmItem(uiObject); connect(m_pdmUiTreeView2, SIGNAL(selectionChanged()), SLOT(slotShowTableView())); // Wire up ManyGroups object std::vector obj; - pdmRoot->descendantsIncludingThisOfType(obj); + if (pdmRoot) + { + pdmRoot->descendantsIncludingThisOfType(obj); + } + + m_customObjectEditor->removeWidget(m_plotLabel); + m_customObjectEditor->removeWidget(m_smallPlotLabel); + if (obj.size() == 1) { - m_customObjectEditor->defineGridLayout(5, 4); m_customObjectEditor->setPdmObject(obj[0]); + m_customObjectEditor->defineGridLayout(5, 4); + m_customObjectEditor->addBlankCell(0, 0); m_customObjectEditor->addWidget(m_plotLabel, 0, 1, 1, 2); m_customObjectEditor->addWidget(m_smallPlotLabel, 1, 2, 2, 1); - - m_customObjectEditor->updateUi(); } + else + { + m_customObjectEditor->setPdmObject(nullptr); + } + + + m_customObjectEditor->updateUi(); } //-------------------------------------------------------------------------------------------------- @@ -763,10 +789,10 @@ void MainWindow::setPdmRoot(caf::PdmObjectHandle* pdmRoot) //-------------------------------------------------------------------------------------------------- MainWindow::~MainWindow() { - m_pdmUiTreeView->setPdmItem(NULL); - m_pdmUiTreeView2->setPdmItem(NULL); - m_pdmUiPropertyView->showProperties(NULL); - m_pdmUiTableView->setListField(NULL); + m_pdmUiTreeView->setPdmItem(nullptr); + m_pdmUiTreeView2->setPdmItem(nullptr); + m_pdmUiPropertyView->showProperties(nullptr); + m_pdmUiTableView->setListField(nullptr); delete m_pdmUiTreeView; delete m_pdmUiTreeView2; @@ -800,21 +826,32 @@ MainWindow* MainWindow::instance() //-------------------------------------------------------------------------------------------------- void MainWindow::createActions() { - // Create actions - QAction* editInsert = new QAction("&Insert", this); - QAction* editRemove = new QAction("&Remove", this); - QAction* editRemoveAll = new QAction("Remove all", this); + { + QAction* loadAction = new QAction("Load Project", this); + QAction* saveAction = new QAction("Save Project", this); - connect(editInsert, SIGNAL(triggered()), SLOT(slotInsert())); - connect(editRemove, SIGNAL(triggered()), SLOT(slotRemove())); - connect(editRemoveAll, SIGNAL(triggered()), SLOT(slotRemoveAll())); + connect(loadAction, SIGNAL(triggered()), SLOT(slotLoadProject())); + connect(saveAction, SIGNAL(triggered()), SLOT(slotSaveProject())); + QMenu* menu = menuBar()->addMenu("&File"); + menu->addAction(loadAction); + menu->addAction(saveAction); + } + + { + QAction* editInsert = new QAction("&Insert", this); + QAction* editRemove = new QAction("&Remove", this); + QAction* editRemoveAll = new QAction("Remove all", this); - // Create menus - QMenu* editMenu = menuBar()->addMenu("&Edit"); - editMenu->addAction(editInsert); - editMenu->addAction(editRemove); - editMenu->addAction(editRemoveAll); + connect(editInsert, SIGNAL(triggered()), SLOT(slotInsert())); + connect(editRemove, SIGNAL(triggered()), SLOT(slotRemove())); + connect(editRemoveAll, SIGNAL(triggered()), SLOT(slotRemoveAll())); + + QMenu* menu = menuBar()->addMenu("&Edit"); + menu->addAction(editInsert); + menu->addAction(editRemove); + menu->addAction(editRemoveAll); + } } //-------------------------------------------------------------------------------------------------- @@ -828,7 +865,7 @@ void MainWindow::slotInsert() for (size_t i = 0; i < selection.size(); ++i) { caf::PdmUiFieldHandle* uiFh = dynamic_cast(selection[i]); - caf::PdmChildArrayField< caf::PdmObjectHandle*> * field = NULL; + caf::PdmChildArrayField< caf::PdmObjectHandle*> * field = nullptr; if (uiFh) field = dynamic_cast *>(uiFh->fieldHandle()); @@ -898,8 +935,8 @@ void MainWindow::slotSimpleSelectionChanged() { std::vector selection; m_pdmUiTreeView->selectedUiItems(selection); - caf::PdmObjectHandle* obj = NULL; - caf::PdmChildArrayFieldHandle* listField = NULL; + caf::PdmObjectHandle* obj = nullptr; + caf::PdmChildArrayFieldHandle* listField = nullptr; if (selection.size()) { @@ -917,8 +954,8 @@ void MainWindow::slotShowTableView() { std::vector selection; m_pdmUiTreeView2->selectedUiItems(selection); - caf::PdmObjectHandle* obj = NULL; - caf::PdmChildArrayFieldHandle* listField = NULL; + caf::PdmObjectHandle* obj = nullptr; + caf::PdmChildArrayFieldHandle* listField = nullptr; if (selection.size()) { @@ -932,7 +969,7 @@ void MainWindow::slotShowTableView() { if (!listField->hasSameFieldCountForAllObjects()) { - listField = NULL; + listField = nullptr; } } } @@ -944,3 +981,37 @@ void MainWindow::slotShowTableView() listField->uiCapability()->updateConnectedEditors(); } } + + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void MainWindow::slotLoadProject() +{ + QString fileName = QFileDialog::getOpenFileName(nullptr, tr("Open Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)"); + if (!fileName.isEmpty()) + { + setPdmRoot(nullptr); + releaseTestData(); + + m_testRoot = new DemoPdmObjectGroup; + m_testRoot->fileName = fileName; + m_testRoot->readFile(); + + setPdmRoot(m_testRoot); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void MainWindow::slotSaveProject() +{ + QString fileName = QFileDialog::getSaveFileName(nullptr, tr("Save Project File"), "test.proj", "Project Files (*.proj);;All files(*.*)"); + if (!fileName.isEmpty()) + { + m_testRoot->fileName = fileName; + m_testRoot->writeFile(); + } +} diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h index 7230bd233e..c70c625b23 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/MainWindow.h @@ -5,6 +5,7 @@ #include class DemoPdmObject; +class DemoPdmObjectGroup; class QTreeView; class QUndoView; class QLabel; @@ -33,11 +34,8 @@ class MainWindow : public QMainWindow private: void createActions(); - void createMenus(); - void createToolBars(); void createDockPanels(); - void buildTestModel(); void releaseTestData(); @@ -49,6 +47,8 @@ private slots: void slotSimpleSelectionChanged(); void slotShowTableView(); + void slotLoadProject(); + void slotSaveProject(); private: static MainWindow* sm_mainWindowInstance; @@ -60,7 +60,7 @@ private slots: caf::PdmUiTreeView* m_pdmUiTreeView2; caf::PdmUiPropertyView* m_pdmUiPropertyView; caf::PdmUiTableView* m_pdmUiTableView; - caf::PdmObjectCollection* m_testRoot; + DemoPdmObjectGroup* m_testRoot; caf::CustomObjectEditor* m_customObjectEditor; diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp index ce5e33eca1..0953e82eaa 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp +++ b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.cpp @@ -96,7 +96,7 @@ void WidgetLayoutTest::setUpInitialConfigurationA() m_mainLayout->addWidget(m_widget2); delete m_widget3; - m_widget3 = NULL; + m_widget3 = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h index 662765c544..2099e34c90 100644 --- a/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h +++ b/Fwk/AppFwk/cafTests/cafTestApplication/WidgetLayoutTest.h @@ -13,7 +13,7 @@ class WidgetLayoutTest : public QWidget Q_OBJECT public: - WidgetLayoutTest(QWidget* parent = 0, Qt::WindowFlags f = 0); + WidgetLayoutTest(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~WidgetLayoutTest(); private: diff --git a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt index 29eeeb0a82..25cddf2a32 100644 --- a/Fwk/AppFwk/cafUserInterface/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Qt find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) @@ -6,15 +6,6 @@ include (${QT_USE_FILE}) project (cafUserInterface) -include_directories( - ${cafProjectDataModel_SOURCE_DIR} -) - -include_directories ( - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} -) # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS @@ -51,7 +42,7 @@ set( QOBJECT_HEADERS cafPdmUiDoubleValueEditor.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -154,10 +145,13 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + target_link_libraries ( ${PROJECT_NAME} cafProjectDataModel - cafPdmUiCore - cafPdmCore ${QT_LIBRARIES} ) diff --git a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h index f1738b58d8..670ffbb7c1 100644 --- a/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h +++ b/Fwk/AppFwk/cafUserInterface/QMinimizePanel.h @@ -51,8 +51,8 @@ class QMinimizePanel : public QWidget { Q_OBJECT public: - explicit QMinimizePanel(QWidget* parent=0); - explicit QMinimizePanel(const QString &title, QWidget* parent=0); + explicit QMinimizePanel(QWidget* parent=nullptr); + explicit QMinimizePanel(const QString &title, QWidget* parent=nullptr); ~QMinimizePanel(); QFrame* contentFrame() { return m_contentFrame; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h index ca50434112..b13b8a0bfe 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiCheckBoxDelegate.h @@ -52,7 +52,7 @@ class PdmUiCheckBoxDelegate : public QStyledItemDelegate Q_OBJECT public: - explicit PdmUiCheckBoxDelegate( QObject* pParent = 0 ); + explicit PdmUiCheckBoxDelegate( QObject* pParent = nullptr ); virtual ~PdmUiCheckBoxDelegate(); virtual void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp index 5efac2f178..02eef60c6e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiComboBoxEditor.cpp @@ -182,7 +182,7 @@ void PdmUiComboBoxEditor::configureAndUpdateUi(const QString& uiConfigName) class CustomQComboBox : public QComboBox { public: - explicit CustomQComboBox(QWidget* parent = 0) + explicit CustomQComboBox(QWidget* parent = nullptr) : QComboBox(parent) {} diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp index 5ebf9a60f8..fb0916eede 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDefaultObjectEditor.cpp @@ -36,11 +36,13 @@ #include "cafPdmUiDefaultObjectEditor.h" +#include "cafFilePath.h" #include "cafPdmField.h" #include "cafPdmProxyValueField.h" #include "cafPdmUiCheckBoxEditor.h" #include "cafPdmUiDateEditor.h" #include "cafPdmUiFieldEditorHandle.h" +#include "cafPdmUiFilePathEditor.h" #include "cafPdmUiLineEditor.h" #include "cafPdmUiListEditor.h" @@ -64,6 +66,8 @@ CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector); CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector); CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiListEditor, std::vector); +CAF_PDM_UI_REGISTER_DEFAULT_FIELD_EDITOR(PdmUiFilePathEditor, FilePath); + //-------------------------------------------------------------------------------------------------- /// diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp index a875ac4721..92a06dc0bd 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleSliderEditor.cpp @@ -51,7 +51,7 @@ class PdmDoubleValidator : public QDoubleValidator { public: - explicit PdmDoubleValidator(QObject * parent = 0) : QDoubleValidator(parent) + explicit PdmDoubleValidator(QObject * parent = nullptr) : QDoubleValidator(parent) { } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp index 65bf59e2e8..0ef047576e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiDoubleValueEditor.cpp @@ -84,7 +84,7 @@ void PdmUiDoubleValueEditor::configureAndUpdateUi(const QString& uiConfigName) QString textValue; if (valueOk) { - textValue = QString::number(value, 'f', m_attributes.m_decimals); + textValue = QString::number(value, 'g', m_attributes.m_decimals); } else { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp index 35f21b0a89..174afc9c6d 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiFieldEditorHelper.cpp @@ -49,7 +49,7 @@ //-------------------------------------------------------------------------------------------------- caf::PdmUiFieldEditorHandle* caf::PdmUiFieldEditorHelper::fieldEditorForField(caf::PdmUiFieldHandle* field, const QString& uiConfigName) { - caf::PdmUiFieldEditorHandle* fieldEditor = NULL; + caf::PdmUiFieldEditorHandle* fieldEditor = nullptr; // If editor type is specified, find in factory if (!field->uiEditorTypeName(uiConfigName).isEmpty()) diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp index 0f37949f40..dcea9d4c1e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiLineEditor.cpp @@ -208,7 +208,7 @@ void PdmUiLineEditor::configureAndUpdateUi(const QString& uiConfigName) { if (isMultipleFieldsWithSameKeywordSelected(field()->fieldHandle())) { - QMessageBox::information(NULL, "Invalid operation", "The field you are manipulating is defined to have unique values. A selection of multiple fields is detected. Please select a single item."); + QMessageBox::information(nullptr, "Invalid operation", "The field you are manipulating is defined to have unique values. A selection of multiple fields is detected. Please select a single item."); } m_lineEdit->setValidator(new PdmUniqueIdValidator(leab.usedIds, isMultipleFieldsWithSameKeywordSelected(field()->fieldHandle()), leab.errorMessage, this)); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp index 513a9a8329..b5a344840a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.cpp @@ -64,7 +64,7 @@ class MyStringListModel : public QStringListModel { public: - explicit MyStringListModel(QObject *parent = 0) : m_isItemsEditable(false), QStringListModel(parent) { } + explicit MyStringListModel(QObject *parent = nullptr) : QStringListModel(parent), m_isItemsEditable(false) { } virtual Qt::ItemFlags flags (const QModelIndex& index) const { @@ -90,7 +90,7 @@ class MyStringListModel : public QStringListModel class QListViewHeightHint : public QListView { public: - explicit QListViewHeightHint(QWidget *parent = 0) + explicit QListViewHeightHint(QWidget *parent = nullptr) : m_heightHint(-1) { } @@ -371,15 +371,7 @@ void PdmUiListEditor::slotListItemEdited(const QModelIndex&, const QModelIndex&) QStringList uiList = m_model->stringList(); - // Remove dummy elements specifically at the end of list. - - QStringList result; - foreach (const QString &str, uiList) - { - if (str != "" && str != " ") result += str; - } - - this->setValueToField(result); + trimAndSetValuesToField(uiList); } //-------------------------------------------------------------------------------------------------- @@ -406,7 +398,21 @@ void PdmUiListEditor::pasteFromString(const QString& content) { QStringList strList = content.split("\n"); - this->setValueToField(strList); + trimAndSetValuesToField(strList); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void PdmUiListEditor::trimAndSetValuesToField(const QStringList& stringList) +{ + QStringList result; + for (const auto& str : stringList) + { + if (str != "" && str != " ") result += str; + } + + this->setValueToField(result); } //-------------------------------------------------------------------------------------------------- @@ -458,14 +464,7 @@ bool PdmUiListEditor::eventFilter(QObject* object, QEvent * event) { QStringList uiList = m_model->stringList(); - // Remove dummy elements specifically at the end of list. - - QStringList result; - foreach (const QString &str, uiList) - { - if (str != "" && str != " ") result += str; - } - this->setValueToField(result); + trimAndSetValuesToField(uiList); } return true; } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h index c088bbf056..980622e259 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListEditor.h @@ -39,11 +39,12 @@ #include "cafPdmUiFieldEditorHandle.h" -class QStringListModel; class QItemSelection; -class QListViewHeightHint; class QLabel; +class QListViewHeightHint; class QModelIndex; +class QStringList; +class QStringListModel; namespace caf { @@ -93,6 +94,8 @@ protected slots: private: QString contentAsString() const; void pasteFromString(const QString& content); + + void trimAndSetValuesToField(const QStringList& stringList); private: QPointer m_listView; diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h index f2a4f12e69..8ec2a9303f 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListView.h @@ -54,7 +54,7 @@ class PdmUiListView : public QWidget { Q_OBJECT public: - PdmUiListView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiListView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiListView(); void setPdmObject(caf::PdmObjectCollection* object); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp index 014efad09e..f850ee4482 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiListViewEditor.cpp @@ -59,7 +59,7 @@ UiListViewModelPdm::UiListViewModelPdm(QObject* parent) : QAbstractTableModel(parent) { m_columnCount = 0; - m_pdmObjectGroup = NULL; + m_pdmObjectGroup = nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp index 1f9408cd1b..c8b61f693c 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.cpp @@ -98,7 +98,7 @@ PdmUiPropertyView::PdmUiPropertyView(QWidget* parent, Qt::WindowFlags f) dummy->setContentsMargins(0,0,0,0); dummy->addWidget(scrollArea); - m_currentObjectView = NULL; + m_currentObjectView = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -123,7 +123,7 @@ void PdmUiPropertyView::setUiConfigurationName(QString uiConfigName) { PdmObjectHandle* object = m_currentObjectView->pdmObject(); delete m_currentObjectView; - m_currentObjectView = NULL; + m_currentObjectView = nullptr; this->showProperties(object); } } @@ -163,7 +163,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object) { this->m_placeHolderLayout->removeWidget(m_currentObjectView->widget()); delete m_currentObjectView; - m_currentObjectView = NULL; + m_currentObjectView = nullptr; } if (!m_currentObjectView) @@ -192,7 +192,7 @@ void PdmUiPropertyView::showProperties( PdmObjectHandle* object) //-------------------------------------------------------------------------------------------------- PdmObjectHandle* PdmUiPropertyView::currentObject() { - if (!m_currentObjectView) return NULL; + if (!m_currentObjectView) return nullptr; return m_currentObjectView->pdmObject(); } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h index c7883b611b..9e50433023 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyView.h @@ -53,7 +53,7 @@ class QVerticalScrollArea : public QScrollArea { Q_OBJECT public: - explicit QVerticalScrollArea(QWidget* parent = 0); + explicit QVerticalScrollArea(QWidget* parent = nullptr); virtual bool eventFilter(QObject* object, QEvent* event) override; }; @@ -72,7 +72,7 @@ class PdmUiPropertyView : public QWidget { Q_OBJECT public: - PdmUiPropertyView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiPropertyView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiPropertyView(); void setUiConfigurationName(QString uiConfigName); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp index f20874fe55..e5febf3df8 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiPropertyViewDialog.cpp @@ -75,7 +75,7 @@ PdmUiPropertyViewDialog::PdmUiPropertyViewDialog(QWidget* parent, PdmObject* obj //-------------------------------------------------------------------------------------------------- PdmUiPropertyViewDialog::~PdmUiPropertyViewDialog() { - m_pdmUiPropertyView->showProperties(NULL); + m_pdmUiPropertyView->showProperties(nullptr); } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h index ba6e6299e4..855562ee4e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableView.h @@ -76,7 +76,7 @@ class PdmUiTableView : public QWidget, public DataModelObserver { Q_OBJECT public: - PdmUiTableView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiTableView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiTableView(); PdmObjectHandle* pdmObjectFromModelIndex(const QModelIndex& mi); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp index 238ca9dcc4..05c89f41e5 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewEditor.cpp @@ -91,13 +91,13 @@ class FocusEventHandler : public QObject //-------------------------------------------------------------------------------------------------- PdmUiTableViewEditor::PdmUiTableViewEditor() { - m_layout = NULL;; - m_tableView = NULL; - m_tableHeading = NULL; - m_tableModelPdm = NULL; - m_tableHeadingIcon = NULL; - m_pdmListField = NULL; - m_delegate = NULL; + m_layout = nullptr;; + m_tableView = nullptr; + m_tableHeading = nullptr; + m_tableModelPdm = nullptr; + m_tableHeadingIcon = nullptr; + m_pdmListField = nullptr; + m_delegate = nullptr; m_useDefaultContextMenu = false; @@ -201,7 +201,7 @@ void PdmUiTableViewEditor::setListField(PdmChildArrayFieldHandle* pdmListField) { m_pdmListField = pdmListField; - caf::PdmUiFieldHandle* uifield = NULL; + caf::PdmUiFieldHandle* uifield = nullptr; if (m_pdmListField) { uifield = m_pdmListField->uiCapability(); @@ -210,7 +210,7 @@ void PdmUiTableViewEditor::setListField(PdmChildArrayFieldHandle* pdmListField) if (!m_pdmListField) { - m_tableModelPdm->setPdmData(NULL, ""); + m_tableModelPdm->setPdmData(nullptr, ""); m_tableHeading->setText(""); m_tableHeadingIcon->setPixmap(QPixmap()); } @@ -297,7 +297,7 @@ void PdmUiTableViewEditor::updateContextMenuSignals() else { m_tableView->setContextMenuPolicy(Qt::DefaultContextMenu); - disconnect(m_tableView, 0, this, 0); + disconnect(m_tableView, nullptr, this, nullptr); } } @@ -375,7 +375,7 @@ PdmObjectHandle* PdmUiTableViewEditor::pdmObjectFromModelIndex(const QModelIndex return m_tableModelPdm->pdmObjectForRow(mi.row()); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp index b4da6f43d2..eb5e0c2b61 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.cpp @@ -62,7 +62,7 @@ namespace caf PdmUiTableViewModel::PdmUiTableViewModel(QWidget* parent) : QAbstractTableModel(parent) { - m_pdmList = NULL; + m_pdmList = nullptr; } //-------------------------------------------------------------------------------------------------- @@ -353,7 +353,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const std::map::iterator it; for (it = m_fieldEditors.begin(); it != m_fieldEditors.end(); ++it) { - it->second->setField(NULL); + it->second->setField(nullptr); } m_modelColumnIndexToFieldIndex.clear(); @@ -366,7 +366,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const { PdmUiFieldHandle* field = dynamic_cast(uiItems[i]); - PdmUiFieldEditorHandle* fieldEditor = NULL; + PdmUiFieldEditorHandle* fieldEditor = nullptr; // Find or create FieldEditor std::map::iterator it; @@ -392,7 +392,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const //TODO: Create/update is not required at this point, as UI is recreated in getEditorWidgetAndTransferOwnership() // Can be moved, but a move will require changes in PdmUiFieldEditorHandle - fieldEditor->createWidgets(NULL); + fieldEditor->createWidgets(nullptr); fieldEditor->updateUi(configName); int fieldIndex = getFieldIndex(field->fieldHandle()); @@ -407,7 +407,7 @@ void PdmUiTableViewModel::setPdmData(PdmChildArrayFieldHandle* listField, const std::vector< QString > fvhToRemoveFromMap; for (it = m_fieldEditors.begin(); it != m_fieldEditors.end(); ++it) { - if (it->second->field() == 0) + if (it->second->field() == nullptr) { PdmUiFieldEditorHandle* fvh = it->second; delete fvh; @@ -451,7 +451,7 @@ PdmFieldHandle* PdmUiTableViewModel::getField(const QModelIndex &index) const } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -462,10 +462,10 @@ PdmUiFieldEditorHandle* PdmUiTableViewModel::getEditor(const QModelIndex &index) PdmFieldHandle* field = getField(index); if (!field) { - return NULL; + return nullptr; } - PdmUiFieldEditorHandle* editor = NULL; + PdmUiFieldEditorHandle* editor = nullptr; std::map::iterator it; it = m_fieldEditors.find(field->keyword()); @@ -503,7 +503,7 @@ QWidget* PdmUiTableViewModel::getEditorWidgetAndTransferOwnership(QWidget* paren return editorWidget; } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -559,7 +559,7 @@ PdmObjectHandle* PdmUiTableViewModel::pdmObjectForRow(int row) const return m_pdmList->at(row); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h index cd6904272e..18cde6c980 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTableViewModel.h @@ -64,7 +64,7 @@ class TableViewPushButton : public QPushButton { Q_OBJECT public: - explicit TableViewPushButton(caf::PdmUiFieldHandle* field, const QString& text, QWidget* parent = 0); + explicit TableViewPushButton(caf::PdmUiFieldHandle* field, const QString& text, QWidget* parent = nullptr); private slots: void slotPressed(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h index de898ed881..e0e9fc07a0 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTextEditor.h @@ -92,7 +92,7 @@ class TextEdit : public QTextEdit { Q_OBJECT public: - explicit TextEdit(QWidget *parent = 0); + explicit TextEdit(QWidget *parent = nullptr); virtual QSize sizeHint() const override; void setHeightHint(int heightHint); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp index 50b18bf29f..872565ffbf 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiToolButtonEditor.cpp @@ -101,7 +101,7 @@ QWidget* PdmUiToolButtonEditor::createEditorWidget(QWidget * parent) //-------------------------------------------------------------------------------------------------- QWidget* PdmUiToolButtonEditor::createLabelWidget(QWidget * parent) { - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp index 011abca12a..3e6d148890 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeItemEditor.cpp @@ -46,7 +46,7 @@ namespace caf //-------------------------------------------------------------------------------------------------- PdmUiTreeItemEditor::PdmUiTreeItemEditor(PdmUiItem* uiItem) { - m_treeViewEditor = NULL; + m_treeViewEditor = nullptr; this->bindToPdmItem(uiItem); } diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp index ca3caf59d7..c481bfd86e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionEditor.cpp @@ -61,7 +61,7 @@ class QTreeViewHeightHint : public QTreeView { public: - explicit QTreeViewHeightHint(QWidget *parent = 0) + explicit QTreeViewHeightHint(QWidget *parent = nullptr) : m_heightHint(-1) { } @@ -100,7 +100,7 @@ class QTreeViewHeightHint : public QTreeView class FilterLeafNodesOnlyProxyModel : public QSortFilterProxyModel { public: - FilterLeafNodesOnlyProxyModel(QObject *parent = 0) + FilterLeafNodesOnlyProxyModel(QObject *parent = nullptr) : QSortFilterProxyModel(parent) { } @@ -131,7 +131,7 @@ class FilterLeafNodesOnlyProxyModel : public QSortFilterProxyModel class PlaceholderLineEdit : public QLineEdit { public: - explicit PlaceholderLineEdit(const QString& placeholderText, QWidget* parent = 0) + explicit PlaceholderLineEdit(const QString& placeholderText, QWidget* parent = nullptr) : QLineEdit(parent), m_placeholderText(placeholderText) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h index a80f788422..9b4191a793 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeSelectionQModel.h @@ -58,7 +58,7 @@ class PdmUiTreeSelectionQModel : public QAbstractItemModel { Q_OBJECT public: - explicit PdmUiTreeSelectionQModel(QObject *parent = 0); + explicit PdmUiTreeSelectionQModel(QObject *parent = nullptr); ~PdmUiTreeSelectionQModel(); static int headingRole(); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp index 6867a4133c..a0b0e7c16e 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.cpp @@ -132,7 +132,7 @@ void PdmUiTreeView::slotOnSelectionChanged() std::vector objects; m_treeViewEditor->selectedUiItems(objects); - PdmObjectHandle* objHandle = NULL; + PdmObjectHandle* objHandle = nullptr; if (objects.size()) { diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h index 91685bbc11..366e0baaf2 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeView.h @@ -61,7 +61,7 @@ class PdmUiTreeView : public QWidget { Q_OBJECT public: - PdmUiTreeView(QWidget* parent = 0, Qt::WindowFlags f = 0); + PdmUiTreeView(QWidget* parent = nullptr, Qt::WindowFlags f = nullptr); ~PdmUiTreeView(); void enableDefaultContextMenu(bool enable); diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp index 3cd2538941..e6dbc4cacf 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewEditor.cpp @@ -64,7 +64,7 @@ namespace caf class PdmUiTreeViewWidget : public QTreeView { public: - explicit PdmUiTreeViewWidget(QWidget* parent = 0) : QTreeView(parent) {}; + explicit PdmUiTreeViewWidget(QWidget* parent = nullptr) : QTreeView(parent) {}; virtual ~PdmUiTreeViewWidget() {}; bool isTreeItemEditWidgetActive() const @@ -115,7 +115,7 @@ PdmUiTreeViewEditor::PdmUiTreeViewEditor() //-------------------------------------------------------------------------------------------------- PdmUiTreeViewEditor::~PdmUiTreeViewEditor() { - m_treeViewModel->setPdmItemRoot(NULL); + m_treeViewModel->setPdmItemRoot(nullptr); } //-------------------------------------------------------------------------------------------------- @@ -249,7 +249,7 @@ void PdmUiTreeViewEditor::updateContextMenuSignals() else { m_treeView->setContextMenuPolicy(Qt::DefaultContextMenu); - disconnect(m_treeView, 0, this, 0); + disconnect(m_treeView, nullptr, this, nullptr); } } @@ -303,7 +303,7 @@ PdmChildArrayFieldHandle* PdmUiTreeViewEditor::currentChildArrayFieldHandle() } } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp index 2cb1ef0cda..846581f362 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiTreeViewModel.cpp @@ -56,8 +56,8 @@ namespace caf //-------------------------------------------------------------------------------------------------- PdmUiTreeViewModel::PdmUiTreeViewModel(PdmUiTreeViewEditor* treeViewEditor) { - m_treeOrderingRoot = NULL; - m_dragDropInterface = NULL; + m_treeOrderingRoot = nullptr; + m_dragDropInterface = nullptr; m_treeViewEditor = treeViewEditor; } @@ -75,7 +75,7 @@ void PdmUiTreeViewModel::setPdmItemRoot(PdmUiItem* rootItem) return; } - PdmUiTreeOrdering* newRoot = NULL; + PdmUiTreeOrdering* newRoot = nullptr; PdmUiFieldHandle* field = dynamic_cast (rootItem); if (field) @@ -92,7 +92,7 @@ void PdmUiTreeViewModel::setPdmItemRoot(PdmUiItem* rootItem) } } - CAF_ASSERT( newRoot || rootItem == NULL ); // Only fields, objects or NULL is allowed. + CAF_ASSERT( newRoot || rootItem == nullptr ); // Only fields, objects or NULL is allowed. //if (newRoot) newRoot->debugDump(0); @@ -141,7 +141,7 @@ void PdmUiTreeViewModel::updateSubTree(PdmUiItem* pdmRoot) { // Build the new "Correct" Tree - PdmUiTreeOrdering* newTreeRootTmp = NULL; + PdmUiTreeOrdering* newTreeRootTmp = nullptr; PdmUiFieldHandle* field = dynamic_cast (pdmRoot); if (field) { @@ -167,7 +167,7 @@ void PdmUiTreeViewModel::updateSubTree(PdmUiItem* pdmRoot) QModelIndex existingSubTreeRootModIdx = findModelIndex(pdmRoot); - PdmUiTreeOrdering* existingSubTreeRoot = NULL; + PdmUiTreeOrdering* existingSubTreeRoot = nullptr; if (existingSubTreeRootModIdx.isValid()) { existingSubTreeRoot = treeItemFromIndex(existingSubTreeRootModIdx); @@ -460,7 +460,7 @@ QModelIndex PdmUiTreeViewModel::index(int row, int column, const QModelIndex &pa if (!m_treeOrderingRoot) return QModelIndex(); - PdmUiTreeOrdering* parentItem = NULL; + PdmUiTreeOrdering* parentItem = nullptr; if (!parentIndex.isValid()) parentItem = m_treeOrderingRoot; @@ -794,7 +794,7 @@ PdmUiItem* PdmUiTreeViewModel::uiItemFromModelIndex(const QModelIndex& index) co return treeItem->activeItem(); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp b/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp index 6419e3b31d..4d725388c4 100644 --- a/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafPdmUiWidgetBasedObjectEditor.cpp @@ -76,7 +76,7 @@ void caf::PdmUiWidgetBasedObjectEditor::recursivelyConfigureAndUpdateUiItemsInGr CAF_ASSERT(containerWidgetWithGridLayout); int currentRowIndex = 0; - QWidget* previousTabOrderWidget = NULL; + QWidget* previousTabOrderWidget = nullptr; // Currently, only QGridLayout is supported QGridLayout* parentLayout = dynamic_cast(containerWidgetWithGridLayout->layout()); @@ -204,8 +204,8 @@ bool caf::PdmUiWidgetBasedObjectEditor::isUiGroupExpanded(const PdmUiGroup* uiGr QMinimizePanel* caf::PdmUiWidgetBasedObjectEditor::findOrCreateGroupBox(QWidget* parent, PdmUiGroup* group, const QString& uiConfigName) { QString groupBoxKey = group->keyword(); - QMinimizePanel* groupBox = NULL; - QGridLayout* groupBoxLayout = NULL; + QMinimizePanel* groupBox = nullptr; + QGridLayout* groupBoxLayout = nullptr; // Find or create groupBox std::map >::iterator it; @@ -338,7 +338,7 @@ void caf::PdmUiWidgetBasedObjectEditor::configureAndUpdateUi(const QString& uiCo std::map::iterator it; for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it) { - it->second->setField(NULL); + it->second->setField(nullptr); } // Set all group Boxes to be unvisited @@ -352,7 +352,7 @@ void caf::PdmUiWidgetBasedObjectEditor::configureAndUpdateUi(const QString& uiCo std::vector< PdmFieldHandle* > fvhToRemoveFromMap; for (it = m_fieldViews.begin(); it != m_fieldViews.end(); ++it) { - if (it->second->field() == 0) + if (it->second->field() == nullptr) { PdmUiFieldEditorHandle* fvh = it->second; delete fvh; diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp index f93989f57a..b81453a92a 100644 --- a/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp +++ b/Fwk/AppFwk/cafUserInterface/cafProgressInfo.cpp @@ -37,6 +37,7 @@ #include "cafProgressInfo.h" #include "cafAssert.h" +#include "cafProgressState.h" #include #include @@ -317,6 +318,13 @@ namespace caf { return progressDialog()->thread() == QThread::currentThread(); } + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + bool ProgressState::isActive() + { + return !maxProgressStack().empty(); + } //-------------------------------------------------------------------------------------------------- /// @@ -335,9 +343,14 @@ namespace caf { #pragma warning (push) #pragma warning (disable: 4996) AllocConsole(); - freopen("conin$", "r", stdin); - freopen("conout$", "w", stdout); - freopen("conout$", "w", stderr); + + FILE* consoleFilePointer; + errno_t err; + + err = freopen_s(&consoleFilePointer, "conin$", "r", stdin); + err = freopen_s(&consoleFilePointer, "conout$", "w", stdout); + err = freopen_s(&consoleFilePointer, "conout$", "w", stderr); + #pragma warning (pop) #endif } @@ -407,7 +420,7 @@ namespace caf { //progressDialog()->setWindowModality(Qt::ApplicationModal); progressDialog()->setMinimum(0); progressDialog()->setWindowTitle(title); - progressDialog()->setCancelButton(NULL); + progressDialog()->setCancelButton(nullptr); progressDialog()->show(); } @@ -421,8 +434,8 @@ namespace caf { progressDialog()->setValue(static_cast(currentTotalProgress())); progressDialog()->setLabelText(currentComposedLabel()); - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); } @@ -436,8 +449,8 @@ namespace caf { descriptionStack().back() = description; progressDialog()->setLabelText(currentComposedLabel()); - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); } @@ -478,8 +491,8 @@ namespace caf { progressDialog()->setMaximum(totalMaxProgress); progressDialog()->setValue(totalProgress); - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); } @@ -555,19 +568,20 @@ namespace caf { progressDialog()->setLabelText(currentComposedLabel()); // If we are finishing the last level, clean up - if (!maxProgressStack_v.size()) + if (maxProgressStack_v.empty()) { - if (progressDialog() != NULL) + if (progressDialog() != nullptr) { progressDialog()->reset(); progressDialog()->close(); } } - - // Make sure the Gui is repainted - //QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); - if (progressDialog()) progressDialog()->repaint(); - + else + { + // Make sure the Gui is repainted + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + //if (progressDialog()) progressDialog()->repaint(); + } } diff --git a/Fwk/AppFwk/cafUserInterface/cafProgressState.h b/Fwk/AppFwk/cafUserInterface/cafProgressState.h new file mode 100644 index 0000000000..7dc47bd6f6 --- /dev/null +++ b/Fwk/AppFwk/cafUserInterface/cafProgressState.h @@ -0,0 +1,47 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2011-2013 Ceetron AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +namespace caf { + +class ProgressState +{ +public: + static bool isActive(); +}; + +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafUserInterface/cafUiProcess.h b/Fwk/AppFwk/cafUserInterface/cafUiProcess.h index b7d365cddb..cdae59e947 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUiProcess.h +++ b/Fwk/AppFwk/cafUserInterface/cafUiProcess.h @@ -60,7 +60,7 @@ class UiProcess : public QProcess QTime m_timer; public: - explicit UiProcess(QObject* pParent = 0); + explicit UiProcess(QObject* pParent = nullptr); private: void doEmitStatusMsg(const QString& msg, int statusMsgType); diff --git a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt index 1644fccae9..7c717e4e31 100644 --- a/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt +++ b/Fwk/AppFwk/cafUserInterface/cafUserInterface_UnitTests/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) include (${QT_USE_FILE}) @@ -6,16 +6,7 @@ include (${QT_USE_FILE}) project ( cafUserInterface_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. - - ${cafProjectDataModel_SOURCE_DIR} - ${cafPdmCore_SOURCE_DIR} - ${cafPdmUiCore_SOURCE_DIR} - ${cafPdmXml_SOURCE_DIR} - - ${cafUserInterface_SOURCE_DIR} - + ${CMAKE_CURRENT_SOURCE_DIR} ) @@ -39,10 +30,6 @@ source_group("" FILES ${PROJECT_FILES}) message(STATUS ${PROJECT_NAME}" - Qt includes : " ${QT_LIBRARIES}) target_link_libraries ( ${PROJECT_NAME} - cafProjectDataModel - cafPdmUiCore - cafPdmCore - cafPdmXml cafUserInterface ${QT_LIBRARIES} ${THREAD_LIBRARY} diff --git a/Fwk/AppFwk/cafViewer/CMakeLists.txt b/Fwk/AppFwk/cafViewer/CMakeLists.txt index b0402fd991..2850fc3b0d 100644 --- a/Fwk/AppFwk/cafViewer/CMakeLists.txt +++ b/Fwk/AppFwk/cafViewer/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafViewer) @@ -6,22 +6,12 @@ project (cafViewer) find_package ( Qt4 COMPONENTS QtCore QtGui QtMain ) include (${QT_USE_FILE}) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} - - ${cafAnimControl_SOURCE_DIR} -) - # These headers need to go through Qt's MOC compiler set( QOBJECT_HEADERS cafViewer.h ) -if ( (${CMAKE_VERSION} VERSION_LESS 2.8.6) OR (NOT CMAKE_AUTOMOC) ) +if ( NOT CMAKE_AUTOMOC ) qt4_wrap_cpp( MOC_FILES_CPP ${QOBJECT_HEADERS} ) endif() @@ -44,3 +34,22 @@ add_library( ${PROJECT_NAME} ${MOC_FILES_CPP} ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibViewing + LibRender + LibGuiQt + + cafAnimControl + + ${QT_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp index 9c56d13f07..a8340535bc 100644 --- a/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCadNavigation.cpp @@ -77,7 +77,7 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier) + if (me->button() == Qt::MidButton && me->modifiers() == Qt::NoModifier && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); @@ -167,6 +167,8 @@ bool caf::CadNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp index e66df439b2..88f70e3516 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronNavigation.cpp @@ -132,6 +132,8 @@ bool caf::CeetronNavigation::handleInputEvent(QInputEvent* inputEvent) case QEvent::Wheel: wheelEvent(static_cast ( inputEvent)); break; + default: + break; } return false; diff --git a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp index 5a7bcd780e..0a7f233ae6 100644 --- a/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafCeetronPlusNavigation.cpp @@ -77,7 +77,7 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent) int translatedMousePosX, translatedMousePosY; cvfEventPos(me->x(), me->y(), &translatedMousePosX, &translatedMousePosY); - if (me->button() == Qt::RightButton) + if (me->button() == Qt::RightButton && isRotationEnabled()) { cvf::HitItemCollection hic; bool hitSomething = m_viewer->rayPick( me->x(), me->y(), &hic); @@ -202,6 +202,8 @@ bool caf::CeetronPlusNavigation::handleInputEvent(QInputEvent* inputEvent) } } break; + default: + break; } if (isSupposedToConsumeEvents()) diff --git a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp index 1813c08e3e..099a301ccf 100644 --- a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp +++ b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.cpp @@ -80,7 +80,7 @@ OpenGLWidget::OpenGLWidget(cvf::OpenGLContextGroup* contextGroup, const QGLForma // the construction process above has already optimistically added the new context to the existing group. // In this case, the newly context is basically defunct so we just shut it down (which will also remove it from the group) myContext->shutdownContext(); - CVF_ASSERT(myContext->group() == NULL); + CVF_ASSERT(myContext->group() == nullptr); } } else @@ -129,7 +129,7 @@ OpenGLWidget::OpenGLWidget(OpenGLWidget* shareWidget, QWidget* parent , Qt::Wind // the construction process above has already optimistically added the new context to the existing group. // In this case, the newly context is basically defunct so we just shut it down (which will also remove it from the group) myContext->shutdownContext(); - CVF_ASSERT(myContext->group() == NULL); + CVF_ASSERT(myContext->group() == nullptr); } } } diff --git a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h index b0cf0a5cd2..7bbf6176c9 100644 --- a/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h +++ b/Fwk/AppFwk/cafViewer/cafOpenGLWidget.h @@ -56,8 +56,8 @@ namespace caf { class OpenGLWidget : public QGLWidget { public: - OpenGLWidget(cvf::OpenGLContextGroup* contextGroup, const QGLFormat& format, QWidget* parent, OpenGLWidget* shareWidget = NULL, Qt::WindowFlags f = 0); - OpenGLWidget(OpenGLWidget* shareWidget, QWidget* parent , Qt::WindowFlags f = 0); + OpenGLWidget(cvf::OpenGLContextGroup* contextGroup, const QGLFormat& format, QWidget* parent, OpenGLWidget* shareWidget = nullptr, Qt::WindowFlags f = nullptr); + OpenGLWidget(OpenGLWidget* shareWidget, QWidget* parent , Qt::WindowFlags f = nullptr); cvf::OpenGLContext* cvfOpenGLContext() const; void cvfShutdownOpenGLContext(); diff --git a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp index 519b5d8534..7352ff7994 100644 --- a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp +++ b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.cpp @@ -78,6 +78,7 @@ void caf::TrackBallBasedNavigation::init() m_trackball = new cvf::ManipulatorTrackball; m_trackball->setCamera(m_viewer->mainCamera()); m_isRotCenterInitialized = false; + m_isRotationEnabled = true; m_hasMovedMouseDuringNavigation = false; m_isNavigating = false; m_isZooming = false; @@ -190,7 +191,7 @@ cvf::ref caf::TrackBallBasedNavigation::createZoomRay(int cvfXPos, int cvf::Camera* cam = m_viewer->mainCamera(); ray = cam->rayFromWindowCoordinates(cvfXPos, cvfYPos); - if (cam->projection() == cvf::Camera::ORTHO) + if (ray.notNull() && cam->projection() == cvf::Camera::ORTHO) { cvf::Vec3d camDir = cam->direction(); cvf::Plane focusPlane; diff --git a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h index 0157e48b4f..a27596fb12 100644 --- a/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h +++ b/Fwk/AppFwk/cafViewer/cafTrackBallBasedNavigation.h @@ -59,6 +59,7 @@ class TrackBallBasedNavigation: public NavigationPolicy TrackBallBasedNavigation(); virtual ~TrackBallBasedNavigation(); void enableEventEating(bool enable) { m_consumeEvents = enable; } + void enableRotation(bool enable) { m_isRotationEnabled = enable; } protected: // General navigation policy overrides @@ -88,9 +89,11 @@ class TrackBallBasedNavigation: public NavigationPolicy int m_lastPosY; bool isSupposedToConsumeEvents() { return m_consumeEvents; } + bool isRotationEnabled() { return m_isRotationEnabled; } private: bool m_consumeEvents; + bool m_isRotationEnabled; }; } // End namespace caf diff --git a/Fwk/AppFwk/cafViewer/cafViewer.cpp b/Fwk/AppFwk/cafViewer/cafViewer.cpp index c872596b77..f38c310505 100644 --- a/Fwk/AppFwk/cafViewer/cafViewer.cpp +++ b/Fwk/AppFwk/cafViewer/cafViewer.cpp @@ -113,13 +113,13 @@ cvf::ref caf::Viewer::sm_openGLContextGroup; //-------------------------------------------------------------------------------------------------- caf::Viewer::Viewer(const QGLFormat& format, QWidget* parent) : caf::OpenGLWidget(contextGroup(), format, new QWidget(parent), sharedWidget()), - m_navigationPolicy(NULL), + m_navigationPolicy(nullptr), + m_navigationPolicyEnabled(true), m_defaultPerspectiveNearPlaneDistance(0.05), m_maxClipPlaneDistance(cvf::UNDEFINED_DOUBLE), m_cameraFieldOfViewYDeg(40.0), - m_releaseOGLResourcesEachFrame(false), m_paintCounter(0), - m_navigationPolicyEnabled(true), + m_releaseOGLResourcesEachFrame(false), m_isOverlayPaintingEnabled(true), m_offscreenViewportWidth(0), m_offscreenViewportHeight(0) @@ -247,7 +247,7 @@ caf::Viewer* caf::Viewer::sharedWidget() return *(sm_viewers.begin()); } - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -676,9 +676,11 @@ void caf::Viewer::zoomAll() cvf::Vec3d newEye = m_mainCamera->computeFitViewEyePosition(bb, vrp-eye, up, 0.9, m_cameraFieldOfViewYDeg, m_mainCamera->viewport()->aspectRatio()); m_mainCamera->setFromLookAt(newEye, bb.center(), up); - + updateParallelProjectionHeightFromMoveZoom(bb.center()); + if (m_navigationPolicy.notNull()) m_navigationPolicy->setPointOfInterest(bb.center()); + navigationPolicyUpdate(); } @@ -733,7 +735,7 @@ void caf::Viewer::slotSetCurrentFrame(int frameIndex) int clampedFrameIndex = clampFrameIndex(frameIndex); - if (m_frameScenes.at(clampedFrameIndex) == NULL) return; + if (m_frameScenes.at(clampedFrameIndex) == nullptr) return; if (m_releaseOGLResourcesEachFrame) { @@ -883,7 +885,7 @@ cvf::Scene* caf::Viewer::frame(size_t frameIndex) if (frameIndex < m_frameScenes.size()) return m_frameScenes[frameIndex].p(); else - return NULL; + return nullptr; } //-------------------------------------------------------------------------------------------------- @@ -1101,7 +1103,7 @@ void caf::Viewer::appendAllStaticModelsToFrame(cvf::Scene* scene) //-------------------------------------------------------------------------------------------------- cvf::OverlayItem* caf::Viewer::overlayItem(int winPosX, int winPosY) { - if (m_mainRendering.isNull()) return NULL; + if (m_mainRendering.isNull()) return nullptr; int translatedMousePosX = winPosX; int translatedMousePosY = height() - winPosY; diff --git a/Fwk/AppFwk/cafViewer/cafViewer.h b/Fwk/AppFwk/cafViewer/cafViewer.h index 23db03d2d6..9a58b4ee64 100644 --- a/Fwk/AppFwk/cafViewer/cafViewer.h +++ b/Fwk/AppFwk/cafViewer/cafViewer.h @@ -54,7 +54,6 @@ namespace cvf { class Model; class OverlayImage; class OverlayItem; - class OverlayScalarMapperLegend; class RenderSequence; class Rendering; class Scene; diff --git a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt index a743f3b293..2d0f236581 100644 --- a/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt +++ b/Fwk/AppFwk/cafVizExtensions/CMakeLists.txt @@ -1,19 +1,10 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (cafVizExtensions) # Open GL find_package( OpenGL ) -include_directories( - ${LibCore_SOURCE_DIR} - ${LibGeometry_SOURCE_DIR} - ${LibGuiQt_SOURCE_DIR} - ${LibRender_SOURCE_DIR} - ${LibViewing_SOURCE_DIR} - ${CommonCode_SOURCE_DIR} -) - add_library( ${PROJECT_NAME} cafDisplayCoordTransform.cpp cafDisplayCoordTransform.h @@ -21,14 +12,22 @@ add_library( ${PROJECT_NAME} cafBoxManipulatorPartManager.h cafBoxManipulatorGeometryGenerator.cpp cafBoxManipulatorGeometryGenerator.h + cafTitledOverlayFrame.cpp + cafTitledOverlayFrame.h cafCategoryLegend.cpp cafCategoryLegend.h + cafOverlayScalarMapperLegend.h + cafOverlayScalarMapperLegend.cpp + cafInternalLegendRenderTools.h + cafInternalLegendRenderTools.cpp cafCategoryMapper.cpp cafCategoryMapper.h cafFixedAtlasFont.h cafFixedAtlasFont.cpp cafTransparentWBRenderConfiguration.h cafTransparentWBRenderConfiguration.cpp + cafLine.h + cafLine.inl TranspWB_CombinationFrag.glsl TranspWB_PartlyTranspPartsFrag.glsl TranspWB_TransparentPartsFrag.glsl @@ -36,3 +35,22 @@ add_library( ${PROJECT_NAME} cafHexGridIntersectionTools/cafHexGridIntersectionTools.h cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp ) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibViewing + LibRender + LibGuiQt + + CommonCode + + ${QT_LIBRARIES} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp index 8a1254cc76..5dc1603592 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorGeometryGenerator.cpp @@ -55,7 +55,7 @@ cvf::ref BoxManipulatorGeometryGenerator::createBoundingBoxMes calculateArrays(); } - if (!(m_vertices.notNull() && m_vertices->size() != 0)) return NULL; + if (!(m_vertices.notNull() && m_vertices->size() != 0)) return nullptr; cvf::ref geo = new cvf::DrawableGeo; geo->setVertexArray(m_vertices.p()); diff --git a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp index b254736d0c..0a388addd5 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.cpp @@ -3,6 +3,7 @@ #include "cafBoxManipulatorGeometryGenerator.h" #include "cafEffectGenerator.h" +#include "cafLine.h" #include "cvfBoxGenerator.h" #include "cvfDrawableGeo.h" @@ -150,11 +151,12 @@ void BoxManipulatorPartManager::updateManipulatorFromRay(const cvf::Ray* ray) BoxFace face = m_handleIds[m_currentHandleIndex].first; cvf::Vec3d faceDir = normalFromFace(face); - cvf::Vec3d closestPointOnMouseRay; - cvf::Vec3d closestPointOnHandleRay; - BoxManipulatorPartManager::closestPointOfTwoLines(ray->origin(), ray->origin() + ray->direction(), - m_initialPickPoint, m_initialPickPoint + faceDir, - &closestPointOnMouseRay, &closestPointOnHandleRay); + caf::Line rayLine(ray->origin(), ray->origin() + ray->direction()); + caf::Line pickLine(m_initialPickPoint, m_initialPickPoint + faceDir); + + caf::Line mouseHandleLine = rayLine.findLineBetweenNearestPoints(pickLine); + cvf::Vec3d closestPointOnMouseRay = mouseHandleLine.start(); + cvf::Vec3d closestPointOnHandleRay = mouseHandleLine.end(); cvf::Vec3d newOrigin = m_origin; cvf::Vec3d newSize = m_size; @@ -402,72 +404,5 @@ void BoxManipulatorPartManager::createBoundingBoxPart() } } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -bool BoxManipulatorPartManager::closestPointOfTwoLines(const cvf::Vec3d& L1p1, const cvf::Vec3d& L1p2, - const cvf::Vec3d& L2p1, const cvf::Vec3d& L2p2, - cvf::Vec3d* closestPointOnL1, cvf::Vec3d* closestPointOnL2) -{ - // qDebug() << p1 << " " << q1 << " " << p2 << " " << q2; - - // Taken from Real-Time Collistion Detection, Christer Ericson, 2005, p146-147 - - // L1(s) = P1 + sd1 - // L2(t) = P2 + td2 - - // d1 = Q1-P1 - // d2 = Q2-P2 - - // r = P1-P2 - - // a = d1*d1 - // b = d1*d2 - // c = d1*r - // e = d2*d2; - // d = ae-b^2 - // f = d2*r - - // s = (bf-ce)/d - // t = (af-bc)/d - - - cvf::Vec3d d1 = L1p2 - L1p1; - cvf::Vec3d d2 = L2p2 - L2p1; - - double a = d1.dot(d1); - double b = d1.dot(d2); - double e = d2.dot(d2); - - double d = a*e - b*b; - - if (d < std::numeric_limits::epsilon()) - { - // Parallel lines - if (closestPointOnL1) *closestPointOnL1 = L1p1; - if (closestPointOnL2) *closestPointOnL2 = L2p1; - return false; - } - - cvf::Vec3d r = L1p1 - L2p1; - double c = d1.dot(r); - double f = d2.dot(r); - - double s = (b*f - c*e) / d; - double t = (a*f - b*c) / d; - - if (closestPointOnL1) *closestPointOnL1 = L1p1 + s*d1; - if (closestPointOnL2) *closestPointOnL2 = L2p1 + t*d2; - - if (s >= 0 && s <= 1 && t >= 0 && t <= 1) - { - return true; - } - else - { - return false; - } -} - -} // namespace cvf +} // namespace caf diff --git a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h index 757f982aa8..dd9612c50e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h +++ b/Fwk/AppFwk/cafVizExtensions/cafBoxManipulatorPartManager.h @@ -79,9 +79,6 @@ class BoxManipulatorPartManager : public cvf::Object const cvf::Vec3f& v3, const cvf::Vec3f& v4, const cvf::Vec3f& v5); - static bool closestPointOfTwoLines(const cvf::Vec3d& p1, const cvf::Vec3d& q1, - const cvf::Vec3d& p2, const cvf::Vec3d& q2, - cvf::Vec3d* closestPoint1, cvf::Vec3d* closestPoint2); private: std::vector< std::pair > m_handleIds; // These arrays have the same length diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp index 80296c4ba1..c1eb88ac3e 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.cpp @@ -27,7 +27,9 @@ #endif #include "cvfScalarMapper.h" +#include "cafInternalLegendRenderTools.h" +#include using namespace cvf; @@ -38,12 +40,9 @@ namespace caf { /// //-------------------------------------------------------------------------------------------------- CategoryLegend::CategoryLegend(Font* font, const CategoryMapper* categoryMapper) - : m_sizeHint(200, 200), - m_color(Color3::BLACK), - m_lineColor(Color3::BLACK), - m_lineWidth(1), - m_font(font), - m_categoryMapper(categoryMapper) + : TitledOverlayFrame(font, 200, 200) + , m_categoryMapper(categoryMapper) + , m_Layout(Vec2ui(200u, 200u)) { CVF_ASSERT(font); CVF_ASSERT(!font->isEmpty()); @@ -57,76 +56,6 @@ CategoryLegend::~CategoryLegend() // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -cvf::Vec2ui CategoryLegend::sizeHint() -{ - return m_sizeHint; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setSizeHint(const Vec2ui& size) -{ - m_sizeHint = size; -} - -//-------------------------------------------------------------------------------------------------- -/// Set color of the text and lines to be rendered -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setColor(const Color3f& color) -{ - m_color = color; -} - - -//-------------------------------------------------------------------------------------------------- -/// Returns the color of the text and lines -//-------------------------------------------------------------------------------------------------- -const Color3f& CategoryLegend::color() const -{ - return m_color; -} - -//-------------------------------------------------------------------------------------------------- -/// Set the title (text that will be rendered above the legend) -/// -/// The legend supports multi-line titles. Separate each line with a '\n' character -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setTitle(const String& title) -{ - // Title - if (title.isEmpty()) - { - m_titleStrings.clear(); - } - else - { - m_titleStrings = title.split("\n"); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -String CategoryLegend::title() const -{ - String title; - for (size_t i = 0; i < m_titleStrings.size(); ++i) - { - title += m_titleStrings[i]; - - if (i != m_titleStrings.size() - 1) - { - title += "\n"; - } - } - - return title; -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -145,7 +74,7 @@ size_t CategoryLegend::categoryCount() const //-------------------------------------------------------------------------------------------------- void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - render(oglContext, position, size, false); + renderGeneric(oglContext, position, size, false); } //-------------------------------------------------------------------------------------------------- @@ -153,7 +82,7 @@ void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, co //-------------------------------------------------------------------------------------------------- void CategoryLegend::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) { - render(oglContext, position, size, true); + renderGeneric(oglContext, position, size, true); } //-------------------------------------------------------------------------------------------------- @@ -163,14 +92,14 @@ bool CategoryLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, c { Recti oglRect(position, size.x(), size.y()); - OverlayColorLegendLayoutInfo layoutInViewPortCoords(oglRect.min(), Vec2ui(oglRect.width(), oglRect.height())); + OverlayColorLegendLayoutInfo layoutInViewPortCoords( Vec2ui(oglRect.width(), oglRect.height())); layoutInfo(&layoutInViewPortCoords); Vec2i legendBarOrigin = oglRect.min(); - legendBarOrigin.x() += static_cast(layoutInViewPortCoords.legendRect.min().x()); - legendBarOrigin.y() += static_cast(layoutInViewPortCoords.legendRect.min().y()); + legendBarOrigin.x() += static_cast(layoutInViewPortCoords.colorBarRect.min().x()); + legendBarOrigin.y() += static_cast(layoutInViewPortCoords.colorBarRect.min().y()); - Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.legendRect.width()), static_cast(layoutInViewPortCoords.legendRect.height())); + Recti legendBarRect = Recti(legendBarOrigin, static_cast(layoutInViewPortCoords.colorBarRect.width()), static_cast(layoutInViewPortCoords.colorBarRect.height())); if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) && (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y())) @@ -184,7 +113,10 @@ bool CategoryLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, c //-------------------------------------------------------------------------------------------------- /// Set up camera/viewport and render //-------------------------------------------------------------------------------------------------- -void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +void CategoryLegend::renderGeneric(OpenGLContext* oglContext, + const Vec2i& position, + const Vec2ui& size, + bool software) { if (size.x() <= 0 || size.y() <= 0) { @@ -198,26 +130,36 @@ void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, co camera.applyOpenGL(); camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); - // Get layout information - // Todo: Cache this between renderings. Update only when needed. - OverlayColorLegendLayoutInfo layout(position, size); - layoutInfo(&layout); + m_Layout = OverlayColorLegendLayoutInfo(size); + layoutInfo(&m_Layout); + m_textDrawer = new TextDrawer(this->font()); // Set up text drawer - TextDrawer textDrawer(m_font.p()); - setupTextDrawer(&textDrawer, &layout); + float maxLegendRightPos = 0; + setupTextDrawer(m_textDrawer.p(), &m_Layout); + + Vec2f backgroundSize(size); // Do the actual rendering if (software) { - renderLegendImmediateMode(oglContext, &layout); - textDrawer.renderSoftware(oglContext, camera); + if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + backgroundSize, + this->backgroundColor(), + this->backgroundFrameColor()); + renderLegendImmediateMode(oglContext, &m_Layout); + m_textDrawer->renderSoftware(oglContext, camera); } else { const MatrixState matrixState(camera); - renderLegend(oglContext, &layout, matrixState); - textDrawer.render(oglContext, camera); + if (this->backgroundEnabled()) InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + matrixState, + backgroundSize, + this->backgroundColor(), + this->backgroundFrameColor()); + renderLegendUsingShaders(oglContext, &m_Layout, matrixState); + m_textDrawer->render(oglContext, camera); } CVF_CHECK_OGL(oglContext); @@ -226,7 +168,8 @@ void CategoryLegend::render(OpenGLContext* oglContext, const Vec2i& position, co //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout) +void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, + const OverlayColorLegendLayoutInfo* layout) { if (m_categoryMapper.isNull()) { @@ -236,11 +179,11 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL CVF_ASSERT(layout); textDrawer->setVerticalAlignment(TextDrawer::CENTER); - textDrawer->setTextColor(m_color); + textDrawer->setTextColor(this->textColor()); m_visibleCategoryLabels.clear(); - const float textX = layout->tickX + 5; + const float textX = layout->tickEndX + layout->tickTextLeadSpace; const float overlapTolerance = 1.2f * layout->charHeight; float lastVisibleTextY = 0.0; @@ -248,11 +191,11 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL CVF_ASSERT(m_categoryMapper.notNull()); size_t numLabels = m_categoryMapper->categoryCount(); - float categoryHeight = static_cast(layout->legendRect.height() / numLabels); + float categoryHeight = static_cast(layout->colorBarRect.height() / numLabels); for (size_t it = 0; it < numLabels; it++) { - float textY = static_cast(layout->legendRect.min().y() + it * categoryHeight + categoryHeight / 2); + float textY = static_cast(layout->colorBarRect.min().y() + it * categoryHeight + categoryHeight / 2); // Always draw first and last tick label. For all others, skip drawing if text ends up // on top of the previous label. @@ -265,7 +208,7 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL } // Make sure it does not overlap the last tick as well - float lastTickY = static_cast(layout->legendRect.max().y()); + float lastTickY = static_cast(layout->colorBarRect.max().y()); if (cvf::Math::abs(textY - lastTickY) < overlapTolerance) { @@ -283,30 +226,33 @@ void CategoryLegend::setupTextDrawer(TextDrawer* textDrawer, OverlayColorLegendL m_visibleCategoryLabels.push_back(true); } - float titleY = static_cast(layout->size.y()) - layout->margins.y() - layout->charHeight / 2.0f; - for (size_t it = 0; it < m_titleStrings.size(); it++) + float titleY = static_cast(layout->overallLegendSize.y()) - layout->margins.y() - layout->charHeight / 2.0f; + for (size_t it = 0; it < this->titleStrings().size(); it++) { Vec2f pos(layout->margins.x(), titleY); - textDrawer->addText(m_titleStrings[it], pos); + textDrawer->addText(this->titleStrings()[it], pos); titleY -= layout->lineSpacing; } + } //-------------------------------------------------------------------------------------------------- /// Draw the legend using shader programs //-------------------------------------------------------------------------------------------------- -void CategoryLegend::renderLegend(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState) +void CategoryLegend::renderLegendUsingShaders(OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout, + const MatrixState& matrixState) { CVF_CALLSITE_OPENGL(oglContext); CVF_TIGHT_ASSERT(layout); - CVF_TIGHT_ASSERT(layout->size.x() > 0); - CVF_TIGHT_ASSERT(layout->size.y() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); RenderStateDepth depth(false); depth.applyOpenGL(oglContext); - RenderStateLine line(static_cast(m_lineWidth)); + RenderStateLine line(static_cast(this->lineWidth())); line.applyOpenGL(oglContext); // All vertices. Initialized here to set Z to zero once and for all. @@ -327,8 +273,8 @@ void CategoryLegend::renderLegend(OpenGLContext* oglContext, OverlayColorLegendL float* v4 = &vertexArray[12]; // Constant coordinates - v0[0] = v3[0] = layout->x0; - v1[0] = v4[0] = layout->x1; + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; // Connects static const ushort trianglesConnects[] = { 0, 1, 4, 0, 4, 3 }; @@ -348,15 +294,15 @@ void CategoryLegend::renderLegend(OpenGLContext* oglContext, OverlayColorLegendL // Render color bar as one colored quad per pixel - int legendHeightPixelCount = static_cast(layout->legendRect.height()); + int legendHeightPixelCount = static_cast(layout->colorBarRect.height()); if (m_categoryMapper.notNull()) { int iPx; for (iPx = 0; iPx < legendHeightPixelCount; iPx++) { const Color3ub& clr = m_categoryMapper->mapToColor(m_categoryMapper->domainValue((iPx + 0.5) / legendHeightPixelCount)); - float y0 = static_cast(layout->legendRect.min().y() + iPx); - float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); // Dynamic coordinates for rectangle v0[1] = v1[1] = y0; @@ -382,13 +328,13 @@ void CategoryLegend::renderLegend(OpenGLContext* oglContext, OverlayColorLegendL bool isRenderingFrame = true; if (isRenderingFrame) { - v0[0] = v2[0] = layout->legendRect.min().x() - 0.5f; - v1[0] = v3[0] = layout->legendRect.max().x() - 0.5f; - v0[1] = v1[1] = layout->legendRect.min().y() - 0.5f; - v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; + v0[0] = v2[0] = layout->colorBarRect.min().x() - 0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x() - 0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y() - 0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y() - 0.5f; static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0 }; - UniformFloat uniformColor("u_color", Color4f(m_lineColor)); + UniformFloat uniformColor("u_color", Color4f(this->lineColor())); shaderProgram->applyUniform(oglContext, uniformColor); #ifdef CVF_OPENGL_ES @@ -424,8 +370,8 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla CVF_FAIL_MSG("Not supported on OpenGL ES"); #else CVF_TIGHT_ASSERT(layout); - CVF_TIGHT_ASSERT(layout->size.x() > 0); - CVF_TIGHT_ASSERT(layout->size.y() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); RenderStateDepth depth(false); depth.applyOpenGL(oglContext); @@ -451,20 +397,20 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla float* v4 = &vertexArray[12]; // Constant coordinates - v0[0] = v3[0] = layout->x0; - v1[0] = v4[0] = layout->x1; + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; // Render color bar as one colored quad per pixel - int legendHeightPixelCount = static_cast(layout->legendRect.height()); + int legendHeightPixelCount = static_cast(layout->colorBarRect.height()); if (m_categoryMapper.notNull()) { int iPx; for (iPx = 0; iPx < legendHeightPixelCount; iPx++) { const Color3ub& clr = m_categoryMapper->mapToColor(m_categoryMapper->domainValue((iPx + 0.5) / legendHeightPixelCount)); - float y0 = static_cast(layout->legendRect.min().y() + iPx); - float y1 = static_cast(layout->legendRect.min().y() + iPx + 1); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); // Dynamic coordinates for rectangle v0[1] = v1[1] = y0; @@ -487,12 +433,12 @@ void CategoryLegend::renderLegendImmediateMode(OpenGLContext* oglContext, Overla bool isRenderingFrame = true; if (isRenderingFrame) { - v0[0] = v2[0] = layout->legendRect.min().x() - 0.5f; - v1[0] = v3[0] = layout->legendRect.max().x() - 0.5f; - v0[1] = v1[1] = layout->legendRect.min().y() - 0.5f; - v2[1] = v3[1] = layout->legendRect.max().y() - 0.5f; + v0[0] = v2[0] = layout->colorBarRect.min().x() - 0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x() - 0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y() - 0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y() - 0.5f; - glColor3fv(m_color.ptr()); + glColor3fv(this->textColor().ptr()); glBegin(GL_LINES); glVertex3fv(v0); glVertex3fv(v1); @@ -523,55 +469,59 @@ void CategoryLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) { CVF_TIGHT_ASSERT(layout); - ref glyph = m_font->getGlyph(L'A'); - layout->charHeight = static_cast(glyph->height()); + ref glyph = this->font()->getGlyph(L'A'); + layout->charHeight = static_cast(glyph->height()); layout->lineSpacing = layout->charHeight*1.5f; - layout->margins = Vec2f(4.0f, 4.0f); - - float legendWidth = 25.0f; - float legendHeight = static_cast(layout->size.y()) - 2 * layout->margins.y() - static_cast(m_titleStrings.size())*layout->lineSpacing - layout->lineSpacing; - layout->legendRect = Rectf(layout->margins.x(), layout->margins.y() + layout->charHeight / 2.0f, legendWidth, legendHeight); - - if (layout->legendRect.width() < 1 || layout->legendRect.height() < 1) - { - return; - } - - layout->x0 = layout->margins.x(); - layout->x1 = layout->margins.x() + layout->legendRect.width(); - layout->tickX = layout->x1 + 5; + layout->margins = Vec2f(8.0f, 8.0f); + layout->tickTextLeadSpace = 5.0f; + + float colorBarWidth = 25.0f; + float colorBarHeight = static_cast(layout->overallLegendSize.y()) + - 2 * layout->margins.y() + - static_cast(this->titleStrings().size()) * layout->lineSpacing + - layout->lineSpacing; + layout->colorBarRect = Rectf(layout->margins.x(), + layout->margins.y() + layout->charHeight / 2.0f, + colorBarWidth, + colorBarHeight); + + layout->tickStartX = layout->margins.x(); + layout->tickMidX = layout->margins.x() + layout->colorBarRect.width(); + layout->tickEndX = layout->tickMidX + 5; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void CategoryLegend::setLineColor(const Color3f& lineColor) +cvf::Vec2ui CategoryLegend::preferredSize() { - m_lineColor = lineColor; -} + OverlayColorLegendLayoutInfo layout({200,200}); // Use default size + layoutInfo(&layout); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -const Color3f& CategoryLegend::lineColor() const -{ - return m_lineColor; -} + float prefferredYSize = 2 * layout.margins.y() + + layout.lineSpacing * (this->titleStrings().size()) + + 1.5f * layout.lineSpacing * (m_categoryMapper->categoryCount() + 1); -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void CategoryLegend::setLineWidth(int lineWidth) -{ - m_lineWidth = lineWidth; -} + unsigned int maxTickTextWidth = 0; + for (size_t cIdx = 0; cIdx < m_categoryMapper->categoryCount(); ++cIdx ) + { + cvf::String cathegoryText = m_categoryMapper->textForCategoryIndex(cIdx); + unsigned int textWidth = this->font()->textExtent(cathegoryText).x(); + maxTickTextWidth = maxTickTextWidth < textWidth ? textWidth : maxTickTextWidth; + } + + float prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; + + for (const cvf::String& titleLine : titleStrings()) + { + float titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); + prefferredXSize = prefferredXSize < titleWidth ? titleWidth : prefferredXSize; + } + + prefferredXSize = std::min(prefferredXSize, 400.0f); + + return { (unsigned int)(std::ceil(prefferredXSize)), (unsigned int)(std::ceil(prefferredYSize)) }; -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -int CategoryLegend::lineWidth() const -{ - return m_lineWidth; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h index 74e9f1d03a..33090e6a39 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h +++ b/Fwk/AppFwk/cafVizExtensions/cafCategoryLegend.h @@ -1,6 +1,7 @@ #pragma once +#include "cafTitledOverlayFrame.h" #include "cvfBase.h" #include "cvfArray.h" #include "cvfCamera.h" @@ -23,88 +24,65 @@ class CategoryMapper; // // //================================================================================================== -class CategoryLegend : public cvf::OverlayItem +class CategoryLegend : public caf::TitledOverlayFrame { public: CategoryLegend(cvf::Font* font, const CategoryMapper* categoryMapper); virtual ~CategoryLegend(); - virtual cvf::Vec2ui sizeHint(); + size_t categoryCount() const; - virtual void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - virtual void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size); - virtual bool pick(int oglXCoord, int oglYCoord, const cvf::Vec2i& position, const cvf::Vec2ui& size); - - - void setSizeHint(const cvf::Vec2ui& size); - - void setColor(const cvf::Color3f& color); - const cvf::Color3f& color() const; - - void setLineColor(const cvf::Color3f& lineColor); - const cvf::Color3f& lineColor() const; - void setLineWidth(int lineWidth); - int lineWidth() const; - - void setTitle(const cvf::String& title); - cvf::String title() const; - - size_t categoryCount() const; + cvf::Vec2ui preferredSize() override; protected: + void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + void renderSoftware(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; + bool pick(int oglXCoord, int oglYCoord, const cvf::Vec2i& position, const cvf::Vec2ui& size) override; - //================================================================================================== - // - // Helper for storing layout info - // - //================================================================================================== struct OverlayColorLegendLayoutInfo { - OverlayColorLegendLayoutInfo(const cvf::Vec2i& pos, const cvf::Vec2ui& setSize) + OverlayColorLegendLayoutInfo(const cvf::Vec2ui& setSize) { charHeight = 0.0f; lineSpacing = 0.0f; margins = cvf::Vec2f::ZERO; - tickX = 0.0f; - x0 = 0.0f; - x1 = 0.0f; + tickEndX = 0.0f; + tickStartX = 0.0f; + tickMidX = 0.0f; - position = pos; - size = setSize; + overallLegendSize = setSize; } float charHeight; float lineSpacing; cvf::Vec2f margins; - float tickX; - float x0, x1; + float tickStartX, tickMidX, tickEndX; + float tickTextLeadSpace; - cvf::Rectf legendRect; + cvf::Rectf colorBarRect; - cvf::Vec2i position; - cvf::Vec2ui size; + cvf::Vec2ui overallLegendSize; }; + void layoutInfo(OverlayColorLegendLayoutInfo* layout); - void render(cvf::OpenGLContext* oglContext, const cvf::Vec2i& position, const cvf::Vec2ui& size, bool software); - virtual void renderLegend(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const cvf::MatrixState& matrixState); - virtual void renderLegendImmediateMode(cvf::OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout); - virtual void setupTextDrawer(cvf::TextDrawer* textDrawer, OverlayColorLegendLayoutInfo* layout); - - void layoutInfo(OverlayColorLegendLayoutInfo* layout); + void renderGeneric(cvf::OpenGLContext* oglContext, + const cvf::Vec2i& position, + const cvf::Vec2ui& size, + bool software); + void setupTextDrawer(cvf::TextDrawer* textDrawer, + const OverlayColorLegendLayoutInfo* layout); + void renderLegendUsingShaders(cvf::OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout, + const cvf::MatrixState& matrixState); + void renderLegendImmediateMode(cvf::OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout); protected: - std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label - - cvf::Vec2ui m_sizeHint; // Pixel size of the color legend area - - cvf::Color3f m_color; - cvf::Color3f m_lineColor; - int m_lineWidth; - std::vector m_titleStrings; - cvf::ref m_font; - - cvf::cref m_categoryMapper; + std::vector m_visibleCategoryLabels; // Skip labels ending up on top of previous visible label + OverlayColorLegendLayoutInfo m_Layout; + cvf::ref m_textDrawer; + cvf::cref m_categoryMapper; }; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h b/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h index f4e73ceda7..3e31256cd8 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h +++ b/Fwk/AppFwk/cafVizExtensions/cafDisplayCoordTransform.h @@ -20,15 +20,14 @@ class DisplayCoordTransform : public cvf::Object void setTranslation(const cvf::Vec3d& translation); cvf::Vec3d transformToDisplayCoord(const cvf::Vec3d& domainCoord) const; + cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const; + cvf::Vec3d scaleToDisplaySize(const cvf::Vec3d& domainSize) const; cvf::Vec3d translateToDomainCoord(const cvf::Vec3d& displayCoord) const; cvf::Vec3d transformToDomainCoord(const cvf::Vec3d& displayCoord) const; cvf::Vec3d scaleToDomainSize(const cvf::Vec3d& displaySize) const; -private: - cvf::Vec3d translateToDisplayCoord(const cvf::Vec3d& domainCoord) const; - private: cvf::Vec3d m_scale; cvf::Vec3d m_translation; diff --git a/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp b/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp index fcb33dfd8d..374ef3f607 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafFixedAtlasFont.cpp @@ -18055,7 +18055,7 @@ const size_t CVF_FIXED_ATLAS_FONT_LARGE_TEXTURE_IMAGE_BLOCK_COUNT = 588; FixedAtlasFont::FixedAtlasFont(FontSize size) : m_name(""), m_numGlyphs(0), - m_textureImage(NULL) + m_textureImage(nullptr) { bool fontLoaded = false; @@ -18160,7 +18160,7 @@ FixedAtlasFont::FixedAtlasFont(FontSize size) // Make sure isEmpty fails if unable to load if (!fontLoaded) { - m_textureImage = NULL; + m_textureImage = nullptr; } } @@ -18187,11 +18187,11 @@ const cvf::String& FixedAtlasFont::name() const //-------------------------------------------------------------------------------------------------- cvf::ref FixedAtlasFont::getGlyph(wchar_t character) { - if (isEmpty()) return NULL; + if (isEmpty()) return nullptr; cvf::uint characterPos = static_cast(character) > static_cast(m_numGlyphs) ? 0 : static_cast(character); - cvf::ref glyph = NULL; + cvf::ref glyph = nullptr; // Glyph already available? MapType::iterator it = m_atlasMap.find(characterPos); @@ -18368,7 +18368,7 @@ void FixedAtlasFont::unload() m_horizontalAdvances.clear(); m_characterWidths.clear(); m_characterHeights.clear(); - m_textureImage = NULL; + m_textureImage = nullptr; } } // namespace cvf diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp index f6ec78936c..a7934f5935 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.cpp @@ -4,7 +4,7 @@ #include "cvfPlane.h" #include - +#include namespace caf { @@ -31,10 +31,16 @@ HexGridIntersectionTools::ClipVx::ClipVx() /// \param normalizedDistFromA Returns the normalized (0..1) position from a to b of the intersection point. /// Will return values along the infinite line defined by the a-b direcion, /// and HUGE_VAL if plane and line are parallel. +/// \param epsilon Tolerance margin for accepting the position being within (0..1) /// /// \return True if line segment intersects the plane //-------------------------------------------------------------------------------------------------- -bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const cvf::Vec3d& a, const cvf::Vec3d& b, cvf::Vec3d* intersection, double* normalizedDistFromA) +bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, + const cvf::Vec3d& a, + const cvf::Vec3d& b, + cvf::Vec3d* intersection, + double* normalizedDistFromA, + double epsilon) { // From Real-Time Collision Detection by Christer Eriscon, published by Morgen Kaufmann Publishers, (c) 2005 Elsevier Inc @@ -53,7 +59,7 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const (*intersection) = a + interpolationParameter * ab; (*normalizedDistFromA) = interpolationParameter; - return (interpolationParameter >= 0.0 && interpolationParameter <= 1.0); + return (interpolationParameter >= -epsilon && interpolationParameter <= 1.0 + epsilon); } @@ -66,7 +72,8 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const // The permutations except for the trivial cases where all vertices are in front or behind plane: // -// Single vertex on positive side of plane => isMostVxesOnPositiveSide = false +// +// 1. Single vertex on positive side of plane => isMostVxesOnPositiveSide = false // // +\ /\3 /\3 /+ /\3 . // \ / \ / \ / + / \ + . @@ -75,7 +82,8 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const // 1/___\1___\2 1/____2/__\2 1/________\2 . // +\ /+ // -// Two vertices vertex on positive side of plane => isMostVxesOnPositiveSide = true +// +// 2. Two vertices vertex on positive side of plane => isMostVxesOnPositiveSide = true // // \+ /\3 /\3 +/ /\3 . // \ / \ / \ / / \ . @@ -83,6 +91,20 @@ bool HexGridIntersectionTools::planeLineIntersect(const cvf::Plane& plane, const // / \ \ / /\ + / \ + . // 1/___\1___\2 1/____2/__\2 1/________\2 . // \+ +/ +// +// 3. The special cases of touching one vertex, either exactly or "close enough" +// in finite precision. These occur for both 2. and 3 and in any rotation. +// +// a) Should not be counted b) May need a tolerance margin to intersect +// as intersecting: both 1->3 and 2->3 as it is theoretically required to: +// 3 +// \ /\ /|\ +// \ / \ / | \ +// \ / \ / | \ +// \ / \ / | \ +// \/________\ /____|____\ +// \ 1 | 2 + //-------------------------------------------------------------------------------------------------- bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane, @@ -92,10 +114,23 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane ClipVx* newVx1, ClipVx* newVx2, bool * isMostVxesOnPositiveSide) { - int onPosSide[3]; - onPosSide[0] = plane.distanceSquared(p1) >= 0; - onPosSide[1] = plane.distanceSquared(p2) >= 0; - onPosSide[2] = plane.distanceSquared(p3) >= 0; + const double nonDimensionalTolerance = 1.0e-8; + + double sqrSignedDistances[3]; + sqrSignedDistances[0] = plane.distanceSquared(p1); + sqrSignedDistances[1] = plane.distanceSquared(p2); + sqrSignedDistances[2] = plane.distanceSquared(p3); + + double maxSqrAbsDistance = std::max(std::abs(sqrSignedDistances[0]), + std::max(std::abs(sqrSignedDistances[1]), + std::abs(sqrSignedDistances[2]))); + + const double sqrDistanceTolerance = nonDimensionalTolerance * maxSqrAbsDistance; + + int onPosSide[3]; + onPosSide[0] = sqrSignedDistances[0] >= 0; + onPosSide[1] = sqrSignedDistances[1] >= 0; + onPosSide[2] = sqrSignedDistances[2] >= 0; const int numPositiveVertices = onPosSide[0] + onPosSide[1] + onPosSide[2]; @@ -122,44 +157,57 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane if (onPosSide[0]) topVx = 1; if (onPosSide[1]) topVx = 2; if (onPosSide[2]) topVx = 3; + + // Case 3a: Two negative distances and the last is within tolerance of zero. + if (sqrSignedDistances[topVx - 1] < sqrDistanceTolerance) + { + return false; + } } else if (numPositiveVertices == 2) { if (!onPosSide[0]) topVx = 1; if (!onPosSide[1]) topVx = 2; if (!onPosSide[2]) topVx = 3; + + // Case 3a: Two positive distances and the last is within tolerance of zero. + if (sqrSignedDistances[topVx - 1] > -sqrDistanceTolerance) + { + return false; + } } else { CVF_ASSERT(false); } - bool ok1, ok2; + bool ok1 = false; + bool ok2 = false; + if (topVx == 1) { - ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); + ok1 = planeLineIntersect(plane, p1, p2, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx1).clippedEdgeVx1Id = p1Id; (*newVx1).clippedEdgeVx2Id = p2Id; - ok2 = planeLineIntersect(plane, p1, p3, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1)); + ok2 = planeLineIntersect(plane, p1, p3, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx2).clippedEdgeVx1Id = p1Id; (*newVx2).clippedEdgeVx2Id = p3Id; - CVF_TIGHT_ASSERT(ok1 && ok2); } else if (topVx == 2) { - ok1 = planeLineIntersect(plane, p2, p3, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); + ok1 = planeLineIntersect(plane, p2, p3, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx1).clippedEdgeVx1Id = p2Id; (*newVx1).clippedEdgeVx2Id = p3Id; - ok2 = planeLineIntersect(plane, p2, p1, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1)); + ok2 = planeLineIntersect(plane, p2, p1, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx2).clippedEdgeVx1Id = p2Id; (*newVx2).clippedEdgeVx2Id = p1Id; } else if (topVx == 3) { - ok1 = planeLineIntersect(plane, p3, p1, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1)); + ok1 = planeLineIntersect(plane, p3, p1, &((*newVx1).vx), &((*newVx1).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx1).clippedEdgeVx1Id = p3Id; (*newVx1).clippedEdgeVx2Id = p1Id; - ok2 = planeLineIntersect(plane, p3, p2, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1)); + ok2 = planeLineIntersect(plane, p3, p2, &((*newVx2).vx), &((*newVx2).normDistFromEdgeVx1), nonDimensionalTolerance); (*newVx2).clippedEdgeVx1Id = p3Id; (*newVx2).clippedEdgeVx2Id = p2Id; } @@ -202,16 +250,19 @@ bool HexGridIntersectionTools::planeTriangleIntersection(const cvf::Plane& plane // // Clips the supplied triangles into new triangles returned in clippedTriangleVxes. // New vertices have set isVxIdsNative = false and their vxIds is indices into triangleVxes -// The isTriangleEdgeCellContour bits refer to the edge after the corresponding triangle vertex. +// The cellFaceForEachTriangleEdge refer to the edge after the corresponding triangle vertex. +// This method will keep the faces provided, while added edges is marked with no face = 6 //-------------------------------------------------------------------------------------------------- void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std::vector& triangleVxes, - const std::vector& isTriangleEdgeCellContour, + const std::vector& cellFaceForEachTriangleEdge, const cvf::Plane& p1Plane, const cvf::Plane& p2Plane, std::vector* clippedTriangleVxes, - std::vector* isClippedTriEdgeCellContour) + std::vector* cellFaceForEachClippedTriangleEdge) { + #define HT_NO_FACE 6 + size_t triangleCount = triangleVxes.size() / 3; for (size_t tIdx = 0; tIdx < triangleCount; ++tIdx) @@ -270,9 +321,9 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(triangleVxes[triVxIdx + 1]); clippedTriangleVxes->push_back(triangleVxes[triVxIdx + 2]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[triVxIdx + 0]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[triVxIdx + 1]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[triVxIdx + 2]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[triVxIdx + 0]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[triVxIdx + 1]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[triVxIdx + 2]); continue; } @@ -288,13 +339,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(triangleVxes[newVx2OnP1.clippedEdgeVx2Id]); clippedTriangleVxes->push_back(newVx2OnP1); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -310,13 +361,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(triangleVxes[newVx1OnP2.clippedEdgeVx2Id]); clippedTriangleVxes->push_back(triangleVxes[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -328,9 +379,9 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx2OnP1); clippedTriangleVxes->push_back(triangleVxes[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); continue; } @@ -342,9 +393,9 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx2OnP2); clippedTriangleVxes->push_back(triangleVxes[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); continue; } @@ -368,17 +419,17 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx1OnP2); clippedTriangleVxes->push_back(triangleVxes[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); } else { @@ -387,17 +438,17 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx1OnP1); clippedTriangleVxes->push_back(triangleVxes[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); } continue; @@ -414,13 +465,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx2OnP2); clippedTriangleVxes->push_back(newVx2OnP1); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP1.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP1.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP2.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP2.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -436,13 +487,13 @@ void HexGridIntersectionTools::clipTrianglesBetweenTwoParallelPlanes(const std:: clippedTriangleVxes->push_back(newVx1OnP2); clippedTriangleVxes->push_back(newVx1OnP1); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx2OnP1.clippedEdgeVx2Id]); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx2OnP1.clippedEdgeVx2Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); - isClippedTriEdgeCellContour->push_back(false); - isClippedTriEdgeCellContour->push_back(isTriangleEdgeCellContour[newVx1OnP2.clippedEdgeVx1Id]); - isClippedTriEdgeCellContour->push_back(false); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); + cellFaceForEachClippedTriangleEdge->push_back(cellFaceForEachTriangleEdge[newVx1OnP2.clippedEdgeVx1Id]); + cellFaceForEachClippedTriangleEdge->push_back(HT_NO_FACE); continue; } @@ -500,17 +551,33 @@ cvf::Vec3d HexGridIntersectionTools::planeLineIntersectionForMC(const cvf::Plane } //-------------------------------------------------------------------------------------------------- +/// Based on description and implementation from Paul Bourke: /// +/// http://paulbourke.net/geometry/polygonise/ +/// +/// Note that the element is turned inside-out compared to what we use elsewhere in caf/ResInsight +/// So the winding of all the sides are opposite. +/// 4-----4------5 +/// /| /| k POS_I = 0 +/// 7 8 5 9 | NEG_I = 1 +/// / | / | | POS_J = 2 +/// 7------6-----6 | | NEG_J = 3 +/// | 0-----0--|---1 *------i POS_K = 4 +/// 11 / 10 / / NEG_K = 5 +/// | 3 | 1 / NO_FACE = 6 +/// |/ |/ j +/// 3------2-----2 +/// +// The cellFaceForEachTriangleEdge refer to the edge after the corresponding triangle vertex. //-------------------------------------------------------------------------------------------------- int HexGridIntersectionTools::planeHexIntersectionMC(const cvf::Plane& plane, - const cvf::Vec3d cell[8], - const size_t hexCornersIds[8], - std::vector* triangleVxes, - std::vector* isTriEdgeCellContour) + const cvf::Vec3d cell[8], + const size_t hexCornersIds[8], + std::vector* triangleVxes, + std::vector* cellFaceForEachTriangleEdge) { - // Based on description and implementation from Paul Bourke: - // http://local.wasp.uwa.edu.au/~pbourke/geometry/polygonise/ + static const cvf::uint cubeIdxToCutEdgeBitfield[256] = { @@ -862,24 +929,67 @@ int HexGridIntersectionTools::planeHexIntersectionMC(const cvf::Plane& plane, const int* triangleIndicesToCubeEdges = cubeIdxToTriangleIndices[cubeIndex]; cvf::uint triangleVxIdx = 0; - int cubeEdgeIdx = triangleIndicesToCubeEdges[triangleVxIdx]; - + int cubeEdgeIdx = triangleIndicesToCubeEdges[triangleVxIdx]; while (cubeEdgeIdx != -1) { ClipVx cvx; - cvx.vx = edgeIntersections[cubeEdgeIdx]; + cvx.vx = edgeIntersections[cubeEdgeIdx]; cvx.normDistFromEdgeVx1 = normDistAlongEdge[cubeEdgeIdx]; - cvx.clippedEdgeVx1Id = hexCornersIds[edgeTable[cubeEdgeIdx][0]]; - cvx.clippedEdgeVx2Id = hexCornersIds[edgeTable[cubeEdgeIdx][1]]; + cvx.clippedEdgeVx1Id = hexCornersIds[edgeTable[cubeEdgeIdx][0]]; + cvx.clippedEdgeVx2Id = hexCornersIds[edgeTable[cubeEdgeIdx][1]]; (*triangleVxes).push_back(cvx); ++triangleVxIdx; + cubeEdgeIdx = triangleIndicesToCubeEdges[triangleVxIdx]; } cvf::uint triangleCount = triangleVxIdx / 3; + static const int edgeEdgeCutsToCellFace[12][12] = { + // 0 1 2 3 4 5 6 7 8 9 10 11 + { 6, 5, 5, 5, 3, 6, 6, 6, 3, 3, 6, 6 }, // 0 + { 5, 6, 5, 5, 6, 0, 6, 6, 6, 0, 0, 6 }, // 1 POS_I = 0 + { 5, 5, 6, 5, 6, 6, 2, 6, 6, 6, 2, 2 }, // 2 NEG_I = 1 + { 5, 5, 5, 6, 6, 6, 6, 1, 1, 6, 6, 1 }, // 3 POS_J = 2 + { 3, 6, 6, 6, 6, 4, 4, 4, 3, 3, 6, 6 }, // 4 NEG_J = 3 + { 6, 0, 6, 6, 4, 6, 4, 4, 6, 0, 0, 6 }, // 5 POS_K = 4 + { 6, 6, 2, 6, 4, 4, 6, 4, 6, 6, 2, 2 }, // 6 NEG_K = 5 + { 6, 6, 6, 1, 4, 4, 4, 6, 1, 6, 6, 1 }, // 7 NO_FACE = 6 + { 3, 6, 6, 1, 3, 6, 6, 1, 6, 3, 6, 1 }, // 8 + { 3, 0, 6, 6, 3, 0, 6, 6, 3, 6, 0, 6 }, // 9 + { 6, 0, 2, 6, 6, 0, 2, 6, 6, 0, 6, 2 }, // 10 + { 6, 6, 2, 1, 6, 6, 2, 1, 1, 6, 2, 6 } // 11 + }; + + + (*cellFaceForEachTriangleEdge).clear(); + (*cellFaceForEachTriangleEdge).resize(triangleVxIdx, 6); + + for (cvf::uint tIdx = 0; tIdx < triangleCount; ++tIdx) + { + cvf::uint triVxIdx = 3 * tIdx; + + int cubeEdgeIdx1 = triangleIndicesToCubeEdges[triVxIdx]; + int cubeEdgeIdx2 = triangleIndicesToCubeEdges[triVxIdx + 1]; + int cubeEdgeIdx3 = triangleIndicesToCubeEdges[triVxIdx + 2]; + + (*cellFaceForEachTriangleEdge)[triVxIdx + 0] = edgeEdgeCutsToCellFace[cubeEdgeIdx1][cubeEdgeIdx2]; + (*cellFaceForEachTriangleEdge)[triVxIdx + 1] = edgeEdgeCutsToCellFace[cubeEdgeIdx2][cubeEdgeIdx3]; + (*cellFaceForEachTriangleEdge)[triVxIdx + 2] = edgeEdgeCutsToCellFace[cubeEdgeIdx3][cubeEdgeIdx1]; + } + + +#if 0 + // Calculate what triangle edges are representing the cut of a cell face + // Do this by counting the times two specific cube edges are used for a triangle edge. + // Internal edges will have a count of 2, while external edges only 1 + + (*isTriEdgeCellContour).clear(); + (*isTriEdgeCellContour).resize(triangleVxIdx); + + int triangleEdgeCount[12][12] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, @@ -918,11 +1028,14 @@ int HexGridIntersectionTools::planeHexIntersectionMC(const cvf::Plane& plane, int cubeEdgeIdx2 = triangleIndicesToCubeEdges[triVxIdx + 1]; int cubeEdgeIdx3 = triangleIndicesToCubeEdges[triVxIdx + 2]; + // We have a contour if the count is exactly 1. + (*isTriEdgeCellContour)[triVxIdx + 0] = (1 == (cubeEdgeIdx1 < cubeEdgeIdx2 ? triangleEdgeCount[cubeEdgeIdx1][cubeEdgeIdx2] : triangleEdgeCount[cubeEdgeIdx2][cubeEdgeIdx1])); (*isTriEdgeCellContour)[triVxIdx + 1] = (1 == (cubeEdgeIdx2 < cubeEdgeIdx3 ? triangleEdgeCount[cubeEdgeIdx2][cubeEdgeIdx3] : triangleEdgeCount[cubeEdgeIdx3][cubeEdgeIdx2])); (*isTriEdgeCellContour)[triVxIdx + 2] = (1 == (cubeEdgeIdx3 < cubeEdgeIdx1 ? triangleEdgeCount[cubeEdgeIdx3][cubeEdgeIdx1] : triangleEdgeCount[cubeEdgeIdx1][cubeEdgeIdx3])); } +#endif return triangleCount; } diff --git a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h index 392cbf2002..8e9fc2d3ea 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h +++ b/Fwk/AppFwk/cafVizExtensions/cafHexGridIntersectionTools/cafHexGridIntersectionTools.h @@ -40,28 +40,41 @@ class HexGridIntersectionTools int derivedVxLevel; //< Helper data to make it possible to track what set of ClipVx's the indices is reffering to in case of consecutive clips }; - static bool planeLineIntersect(const cvf::Plane& plane, const cvf::Vec3d& a, const cvf::Vec3d& b, cvf::Vec3d* intersection, double* normalizedDistFromA); + static bool planeLineIntersect(const cvf::Plane& plane, + const cvf::Vec3d& a, + const cvf::Vec3d& b, + cvf::Vec3d* intersection, + double* normalizedDistFromA, + double epsilon); static bool planeTriangleIntersection(const cvf::Plane& plane, - const cvf::Vec3d& p1, size_t p1Id, - const cvf::Vec3d& p2, size_t p2Id, - const cvf::Vec3d& p3, size_t p3Id, - ClipVx* newVx1, ClipVx* newVx2, - bool* isMostVxesOnPositiveSide); + const cvf::Vec3d& p1, + size_t p1Id, + const cvf::Vec3d& p2, + size_t p2Id, + const cvf::Vec3d& p3, + size_t p3Id, + ClipVx* newVx1, + ClipVx* newVx2, + bool* isMostVxesOnPositiveSide); static void clipTrianglesBetweenTwoParallelPlanes(const std::vector& triangleVxes, - const std::vector& isTriangleEdgeCellContour, - const cvf::Plane& p1Plane, const cvf::Plane& p2Plane, - std::vector* clippedTriangleVxes, - std::vector* isClippedTriEdgeCellContour); + const std::vector& cellFaceForEachTriangleEdge, + const cvf::Plane& p1Plane, + const cvf::Plane& p2Plane, + std::vector* clippedTriangleVxes, + std::vector* cellFaceForEachClippedTriangleEdge); - static cvf::Vec3d planeLineIntersectionForMC(const cvf::Plane& plane, const cvf::Vec3d& p1, const cvf::Vec3d& p2, double* normalizedDistFromP1); + static cvf::Vec3d planeLineIntersectionForMC(const cvf::Plane& plane, + const cvf::Vec3d& p1, + const cvf::Vec3d& p2, + double* normalizedDistFromP1); static int planeHexIntersectionMC(const cvf::Plane& plane, - const cvf::Vec3d cell[8], - const size_t hexCornersIds[8], - std::vector* triangleVxes, - std::vector* isTriEdgeCellContour); + const cvf::Vec3d cell[8], + const size_t hexCornersIds[8], + std::vector* triangleVxes, + std::vector* cellFaceForEachTriangleEdge); }; diff --git a/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp new file mode 100644 index 0000000000..9f97ea4e43 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.cpp @@ -0,0 +1,203 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafInternalLegendRenderTools.h" +#include "cvfOpenGL.h" +#include "cvfRenderStateDepth.h" +#include "cvfRenderStateLine.h" +#include "cvfRenderStateBlending.h" +#include "cvfShaderProgram.h" +#include "cvfOpenGLContext.h" +#include "cvfOpenGLResourceManager.h" +#include +#include "cvfUniform.h" +#include "cvfRenderState_FF.h" + +using namespace cvf; + +namespace caf +{ +//-------------------------------------------------------------------------------------------------- +/// Render a semi transparent background frame +//-------------------------------------------------------------------------------------------------- +void InternalLegendRenderTools::renderBackgroundUsingShaders(OpenGLContext* oglContext, + const MatrixState& matrixState, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor) +{ + CVF_CALLSITE_OPENGL(oglContext); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLine line(1.0f); + line.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Shader program + + ref shaderProgram = oglContext->resourceManager()->getLinkedUnlitColorShaderProgram(oglContext); + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + + if (shaderProgram->useProgram(oglContext)) + { + shaderProgram->clearUniformApplyTracking(); + shaderProgram->applyFixedUniforms(oglContext, matrixState); + } + + std::array vertexArray ={ + Vec3f(1 , 1, 0.0f), + Vec3f(size.x(), 1, 0.0f), + Vec3f(size.x(), size.y(), 0.0f), + Vec3f(1 , size.y(), 0.0f), + }; + + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glEnableVertexAttribArray(ShaderProgram::VERTEX); + glVertexAttribPointer(ShaderProgram::VERTEX, 3, GL_FLOAT, GL_FALSE, 0, vertexArray.data()); + + // Draw frame background + + UniformFloat backgroundColorUniform("u_color", backgroundColor); + shaderProgram->applyUniform(oglContext, backgroundColorUniform); + + // Triangle indices for the frame background + + static const ushort backgroundTriangleIndices[] = { 0, 1, 2, 2, 3, 0}; + + glDrawRangeElements(GL_TRIANGLES, 0, 3, 6, GL_UNSIGNED_SHORT, backgroundTriangleIndices); + + + // Draw frame border lines + + UniformFloat uniformColor("u_color", backgroundFrameColor); + shaderProgram->applyUniform(oglContext, uniformColor); + + static const ushort frameLineIndices[] = { 0, 1, + 1, 2, + 2, 3, + 3, 0 }; + + glDrawRangeElements(GL_LINES, 0, 3, 8, GL_UNSIGNED_SHORT, frameLineIndices); + + glDisableVertexAttribArray(ShaderProgram::VERTEX); + + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + shaderProgram->useNoProgram(oglContext); + + // Reset render states + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + RenderStateLine resetLine; + resetLine.applyOpenGL(oglContext); + + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +} + +//-------------------------------------------------------------------------------------------------- +/// Draw a background rectangle using OGL 1.1 compatibility +//-------------------------------------------------------------------------------------------------- +void InternalLegendRenderTools::renderBackgroundImmediateMode(OpenGLContext* oglContext, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor) +{ + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLighting_FF lighting(false); + lighting.applyOpenGL(oglContext); + + RenderStateBlending blend; + blend.configureTransparencyBlending(); + blend.applyOpenGL(oglContext); + + // Frame vertices + + std::array vertexArray = { + Vec3f(1 , 1, 0.0f), + Vec3f(size.x(), 1, 0.0f), + Vec3f(size.x(), size.y(), 0.0f), + Vec3f(1 , size.y(), 0.0f), + }; + + + glColor4fv(backgroundColor.ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glEnd(); + + // Render Line around + + { + glColor4fv(backgroundFrameColor.ptr()); + glBegin(GL_LINES); + glVertex3fv(vertexArray[0].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[1].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[2].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[3].ptr()); + glVertex3fv(vertexArray[0].ptr()); + glEnd(); + } + + // Reset render states + + RenderStateLighting_FF resetLighting; + resetLighting.applyOpenGL(oglContext); + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + RenderStateBlending resetblend; + resetblend.applyOpenGL(oglContext); + CVF_CHECK_OGL(oglContext); +} + + +} diff --git a/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h new file mode 100644 index 0000000000..586d017282 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafInternalLegendRenderTools.h @@ -0,0 +1,72 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## +#pragma once + +#include "cvfBase.h" +#include "cvfOpenGLContext.h" +#include "cvfMatrixState.h" +#include "cvfColor4.h" + + +//================================================================================================== +// +// Tools to render legend stuff +// +//================================================================================================== +namespace caf { + + +class InternalLegendRenderTools +{ + using OpenGLContext = cvf::OpenGLContext; + using Color4f = cvf::Color4f; + using String = cvf::String; + using MatrixState = cvf::MatrixState; + using Vec2f = cvf::Vec2f; +public: + static void renderBackgroundUsingShaders(OpenGLContext* oglContext, + const MatrixState& matrixState, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor); + static void renderBackgroundImmediateMode(OpenGLContext* oglContext, + const Vec2f& size, + const Color4f& backgroundColor, + const Color4f& backgroundFrameColor); +}; + +} + diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.h b/Fwk/AppFwk/cafVizExtensions/cafLine.h new file mode 100644 index 0000000000..aea0b7a710 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.h @@ -0,0 +1,68 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include "cvfBase.h" +#include "cvfVector3.h" + +namespace caf +{ +template +class Line +{ +public: + Line(); + Line(const cvf::Vector3& startPoint, const cvf::Vector3& endPoint); + Line(const Line& copyFrom); + Line& operator=(const Line& copyFrom); + + const cvf::Vector3& start() const; + const cvf::Vector3& end() const; + cvf::Vector3 vector() const; + + Line findLineBetweenNearestPoints(const Line& otherLine, bool* withinLineSegments = nullptr); + +private: + cvf::Vector3 m_start; + cvf::Vector3 m_end; +}; + +} + +#include "cafLine.inl" + + diff --git a/Fwk/AppFwk/cafVizExtensions/cafLine.inl b/Fwk/AppFwk/cafVizExtensions/cafLine.inl new file mode 100644 index 0000000000..6a4b1c39fd --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafLine.inl @@ -0,0 +1,111 @@ +#include "cafLine.h" + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line::Line() + : m_start(cvf::Vector3::UNDEFINED) + , m_end(cvf::Vector3::UNDEFINED) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line::Line(const cvf::Vector3& startPoint, const cvf::Vector3& endPoint) + : m_start(startPoint) + , m_end(endPoint) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line::Line(const Line& copyFrom) +{ + m_start = copyFrom.start(); + m_end = copyFrom.end(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line& caf::Line::operator=(const Line& copyFrom) +{ + m_start = copyFrom.start(); + m_end = copyFrom.end(); + return *this; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +const cvf::Vector3& caf::Line::start() const +{ + return m_start; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +const cvf::Vector3& caf::Line::end() const +{ + return m_end; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +cvf::Vector3 caf::Line::vector() const +{ + return m_end - m_start; +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +template +caf::Line caf::Line::findLineBetweenNearestPoints(const Line& otherLine, bool* withinLineSegments) +{ + // Taken from Real-Time Collision Detection, Christer Ericson, 2005, p146-147 + cvf::Vector3 d1 = vector(); + cvf::Vector3 d2 = otherLine.vector(); + + S a = d1.dot(d1); + S b = d1.dot(d2); + S e = d2.dot(d2); + + S d = a * e - b * b; + + if (d < std::numeric_limits::epsilon()) + { + // Parallel lines. Choice of closest points is arbitrary. + // Just use start to start. + if (withinLineSegments) *withinLineSegments = true; + return Line(start(), otherLine.start()); + } + + cvf::Vector3 r = start() - otherLine.start(); + S c = d1.dot(r); + S f = d2.dot(r); + + S s = (b*f - c * e) / d; + S t = (a*f - b * c) / d; + + if (withinLineSegments) + { + *withinLineSegments = s >= 0 && s <= 1 && t >= 0 && t <= 1; + } + return Line(start() + s * d1, otherLine.start() + t * d2); +} + diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp new file mode 100644 index 0000000000..7cf1630953 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.cpp @@ -0,0 +1,724 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#include "cvfBase.h" +#include "cafOverlayScalarMapperLegend.h" +#include "cvfOpenGL.h" +#include "cvfOpenGLResourceManager.h" +#include "cvfGeometryBuilderDrawableGeo.h" +#include "cvfGeometryUtils.h" +#include "cvfViewport.h" +#include "cvfCamera.h" +#include "cvfTextDrawer.h" +#include "cvfFont.h" +#include "cvfShaderProgram.h" +#include "cvfShaderProgramGenerator.h" +#include "cvfShaderSourceProvider.h" +#include "cvfShaderSourceRepository.h" +#include "cvfUniform.h" +#include "cvfMatrixState.h" +#include "cvfBufferObjectManaged.h" +#include "cvfGlyph.h" +#include "cvfRenderStateDepth.h" +#include "cvfRenderStateLine.h" + +#include "cafInternalLegendRenderTools.h" + +#ifndef CVF_OPENGL_ES +#include "cvfRenderState_FF.h" +#endif + +#include "cvfScalarMapper.h" +#include +#include "cvfRenderStateBlending.h" +#include +#include + +namespace caf { + +using namespace cvf; + +//================================================================================================== +/// +/// \class cvf::OverlayColorLegend +/// \ingroup Render +/// +/// +/// +//================================================================================================== + +//-------------------------------------------------------------------------------------------------- +/// Constructor +//-------------------------------------------------------------------------------------------------- +OverlayScalarMapperLegend::OverlayScalarMapperLegend(Font* font) +: TitledOverlayFrame(font, 200, 200) + , m_tickNumberPrecision(4) + , m_numberFormat(AUTO) + , m_Layout(Vec2ui(200u, 200u)) +{ + CVF_ASSERT(font); + CVF_ASSERT(!font->isEmpty()); + + m_tickValues.reserve(3); + m_tickValues.add(0.0); + m_tickValues.add(0.5); + m_tickValues.add(1.0); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +OverlayScalarMapperLegend::~OverlayScalarMapperLegend() +{ + // Empty destructor to avoid errors with undefined types when cvf::ref's destructor gets called +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setScalarMapper(const ScalarMapper* scalarMapper) +{ + m_scalarMapper = scalarMapper; + + if (m_scalarMapper.notNull()) + { + std::vector levelValues; + m_scalarMapper->majorTickValues(&levelValues); + + m_tickValues.assign(levelValues); + } +} + +//-------------------------------------------------------------------------------------------------- +/// Hardware rendering using shader programs +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + renderGeneric(oglContext, position, size, false); +} + + +//-------------------------------------------------------------------------------------------------- +/// Software rendering using software +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) +{ + renderGeneric(oglContext, position, size, true); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool OverlayScalarMapperLegend::pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) +{ + Recti oglRect(position, size.x(), size.y()); + + OverlayColorLegendLayoutInfo layoutInViewPortCoords(Vec2ui(oglRect.width(), oglRect.height())); + layoutInfo(&layoutInViewPortCoords); + + Vec2i legendBarOrigin = oglRect.min(); + legendBarOrigin.x() += static_cast(layoutInViewPortCoords.colorBarRect.min().x()); + legendBarOrigin.y() += static_cast(layoutInViewPortCoords.colorBarRect.min().y()); + + Recti legendBarRect = Recti(legendBarOrigin, + static_cast(layoutInViewPortCoords.colorBarRect.width()), + static_cast(layoutInViewPortCoords.colorBarRect.height())); + + if ((oglXCoord > legendBarRect.min().x()) && (oglXCoord < legendBarRect.max().x()) && + (oglYCoord > legendBarRect.min().y()) && (oglYCoord < legendBarRect.max().y())) + { + return true; + } + + return false; +} + + +//-------------------------------------------------------------------------------------------------- +/// Set up camera/viewport and render +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderGeneric(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size, bool software) +{ + if (size.x() <= 0 || size.y() <= 0) + { + return; + } + + Camera camera; + camera.setViewport(position.x(), position.y(), size.x(), size.y()); + camera.setProjectionAsPixelExact2D(); + camera.setViewMatrix(Mat4d::IDENTITY); + camera.applyOpenGL(); + camera.viewport()->applyOpenGL(oglContext, Viewport::CLEAR_DEPTH); + + m_Layout = OverlayColorLegendLayoutInfo(size); + layoutInfo(&m_Layout); + m_textDrawer = new TextDrawer(this->font()); + + // Set up text drawer + float maxLegendRightPos = 0; + setupTextDrawer(m_textDrawer.p(), &m_Layout ); + + Vec2f backgroundSize(size); + + // Do the actual rendering + if (software) + { + if ( this->backgroundEnabled() ) + { + InternalLegendRenderTools::renderBackgroundImmediateMode(oglContext, + backgroundSize, + this->backgroundColor(), + this->backgroundFrameColor()); + } + renderLegendImmediateMode(oglContext, &m_Layout); + m_textDrawer->renderSoftware(oglContext, camera); + } + else + { + const MatrixState matrixState(camera); + if ( this->backgroundEnabled() ) + { + InternalLegendRenderTools::renderBackgroundUsingShaders(oglContext, + matrixState, + backgroundSize, + this->backgroundColor(), + this->backgroundFrameColor()); + } + renderLegendUsingShaders(oglContext, &m_Layout, matrixState); + m_textDrawer->render(oglContext, camera); + } + + CVF_CHECK_OGL(oglContext); +} + + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setupTextDrawer(TextDrawer* textDrawer, const OverlayColorLegendLayoutInfo* layout) +{ + CVF_ASSERT(layout); + + textDrawer->setVerticalAlignment(TextDrawer::CENTER); + textDrawer->setTextColor(this->textColor()); + + m_visibleTickLabels.clear(); + + const float textX = layout->tickEndX + layout->tickTextLeadSpace; + + const float overlapTolerance = 1.2f * layout->charHeight; + float lastVisibleTextY = 0.0; + + size_t numTicks = m_tickValues.size(); + size_t it; + for (it = 0; it < numTicks; it++) + { + float textY = static_cast(layout->colorBarRect.min().y() + layout->tickYPixelPos->get(it)); + + // Always draw first and last tick label. For all others, skip drawing if text ends up + // on top of the previous label. + if (it != 0 && it != (numTicks - 1)) + { + if (cvf::Math::abs(textY - lastVisibleTextY) < overlapTolerance) + { + m_visibleTickLabels.push_back(false); + continue; + } + // Make sure it does not overlap the last tick as well + + float lastTickY = static_cast(layout->colorBarRect.max().y() ); + + if (cvf::Math::abs(textY - lastTickY) < overlapTolerance) + { + m_visibleTickLabels.push_back(false); + continue; + } + } + + double tickValue = m_tickValues[it]; + String valueString; + switch (m_numberFormat) + { + case FIXED: + valueString = String::number(tickValue, 'f', m_tickNumberPrecision); + break; + case SCIENTIFIC: + valueString = String::number(tickValue, 'e', m_tickNumberPrecision); + break; + default: + valueString = String::number(tickValue); + break; + } + + Vec2f pos(textX, textY); + textDrawer->addText(valueString, pos); + + lastVisibleTextY = textY; + m_visibleTickLabels.push_back(true); + } + + float titleY = static_cast(layout->overallLegendSize.y()) - layout->margins.y() - layout->charHeight/2.0f; + for (it = 0; it < this->titleStrings().size(); it++) + { + Vec2f pos(layout->margins.x(), titleY); + textDrawer->addText(this->titleStrings()[it], pos); + + titleY -= layout->lineSpacing; + } + +} + + +//-------------------------------------------------------------------------------------------------- +/// Draw the legend using shader programs +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderLegendUsingShaders(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout, const MatrixState& matrixState) +{ + CVF_CALLSITE_OPENGL(oglContext); + + CVF_TIGHT_ASSERT(layout); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + RenderStateLine line(static_cast(this->lineWidth())); + line.applyOpenGL(oglContext); + + // All vertices. Initialized here to set Z to zero once and for all. + static float vertexArray[] = + { + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f + }; + + // Per vector convenience pointers + float* v0 = &vertexArray[0]; + float* v1 = &vertexArray[3]; + float* v2 = &vertexArray[6]; + float* v3 = &vertexArray[9]; + float* v4 = &vertexArray[12]; + + // Constant coordinates + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; + + // Connects + static const ushort trianglesConnects[] = { 0, 1, 4, 0, 4, 3 }; + + ref shaderProgram = oglContext->resourceManager()->getLinkedUnlitColorShaderProgram(oglContext); + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + + if (shaderProgram->useProgram(oglContext)) + { + shaderProgram->clearUniformApplyTracking(); + shaderProgram->applyFixedUniforms(oglContext, matrixState); + } + + glBindBuffer(GL_ARRAY_BUFFER, 0); + glEnableVertexAttribArray(ShaderProgram::VERTEX); + glVertexAttribPointer(ShaderProgram::VERTEX, 3, GL_FLOAT, GL_FALSE, 0, vertexArray); + + // Render color bar as one colored quad per pixel + + int legendHeightPixelCount = static_cast(layout->tickYPixelPos->get(m_tickValues.size()-1) - layout->tickYPixelPos->get(0) + 0.01); + if (m_scalarMapper.notNull()) + { + int iPx; + for (iPx = 0; iPx < legendHeightPixelCount; iPx++) + { + const Color3ub& clr = m_scalarMapper->mapToColor(m_scalarMapper->domainValue((iPx+0.5)/legendHeightPixelCount)); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); + + // Dynamic coordinates for rectangle + v0[1] = v1[1] = y0; + v3[1] = v4[1] = y1; + + // Draw filled rectangle elements + { + UniformFloat uniformColor("u_color", Color4f(Color3f(clr))); + shaderProgram->applyUniform(oglContext, uniformColor); + +#ifdef CVF_OPENGL_ES + glDrawElements(GL_TRIANGLES, 6, GL_UNSIGNED_SHORT, trianglesConnects); +#else + glDrawRangeElements(GL_TRIANGLES, 0, 4, 6, GL_UNSIGNED_SHORT, trianglesConnects); +#endif + } + } + } + + // Render frame + + // Dynamic coordinates for tickmarks-lines + bool isRenderingFrame = true; + if (isRenderingFrame) + { + v0[0] = v2[0] = layout->colorBarRect.min().x()-0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x()-0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y()-0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y()-0.5f; + static const ushort frameConnects[] = { 0, 1, 1, 3, 3, 2, 2, 0}; + + UniformFloat uniformColor("u_color", Color4f(this->lineColor())); + shaderProgram->applyUniform(oglContext, uniformColor); + +#ifdef CVF_OPENGL_ES + glDrawElements(GL_LINES, 8, GL_UNSIGNED_SHORT, frameConnects); +#else + glDrawRangeElements(GL_LINES, 0, 3, 8, GL_UNSIGNED_SHORT, frameConnects); +#endif + } + + // Render tickmarks + bool isRenderingTicks = true; + + if (isRenderingTicks) + { + // Constant coordinates + v0[0] = layout->tickStartX; + v1[0] = layout->tickMidX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v2[0] = layout->tickMidX; + v3[0] = layout->tickEndX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v4[0] = layout->tickEndX; + + static const ushort tickLinesWithLabel[] = { 0, 4 }; + static const ushort tickLinesWoLabel[] = { 2, 3 }; + + size_t ic; + for (ic = 0; ic < m_tickValues.size(); ic++) + { + float y0 = static_cast(layout->colorBarRect.min().y() + layout->tickYPixelPos->get(ic) - 0.5f); + + // Dynamic coordinates for tickmarks-lines + v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; + + UniformFloat uniformColor("u_color", Color4f(this->lineColor())); + shaderProgram->applyUniform(oglContext, uniformColor); + const ushort * linesConnects; + + if ( m_visibleTickLabels[ic]) + { + linesConnects = tickLinesWithLabel; + } + else + { + linesConnects = tickLinesWoLabel; + } + +#ifdef CVF_OPENGL_ES + glDrawElements(GL_LINES, 2, GL_UNSIGNED_SHORT, linesConnects); +#else + glDrawRangeElements(GL_LINES, 0, 4, 2, GL_UNSIGNED_SHORT, linesConnects); +#endif + } + } + + glDisableVertexAttribArray(ShaderProgram::VERTEX); + + CVF_TIGHT_ASSERT(shaderProgram.notNull()); + shaderProgram->useNoProgram(oglContext); + + // Reset render states + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + RenderStateLine resetLine; + resetLine.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +} + + +//-------------------------------------------------------------------------------------------------- +/// Draw the legend using immediate mode OpenGL +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::renderLegendImmediateMode(OpenGLContext* oglContext, OverlayColorLegendLayoutInfo* layout) +{ +#ifdef CVF_OPENGL_ES + CVF_UNUSED(layout); + CVF_FAIL_MSG("Not supported on OpenGL ES"); +#else + CVF_TIGHT_ASSERT(layout); + CVF_TIGHT_ASSERT(layout->overallLegendSize.x() > 0); + CVF_TIGHT_ASSERT(layout->overallLegendSize.y() > 0); + + RenderStateDepth depth(false); + depth.applyOpenGL(oglContext); + + RenderStateLighting_FF lighting(false); + lighting.applyOpenGL(oglContext); + + // All vertices. Initialized here to set Z to zero once and for all. + static float vertexArray[] = + { + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, + }; + + // Per vector convenience pointers + float* v0 = &vertexArray[0]; + float* v1 = &vertexArray[3]; + float* v2 = &vertexArray[6]; + float* v3 = &vertexArray[9]; + float* v4 = &vertexArray[12]; + + // Constant coordinates + v0[0] = v3[0] = layout->tickStartX; + v1[0] = v4[0] = layout->tickMidX; + + // Render color bar as one colored quad per pixel + + int legendHeightPixelCount = static_cast(layout->tickYPixelPos->get(m_tickValues.size() - 1) - layout->tickYPixelPos->get(0) + 0.01); + if (m_scalarMapper.notNull()) + { + int iPx; + for (iPx = 0; iPx < legendHeightPixelCount; iPx++) + { + const Color3ub& clr = m_scalarMapper->mapToColor(m_scalarMapper->domainValue((iPx+0.5)/legendHeightPixelCount)); + float y0 = static_cast(layout->colorBarRect.min().y() + iPx); + float y1 = static_cast(layout->colorBarRect.min().y() + iPx + 1); + + // Dynamic coordinates for rectangle + v0[1] = v1[1] = y0; + v3[1] = v4[1] = y1; + + // Draw filled rectangle elements + glColor3ubv(clr.ptr()); + glBegin(GL_TRIANGLE_FAN); + glVertex3fv(v0); + glVertex3fv(v1); + glVertex3fv(v4); + glVertex3fv(v3); + glEnd(); + } + } + + // Render frame + + // Dynamic coordinates for tickmarks-lines + bool isRenderingFrame = true; + if (isRenderingFrame) + { + v0[0] = v2[0] = layout->colorBarRect.min().x()-0.5f; + v1[0] = v3[0] = layout->colorBarRect.max().x()-0.5f; + v0[1] = v1[1] = layout->colorBarRect.min().y()-0.5f; + v2[1] = v3[1] = layout->colorBarRect.max().y()-0.5f; + + glColor3fv(this->textColor().ptr()); + glBegin(GL_LINES); + glVertex3fv(v0); + glVertex3fv(v1); + glVertex3fv(v1); + glVertex3fv(v3); + glVertex3fv(v3); + glVertex3fv(v2); + glVertex3fv(v2); + glVertex3fv(v0); + glEnd(); + + } + + // Render tickmarks + bool isRenderingTicks = true; + + if (isRenderingTicks) + { + // Constant coordinates + v0[0] = layout->tickStartX; + v1[0] = layout->tickMidX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v2[0] = layout->tickMidX; + v3[0] = layout->tickEndX - 0.5f*(layout->tickEndX - layout->tickMidX) - 0.5f; + v4[0] = layout->tickEndX; + + size_t ic; + for (ic = 0; ic < m_tickValues.size(); ic++) + { + float y0 = static_cast(layout->colorBarRect.min().y() + layout->tickYPixelPos->get(ic) - 0.5f); + + // Dynamic coordinates for tickmarks-lines + v0[1] = v1[1] = v2[1] = v3[1] = v4[1] = y0; + + glColor3fv(this->textColor().ptr()); + glBegin(GL_LINES); + if ( m_visibleTickLabels[ic]) + { + glVertex3fv(v0); + glVertex3fv(v4); + } + else + { + glVertex3fv(v2); + glVertex3fv(v3); + } + glEnd(); + } + } + + // Reset render states + RenderStateLighting_FF resetLighting; + resetLighting.applyOpenGL(oglContext); + RenderStateDepth resetDepth; + resetDepth.applyOpenGL(oglContext); + + CVF_CHECK_OGL(oglContext); +#endif // CVF_OPENGL_ES +} + +//-------------------------------------------------------------------------------------------------- +/// Get layout information +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::layoutInfo(OverlayColorLegendLayoutInfo* layout) +{ + CVF_TIGHT_ASSERT(layout); + + ref glyph = this->font()->getGlyph(L'A'); + layout->charHeight = static_cast(glyph->height()); + layout->lineSpacing = layout->charHeight*1.5f; + layout->margins = Vec2f(8.0f, 8.0f); + layout->tickTextLeadSpace = 5.0f; + + float colorBarWidth = 25.0f; + float colorBarHeight = static_cast(layout->overallLegendSize.y()) + - 2*layout->margins.y() + - static_cast(this->titleStrings().size()) * layout->lineSpacing + - layout->lineSpacing; + layout->colorBarRect = Rectf(layout->margins.x(), + layout->margins.y() + layout->charHeight/2.0f, + colorBarWidth, + colorBarHeight); + + layout->tickStartX = layout->margins.x(); + layout->tickMidX = layout->margins.x() + layout->colorBarRect.width(); + layout->tickEndX = layout->tickMidX + 5; + + // Build array containing the pixel positions of all the ticks + size_t numTicks = m_tickValues.size(); + layout->tickYPixelPos = new DoubleArray(numTicks); + + size_t i; + for (i = 0; i < numTicks; i++) + { + double t; + if (m_scalarMapper.isNull()) t = 0; + else t = m_scalarMapper->normalizedValue(m_tickValues[i]); + t = Math::clamp(t, 0.0, 1.1); + if (i != numTicks -1) + { + layout->tickYPixelPos->set(i, t*layout->colorBarRect.height()); + } + else + { + layout->tickYPixelPos->set(i, layout->colorBarRect.height()); // Make sure we get a value at the top even if the scalarmapper range is zero + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setTickPrecision(int precision) +{ + m_tickNumberPrecision = precision; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void OverlayScalarMapperLegend::setTickFormat(NumberFormat format) +{ + m_numberFormat = format; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +cvf::Vec2ui OverlayScalarMapperLegend::preferredSize() +{ + OverlayColorLegendLayoutInfo layout({200,200}); // Use default size + layoutInfo(&layout); + + float prefferredYSize = 2 * layout.margins.y() + + layout.lineSpacing * this->titleStrings().size() + + 1.5f * layout.lineSpacing * m_tickValues.size(); + + unsigned int maxTickTextWidth = 0; + for (double tickValue : m_tickValues ) + { + String valueString; + switch ( m_numberFormat ) + { + case FIXED: + valueString = String::number(tickValue, 'f', m_tickNumberPrecision); + break; + case SCIENTIFIC: + valueString = String::number(tickValue, 'e', m_tickNumberPrecision); + break; + default: + valueString = String::number(tickValue); + break; + } + unsigned int textWidth = this->font()->textExtent(valueString).x(); + maxTickTextWidth = maxTickTextWidth < textWidth ? textWidth : maxTickTextWidth; + } + + float prefferredXSize = layout.tickEndX + layout.margins.x() + layout.tickTextLeadSpace + maxTickTextWidth; + + for (const cvf::String& titleLine : titleStrings()) + { + float titleWidth = this->font()->textExtent(titleLine).x() + 2*layout.margins.x(); + prefferredXSize = prefferredXSize < titleWidth ? titleWidth : prefferredXSize; + } + + prefferredXSize = std::min(prefferredXSize, 400.0f); + + return { (unsigned int)(std::ceil(prefferredXSize)), (unsigned int)(std::ceil(prefferredYSize)) }; + +} + +} // namespace cvf + diff --git a/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h new file mode 100644 index 0000000000..2cb28c654d --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafOverlayScalarMapperLegend.h @@ -0,0 +1,141 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + + +#pragma once + +#include "cafTitledOverlayFrame.h" +#include "cvfOverlayItem.h" +#include "cvfArray.h" +#include "cvfCamera.h" +#include "cvfString.h" +#include "cvfRect.h" + +namespace cvf { +class Font; +class ShaderProgram; +class MatrixState; +class TextDrawer; +class ScalarMapper; +} + +namespace caf { + + +//================================================================================================== +// +// Overlay color legend +// +//================================================================================================== +class OverlayScalarMapperLegend : public caf::TitledOverlayFrame +{ + using Font = cvf::Font; + using ScalarMapper = cvf::ScalarMapper; + using OpenGLContext = cvf::OpenGLContext; + using Vec2i = cvf::Vec2i; + using Vec2ui = cvf::Vec2ui; + using Color3f = cvf::Color3f; + using Color4f = cvf::Color4f; + using String = cvf::String; + using DoubleArray = cvf::DoubleArray; + using MatrixState = cvf::MatrixState; + using Vec2f = cvf::Vec2f; + using Rectf = cvf::Rectf; + using TextDrawer = cvf::TextDrawer; + +public: + OverlayScalarMapperLegend(Font* font); + virtual ~OverlayScalarMapperLegend(); + + void setScalarMapper(const ScalarMapper* scalarMapper); + + void setTickPrecision(int precision); + enum NumberFormat { AUTO, SCIENTIFIC, FIXED}; + void setTickFormat(NumberFormat format); + + virtual cvf::Vec2ui preferredSize() override; + +protected: + void render(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + void renderSoftware(OpenGLContext* oglContext, const Vec2i& position, const Vec2ui& size) override; + bool pick(int oglXCoord, int oglYCoord, const Vec2i& position, const Vec2ui& size) override; + + struct OverlayColorLegendLayoutInfo + { + OverlayColorLegendLayoutInfo(const Vec2ui& setSize) + { + overallLegendSize = setSize; + } + + float charHeight; + float lineSpacing; + Vec2f margins; + float tickStartX, tickMidX, tickEndX; + float tickTextLeadSpace; + + Rectf colorBarRect; + + cvf::ref tickYPixelPos; + + Vec2ui overallLegendSize; + }; + + void layoutInfo(OverlayColorLegendLayoutInfo* layout); + + void renderGeneric(OpenGLContext* oglContext, + const Vec2i& position, + const Vec2ui& size, + bool software); + void renderLegendUsingShaders(OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout, + const MatrixState& matrixState); + void renderLegendImmediateMode(OpenGLContext* oglContext, + OverlayColorLegendLayoutInfo* layout); + void setupTextDrawer(TextDrawer* textDrawer, + const OverlayColorLegendLayoutInfo* layout); + +protected: + DoubleArray m_tickValues; // Ticks between each level + top and bottom of legend (n+1 entries) + std::vector m_visibleTickLabels; // Skip tick labels ending up on top of previous visible label + int m_tickNumberPrecision; + NumberFormat m_numberFormat; + + OverlayColorLegendLayoutInfo m_Layout; + cvf::ref m_textDrawer; + cvf::cref m_scalarMapper; +}; + +} diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp new file mode 100644 index 0000000000..5745dd2206 --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.cpp @@ -0,0 +1,213 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#include "cafTitledOverlayFrame.h" +#include "cafCategoryMapper.h" +#include "cvfFont.h" + +#include + +using namespace cvf; + +namespace caf { + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + TitledOverlayFrame::TitledOverlayFrame(Font* font, unsigned int width, unsigned int height) + : m_font(font) + , m_renderSize(width, height) + , m_textColor(Color3::BLACK) + , m_lineColor(Color3::BLACK) + , m_lineWidth(1) + , m_isBackgroundEnabled(true) + , m_backgroundColor(1.0f, 1.0f, 1.0f, 0.8f) + , m_backgroundFrameColor(0.0f, 0.0f, 0.0f, 0.5f) + { + } + + TitledOverlayFrame::~TitledOverlayFrame() + { + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setRenderSize(const Vec2ui& size) + { + m_renderSize = size; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Vec2ui TitledOverlayFrame::renderSize() const + { + return m_renderSize; + } + + //-------------------------------------------------------------------------------------------------- + /// Set color of the text + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setTextColor(const Color3f& color) + { + m_textColor = color; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setLineColor(const Color3f& lineColor) + { + m_lineColor = lineColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setLineWidth(int lineWidth) + { + m_lineWidth = lineWidth; + } + + //-------------------------------------------------------------------------------------------------- + /// Set the title (text that will be rendered above the legend) + /// + /// The legend supports multi-line titles. Separate each line with a '\n' character + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setTitle(const String& title) + { + // Title + if (title.isEmpty()) + { + m_titleStrings.clear(); + } + else + { + m_titleStrings = title.split("\n"); + } + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::enableBackground(bool enable) + { + m_isBackgroundEnabled = enable; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setBackgroundColor(const Color4f& backgroundColor) + { + m_backgroundColor = backgroundColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + void TitledOverlayFrame::setBackgroundFrameColor(const Color4f& backgroundFrameColor) + { + m_backgroundFrameColor = backgroundFrameColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Vec2ui TitledOverlayFrame::sizeHint() + { + return m_renderSize; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color3f TitledOverlayFrame::textColor() const + { + return m_textColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color3f TitledOverlayFrame::lineColor() const + { + return m_lineColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + int TitledOverlayFrame::lineWidth() const + { + return m_lineWidth; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + bool TitledOverlayFrame::backgroundEnabled() const + { + return m_isBackgroundEnabled; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color4f TitledOverlayFrame::backgroundColor() const + { + return m_backgroundColor; + } + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + cvf::Color4f TitledOverlayFrame::backgroundFrameColor() const + { + return m_backgroundFrameColor; + } + + std::vector& TitledOverlayFrame::titleStrings() + { + return m_titleStrings; + } + + cvf::Font* TitledOverlayFrame::font() + { + return m_font.p(); + } +} \ No newline at end of file diff --git a/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h new file mode 100644 index 0000000000..6852622c2e --- /dev/null +++ b/Fwk/AppFwk/cafVizExtensions/cafTitledOverlayFrame.h @@ -0,0 +1,102 @@ +//################################################################################################## +// +// Custom Visualization Core library +// Copyright (C) 2018- Ceetron Solutions AS +// +// This library may be used under the terms of either the GNU General Public License or +// the GNU Lesser General Public License as follows: +// +// GNU General Public License Usage +// This library 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. +// +// This library 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 <> +// for more details. +// +// GNU Lesser General Public License Usage +// This library is free software; you can redistribute it and/or modify +// it under the terms of the GNU Lesser General Public License as published by +// the Free Software Foundation; either version 2.1 of the License, or +// (at your option) any later version. +// +// This library 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 Lesser General Public License at <> +// for more details. +// +//################################################################################################## + +#pragma once + +#include "cvfBase.h" +#include "cvfColor3.h" +#include "cvfColor4.h" +#include "cvfOverlayItem.h" +#include "cvfString.h" + +namespace cvf +{ + class Font; +} + +namespace caf { + //================================================================================================== + // Base class for ApplicationFwk Legends. + // Abstract because the pure virtual render methods from cvf::OverlayItem are not implemented. + //================================================================================================== + class TitledOverlayFrame : public cvf::OverlayItem + { + public: + TitledOverlayFrame(cvf::Font* font, unsigned int width = 100, unsigned int height = 200); + virtual ~TitledOverlayFrame(); + + void setRenderSize(const cvf::Vec2ui& size); + cvf::Vec2ui renderSize() const; + + void setTextColor(const cvf::Color3f& color); + void setLineColor(const cvf::Color3f& lineColor); + void setLineWidth(int lineWidth); + + void setTitle(const cvf::String& title); + + void enableBackground(bool enable); + void setBackgroundColor(const cvf::Color4f& backgroundColor); + void setBackgroundFrameColor(const cvf::Color4f& backgroundFrameColor); + + virtual cvf::Vec2ui preferredSize() = 0; + + protected: + cvf::Color3f textColor() const; + cvf::Color3f lineColor() const; + int lineWidth() const; + + bool backgroundEnabled() const; + cvf::Color4f backgroundColor() const; + cvf::Color4f backgroundFrameColor() const; + std::vector& titleStrings(); + cvf::Font* font(); + + private: + cvf::Vec2ui sizeHint() override final; // Will return the size to use for rendering, and is really not a hint. + cvf::Vec2ui m_renderSize; // The rendered size of the color legend area in pixels + + cvf::Color3f m_textColor; + cvf::Color3f m_lineColor; + int m_lineWidth; + + bool m_isBackgroundEnabled; + cvf::Color4f m_backgroundColor; + cvf::Color4f m_backgroundFrameColor; + + std::vector m_titleStrings; + cvf::ref m_font; + }; +} diff --git a/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp b/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp index 9e05655d84..f98be873c9 100644 --- a/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp +++ b/Fwk/AppFwk/cafVizExtensions/cafTransparentWBRenderConfiguration.cpp @@ -51,6 +51,73 @@ using namespace cvf; P4 Combination pass + ==================================== + Usage + ==================================== + class MyViewer : public caf::Viewer + { + Q_OBJECT; + public: + MyViewer(const QGLFormat& format, QWidget* parent) + : caf::Viewer(format, parent) + { + m_renderConf = new caf::TransparentWBRenderConfiguration; + m_renderConf->setUpRenderSequence(m_renderingSequence.p()); + + // Cerate overly item if needed + cvf::OverlyItem* overlayItem; // = new someTtem + m_renderConf->overlayRendering()->addOverlayItem(overlayItem); + } + + ~MyViewer(); + + virtual void optimizeClippingPlanes() + { + // ... Do ordinary clipplane adjustments + + m_renderConf->prepareForRendering(); + } + virtual void resizeGL(int width, int height) + { + m_renderConf->resize(width, height); + caf::Viewer::resizeGL(width, height); + } + + private: + cvf::ref m_renderConf; + }; + + //-------------------------------------------------------------------------------------------------- + /// + //-------------------------------------------------------------------------------------------------- + + ref createFacePartFromDrawableGeo(cvf::DrawableGeo* geo, + const Color3f& color, + float opacity, + bool useSpecularReflection) + { + ref part = new Part; + part->setDrawable(geo); + + cvf::Color4f colorWithAlpha(color); + colorWithAlpha.a() = opacity; + + caf::WBTransparencySurfaceEffectGenerator effGen(colorWithAlpha, caf::PO_NONE, useSpecularReflection); + ref eff = effGen.generateEffectFromCache(); + + if (opacity < 1.0) + { + part->setPriority(100); + } + + part->setEffect(eff.p()); + + return part; + } + + + + */ class RenderPassPreparator : public cvf::DynamicUniformSet @@ -61,7 +128,7 @@ class RenderPassPreparator : public cvf::DynamicUniformSet CVF_ASSERT(renderConfiguration); m_renderConfiguration = renderConfiguration; } - virtual cvf::UniformSet* uniformSet() { return NULL; } + virtual cvf::UniformSet* uniformSet() { return nullptr; } virtual void update(cvf::Rendering* rendering) { m_renderConfiguration->updateEffectsForRendering(rendering); diff --git a/Fwk/VizFwk/LibCore/CMakeLists.txt b/Fwk/VizFwk/LibCore/CMakeLists.txt index 3ce19f6ec0..0637746261 100644 --- a/Fwk/VizFwk/LibCore/CMakeLists.txt +++ b/Fwk/VizFwk/LibCore/CMakeLists.txt @@ -100,3 +100,10 @@ cvfVector4.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibCore/cvfObject.inl b/Fwk/VizFwk/LibCore/cvfObject.inl index 59bf9dbf38..25ea5cefec 100644 --- a/Fwk/VizFwk/LibCore/cvfObject.inl +++ b/Fwk/VizFwk/LibCore/cvfObject.inl @@ -87,8 +87,9 @@ inline int Object::release() const { // Release on a NULL object ok, just return 0 // This is symmetric with being able to call delete on a NULL pointer +#ifndef __clang__ if (!this) return 0; - +#endif CVF_TIGHT_ASSERT(m_refCount > 0); if (--m_refCount == 0) diff --git a/Fwk/VizFwk/LibCore/cvfVector2.h b/Fwk/VizFwk/LibCore/cvfVector2.h index 720dceab45..c80c087e20 100644 --- a/Fwk/VizFwk/LibCore/cvfVector2.h +++ b/Fwk/VizFwk/LibCore/cvfVector2.h @@ -118,7 +118,7 @@ class Vector2 private: template - friend inline const Vector2 operator*(T scalar, const Vector2& rhs); + friend const Vector2 operator*(T scalar, const Vector2& rhs); private: S m_v[2]; diff --git a/Fwk/VizFwk/LibCore/cvfVector3.h b/Fwk/VizFwk/LibCore/cvfVector3.h index 25d4c9533e..0a31071367 100644 --- a/Fwk/VizFwk/LibCore/cvfVector3.h +++ b/Fwk/VizFwk/LibCore/cvfVector3.h @@ -144,7 +144,7 @@ class Vector3 private: template - friend inline const Vector3 operator*(T scalar, const Vector3& rhs); + friend const Vector3 operator*(T scalar, const Vector3& rhs); private: S m_v[3]; diff --git a/Fwk/VizFwk/LibGeometry/CMakeLists.txt b/Fwk/VizFwk/LibGeometry/CMakeLists.txt index 6034118a2c..c18b0bd727 100644 --- a/Fwk/VizFwk/LibGeometry/CMakeLists.txt +++ b/Fwk/VizFwk/LibGeometry/CMakeLists.txt @@ -7,9 +7,6 @@ project(LibGeometry) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") -include_directories(../LibCore) - - set(CEE_HEADER_FILES cvfArrowGenerator.h cvfBoundingBox.h @@ -57,3 +54,14 @@ cvfVertexWelder.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibGuiQt/CMakeLists.txt b/Fwk/VizFwk/LibGuiQt/CMakeLists.txt index 5184988103..b699af4960 100644 --- a/Fwk/VizFwk/LibGuiQt/CMakeLists.txt +++ b/Fwk/VizFwk/LibGuiQt/CMakeLists.txt @@ -14,13 +14,6 @@ endif() find_package(Qt4 REQUIRED) include(${QT_USE_FILE}) - -include_directories(../LibCore) -include_directories(../LibGeometry) -include_directories(../LibRender) -include_directories(../LibViewing) - - set(CEE_HEADER_FILES cvfqtBasicAboutDialog.h cvfqtCvfBoundQGLContext.h @@ -43,3 +36,18 @@ cvfqtUtils.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibRender + LibViewing + + ${QT_LIBRARIES} +) +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibRender/CMakeLists.txt b/Fwk/VizFwk/LibRender/CMakeLists.txt index d2e28dee6c..73466d5e69 100644 --- a/Fwk/VizFwk/LibRender/CMakeLists.txt +++ b/Fwk/VizFwk/LibRender/CMakeLists.txt @@ -18,8 +18,6 @@ if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") endif() -include_directories(../LibCore) -include_directories(../LibGeometry) include_directories(glew) @@ -178,3 +176,15 @@ cvfViewport.cpp add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp b/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp index d07c79291d..a7c191ac1f 100644 --- a/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp +++ b/Fwk/VizFwk/LibRender/cvfDrawableVectors.cpp @@ -125,6 +125,12 @@ void DrawableVectors::setSingleColor(Color3f color) } +void DrawableVectors::setUniformNames(String vectorMatrixUniformName, String colorUniformName) +{ + m_vectorMatrixUniformName = vectorMatrixUniformName; + m_colorUniformName = colorUniformName; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/Fwk/VizFwk/LibRender/cvfDrawableVectors.h b/Fwk/VizFwk/LibRender/cvfDrawableVectors.h index 18798b1fce..bdf9f9c901 100644 --- a/Fwk/VizFwk/LibRender/cvfDrawableVectors.h +++ b/Fwk/VizFwk/LibRender/cvfDrawableVectors.h @@ -63,6 +63,7 @@ class DrawableVectors : public Drawable void setGlyph(UShortArray* triangles, Vec3fArray* vertices); void setSingleColor(Color3f color); + void setUniformNames(String vectorMatrixUniformName, String colorUniformName); void setVectors(Vec3fArray* vertexArray, Vec3fArray* vectorArray); void setColors(Color3fArray* vectorColorArray); size_t vectorCount() const; diff --git a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp index 9fd13eaea2..3f2467ce55 100644 --- a/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp +++ b/Fwk/VizFwk/LibRender/cvfScalarMapperRangeBased.cpp @@ -115,7 +115,7 @@ void ScalarMapperRangeBased::setLevelCount(size_t levelCount, bool adjustLevels) //-------------------------------------------------------------------------------------------------- void ScalarMapperRangeBased::setLevelsFromValues(const std::set& levelValues) { - CVF_ASSERT(!m_userDefinedLevelValues.empty()); + CVF_ASSERT(!levelValues.empty()); m_userDefinedLevelValues = levelValues; m_rangeMax = (*levelValues.rbegin()); @@ -244,15 +244,21 @@ void ScalarMapperRangeBased::majorTickValues( std::vector* domainValues) if (normalizedValue(newLevel) > 1.0 - stepSizeNorm*0.4) break; - domainValues->push_back(newLevel); + if (newLevel != prevDomValue) domainValues->push_back(newLevel); + prevDomValue = newLevel; } } else { + double prevDomValue = domainValue(0); for (i = 1; i < m_levelCount; ++i) { - domainValues->push_back(domainValue(stepSizeNorm*i)); + double newLevel = domainValue(stepSizeNorm*i); + + if (newLevel != prevDomValue) domainValues->push_back(newLevel); + + prevDomValue = newLevel; } } } diff --git a/Fwk/VizFwk/LibViewing/CMakeLists.txt b/Fwk/VizFwk/LibViewing/CMakeLists.txt index 7c40ee0661..28f5937fbd 100644 --- a/Fwk/VizFwk/LibViewing/CMakeLists.txt +++ b/Fwk/VizFwk/LibViewing/CMakeLists.txt @@ -6,12 +6,6 @@ project(LibViewing) # Use our strict compile flags set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CEE_STRICT_CXX_FLAGS}") - -include_directories(../LibCore) -include_directories(../LibGeometry) -include_directories(../LibRender) - - set(CEE_HEADER_FILES cvfClipPlaneSet.h cvfConstantFrameRate.h @@ -76,3 +70,17 @@ cvfTransform.cpp ) add_library(${PROJECT_NAME} ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +target_link_libraries ( ${PROJECT_NAME} + LibCore + LibGeometry + LibRender +) + +set(PROJECT_FILES ${CEE_HEADER_FILES} ${CEE_SOURCE_FILES}) +source_group("" FILES ${PROJECT_FILES}) diff --git a/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m b/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m deleted file mode 100644 index 182b99c1c6..0000000000 --- a/OctavePlugin/OctaveScripts/OctaveInterfaceTest.m +++ /dev/null @@ -1,325 +0,0 @@ -### The case with caseid 1 has to be selected/active in ResInsight when running this test-script -### Coarsening and Dual porosity is not exercised by this tes yet. We need models - - -### CaseInfo riGetCurrentCase() -%!test -%! printf ("===== Testing ====> riGetCurrentCase\n"); -%! caseInfo = riGetCurrentCase(); -%! assert ( caseInfo.CaseId == 1 ); -%! assert ( caseInfo.CaseName == "BRUGGE_0000" ); -%! assert ( caseInfo.CaseType == "SourceCase" ); -%! assert ( caseInfo.CaseGroupId == 0 ); - -### Vector[CaseInfo] riGetSelectedCases() -%!test -%! printf ("===== Testing ====> riGetSelectedCases\n"); -%! caseInfoVector1 = riGetSelectedCases(); -%! assert ( caseInfoVector1.CaseId == 1 ); -%! assert ( caseInfoVector1.CaseName == "BRUGGE_0000" ); -%! assert ( caseInfoVector1.CaseType == "SourceCase" ); -%! assert ( caseInfoVector1.CaseGroupId == 0 ); - - -### Vector[CaseGroupInfo] riGetCaseGroups() -%!test -%! printf ("===== Testing ====> riGetCaseGroups\n"); -%! caseGroupInfoVector = riGetCaseGroups(); -%! assert (rows(caseGroupInfoVector) == 2); -%! assert (caseGroupInfoVector(2).CaseGroupId == 1); -%! assert (caseGroupInfoVector(2).CaseGroupName == "Grid Case Group 2"); - -### Vector[CaseInfo] riGetCases([CaseGroupId]) -%!test -%! printf ("===== Testing ====> riGetCases\n"); -%! caseInfoVector3 = riGetCases(); -%! assert(rows(caseInfoVector3) == 10); -%! assert(caseInfoVector3(2).CaseName == "BRUGGE_0040"); -%! assert(caseInfoVector3(2).CaseType == "ResultCase"); -%! assert(caseInfoVector3(3).CaseType == "StatisticsCase"); -%! assert(caseInfoVector3(4).CaseType == "SourceCase"); -%! caseinfoVector3 = riGetCases(1); -%! assert(rows(caseinfoVector3) == 3); - - -### Matrix[numActiveCells][9] riGetActiveCellInfo([CaseId], [PorosityModel = "Matrix"|"Fracture"] ) -%!test -%! printf ("===== Testing ====> riGetActiveCellInfo\n"); -%! ACInfo1 = riGetActiveCellInfo(); -%! assert(rows(ACInfo1) == 43374); -%! assert(columns(ACInfo1) == 9); -%! ACInfo2 = riGetActiveCellInfo("Matrix"); -%! assert(ACInfo1 == ACInfo2); -%! ACInfo3 = riGetActiveCellInfo(1, "Matrix"); -%! assert(ACInfo1 == ACInfo3); -%! ACInfo4 = riGetActiveCellInfo(1); -%! assert(ACInfo1 == ACInfo4); - -### Matrix[numCoarseGroups][6] riGetCoarseningInfo([CaseId]) -%!test -%! printf ("===== Testing ====> riGetCoarseningInfo\n"); -%! CoarseInfo1 = riGetCoarseningInfo(); -%! assert(rows(CoarseInfo1) == 0); -%! assert(columns(CoarseInfo1) == 6); - - -### Matrix[numGrids][3] riGetGridDimensions([CaseId]) -%!test -%! printf ("===== Testing ====> riGetGridDimensions\n"); -%! GridDims1 = riGetGridDimensions(); -%! assert(rows(GridDims1) == 1); -%! assert(columns(GridDims1) == 3); - -%! GridDims2 = riGetGridDimensions(0); -%! assert(rows(GridDims2) == 2); -%! assert(columns(GridDims2) == 3); -%! assert( GridDims2(2,1) == 12); -%! assert( GridDims2(2,3) == 36); - -### Vector[TimeStepDate] riGetTimestepDates([CaseId]) -%!test -%! printf ("===== Testing ====> riGetTimestepDates\n"); -%! TimeStepDates1 = riGetTimeStepDates(); -%! assert(rows(TimeStepDates1) == 11); -%! assert(TimeStepDates1(2).Year == 1997); -%! assert(TimeStepDates1(2).Month == 01); -%! assert(TimeStepDates1(2).Day == 31); -%! assert(TimeStepDates1(2).Hour == 0); -%! assert(TimeStepDates1(2).Minute == 0); -%! assert(TimeStepDates1(2).Second == 0); -%! TimeStepDates2 = riGetTimeStepDates(1); -%! assert(TimeStepDates2(7).Year == 1997); -%! assert(TimeStepDates2(7).Month == 06); -%! assert(TimeStepDates2(7).Day == 30); -%! assert(TimeStepDates2(7).Hour == 0); -%! assert(TimeStepDates2(7).Minute == 0); -%! assert(TimeStepDates2(7).Second == 0); - -### Vector[DecimalDay] riGetTimestepDays([CaseId]) -%!test -%! printf ("===== Testing ====> riGetTimestepDays\n"); -%! TimeStepDays1 = riGetTimeStepDays(); -%! assert(TimeStepDays1(1) == 0); -%! assert(TimeStepDays1(2) == 30); -%! assert(rows(TimeStepDays1) == 11); -%! TimeStepDays2 = riGetTimeStepDays(1); -%! assert(rows(TimeStepDays2) == 11); - - -### Vector[PropertyInfo] riGetPropertyNames([CaseId] ], [PorosityModel = "Matrix"|"Fracture"]) -%!xtest -%! printf ("===== Testing ====> riGetPropertyNames\n"); -%! PropertyInfos1 = riGetPropertyNames(); -%! PropertyInfos2 = riGetPropertyNames(1); -%! PropertyInfos3 = riGetPropertyNames("Matrix"); -%! PropertyInfos4 = riGetPropertyNames(1, "Matrix"); -%! assert(PropertyInfos1(1).PropName == "PRESSURE"); -%! assert(PropertyInfos1(1).PropType == "DynamicNative"); -%! assert(PropertyInfos1(26).PropType == "StaticNative"); - -### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetActiveCellProperty\n"); -%! ActivePropData1 = riGetActiveCellProperty("SWAT"); -%! assert (rows(ActivePropData1) == rows(riGetActiveCellInfo())); -%! assert (columns(ActivePropData1) == rows(riGetTimeStepDays())); -%! ActivePropData2 = riGetActiveCellProperty("SWAT", "Matrix"); -%! assert (ActivePropData2 == ActivePropData1); -%! ActivePropData3 = riGetActiveCellProperty("SWAT", [1,3]); -%! assert (columns(ActivePropData3) == 2); -%! assert (ActivePropData3(:,2) == ActivePropData1(:,3)); -%! ActivePropData4 = riGetActiveCellProperty("SWAT", [1,3], "Matrix"); -%! assert (ActivePropData3 == ActivePropData4); -%! ActivePropData5 = riGetActiveCellProperty(1, "SWAT"); -%! assert (ActivePropData5 == ActivePropData1); -%! ActivePropData6 = riGetActiveCellProperty(1, "SWAT", [1,3]); -%! assert (ActivePropData6 == ActivePropData3); -%! ActivePropData7 = riGetActiveCellProperty(1, "SWAT", [1,3], "Matrix"); -%! assert (ActivePropData7 == ActivePropData3); -%! ActivePropData8 = riGetActiveCellProperty(1, "SWAT", "Matrix"); -%! assert (ActivePropData8 == ActivePropData1); - -### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetGridProperty\n"); -%! GridProps1 = riGetGridProperty( 0 , "SWAT" ); -%! assert( ndims (GridProps1) == 4); -%! [ni, nj, nk, nts ] = size(GridProps1); -%! disp(nts); -%! assert(nts == 11); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(GridProps1(62,30,1,3), 0.40942, 0.00001); - -%! GridProps2 = riGetGridProperty( 0 , "SWAT", [1,3]); -%! assert( ndims (GridProps2) == 4); -%! [ni, nj, nk, nts ] = size(GridProps2); -%! assert(nts == 2); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(GridProps2(62,30,1,2), 0.40942, 0.00001); - -%! GridProps3 = riGetGridProperty( 0 , "SWAT", [1,3], "Matrix"); -%! GridProps4 = riGetGridProperty( 0 , "SWAT", "Matrix"); -%! GridProps5 = riGetGridProperty(1, 0 , "SWAT" ); -%! GridProps6 = riGetGridProperty(1, 0 , "SWAT", [1,3]); -%! GridProps7 = riGetGridProperty(1, 0 , "SWAT", [1,3], "Matrix"); -%! GridProps8 = riGetGridProperty(1, 0 , "SWAT", "Matrix"); - -%! assert(GridProps3 == GridProps2); -%! assert(GridProps4 == GridProps1); -%! assert(GridProps5 == GridProps1); -%! assert(GridProps6 == GridProps2); -%! assert(GridProps7 == GridProps2); -%! assert(GridProps8 == GridProps1); - - - ### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riSetActiveCellProperty\n"); -%! ActivePropData1 = riGetActiveCellProperty("SWAT"); -%! ActivePropData3 = riGetActiveCellProperty("SWAT", [1,3]); - -%! riSetActiveCellProperty( ActivePropData1, "PropertyName1" ); -%! riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]); -%! riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix"); -%! riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix"); -%! riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" ); -%! riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]); -%! riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix"); -%! riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix"); - -%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName1")); -%! assert(ActivePropData3 == riGetActiveCellProperty("PropertyName2", [1,3])); -%! assert(ActivePropData3 == riGetActiveCellProperty("PropertyName3", [1,3])); -%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName4", "Matrix")); -%! assert(ActivePropData1 == riGetActiveCellProperty("PropertyName5")); -%! assert(ActivePropData3 == riGetActiveCellProperty( 1, "PropertyName6", [1,3])); -%! assert(ActivePropData3 == riGetActiveCellProperty( 1, "PropertyName7", [1,3], "Matrix")); -%! assert(ActivePropData1 == riGetActiveCellProperty( 1, "PropertyName8", "Matrix")); - -### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riSetGridProperty\n"); -%! GridProps1 = riGetGridProperty( 0 , "SWAT" ); -%! GridProps2 = riGetGridProperty( 0 , "SWAT", [1,3]); - -%! riSetGridProperty( GridProps1, 0, "PropertyName11" ); -%! riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]); -%! riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix"); -%! riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix"); -%! riSetGridProperty( GridProps1, 1, 0, "PropertyName15" ); -%! riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]); -%! riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix"); -%! riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix"); - -%! assert(GridProps1 == riGetGridProperty( 0, "PropertyName11")); -%! assert(GridProps2 == riGetGridProperty( 0, "PropertyName12", [1,3])); -%! assert(GridProps2 == riGetGridProperty( 0, "PropertyName13", [1,3], "Matrix")); -%! assert(GridProps1 == riGetGridProperty( 0, "PropertyName14", "Matrix")); -%! assert(GridProps1 == riGetGridProperty( 1, 0, "PropertyName15")); -%! assert(GridProps2 == riGetGridProperty( 1, 0, "PropertyName16", [1,3])); -%! assert(GridProps2 == riGetGridProperty( 1, 0, "PropertyName17", [1,3], "Matrix")); -%! assert(GridProps1 == riGetGridProperty( 1, 0, "PropertyName18", "Matrix")); - - -### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex) -%!test -%! printf ("===== Testing ====> riGetCellCenters\n"); -%! CellCenters1 = riGetCellCenters(0); -%! CellCenters2 = riGetCellCenters(1, 0); -%! assert( ndims (CellCenters1) == 4); -%! [ni, nj, nk, idx ] = size(CellCenters1); -%! assert(idx == 3); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(CellCenters1(62,30,1, 1), 3489.2, 0.1); -%! assert(CellCenters1(62,30,1, 2), 1.5909e+004, 0.1); -%! assert(CellCenters1(62,30,1, 3), -5458.8, 0.1); -%! assert(CellCenters1 == CellCenters2); - - - -### Matrix[ActiveCells][3] riGetActiveCellCenters([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetActiveCellCenters\n"); -%! ActiveCellCenters1 = riGetActiveCellCenters(); -%! ActiveCellCenters2 = riGetActiveCellCenters("Matrix"); -%! ActiveCellCenters3 = riGetActiveCellCenters(1, "Matrix"); - -%! assert (rows(ActiveCellCenters1), rows(riGetActiveCellInfo())); -%! assert (columns(ActiveCellCenters1) == 3); -%! assert (ActiveCellCenters1(500,:) ,[3493.7, 9184.6, -6074.4], [0.1, 0.1, 0.1]); -%! assert (ActiveCellCenters1 == ActiveCellCenters2); -%! assert (ActiveCellCenters1 == ActiveCellCenters3); - - -### Matrix[numI][numJ][numK][8][3] riGetCellCorners([CaseId], GridIndex) -%!test -%! printf ("===== Testing ====> riGetCellCorners\n"); -%! CellCorners1 = riGetCellCorners(0); -%! CellCorners2 = riGetCellCorners(1, 0); - -%! assert( ndims (CellCorners1) == 5); -%! [ni, nj, nk, cidx, idx ] = size(CellCorners1); -%! assert(idx == 3); -%! assert(cidx == 8); -%! assert(ni == 139); -%! assert(nj == 48); -%! assert(nk == 9); -%! assert(CellCorners1(62,30,1, 1, 1), 3207.4, 0.1); -%! assert(CellCorners1(62,30,1, 1, 2), 1.5781e+004, 1); -%! assert(CellCorners1(62,30,1, 1, 3), -5466.1, 0.1); -%! assert (CellCorners1 == CellCorners2); - - -### Matrix[ActiveCells][8][3] riGetActiveCellCorners([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -%!test -%! printf ("===== Testing ====> riGetActiveCellCorners\n"); -%! ActiveCellCorners1 = riGetActiveCellCorners(); -%! ActiveCellCorners2 = riGetActiveCellCorners(1); -%! ActiveCellCorners3 = riGetActiveCellCorners(1, "Matrix"); -%! ActiveCellCorners4 = riGetActiveCellCorners("Matrix"); - -%! assert( ndims (ActiveCellCorners1) == 3); -%! [nactive, cidx, idx ] = size(ActiveCellCorners1); -%! assert(idx == 3); -%! assert(cidx == 8); -%! assert(nactive , rows(riGetActiveCellInfo())); - -%! assert(ActiveCellCorners1(500,1, 1), 3207.2, 0.1); -%! assert(ActiveCellCorners1(500,1, 2), 9080.7, 0.1); -%! assert(ActiveCellCorners1(500,1, 3), -6076.8, 0.1); -%! assert (ActiveCellCorners1 , ActiveCellCorners2); -%! assert (ActiveCellCorners1 , ActiveCellCorners3); -%! assert (ActiveCellCorners1 , ActiveCellCorners4); - -### Vector[WellNames] riGetWellNames([CaseId]) -%!xtest -%! printf ("===== Testing ====> riGetWellNames\n"); -%! WellNames1 = riGetWellNames(); -%! WellNames2 = riGetWellNames(1); -%! assert (rows(WellNames1), 113); -%! assert (rows(WellNames1) == rows(WellNames2)); - -### Vector[WellCellInfo] riGetWellCells([CaseId], WellName, TimeStep) -%!test -%! printf ("===== Testing ====> riGetWellCells\n"); -%! WellNames1 = riGetWellNames(); -%! WellCellInfos1 = riGetWellCells(1, WellNames1{1}, 3); -%! WellCellInfos2 = riGetWellCells(WellNames1{1}, 3); - - -### Vector[WellStatus] riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps]) -%!test -%! printf ("===== Testing ====> riGetWellStatus\n"); -%! WellNames1 = riGetWellNames(); -%! WellStatuses1 = riGetWellStatus(1, WellNames1{1}, [1,3]); -%! disp(WellStatuses1(1)); -%! WellStatuses2 = riGetWellStatus( WellNames1{1}, [1,3]); -%! WellStatuses3 = riGetWellStatus(WellNames1{1}); - -endif \ No newline at end of file diff --git a/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m b/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m deleted file mode 100644 index ef2855d5ae..0000000000 --- a/OctavePlugin/OctaveScripts/ResInsightIterfaceUnitTest.m +++ /dev/null @@ -1,154 +0,0 @@ -### The case with caseid 1 has to be selected/active in ResInsight when running this test-script -### Coarsening and Dual porosity is not exercised by this tes yet. We need models - -if (1) -test OctaveInterfaceTest.m -else - -### CaseInfo riGetCurrentCase() -printf ("===== Testing ====> riGetCurrentCase\n"); -caseInfo = riGetCurrentCase(); -disp(caseInfo); - - -### Vector[CaseInfo] riGetSelectedCases() -printf ("===== Testing ====> riGetSelectedCases\n"); -caseInfoVector1 = riGetSelectedCases(); -disp(caseInfoVector1); - -if(0) - -### Vector[CaseGroupInfo] riGetCaseGroups() -printf ("===== Testing ====> riGetCaseGroups\n"); -caseGroupInfoVector = riGetCaseGroups(); - -### Vector[CaseInfo] riGetCases([CaseGroupId]) -printf ("===== Testing ====> riGetCases\n"); -caseinfoVector2 = riGetCases(); -caseinfoVector3 = riGetCases(caseGroupInfoVector(2).CaseGroupId); - -### Matrix[numActiveCells][9] riGetActiveCellInfo([CaseId], [PorosityModel = "Matrix"|"Fracture"] ) -printf ("===== Testing ====> riGetActiveCellInfo\n"); -ACInfo1 = riGetActiveCellInfo(); -ACInfo2 = riGetActiveCellInfo("Matrix"); -ACInfo3 = riGetActiveCellInfo(1, "Matrix"); - -### Matrix[numCoarseGroups][6] riGetCoarseningInfo([CaseId]) -printf ("===== Testing ====> riGetCoarseningInfo\n"); -CoarseInfo1 = riGetCoarseningInfo(); -CoarseInfo2 = riGetCoarseningInfo(1); - -### Matrix[numGrids][3] riGetGridDimensions([CaseId]) -printf ("===== Testing ====> riGetGridDimensions\n"); -GridDims1 = riGetGridDimensions(); -GridDims2 = riGetGridDimensions(1); - -### Vector[TimeStepDate] riGetTimestepDates([CaseId]) -printf ("===== Testing ====> riGetTimestepDates\n"); -TimeStepDates1 = riGetTimeStepDates(); -TimeStepDates2 = riGetTimeStepDates(1); - -### Vector[DecimalDay] riGetTimestepDays([CaseId]) -printf ("===== Testing ====> riGetTimestepDays\n"); -TimeStepDays1 = riGetTimeStepDays(); -TimeStepDays2 = riGetTimeStepDays(1); - -### Vector[PropertyInfo] riGetPropertyNames([CaseId] ], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetPropertyNames\n"); -PropertyInfos1 = riGetPropertyNames(); -PropertyInfos2 = riGetPropertyNames(1); -PropertyInfos3 = riGetPropertyNames("Matrix"); -PropertyInfos4 = riGetPropertyNames(1, "Matrix"); - -### Matrix[numActiveCells][numTimestepsRequested] riGetActiveCellProperty([CaseId], PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetActiveCellProperty\n"); -ActivePropData1 = riGetActiveCellProperty("SOIL"); -ActivePropData2 = riGetActiveCellProperty("SOIL", "Matrix"); -ActivePropData3 = riGetActiveCellProperty("SOIL", [1,3]); -ActivePropData4 = riGetActiveCellProperty("SOIL", [1,3], "Matrix"); - -ActivePropData5 = riGetActiveCellProperty(1, "SOIL"); -ActivePropData6 = riGetActiveCellProperty(1, "SOIL", [1,3]); -ActivePropData7 = riGetActiveCellProperty(1, "SOIL", [1,3], "Matrix"); -ActivePropData8 = riGetActiveCellProperty(1, "SOIL", "Matrix"); - -### Matrix[numI][numJ][numK][numTimestepsRequested] riGetGridProperty([CaseId], GridIndex , PropertyName, [RequestedTimeSteps], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetGridProperty\n"); -GridProps1 = riGetGridProperty( 0 , "SOIL" ); -GridProps2 = riGetGridProperty( 0 , "SOIL", [1,3]); -GridProps3 = riGetGridProperty( 0 , "SOIL", [1,3], "Matrix"); -GridProps4 = riGetGridProperty( 0 , "SOIL", "Matrix"); -GridProps5 = riGetGridProperty(1, 0 , "SOIL" ); -GridProps6 = riGetGridProperty(1, 0 , "SOIL", [1,3]); -GridProps7 = riGetGridProperty(1, 0 , "SOIL", [1,3], "Matrix"); -GridProps8 = riGetGridProperty(1, 0 , "SOIL", "Matrix"); - - -### riSetActiveCellProperty( Matrix[numActiveCells][numTimeSteps], [CaseId], PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riSetActiveCellProperty\n"); -riSetActiveCellProperty( ActivePropData1, "PropertyName1" ); - -riSetActiveCellProperty( ActivePropData3, "PropertyName2", [1,3]); -riSetActiveCellProperty( ActivePropData3, "PropertyName3", [1,3], "Matrix"); -riSetActiveCellProperty( ActivePropData1, "PropertyName4", "Matrix"); -riSetActiveCellProperty( ActivePropData1, 1, "PropertyName5" ); -riSetActiveCellProperty( ActivePropData3, 1, "PropertyName6", [1,3]); -riSetActiveCellProperty( ActivePropData3, 1, "PropertyName7", [1,3], "Matrix"); -riSetActiveCellProperty( ActivePropData1, 1, "PropertyName8", "Matrix"); - -### riSetGridProperty( Matrix[numI][numJ][numK][numTimeSteps], [CaseId], GridIndex, PropertyName, [TimeStepIndices], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riSetGridProperty\n"); -riSetGridProperty( GridProps1, 0, "PropertyName11" ); -riSetGridProperty( GridProps2, 0, "PropertyName12", [1,3]); -riSetGridProperty( GridProps2, 0, "PropertyName13", [1,3], "Matrix"); -riSetGridProperty( GridProps1, 0, "PropertyName14", "Matrix"); -riSetGridProperty( GridProps1, 1, 0, "PropertyName15" ); -riSetGridProperty( GridProps2, 1, 0, "PropertyName16", [1,3]); -riSetGridProperty( GridProps2, 1, 0, "PropertyName17", [1,3], "Matrix"); -riSetGridProperty( GridProps1, 1, 0, "PropertyName18", "Matrix"); - - -### Matrix[numI][numJ][numK][3] riGetCellCenters([CaseId], GridIndex) -printf ("===== Testing ====> riGetCellCenters\n"); -CellCenters1 = riGetCellCenters(0); -CellCenters2 = riGetCellCenters(1, 0); - -### Matrix[ActiveCells][3] riGetActiveCellCenters([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetActiveCellCenters\n"); -ActiveCellCenters1 = riGetActiveCellCenters(); -ActiveCellCenters2 = riGetActiveCellCenters("Matrix"); -ActiveCellCenters3 = riGetActiveCellCenters(1, "Matrix"); - -### Matrix[numI][numJ][numK][8][3] riGetCellCorners([CaseId], GridIndex) -printf ("===== Testing ====> riGetCellCorners\n"); -CellCorners1 = riGetCellCorners(0); -CellCorners2 = riGetCellCorners(1, 0); - -### Matrix[ActiveCells][8][3] riGetActiveCellCorners([CaseId], [PorosityModel = "Matrix"|"Fracture"]) -printf ("===== Testing ====> riGetActiveCellCorners\n"); -ActiveCellCorners1 = riGetActiveCellCorners(); -ActiveCellCorners2 = riGetActiveCellCorners(1); -ActiveCellCorners3 = riGetActiveCellCorners(1, "Matrix"); -ActiveCellCorners4 = riGetActiveCellCorners("Matrix"); - -### Vector[WellNames] riGetWellNames([CaseId]) -printf ("===== Testing ====> riGetWellNames\n"); - -WellNames1 = riGetWellNames(); -WellNames2 = riGetWellNames(1); - -### Vector[WellCellInfo] riGetWellCells([CaseId], WellName, TimeStep) -printf ("===== Testing ====> riGetWellCells\n"); -WellCellInfos1 = riGetWellCells(1, WellNames1(1,:), 3); -WellCellInfos2 = riGetWellCells(WellNames1(1,:), 3); - - -### Vector[WellStatus] riGetWellStatus ([CaseId], WellName, [RequestedTimeSteps]) -printf ("===== Testing ====> riGetWellStatus\n"); -WellStatuses1 = riGetWellStatus(1, WellNames1(1,:), [1,3]); -disp(WellStatuses1(1)); -WellStatuses2 = riGetWellStatus( WellNames1(1,:), [1,3]); -WellStatuses3 = riGetWellStatus(WellNames1(1,:)); - -endif -endif \ No newline at end of file diff --git a/OctavePlugin/riSettings.h b/OctavePlugin/riSettings.h index 3e80a781d9..ee31729355 100644 --- a/OctavePlugin/riSettings.h +++ b/OctavePlugin/riSettings.h @@ -16,7 +16,7 @@ // ///////////////////////////////////////////////////////////////////////////////// -#include "../ApplicationCode/SocketInterface/RiaSocketServer.h" +#include "../ApplicationCode/SocketInterface/RiaSocketServerDefines.h" namespace riOctavePlugin { diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 6d09cf4146..a65fff0741 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -1,28 +1,28 @@ set(RESINSIGHT_MAJOR_VERSION 2018) -set(RESINSIGHT_MINOR_VERSION 01) -set(RESINSIGHT_PATCH_VERSION 1) +set(RESINSIGHT_MINOR_VERSION 05) +set(RESINSIGHT_PATCH_VERSION 0) # Opional text with no restrictions -#set(RESINSIGHT_VERSION_TEXT "-patch") +#set(RESINSIGHT_VERSION_TEXT "-dev") # Optional text # Must be unique and increasing within one combination of major/minor/patch version # The uniqueness of this text is independent of RESINSIGHT_VERSION_TEXT # Format of text must be ".xx" -#set(RESINSIGHT_DEV_VERSION ".00") +#set(RESINSIGHT_DEV_VERSION ".01") # https://github.com/CRAVA/crava/tree/master/libs/nrlib set(NRLIB_GITHUB_SHA "ba35d4359882f1c6f5e9dc30eb95fe52af50fd6f") # https://github.com/Statoil/libecl -set(ERT_GITHUB_SHA "2e36798b43daf18c112b91aa3febbf2fccd4a95f") +set(ECL_GITHUB_SHA "0188b08081eb1ac4ade89ac224b8128b4c9b0481") # https://github.com/OPM/opm-flowdiagnostics -set(OPM_FLOWDIAGNOSTICS_SHA "7e2be931d430796ed42efcfb5c6b67a8d5962f7f") +set(OPM_FLOWDIAGNOSTICS_SHA "f8af0914f8b1ddcda41f040f539c945a6057f5e4") # https://github.com/OPM/opm-flowdiagnostics-applications -set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "5bcd6d99259a63f5cd820db541b45c4f07aec808") +set(OPM_FLOWDIAGNOSTICS_APPLICATIONS_SHA "e769c492ccd3fc4e1f834ed60f4f9279ba8524bc") # https://github.com/OPM/opm-parser/blob/master/opm/parser/eclipse/Units/Units.hpp # This file was moved from opm-core to opm-parser october 2016 diff --git a/TestModels/20Layers.lyr b/TestModels/20Layers.lyr new file mode 100644 index 0000000000..286d4016ae --- /dev/null +++ b/TestModels/20Layers.lyr @@ -0,0 +1,13 @@ + +'Fm. 1.1' 15 - 15 +'Fm. 1.2' 16 - 17 +'Fm. 2 HD' 18 - 18 +'Fm. 2.1 HD' 19 - 19 +' Fm. 3.1 HD' 20 - 20 +' Fm. 3.2 HD' 21 - 23 +' Fm. 3.2.1 HD' 24 - 26 +' Fm. 3.3 HD' 27 - 29 +' Fm. 3.4 HD' 30 - 31 +' Fm. 3.5 HD' 32 - 32 +' Fm. 4 HD' 33 - 33 +' Fm. 4.1 HD' 34 - 34 diff --git a/TestModels/Documenetation.rsp b/TestModels/Documenetation.rsp index 220c94a5a8..809a1b8ea7 100644 --- a/TestModels/Documenetation.rsp +++ b/TestModels/Documenetation.rsp @@ -1,8 +1,7 @@ - C:/gitRoot/OPM/ResInsight/TestModels/Documenetation.rsp - 0.9.31 + 2018.01.1-devRC.110 11 3 @@ -13,15 +12,105 @@ TEST10K_FLT_LGR_NNC 0 + .. .. FormationNamesCollection 0 FormationNamesList 0 + + + + 0 + 0 + TS_ALL + 1 + + + + + + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 1 + 0.990313 0.137942 0.0158881 -1512.91 -0.108227 0.695124 0.710697 -1652.45 0.0869907 -0.705531 0.703319 -4090.21 0 0 0 1 + 0 0 0 + True + 11 + 0.752941191196442 0.823529422283173 0.87058824300766 + 10 + True + 5 + NO_MESH + SURFACE + True + False + + + + + New Filter (1) + True + EXCLUDE + 0 + True + 31 + 16 + 23 + 28 + 13 + 14 + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + DYNAMIC_NATIVE MATRIX_MODEL SOIL - + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + True 8 2 FIXED @@ -32,18 +121,35 @@ 0 SOIL - - + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + True + MULTI_AXIS_STATIC_PROPERTY True True True + True 8 2 FIXED @@ -55,71 +161,291 @@ + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + - - - True - True - True - True - - - View 1 - 11 - True - 5 - True + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + True - True - True + True 1 - WELLHEAD_POS_TOP_COLUMN - 0 0 0 - OPEN_IN_VISIBLE_CELLS 0.1 + 0.2 + 0 0 0 + True + 1 1 0 12 - FORCE_ALL_OFF - False + WELLPIPE_INTERPOLATED K_DIRECTION 0.5 True + WELLHEAD_POS_TOP_COLUMN - GP1 + GI1 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - GI1 + GP1 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + GP2 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + + False + + + True + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + + + + True + + + New Filter (1) + False + INCLUDE + + + + DYNAMIC_NATIVE + MATRIX_MODEL + SOIL + .. .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + 0 + 0.646495 + False + + + + + True + False + False + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 2 + 0.701898795447785 -0.712270228219442 -0.00303363497680109 358.817761221941 0.0733074277453067 0.0680022300575077 0.994988300305372 -467.44443386495 -0.708494249790579 -0.698603477445847 0.0999453816554576 -218.844742120346 0 0 0 1 + 18.6498219292924 545.189477193059 393.149390063892 + True + 5 + 0.752941191196442 0.823529422283173 0.87058824300766 + 10 + True + 5 + FULL_MESH + SURFACE + True + False @@ -137,51 +463,374 @@ 14 - True + False + + + + + True + + + + + True + + + + + False + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + + + + FORMATION_NAMES + MATRIX_MODEL + Active Formation Names + .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 2 + FIXED + NORMAL + LinearContinuous + USER_DEFINED_MAX_MIN + 0.4 + 0 + SOIL + + + True + 8 + 4 + FIXED + CATEGORY + Category + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + Active Formation Names + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 1 + + + + + True + MULTI_AXIS_STATIC_PROPERTY + + True + True + True + + + True + 8 + 2 + FIXED + PINK_WHITE + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + + + + False + True + 1 + 0.1 + 0.2 + 0 0 0 + True + 1 1 0 + 12 + WELLPIPE_INTERPOLATED + K_DIRECTION + 0.5 + True + WELLHEAD_POS_TOP_COLUMN + + + GI1 + True + True + True + True + False + 1 + 1 + 0.587999999523163 0.587999999523163 0.804000020027161 + False + False + + + + + + + + GP1 + True + True + True + True + False + 1 + 1 + 0.587999999523163 0.587999999523163 0.804000020027161 + False + False + + + + + + + + GP2 + True + True + True + True + False + 1 + 1 + 0.587999999523163 0.587999999523163 0.804000020027161 + False + False + + + + + + + + False + + + + + True + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + + False New Filter (1) False INCLUDE + DYNAMIC_NATIVE MATRIX_MODEL SOIL + .. .. .. .. FlowDiagSolutions 0 + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + 0 0.646495 + False - True - NO_MESH - SURFACE - 10 True False False - 0.752941 0.823529 0.870588 - 0.990313 0.137942 0.0158881 -1512.91 -0.108227 0.695124 0.710697 -1652.45 0.0869907 -0.705531 0.703319 -4090.21 0 0 0 1 C:/gitRoot/OPM/ResInsight/TestModels/Documenetation_cache/{3fb560c2-fab1-4397-8174-c9783de1ab58} - - - GENERATED - KSlice - - 8 - - + @@ -192,20 +841,103 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID + + + All Wells + + + BRUGGE_0040 6 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 1 + 0.0886273 -0.975863 0.199593 5826.88 -0.026925 0.197962 0.97984 -15330.1 -0.995701 -0.0922146 -0.0087303 -23559.7 0 0 0 1 + 0 0 0 + True + 5 + 0.752941012382507 0.823529005050659 0.870588004589081 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + DYNAMIC_NATIVE MATRIX_MODEL SOIL - + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + True 8 2 FIXED @@ -216,18 +948,35 @@ 0 SOIL - - + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + True + MULTI_AXIS_STATIC_PROPERTY True True True + True 8 2 FIXED @@ -239,1191 +988,2222 @@ + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + - - - True - True - True - True - - - View 1 - 5 - True - 0 - True + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + True - True - True + True 1 - WELLHEAD_POS_TOP_COLUMN - 0.898039 0.898039 0.898039 - OPEN_IN_VISIBLE_CELLS 0.1 + 0.2 + 0.898038983345032 0.898038983345032 0.898038983345032 + True + 1 1 0 12 - FORCE_ALL_OFF - False + WELLPIPE_INTERPOLATED K_DIRECTION 0.5 True + WELLHEAD_POS_TOP_COLUMN I01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02 + I01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03 + I01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04 + I01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05 + I02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06 + I02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07 + I02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08 + I02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09 + I03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10 + I03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01 + I03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02 + I03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03 + I04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04 + I04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05 + I04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06 + I04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07 + I05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08 + I05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09 + I05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10 + I05-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11 + I06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12 + I06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13 + I06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14 + I06-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15 + I07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16 + I07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17 + I07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18 + I07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19 + I08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P20 + I08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-01 + I08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-02 + I08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-03 + I09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-01 + I09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-02 + I09-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-03 + I09-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-01 + I10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-02 + I10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-03 + I10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-01 + I10-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-02 + P01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-03 + P01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-01 + P01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-02 + P01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-03 + P02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-01 + P02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-02 + P02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-03 + P02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-01 + P03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-02 + P03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-03 + P03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-01 + P03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-02 + P04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-03 + P04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-01 + P04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-02 + P04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-03 + P05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-01 + P05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-02 + P05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-03 + P06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-01 + P06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-02 + P06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-03 + P07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-01 + P07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-02 + P07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-03 + P07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-01 + P08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-02 + P08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-03 + P08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-01 + P08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-02 + P09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-03 + P09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-01 + P10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-02 + P10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-01 + P10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-02 + P11 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-01 + P11-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-02 + P11-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-03 + P11-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-01 + P12 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-02 + P12-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-03 + P12-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09-01 + P12-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-01 + P13 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-02 + P13-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-01 + P13-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-02 + P13-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-03 + P14 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-01 + P14-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-02 + P14-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-03 + P15 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-01 + P15-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-02 + P15-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-03 + P16 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-01 + P16-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-02 + P16-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-01 + P16-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-02 + P17 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-01 + P17-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-02 + P17-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-03 + P17-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-01 + P18 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-02 + P18-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-03 + P18-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-01 + P18-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-02 + P19 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-03 + P19-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-01 + P19-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-02 + P19-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-03 + P20 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + + False - - - + + True - - + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + - True + - FULL_MESH - SURFACE - 10 True False False - 0.752941 0.823529 0.870588 - 0.0886273 -0.975863 0.199593 5826.88 -0.026925 0.197962 0.97984 -15330.1 -0.995701 -0.0922146 -0.0087303 -23559.7 0 0 0 1 @@ -1440,7 +3220,14 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID + + + All Wells + + + @@ -1453,6 +3240,21 @@ Statistics 1 2 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -1468,6 +3270,7 @@ False False + PRESSURE PERMX PORO @@ -1482,6 +3285,7 @@ 50 90 None + False @@ -1492,15 +3296,91 @@ BRUGGE_0000 1 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + + + + 0 + 0 + 0 + 1030 + 638 + True + + + True + View 1 + 1 0 0 -31314.5 0 1 0 -26550.5 0 0 1 -64567.3 0 0 0 1 + 0 0 0 + True + 5 + 0.752941012382507 0.823529005050659 0.870588004589081 + 10 + True + 0 + FULL_MESH + SURFACE + True + False + + + + True + + + + + + + True + + + + + True + + + + + True + True + True + True + True + True + ALL_TIMESTEPS + ALL_CELLS + + DYNAMIC_NATIVE MATRIX_MODEL PRESSURE - + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + True 8 2 FIXED @@ -1509,11 +3389,10 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - PRESSURE + - - + True 8 2 FIXED @@ -1522,9 +3401,10 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - + SOIL + True 8 2 FIXED @@ -1533,9 +3413,10 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - SOIL + SWAT + True 8 2 FIXED @@ -1544,19 +3425,37 @@ AUTOMATIC_ALLTIMESTEPS 1 0 - SWAT + PRESSURE + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 3 + True + MULTI_AXIS_STATIC_PROPERTY True True True + True 8 2 FIXED @@ -1568,1191 +3467,2222 @@ + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + - - - True - True - True - True - - - View 1 - 5 - True - 0 - True + + + False + + + DYNAMIC_NATIVE + MATRIX_MODEL + None + + + + FLOW_TR_INJ_AND_PROD + PHASE_ALL + + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + None + + + + + True + 2 + USER_DEFINED_MAX_MIN + + 1 + 0 + 1 + 0 + 1 + 0 + + + ResultVarLegendDefinitionList 0 + + + + + + + True + + 0.647058844566345 0.164705887436867 0.164705887436867 + + True + COLOR_INTERPOLATION + + + + + False + True + 2 + + + True + 8 + 4 + FIXED + NORMAL + LinearContinuous + AUTOMATIC_ALLTIMESTEPS + 1 + 0 + + + + + True - True - True + True 1 - WELLHEAD_POS_TOP_COLUMN - 0.890196 0.890196 0.890196 - OPEN_IN_VISIBLE_CELLS 0.1 + 0.2 + 0.890196025371552 0.890196025371552 0.890196025371552 + True + 1 1 0 12 - FORCE_ALL_OFF - False + WELLPIPE_INTERPOLATED K_DIRECTION 0.5 True + WELLHEAD_POS_TOP_COLUMN I01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02 + I01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03 + I01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04 + I01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05 + I02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06 + I02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07 + I02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08 + I02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09 + I03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10 + I03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01 + I03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02 + I03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03 + I04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04 + I04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05 + I04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06 + I04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07 + I05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08 + I05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09 + I05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10 + I05-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11 + I06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12 + I06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13 + I06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14 + I06-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15 + I07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16 + I07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17 + I07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18 + I07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19 + I08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P20 + I08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-01 + I08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-02 + I08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I01-03 + I09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-01 + I09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-02 + I09-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I02-03 + I09-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-01 + I10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-02 + I10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I03-03 + I10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-01 + I10-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-02 + P01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I04-03 + P01-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-01 + P01-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-02 + P01-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I05-03 + P02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-01 + P02-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-02 + P02-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I06-03 + P02-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-01 + P03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-02 + P03-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I07-03 + P03-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-01 + P03-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-02 + P04 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I08-03 + P04-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-01 + P04-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-02 + P04-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I09-03 + P05 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-01 + P05-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-02 + P05-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - I10-03 + P06 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-01 + P06-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-02 + P06-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P01-03 + P07 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-01 + P07-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-02 + P07-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P02-03 + P07-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-01 + P08 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-02 + P08-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P03-03 + P08-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-01 + P08-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-02 + P09 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P04-03 + P09-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-01 + P10 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P05-02 + P10-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-01 + P10-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P06-02 + P11 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-01 + P11-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-02 + P11-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P07-03 + P11-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-01 + P12 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-02 + P12-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P08-03 + P12-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P09-01 + P12-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-01 + P13 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P10-02 + P13-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-01 + P13-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-02 + P13-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P11-03 + P14 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-01 + P14-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-02 + P14-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P12-03 + P15 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-01 + P15-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-02 + P15-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P13-03 + P16 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-01 + P16-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P14-02 + P16-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-01 + P16-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P15-02 + P17 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-01 + P17-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-02 + P17-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P16-03 + P17-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-01 + P18 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-02 + P18-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P17-03 + P18-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-01 + P18-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-02 + P19 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P18-03 + P19-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-01 + P19-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-02 + P19-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + - P19-03 + P20 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-01 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-02 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + P20-03 True True + True True + False + 1 1 - 0.588 0.588 0.804 - True + 0.587999999523163 0.587999999523163 0.804000020027161 + False False + + + + + + False - - - + + True - - + True + True + True + FAULT_BACK_FACE_CULLING + False + 0.945098042488098 0.945098042488098 0.945098042488098 + True + True + + + NNCs With No Common Area (0) + + + + + Undefined Grid Faults + True + 0.396078437566757 0.517647087574005 0.376470595598221 + + + Undefined Grid Faults With Inactive + False + 1 0.513725519180298 0.549019634723663 + + + + - True + - FULL_MESH - SURFACE - 10 True False False - 0.752941 0.823529 0.870588 - 1 0 0 -31314.5 0 1 0 -26550.5 0 0 1 -64567.3 0 0 0 1 @@ -2769,11 +5699,33 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID + + + All Wells + + + BRUGGE_0010 3 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2789,11 +5741,29 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID + + BRUGGE_0030 4 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2809,11 +5779,29 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real30/BRUGGE_0030.EGRID + + BRUGGE_0040 5 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2829,7 +5817,10 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real40/BRUGGE_0040.EGRID + + @@ -2844,6 +5835,21 @@ Statistics 1 7 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2859,6 +5865,7 @@ False False + PRESSURE PERMX PORO @@ -2873,6 +5880,7 @@ 50 90 None + False @@ -2883,6 +5891,21 @@ BRUGGE_0000 8 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2898,11 +5921,33 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real0/BRUGGE_0000.EGRID + + + All Wells + + + BRUGGE_0010 9 + + + + + 0 + 0 + TS_ALL + 1 + + + + + + + @@ -2918,7 +5963,10 @@ False False + C:/gitRoot/OPM/ResInsight/TestModels/Case_with_10_timesteps/Real10/BRUGGE_0010.EGRID + + @@ -2927,10 +5975,12 @@ + + True True - 0.870588 0.870588 0.870588 + 0.870588004589081 0.870588004589081 0.870588004589081 ALL_ON 0.1 True @@ -2938,6 +5988,33 @@ + + + UNITS_METRIC + + 0 + + + + + + + + + + + + + C:\gitRoot\OPM\ResInsight\TestModels\20Layers.lyr + + + + + + + + + @@ -2961,16 +6038,52 @@ C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\LGRSOIL.m - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\OctaveInterfaceTest.m + C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SatNum.m - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\ResInsightIterfaceUnitTest.m + C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SoilTimeDiff.m + + + + + C:\gitRoot\OPM\ResInsight-regression-test\OctaveScripts + - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SatNum.m + C:\gitRoot\OPM\ResInsight-regression-test\OctaveScripts\OctaveInterfaceTest.m - C:\gitRoot\OPM\ResInsight\OctavePlugin\OctaveScripts\SoilTimeDiff.m + C:\gitRoot\OPM\ResInsight-regression-test\OctaveScripts\ResInsightInterfaceUnitTest.m + + + + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\AKBedited_virtualCF_2D.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\AKBedited_virtualCF_2D_2WellCells.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\AKBedited_virtualCF_2D_printDetails.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\Calc_InfConductive_Frac_Transm.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\findPathFuncs.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\Sum_WaterInfluxWithTime.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\virtualCF_2D.m + + + V:\ProjectData\StatoilReservoir\Astrid\RIProject\MyOctaveScripts\virtualCF_2D_MatrixReduction.m @@ -2978,7 +6091,6 @@ - -1-100000000;-1-100000040;-1-100000050;-1-1000000;-1-10000;-1-1001000;-1-10010;-1-10020100000;-1-100201000;-1-1002010;-1-10020;-1-100;-1-12000;-1-120 True @@ -2991,6 +6103,129 @@ + + + True + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + 0 + 0 + -1 + -1 + False + + + False + + + SELECTED + + + 0.1 + True + CELLS_ACTIVE + + + + 0 + 146000 + + + + + + + + + + + + True + + + + + + + + + + -1-10000;-1-100;-1-120 0 0;0 0;0 0 + + 0 0 + True + True + + + + + + + + 0 + 1 + 1 + 1 + 1 + 1 + 1 + + + + + 2 + 2 + 2 + 8 + + + + + D:/Tools/DropBox/Dropbox (Ceetron Solutions)/Projects/20059 ResInsight Deeper Reservoir Insight/Meetings/2018.01.18_ProjectMeeting + + UNIFIED_FILE + TRANSMISSIBILITIES + 0 + False + True + True + True + False + INDIVIDUALLY + + + + diff --git a/ThirdParty/Ert/.travis.yml b/ThirdParty/Ert/.travis.yml index 06dc0a0217..5d137e94ad 100644 --- a/ThirdParty/Ert/.travis.yml +++ b/ThirdParty/Ert/.travis.yml @@ -15,6 +15,7 @@ dist: trusty env: global: - ERT_SHOW_BACKTRACE=1 + - LD_LIBRARY_PATH="$(pwd)/install/lib64" matrix: - PYTHON_VERSION=2.7 TEST_SUITE="-LE SLOW" # Run all tests not labeled as slow - PYTHON_VERSION=2.7 TEST_SUITE="-L SLOW_1" # Run all tests labeled as SLOW in group 1 @@ -23,8 +24,6 @@ env: matrix: fast_finish: true - allow_failures: - - env: PYTHON_VERSION=3.6 exclude: - os: osx compiler: gcc @@ -65,10 +64,12 @@ install: - export CONDA_HOME="$HOME/miniconda" - export PATH="$CONDA_HOME/bin:$PATH" - hash -r + - pip install -r requirements.txt - conda config --set always_yes yes --set changeps1 no - conda update -q conda - conda info -a # Useful for debugging any issues with conda - - conda install pylint numpy pandas + - wget https://raw.githubusercontent.com/Statoil/ert/master/travis/install_python_packages.py + - python install_python_packages.py before_script: - wget https://raw.githubusercontent.com/Statoil/ert/master/travis/build_total.py diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt index 73fb3b30db..bddc356a17 100644 --- a/ThirdParty/Ert/CMakeLists.txt +++ b/ThirdParty/Ert/CMakeLists.txt @@ -45,8 +45,8 @@ endif() option( BUILD_TESTS "Should the tests be built" OFF) option( BUILD_APPLICATIONS "Should we build small utility applications" OFF) option( BUILD_ECL_SUMMARY "Build the commandline application ecl_summary" OFF) -option( BUILD_NEXUS "Build support for the Nexus simulator" ON) option( BUILD_PYTHON "Run py_compile on the python wrappers" OFF) +option( ENABLE_PYTHON "Build and install the Python wrappers" OFF) option( BUILD_SHARED_LIBS "Build shared libraries" ON ) option( ERT_USE_OPENMP "Use OpenMP" OFF ) option( RST_DOC "Build RST documentation" OFF) @@ -54,7 +54,6 @@ option( ERT_BUILD_CXX "Build some CXX wrappers" option( USE_RPATH "Don't strip RPATH from libraries and binaries" OFF) option( INSTALL_ERT_LEGACY "Add ert legacy wrappers" OFF) - set(STATOIL_TESTDATA_ROOT "" CACHE PATH "Root to Statoil internal testdata") if (EXISTS ${STATOIL_TESTDATA_ROOT}) set( LINK "${CMAKE_CURRENT_SOURCE_DIR}/test-data/Statoil" ) @@ -71,6 +70,11 @@ if (EXISTS ${STATOIL_TESTDATA_ROOT}) endif() +if (BUILD_PYTHON) + set(ENABLE_PYTHON ON) + message(WARNING "The option 'BUILD_PYTHON' is deprecated - use ENABLE_PYTHON.") +endif() + # output libs to some lib/ path for testing set(LIBRARY_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR}) set(EXECUTABLE_OUTPUT_PATH ${CMAKE_CURRENT_BINARY_DIR}/bin) @@ -176,18 +180,6 @@ if(M_LIBRARY) set(m m) endif () -find_package(BLAS) -if (BLAS_FOUND) - set(blas "${BLAS_LIBRARIES}") -endif () - -set(ERT_HAVE_LAPACK OFF) -find_package(LAPACK) -if (LAPACK_FOUND) - set(ERT_HAVE_LAPACK ON) - list(APPEND lapack ${LAPACK_LIBRARIES} ${LAPACK_LINKER_FLAGS}) -endif() - find_package(ZLIB) if (ZLIB_FOUND) set(ERT_HAVE_ZLIB ON) @@ -199,6 +191,11 @@ if (SHLWAPI_LIBRARY) set(shlwapi ${SHLWAPI_LIBRARY}) endif () +find_library(WS2_32_LIBRARY NAMES Ws2_32) +if (WS2_32_LIBRARY) + set(ws2_32 ${WS2_32_LIBRARY}) +endif () + #----------------------------------------------------------------- # feature tests @@ -207,6 +204,8 @@ include(CheckIncludeFile) include(CheckSymbolExists) include(CheckTypeSize) +check_function_exists( access HAVE_POSIX_ACCESS) +check_function_exists( _access HAVE_WINDOWS__ACCESS) check_function_exists( chdir HAVE_POSIX_CHDIR ) check_function_exists( _chdir HAVE_WINDOWS_CHDIR ) check_function_exists( chmod HAVE_CHMOD ) @@ -235,7 +234,6 @@ check_function_exists( readlinkat ERT_HAVE_READLINKAT ) check_function_exists( realpath HAVE_REALPATH ) check_function_exists( regexec ERT_HAVE_REGEXP ) check_function_exists( round HAVE_ROUND ) -check_function_exists( setenv HAVE_POSIX_SETENV ) check_function_exists( symlink ERT_HAVE_SYMLINK ) check_function_exists( timegm HAVE_TIMEGM ) check_function_exists( usleep HAVE__USLEEP ) @@ -270,6 +268,13 @@ try_compile( HAVE_PID_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/ try_compile( HAVE_MODE_T ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mode_t.c ) try_compile( ERT_HAVE_ISFINITE ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c) +if (ERT_HAVE_READLINKAT) + try_compile( ERT_HAVE_READLINKAT_DECLARATION + ${CMAKE_BINARY_DIR} + ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_readlinkat_decl.c + ) +endif() + set( BUILD_CXX ON ) try_compile( HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp ) if (NOT HAVE_CXX_SHARED_PTR) @@ -287,10 +292,6 @@ if (ERT_WINDOWS) endif() endif() -find_program(PING_PATH NAMES ping) -if (PING_PATH) - set(ERT_HAVE_PING ON) -endif() find_package(Git) if(GIT_FOUND) @@ -330,7 +331,7 @@ endif() if (ERT_WINDOWS) message(WARNING "Python is not supported on Windows") - set( BUILD_PYTHON OFF ) + set( ENABLE_PYTHON OFF ) endif () if (ERT_LINUX) @@ -339,15 +340,15 @@ endif() add_subdirectory( lib ) add_subdirectory( applications ) +add_subdirectory( bin ) - -if (BUILD_PYTHON) +if (ENABLE_PYTHON) if (ERT_WINDOWS) message(WARNING "Python is not supported on Windows") - set( BUILD_PYTHON OFF ) + set( ENABLE_PYTHON OFF ) else() # If finding the Python interpreter and required packages - # fails in the python/CMakeLists.txt file the BUILD_PYTHON + # fails in the python/CMakeLists.txt file the ENABLE_PYTHON # will be set to OFF. add_subdirectory( python ) @@ -357,7 +358,7 @@ if (BUILD_PYTHON) endif() endif() -if (BUILD_PYTHON) +if (ENABLE_PYTHON) if (NOT ${BUILD_SHARED_LIBS}) message(FATAL_ERROR "The Python wrappers require shared libraries") endif() diff --git a/ThirdParty/Ert/applications/CMakeLists.txt b/ThirdParty/Ert/applications/CMakeLists.txt index 318197a204..d2a2ed6e8c 100644 --- a/ThirdParty/Ert/applications/CMakeLists.txt +++ b/ThirdParty/Ert/applications/CMakeLists.txt @@ -10,6 +10,7 @@ if (BUILD_APPLICATIONS) target_link_libraries(grdecl_grid ecl) target_link_libraries(summary ecl) + list(APPEND apps make_grid grdecl_grid summary) foreach (app ecl_pack @@ -32,7 +33,7 @@ if (BUILD_APPLICATIONS) if (ERT_LINUX) - foreach (app convert esummary grdecl_test kw_list) + foreach (app convert grdecl_test kw_list) add_executable(${app} ecl/${app}.c) target_link_libraries(${app} ecl) # The stupid .x extension creates problems on windows diff --git a/ThirdParty/Ert/applications/ecl/ecl_pack.c b/ThirdParty/Ert/applications/ecl/ecl_pack.c index 34ae853cda..ad6822c0ad 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_pack.c +++ b/ThirdParty/Ert/applications/ecl/ecl_pack.c @@ -1,30 +1,29 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_pack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include #include #include -#include #include #include -#include +#include #include @@ -50,7 +49,7 @@ int main(int argc, char ** argv) { } util_alloc_file_components( argv[1] , &path , &ecl_base , NULL); - + /** Will pack to cwd, even though the source files might be somewhere else. To unpack to the same directory as the source @@ -59,7 +58,6 @@ int main(int argc, char ** argv) { */ { - msg_type * msg; int i , report_step , prev_report_step; char * target_file_name = ecl_util_alloc_filename( NULL , ecl_base , target_type , fmt_file , -1); stringlist_type * filelist = stringlist_alloc_argv_copy( (const char **) &argv[1] , num_files ); @@ -69,16 +67,8 @@ int main(int argc, char ** argv) { if (target_type == ECL_UNIFIED_RESTART_FILE) { int dummy; seqnum_kw = ecl_kw_alloc_new("SEQNUM" , 1 , ECL_INT , &dummy); - } - - { - char * msg_format = util_alloc_sprintf("Packing %s <= " , target_file_name); - msg = msg_alloc( msg_format , false); - free( msg_format ); } - - msg_show( msg ); stringlist_sort( filelist , ecl_util_fname_report_cmp); prev_report_step = -1; for (i=0; i < num_files; i++) { @@ -87,11 +77,10 @@ int main(int argc, char ** argv) { if (this_file_type == file_type) { if (report_step == prev_report_step) util_exit("Tried to write same report step twice: %s / %s \n", - stringlist_iget(filelist , i-1) , + stringlist_iget(filelist , i-1) , stringlist_iget(filelist , i)); prev_report_step = report_step; - msg_update(msg , stringlist_iget( filelist , i)); { ecl_file_type * src_file = ecl_file_open( stringlist_iget( filelist , i) , 0 ); if (target_type == ECL_UNIFIED_RESTART_FILE) { @@ -104,7 +93,6 @@ int main(int argc, char ** argv) { } } /* Else skipping file of incorrect type. */ } - msg_free(msg , false); fortio_fclose( target ); free(target_file_name); stringlist_free( filelist ); @@ -114,4 +102,4 @@ int main(int argc, char ** argv) { util_safe_free(path); } } - + diff --git a/ThirdParty/Ert/applications/ecl/ecl_unpack.c b/ThirdParty/Ert/applications/ecl/ecl_unpack.c index 71c6f3492d..58f9cde244 100644 --- a/ThirdParty/Ert/applications/ecl/ecl_unpack.c +++ b/ThirdParty/Ert/applications/ecl/ecl_unpack.c @@ -1,25 +1,24 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'ecl_unpack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include #include -#include #include #include @@ -36,9 +35,9 @@ void unpack_file(const char * filename) { target_type = ECL_SUMMARY_FILE; else if (file_type == ECL_UNIFIED_RESTART_FILE) target_type = ECL_RESTART_FILE; - else + else util_exit("Can only unpack unified ECLIPSE summary and restart files\n"); - + if (target_type == ECL_SUMMARY_FILE) { printf("** Warning: when unpacking unified summary files it as ambigous - starting with 0001 -> \n"); } @@ -48,23 +47,16 @@ void unpack_file(const char * filename) { int offset; int report_step = 0; int block_index = 0; - char * path; + char * path; char * base; - msg_type * msg; util_alloc_file_components( filename , &path , &base , NULL); - { - char * label = util_alloc_sprintf("Unpacking %s => ", filename); - msg = msg_alloc( label , false); - free( label ); - } - msg_show(msg); - if (target_type == ECL_SUMMARY_FILE) + if (target_type == ECL_SUMMARY_FILE) size = ecl_file_get_num_named_kw( src_file , "SEQHDR" ); else size = ecl_file_get_num_named_kw( src_file , "SEQNUM" ); - - + + while (true) { ecl_file_view_type * active_view; @@ -89,22 +81,20 @@ void unpack_file(const char * filename) { files, just send in @path as first argument when creating the target_file. */ - + { char * target_file = ecl_util_alloc_filename( NULL , base , target_type , fmt_file , report_step); fortio_type * fortio_target = fortio_open_writer( target_file , fmt_file , ECL_ENDIAN_FLIP ); - msg_update(msg , target_file); ecl_file_view_fwrite( active_view , fortio_target , offset); - + fortio_fclose(fortio_target); free(target_file); } block_index++; - } + } ecl_file_close( src_file ); util_safe_free(path); free(base); - msg_free(msg , true); } } diff --git a/ThirdParty/Ert/applications/ecl/esummary.c b/ThirdParty/Ert/applications/ecl/esummary.c deleted file mode 100644 index b7a7b4c75f..0000000000 --- a/ThirdParty/Ert/applications/ecl/esummary.c +++ /dev/null @@ -1,198 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'esummary.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include - -#include -#include -#include - -#include -#include - - -void install_SIGNALS(void) { - signal(SIGSEGV , util_abort_signal); /* Segmentation violation, i.e. overwriting memory ... */ - signal(SIGINT , util_abort_signal); /* Control C */ - signal(SIGTERM , util_abort_signal); /* If killing the enkf program with SIGTERM (the default kill signal) you will get a backtrace. Killing with SIGKILL (-9) will not give a backtrace.*/ -} - -void usage() { - fprintf(stderr," The esummary.x program can be used to extract summary vectors from \n"); - fprintf(stderr," an ensemble of summary files: \n\n"); - fprintf(stderr," bash%% esummary.x ECLIPSE1.DATA ECLIPSE2.DATA KEY1 KEY2 ... \n\n"); - exit(1); -} - - -#define MISSING_STRING " 0.000" - - - -int main(int argc , char ** argv) { - install_SIGNALS(); - { - if (argc < 3) usage(); - - { - ecl_sum_type * first_ecl_sum = NULL; /* This governs the timing */ - vector_type * ecl_sum_list = vector_alloc_new(); - time_interval_type * time_union = NULL; - time_interval_type * time_intersect = NULL; - time_interval_type * time = NULL; - bool use_time_union = true; - - int load_count = 0; - int nvars; - char ** var_list; - bool * has_var; - - /** Loading the data */ - { - int iarg = 1; - /* Some sorting here??? */ - while (iarg < argc && util_file_exists( argv[iarg] )) { - char * path , * basename; - ecl_sum_type * ecl_sum; - util_alloc_file_components( argv[iarg] , &path , &basename , NULL); - fprintf(stderr,"Loading case: %s/%s" , path , basename); fflush(stderr); - ecl_sum = ecl_sum_fread_alloc_case( argv[iarg] , ":"); - if (ecl_sum) { - if (first_ecl_sum == NULL) { - first_ecl_sum = ecl_sum; /* Keep track of this - might sort the vector */ - time_union = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum )); - time_intersect = time_interval_alloc_copy( ecl_sum_get_sim_time( ecl_sum )); - - if (use_time_union) - time = time_union; - else - time = time_intersect; - - vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); - load_count++; - } else { - const time_interval_type * ti = ecl_sum_get_sim_time( ecl_sum ); - if (time_interval_has_overlap(time , ti)) { - time_interval_intersect( time_intersect , ti ); - time_interval_extend( time_union , ti ); - - vector_append_owned_ref( ecl_sum_list , ecl_sum , ecl_sum_free__ ); - load_count++; - } else { - fprintf(stderr,"** Warning case:%s has no time overlap - discarded \n",ecl_sum_get_case( ecl_sum )); - ecl_sum_free( ecl_sum ); - } - } - } else - fprintf(stderr," --- no data found?!"); - - iarg++; - fprintf(stderr,"\n"); - util_safe_free( path ); - free( basename ); - } - } - if (load_count == 0) - usage(); - - nvars = argc - load_count - 1; - if (nvars == 0) util_exit(" --- No variables \n"); - var_list = &argv[load_count + 1]; - has_var = util_calloc( nvars , sizeof * has_var ); - - /* - Checking that the summary files have the various variables - - if a variable is missing from one of the cases it is - completely discarded. - */ - { - int iens,ivar; - - /* Checking the variables */ - for (ivar = 0; ivar < nvars; ivar++) - has_var[ivar] = true; - - for (iens = 0; iens < vector_get_size( ecl_sum_list ); iens++) { - const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , iens ); - for (ivar = 0; ivar < nvars; ivar++) { - if (has_var[ivar]) { - if (!ecl_sum_has_general_var( ecl_sum , var_list[ivar] )) { - fprintf(stderr,"** Warning: could not find variable: \'%s\' in case:%s - completely discarded.\n", var_list[ivar] , ecl_sum_get_case(ecl_sum)); - has_var[ivar] = false; - } - } - } - } - } - - if (!time_interval_equal(time_union , time_intersect )) { - fprintf(stderr,"** Warning: not all simulations have the same length. "); - if (use_time_union) - fprintf(stderr,"Using %s for missing values.\n" , MISSING_STRING); - else - fprintf(stderr,"Only showing common time period.\n"); - } - - /** The actual summary lookup. */ - { - time_t_vector_type * date_list = time_t_vector_alloc(0,0); - time_t start_time = time_interval_get_start( time ); - FILE * stream = stdout; - int iens,ivar,itime; - - ecl_util_init_month_range( date_list , time_interval_get_start( time ) , time_interval_get_end( time )); - for (itime = 0; itime < time_t_vector_size( date_list ); itime++) { - time_t current_time = time_t_vector_iget( date_list , itime ); - for (ivar = 0; ivar < nvars; ivar++) { /* Iterating over the variables */ - if (has_var[ivar]) { - for (iens = 0; iens < vector_get_size( ecl_sum_list ); iens++) { /* Iterating over the ensemble members */ - const ecl_sum_type * ecl_sum = vector_iget_const( ecl_sum_list , iens ); - - if (ivar == 0 && iens == 0) { /* Display time info in the first columns */ - int day,month,year; - util_set_date_values_utc( current_time , &day , &month, &year); - fprintf(stream , "%7.2f %02d/%02d/%04d " , util_difftime_days( start_time , current_time ) , day , month , year); - } - - { - const time_interval_type * sim_time = ecl_sum_get_sim_time( ecl_sum ); - - if (time_interval_arg_before( sim_time , current_time)) - fprintf(stream , " %s " , MISSING_STRING); // We are before this case has data. - else if (time_interval_arg_after( sim_time , current_time)) - fprintf(stream , " %s " , MISSING_STRING); // We are after this case has data. - else { - double value = ecl_sum_get_general_var_from_sim_time(ecl_sum , current_time , var_list[ivar]); - fprintf(stream , " %12.3f " , value); - } - - } - } - } - } - fprintf(stream , "\n"); - } - time_t_vector_free( date_list ); - } - vector_free( ecl_sum_list ); - free( has_var ); - } - } -} diff --git a/ThirdParty/Ert/applications/ecl/kw_extract.c b/ThirdParty/Ert/applications/ecl/kw_extract.c index a578b5abfa..165ad67f7d 100644 --- a/ThirdParty/Ert/applications/ecl/kw_extract.c +++ b/ThirdParty/Ert/applications/ecl/kw_extract.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'kw_extract.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'kw_extract.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include @@ -23,7 +23,6 @@ #include #include #include -#include #include #include @@ -54,10 +53,10 @@ int main(int argc, char ** argv) { fortio_type * fortio_target; bool fmt_src , fmt_target; set_type * kw_set = set_alloc( num_kw , kw_list ); - + if (!ecl_util_fmt_file(src_file, &fmt_src)) util_exit("Hmm - could not determine formatted/unformatted status for:%s \n",src_file); - + fmt_target = fmt_src; /* Can in principle be different */ fortio_src = fortio_open_reader(src_file , fmt_src , ECL_ENDIAN_FLIP); fortio_target = fortio_open_writer(target_file , fmt_target , ECL_ENDIAN_FLIP); @@ -66,18 +65,18 @@ int main(int argc, char ** argv) { ecl_kw_type * ecl_kw = ecl_kw_alloc_empty(); while (true) { if (ecl_kw_fread_header( ecl_kw , fortio_src ) == ECL_KW_READ_OK) { - const char * header = ecl_kw_get_header( ecl_kw ); + const char * header = ecl_kw_get_header( ecl_kw ); if (set_has_key( kw_set , header )) { ecl_kw_fread_realloc_data(ecl_kw , fortio_src ); ecl_kw_fwrite( ecl_kw , fortio_target ); } else ecl_kw_fskip_data( ecl_kw , fortio_src ); - } else + } else break; /* We have reached EOF */ } ecl_kw_free( ecl_kw ); } - + fortio_fclose(fortio_src); fortio_fclose(fortio_target); set_free( kw_set ); diff --git a/ThirdParty/Ert/appveyor.yml b/ThirdParty/Ert/appveyor.yml index 574be1fff7..78604583b0 100644 --- a/ThirdParty/Ert/appveyor.yml +++ b/ThirdParty/Ert/appveyor.yml @@ -6,7 +6,7 @@ build_script: cd build - cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DERT_BUILD_CXX=OFF -DBUILD_PYTHON=OFF -DBUILD_APPLICATIONS=ON + cmake .. -G"Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DERT_BUILD_CXX=OFF -DENABLE_PYTHON=OFF -DBUILD_APPLICATIONS=ON msbuild /m /p:Configuration=Release /p:Platform="x64" ERT.sln diff --git a/ThirdParty/Ert/bin/CMakeLists.txt b/ThirdParty/Ert/bin/CMakeLists.txt new file mode 100644 index 0000000000..528b7fd216 --- /dev/null +++ b/ThirdParty/Ert/bin/CMakeLists.txt @@ -0,0 +1,3 @@ +if (ENABLE_PYTHON) + install(PROGRAMS summary_resample DESTINATION ${CMAKE_INSTALL_PREFIX}/bin) +endif() diff --git a/ThirdParty/Ert/bin/summary_resample b/ThirdParty/Ert/bin/summary_resample new file mode 100644 index 0000000000..eb6cf5521f --- /dev/null +++ b/ThirdParty/Ert/bin/summary_resample @@ -0,0 +1,27 @@ +#!/usr/bin/env python +import sys +import argparse +from ecl.summary import EclSum +from ecl.util.util import TimeVector, CTime + + + +parser = argparse.ArgumentParser() +parser.add_argument("input_case", metavar="input_case", type=str) +parser.add_argument("output_case", metavar="output_case", type=str) +parser.add_argument("--num-timestep", type=int, default=50) +parser.add_argument("--refcase", metavar="refcase", type=str) +args = parser.parse_args() + +input_case = EclSum(args.input_case) +if args.refcase: + refcase = EclSum(args.refcase) + report_only = False + time_points = refcase.alloc_time_vector( report_only ) +else: + start_time = input_case.get_data_start_time() + end_time = input_case.get_end_time() + time_points = TimeVector.create_linear(CTime(start_time), CTime(end_time), args.num_timestep) + +output_case = input_case.resample(args.output_case, time_points) +output_case.fwrite( ) diff --git a/ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c b/ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c new file mode 100644 index 0000000000..3d77e99904 --- /dev/null +++ b/ThirdParty/Ert/cmake/Tests/test_have_readlinkat_decl.c @@ -0,0 +1,17 @@ +#include +#include + +#include + +#define NCHAR 63 + +int main(int argc, char *argv[]) +{ + char linkname[NCHAR + 1] = { 0 }; + ssize_t r; + + r = (argc < 2) ? -1 + : readlinkat(1, argv[1], linkname, NCHAR); + + return (r > 0) ? EXIT_SUCCESS : EXIT_FAILURE; +} diff --git a/ThirdParty/Ert/cmake/libecl-config-version.cmake.in b/ThirdParty/Ert/cmake/libecl-config-version.cmake.in index 3a8e633c45..2f8df5a4e8 100644 --- a/ThirdParty/Ert/cmake/libecl-config-version.cmake.in +++ b/ThirdParty/Ert/cmake/libecl-config-version.cmake.in @@ -9,6 +9,6 @@ link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ ) include_directories( @CMAKE_INSTALL_PREFIX@/include ) set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE_PATH}) -if (@BUILD_PYTHON@) +if (@ENABLE_PYTHON@) set(libecl_PYTHONPATH @CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@ ) -endif() \ No newline at end of file +endif() diff --git a/ThirdParty/Ert/cmake/libecl-config.cmake.in b/ThirdParty/Ert/cmake/libecl-config.cmake.in index 318a35c20b..bf718e2e23 100644 --- a/ThirdParty/Ert/cmake/libecl-config.cmake.in +++ b/ThirdParty/Ert/cmake/libecl-config.cmake.in @@ -5,6 +5,6 @@ set( CMAKE_MODULE_PATH @CMAKE_INSTALL_PREFIX@/share/cmake/Modules ${CMAKE_MODULE link_directories( @CMAKE_INSTALL_PREFIX@/@CMAKE_INSTALL_LIBDIR@ ) include_directories( @CMAKE_INSTALL_PREFIX@/include ) -if (@BUILD_PYTHON@) +if (@ENABLE_PYTHON@) set(libecl_PYTHONPATH @CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@ ) -endif() \ No newline at end of file +endif() diff --git a/ThirdParty/Ert/debian/control b/ThirdParty/Ert/debian/control index e91d5b83d0..f1cee7a739 100644 --- a/ThirdParty/Ert/debian/control +++ b/ThirdParty/Ert/debian/control @@ -2,7 +2,7 @@ Source: ecl Priority: extra Maintainer: Arne Morten Kvarving Build-Depends: debhelper (>= 8.0.0), cmake, liblapack-dev, libquadmath0, - iputils-ping, zlib1g-dev, git, python-dev, python-numpy + iputils-ping, zlib1g-dev, git, python-dev, python-numpy, python-cwrap Standards-Version: 3.9.2 Section: libs Homepage: http://ert.nr.no @@ -26,6 +26,6 @@ Description: libecl Eclipse IO library Package: python-ecl Section: python Architecture: any -Depends: ${shlibs:Depends}, ${misc:Depends}, libert.ecl1, python-cwrap +Depends: ${shlibs:Depends}, ${misc:Depends}, libecl1, python-cwrap Description: libecl Eclipse IO library - Python bindings libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. diff --git a/ThirdParty/Ert/debian/python-cwrap.install b/ThirdParty/Ert/debian/python-cwrap.install new file mode 100644 index 0000000000..4712e62110 --- /dev/null +++ b/ThirdParty/Ert/debian/python-cwrap.install @@ -0,0 +1 @@ +usr/lib/python2.7/*/cwrap/* diff --git a/ThirdParty/Ert/debian/rules b/ThirdParty/Ert/debian/rules index 7e2e104ef3..a2fd90c353 100644 --- a/ThirdParty/Ert/debian/rules +++ b/ThirdParty/Ert/debian/rules @@ -13,4 +13,4 @@ dh $@ override_dh_auto_configure: - DESTDIR=$$(pwd)/debian/tmp dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DBUILD_PYTHON=1 -DCMAKE_BUILD_TYPE=Release + DESTDIR=$$(pwd)/debian/tmp dh_auto_configure -- -DBUILD_SHARED_LIBS=1 -DBUILD_ECL_SUMMARY=1 -DENABLE_PYTHON=1 -DCMAKE_BUILD_TYPE=Release diff --git a/ThirdParty/Ert/docs/CMakeLists.txt b/ThirdParty/Ert/docs/CMakeLists.txt index 117c4af359..833ce3a56e 100644 --- a/ThirdParty/Ert/docs/CMakeLists.txt +++ b/ThirdParty/Ert/docs/CMakeLists.txt @@ -17,7 +17,7 @@ if (SPHINX_FOUND) configure_file(index.rst.in ${PROJECT_BINARY_DIR}/doc-src/index.rst) configure_file(conf.py.in ${PROJECT_BINARY_DIR}/doc-src/conf.py) - if (BUILD_PYTHON) + if (ENABLE_PYTHON) add_custom_target(api-doc ALL COMMAND ${CMAKE_COMMAND} -E create_symlink "${CMAKE_CURRENT_SOURCE_DIR}/code" "${PROJECT_BINARY_DIR}/doc-src/code" COMMAND sphinx-apidoc -e -o doc-src/API/python/ecl ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX} diff --git a/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst b/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst index 2d6b93d97b..90946c557e 100644 --- a/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst +++ b/ThirdParty/Ert/docs/code/python/packages/eclipse/index.rst @@ -851,9 +851,9 @@ ministep sequence, but there will never be holes in this range. It is closely coupled to the simulator timestep and what the user of ECLIPSE has chosen to store, so no further meaning should be attached to these indices. Ultimately all lookups will be based on :code:`time_index`; in the C -code it is therefor often denoted :code:`internal_index`. +code it is therefore often denoted :code:`internal_index`. -ministep +ministep ,,,,,,,,, Each simulator timestep corresponds to one ministep, but an arbitrary diff --git a/ThirdParty/Ert/docs/nexus.plt b/ThirdParty/Ert/docs/nexus.plt index ec183b8dd8..88b482631b 100644 --- a/ThirdParty/Ert/docs/nexus.plt +++ b/ThirdParty/Ert/docs/nexus.plt @@ -20,14 +20,13 @@ for c in classes: for v in vars[c]: 4*b : The variable names 8*b : Skipped -4*b : Skipped ----> : This is the position of first timestep while classname != STOP: 8*b : classname 8*b : skipped - f : timestep (will cast to int) + f : timestep (cast to int) f : time f : num_items (cast to int) f : max_items (cast to int) @@ -49,3 +48,4 @@ while classname != STOP: 8*b : skipped 72*b : skipped var_in_class*f : The real data + 8*b : skipped diff --git a/ThirdParty/Ert/docs/tips.txt b/ThirdParty/Ert/docs/tips.txt index 6ed9b68ab7..d6bf3c18dc 100644 --- a/ThirdParty/Ert/docs/tips.txt +++ b/ThirdParty/Ert/docs/tips.txt @@ -94,7 +94,7 @@ it. In the configuration file both GEN_DATA and GEN_PARAM can be used: GEN_PARAM: For parameters which are not changed by the forward model, i.e. like porosity and permeability. - GEN_DATA: Data which is changed by the forward model, and therefor + GEN_DATA: Data which is changed by the forward model, and therefore must be loaded at the end of each timestep. The arch-typical example of a GEN_DATA instance would be seismic data. @@ -436,14 +436,14 @@ The block_fs driver is based on creating block_fs instances (block_fs_type is implemented in libutil/src/block_fs.c). The block_fs instances are binary files which are open through the duration of the program, the block_fs system then has an api for reading and writing -(key,value) pairs to this file. +(key,value) pairs to this file. The block_fs_driver/block_fs combination is quite complex, but it has not had any hickups for about 1.5 years of extensive use in Statoil. Observe that if you pull the plug on ERT you might loose some of the data which has been stored with the block_fs driver, but partly written and malformed data will be detected and discarded at the next -boot. You are therefor guaranteed (add as many quotes you like to the +boot. You are therefore guaranteed (add as many quotes you like to the guarantee - but this has at least worked 100% up until now) that no bogus data will be loaded after an unclean shutdown. When shut down cleanly the block_fs will create an index file which can be used for @@ -551,7 +551,7 @@ SConstruct files: Unfortunately it has been a major pain in the ass to get SCons to behave according to the requirements listed above; for the more -extensive installation procedures there are therefor simple Python +extensive installation procedures there are therefore simple Python scripts "install.py" which should be invoked after the SCons build is complete. diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt index 2b91ee17fc..6b6ef43667 100644 --- a/ThirdParty/Ert/lib/CMakeLists.txt +++ b/ThirdParty/Ert/lib/CMakeLists.txt @@ -1,20 +1,6 @@ project(libecl-ecl C CXX) -if (HAVE_PTHREAD) - # The block_fs filesystem is so heavily dependant on pthreads that it is - # not built if de not have pthreads. - list(APPEND opt_srcs util/thread_pool.c) -endif () -if (LAPACK_FOUND) - list(APPEND opt_srcs util/matrix_lapack.c - util/matrix_blas.c - util/matrix_stat.c - util/regression.c - util/lars.c - util/stepwise.c -) -endif () if (HAVE_BACKTRACE) list(APPEND opt_srcs util/util_abort_gnu.c) @@ -23,23 +9,23 @@ else() endif() if (ERT_HAVE_GETUID AND ERT_HAVE_OPENDIR) - list(APPEND opt_srcs util/test_work_area.c util/util_getuid.c) + list(APPEND opt_srcs util/test_work_area.cpp util/util_getuid.cpp) endif() if (ERT_HAVE_OPENDIR) - list(APPEND opt_srcs util/util_opendir.c) + list(APPEND opt_srcs util/util_opendir.cpp) endif() if (ERT_HAVE_SPAWN) - list(APPEND opt_srcs util/util_spawn.c) + list(APPEND opt_srcs util/util_spawn.cpp) endif() if (ERT_HAVE_LOCKF) - list(APPEND opt_srcs util/util_lockf.c) + list(APPEND opt_srcs util/util_lockf.cpp) endif () if (ERT_HAVE_UNISTD) - list(APPEND opt_srcs util/path_stack.c) + list(APPEND opt_srcs util/path_stack.cpp) endif () if (MSVC) @@ -50,20 +36,22 @@ foreach (type int double long time_t float) set(TYPE ${type}) set(SIGNED_TYPE true) configure_file(vector_template.h.in include/ert/util/${type}_vector.h) - configure_file(util/vector_template.c ${type}_vector.c) - list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.c) + configure_file(vector_template.hpp.in include/ert/util/${type}_vector.hpp) + configure_file(util/vector_template.cpp ${type}_vector.cpp) + list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.cpp) endforeach () foreach (type bool size_t) set(TYPE ${type}) set(SIGNED_TYPE false) configure_file(vector_template.h.in include/ert/util/${type}_vector.h) - configure_file(util/vector_template.c ${type}_vector.c) - list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.c) + configure_file(vector_template.hpp.in include/ert/util/${type}_vector.hpp) + configure_file(util/vector_template.cpp ${type}_vector.cpp) + list(APPEND opt_srcs ${CMAKE_CURRENT_BINARY_DIR}/${type}_vector.cpp) endforeach () if (ZLIB_FOUND) - list(APPEND opt_srcs util/util_zlib.c) + list(APPEND opt_srcs util/util_zlib.cpp) endif () if (ERT_BUILD_CXX) @@ -71,120 +59,108 @@ if (ERT_BUILD_CXX) ecl/FortIO.cpp ecl/Smspec.cpp ecl/EclFilename.cpp - nexus/nexus_plot.cpp ) endif () -if (BUILD_NEXUS) - list(APPEND opt_srcs nexus/nexus_plot.cpp) -endif () - configure_file(build_config.h.in include/ert/util/build_config.h) configure_file(ert_api_config.h.in include/ert/util/ert_api_config.h) - -add_library(ecl util/rng.c - util/lookup_table.c - util/statistics.c - util/mzran.c - util/set.c - util/hash_node.c - util/hash_sll.c - util/hash.c - util/node_data.c - util/node_ctype.c +configure_file(build_config.hpp.in include/ert/util/build_config.hpp) +configure_file(ert_api_config.hpp.in include/ert/util/ert_api_config.hpp) + +add_library(ecl util/rng.cpp + util/lookup_table.cpp + util/statistics.cpp + util/mzran.cpp + util/set.cpp + util/hash_node.cpp + util/hash_sll.cpp + util/hash.cpp + util/node_data.cpp + util/node_ctype.cpp util/util.c - util/util_env.c - util/util_symlink.c + util/util_symlink.cpp util/util_lfs.c - util/util_unlink.c - util/msg.c - util/arg_pack.c - util/path_fmt.c - util/menu.c - util/subst_func.c - util/vector.c - util/parser.c - util/stringlist.c - util/matrix.c - util/buffer.c - util/log.c - util/timer.c - util/time_interval.c - util/string_util.c - util/type_vector_functions.c - util/ui_return.c - util/ecl_version.c - util/struct_vector.c - util/perm_vector.c - util/test_util.c + util/util_unlink.cpp + util/arg_pack.cpp + util/vector.cpp + util/parser.cpp + util/stringlist.cpp + util/buffer.cpp + util/timer.cpp + util/string_util.cpp + util/type_vector_functions.cpp + util/ecl_version.cpp + util/struct_vector.cpp + util/perm_vector.cpp + util/test_util.cpp ${opt_srcs} - ecl/ecl_rsthead.c - ecl/ecl_sum_tstep.c - ecl/ecl_rst_file.c - ecl/ecl_init_file.c - ecl/ecl_grid_cache.c - ecl/smspec_node.c - ecl/ecl_kw_grdecl.c - ecl/ecl_file_kw.c - ecl/ecl_file_view.c - ecl/ecl_grav.c - ecl/ecl_grav_calc.c - ecl/ecl_smspec.c - ecl/ecl_sum_data.c - ecl/ecl_util.c - ecl/ecl_kw.c - ecl/ecl_sum.c - ecl/ecl_sum_vector.c + ecl/ecl_rsthead.cpp + ecl/ecl_sum_tstep.cpp + ecl/ecl_rst_file.cpp + ecl/ecl_init_file.cpp + ecl/ecl_grid_cache.cpp + ecl/smspec_node.cpp + ecl/ecl_kw_grdecl.cpp + ecl/ecl_file_kw.cpp + ecl/ecl_file_view.cpp + ecl/ecl_grav.cpp + ecl/ecl_grav_calc.cpp + ecl/ecl_smspec.cpp + ecl/ecl_sum_data.cpp + ecl/ecl_util.cpp + ecl/ecl_kw.cpp + ecl/ecl_sum.cpp + ecl/ecl_sum_vector.cpp ecl/fortio.c - ecl/ecl_rft_file.c - ecl/ecl_rft_node.c - ecl/ecl_rft_cell.c - ecl/ecl_grid.c - ecl/ecl_coarse_cell.c - ecl/ecl_box.c - ecl/ecl_io_config.c - ecl/ecl_file.c - ecl/ecl_region.c - ecl/ecl_subsidence.c - ecl/ecl_grid_dims.c - ecl/grid_dims.c - ecl/nnc_info.c - ecl/ecl_grav_common.c - ecl/nnc_vector.c - ecl/ecl_nnc_export.c - ecl/ecl_nnc_data.c - ecl/ecl_nnc_geometry.c - ecl/layer.c - ecl/fault_block.c - ecl/fault_block_layer.c - ecl/ecl_type.c - ecl/ecl_type_python.c - ecl/well_state.c - ecl/well_conn.c - ecl/well_info.c - ecl/well_ts.c - ecl/well_conn_collection.c - ecl/well_segment.c - ecl/well_segment_collection.c - ecl/well_branch_collection.c - ecl/well_rseg_loader.c - - geometry/geo_surface.c - geometry/geo_util.c - geometry/geo_pointset.c - geometry/geo_region.c - geometry/geo_polygon.c - geometry/geo_polygon_collection.c + ecl/ecl_rft_file.cpp + ecl/ecl_rft_node.cpp + ecl/ecl_rft_cell.cpp + ecl/ecl_grid.cpp + ecl/ecl_coarse_cell.cpp + ecl/ecl_box.cpp + ecl/ecl_io_config.cpp + ecl/ecl_file.cpp + ecl/ecl_region.cpp + ecl/ecl_subsidence.cpp + ecl/ecl_grid_dims.cpp + ecl/grid_dims.cpp + ecl/nnc_info.cpp + ecl/ecl_grav_common.cpp + ecl/nnc_vector.cpp + ecl/ecl_nnc_export.cpp + ecl/ecl_nnc_data.cpp + ecl/ecl_nnc_geometry.cpp + ecl/layer.cpp + ecl/fault_block.cpp + ecl/fault_block_layer.cpp + ecl/ecl_type.cpp + ecl/ecl_type_python.cpp + ecl/well_state.cpp + ecl/well_conn.cpp + ecl/well_info.cpp + ecl/well_ts.cpp + ecl/well_conn_collection.cpp + ecl/well_segment.cpp + ecl/well_segment_collection.cpp + ecl/well_branch_collection.cpp + ecl/well_rseg_loader.cpp + + geometry/geo_surface.cpp + geometry/geo_util.cpp + geometry/geo_pointset.cpp + geometry/geo_region.cpp + geometry/geo_polygon.cpp + geometry/geo_polygon_collection.cpp ) target_link_libraries(ecl PUBLIC ${m} ${dl} ${pthread} ${blas} - ${lapack} ${zlib} ${shlwapi} + ${ws2_32} ) target_include_directories(ecl @@ -207,9 +183,6 @@ target_compile_definitions(ecl PRIVATE target_compile_options(ecl PUBLIC ${pthreadarg}) -if (PING_PATH) - target_compile_definitions(ecl PRIVATE -DPING_CMD=${PING_PATH}) -endif() if (ERT_USE_OPENMP) target_compile_options(ecl PUBLIC ${OpenMP_C_FLAGS}) @@ -261,10 +234,7 @@ foreach (name ert_util_alloc_file_components ert_util_chdir ert_util_filename ert_util_hash_test - ert_util_logh - ert_util_matrix ert_util_parent_path - ert_util_PATH_test ert_util_realpath ert_util_relpath_test ert_util_rng @@ -275,11 +245,10 @@ foreach (name ert_util_alloc_file_components ert_util_stringlist_test ert_util_string_util ert_util_strstr_int_format - ert_util_time_interval ert_util_type_vector_functions - ert_util_ui_return ert_util_vector_test ert_util_datetime + ert_util_normal_path ) add_executable(${name} util/tests/${name}.c) @@ -301,15 +270,6 @@ add_test(NAME ert_util_work_area WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/util/tests ) -find_library( VALGRIND NAMES valgr ) -if (VALGRIND) - set(valgrind_cmd valgrind --error-exitcode=1 --tool=memcheck) -endif () - -add_executable(test_thread_pool util/tests/test_thread_pool.c) -target_link_libraries(test_thread_pool ecl) -add_test(NAME test_thread_pool COMMAND ${valgrind_cmd} test_thread_pool) - add_executable(ert_util_cwd_test util/tests/ert_util_cwd_test.c) target_link_libraries(ert_util_cwd_test ecl) add_test(NAME ert_util_cwd_test COMMAND ert_util_cwd_test ${CMAKE_CURRENT_BINARY_DIR}) @@ -329,15 +289,6 @@ target_link_libraries(ert_util_path_stack_test ecl) add_test(NAME ert_util_path_stack_test COMMAND ert_util_path_stack_test ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}) -if (LAPACK_FOUND) - add_executable(ert_util_matrix_lapack util/tests/ert_util_matrix_lapack.c) - target_link_libraries(ert_util_matrix_lapack ecl) - add_test(NAME ert_util_matrix_lapack COMMAND ert_util_matrix_lapack) - - add_executable(ert_util_matrix_stat util/tests/ert_util_matrix_stat.c) - target_link_libraries(ert_util_matrix_stat ecl) - add_test(NAME ert_util_matrix_stat COMMAND ert_util_matrix_stat) -endif() if (HAVE_BACKTRACE) add_executable(ert_util_abort_gnu_tests util/tests/ert_util_abort_gnu_tests.c) @@ -372,6 +323,7 @@ endif() foreach (name ecl_alloc_cpgrid ecl_alloc_grid_dxv_dyv_dzv ecl_fault_block_layer + ecl_util_path_access ecl_grid_add_nnc ecl_grid_copy ecl_grid_create @@ -389,11 +341,13 @@ foreach (name ecl_alloc_cpgrid ecl_nnc_info_test ecl_nnc_vector ecl_rft_cell + ecl_sum_alloc_resampled_test ecl_file_view test_ecl_file_index test_transactions ecl_rst_file ecl_sum_writer + ecl_util_filenames ecl_util_make_date_no_shift ecl_util_month_range ecl_valid_basename @@ -467,14 +421,6 @@ if (ERT_BUILD_CXX) endforeach () endif () -if (BUILD_NEXUS) - foreach (name nexus_plot_load nexus2ecl) - add_executable(${name} nexus/tests/${name}.cpp) - target_link_libraries(${name} ecl) - add_test(NAME ${name} COMMAND ${name} ${CMAKE_SOURCE_DIR}) - endforeach () -endif() - if (NOT STATOIL_TESTDATA_ROOT) return () @@ -484,12 +430,6 @@ endif() # ecl # -if (PING_PATH) - add_executable(ert_util_ping util/tests/ert_util_ping.c) - target_link_libraries(ert_util_ping ecl) - add_test(NAME ert_util_ping COMMAND ert_util_ping) -endif () - add_executable(ecl_coarse_test ecl/tests/ecl_coarse_test.c) target_link_libraries(ecl_coarse_test ecl) diff --git a/ThirdParty/Ert/lib/build_config.h.in b/ThirdParty/Ert/lib/build_config.h.in index d468d27d13..2c4c6aa5fb 100644 --- a/ThirdParty/Ert/lib/build_config.h.in +++ b/ThirdParty/Ert/lib/build_config.h.in @@ -24,7 +24,6 @@ #cmakedefine HAVE_WINDOWS_MKDIR #cmakedefine HAVE_GETPWUID #cmakedefine HAVE_FSYNC -#cmakedefine HAVE_POSIX_SETENV #cmakedefine HAVE_CHMOD #cmakedefine HAVE_MODE_T #cmakedefine HAVE_CXX_SHARED_PTR @@ -35,6 +34,8 @@ #cmakedefine HAVE_WINSOCK2_H +#cmakedefine HAVE_POSIX_ACCESS +#cmakedefine HAVE_WINDOWS__ACCESS #cmakedefine HAVE_WINDOWS_GET_TEMP_PATH #cmakedefine HAVE_WINDOWS_TZNAME diff --git a/ThirdParty/Ert/lib/build_config.hpp.in b/ThirdParty/Ert/lib/build_config.hpp.in new file mode 100644 index 0000000000..3c81293d5b --- /dev/null +++ b/ThirdParty/Ert/lib/build_config.hpp.in @@ -0,0 +1 @@ +#include diff --git a/ThirdParty/Ert/lib/ecl/FortIO.cpp b/ThirdParty/Ert/lib/ecl/FortIO.cpp index 7732390422..803640ad6e 100644 --- a/ThirdParty/Ert/lib/ecl/FortIO.cpp +++ b/ThirdParty/Ert/lib/ecl/FortIO.cpp @@ -19,8 +19,7 @@ #include -#include -#include +#include #include diff --git a/ThirdParty/Ert/lib/ecl/Smspec.cpp b/ThirdParty/Ert/lib/ecl/Smspec.cpp index 558c652bf8..ba81341bef 100644 --- a/ThirdParty/Ert/lib/ecl/Smspec.cpp +++ b/ThirdParty/Ert/lib/ecl/Smspec.cpp @@ -1,4 +1,4 @@ -#include +#include #include namespace ERT { diff --git a/ThirdParty/Ert/lib/ecl/ecl_box.c b/ThirdParty/Ert/lib/ecl/ecl_box.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_box.c rename to ThirdParty/Ert/lib/ecl/ecl_box.cpp index 9c5b0350c1..f5fc900fab 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_box.c +++ b/ThirdParty/Ert/lib/ecl/ecl_box.cpp @@ -21,10 +21,10 @@ #include #include -#include +#include -#include -#include +#include +#include #define ECL_BOX_TYPE_ID 6610643 @@ -60,7 +60,7 @@ UTIL_SAFE_CAST_FUNCTION( ecl_box , ECL_BOX_TYPE_ID) */ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 , int __j1 , int __j2 , int __k1, int __k2) { - ecl_box_type * ecl_box = util_malloc(sizeof * ecl_box ); + ecl_box_type * ecl_box = (ecl_box_type *)util_malloc(sizeof * ecl_box ); UTIL_TYPE_ID_INIT( ecl_box , ECL_BOX_TYPE_ID); ecl_box->parent_grid = ecl_grid; /* Properties of the parent grid. */ @@ -102,8 +102,8 @@ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 int global_counter = 0; int i,j,k; ecl_box->active_size = 0; - ecl_box->active_list = util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->active_list ); - ecl_box->global_list = util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->global_list ); + ecl_box->active_list = (int*)util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->active_list ); + ecl_box->global_list = (int*)util_calloc( ecl_box->box_nx * ecl_box->box_ny * ecl_box->box_nz , sizeof * ecl_box->global_list ); for (k=k1; k <= k2; k++) for (j=j1; j <= j2; j++) for (i=i1; i <= i2; i++) { @@ -121,7 +121,7 @@ ecl_box_type * ecl_box_alloc(const ecl_grid_type * ecl_grid , int __i1,int __i2 } } - ecl_box->active_list = util_realloc( ecl_box->active_list , ecl_box->active_size * sizeof * ecl_box->active_list ); + ecl_box->active_list = (int*)util_realloc( ecl_box->active_list , ecl_box->active_size * sizeof * ecl_box->active_list ); } } return ecl_box; diff --git a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c rename to ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp index e279f0c73b..48e688d011 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.c +++ b/ThirdParty/Ert/lib/ecl/ecl_coarse_cell.cpp @@ -17,13 +17,15 @@ */ #include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include /******************************************************************/ /* @@ -138,7 +140,7 @@ void ecl_coarse_cell_assert( ecl_coarse_cell_type * coarse_cell ) { ecl_coarse_cell_type * ecl_coarse_cell_alloc() { const int LARGE = 1 << 30; - ecl_coarse_cell_type * coarse_cell = util_malloc( sizeof * coarse_cell ); + ecl_coarse_cell_type * coarse_cell = (ecl_coarse_cell_type *) util_malloc( sizeof * coarse_cell ); UTIL_TYPE_ID_INIT( coarse_cell , ECL_COARSE_CELL_TYPE_ID ); coarse_cell->ijk[0] = LARGE; diff --git a/ThirdParty/Ert/lib/ecl/ecl_file.c b/ThirdParty/Ert/lib/ecl/ecl_file.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/ecl_file.c rename to ThirdParty/Ert/lib/ecl/ecl_file.cpp index 7c9d3f652c..510c87f2cf 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_file.cpp @@ -22,21 +22,21 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include /** This file implements functionality to load an ECLIPSE file in @@ -178,7 +178,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file , ECL_FILE_ID) ecl_file_type * ecl_file_alloc_empty( int flags ) { - ecl_file_type * ecl_file = util_malloc( sizeof * ecl_file ); + ecl_file_type * ecl_file = (ecl_file_type *)util_malloc( sizeof * ecl_file ); UTIL_TYPE_ID_INIT(ecl_file , ECL_FILE_ID); ecl_file->map_stack = vector_alloc_new(); ecl_file->inv_view = inv_map_alloc( ); @@ -800,7 +800,6 @@ ecl_version_enum ecl_file_get_ecl_version( const ecl_file_type * file ) { return FRONTSIM; util_abort("%s: Simulator version value:%d not recognized \n",__func__ , int_value ); - return -1; } /* @@ -887,7 +886,7 @@ void ecl_file_push_block( ecl_file_type * ecl_file ) { } void ecl_file_pop_block( ecl_file_type * ecl_file ) { - ecl_file->active_view = vector_pop_back( ecl_file->map_stack ); + ecl_file->active_view = (ecl_file_view_type *)vector_pop_back( ecl_file->map_stack ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_file_kw.c b/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_file_kw.c rename to ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp index d8fe735202..e07c9884d6 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file_kw.c +++ b/ThirdParty/Ert/lib/ecl/ecl_file_kw.cpp @@ -21,12 +21,12 @@ #include #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #include /* @@ -69,7 +69,7 @@ struct ecl_file_kw_struct { /*****************************************************************/ inv_map_type * inv_map_alloc() { - inv_map_type * map = util_malloc( sizeof * map ); + inv_map_type * map = (inv_map_type *)util_malloc( sizeof * map ); map->file_kw_ptr = size_t_vector_alloc( 0 , 0 ); map->ecl_kw_ptr = size_t_vector_alloc( 0 , 0 ); map->sorted = false; @@ -137,7 +137,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_file_kw , ECL_FILE_KW_TYPE_ID ) ecl_file_kw_type * ecl_file_kw_alloc0( const char * header , ecl_data_type data_type , int size , offset_type offset) { - ecl_file_kw_type * file_kw = util_malloc( sizeof * file_kw ); + ecl_file_kw_type * file_kw = (ecl_file_kw_type *)util_malloc( sizeof * file_kw ); UTIL_TYPE_ID_INIT( file_kw , ECL_FILE_KW_TYPE_ID ); file_kw->header = util_alloc_string_copy( header ); @@ -363,14 +363,14 @@ void ecl_file_kw_fwrite( const ecl_file_kw_type * file_kw , FILE * stream ) { util_fwrite_int( file_kw->kw_size , stream ); util_fwrite_offset( file_kw->file_offset , stream ); util_fwrite_int( ecl_type_get_type( file_kw->data_type ) , stream ); - util_fwrite_size_t( ecl_type_get_sizeof_ctype_fortio( file_kw->data_type ) , stream ); + util_fwrite_size_t( ecl_type_get_sizeof_iotype( file_kw->data_type ) , stream ); } ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num) { - + size_t file_kw_size = ECL_STRING8_LENGTH + 2 * sizeof(int) + sizeof(offset_type) + sizeof(size_t); size_t buffer_size = num * file_kw_size; - char * buffer = util_malloc( buffer_size * sizeof * buffer ); + char * buffer = (char*)util_malloc( buffer_size * sizeof * buffer ); size_t num_read = fread( buffer, 1 , buffer_size , stream); if (num_read != buffer_size) { @@ -379,7 +379,7 @@ ecl_file_kw_type ** ecl_file_kw_fread_alloc_multiple( FILE * stream , int num) { } { - ecl_file_kw_type ** kw_list = util_malloc( num * sizeof * kw_list ); + ecl_file_kw_type ** kw_list = (ecl_file_kw_type **)util_malloc( num * sizeof * kw_list ); for (int ikw = 0; ikw < num; ikw++) { int buffer_offset = ikw * file_kw_size; char header[ECL_STRING8_LENGTH + 1]; diff --git a/ThirdParty/Ert/lib/ecl/ecl_file_view.c b/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/ecl_file_view.c rename to ThirdParty/Ert/lib/ecl/ecl_file_view.cpp index 0d42d7fd7a..ed3e549ebd 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_file_view.c +++ b/ThirdParty/Ert/lib/ecl/ecl_file_view.cpp @@ -17,17 +17,17 @@ */ -#include -#include -#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct ecl_file_view_struct { @@ -71,7 +71,7 @@ const char * ecl_file_view_get_src_file( const ecl_file_view_type * file_view ) ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , inv_map_type * inv_map , bool owner ) { - ecl_file_view_type * ecl_file_view = util_malloc( sizeof * ecl_file_view ); + ecl_file_view_type * ecl_file_view = (ecl_file_view_type*)util_malloc( sizeof * ecl_file_view ); ecl_file_view->kw_list = vector_alloc_new(); ecl_file_view->kw_index = hash_alloc(); ecl_file_view->distinct_kw = stringlist_alloc_new(); @@ -84,7 +84,7 @@ ecl_file_view_type * ecl_file_view_alloc( fortio_type * fortio , int * flags , i } int ecl_file_view_get_global_index( const ecl_file_view_type * ecl_file_view , const char * kw , int ith) { - const int_vector_type * index_vector = hash_get(ecl_file_view->kw_index , kw); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); int global_index = int_vector_iget( index_vector , ith); return global_index; } @@ -106,7 +106,7 @@ void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) { { int i; for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { - const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i); + const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i); const char * header = ecl_file_kw_get_header( file_kw ); if ( !hash_has_key( ecl_file_view->kw_index , header )) { int_vector_type * index_vector = int_vector_alloc( 0 , -1 ); @@ -115,7 +115,7 @@ void ecl_file_view_make_index( ecl_file_view_type * ecl_file_view ) { } { - int_vector_type * index_vector = hash_get( ecl_file_view->kw_index , header); + int_vector_type * index_vector = (int_vector_type*)hash_get( ecl_file_view->kw_index , header); int_vector_append( index_vector , i); } } @@ -128,7 +128,7 @@ bool ecl_file_view_has_kw( const ecl_file_view_type * ecl_file_view, const char ecl_file_kw_type * ecl_file_view_iget_file_kw( const ecl_file_view_type * ecl_file_view , int global_index) { - ecl_file_kw_type * file_kw = vector_iget( ecl_file_view->kw_list , global_index); + ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , global_index); return file_kw; } @@ -169,7 +169,7 @@ ecl_kw_type * ecl_file_view_iget_kw( const ecl_file_view_type * ecl_file_view , return ecl_file_view_get_kw(ecl_file_view, file_kw); } -void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, const char* kw, int index, const int_vector_type * index_map, char* buffer) { +void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, const char* kw, int index, const int_vector_type * index_map, char* io_buffer) { ecl_file_kw_type * file_kw = ecl_file_view_iget_named_file_kw( ecl_file_view , kw , index); if (fortio_assert_stream_open( ecl_file_view->fortio )) { @@ -177,7 +177,7 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons ecl_data_type data_type = ecl_file_kw_get_data_type(file_kw); int element_count = ecl_file_kw_get_size(file_kw); - ecl_kw_fread_indexed_data(ecl_file_view->fortio, offset + ECL_KW_HEADER_FORTIO_SIZE, data_type, element_count, index_map, buffer); + ecl_kw_fread_indexed_data(ecl_file_view->fortio, offset + ECL_KW_HEADER_FORTIO_SIZE, data_type, element_count, index_map, io_buffer); } } @@ -185,7 +185,7 @@ void ecl_file_view_index_fload_kw(const ecl_file_view_type * ecl_file_view, cons int ecl_file_view_find_kw_value( const ecl_file_view_type * ecl_file_view , const char * kw , const void * value) { int global_index = -1; if ( ecl_file_view_has_kw( ecl_file_view , kw)) { - const int_vector_type * index_list = hash_get( ecl_file_view->kw_index , kw ); + const int_vector_type * index_list = (const int_vector_type*)hash_get( ecl_file_view->kw_index , kw ); int index = 0; while (index < int_vector_size( index_list )) { const ecl_kw_type * ecl_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( index_list , index )); @@ -247,7 +247,7 @@ int ecl_file_view_iget_named_size( const ecl_file_view_type * ecl_file_view , co void ecl_file_view_replace_kw( ecl_file_view_type * ecl_file_view , ecl_kw_type * old_kw , ecl_kw_type * new_kw , bool insert_copy) { int index = 0; while (index < vector_get_size( ecl_file_view->kw_list )) { - ecl_file_kw_type * ikw = vector_iget( ecl_file_view->kw_list , index ); + ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); if (ecl_file_kw_ptr_eq( ikw , old_kw)) { /* Found it; observe that the vector_iset() function will @@ -274,7 +274,7 @@ bool ecl_file_view_load_all( ecl_file_view_type * ecl_file_view ) { if (fortio_assert_stream_open( ecl_file_view->fortio )) { int index; for (index = 0; index < vector_get_size( ecl_file_view->kw_list); index++) { - ecl_file_kw_type * ikw = vector_iget( ecl_file_view->kw_list , index ); + ecl_file_kw_type * ikw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , index ); ecl_file_kw_get_kw( ikw , ecl_file_view->fortio , ecl_file_view->inv_map); } loadOK = true; @@ -314,7 +314,7 @@ void ecl_file_view_free__( void * arg ) { int ecl_file_view_get_num_named_kw(const ecl_file_view_type * ecl_file_view , const char * kw) { if (hash_has_key(ecl_file_view->kw_index , kw)) { - const int_vector_type * index_vector = hash_get(ecl_file_view->kw_index , kw); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(ecl_file_view->kw_index , kw); return int_vector_size( index_vector ); } else return 0; @@ -332,9 +332,9 @@ void ecl_file_view_fwrite( const ecl_file_view_type * ecl_file_view , fortio_typ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int global_index) { - const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , global_index); + const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , global_index); const char * header = ecl_file_kw_get_header( file_kw ); - const int_vector_type * index_vector = hash_get( ecl_file_view->kw_index , header ); + const int_vector_type * index_vector = (const int_vector_type*)hash_get( ecl_file_view->kw_index , header ); const int * index_data = int_vector_get_const_ptr( index_vector ); int occurence = -1; @@ -354,7 +354,7 @@ int ecl_file_view_iget_occurence( const ecl_file_view_type * ecl_file_view , int void ecl_file_view_fprintf_kw_list(const ecl_file_view_type * ecl_file_view , FILE * stream) { int i; for (i=0; i < vector_get_size( ecl_file_view->kw_list ); i++) { - const ecl_file_kw_type * file_kw = vector_iget_const( ecl_file_view->kw_list , i ); + const ecl_file_kw_type * file_kw = (const ecl_file_kw_type*)vector_iget_const( ecl_file_view->kw_list , i ); char * type_name = ecl_type_alloc_name(ecl_file_kw_get_data_type(file_kw)); fprintf(stream , "%-8s %7d:%s\n", ecl_file_kw_get_header( file_kw ) , @@ -376,7 +376,7 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e kw_index = ecl_file_view_get_global_index( ecl_file_view , start_kw , occurence ); { - ecl_file_kw_type * file_kw = vector_iget( ecl_file_view->kw_list , kw_index ); + ecl_file_kw_type * file_kw = (ecl_file_kw_type*)vector_iget( ecl_file_view->kw_list , kw_index ); while (true) { ecl_file_view_add_kw( block_map , file_kw ); @@ -385,7 +385,7 @@ ecl_file_view_type * ecl_file_view_alloc_blockview2(const ecl_file_view_type * e break; else { if (end_kw) { - file_kw = vector_iget(ecl_file_view->kw_list , kw_index); + file_kw = (ecl_file_kw_type*)vector_iget(ecl_file_view->kw_list , kw_index); if (strcmp( end_kw , ecl_file_kw_get_header( file_kw )) == 0) break; } @@ -589,7 +589,7 @@ double ecl_file_view_iget_restart_sim_days(const ecl_file_view_type * ecl_file_v int ecl_file_view_find_sim_time(const ecl_file_view_type * ecl_file_view , time_t sim_time) { int seqnum_index = -1; if ( ecl_file_view_has_kw( ecl_file_view , INTEHEAD_KW)) { - const int_vector_type * intehead_index_list = hash_get( ecl_file_view->kw_index , INTEHEAD_KW ); + const int_vector_type * intehead_index_list = (const int_vector_type *)hash_get( ecl_file_view->kw_index , INTEHEAD_KW ); int index = 0; while (index < int_vector_size( intehead_index_list )) { const ecl_kw_type * intehead_kw = ecl_file_view_iget_kw( ecl_file_view , int_vector_iget( intehead_index_list , index )); @@ -807,10 +807,10 @@ ecl_file_view_type * ecl_file_view_fread_alloc( fortio_type * fortio , int * fla ecl_file_transaction_type * ecl_file_view_start_transaction(ecl_file_view_type * file_view) { - ecl_file_transaction_type * t = util_malloc(sizeof * t); + ecl_file_transaction_type * t = (ecl_file_transaction_type *)util_malloc(sizeof * t); int size = ecl_file_view_get_size(file_view); t->file_view = file_view; - t->ref_count = util_malloc( size * sizeof * t->ref_count ); + t->ref_count = (int*)util_malloc( size * sizeof * t->ref_count ); for (int i = 0; i < size; i++) { ecl_file_kw_type * file_kw = ecl_file_view_iget_file_kw(file_view, i); ecl_file_kw_start_transaction(file_kw, &t->ref_count[i]); diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav.c b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_grav.c rename to ThirdParty/Ert/lib/ecl/ecl_grav.cpp index a763f111f0..5d25b9b966 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grav.cpp @@ -20,19 +20,19 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** @@ -157,7 +157,7 @@ static const char * get_den_kw( ecl_phase_enum phase , ecl_version_enum ecl_vers static void ecl_grav_phase_ensure_work( ecl_grav_phase_type * grav_phase) { if (grav_phase->work == NULL) - grav_phase->work = util_calloc( ecl_grid_cache_get_size( grav_phase->grid_cache ) , sizeof * grav_phase->work ); + grav_phase->work = (double*)util_calloc( ecl_grid_cache_get_size( grav_phase->grid_cache ) , sizeof * grav_phase->work ); } @@ -213,19 +213,19 @@ static ecl_grav_phase_type * ecl_grav_phase_alloc( ecl_grav_type * ecl_grav , const ecl_grid_cache_type * grid_cache = ecl_grav->grid_cache; const char * sat_kw_name = ecl_util_get_phase_name( phase ); { - ecl_grav_phase_type * grav_phase = util_malloc( sizeof * grav_phase ); + ecl_grav_phase_type * grav_phase = (ecl_grav_phase_type*)util_malloc( sizeof * grav_phase ); const int size = ecl_grid_cache_get_size( grid_cache ); UTIL_TYPE_ID_INIT( grav_phase , ECL_GRAV_PHASE_TYPE_ID ); grav_phase->grid_cache = grid_cache; grav_phase->aquifer_cell = ecl_grav->aquifer_cell; - grav_phase->fluid_mass = util_calloc( size , sizeof * grav_phase->fluid_mass ); + grav_phase->fluid_mass = (double*)util_calloc( size , sizeof * grav_phase->fluid_mass ); grav_phase->phase = phase; grav_phase->work = NULL; if (calc_type == GRAV_CALC_FIP) { ecl_kw_type * pvtnum_kw = ecl_file_iget_named_kw( init_file , PVTNUM_KW , 0 ); - double_vector_type * std_density = hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase )); + double_vector_type * std_density = (double_vector_type*)hash_get( ecl_grav->std_density , ecl_util_get_phase_name( phase )); ecl_kw_type * fip_kw; if ( phase == ECL_OIL_PHASE) @@ -349,7 +349,7 @@ static void ecl_grav_survey_add_phases( ecl_grav_type * ecl_grav , ecl_grav_surv static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * ecl_grav , const char * name , grav_calc_type calc_type) { - ecl_grav_survey_type * survey = util_malloc( sizeof * survey ); + ecl_grav_survey_type * survey = (ecl_grav_survey_type*)util_malloc( sizeof * survey ); UTIL_TYPE_ID_INIT( survey , ECL_GRAV_SURVEY_ID ); survey->grid_cache = ecl_grav->grid_cache; survey->aquifer_cell = ecl_grav->aquifer_cell; @@ -358,7 +358,7 @@ static ecl_grav_survey_type * ecl_grav_survey_alloc_empty(const ecl_grav_type * survey->phase_map = hash_alloc(); if (calc_type & GRAV_CALC_USE_PORV) - survey->porv = util_calloc( ecl_grid_cache_get_size( ecl_grav->grid_cache ) , sizeof * survey->porv ); + survey->porv = (double*)util_calloc( ecl_grid_cache_get_size( ecl_grav->grid_cache ) , sizeof * survey->porv ); else survey->porv = NULL; @@ -549,10 +549,10 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey, int phase_nr; double deltag = 0; for (phase_nr = 0; phase_nr < vector_get_size( base_survey->phase_list ); phase_nr++) { - ecl_grav_phase_type * base_phase = vector_iget( base_survey->phase_list , phase_nr ); + ecl_grav_phase_type * base_phase = (ecl_grav_phase_type*)vector_iget( base_survey->phase_list , phase_nr ); if (base_phase->phase & phase_mask) { if (monitor_survey != NULL) { - const ecl_grav_phase_type * monitor_phase = vector_iget_const( monitor_survey->phase_list , phase_nr ); + const ecl_grav_phase_type * monitor_phase = (const ecl_grav_phase_type*)vector_iget_const( monitor_survey->phase_list , phase_nr ); deltag += ecl_grav_phase_eval( base_phase , monitor_phase , region , utm_x , utm_y , depth ); } else deltag += ecl_grav_phase_eval( base_phase , NULL , region , utm_x , utm_y , depth ); @@ -570,7 +570,7 @@ static double ecl_grav_survey_eval( const ecl_grav_survey_type * base_survey, */ ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file) { - ecl_grav_type * ecl_grav = util_malloc( sizeof * ecl_grav ); + ecl_grav_type * ecl_grav = (ecl_grav_type*)util_malloc( sizeof * ecl_grav ); ecl_grav->init_file = init_file; ecl_grav->grid_cache = ecl_grid_cache_alloc( ecl_grid ); ecl_grav->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( ecl_grav->grid_cache , ecl_grav->init_file ); @@ -619,7 +619,7 @@ static ecl_grav_survey_type * ecl_grav_get_survey( const ecl_grav_type * grav , return NULL; // Calling scope must determine if this is OK? else { if (hash_has_key( grav->surveys , name)) - return hash_get( grav->surveys , name ); + return (ecl_grav_survey_type*)hash_get( grav->surveys , name ); else { hash_iter_type * survey_iter = hash_iter_alloc( grav->surveys ); fprintf(stderr,"Survey name:%s not registered. Available surveys are: \n\n " , name); @@ -680,7 +680,7 @@ void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , dou void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density) { - double_vector_type * std_density = hash_get( grav->std_density , ecl_util_get_phase_name( phase )); + double_vector_type * std_density = (double_vector_type*)hash_get( grav->std_density , ecl_util_get_phase_name( phase )); double_vector_iset( std_density , pvtnum , density ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.c b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_grav_calc.c rename to ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp index 66618bbbe6..ae41b98c69 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_calc.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_calc.cpp @@ -20,12 +20,12 @@ #include #include -#include +#include -#include -#include -#include -#include +#include +#include +#include +#include diff --git a/ThirdParty/Ert/lib/ecl/ecl_grav_common.c b/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_grav_common.c rename to ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp index 024a44c09f..37da5a000c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grav_common.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grav_common.cpp @@ -21,13 +21,14 @@ #include #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /* This file contains code which is common to both the ecl_grav @@ -36,7 +37,7 @@ */ bool * ecl_grav_common_alloc_aquifer_cell( const ecl_grid_cache_type * grid_cache , const ecl_file_type * init_file) { - bool * aquifer_cell = util_calloc( ecl_grid_cache_get_size( grid_cache ) , sizeof * aquifer_cell ); + bool * aquifer_cell = (bool*)util_calloc( ecl_grid_cache_get_size( grid_cache ) , sizeof * aquifer_cell ); for (int active_index = 0; active_index < ecl_grid_cache_get_size( grid_cache ); active_index++) aquifer_cell[ active_index ] = false; diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid.c b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_grid.c rename to ThirdParty/Ert/lib/ecl/ecl_grid.cpp index 0d484aecba..4f494d0ffc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid.cpp @@ -22,26 +22,26 @@ #include #include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** @@ -411,7 +411,7 @@ properties and the fracture properties in a cell is implemented as a nnc where the fracture cell has global index in the range [nx*ny*nz, 2*nz*ny*nz). In ert we we have not implemented this double covering - in the case of dual porosity models, and therefor NNC involving + in the case of dual porosity models so NNC involving fracture cells are not considered. */ @@ -861,7 +861,7 @@ static void ecl_cell_fwrite_GRID(const ecl_grid_type * grid, ecl_kw_fwrite( coords_kw , fortio ); { - float * corners = ecl_kw_get_void_ptr( corners_kw ); + float * corners = (float*)ecl_kw_get_void_ptr( corners_kw ); point_type point; int c; @@ -1011,7 +1011,7 @@ static double ecl_cell_max_y( const ecl_cell_type * cell ) { have all four corner at the same arbitrary depth; these cells are inactive and do not affect flow simulations - however the arbitrary location of the cells warps visualisation of normal inactive cells - completely. We therefor try to invalidate such cells here. The + completely. We therefore try to invalidate such cells here. The algorithm used is the same as used for RMS; however RMS will mark the cells as inactive - whereas we mark already inactive cells as invalid. @@ -1288,7 +1288,8 @@ static double ecl_cell_get_signed_volume( ecl_cell_type * cell) { point_type corners[ 8 ]; memcpy( corners, cell->corner_list, sizeof( point_type ) * 8 ); - tetrahedron_type tet = { .p0 = center }; + tetrahedron_type tet; + tet.p0 = center; double volume = 0; /* using both tetrahedron decompositions - gives good agreement @@ -1326,7 +1327,7 @@ static double ecl_cell_get_signed_volume( ecl_cell_type * cell) { * Note added: these volume calculations are used to calculate pore * volumes in OPM, it turns out that opm is very sensitive to these * volumes. Extracting the divison by 6.0 was actually enough to - * induce a regression test failure in flow, this has therefor been + * induce a regression test failure in flow, this has therefore been * reverted. */ @@ -1567,7 +1568,7 @@ static void ecl_grid_free_cells( ecl_grid_type * grid ) { } static bool ecl_grid_alloc_cells( ecl_grid_type * grid , bool init_valid) { - grid->cells = malloc(grid->size * sizeof * grid->cells ); + grid->cells = (ecl_cell_type*)malloc(grid->size * sizeof * grid->cells ); if (!grid->cells) return false; @@ -1600,7 +1601,7 @@ static ecl_grid_type * ecl_grid_alloc_empty(ecl_grid_type * global_grid, int nz, int lgr_nr, bool init_valid) { - ecl_grid_type * grid = util_malloc(sizeof * grid ); + ecl_grid_type * grid = (ecl_grid_type*)util_malloc(sizeof * grid ); UTIL_TYPE_ID_INIT(grid , ECL_GRID_ID); grid->total_active = 0; grid->total_active_fracture = 0; @@ -1845,9 +1846,9 @@ static void ecl_grid_init_index_map__(ecl_grid_type * ecl_grid, static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { /* Creating the inverse mapping for the matrix cells. */ - ecl_grid->index_map = util_realloc(ecl_grid->index_map, + ecl_grid->index_map = (int*)util_realloc(ecl_grid->index_map, ecl_grid->size * sizeof * ecl_grid->index_map); - ecl_grid->inv_index_map = util_realloc(ecl_grid->inv_index_map, + ecl_grid->inv_index_map = (int*)util_realloc(ecl_grid->inv_index_map, ecl_grid->total_active * sizeof * ecl_grid->inv_index_map); ecl_grid_init_index_map__(ecl_grid, ecl_grid->index_map, @@ -1858,9 +1859,9 @@ static void ecl_grid_realloc_index_map(ecl_grid_type * ecl_grid) { /* Create the inverse mapping for the fractures. */ if (ecl_grid->dualp_flag != FILEHEAD_SINGLE_POROSITY) { - ecl_grid->fracture_index_map = util_realloc(ecl_grid->fracture_index_map, + ecl_grid->fracture_index_map = (int*)util_realloc(ecl_grid->fracture_index_map, ecl_grid->size * sizeof * ecl_grid->fracture_index_map); - ecl_grid->inv_fracture_index_map = util_realloc(ecl_grid->inv_fracture_index_map, + ecl_grid->inv_fracture_index_map = (int*)util_realloc(ecl_grid->inv_fracture_index_map, ecl_grid->total_active_fracture * sizeof * ecl_grid->inv_fracture_index_map); ecl_grid_init_index_map__(ecl_grid, ecl_grid->fracture_index_map, @@ -2023,7 +2024,7 @@ static ecl_coarse_cell_type * ecl_grid_get_or_create_coarse_cell( ecl_grid_type if (vector_safe_iget( ecl_grid->coarse_cells , coarse_nr ) == NULL) vector_iset_owned_ref( ecl_grid->coarse_cells , coarse_nr , ecl_coarse_cell_alloc() , ecl_coarse_cell_free__); - return vector_iget( ecl_grid->coarse_cells , coarse_nr ); + return (ecl_coarse_cell_type*)vector_iget( ecl_grid->coarse_cells , coarse_nr ); } @@ -2044,7 +2045,7 @@ static void ecl_grid_init_coarse_cells( ecl_grid_type * ecl_grid ) { ecl_coarse_cell_type * ecl_grid_iget_coarse_group( const ecl_grid_type * ecl_grid , int coarse_nr ) { - return vector_iget( ecl_grid->coarse_cells , coarse_nr ); + return (ecl_coarse_cell_type*)vector_iget( ecl_grid->coarse_cells , coarse_nr ); } @@ -2123,7 +2124,7 @@ static void ecl_grid_init_mapaxes( ecl_grid_type * ecl_grid , bool apply_mapaxes } ecl_grid->origo[0] = mapaxes[2]; ecl_grid->origo[1] = mapaxes[3]; - ecl_grid->mapaxes = util_malloc( 6 * sizeof * ecl_grid->mapaxes ); + ecl_grid->mapaxes = (float*)util_malloc( 6 * sizeof * ecl_grid->mapaxes ); memcpy( ecl_grid->mapaxes , mapaxes , 6 * sizeof( float )); /* @@ -2230,10 +2231,10 @@ static void ecl_grid_install_lgr_GRID(ecl_grid_type * host_grid , ecl_grid_type static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_file_type * ecl_file , int grid_nr) { ecl_kw_type * lgrname_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1); - lgr_grid->name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrname_kw , 0) ); /* trailing zeros are stripped away. */ + lgr_grid->name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgrname_kw , 0) ); /* trailing zeros are stripped away. */ if (ecl_file_has_kw( ecl_file , LGR_PARENT_KW)) { ecl_kw_type * parent_kw = ecl_file_iget_named_kw( ecl_file , LGR_PARENT_KW , grid_nr -1); - char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( parent_kw , 0)); + char * parent = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( parent_kw , 0)); if (strlen( parent ) > 0) lgr_grid->parent_name = parent; @@ -2251,7 +2252,7 @@ static void ecl_grid_set_lgr_name_EGRID(ecl_grid_type * lgr_grid , const ecl_fil static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file_type * ecl_file , int grid_nr) { ecl_kw_type * lgr_kw = ecl_file_iget_named_kw( ecl_file , LGR_KW , grid_nr - 1); - lgr_grid->name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgr_kw , 0) ); /* trailing zeros are stripped away. */ + lgr_grid->name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgr_kw , 0) ); /* trailing zeros are stripped away. */ { /** the lgr keyword can have one or two elements; in the case of two elements @@ -2259,7 +2260,7 @@ static void ecl_grid_set_lgr_name_GRID(ecl_grid_type * lgr_grid , const ecl_file only one element the current lgr is assumed to descend from the main grid */ if (ecl_kw_get_size( lgr_kw ) == 2) { - char * parent = util_alloc_strip_copy( ecl_kw_iget_ptr( lgr_kw , 1)); + char * parent = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgr_kw , 1)); if ((strlen(parent) == 0) || (strcmp(parent , GLOBAL_STRING ) == 0)) free( parent ); @@ -2430,9 +2431,9 @@ static ecl_grid_type * ecl_grid_alloc_GRDECL_data__(ecl_grid_type * global_grid, static void ecl_grid_copy_mapaxes( ecl_grid_type * target_grid , const ecl_grid_type * src_grid ) { target_grid->use_mapaxes = src_grid->use_mapaxes; if (src_grid->mapaxes) - target_grid->mapaxes = util_realloc_copy(target_grid->mapaxes , src_grid->mapaxes , 6 * sizeof * src_grid->mapaxes ); + target_grid->mapaxes = (float*)util_realloc_copy(target_grid->mapaxes , src_grid->mapaxes , 6 * sizeof * src_grid->mapaxes ); else - target_grid->mapaxes = util_realloc_copy(target_grid->mapaxes , NULL , 0 ); + target_grid->mapaxes = (float*)util_realloc_copy(target_grid->mapaxes , NULL , 0 ); for (int i=0; i < 2; i++) { target_grid->unit_x[i] = src_grid->unit_x[i]; @@ -2485,7 +2486,7 @@ ecl_grid_type * ecl_grid_alloc_copy( const ecl_grid_type * src_grid ) { { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( src_grid->LGR_list ); grid_nr++) { - const ecl_grid_type * src_lgr = vector_iget_const( src_grid->LGR_list , grid_nr); + const ecl_grid_type * src_lgr = (const ecl_grid_type*)vector_iget_const( src_grid->LGR_list , grid_nr); ecl_grid_type * copy_lgr = ecl_grid_alloc_copy__( src_lgr , copy_grid ); ecl_grid_type * host_grid; @@ -2528,12 +2529,12 @@ ecl_grid_type * ecl_grid_alloc_processed_copy( const ecl_grid_type * src_grid , } else { int nx,ny,nz,na; int zcorn_size = ecl_grid_get_zcorn_size( src_grid ); - float * zcorn_float = util_malloc( zcorn_size * sizeof * zcorn_float ); + float * zcorn_float = (float*)util_malloc( zcorn_size * sizeof * zcorn_float ); float * coord = ecl_grid_alloc_coord_data( src_grid ); float * mapaxes = NULL; if (ecl_grid_get_mapaxes( src_grid )) { - mapaxes = util_malloc( 6 * sizeof * mapaxes ); + mapaxes = (float*)util_malloc( 6 * sizeof * mapaxes ); ecl_grid_init_mapaxes_data_float(src_grid, mapaxes); } ecl_grid_get_dims( src_grid , &nx, &ny , &nz , &na); @@ -2793,7 +2794,7 @@ static void ecl_grid_init_nnc_cells( ecl_grid_type * grid1, ecl_grid_type * grid The physical connection between the matrix and the fractures in cell nr c is modelled as an nnc: cell[c] -> cell[c + nx*ny*nz]. In the ert ecl library we only have cells in the range [0,nx*ny*nz), - and fracture is a property of a cell, we therefor do not include + and fracture is a property of a cell. We therefore do not include nnc connections involving fracture cells (i.e. cell_index >= nx*ny*nz). */ @@ -3160,8 +3161,8 @@ static ecl_grid_type * ecl_grid_alloc_GRID__(ecl_grid_type * global_grid , const int coords_size = -1; int index; - int ** coords = util_calloc( num_coords , sizeof * coords ); - float ** corners = util_calloc( num_coords , sizeof * corners ); + int ** coords = (int **)util_calloc( num_coords , sizeof * coords ); + float ** corners = (float**)util_calloc( num_coords , sizeof * corners ); for (index = 0; index < num_coords; index++) { const ecl_kw_type * coords_kw = ecl_file_iget_named_kw(ecl_file , COORDS_KW , index + cell_offset); @@ -3449,7 +3450,7 @@ ecl_grid_type * ecl_grid_alloc_dx_dy_dz_tops( int nx, int ny , int nz , const do 0, true); if (grid) { int i, j, k; - double * y0 = util_calloc( nx, sizeof * y0 ); + double * y0 = (double*)util_calloc( nx, sizeof * y0 ); for (k=0; k < nz; k++) { for (i=0; i < nx; i++) { @@ -3744,8 +3745,8 @@ static bool ecl_grid_compare_coarse_cells(const ecl_grid_type * g1 , const ecl_g int c; for (c = 0; c < vector_get_size( g1->coarse_cells ); c++) { - const ecl_coarse_cell_type * coarse_cell1 = vector_iget_const( g1->coarse_cells , c); - const ecl_coarse_cell_type * coarse_cell2 = vector_iget_const( g2->coarse_cells , c); + const ecl_coarse_cell_type * coarse_cell1 = (const ecl_coarse_cell_type*)vector_iget_const( g1->coarse_cells , c); + const ecl_coarse_cell_type * coarse_cell2 = (const ecl_coarse_cell_type*)vector_iget_const( g2->coarse_cells , c); equal = ecl_coarse_cell_equal( coarse_cell1 , coarse_cell2 ); if (!equal) @@ -3909,8 +3910,8 @@ bool ecl_grid_compare(const ecl_grid_type * g1 , const ecl_grid_type * g2 , bool if (vector_get_size( g1->LGR_list ) == vector_get_size( g2->LGR_list )) { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( g1->LGR_list ); grid_nr++) { - const ecl_grid_type * lgr1 = vector_iget_const( g1->LGR_list , grid_nr); - const ecl_grid_type * lgr2 = vector_iget_const( g2->LGR_list , grid_nr); + const ecl_grid_type * lgr1 = (const ecl_grid_type*)vector_iget_const( g1->LGR_list , grid_nr); + const ecl_grid_type * lgr2 = (const ecl_grid_type*)vector_iget_const( g2->LGR_list , grid_nr); printf("Comparing lgr grid:%d \n",grid_nr); equal = ecl_grid_compare__(lgr1 , lgr2 , include_nnc , verbose); @@ -4185,7 +4186,7 @@ int ecl_grid_get_global_index_from_xy_bottom( const ecl_grid_type * ecl_grid , d static void ecl_grid_clear_visited( ecl_grid_type * grid ) { if (grid->visited == NULL) - grid->visited = util_calloc( grid->size , sizeof * grid->visited ); + grid->visited = (bool*)util_calloc( grid->size , sizeof * grid->visited ); { int i; @@ -4407,7 +4408,7 @@ void ecl_grid_alloc_blocking_variables(ecl_grid_type * grid, int block_dim) { else util_abort("%: valid values are two and three. Value:%d invaid \n",__func__ , block_dim); - grid->values = util_calloc( grid->block_size , sizeof * grid->values ); + grid->values = (double_vector_type**)util_calloc( grid->block_size , sizeof * grid->values ); for (index = 0; index < grid->block_size; index++) grid->values[index] = double_vector_alloc( 0 , 0.0 ); } @@ -4751,6 +4752,17 @@ void ecl_grid_get_cell_corner_xyz1(const ecl_grid_type * grid , int global_index } +void ecl_grid_export_cell_corners1(const ecl_grid_type * grid, int global_index, double *x, double *y, double *z) { + const ecl_cell_type * cell = ecl_grid_get_cell(grid, global_index); + for (int i=0; i<8; i++) { + const point_type point = cell->corner_list[i]; + x[i] = point.x; + y[i] = point.y; + z[i] = point.z; + } +} + + void ecl_grid_get_cell_corner_xyz3(const ecl_grid_type * grid , int i , int j , int k, int corner_nr , double * xpos , double * ypos , double * zpos ) { const int global_index = ecl_grid_get_global_index__(grid , i , j , k ); ecl_grid_get_cell_corner_xyz1( grid , global_index , corner_nr , xpos , ypos , zpos); @@ -5117,7 +5129,7 @@ ecl_grid_type * ecl_grid_get_lgr(const ecl_grid_type * main_grid, const char * _ __assert_main_grid( main_grid ); { char * lgr_name = util_alloc_strip_copy( __lgr_name ); - ecl_grid_type * lgr_grid = hash_get(main_grid->LGR_hash , lgr_name); + ecl_grid_type * lgr_grid = (ecl_grid_type*)hash_get(main_grid->LGR_hash , lgr_name); free(lgr_name); return lgr_grid; } @@ -5184,7 +5196,7 @@ int ecl_grid_get_num_lgr(const ecl_grid_type * main_grid ) { ecl_grid_type * ecl_grid_iget_lgr(const ecl_grid_type * main_grid, int lgr_index) { __assert_main_grid( main_grid ); - return vector_iget( main_grid->LGR_list , lgr_index); + return (ecl_grid_type*)vector_iget( main_grid->LGR_list , lgr_index); } /* @@ -5201,7 +5213,7 @@ ecl_grid_type * ecl_grid_get_lgr_from_lgr_nr(const ecl_grid_type * main_grid, in __assert_main_grid( main_grid ); { int lgr_index = int_vector_iget( main_grid->lgr_index_map , lgr_nr ); - return vector_iget( main_grid->LGR_list , lgr_index); + return (ecl_grid_type*)vector_iget( main_grid->LGR_list , lgr_index); } } @@ -5265,7 +5277,7 @@ stringlist_type * ecl_grid_alloc_lgr_name_list(const ecl_grid_type * ecl_grid) { const char * ecl_grid_iget_lgr_name( const ecl_grid_type * ecl_grid , int lgr_index) { __assert_main_grid( ecl_grid ); if (lgr_index < (vector_get_size( ecl_grid->LGR_list ))) { - const ecl_grid_type * lgr = vector_iget( ecl_grid->LGR_list , lgr_index); + const ecl_grid_type * lgr = (const ecl_grid_type*)vector_iget( ecl_grid->LGR_list , lgr_index); return lgr->name; } else return NULL; @@ -5410,7 +5422,7 @@ void ecl_grid_summarize(const ecl_grid_type * ecl_grid) { int grid_nr; for (grid_nr=1; grid_nr < vector_get_size( ecl_grid->LGR_list ); grid_nr++) { printf("\n"); - ecl_grid_summarize( vector_iget_const( ecl_grid->LGR_list , grid_nr )); + ecl_grid_summarize( (const ecl_grid_type*)vector_iget_const( ecl_grid->LGR_list , grid_nr )); } } ecl_grid_test_lgr_consistency( ecl_grid ); @@ -5632,7 +5644,7 @@ int ecl_grid_get_region_cells(const ecl_grid_type * ecl_grid , const ecl_kw_type int cells_found = 0; if (ecl_kw_get_size( region_kw ) == ecl_grid->size) { if (ecl_type_is_int(ecl_kw_get_data_type( region_kw ))) { - const int * region_ptr = ecl_kw_iget_ptr( region_kw , 0); + const int * region_ptr = (const int*)ecl_kw_iget_ptr( region_kw , 0); int_vector_reset( index_list ); @@ -5737,7 +5749,7 @@ bool ecl_grid_test_lgr_consistency( const ecl_grid_type * ecl_grid ) { hash_iter_type * lgr_iter = hash_iter_alloc( ecl_grid->children ); bool consistent = true; while (!hash_iter_is_complete( lgr_iter )) { - const ecl_grid_type * lgr = hash_iter_get_next_value( lgr_iter ); + const ecl_grid_type * lgr = (const ecl_grid_type*)hash_iter_get_next_value( lgr_iter ); consistent &= ecl_grid_test_lgr_consistency2( ecl_grid , lgr ); consistent &= ecl_grid_test_lgr_consistency( lgr ); } @@ -5804,7 +5816,7 @@ void ecl_grid_dump(const ecl_grid_type * grid , FILE * stream) { { int i; for (i = 0; i < vector_get_size( grid->LGR_list ); i++) - ecl_grid_dump__( vector_iget_const( grid->LGR_list , i) , stream ); + ecl_grid_dump__( (const ecl_grid_type*)vector_iget_const( grid->LGR_list , i) , stream ); } } @@ -5813,7 +5825,7 @@ void ecl_grid_dump_ascii(ecl_grid_type * grid , bool active_only , FILE * stream { int i; for (i = 0; i < vector_get_size( grid->LGR_list ); i++) - ecl_grid_dump_ascii__( vector_iget( grid->LGR_list , i) , active_only , stream ); + ecl_grid_dump_ascii__( (ecl_grid_type*)vector_iget( grid->LGR_list , i) , active_only , stream ); } } @@ -6057,7 +6069,7 @@ void ecl_grid_fwrite_GRID2( const ecl_grid_type * grid , const char * filename, { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { - const ecl_grid_type * igrid = vector_iget_const( grid->LGR_list , grid_nr ); + const ecl_grid_type * igrid = (const ecl_grid_type*)vector_iget_const( grid->LGR_list , grid_nr ); ecl_grid_fwrite_GRID__( igrid , coords_size , fortio , output_unit ); } } @@ -6285,7 +6297,7 @@ void ecl_grid_init_coord_data_double( const ecl_grid_type * grid , double * coor float * ecl_grid_alloc_coord_data( const ecl_grid_type * grid ) { - float * coord = util_calloc( ecl_grid_get_coord_size(grid) , sizeof * coord ); + float * coord = (float*)util_calloc( ecl_grid_get_coord_size(grid) , sizeof * coord ); ecl_grid_init_coord_data( grid , coord ); return coord; } @@ -6293,7 +6305,7 @@ float * ecl_grid_alloc_coord_data( const ecl_grid_type * grid ) { void ecl_grid_assert_coord_kw( ecl_grid_type * grid ) { if (grid->coord_kw == NULL) { grid->coord_kw = ecl_kw_alloc( COORD_KW , ecl_grid_get_coord_size( grid ) , ECL_FLOAT); - ecl_grid_init_coord_data( grid , ecl_kw_get_void_ptr( grid->coord_kw )); + ecl_grid_init_coord_data( grid , (float*)ecl_kw_get_void_ptr( grid->coord_kw )); } } @@ -6355,7 +6367,7 @@ void ecl_grid_init_zcorn_data_double( const ecl_grid_type * grid , double * zcor float * ecl_grid_alloc_zcorn_data( const ecl_grid_type * grid ) { - float * zcorn = util_calloc( 8 * grid->size , sizeof * zcorn ); + float * zcorn = (float*)util_calloc( 8 * grid->size , sizeof * zcorn ); ecl_grid_init_zcorn_data( grid , zcorn ); return zcorn; } @@ -6364,7 +6376,7 @@ float * ecl_grid_alloc_zcorn_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_zcorn_kw( const ecl_grid_type * grid ) { ecl_kw_type * zcorn_kw = ecl_kw_alloc( ZCORN_KW , ecl_grid_get_zcorn_size(grid), ECL_FLOAT); - ecl_grid_init_zcorn_data(grid , ecl_kw_get_void_ptr(zcorn_kw)); + ecl_grid_init_zcorn_data(grid , (float*)ecl_kw_get_void_ptr(zcorn_kw)); return zcorn_kw; } @@ -6433,7 +6445,7 @@ void ecl_grid_init_actnum_data( const ecl_grid_type * grid , int * actnum ) { int * ecl_grid_alloc_actnum_data( const ecl_grid_type * grid ) { - int * actnum = util_calloc( grid->size , sizeof * actnum); + int * actnum = (int*)util_calloc( grid->size , sizeof * actnum); ecl_grid_init_actnum_data( grid , actnum ); return actnum; } @@ -6442,7 +6454,7 @@ int * ecl_grid_alloc_actnum_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_actnum_kw( const ecl_grid_type * grid ) { ecl_kw_type * actnum_kw = ecl_kw_alloc( ACTNUM_KW , grid->size , ECL_INT); - ecl_grid_init_actnum_data( grid , ecl_kw_get_void_ptr( actnum_kw )); + ecl_grid_init_actnum_data( grid , (int*)ecl_kw_get_void_ptr( actnum_kw )); return actnum_kw; } @@ -6488,7 +6500,7 @@ static void ecl_grid_init_hostnum_data( const ecl_grid_type * grid , int * hostn } int * ecl_grid_alloc_hostnum_data( const ecl_grid_type * grid ) { - int * hostnum = util_calloc( grid->size , sizeof * hostnum ); + int * hostnum = (int*)util_calloc( grid->size , sizeof * hostnum ); ecl_grid_init_hostnum_data( grid , hostnum ); return hostnum; } @@ -6496,7 +6508,7 @@ int * ecl_grid_alloc_hostnum_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_hostnum_kw( const ecl_grid_type * grid ) { ecl_kw_type * hostnum_kw = ecl_kw_alloc( HOSTNUM_KW , grid->size , ECL_INT); - ecl_grid_init_hostnum_data( grid , ecl_kw_get_void_ptr( hostnum_kw )); + ecl_grid_init_hostnum_data( grid , (int*)ecl_kw_get_void_ptr( hostnum_kw )); return hostnum_kw; } @@ -6511,7 +6523,7 @@ static void ecl_grid_init_corsnum_data( const ecl_grid_type * grid , int * corsn } int * ecl_grid_alloc_corsnum_data( const ecl_grid_type * grid ) { - int * corsnum = util_calloc( grid->size , sizeof * corsnum ); + int * corsnum = (int*)util_calloc( grid->size , sizeof * corsnum ); ecl_grid_init_corsnum_data( grid , corsnum ); return corsnum; } @@ -6519,7 +6531,7 @@ int * ecl_grid_alloc_corsnum_data( const ecl_grid_type * grid ) { ecl_kw_type * ecl_grid_alloc_corsnum_kw( const ecl_grid_type * grid ) { ecl_kw_type * corsnum_kw = ecl_kw_alloc( CORSNUM_KW , grid->size , ECL_INT); - ecl_grid_init_corsnum_data( grid , ecl_kw_get_void_ptr( corsnum_kw )); + ecl_grid_init_corsnum_data( grid , (int*)ecl_kw_get_void_ptr( corsnum_kw )); return corsnum_kw; } @@ -6687,7 +6699,7 @@ void ecl_grid_fwrite_EGRID2( ecl_grid_type * grid , const char * filename, ert_e { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { - ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr ); + ecl_grid_type * igrid = (ecl_grid_type*)vector_iget( grid->LGR_list , grid_nr ); ecl_grid_fwrite_EGRID__( igrid , fortio, output_unit ); } } @@ -6715,7 +6727,7 @@ void ecl_grid_fwrite_EGRID( ecl_grid_type * grid , const char * filename, bool o void ecl_grid_fwrite_depth( const ecl_grid_type * grid , fortio_type * init_file , ert_ecl_unit_enum output_unit) { ecl_kw_type * depth_kw = ecl_kw_alloc("DEPTH" , ecl_grid_get_nactive(grid) , ECL_FLOAT); { - float * depth_ptr = ecl_kw_get_ptr(depth_kw); + float * depth_ptr = (float*)ecl_kw_get_ptr(depth_kw); for (int i = 0; i < ecl_grid_get_nactive( grid ); i++) depth_ptr[i] = ecl_grid_get_cdepth1A( grid , i ); } @@ -6731,9 +6743,9 @@ void ecl_grid_fwrite_dims( const ecl_grid_type * grid , fortio_type * init_file, ecl_kw_type * dz = ecl_kw_alloc("DZ" , ecl_grid_get_nactive(grid) , ECL_FLOAT); { { - float * dx_ptr = ecl_kw_get_ptr(dx); - float * dy_ptr = ecl_kw_get_ptr(dy); - float * dz_ptr = ecl_kw_get_ptr(dz); + float * dx_ptr = (float*)ecl_kw_get_ptr(dx); + float * dy_ptr = (float*)ecl_kw_get_ptr(dy); + float * dz_ptr = (float*)ecl_kw_get_ptr(dz); for (int i = 0; i < ecl_grid_get_nactive( grid ); i++) { dx_ptr[i] = ecl_grid_get_cell_dx1A( grid , i ); @@ -6872,7 +6884,7 @@ int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) { { int grid_nr; for (grid_nr = 0; grid_nr < vector_get_size( grid->LGR_list ); grid_nr++) { - ecl_grid_type * igrid = vector_iget( grid->LGR_list , grid_nr ); + ecl_grid_type * igrid = (ecl_grid_type*)vector_iget( grid->LGR_list , grid_nr ); num_nnc += ecl_grid_get_num_nnc__( igrid ); } } @@ -6883,7 +6895,7 @@ int ecl_grid_get_num_nnc( const ecl_grid_type * grid ) { static ecl_kw_type * ecl_grid_alloc_volume_kw_active( const ecl_grid_type * grid) { ecl_kw_type * volume_kw = ecl_kw_alloc("VOLUME" , ecl_grid_get_active_size(grid) , ECL_DOUBLE); { - double * volume_data = ecl_kw_get_ptr( volume_kw ); + double * volume_data = (double*)ecl_kw_get_ptr( volume_kw ); int active_index; for (active_index = 0; active_index < ecl_grid_get_active_size(grid); active_index++) { double cell_volume = ecl_grid_get_cell_volume1A(grid , active_index); @@ -6897,7 +6909,7 @@ static ecl_kw_type * ecl_grid_alloc_volume_kw_active( const ecl_grid_type * grid static ecl_kw_type * ecl_grid_alloc_volume_kw_global( const ecl_grid_type * grid) { ecl_kw_type * volume_kw = ecl_kw_alloc("VOLUME" , ecl_grid_get_global_size(grid) , ECL_DOUBLE); { - double * volume_data = ecl_kw_get_ptr( volume_kw ); + double * volume_data = (double*)ecl_kw_get_ptr( volume_kw ); int global_index; for (global_index = 0; global_index < ecl_grid_get_global_size(grid); global_index++) { double cell_volume = ecl_grid_get_cell_volume1(grid , global_index); diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid_cache.c b/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp similarity index 82% rename from ThirdParty/Ert/lib/ecl/ecl_grid_cache.c rename to ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp index 3c11f46231..f856b9cc41 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid_cache.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid_cache.cpp @@ -21,13 +21,13 @@ #include #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include @@ -54,15 +54,15 @@ struct ecl_grid_cache_struct { ecl_grid_cache_type * ecl_grid_cache_alloc( const ecl_grid_type * grid ) { - ecl_grid_cache_type * grid_cache = util_malloc( sizeof * grid_cache ); + ecl_grid_cache_type * grid_cache = (ecl_grid_cache_type*)util_malloc( sizeof * grid_cache ); grid_cache->grid = grid; grid_cache->volume = NULL; grid_cache->size = ecl_grid_get_active_size( grid ); - grid_cache->xpos = util_calloc( grid_cache->size , sizeof * grid_cache->xpos ); - grid_cache->ypos = util_calloc( grid_cache->size , sizeof * grid_cache->ypos ); - grid_cache->zpos = util_calloc( grid_cache->size , sizeof * grid_cache->zpos ); - grid_cache->global_index = util_calloc( grid_cache->size , sizeof * grid_cache->global_index ); + grid_cache->xpos = (double*)util_calloc( grid_cache->size , sizeof * grid_cache->xpos ); + grid_cache->ypos = (double*)util_calloc( grid_cache->size , sizeof * grid_cache->ypos ); + grid_cache->zpos = (double*)util_calloc( grid_cache->size , sizeof * grid_cache->zpos ); + grid_cache->global_index = (int*)util_calloc( grid_cache->size , sizeof * grid_cache->global_index ); { int active_index; @@ -113,7 +113,7 @@ const double * ecl_grid_cache_get_volume( const ecl_grid_cache_type * grid_cache if (!grid_cache->volume) { // C++ style const cast. ecl_grid_cache_type * gc = (ecl_grid_cache_type *) grid_cache; - gc->volume = util_calloc( gc->size , sizeof * gc->volume ); + gc->volume = (double*)util_calloc( gc->size , sizeof * gc->volume ); for (int active_index = 0; active_index < grid_cache->size; active_index++) gc->volume[active_index] = ecl_grid_get_cell_volume1A( gc->grid , active_index ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_grid_dims.c b/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_grid_dims.c rename to ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp index 23d4b40838..24e6b671c3 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_grid_dims.c +++ b/ThirdParty/Ert/lib/ecl/ecl_grid_dims.cpp @@ -18,15 +18,15 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include #include -#include -#include -#include +#include +#include +#include struct ecl_grid_dims_struct { @@ -101,7 +101,7 @@ ecl_grid_dims_type * ecl_grid_dims_alloc( const char * grid_file , const char * if ((grid_file_type == ECL_GRID_FILE) || (grid_file_type == ECL_EGRID_FILE)) { fortio_type * grid_fortio = fortio_open_reader( grid_file , grid_fmt_file , ECL_ENDIAN_FLIP ); if (grid_fortio) { - grid_dims = util_malloc( sizeof * grid_dims ); + grid_dims = (ecl_grid_dims_type*)util_malloc( sizeof * grid_dims ); grid_dims->dims_list = vector_alloc_new( ); { @@ -144,6 +144,6 @@ int ecl_grid_dims_get_num_grids( const ecl_grid_dims_type * grid_dims ) { const grid_dims_type * ecl_grid_dims_iget_dims( const ecl_grid_dims_type * grid_dims , int grid_nr ) { - return vector_iget_const( grid_dims->dims_list , grid_nr ); + return (const grid_dims_type*)vector_iget_const( grid_dims->dims_list , grid_nr ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_init_file.c b/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_init_file.c rename to ThirdParty/Ert/lib/ecl/ecl_init_file.cpp index eb20dc8674..98b1ce5ba9 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_init_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_init_file.cpp @@ -31,14 +31,15 @@ */ -#include +#include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include static ecl_kw_type * ecl_init_file_alloc_INTEHEAD( const ecl_grid_type * ecl_grid , ert_ecl_unit_enum unit_system, int phases, time_t start_date , int simulator) { ecl_kw_type * intehead_kw = ecl_kw_alloc( INTEHEAD_KW , INTEHEAD_INIT_SIZE , ECL_INT ); diff --git a/ThirdParty/Ert/lib/ecl/ecl_io_config.c b/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_io_config.c rename to ThirdParty/Ert/lib/ecl/ecl_io_config.cpp index 924bc15c6b..5c5ee3a4d8 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_io_config.c +++ b/ThirdParty/Ert/lib/ecl/ecl_io_config.cpp @@ -20,10 +20,10 @@ #include #include -#include +#include -#include -#include +#include +#include /** @@ -61,7 +61,7 @@ struct ecl_io_config_struct { /*****************************************************************/ static ecl_io_config_type * ecl_io_config_alloc__() { - ecl_io_config_type * ecl_io_config = util_malloc(sizeof * ecl_io_config ); + ecl_io_config_type * ecl_io_config = (ecl_io_config_type*)util_malloc(sizeof * ecl_io_config ); ecl_io_config->formatted = FMT_UNDEFINED; ecl_io_config->unified_restart = UNIF_UNDEFINED; diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw.c b/ThirdParty/Ert/lib/ecl/ecl_kw.cpp similarity index 85% rename from ThirdParty/Ert/lib/ecl/ecl_kw.c rename to ThirdParty/Ert/lib/ecl/ecl_kw.cpp index 86cc2e75aa..8fed785eed 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw.cpp @@ -22,14 +22,15 @@ #include #include -#include -#include -#include +#include +#include +#include -#include +#include +#include #include -#include -#include +#include +#include #define ECL_KW_TYPE_ID 6111098 @@ -107,7 +108,7 @@ UTIL_IS_INSTANCE_FUNCTION(ecl_kw , ECL_KW_TYPE_ID ) 3. The logical type involves converting back and forth between 'T' and 'F' and internal logical representation. The format strings - are therefor for reading/writing a character. + are therefore for reading/writing a character. */ @@ -161,7 +162,7 @@ void ecl_kw_set_data_type(ecl_kw_type * ecl_kw, ecl_data_type data_type); static char * alloc_read_fmt_string(const ecl_data_type ecl_type) { return util_alloc_sprintf( "%%%dc", - ecl_type_get_sizeof_ctype_fortio(ecl_type) + ecl_type_get_sizeof_iotype(ecl_type) ); } @@ -190,7 +191,7 @@ static char * alloc_read_fmt(const ecl_data_type data_type ) { static char * alloc_write_fmt_string(const ecl_data_type ecl_type) { return util_alloc_sprintf( " '%%-%ds'", - ecl_type_get_sizeof_ctype_fortio(ecl_type) + ecl_type_get_sizeof_iotype(ecl_type) ); } @@ -257,12 +258,105 @@ static void ecl_kw_assert_index(const ecl_kw_type *ecl_kw , int index, const cha -static void ecl_kw_endian_convert_data(ecl_kw_type *ecl_kw) { - if (ecl_type_is_numeric(ecl_kw->data_type) || ecl_type_is_bool(ecl_kw->data_type)) - util_endian_flip_vector(ecl_kw->data , ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size); +static char * ecl_kw_alloc_output_buffer(const ecl_kw_type * ecl_kw) { + size_t sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + size_t buffer_size = ecl_kw->size * sizeof_iotype; + char * buffer = (char*)util_malloc( buffer_size ); + + if (ecl_type_is_bool(ecl_kw->data_type)) { + int * int_data = (int *) buffer; + bool * bool_data = (bool *) ecl_kw->data; + + for (int i=0; i < ecl_kw->size; i++) + if (bool_data[i]) + int_data[i] = ECL_BOOL_TRUE_INT; + else + int_data[i] = ECL_BOOL_FALSE_INT; + + util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + return buffer; + } + + + if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { + size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); + for (int i=0; i < ecl_kw->size; i++) { + size_t buffer_offset = i * sizeof_iotype; + size_t data_offset = i * sizeof_ctype; + memcpy(&buffer[buffer_offset], &ecl_kw->data[data_offset], sizeof_iotype); + } + + return buffer; + } + + if (ecl_type_is_mess(ecl_kw->data_type)) + return buffer; + + memcpy(buffer, ecl_kw->data, buffer_size); + util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + return buffer; } +static char * ecl_kw_alloc_input_buffer(const ecl_kw_type * ecl_kw) { + size_t buffer_size = ecl_kw->size * ecl_type_get_sizeof_iotype(ecl_kw->data_type); + char * buffer = (char*)util_malloc( buffer_size ); + + return buffer; +} + + +static void ecl_kw_load_from_input_buffer(ecl_kw_type * ecl_kw, char * buffer) { + size_t sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); + size_t buffer_size = ecl_kw->size * sizeof_iotype; + if (ECL_ENDIAN_FLIP) { + if (ecl_type_is_numeric(ecl_kw->data_type) || ecl_type_is_bool(ecl_kw->data_type)) + util_endian_flip_vector(buffer, sizeof_iotype, ecl_kw->size); + } + + /* + Special case bool: Return Eclipse integer representation of bool to native bool. + */ + if (ecl_type_is_bool(ecl_kw->data_type)) { + int * int_data = (int *) buffer; + bool * bool_data = (bool *) ecl_kw->data; + + for (int i=0; i < ecl_kw->size; i++) { + if (int_data[i] == ECL_BOOL_TRUE_INT) + bool_data[i] = true; + else + bool_data[i] = false; + } + return; + } + + /* + Special case: insert '\0' termination at end of strings loaded from file. + */ + if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { + const char null_char = '\0'; + for (int i=0; i < ecl_kw->size; i++) { + size_t buffer_offset = i * sizeof_iotype; + size_t data_offset = i * sizeof_ctype; + memcpy(&ecl_kw->data[data_offset], &buffer[buffer_offset], sizeof_iotype); + ecl_kw->data[data_offset + sizeof_iotype] = null_char; + } + return; + } + + if (ecl_type_is_mess(ecl_kw->data_type)) + return; + + /* + Plain int, double, float data - that can be copied straight over to the ->data field. + */ + memcpy(ecl_kw->data, buffer, buffer_size); +} + + + + const char * ecl_kw_get_header8(const ecl_kw_type *ecl_kw) { return ecl_kw->header8; } @@ -281,7 +375,7 @@ bool ecl_kw_name_equal( const ecl_kw_type * ecl_kw , const char * name) { void ecl_kw_get_memcpy_data(const ecl_kw_type *ecl_kw , void *target) { - memcpy(target , ecl_kw->data , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(target , ecl_kw->data , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } void ecl_kw_get_memcpy_int_data(const ecl_kw_type *ecl_kw , int * target) { @@ -302,14 +396,14 @@ if (ecl_type_is_double(ecl_kw->data_type)) /** Allocates a untyped buffer with exactly the same content as the ecl_kw instances data. */ void * ecl_kw_alloc_data_copy(const ecl_kw_type * ecl_kw) { - void * buffer = util_alloc_copy( ecl_kw->data , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw) ); + void * buffer = util_alloc_copy( ecl_kw->data , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type) ); return buffer; } void ecl_kw_set_memcpy_data(ecl_kw_type *ecl_kw , const void *src) { if (src != NULL) - memcpy(ecl_kw->data , src , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(ecl_kw->data , src , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } @@ -362,7 +456,7 @@ bool ecl_kw_header_eq(const ecl_kw_type *ecl_kw1 , const ecl_kw_type * ecl_kw2) } static bool ecl_kw_data_equal__( const ecl_kw_type * ecl_kw , const void * data , int cmp_elements) { - int cmp = memcmp( ecl_kw->data , data , cmp_elements * ecl_kw_get_sizeof_ctype(ecl_kw)); + int cmp = memcmp( ecl_kw->data , data , cmp_elements * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); if (cmp == 0) return true; else @@ -467,7 +561,7 @@ static void ecl_kw_set_shared_ref(ecl_kw_type * ecl_kw , void *data_ptr) { util_abort("%s: can not change to shared for keyword with allocated storage - aborting \n",__func__); } ecl_kw->shared_data = true; - ecl_kw->data = data_ptr; + ecl_kw->data = (char*)data_ptr; } @@ -483,7 +577,7 @@ static size_t ecl_kw_fortio_data_size( const ecl_kw_type * ecl_kw) { const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); return num_blocks * (4 + 4) + // Fortran fluff for each block - ecl_kw->size * ecl_type_get_sizeof_ctype_fortio( ecl_kw->data_type ); // Actual data + ecl_kw->size * ecl_type_get_sizeof_iotype( ecl_kw->data_type ); // Actual data } @@ -542,7 +636,7 @@ ecl_kw_type * ecl_kw_alloc_new_shared(const char * header , int size, ecl_data_ ecl_kw_type * ecl_kw_alloc_empty() { ecl_kw_type *ecl_kw; - ecl_kw = util_malloc(sizeof *ecl_kw ); + ecl_kw = (ecl_kw_type*)util_malloc(sizeof *ecl_kw ); ecl_kw->header = NULL; ecl_kw->header8 = NULL; ecl_kw->data = NULL; @@ -572,7 +666,7 @@ void ecl_kw_memcpy_data( ecl_kw_type * target , const ecl_kw_type * src) { if (!ecl_kw_size_and_type_equal( target , src )) util_abort("%s: type/size mismatch \n",__func__); - memcpy(target->data , src->data , target->size * ecl_kw_get_sizeof_ctype(target)); + memcpy(target->data , src->data , target->size * ecl_type_get_sizeof_ctype(target->data_type)); } @@ -588,10 +682,10 @@ void ecl_kw_memcpy(ecl_kw_type *target, const ecl_kw_type *src) { ecl_kw_type *ecl_kw_alloc_copy(const ecl_kw_type *src) { - ecl_kw_type *new; - new = ecl_kw_alloc_empty(); - ecl_kw_memcpy(new , src); - return new; + ecl_kw_type *new_; + new_ = ecl_kw_alloc_empty(); + ecl_kw_memcpy(new_ , src); + return new_; } /** @@ -636,7 +730,7 @@ ecl_kw_type * ecl_kw_alloc_slice_copy( const ecl_kw_type * src, int index1, int int target_index = 0; const char * src_ptr = src->data; char * new_ptr = new_kw->data; - int sizeof_ctype = ecl_kw_get_sizeof_ctype(new_kw); + int sizeof_ctype = ecl_type_get_sizeof_ctype(new_kw->data_type); while ( src_index < index2 ) { memcpy( &new_ptr[ target_index * sizeof_ctype ] , &src_ptr[ src_index * sizeof_ctype ] , sizeof_ctype ); @@ -657,10 +751,10 @@ void ecl_kw_resize( ecl_kw_type * ecl_kw, int new_size) { util_abort("%s: trying to allocate data for ecl_kw object which has been declared with shared storage - aborting \n",__func__); if (new_size != ecl_kw->size) { - size_t old_byte_size = ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw); - size_t new_byte_size = new_size * ecl_kw_get_sizeof_ctype(ecl_kw); + size_t old_byte_size = ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); + size_t new_byte_size = new_size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); - ecl_kw->data = util_realloc(ecl_kw->data , new_byte_size ); + ecl_kw->data = (char*)util_realloc(ecl_kw->data , new_byte_size ); if (new_byte_size > old_byte_size) { size_t offset = old_byte_size; memset(&ecl_kw->data[offset] , 0 , new_byte_size - old_byte_size); @@ -702,18 +796,19 @@ const void * ecl_kw_copyc__(const void * void_kw) { static void * ecl_kw_iget_ptr_static(const ecl_kw_type *ecl_kw , int i) { ecl_kw_assert_index(ecl_kw , i , __func__); - return &ecl_kw->data[i * ecl_kw_get_sizeof_ctype(ecl_kw)]; + return &ecl_kw->data[i * ecl_type_get_sizeof_ctype(ecl_kw->data_type)]; } static void ecl_kw_iget_static(const ecl_kw_type *ecl_kw , int i , void *iptr) { - memcpy(iptr , ecl_kw_iget_ptr_static(ecl_kw , i) , ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(iptr , ecl_kw_iget_ptr_static(ecl_kw , i) , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } static void ecl_kw_iset_static(ecl_kw_type *ecl_kw , int i , const void *iptr) { + size_t sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); ecl_kw_assert_index(ecl_kw , i , __func__); - memcpy(&ecl_kw->data[i * ecl_kw_get_sizeof_ctype(ecl_kw)] , iptr, ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(&ecl_kw->data[i * sizeof_ctype] , iptr, sizeof_ctype); } @@ -767,34 +862,20 @@ ctype ecl_kw_iget_ ## ctype(const ecl_kw_type * ecl_kw, int i) { ECL_KW_IGET_TYPED(double , ECL_DOUBLE_TYPE); ECL_KW_IGET_TYPED(float , ECL_FLOAT_TYPE); ECL_KW_IGET_TYPED(int , ECL_INT_TYPE); +ECL_KW_IGET_TYPED(bool , ECL_BOOL_TYPE); #undef ECL_KW_IGET_TYPED -bool ecl_kw_iget_bool( const ecl_kw_type * ecl_kw , int i) { - int int_value; - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - ecl_kw_iget_static(ecl_kw , i , &int_value); - if (int_value == ECL_BOOL_TRUE_INT) - return true; - else if (int_value == ECL_BOOL_FALSE_INT) - return false; - else { - util_abort("%s: fuckup - wrong integer in BOOL type \n",__func__); - return false; - } -} - const char * ecl_kw_iget_char_ptr( const ecl_kw_type * ecl_kw , int i) { if (ecl_kw_get_type(ecl_kw) != ECL_CHAR_TYPE) util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - return ecl_kw_iget_ptr( ecl_kw , i ); + return (const char *)ecl_kw_iget_ptr( ecl_kw , i ); } const char * ecl_kw_iget_string_ptr( const ecl_kw_type * ecl_kw, int i) { if (ecl_kw_get_type(ecl_kw) != ECL_STRING_TYPE) util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - return ecl_kw_iget_ptr( ecl_kw , i ); + return (const char *)ecl_kw_iget_ptr( ecl_kw , i ); } @@ -863,7 +944,7 @@ void ecl_kw_iset_string_ptr( ecl_kw_type * ecl_kw, int index, const char * s) { } size_t input_len = strlen(s); - size_t type_len = ecl_type_get_sizeof_ctype_fortio(ecl_kw_get_data_type(ecl_kw)); + size_t type_len = ecl_type_get_sizeof_iotype(ecl_kw->data_type); if(input_len > type_len) util_abort("%s: String of length %d cannot hold input string of length %d\n", __func__, type_len, input_len); @@ -891,9 +972,9 @@ void ecl_kw_iset_string_ptr( ecl_kw_type * ecl_kw, int index, const char * s) { */ bool ecl_kw_icmp_string( const ecl_kw_type * ecl_kw , int index, const char * other_string) { - const char * kw_string = ecl_kw_iget_char_ptr( ecl_kw , index ); + const char * kw_string = (const char *)ecl_kw_iget_char_ptr( ecl_kw , index ); if (strlen(other_string)) { - char * match = strstr( kw_string , other_string); + const char * match = strstr( kw_string , other_string); if (match == kw_string) return true; } @@ -913,6 +994,7 @@ void ecl_kw_iset_ ## ctype(ecl_kw_type * ecl_kw, int i, ctype value) { ECL_KW_ISET_TYPED(double , ECL_DOUBLE_TYPE); ECL_KW_ISET_TYPED(float , ECL_FLOAT_TYPE); ECL_KW_ISET_TYPED(int , ECL_INT_TYPE); +ECL_KW_ISET_TYPED(bool , ECL_BOOL_TYPE); #undef ECL_KW_ISET_TYPED @@ -977,20 +1059,6 @@ ECL_KW_SCALE_INDEXED( int , ECL_INT_TYPE); #undef ECL_KW_SCALE_INDEXED -void ecl_kw_iset_bool( ecl_kw_type * ecl_kw , int i , bool bool_value) { - int int_value; - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - - if (bool_value) - int_value = ECL_BOOL_TRUE_INT; - else - int_value = ECL_BOOL_FALSE_INT; - - ecl_kw_iset_static(ecl_kw , i , &int_value); -} - - /*****************************************************************/ /* Various ways to get pointers to the underlying data. */ @@ -1005,6 +1073,7 @@ ctype * ecl_kw_get_ ## ctype ## _ptr(const ecl_kw_type * ecl_kw) { ECL_KW_GET_TYPED_PTR(double , ECL_DOUBLE_TYPE); ECL_KW_GET_TYPED_PTR(float , ECL_FLOAT_TYPE); ECL_KW_GET_TYPED_PTR(int , ECL_INT_TYPE); +ECL_KW_GET_TYPED_PTR(bool , ECL_BOOL_TYPE); #undef ECL_KW_GET_TYPED_PTR void * ecl_kw_get_void_ptr(const ecl_kw_type * ecl_kw) { @@ -1090,7 +1159,6 @@ static double __fscanf_ECL_double( FILE * stream , const char * fmt) { } bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { - const char null_char = '\0'; bool fmt_file = fortio_fmt_file( fortio ); if (ecl_kw->size > 0) { const int blocksize = get_blocksize( ecl_kw->data_type ); @@ -1112,7 +1180,7 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { ecl_kw_fscanf_qstring( &ecl_kw->data[offset], read_fmt, - ecl_type_get_sizeof_ctype_fortio(ecl_kw_get_data_type(ecl_kw)), + ecl_type_get_sizeof_iotype(ecl_kw_get_data_type(ecl_kw)), stream ); break; @@ -1120,16 +1188,19 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { { int iread = fscanf(stream , read_fmt , (int *) &ecl_kw->data[offset]); if (iread != 1) - util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , offset / ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->header8 , fortio_filename_ref(fortio)); + util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__, + offset / ecl_type_get_sizeof_ctype(ecl_kw->data_type), + ecl_kw->header8, + fortio_filename_ref(fortio)); } break; case(ECL_FLOAT_TYPE): { int iread = fscanf(stream , read_fmt , (float *) &ecl_kw->data[offset]); if (iread != 1) { - util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__ , - offset / ecl_kw_get_sizeof_ctype(ecl_kw) , - ecl_kw->header8 , + util_abort("%s: after reading %d values reading of keyword:%s from:%s failed - aborting \n",__func__, + offset / ecl_type_get_sizeof_ctype(ecl_kw->data_type), + ecl_kw->header8, fortio_filename_ref(fortio)); } } @@ -1160,7 +1231,7 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { default: util_abort("%s: Internal error: internal eclipse_type: %d not recognized - aborting \n",__func__ , ecl_kw_get_type(ecl_kw)); } - offset += ecl_kw_get_sizeof_ctype(ecl_kw); + offset += ecl_type_get_sizeof_ctype(ecl_kw->data_type); index++; } } @@ -1170,46 +1241,14 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { free(read_fmt); return true; } else { - bool read_ok = true; - if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { - const int blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); - int ib = 0; - while (true) { - /* - Due to the necessary terminating \0 characters there is - not a continous file/memory mapping. - */ - int read_elm = util_int_min((ib + 1) * blocksize , ecl_kw->size) - ib * blocksize; - FILE * stream = fortio_get_FILE(fortio); - int record_size = fortio_init_read(fortio); - if (record_size >= 0) { - int ir; - const int sizeof_ctype = ecl_type_get_sizeof_ctype(ecl_kw->data_type); - const int sizeof_ctype_fortio = ecl_type_get_sizeof_ctype_fortio(ecl_kw->data_type); - for (ir = 0; ir < read_elm; ir++) { - util_fread( &ecl_kw->data[(ib * blocksize + ir) * sizeof_ctype] , 1 , sizeof_ctype_fortio , stream , __func__); - ecl_kw->data[(ib * blocksize + ir) * sizeof_ctype + sizeof_ctype_fortio] = null_char; - } - read_ok = fortio_complete_read(fortio , record_size); - } else - read_ok = false; + char * buffer = ecl_kw_alloc_input_buffer(ecl_kw); + const int sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); + bool read_ok = fortio_fread_buffer(fortio, buffer, ecl_kw->size * sizeof_iotype); - if (!read_ok) - break; + if (read_ok) + ecl_kw_load_from_input_buffer(ecl_kw, buffer); - ib++; - if (ib == blocks) - break; - } - } else { - /** - This function handles the fuc***g blocks transparently at a - low level. - */ - read_ok = fortio_fread_buffer(fortio , ecl_kw->data , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); - if (read_ok && ECL_ENDIAN_FLIP) - ecl_kw_endian_convert_data(ecl_kw); - } + free(buffer); return read_ok; } } else @@ -1218,30 +1257,24 @@ bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { } -void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ecl_data_type data_type, int element_count, const int_vector_type* index_map, char* buffer) { +void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ecl_data_type data_type, int element_count, const int_vector_type* index_map, char* io_buffer) { const int block_size = get_blocksize(data_type); FILE *stream = fortio_get_FILE( fortio ); int index; - int element_size = ecl_type_get_sizeof_ctype(data_type); - - if(ecl_type_is_char(data_type) || ecl_type_is_mess(data_type)) { - element_size = ECL_STRING8_LENGTH; - } - + int sizeof_iotype = ecl_type_get_sizeof_iotype(data_type); for(index = 0; index < int_vector_size(index_map); index++) { int element_index = int_vector_iget(index_map, index); - if(element_index < 0 || element_index >= element_count) { + if(element_index < 0 || element_index >= element_count) util_abort("%s: Element index is out of range 0 <= %d < %d\n", __func__, element_index, element_count); - } - fortio_data_fseek(fortio, data_offset, element_index, element_size, element_count, block_size); - util_fread(&buffer[index * element_size], element_size, 1, stream, __func__); - } - if (ECL_ENDIAN_FLIP) { - util_endian_flip_vector(buffer, element_size, int_vector_size(index_map)); + fortio_data_fseek(fortio, data_offset, element_index, sizeof_iotype, element_count, block_size); + util_fread(&io_buffer[index * sizeof_iotype], sizeof_iotype, 1, stream, __func__); } + + if (ECL_ENDIAN_FLIP) + util_endian_flip_vector(io_buffer, sizeof_iotype, int_vector_size(index_map)); } /** @@ -1271,7 +1304,7 @@ bool ecl_kw_fskip_data__( ecl_data_type data_type , const int element_count , fo } else { const int blocksize = get_blocksize( data_type ); const int block_count = element_count / blocksize + (element_count % blocksize != 0); - int element_size = ecl_type_get_sizeof_ctype_fortio(data_type); + int element_size = ecl_type_get_sizeof_iotype(data_type); if(!fortio_data_fskip(fortio, element_size, element_count, block_count)) return false; @@ -1289,7 +1322,7 @@ bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio) { /** This function will skip the header part of an ecl_kw instance. The function will read the file content at the current position, it is - therefor essential that the file pointer is positioned at the + therefore essential that the file pointer is positioned at the beginning of a keyword when this function is called; otherwise it will be complete crash and burn. */ @@ -1451,7 +1484,7 @@ bool ecl_kw_fseek_last_kw(const char * kw , bool abort_on_error , fortio_type *f void ecl_kw_set_data_ptr(ecl_kw_type * ecl_kw , void * data) { if (!ecl_kw->shared_data) util_safe_free( ecl_kw->data ); - ecl_kw->data = data; + ecl_kw->data = (char*)data; } @@ -1463,8 +1496,8 @@ void ecl_kw_alloc_data(ecl_kw_type *ecl_kw) { util_abort("%s: trying to allocate data for ecl_kw object which has been declared with shared storage - aborting \n",__func__); { - size_t byte_size = ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw); - ecl_kw->data = util_realloc(ecl_kw->data , byte_size ); + size_t byte_size = ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type); + ecl_kw->data = (char*)util_realloc(ecl_kw->data , byte_size ); memset(ecl_kw->data , 0 , byte_size); } } @@ -1481,7 +1514,7 @@ void ecl_kw_free_data(ecl_kw_type *ecl_kw) { void ecl_kw_set_header_name(ecl_kw_type * ecl_kw , const char * header) { - ecl_kw->header8 = realloc(ecl_kw->header8 , ECL_STRING8_LENGTH + 1); + ecl_kw->header8 = (char*)realloc(ecl_kw->header8 , ECL_STRING8_LENGTH + 1); if (strlen(header) <= 8) { sprintf(ecl_kw->header8 , "%-8s" , header); @@ -1490,7 +1523,7 @@ void ecl_kw_set_header_name(ecl_kw_type * ecl_kw , const char * header) { ecl_kw->header = util_alloc_strip_copy( ecl_kw->header8 ); } else { - ecl_kw->header = util_alloc_copy(header, strlen( header ) + 1); + ecl_kw->header = (char*)util_alloc_copy(header, strlen( header ) + 1); } } @@ -1544,10 +1577,9 @@ void ecl_kw_fskip(fortio_type *fortio) { -static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * fortio ) { - if (ECL_ENDIAN_FLIP) - ecl_kw_endian_convert_data(ecl_kw); - +static void ecl_kw_fwrite_data_unformatted( const ecl_kw_type * ecl_kw , fortio_type * fortio ) { + char * iobuffer = ecl_kw_alloc_output_buffer(ecl_kw); + int sizeof_iotype = ecl_type_get_sizeof_iotype(ecl_kw->data_type); { const int blocksize = get_blocksize( ecl_kw->data_type ); const int num_blocks = ecl_kw->size / blocksize + (ecl_kw->size % blocksize == 0 ? 0 : 1); @@ -1555,29 +1587,11 @@ static void ecl_kw_fwrite_data_unformatted( ecl_kw_type * ecl_kw , fortio_type * for (block_nr = 0; block_nr < num_blocks; block_nr++) { int this_blocksize = util_int_min((block_nr + 1)*blocksize , ecl_kw->size) - block_nr*blocksize; - if (ecl_type_is_char(ecl_kw->data_type) || ecl_type_is_mess(ecl_kw->data_type) || ecl_type_is_string(ecl_kw->data_type)) { - /* - Due to the terminating \0 characters there is not a - continous file/memory mapping - the \0 characters arel - skipped. - */ - FILE *stream = fortio_get_FILE(fortio); - int word_size = ecl_type_get_sizeof_ctype_fortio(ecl_kw->data_type); - int record_size = this_blocksize * word_size; /* The total size in bytes of the record written by the fortio layer. */ - int i; - fortio_init_write(fortio , record_size ); - for (i = 0; i < this_blocksize; i++) - fwrite(&ecl_kw->data[(block_nr * blocksize + i) * ecl_kw_get_sizeof_ctype(ecl_kw)] , 1 , word_size , stream); - fortio_complete_write(fortio , record_size); - } else { - int record_size = this_blocksize * ecl_kw_get_sizeof_ctype(ecl_kw); /* The total size in bytes of the record written by the fortio layer. */ - fortio_fwrite_record(fortio , &ecl_kw->data[block_nr * blocksize * ecl_kw_get_sizeof_ctype(ecl_kw)] , record_size); - } + int record_size = this_blocksize * sizeof_iotype; /* The total size in bytes of the record written by the fortio layer. */ + fortio_fwrite_record(fortio , &iobuffer[block_nr * blocksize * sizeof_iotype] , record_size); } } - - if (ECL_ENDIAN_FLIP) - ecl_kw_endian_convert_data(ecl_kw); + free(iobuffer); } @@ -1760,10 +1774,6 @@ ecl_data_type ecl_kw_get_data_type(const ecl_kw_type * ecl_kw) { return ecl_kw->data_type; } -size_t ecl_kw_get_sizeof_ctype(const ecl_kw_type * ecl_kw) { - return ecl_type_get_sizeof_ctype(ecl_kw->data_type); -} - /******************************************************************/ @@ -1771,14 +1781,14 @@ size_t ecl_kw_get_sizeof_ctype(const ecl_kw_type * ecl_kw) { ecl_kw_type * ecl_kw_buffer_alloc(buffer_type * buffer) { const char * header = buffer_fread_string( buffer ); int size = buffer_fread_int( buffer ); - ecl_type_enum ecl_type = buffer_fread_int( buffer ); + ecl_type_enum ecl_type = (ecl_type_enum)buffer_fread_int( buffer ); size_t element_size = buffer_fread_int( buffer ); ecl_data_type data_type = ecl_type_create(ecl_type, element_size); ecl_kw_type * ecl_kw = ecl_kw_alloc_empty(); ecl_kw_initialize( ecl_kw , header , size , data_type ); ecl_kw_alloc_data(ecl_kw); - buffer_fread(buffer , ecl_kw->data , ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size); + buffer_fread(buffer , ecl_kw->data , ecl_type_get_sizeof_ctype(ecl_kw->data_type) , ecl_kw->size); return ecl_kw; } @@ -1788,7 +1798,7 @@ void ecl_kw_buffer_store(const ecl_kw_type * ecl_kw , buffer_type * buffer) { buffer_fwrite_int( buffer , ecl_kw->size ); buffer_fwrite_int( buffer , ecl_type_get_type(ecl_kw->data_type) ); buffer_fwrite_int( buffer , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); - buffer_fwrite( buffer , ecl_kw->data , ecl_kw_get_sizeof_ctype(ecl_kw) , ecl_kw->size); + buffer_fwrite( buffer , ecl_kw->data , ecl_type_get_sizeof_ctype(ecl_kw->data_type) , ecl_kw->size); } @@ -1876,7 +1886,7 @@ ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target int default_int = 0; double default_double = 0; float default_float = 0; - int default_bool = ECL_BOOL_FALSE_INT; + bool default_bool = false; const char * default_char = ""; ecl_kw_type * new_kw = ecl_kw_alloc( src_kw->header , target_size , src_kw->data_type ); @@ -1917,6 +1927,38 @@ ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target return new_kw; } +ecl_kw_type * ecl_kw_alloc_global_copy(const ecl_kw_type * src, const ecl_kw_type * actnum) { + if (ecl_kw_get_type(actnum) != ECL_INT_TYPE) + return NULL; + + const int global_size = ecl_kw_get_size(actnum); + ecl_kw_type * global_copy = ecl_kw_alloc( ecl_kw_get_header(src), global_size, src->data_type); + const int * mapping = ecl_kw_get_int_ptr(actnum); + const int src_size = ecl_kw_get_size(src); + int src_index = 0; + for (int global_index=0; global_index < global_size; global_index++) { + if (mapping[global_index]) { + /* We ran through and beyond the size of the src keyword. */ + if (src_index >= src_size) { + ecl_kw_free(global_copy); + global_copy = NULL; + break; + } + const void * value_ptr = ecl_kw_iget_ptr(src, src_index); + ecl_kw_iset_static(global_copy, global_index, value_ptr); + src_index++; + } + } + + /* Not all the src data was distributed. */ + if (src_index < src_size) { + ecl_kw_free(global_copy); + global_copy = NULL; + } + + return global_copy; +} + void ecl_kw_fread_double_param(const char * filename , bool fmt_file , double * double_data) { @@ -1949,7 +1991,7 @@ void ecl_kw_summarize(const ecl_kw_type * ecl_kw) { #define ECL_KW_SCALAR_SET_TYPED( ctype , ECL_TYPE ) \ void ecl_kw_scalar_set_ ## ctype( ecl_kw_type * ecl_kw , ctype value){ \ if (ecl_kw_get_type(ecl_kw) == ECL_TYPE) { \ - ctype * data = ecl_kw_get_data_ref(ecl_kw); \ + ctype * data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ int i; \ for (i=0;i < ecl_kw->size; i++) \ data[i] = value; \ @@ -1959,26 +2001,9 @@ void ecl_kw_scalar_set_ ## ctype( ecl_kw_type * ecl_kw , ctype value){ \ ECL_KW_SCALAR_SET_TYPED( int , ECL_INT_TYPE ) ECL_KW_SCALAR_SET_TYPED( float , ECL_FLOAT_TYPE ) ECL_KW_SCALAR_SET_TYPED( double , ECL_DOUBLE_TYPE ) +ECL_KW_SCALAR_SET_TYPED( bool , ECL_BOOL_TYPE ) #undef ECL_KW_SCALAR_SET_TYPED -void ecl_kw_scalar_set_bool( ecl_kw_type * ecl_kw , bool bool_value) { - if (ecl_kw_get_type(ecl_kw) != ECL_BOOL_TYPE) - util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); - { - int * data = ecl_kw_get_data_ref(ecl_kw); - int int_value; - if (bool_value) - int_value = ECL_BOOL_TRUE_INT; - else - int_value = ECL_BOOL_FALSE_INT; - { - int i; - for ( i=0; i < ecl_kw->size; i++) - data[i] = int_value; - } - } -} - void ecl_kw_scalar_set_float_or_double( ecl_kw_type * ecl_kw , double value ) { ecl_type_enum ecl_type = ecl_kw_get_type(ecl_kw); @@ -2007,12 +2032,12 @@ void ecl_kw_scalar_set__(ecl_kw_type * ecl_kw , const void * value) { void ecl_kw_alloc_double_data(ecl_kw_type * ecl_kw , double * values) { ecl_kw_alloc_data(ecl_kw); - memcpy(ecl_kw->data , values , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(ecl_kw->data , values , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } void ecl_kw_alloc_float_data(ecl_kw_type * ecl_kw , float * values) { ecl_kw_alloc_data(ecl_kw); - memcpy(ecl_kw->data , values , ecl_kw->size * ecl_kw_get_sizeof_ctype(ecl_kw)); + memcpy(ecl_kw->data , values , ecl_kw->size * ecl_type_get_sizeof_ctype(ecl_kw->data_type)); } /*****************************************************************/ @@ -2023,7 +2048,7 @@ void ecl_kw_scale_ ## ctype (ecl_kw_type * ecl_kw , ctype scale_factor) { if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); \ { \ - ctype * data = ecl_kw_get_data_ref(ecl_kw); \ + ctype * data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ int size = ecl_kw_get_size(ecl_kw); \ int i; \ for (i=0; i < size; i++) \ @@ -2052,7 +2077,7 @@ void ecl_kw_shift_ ## ctype (ecl_kw_type * ecl_kw , ctype shift_value) { if (ecl_kw_get_type(ecl_kw) != ECL_TYPE) \ util_abort("%s: Keyword: %s is wrong type - aborting \n",__func__ , ecl_kw_get_header8(ecl_kw)); \ { \ - ctype * data = ecl_kw_get_data_ref(ecl_kw); \ + ctype * data = (ctype *)ecl_kw_get_data_ref(ecl_kw); \ int size = ecl_kw_get_size(ecl_kw); \ int i; \ for (i=0; i < size; i++) \ @@ -2101,8 +2126,8 @@ void ecl_kw_copy_indexed( ecl_kw_type * target_kw , const int_vector_type * inde if (!ecl_kw_size_and_type_equal( target_kw , src_kw )) util_abort("%s: type/size mismatch\n",__func__); { - char * target_data = ecl_kw_get_data_ref( target_kw ); - const char * src_data = ecl_kw_get_data_ref( src_kw ); + char * target_data = (char *)ecl_kw_get_data_ref( target_kw ); + const char * src_data = (const char *)ecl_kw_get_data_ref( src_kw ); int sizeof_ctype = ecl_type_get_sizeof_ctype(target_kw->data_type); int set_size = int_vector_size( index_set ); const int * index_data = int_vector_get_const_ptr( index_set ); @@ -2121,8 +2146,8 @@ static void ecl_kw_inplace_add_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * add_data = ecl_kw_get_data_ref( add_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = (const ctype *)ecl_kw_get_data_ref( add_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2164,8 +2189,8 @@ static void ecl_kw_inplace_add_ ## ctype( ecl_kw_type * target_kw , const ecl_kw if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * add_data = ecl_kw_get_data_ref( add_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = (const ctype *)ecl_kw_get_data_ref( add_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] += add_data[i]; \ @@ -2194,6 +2219,41 @@ void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) { } } +#define ECL_KW_TYPED_INPLACE_ADD_SQUARED( ctype ) \ +static void ecl_kw_inplace_add_squared_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) { \ + if (!ecl_kw_assert_binary_ ## ctype( target_kw , add_kw )) \ + util_abort("%s: type/size mismatch\n",__func__); \ + { \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * add_data = (const ctype *)ecl_kw_get_data_ref( add_kw ); \ + int i; \ + for (i=0; i < target_kw->size; i++) \ + target_data[i] += add_data[i] * add_data[i]; \ + } \ +} +ECL_KW_TYPED_INPLACE_ADD_SQUARED( int ) +ECL_KW_TYPED_INPLACE_ADD_SQUARED( double ) +ECL_KW_TYPED_INPLACE_ADD_SQUARED( float ) + +#undef ECL_KW_TYPED_INPLACE_ADD + +void ecl_kw_inplace_add_squared( ecl_kw_type * target_kw , const ecl_kw_type * add_kw) { + ecl_type_enum type = ecl_kw_get_type(target_kw); + switch (type) { + case(ECL_FLOAT_TYPE): + ecl_kw_inplace_add_squared_float( target_kw , add_kw ); + break; + case(ECL_DOUBLE_TYPE): + ecl_kw_inplace_add_squared_double( target_kw , add_kw ); + break; + case(ECL_INT_TYPE): + ecl_kw_inplace_add_squared_int( target_kw , add_kw ); + break; + default: + util_abort("%s: inplace add not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(target_kw) )); + } +} + @@ -2204,8 +2264,8 @@ void ecl_kw_inplace_sub_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * if (!ecl_kw_assert_binary_ ## ctype( target_kw , sub_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * sub_data = ecl_kw_get_data_ref( sub_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * sub_data = (const ctype *)ecl_kw_get_data_ref( sub_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] -= sub_data[i]; \ @@ -2238,8 +2298,8 @@ static void ecl_kw_inplace_sub_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , sub_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * sub_data = ecl_kw_get_data_ref( sub_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * sub_data = (const ctype *)ecl_kw_get_data_ref( sub_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2278,7 +2338,7 @@ void ecl_kw_inplace_sub_indexed( ecl_kw_type * target_kw , const int_vector_type #define ECL_KW_TYPED_INPLACE_ABS( ctype , abs_func) \ void ecl_kw_inplace_abs_ ## ctype( ecl_kw_type * kw ) { \ - ctype * data = ecl_kw_get_data_ref( kw ); \ + ctype * data = (ctype *)ecl_kw_get_data_ref( kw ); \ int i; \ for (i=0; i < kw->size; i++) \ data[i] = abs_func(data[i]); \ @@ -2310,14 +2370,53 @@ void ecl_kw_inplace_abs( ecl_kw_type * kw ) { /*****************************************************************/ +static int sqrti(int x) { + return round( sqrt(x) ); +} + +#define ECL_KW_TYPED_INPLACE_SQRT( ctype, sqrt_func ) \ +void ecl_kw_inplace_sqrt_ ## ctype( ecl_kw_type * kw ) { \ + ctype * data = (ctype *)ecl_kw_get_data_ref( kw ); \ + int i; \ + for (i=0; i < kw->size; i++) \ + data[i] = sqrt_func(data[i]); \ +} + +ECL_KW_TYPED_INPLACE_SQRT( double , sqrt ) +ECL_KW_TYPED_INPLACE_SQRT( float , sqrtf ) +ECL_KW_TYPED_INPLACE_SQRT( int, sqrti) +#undef ECL_KW_TYPED_INPLACE_SQRT + + + +void ecl_kw_inplace_sqrt( ecl_kw_type * kw ) { + ecl_type_enum type = ecl_kw_get_type(kw); + switch (type) { + case(ECL_FLOAT_TYPE): + ecl_kw_inplace_sqrt_float( kw ); + break; + case(ECL_DOUBLE_TYPE): + ecl_kw_inplace_sqrt_double( kw ); + break; + case(ECL_INT_TYPE): + ecl_kw_inplace_sqrt_int( kw ); + break; + default: + util_abort("%s: inplace sqrt not implemented for type:%s \n",__func__ , ecl_type_alloc_name( ecl_kw_get_data_type(kw) )); + } +} + + +/*****************************************************************/ + #define ECL_KW_TYPED_INPLACE_MUL( ctype ) \ void ecl_kw_inplace_mul_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * mul_kw) { \ if (!ecl_kw_assert_binary_ ## ctype( target_kw , mul_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * mul_data = ecl_kw_get_data_ref( mul_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * mul_data = (const ctype *)ecl_kw_get_data_ref( mul_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] *= mul_data[i]; \ @@ -2350,8 +2449,8 @@ static void ecl_kw_inplace_mul_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , mul_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * mul_data = ecl_kw_get_data_ref( mul_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * mul_data = (const ctype *)ecl_kw_get_data_ref( mul_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2394,8 +2493,8 @@ void ecl_kw_inplace_div_ ## ctype( ecl_kw_type * target_kw , const ecl_kw_type * if (!ecl_kw_assert_binary_ ## ctype( target_kw , div_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * div_data = ecl_kw_get_data_ref( div_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * div_data = (const ctype *)ecl_kw_get_data_ref( div_kw ); \ int i; \ for (i=0; i < target_kw->size; i++) \ target_data[i] /= div_data[i]; \ @@ -2429,8 +2528,8 @@ static void ecl_kw_inplace_div_indexed_ ## ctype( ecl_kw_type * target_kw , cons if (!ecl_kw_assert_binary_ ## ctype( target_kw , div_kw )) \ util_abort("%s: type/size mismatch\n",__func__); \ { \ - ctype * target_data = ecl_kw_get_data_ref( target_kw ); \ - const ctype * div_data = ecl_kw_get_data_ref( div_kw ); \ + ctype * target_data = (ctype *)ecl_kw_get_data_ref( target_kw ); \ + const ctype * div_data = (const ctype *)ecl_kw_get_data_ref( div_kw ); \ int set_size = int_vector_size( index_set ); \ const int * index_data = int_vector_get_const_ptr( index_set ); \ int i; \ @@ -2468,6 +2567,23 @@ void ecl_kw_inplace_div_indexed( ecl_kw_type * target_kw , const int_vector_type } +bool ecl_kw_inplace_safe_div(ecl_kw_type * target_kw, const ecl_kw_type * divisor) { + if (ecl_kw_get_type(target_kw) != ECL_FLOAT_TYPE) + return false; + + if (ecl_kw_get_type(divisor) != ECL_INT_TYPE) + return false; + + float * target_data = (float*)ecl_kw_get_data_ref( target_kw ); + const int* div_data = (const int*)ecl_kw_get_data_ref( divisor ); + for (int i=0; i < target_kw->size; i++) { + if (div_data[i] != 0) + target_data[i] /= div_data[i]; + } + + return true; +} + @@ -2561,14 +2677,14 @@ bool ecl_kw_is_kw_file(fortio_type * fortio) { #define KW_MAX_MIN(type) \ { \ - type * data = ecl_kw_get_data_ref(ecl_kw); \ + type * data = (type*)ecl_kw_get_data_ref(ecl_kw); \ type max = data[0]; \ type min = data[0]; \ int i; \ for (i=1; i < ecl_kw_get_size(ecl_kw); i++) \ util_update_ ## type ## _max_min(data[i] , &max , &min); \ - memcpy(_max , &max , ecl_kw_get_sizeof_ctype(ecl_kw)); \ - memcpy(_min , &min , ecl_kw_get_sizeof_ctype(ecl_kw)); \ + memcpy(_max , &max , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ + memcpy(_min , &min , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ } @@ -2629,13 +2745,13 @@ ECL_KW_MIN( double ) #define KW_SUM_INDEXED(type) \ { \ - const type * data = ecl_kw_get_data_ref(ecl_kw); \ + const type * data = (const type *)ecl_kw_get_data_ref(ecl_kw); \ type sum = 0; \ int size = int_vector_size( index_list ); \ const int * index_ptr = int_vector_get_const_ptr( index_list ); \ for (int i = 0; i < size; i++) \ sum += data[index_ptr[i]]; \ - memcpy(_sum , &sum , ecl_kw_get_sizeof_ctype(ecl_kw)); \ + memcpy(_sum , &sum , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ } @@ -2652,12 +2768,12 @@ void ecl_kw_element_sum_indexed(const ecl_kw_type * ecl_kw , const int_vector_ty break; case(ECL_BOOL_TYPE): { - const int * data = ecl_kw_get_data_ref(ecl_kw); + const bool * data = (const bool *)ecl_kw_get_data_ref(ecl_kw); const int * index_ptr = int_vector_get_const_ptr( index_list ); const int size = int_vector_size( index_list ); int sum = 0; for (int i = 0; i < size; i++) - sum += (data[index_ptr[i]] == ECL_BOOL_TRUE_INT); + sum += (data[index_ptr[i]]); memcpy(_sum , &sum , sizeof sum); } @@ -2677,11 +2793,11 @@ void ecl_kw_element_sum_indexed(const ecl_kw_type * ecl_kw , const int_vector_ty #define KW_SUM(type) \ { \ - const type * data = ecl_kw_get_data_ref(ecl_kw); \ + const type * data = (const type *)ecl_kw_get_data_ref(ecl_kw); \ type sum = 0; \ for (int i=0; i < ecl_kw_get_size(ecl_kw); i++) \ sum += data[i]; \ - memcpy(_sum , &sum , ecl_kw_get_sizeof_ctype(ecl_kw)); \ + memcpy(_sum , &sum , ecl_type_get_sizeof_ctype(ecl_kw->data_type)); \ } @@ -2748,24 +2864,13 @@ static void ecl_kw_fprintf_data_ ## ctype(const ecl_kw_type * ecl_kw , const cha ECL_KW_FPRINTF_DATA( int ) ECL_KW_FPRINTF_DATA( float ) ECL_KW_FPRINTF_DATA( double ) +ECL_KW_FPRINTF_DATA( bool ) #undef ECL_KW_FPRINTF_DATA -static void ecl_kw_fprintf_data_bool( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) { - const int * data = (const int *) ecl_kw->data; - int i; - for (i=0; i < ecl_kw->size; i++) { - if (data[i] == ECL_BOOL_TRUE_INT) - fprintf(stream , fmt , 1); - else - fprintf(stream , fmt , 0); - } -} - - static void ecl_kw_fprintf_data_string( const ecl_kw_type * ecl_kw , const char * fmt , FILE * stream) { int i; for (i=0; i < ecl_kw->size; i++) - fprintf(stream , fmt , &ecl_kw->data[ i * ecl_kw_get_sizeof_ctype(ecl_kw)]); + fprintf(stream , fmt , &ecl_kw->data[ i * ecl_type_get_sizeof_ctype(ecl_kw->data_type)]); } @@ -2792,8 +2897,8 @@ static bool ecl_kw_elm_equal_numeric__( const ecl_kw_type * ecl_kw1 , const ecl_ static bool ecl_kw_elm_equal__( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ecl_kw2 , int offset) { - size_t data_offset = ecl_kw_get_sizeof_ctype(ecl_kw1) * offset; - int cmp = memcmp( &ecl_kw1->data[ data_offset ] , &ecl_kw2->data[ data_offset ] , ecl_kw_get_sizeof_ctype(ecl_kw1)); + size_t data_offset = ecl_type_get_sizeof_ctype(ecl_kw1->data_type) * offset; + int cmp = memcmp( &ecl_kw1->data[ data_offset ] , &ecl_kw2->data[ data_offset ] , ecl_type_get_sizeof_ctype(ecl_kw1->data_type)); if (cmp == 0) return true; else @@ -2832,4 +2937,4 @@ int ecl_kw_first_different( const ecl_kw_type * ecl_kw1 , const ecl_kw_type * ec } } -#include "ecl_kw_functions.c" +#include "ecl_kw_functions.cpp" diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c b/ThirdParty/Ert/lib/ecl/ecl_kw_functions.cpp similarity index 83% rename from ThirdParty/Ert/lib/ecl/ecl_kw_functions.c rename to ThirdParty/Ert/lib/ecl/ecl_kw_functions.cpp index 1737b808ff..d10646fd33 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_functions.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_functions.cpp @@ -23,7 +23,7 @@ void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, const int * actnum) { int i,j,k; - int * data = ecl_kw_get_ptr( ecl_kw ); + int * data = (int*)ecl_kw_get_ptr( ecl_kw ); int_vector_type * undetermined1 = int_vector_alloc(0,0); int_vector_type * undetermined2 = int_vector_alloc(0,0); @@ -128,3 +128,27 @@ void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, c int_vector_free( undetermined1 ); int_vector_free( undetermined2 ); } + + + +ecl_kw_type * ecl_kw_alloc_actnum(const ecl_kw_type * porv_kw, float porv_limit) { + if (!ecl_type_is_float( porv_kw->data_type)) + return NULL; + + if (!util_string_equal(PORV_KW, ecl_kw_get_header(porv_kw))) + return NULL; + + const int size = ecl_kw_get_size(porv_kw); + ecl_kw_type * actnum_kw = ecl_kw_alloc(ACTNUM_KW, size, ECL_INT); + const float * porv_values = ecl_kw_get_float_ptr(porv_kw); + int * actnum_values = ecl_kw_get_int_ptr( actnum_kw); + + for (int i=0; i < size; i++) { + if (porv_values[i] > porv_limit) + actnum_values[i] = 1; + else + actnum_values[i] = 0; + } + + return actnum_kw; +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c rename to ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp index 8149fca1dd..fc51a42e8d 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.c +++ b/ThirdParty/Ert/lib/ecl/ecl_kw_grdecl.cpp @@ -19,11 +19,11 @@ #include #include -#include +#include -#include -#include -#include +#include +#include +#include #define MAX_GRDECL_HEADER_SIZE 512 @@ -42,7 +42,7 @@ b) There is not type information; presented with a bunch of formatted numbers it is in general impossible to determine whether the underlying datatype should be integer, float or - double. Therefor all the file-reading routines here expect an + double. Therefore all the file-reading routines here expect an ecl_data_type as input. 2. The files can have comment sections; even in the data block. @@ -159,7 +159,7 @@ char * ecl_kw_grdecl_alloc_next_header( FILE * stream ) { This function will search through a GRDECL file to look for the 'kw'; input variables and return vales are similar to ecl_kw_fseek_kw(). Observe that the GRDECL files are extremely - weakly structured, it is therefor veeeery easy to fool this function + weakly structured, it is therefore veeeery easy to fool this function with a malformed GRDECL file. In particular the comparison is case sensitive; that is probably not @@ -260,8 +260,8 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ int data_index = 0; int sizeof_ctype = ecl_type_get_sizeof_ctype( data_type ); int data_size = init_size; - char * buffer = util_calloc( (buffer_size + 1) , sizeof * buffer ); - char * data = util_calloc( sizeof_ctype * data_size , sizeof * data ); + char * buffer = (char*)util_calloc( (buffer_size + 1) , sizeof * buffer ); + char * data = (char*)util_calloc( sizeof_ctype * data_size , sizeof * data ); while (true) { if (fscanf(stream , "%32s" , buffer) == 1) { @@ -347,7 +347,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ data_size = util_size_t_min( ECL_KW_MAX_SIZE , 2*(data_index + multiplier)); byte_size *= data_size; - data = util_realloc( data , byte_size ); + data = (char*)util_realloc( data , byte_size ); } else { /* We are asking for more elements than can possible be adressed in @@ -371,7 +371,7 @@ static char * fscanf_alloc_grdecl_data( const char * header , bool strict , ecl_ } free( buffer ); *kw_size = data_index; - data = util_realloc( data , sizeof_ctype * data_index * sizeof * data ); + data = (char*)util_realloc( data , sizeof_ctype * data_index * sizeof * data ); return data; } diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_data.c b/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_nnc_data.c rename to ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp index c96f9c202c..ca35f63fb8 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_data.c +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_data.cpp @@ -18,12 +18,12 @@ #define ECL_NNC_DATA_TYPE_ID 83756236 -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include enum kw_data_type { TRANS_DATA = 1, @@ -211,12 +211,12 @@ static bool ecl_nnc_data_set_values(ecl_nnc_data_type * data, const ecl_grid_typ } static ecl_nnc_data_type * ecl_nnc_data_alloc__(const ecl_grid_type * grid, const ecl_nnc_geometry_type * nnc_geo, const ecl_file_view_type * init_file, int kw_type) { - ecl_nnc_data_type * data = util_malloc(sizeof * data); + ecl_nnc_data_type * data = (ecl_nnc_data_type*)util_malloc(sizeof * data); int nnc_size = ecl_nnc_geometry_size( nnc_geo ); data->size = nnc_size; - data->values = util_malloc( nnc_size * sizeof(double)); + data->values = (double*)util_malloc( nnc_size * sizeof(double)); if (ecl_nnc_data_set_values(data, grid, nnc_geo, init_file, kw_type)) return data; diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_export.c b/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp similarity index 96% rename from ThirdParty/Ert/lib/ecl/ecl_nnc_export.c rename to ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp index ec549de43d..79cec6dabb 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_export.c +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_export.cpp @@ -17,13 +17,13 @@ */ #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include int ecl_nnc_export_get_size( const ecl_grid_type * grid ) { @@ -147,7 +147,7 @@ bool ecl_nnc_equal( const ecl_nnc_type * nnc1 , const ecl_nnc_type * nnc2) { static int ecl_nnc_sort_cmp__( const void * nnc1 , const void * nnc2) { - return ecl_nnc_sort_cmp( nnc1 , nnc2 ); + return ecl_nnc_sort_cmp( (const ecl_nnc_type*)nnc1 , (const ecl_nnc_type*)nnc2 ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.c b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp similarity index 88% rename from ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.c rename to ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp index 064862c16a..84251d8f47 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.c +++ b/ThirdParty/Ert/lib/ecl/ecl_nnc_geometry.cpp @@ -18,7 +18,7 @@ #include -#include +#include #define ECL_NNC_GEOMETRY_TYPE_ID 6124343 @@ -65,12 +65,12 @@ static void ecl_nnc_geometry_add_pairs( const ecl_nnc_geometry_type * nnc_geo , int lgr_nr2 = nnc_vector_get_lgr_nr( nnc_vector ); for (int index2 = 0; index2 < nnc_vector_get_size( nnc_vector ); index2++) { - ecl_nnc_pair_type pair = {.grid_nr1 = lgr_nr1, - .global_index1 = global_index1, - .grid_nr2 = lgr_nr2, - .global_index2 = int_vector_iget( grid2_index_list , index2 ), - .input_index = int_vector_iget( nnc_index_list, index2 )}; - + ecl_nnc_pair_type pair; + pair.grid_nr1 = lgr_nr1; + pair.global_index1 = global_index1; + pair.grid_nr2 = lgr_nr2; + pair.global_index2 = int_vector_iget( grid2_index_list , index2 ); + pair.input_index = int_vector_iget( nnc_index_list, index2 ); struct_vector_append( nnc_geo->data , &pair); } } @@ -100,7 +100,7 @@ static int ecl_nnc_cmp(const void * _nnc1 , const void * _nnc2) { ecl_nnc_geometry_type * ecl_nnc_geometry_alloc( const ecl_grid_type * grid ) { - ecl_nnc_geometry_type * nnc_geo = util_malloc( sizeof * nnc_geo ); + ecl_nnc_geometry_type * nnc_geo = (ecl_nnc_geometry_type*)util_malloc( sizeof * nnc_geo ); UTIL_TYPE_ID_INIT( nnc_geo , ECL_NNC_GEOMETRY_TYPE_ID ); nnc_geo->data = struct_vector_alloc( sizeof( struct ecl_nnc_pair_struct )); @@ -121,7 +121,7 @@ void ecl_nnc_geometry_free( ecl_nnc_geometry_type * nnc_geo) { const ecl_nnc_pair_type * ecl_nnc_geometry_iget( const ecl_nnc_geometry_type * nnc_geo , int index) { - return struct_vector_iget_ptr( nnc_geo->data , index ); + return (const ecl_nnc_pair_type*)struct_vector_iget_ptr( nnc_geo->data , index ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_region.c b/ThirdParty/Ert/lib/ecl/ecl_region.cpp similarity index 99% rename from ThirdParty/Ert/lib/ecl/ecl_region.c rename to ThirdParty/Ert/lib/ecl/ecl_region.cpp index 08410ddfc4..f76c7fc5a0 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_region.c +++ b/ThirdParty/Ert/lib/ecl/ecl_region.cpp @@ -20,17 +20,17 @@ #include #include -#include -#include +#include +#include #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** @@ -137,12 +137,12 @@ void ecl_region_unlock( ecl_region_type * region ){ ecl_region_type * ecl_region_alloc( const ecl_grid_type * ecl_grid , bool preselect) { - ecl_region_type * region = util_malloc( sizeof * region ); + ecl_region_type * region = (ecl_region_type*)util_malloc( sizeof * region ); UTIL_TYPE_ID_INIT( region , ECL_REGION_TYPE_ID); region->parent_grid = ecl_grid; ecl_grid_get_dims( ecl_grid , ®ion->grid_nx , ®ion->grid_ny , ®ion->grid_nz , ®ion->grid_active); region->grid_vol = region->grid_nx * region->grid_ny * region->grid_nz; - region->active_mask = util_calloc(region->grid_vol , sizeof * region->active_mask ); + region->active_mask = (bool*)util_calloc(region->grid_vol , sizeof * region->active_mask ); region->active_index_list = int_vector_alloc(0 , 0); region->global_index_list = int_vector_alloc(0 , 0); region->global_active_list = int_vector_alloc(0 , 0); diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_cell.c b/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_rft_cell.c rename to ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp index 0a2bced36e..ae683086f4 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_cell.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_cell.cpp @@ -23,13 +23,13 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define ECL_RFT_CELL_TYPE_ID 99164012 @@ -78,7 +78,7 @@ struct plt_data_struct { /*****************************************************************/ static rft_data_type * rft_data_alloc( double swat , double sgas) { - rft_data_type * data = util_malloc( sizeof * data ); + rft_data_type * data = (rft_data_type*)util_malloc( sizeof * data ); UTIL_TYPE_ID_INIT( data , RFT_DATA_TYPE_ID ); data->swat = swat; @@ -98,7 +98,7 @@ static UTIL_IS_INSTANCE_FUNCTION( rft_data , RFT_DATA_TYPE_ID) /*****************************************************************/ static plt_data_type * plt_data_alloc( double orat , double grat , double wrat,double connection_start, double connection_end, double flowrate , double oil_flowrate , double gas_flowrate , double water_flowrate) { - plt_data_type * data = util_malloc( sizeof * data ); + plt_data_type * data = (plt_data_type*)util_malloc( sizeof * data ); UTIL_TYPE_ID_INIT( data , PLT_DATA_TYPE_ID ); data->orat = orat; @@ -133,7 +133,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_rft_cell , ECL_RFT_CELL_TYPE_ID) static ecl_rft_cell_type * ecl_rft_cell_alloc_common(int i , int j , int k , double depth , double pressure) { - ecl_rft_cell_type * cell = util_malloc( sizeof * cell ); + ecl_rft_cell_type * cell = (ecl_rft_cell_type*)util_malloc( sizeof * cell ); UTIL_TYPE_ID_INIT( cell , ECL_RFT_CELL_TYPE_ID ); cell->i = i; @@ -180,9 +180,9 @@ ecl_rft_cell_type * ecl_rft_cell_alloc_PLT( int i , void ecl_rft_cell_free( ecl_rft_cell_type * cell ) { if (rft_data_is_instance( cell->data )) - rft_data_free( cell->data ); + rft_data_free( (rft_data_type*)cell->data ); else if (plt_data_is_instance( cell->data )) - plt_data_free( cell->data ); + plt_data_free( (plt_data_type*)cell->data ); free( cell ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_file.c b/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_rft_file.c rename to ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp index 9fb1df3153..0600a94efe 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_file.cpp @@ -25,16 +25,16 @@ #include #endif -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /** @@ -63,7 +63,7 @@ struct ecl_rft_file_struct { static ecl_rft_file_type * ecl_rft_file_alloc_empty(const char * filename) { - ecl_rft_file_type * rft_vector = util_malloc(sizeof * rft_vector ); + ecl_rft_file_type * rft_vector = (ecl_rft_file_type*)util_malloc(sizeof * rft_vector ); UTIL_TYPE_ID_INIT( rft_vector , ECL_RFT_FILE_ID ); rft_vector->data = vector_alloc_new(); rft_vector->filename = util_alloc_string_copy(filename); @@ -106,7 +106,7 @@ ecl_rft_file_type * ecl_rft_file_alloc(const char * filename) { if (!hash_has_key( rft_vector->well_index , well_name)) hash_insert_hash_owned_ref( rft_vector->well_index , well_name , int_vector_alloc( 0 , 0 ) , int_vector_free__); { - int_vector_type * index_list = hash_get( rft_vector->well_index , well_name ); + int_vector_type * index_list = (int_vector_type*)hash_get( rft_vector->well_index , well_name ); int_vector_append(index_list , global_index); } global_index++; @@ -228,7 +228,7 @@ int ecl_rft_file_get_size__( const ecl_rft_file_type * rft_file, const char * we int match_count = 0; int i; for ( i=0; i < vector_get_size( rft_file->data ); i++) { - const ecl_rft_node_type * rft = vector_iget_const( rft_file->data , i); + const ecl_rft_node_type * rft = (const ecl_rft_node_type*)vector_iget_const( rft_file->data , i); if (well_pattern) { if (util_fnmatch( well_pattern , ecl_rft_node_get_well_name( rft )) != 0) @@ -274,7 +274,7 @@ const char * ecl_rft_file_get_filename( const ecl_rft_file_type * rft_file ) { */ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , int index) { - return vector_iget( rft_file->data , index ); + return (ecl_rft_node_type*)vector_iget( rft_file->data , index ); } @@ -306,7 +306,7 @@ ecl_rft_node_type * ecl_rft_file_iget_node( const ecl_rft_file_type * rft_file , ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_file , const char * well, int index) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); return ecl_rft_file_iget_node( rft_file , int_vector_iget(index_vector , index)); } @@ -314,7 +314,7 @@ ecl_rft_node_type * ecl_rft_file_iget_well_rft( const ecl_rft_file_type * rft_fi static int ecl_rft_file_get_node_index_time_rft( const ecl_rft_file_type * rft_file , const char * well , time_t recording_time) { int global_index = -1; if (hash_has_key( rft_file->well_index , well)) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); int well_index = 0; while (true) { if (well_index == int_vector_size( index_vector )) @@ -364,7 +364,7 @@ bool ecl_rft_file_has_well( const ecl_rft_file_type * rft_file , const char * we */ int ecl_rft_file_get_well_occurences( const ecl_rft_file_type * rft_file , const char * well) { - const int_vector_type * index_vector = hash_get(rft_file->well_index , well); + const int_vector_type * index_vector = (const int_vector_type*)hash_get(rft_file->well_index , well); return int_vector_size( index_vector ); } @@ -415,7 +415,7 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, /** The sorting here works directly on the internal node storage rft_file->data; that might in principle ruin the indexing of - the ecl_file object - it is therefor absolutely essential + the ecl_file object - it is therefore absolutely essential that this ecl_rft_file object does not live beyond this function, and also that the ecl_rft_file api functions are avoided for the rest of this function. @@ -423,7 +423,7 @@ void ecl_rft_file_update(const char * rft_file_name, ecl_rft_node_type ** nodes, vector_sort(rft_file->data,(vector_cmp_ftype *) ecl_rft_node_cmp); for(node_index=0; node_index < vector_get_size( rft_file->data ); node_index++) { - const ecl_rft_node_type *new_node = vector_iget_const(rft_file->data, node_index); + const ecl_rft_node_type *new_node = (const ecl_rft_node_type*)vector_iget_const(rft_file->data, node_index); ecl_rft_node_fwrite(new_node, fortio, unit_set); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_rft_node.c b/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp similarity index 92% rename from ThirdParty/Ert/lib/ecl/ecl_rft_node.c rename to ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp index 73bc54ec2d..d4681bf3f6 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rft_node.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rft_node.cpp @@ -23,18 +23,18 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include /** @@ -75,7 +75,7 @@ struct ecl_rft_node_struct { The implementation of cell types based on _either_ RFT data or PLT data is based on a misunderstanding and is currently WRONG. One section in an RFT file can contain RFT data, PLT data and SEGMENT - data. The @data_type string should therefor not be interpreted as a + data. The @data_type string should therefore not be interpreted as a type string, but rather as a "bit mask": @@ -106,7 +106,7 @@ static ecl_rft_enum translate_from_sting_to_ecl_rft_enum(const char * data_type_ ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days){ ecl_rft_enum data_type = translate_from_sting_to_ecl_rft_enum(data_type_string); - ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); + ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node ); UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); rft_node->well_name = util_alloc_string_copy(well_name); rft_node->cells = vector_alloc_new(); @@ -130,7 +130,7 @@ static ecl_rft_node_type * ecl_rft_node_alloc_empty(const char * data_type_strin } { - ecl_rft_node_type * rft_node = util_malloc(sizeof * rft_node ); + ecl_rft_node_type * rft_node = (ecl_rft_node_type*)util_malloc(sizeof * rft_node ); UTIL_TYPE_ID_INIT( rft_node , ECL_RFT_NODE_ID ); rft_node->cells = vector_alloc_new(); @@ -269,11 +269,11 @@ static void ecl_rft_node_init_cells( ecl_rft_node_type * rft_node , const ecl_fi ecl_rft_node_type * ecl_rft_node_alloc(const ecl_file_view_type * rft_view) { ecl_kw_type * welletc = ecl_file_view_iget_named_kw(rft_view , WELLETC_KW , 0); - ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty(ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX)); + ecl_rft_node_type * rft_node = ecl_rft_node_alloc_empty((const char*)ecl_kw_iget_ptr(welletc , WELLETC_TYPE_INDEX)); if (rft_node != NULL) { ecl_kw_type * date_kw = ecl_file_view_iget_named_kw( rft_view , DATE_KW , 0); - rft_node->well_name = util_alloc_strip_copy( ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX)); + rft_node->well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr(welletc , WELLETC_NAME_INDEX)); /* Time information. */ { @@ -325,7 +325,7 @@ ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node) { return /* various functions to access properties at the cell level */ const ecl_rft_cell_type * ecl_rft_node_iget_cell( const ecl_rft_node_type * rft_node , int index) { - return vector_iget_const( rft_node->cells , index ); + return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); } @@ -349,7 +349,7 @@ const ecl_rft_cell_type * ecl_rft_node_iget_cell_sorted( ecl_rft_node_type * rft if (!rft_node->sort_perm_in_sync) ecl_rft_node_create_sort_perm( rft_node ); - return vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index )); + return (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , int_vector_iget( rft_node->sort_perm , index )); } } @@ -403,7 +403,7 @@ static void assert_type_and_index( const ecl_rft_node_type * rft_node , ecl_rft_ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_sgas( cell ); } } @@ -412,7 +412,7 @@ double ecl_rft_node_iget_sgas( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_swat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_swat( cell ); } } @@ -424,7 +424,7 @@ double ecl_rft_node_get_days(const ecl_rft_node_type * rft_node ){ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , RFT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_soil( cell ); } } @@ -435,7 +435,7 @@ double ecl_rft_node_iget_soil( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index ); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index ); return ecl_rft_cell_get_orat( cell ); } } @@ -444,7 +444,7 @@ double ecl_rft_node_iget_orat( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index); return ecl_rft_cell_get_wrat( cell ); } } @@ -453,7 +453,7 @@ double ecl_rft_node_iget_wrat( const ecl_rft_node_type * rft_node , int index) { double ecl_rft_node_iget_grat( const ecl_rft_node_type * rft_node , int index) { assert_type_and_index( rft_node , PLT , index ); { - const ecl_rft_cell_type * cell = vector_iget_const( rft_node->cells , index); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , index); return ecl_rft_cell_get_grat( cell ); } } @@ -594,7 +594,7 @@ void ecl_rft_node_fwrite(const ecl_rft_node_type * rft_node, fortio_type * forti int i; for(i =0;icells , i); + const ecl_rft_cell_type * cell = (const ecl_rft_cell_type*)vector_iget_const( rft_node->cells , i); ecl_kw_iset_int(conipos, i, ecl_rft_cell_get_i(cell)+1); ecl_kw_iset_int(conjpos, i, ecl_rft_cell_get_j(cell)+1); ecl_kw_iset_int(conkpos, i, ecl_rft_cell_get_k(cell)+1); diff --git a/ThirdParty/Ert/lib/ecl/ecl_rst_file.c b/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp similarity index 94% rename from ThirdParty/Ert/lib/ecl/ecl_rst_file.c rename to ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp index 2bc6fd70cd..646f6c6598 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rst_file.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rst_file.cpp @@ -23,21 +23,21 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include struct ecl_rst_file_struct { fortio_type * fortio; @@ -50,7 +50,7 @@ struct ecl_rst_file_struct { static ecl_rst_file_type * ecl_rst_file_alloc( const char * filename ) { bool unified = ecl_util_unified_file( filename ); bool fmt_file; - ecl_rst_file_type * rst_file = util_malloc( sizeof * rst_file ); + ecl_rst_file_type * rst_file = (ecl_rst_file_type*)util_malloc( sizeof * rst_file ); if (ecl_util_fmt_file( filename , &fmt_file)) { rst_file->unified = unified; diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/ecl_rsthead.c rename to ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index 52d40a9aab..56c3a87ac7 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -17,13 +17,13 @@ */ #include -#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include static time_t rsthead_date( int day , int month , int year) { @@ -55,7 +55,7 @@ int ecl_rsthead_get_report_step( const ecl_rsthead_type * header ) { ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_type * intehead_kw , const ecl_kw_type * doubhead_kw , const ecl_kw_type * logihead_kw ) { - ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); + ecl_rsthead_type * rsthead = (ecl_rsthead_type*)util_malloc( sizeof * rsthead ); rsthead->report_step = report_step; { const int * data = (const int *) ecl_kw_get_void_ptr( intehead_kw ); @@ -135,7 +135,7 @@ ecl_rsthead_type * ecl_rsthead_alloc( const ecl_file_view_type * rst_view, int r ecl_rsthead_type * ecl_rsthead_alloc_empty() { - ecl_rsthead_type * rsthead = util_malloc( sizeof * rsthead ); + ecl_rsthead_type * rsthead = (ecl_rsthead_type*)util_malloc( sizeof * rsthead ); rsthead->day = 0; rsthead->month = 0; diff --git a/ThirdParty/Ert/lib/ecl/ecl_smspec.c b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp similarity index 81% rename from ThirdParty/Ert/lib/ecl/ecl_smspec.c rename to ThirdParty/Ert/lib/ecl/ecl_smspec.cpp index a8b02a7a06..2e774554b2 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_smspec.c +++ b/ThirdParty/Ert/lib/ecl/ecl_smspec.cpp @@ -20,22 +20,23 @@ #include #include #include - -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include +#include + +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include #ifdef HAVE_FNMATCH #include @@ -141,6 +142,8 @@ struct ecl_smspec_struct { float_vector_type * params_default; char * restart_case; + ert_ecl_unit_enum unit_system; + int restart_step; }; @@ -246,9 +249,9 @@ static const char* smspec_required_keywords[] = { /*****************************************************************/ -static ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string) { +ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string) { ecl_smspec_type *ecl_smspec; - ecl_smspec = util_malloc(sizeof *ecl_smspec ); + ecl_smspec = (ecl_smspec_type*)util_malloc(sizeof *ecl_smspec ); UTIL_TYPE_ID_INIT(ecl_smspec , ECL_SMSPEC_ID); ecl_smspec->well_var_index = hash_alloc(); @@ -272,8 +275,16 @@ static ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * k ecl_smspec->locked = false; ecl_smspec->time_seconds = -1; + /* + The unit system is given as an integer in the INTEHEAD keyword. The INTEHEAD + keyword is optional, and we have for a long time been completely oblivious + to the possibility of extracting unit system information from the SMSPEC file. + */ + ecl_smspec->unit_system = ECL_METRIC_UNITS; + ecl_smspec->index_map = int_vector_alloc(0,0); ecl_smspec->restart_case = NULL; + ecl_smspec->restart_step = -1; ecl_smspec->params_default = float_vector_alloc(0 , PARAMS_GLOBAL_DEFAULT); ecl_smspec->write_mode = write_mode; ecl_smspec->need_nums = false; @@ -284,7 +295,7 @@ static ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * k int * ecl_smspec_alloc_mapping( const ecl_smspec_type * self, const ecl_smspec_type * other) { int params_size = ecl_smspec_get_params_size( self ); - int * mapping = util_malloc( params_size * sizeof * mapping ); + int * mapping = (int*)util_malloc( params_size * sizeof * mapping ); for (int i = 0; i < params_size; i++) mapping[i] = -1; @@ -315,7 +326,7 @@ int * ecl_smspec_alloc_mapping( const ecl_smspec_type * self, const ecl_smspec_t const smspec_node_type * ecl_smspec_iget_node( const ecl_smspec_type * smspec , int index ) { - return vector_iget_const( smspec->smspec_nodes , index ); + return (const smspec_node_type*)vector_iget_const( smspec->smspec_nodes , index ); } int ecl_smspec_num_nodes( const ecl_smspec_type * smspec) { @@ -357,137 +368,140 @@ static ecl_data_type get_wgnames_type(const ecl_smspec_type * smspec) { return max_len <= ECL_STRING8_LENGTH ? ECL_CHAR : ECL_STRING(max_len); } -// DIMENS -// KEYWORDS -// WGNAMES -// NUMS - optional -// UNITS -// STARTDAT +static void ecl_smspec_fwrite_INTEHEAD(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * intehead = ecl_kw_alloc( INTEHEAD_KW, INTEHEAD_SMSPEC_SIZE, ECL_INT); + ecl_kw_iset_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX, smspec->unit_system); + /* + The simulator type is just hardcoded to ECLIPSE100. + */ + ecl_kw_iset_int(intehead, INTEHEAD_SMSPEC_IPROG_INDEX, INTEHEAD_ECLIPSE100_VALUE); + ecl_kw_fwrite(intehead, fortio); + ecl_kw_free(intehead); +} -static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_type * fortio) { - int num_nodes = ecl_smspec_num_nodes( smspec ); - { - ecl_kw_type * restart_kw = ecl_kw_alloc( RESTART_KW , SUMMARY_RESTART_SIZE , ECL_CHAR ); - for (int i=0; i < SUMMARY_RESTART_SIZE; i++) - ecl_kw_iset_string8( restart_kw , i , ""); - - if (smspec->restart_case != NULL) { - int restart_case_len = strlen(smspec->restart_case); - - int offset = 0; - for (int i = 0; i < SUMMARY_RESTART_SIZE ; i++) { - if (offset < restart_case_len) - ecl_kw_iset_string8( restart_kw , i , &smspec->restart_case[ offset ]); - offset += ECL_STRING8_LENGTH; - } - } +static void ecl_smspec_fwrite_RESTART(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * restart_kw = ecl_kw_alloc( RESTART_KW , SUMMARY_RESTART_SIZE , ECL_CHAR ); + for (int i=0; i < SUMMARY_RESTART_SIZE; i++) + ecl_kw_iset_string8( restart_kw , i , ""); - ecl_kw_fwrite( restart_kw , fortio ); - ecl_kw_free( restart_kw ); - } - { - ecl_kw_type * dimens_kw = ecl_kw_alloc( DIMENS_KW , DIMENS_SIZE , ECL_INT ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_SIZE_INDEX , num_nodes ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NX_INDEX , smspec->grid_dims[0] ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NY_INDEX , smspec->grid_dims[1] ); - ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NZ_INDEX , smspec->grid_dims[2] ); - - /* Do not know what these two last items are for. */ - ecl_kw_iset_int( dimens_kw , 4 , 0 ); - ecl_kw_iset_int( dimens_kw , 5 , -1 ); - - ecl_kw_fwrite( dimens_kw , fortio ); - ecl_kw_free( dimens_kw ); + if (smspec->restart_case != NULL) { + int restart_case_len = strlen(smspec->restart_case); + + int offset = 0; + for (int i = 0; i < SUMMARY_RESTART_SIZE ; i++) { + if (offset < restart_case_len) + ecl_kw_iset_string8( restart_kw , i , &smspec->restart_case[ offset ]); + offset += ECL_STRING8_LENGTH; + } } + ecl_kw_fwrite( restart_kw , fortio ); + ecl_kw_free( restart_kw ); +} - { - ecl_kw_type * keywords_kw = ecl_kw_alloc( KEYWORDS_KW , num_nodes , ECL_CHAR ); - ecl_kw_type * units_kw = ecl_kw_alloc( UNITS_KW , num_nodes , ECL_CHAR ); - ecl_kw_type * nums_kw = NULL; - - // If the names_type is an ECL_STRING we expect this to be an INTERSECT - // summary, otherwise an ECLIPSE summary. - ecl_data_type names_type = get_wgnames_type(smspec); - ecl_kw_type * wgnames_kw = ecl_kw_alloc( - ecl_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW, - num_nodes, - names_type - ); - if (smspec->need_nums) - nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT); - { - int i; - for (i=0; i < ecl_smspec_num_nodes( smspec ); i++) { - const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , i ); - /* - It is possible to add variables with deferred initialisation - with the ecl_sum_add_blank_var() function. Before these - variables can be actually used for anything interesting they - must be initialized with the ecl_sum_init_var() function. +static void ecl_smspec_fwrite_DIMENS(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * dimens_kw = ecl_kw_alloc( DIMENS_KW , DIMENS_SIZE , ECL_INT ); + int num_nodes = ecl_smspec_num_nodes( smspec ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_SIZE_INDEX , num_nodes ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NX_INDEX , smspec->grid_dims[0] ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NY_INDEX , smspec->grid_dims[1] ); + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_NZ_INDEX , smspec->grid_dims[2] ); + ecl_kw_iset_int( dimens_kw , 4 , 0 ); // Do not know what this is for. + ecl_kw_iset_int( dimens_kw , DIMENS_SMSPEC_RESTART_STEP_INDEX , smspec->restart_step ); - If a call to save the smspec file comes before all the - variable have been initialized things will potentially go - belly up. This is solved with the following uber-hack: + ecl_kw_fwrite( dimens_kw , fortio ); + ecl_kw_free( dimens_kw ); +} - o One of the well related keywords is chosen; in - particular 'WWCT' in this case. - o The wgname value is set to DUMMY_WELL +static void ecl_smspec_fwrite_STARTDAT(const ecl_smspec_type * smspec, fortio_type * fortio) { + ecl_kw_type * startdat_kw = ecl_kw_alloc( STARTDAT_KW , STARTDAT_SIZE , ECL_INT ); + int day,month,year; + ecl_util_set_date_values( smspec->sim_start_time , &day, &month , &year); - The use of DUMMY_WELL ensures that this field will be - ignored when/if this smspec file is read in at a later - stage. - */ - if (smspec_node_get_var_type( smspec_node ) == ECL_SMSPEC_INVALID_VAR) { - ecl_kw_iset_string8( keywords_kw , i , "WWCT" ); - ecl_kw_iset_string8( units_kw , i , "????????"); - ecl_kw_iset_string_ptr( wgnames_kw , i , DUMMY_WELL); - } else { - ecl_kw_iset_string8( keywords_kw , i , smspec_node_get_keyword( smspec_node )); - ecl_kw_iset_string8( units_kw , i , smspec_node_get_unit( smspec_node )); - { - const char * wgname = DUMMY_WELL; - if (smspec_node_get_wgname( smspec_node )) - wgname = smspec_node_get_wgname( smspec_node ); - ecl_kw_iset_string_ptr( wgnames_kw , i , wgname); - } - } + ecl_kw_iset_int( startdat_kw , STARTDAT_DAY_INDEX , day ); + ecl_kw_iset_int( startdat_kw , STARTDAT_MONTH_INDEX , month ); + ecl_kw_iset_int( startdat_kw , STARTDAT_YEAR_INDEX , year ); - if (nums_kw != NULL) - ecl_kw_iset_int( nums_kw , i , smspec_node_get_num( smspec_node )); - } - } + ecl_kw_fwrite( startdat_kw , fortio ); + ecl_kw_free( startdat_kw ); +} - ecl_kw_fwrite( keywords_kw , fortio ); - ecl_kw_fwrite( wgnames_kw , fortio ); - if (nums_kw != NULL) - ecl_kw_fwrite( nums_kw , fortio ); - ecl_kw_fwrite( units_kw , fortio ); +static void ecl_smspec_fortio_fwrite( const ecl_smspec_type * smspec , fortio_type * fortio) { + ecl_smspec_fwrite_INTEHEAD(smspec, fortio); + ecl_smspec_fwrite_RESTART(smspec, fortio); + ecl_smspec_fwrite_DIMENS(smspec, fortio); + + int num_nodes = ecl_smspec_num_nodes( smspec ); + ecl_kw_type * keywords_kw = ecl_kw_alloc( KEYWORDS_KW , num_nodes , ECL_CHAR ); + ecl_kw_type * units_kw = ecl_kw_alloc( UNITS_KW , num_nodes , ECL_CHAR ); + ecl_kw_type * nums_kw = NULL; + + // If the names_type is an ECL_STRING we expect this to be an INTERSECT + // summary, otherwise an ECLIPSE summary. + ecl_data_type names_type = get_wgnames_type(smspec); + ecl_kw_type * wgnames_kw = ecl_kw_alloc( ecl_type_is_char(names_type) ? WGNAMES_KW : NAMES_KW, + num_nodes, + names_type ); + + if (smspec->need_nums) + nums_kw = ecl_kw_alloc( NUMS_KW , num_nodes , ECL_INT); + + for (int i=0; i < ecl_smspec_num_nodes( smspec ); i++) { + const smspec_node_type * smspec_node = ecl_smspec_iget_node( smspec , i ); + /* + It is possible to add variables with deferred initialisation + with the ecl_sum_add_blank_var() function. Before these + variables can be actually used for anything interesting they + must be initialized with the ecl_sum_init_var() function. + If a call to save the smspec file comes before all the + variable have been initialized things will potentially go + belly up. This is solved with the following uber-hack: - ecl_kw_free( keywords_kw ); - ecl_kw_free( wgnames_kw ); - ecl_kw_free( units_kw ); - if (nums_kw != NULL) - ecl_kw_free( nums_kw ); - } + o One of the well related keywords is chosen; in + particular 'WWCT' in this case. - { - ecl_kw_type * startdat_kw = ecl_kw_alloc( STARTDAT_KW , STARTDAT_SIZE , ECL_INT ); - int day,month,year; - ecl_util_set_date_values( smspec->sim_start_time , &day, &month , &year); + o The wgname value is set to DUMMY_WELL - ecl_kw_iset_int( startdat_kw , STARTDAT_DAY_INDEX , day ); - ecl_kw_iset_int( startdat_kw , STARTDAT_MONTH_INDEX , month ); - ecl_kw_iset_int( startdat_kw , STARTDAT_YEAR_INDEX , year ); + The use of DUMMY_WELL ensures that this field will be + ignored when/if this smspec file is read in at a later + stage. + */ + if (smspec_node_get_var_type( smspec_node ) == ECL_SMSPEC_INVALID_VAR) { + ecl_kw_iset_string8( keywords_kw , i , "WWCT" ); + ecl_kw_iset_string8( units_kw , i , "????????"); + ecl_kw_iset_string_ptr( wgnames_kw , i , DUMMY_WELL); + } else { + ecl_kw_iset_string8( keywords_kw , i , smspec_node_get_keyword( smspec_node )); + ecl_kw_iset_string8( units_kw , i , smspec_node_get_unit( smspec_node )); + { + const char * wgname = DUMMY_WELL; + if (smspec_node_get_wgname( smspec_node )) + wgname = smspec_node_get_wgname( smspec_node ); + ecl_kw_iset_string_ptr( wgnames_kw , i , wgname); + } + } - ecl_kw_fwrite( startdat_kw , fortio ); - ecl_kw_free( startdat_kw ); + if (nums_kw != NULL) + ecl_kw_iset_int( nums_kw , i , smspec_node_get_num( smspec_node )); } + ecl_kw_fwrite( keywords_kw , fortio ); + ecl_kw_fwrite( wgnames_kw , fortio ); + if (nums_kw != NULL) + ecl_kw_fwrite( nums_kw , fortio ); + ecl_kw_fwrite( units_kw , fortio ); + + ecl_kw_free( keywords_kw ); + ecl_kw_free( wgnames_kw ); + ecl_kw_free( units_kw ); + if (nums_kw != NULL) + ecl_kw_free( nums_kw ); + + ecl_smspec_fwrite_STARTDAT(smspec, fortio); } @@ -495,20 +509,30 @@ void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , char * filename = ecl_util_alloc_filename( NULL , ecl_case , ECL_SUMMARY_HEADER_FILE , fmt_file , 0 ); fortio_type * fortio = fortio_open_writer( filename , fmt_file , ECL_ENDIAN_FLIP); + if (!fortio) { + char * error_fmt_msg = "%s: Unable to open fortio file %s, error: %s .\n"; + util_abort( error_fmt_msg , __func__ , filename , strerror( errno ) ); + } + ecl_smspec_fortio_fwrite( smspec , fortio ); fortio_fclose( fortio ); free( filename ); } -ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , const char * restart_case, time_t sim_start , bool time_in_days , int nx , int ny , int nz) { - ecl_smspec_type * ecl_smspec = ecl_smspec_alloc_empty( true , key_join_string ); - - if (restart_case != NULL) { - if (strlen(restart_case) <= (SUMMARY_RESTART_SIZE * ECL_STRING8_LENGTH)) - ecl_smspec->restart_case = util_alloc_string_copy( restart_case ); - else - return NULL; + + +static ecl_smspec_type * ecl_smspec_alloc_writer__( const char * key_join_string , const char * restart_case, int restart_step, time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + ecl_smspec_type * ecl_smspec = ecl_smspec_alloc_empty( true , key_join_string ); + /* + Only a total of 9 * 8 characters is set aside for the restart keyword, if + the supplied restart case is longer than that we silently ignore it. + */ + if (restart_case) { + if (strlen(restart_case) <= (SUMMARY_RESTART_SIZE * ECL_STRING8_LENGTH)) { + ecl_smspec->restart_case = util_alloc_string_copy( restart_case ); + ecl_smspec->restart_step = restart_step; + } } ecl_smspec->grid_dims[0] = nx; ecl_smspec->grid_dims[1] = ny; @@ -547,6 +571,14 @@ ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , const return ecl_smspec; } +ecl_smspec_type * ecl_smspec_alloc_restart_writer( const char * key_join_string , const char * restart_case, int restart_step, time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + return ecl_smspec_alloc_writer__(key_join_string, restart_case, restart_step, sim_start, time_in_days, nx, ny, nz); +} + +ecl_smspec_type * ecl_smspec_alloc_writer(const char * key_join_string, time_t sim_start, bool time_in_days, int nx, int ny , int nz) { + return ecl_smspec_alloc_writer__(key_join_string, NULL, 0, sim_start, time_in_days, nx, ny, nz); +} + UTIL_SAFE_CAST_FUNCTION( ecl_smspec , ECL_SMSPEC_ID ) @@ -812,13 +844,13 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->well_completion_var_index , well)) hash_insert_hash_owned_ref(ecl_smspec->well_completion_var_index , well , hash_alloc() , hash_free__); { - hash_type * cell_hash = hash_get(ecl_smspec->well_completion_var_index , well); + hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well); char cell_str[16]; sprintf(cell_str , "%d" , num); if (!hash_has_key(cell_hash , cell_str)) hash_insert_hash_owned_ref(cell_hash , cell_str , hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(cell_hash , cell_str); + hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str); hash_insert_ref(var_hash , keyword , smspec_node ); } } @@ -833,7 +865,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->group_var_index , group)) hash_insert_hash_owned_ref(ecl_smspec->group_var_index , group, hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(ecl_smspec->group_var_index , group); + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->group_var_index , group); hash_insert_ref(var_hash , keyword , smspec_node ); } break; @@ -841,7 +873,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->region_var_index , keyword)) hash_insert_hash_owned_ref( ecl_smspec->region_var_index , keyword , hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(ecl_smspec->region_var_index , keyword); + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->region_var_index , keyword); char num_str[16]; sprintf( num_str , "%d" , num); hash_insert_ref(var_hash , num_str , smspec_node); @@ -852,7 +884,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->well_var_index , well)) hash_insert_hash_owned_ref(ecl_smspec->well_var_index , well , hash_alloc() , hash_free__); { - hash_type * var_hash = hash_get(ecl_smspec->well_var_index , well); + hash_type * var_hash = (hash_type*)hash_get(ecl_smspec->well_var_index , well); hash_insert_ref(var_hash , keyword , smspec_node ); } break; @@ -865,7 +897,7 @@ static void ecl_smspec_install_special_keys( ecl_smspec_type * ecl_smspec , smsp if (!hash_has_key(ecl_smspec->block_var_index , keyword)) hash_insert_hash_owned_ref(ecl_smspec->block_var_index , keyword , hash_alloc() , hash_free__); { - hash_type * block_hash = hash_get(ecl_smspec->block_var_index , keyword); + hash_type * block_hash = (hash_type*)hash_get(ecl_smspec->block_var_index , keyword); char block_nr[16]; sprintf( block_nr , "%d" , num ); hash_insert_ref(block_hash , block_nr , smspec_node); @@ -986,8 +1018,8 @@ bool ecl_smspec_equal(const ecl_smspec_type * self, return false; for (int i=0; i < vector_get_size( self->smspec_nodes ); i++) { - const smspec_node_type * node1 = vector_iget_const(self->smspec_nodes, i); - const smspec_node_type * node2 = vector_iget_const(other->smspec_nodes, i); + const smspec_node_type * node1 = (const smspec_node_type*)vector_iget_const(self->smspec_nodes, i); + const smspec_node_type * node2 = (const smspec_node_type*)vector_iget_const(other->smspec_nodes, i); if (!smspec_node_equal(node1, node2)) return false; @@ -1006,20 +1038,43 @@ static void ecl_smspec_load_restart( ecl_smspec_type * ecl_smspec , const ecl_fi char * restart_base; int i; tmp_base[0] = '\0'; - for (i=0; i < ecl_kw_get_size( restart_kw ); i++) - strcat( tmp_base , ecl_kw_iget_ptr( restart_kw , i )); + for (i=0; i < ecl_kw_get_size( restart_kw ); i++) + strcat( tmp_base , (const char*)ecl_kw_iget_ptr( restart_kw , i )); restart_base = util_alloc_strip_copy( tmp_base ); if (strlen(restart_base)) { /* We ignore the empty ones. */ char * path; char * smspec_header; + /* + The conditional block here is to support the following situation: + + 1. A simulation with a restart has been performed on Posix with path + separator '/'. + + 2. The simulation is loaded on windows, where the native path + separator is '\'. + + This code block will translate '/' -> '\' in the restart keyword which + is read from the summary file. + */ +#ifdef ERT_WINDOWS + for (int i=0; i < strlen(restart_base); i++) { + if (restart_base[i] == UTIL_POSIX_PATH_SEP_CHAR) + restart_base[i] = UTIL_PATH_SEP_CHAR; + } +#endif + util_alloc_file_components( ecl_smspec->header_file , &path , NULL , NULL ); smspec_header = ecl_util_alloc_exfilename( path , restart_base , ECL_SUMMARY_HEADER_FILE , ecl_smspec->formatted , 0); if (!util_same_file(smspec_header , ecl_smspec->header_file)) /* Restart from the current case is ignored. */ { - char * tmp_path = util_alloc_filename( path , restart_base , NULL ); - ecl_smspec->restart_case = util_alloc_abs_path(tmp_path); - free( tmp_path ); + if (util_is_abs_path(restart_base)) + ecl_smspec->restart_case = util_alloc_string_copy( restart_base ); + else { + char * tmp_path = util_alloc_filename( path , restart_base , NULL ); + ecl_smspec->restart_case = util_alloc_abs_path(tmp_path); + free( tmp_path ); + } } util_safe_free( path ); @@ -1147,6 +1202,16 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h if (ecl_file_has_kw(header , NUMS_KW)) nums = ecl_file_iget_named_kw(header , NUMS_KW , 0); + if (ecl_file_has_kw(header, INTEHEAD_KW)) { + const ecl_kw_type * intehead = ecl_file_iget_named_kw(header, INTEHEAD_KW, 0); + ecl_smspec->unit_system = (ert_ecl_unit_enum)ecl_kw_iget_int(intehead, INTEHEAD_SMSPEC_UNIT_INDEX); + /* + The second item in the INTEHEAD vector is an integer designating which + simulator has been used for the current simulation, that is currently + ignored. + */ + } + if (ecl_file_has_kw( header , LGRS_KW )) {/* The file has LGR information. */ lgrs = ecl_file_iget_named_kw( header , LGRS_KW , 0 ); numlx = ecl_file_iget_named_kw( header , NUMLX_KW , 0 ); @@ -1166,6 +1231,7 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h ecl_smspec->grid_dims[0] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NX_INDEX ); ecl_smspec->grid_dims[1] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NY_INDEX ); ecl_smspec->grid_dims[2] = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_NZ_INDEX ); + ecl_smspec->restart_step = ecl_kw_iget_int(dimens , DIMENS_SMSPEC_RESTART_STEP_INDEX); ecl_smspec_set_params_size( ecl_smspec , ecl_kw_get_size(keywords)); ecl_util_get_file_type( header_file , &ecl_smspec->formatted , NULL ); @@ -1174,9 +1240,9 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h for (params_index=0; params_index < ecl_kw_get_size(wells); params_index++) { float default_value = PARAMS_GLOBAL_DEFAULT; int num = SMSPEC_NUMS_INVALID; - char * well = util_alloc_strip_copy(ecl_kw_iget_ptr(wells , params_index)); - char * kw = util_alloc_strip_copy(ecl_kw_iget_ptr(keywords , params_index)); - char * unit = util_alloc_strip_copy(ecl_kw_iget_ptr(units , params_index)); + char * well = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(wells , params_index)); + char * kw = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(keywords , params_index)); + char * unit = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr(units , params_index)); char * lgr_name = NULL; smspec_node_type * smspec_node; @@ -1186,7 +1252,7 @@ static bool ecl_smspec_fread_header(ecl_smspec_type * ecl_smspec, const char * h int lgr_i = ecl_kw_iget_int( numlx , params_index ); int lgr_j = ecl_kw_iget_int( numly , params_index ); int lgr_k = ecl_kw_iget_int( numlz , params_index ); - lgr_name = util_alloc_strip_copy( ecl_kw_iget_ptr( lgrs , params_index )); + lgr_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( lgrs , params_index )); smspec_node = smspec_node_alloc_lgr( var_type , well , kw , unit , lgr_name , ecl_smspec->key_join_string , lgr_i , lgr_j , lgr_k , params_index, default_value); } else smspec_node = smspec_node_alloc( var_type , well , kw , unit , ecl_smspec->key_join_string , ecl_smspec->grid_dims , num , params_index , default_value); @@ -1227,7 +1293,7 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k if (ecl_smspec_fread_header(ecl_smspec , header_file , include_restart)) { if (hash_has_key( ecl_smspec->misc_var_index , "TIME")) { - const smspec_node_type * time_node = hash_get(ecl_smspec->misc_var_index , "TIME"); + const smspec_node_type * time_node = (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "TIME"); const char * time_unit = smspec_node_get_unit( time_node ); ecl_smspec->time_index = smspec_node_get_params_index( time_node ); @@ -1240,9 +1306,9 @@ ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * k } if (hash_has_key(ecl_smspec->misc_var_index , "DAY")) { - ecl_smspec->day_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "DAY") ); - ecl_smspec->month_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "MONTH") ); - ecl_smspec->year_index = smspec_node_get_params_index( hash_get(ecl_smspec->misc_var_index , "YEAR") ); + ecl_smspec->day_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "DAY") ); + ecl_smspec->month_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "MONTH") ); + ecl_smspec->year_index = smspec_node_get_params_index( (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , "YEAR") ); } if ((ecl_smspec->time_index == -1) && ( ecl_smspec->day_index == -1)) { @@ -1326,9 +1392,9 @@ int ecl_smspec_get_num_regions(const ecl_smspec_type * ecl_smspec) { const smspec_node_type * ecl_smspec_get_well_var_node( const ecl_smspec_type * smspec , const char * well , const char * var) { const smspec_node_type * node = NULL; if (hash_has_key( smspec->well_var_index , well)) { - hash_type * var_hash = hash_get(smspec->well_var_index , well); + hash_type * var_hash = (hash_type*)hash_get(smspec->well_var_index , well); if (hash_has_key(var_hash , var)) - node = hash_get(var_hash , var); + node = (const smspec_node_type*)hash_get(var_hash , var); } return node; } @@ -1353,9 +1419,9 @@ bool ecl_smspec_has_well_var(const ecl_smspec_type * ecl_smspec , const char * w const smspec_node_type * ecl_smspec_get_group_var_node( const ecl_smspec_type * smspec , const char * group , const char * var) { const smspec_node_type * node = NULL; if (hash_has_key(smspec->group_var_index , group)) { - hash_type * var_hash = hash_get(smspec->group_var_index , group); + hash_type * var_hash = (hash_type*)hash_get(smspec->group_var_index , group); if (hash_has_key(var_hash , var)) - node = hash_get(var_hash , var); + node = (const smspec_node_type*)hash_get(var_hash , var); } return node; } @@ -1379,7 +1445,7 @@ bool ecl_smspec_has_group_var(const ecl_smspec_type * ecl_smspec , const char * const smspec_node_type * ecl_smspec_get_field_var_node(const ecl_smspec_type * ecl_smspec , const char *var) { const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->field_var_index , var)) - node = hash_get(ecl_smspec->field_var_index , var); + node = (const smspec_node_type*)hash_get(ecl_smspec->field_var_index , var); return node; } @@ -1413,9 +1479,9 @@ static const smspec_node_type * ecl_smspec_get_block_var_node_string(const ecl_s const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->block_var_index , block_var)) { - hash_type * block_hash = hash_get(ecl_smspec->block_var_index , block_var); + hash_type * block_hash = (hash_type*)hash_get(ecl_smspec->block_var_index , block_var); if (hash_has_key(block_hash , block_str)) - node = hash_get(block_hash , block_str); + node = (const smspec_node_type*)hash_get(block_hash , block_str); } return node; @@ -1473,9 +1539,9 @@ const smspec_node_type * ecl_smspec_get_region_var_node(const ecl_smspec_type * if (hash_has_key(ecl_smspec->region_var_index , region_var)) { char * nr_str = util_alloc_sprintf( "%d" , region_nr ); - hash_type * nr_hash = hash_get(ecl_smspec->region_var_index , region_var); + hash_type * nr_hash = (hash_type*)hash_get(ecl_smspec->region_var_index , region_var); if (hash_has_key( nr_hash , nr_str)) - node = hash_get( nr_hash , nr_str ); + node = (const smspec_node_type*)hash_get( nr_hash , nr_str ); free( nr_str ); } @@ -1501,7 +1567,7 @@ const smspec_node_type * ecl_smspec_get_misc_var_node(const ecl_smspec_type * ec const smspec_node_type * node = NULL; if (hash_has_key(ecl_smspec->misc_var_index , var)) - node = hash_get(ecl_smspec->misc_var_index , var); + node = (const smspec_node_type*)hash_get(ecl_smspec->misc_var_index , var); return node; } @@ -1527,12 +1593,12 @@ const smspec_node_type * ecl_smspec_get_well_completion_var_node(const ecl_smspe char * cell_str = util_alloc_sprintf("%d" , cell_nr); if (hash_has_key(ecl_smspec->well_completion_var_index , well)) { - hash_type * cell_hash = hash_get(ecl_smspec->well_completion_var_index , well); + hash_type * cell_hash = (hash_type*)hash_get(ecl_smspec->well_completion_var_index , well); if (hash_has_key(cell_hash , cell_str)) { - hash_type * var_hash = hash_get(cell_hash , cell_str); + hash_type * var_hash = (hash_type*)hash_get(cell_hash , cell_str); if (hash_has_key(var_hash , var)) - node = hash_get( var_hash , var); + node = (const smspec_node_type*)hash_get( var_hash , var); } } free(cell_str); @@ -1564,7 +1630,7 @@ int ecl_smspec_get_well_completion_var_params_index(const ecl_smspec_type * ecl const smspec_node_type * ecl_smspec_get_general_var_node( const ecl_smspec_type * smspec , const char * lookup_kw ) { if (hash_has_key( smspec->gen_var_index , lookup_kw )) { - const smspec_node_type * smspec_node = hash_get( smspec->gen_var_index , lookup_kw ); + const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( smspec->gen_var_index , lookup_kw ); return smspec_node; } else return NULL; @@ -1585,7 +1651,7 @@ bool ecl_smspec_has_general_var(const ecl_smspec_type * ecl_smspec , const char /** DIES if the lookup_kw is not present. */ const char * ecl_smspec_get_general_var_unit( const ecl_smspec_type * ecl_smspec , const char * lookup_kw) { - const smspec_node_type * smspec_node = hash_get( ecl_smspec->gen_var_index , lookup_kw ); + const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( ecl_smspec->gen_var_index , lookup_kw ); return smspec_node_get_unit( smspec_node ); } @@ -1640,6 +1706,10 @@ const char * ecl_smspec_get_header_file( const ecl_smspec_type * ecl_smspec ) { } +int ecl_smspec_get_restart_step(const ecl_smspec_type * ecl_smspec) { + return ecl_smspec->restart_step; +} + const char * ecl_smspec_get_restart_case( const ecl_smspec_type * ecl_smspec) { return ecl_smspec->restart_case; @@ -1698,7 +1768,7 @@ int ecl_smspec_get_date_year_index( const ecl_smspec_type * smspec ) { bool ecl_smspec_general_is_total( const ecl_smspec_type * smspec , const char * gen_key) { - const smspec_node_type * smspec_node = hash_get( smspec->gen_var_index , gen_key ); + const smspec_node_type * smspec_node = (const smspec_node_type*)hash_get( smspec->gen_var_index , gen_key ); return smspec_node_is_total( smspec_node ); } @@ -1844,7 +1914,7 @@ stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec ) { hash_iter_type * well_iter = hash_iter_alloc( smspec->well_var_index ); - hash_type * var_hash = hash_iter_get_next_value( well_iter ); + hash_type * var_hash = (hash_type*)hash_iter_get_next_value( well_iter ); hash_iter_free( well_iter ); return hash_alloc_stringlist( var_hash ); } @@ -1879,8 +1949,12 @@ void ecl_smspec_sort( ecl_smspec_type * smspec ) { vector_sort( smspec->smspec_nodes , smspec_node_cmp__); for (int i=0; i < vector_get_size( smspec->smspec_nodes ); i++) { - smspec_node_type * node = vector_iget( smspec->smspec_nodes , i ); + smspec_node_type * node = (smspec_node_type*)vector_iget( smspec->smspec_nodes , i ); smspec_node_set_params_index( node , i ); } } + +ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_smspec_type * smspec) { + return smspec->unit_system; +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_subsidence.c b/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/ecl_subsidence.c rename to ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp index 4fe053f6f9..301e3ce9a9 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_subsidence.c +++ b/ThirdParty/Ert/lib/ecl/ecl_subsidence.cpp @@ -22,19 +22,19 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include /** @@ -84,14 +84,14 @@ struct ecl_subsidence_survey_struct { static ecl_subsidence_survey_type * ecl_subsidence_survey_alloc_empty(const ecl_subsidence_type * sub, const char * name) { - ecl_subsidence_survey_type * survey = util_malloc( sizeof * survey ); + ecl_subsidence_survey_type * survey = (ecl_subsidence_survey_type*)util_malloc( sizeof * survey ); UTIL_TYPE_ID_INIT( survey , ECL_SUBSIDENCE_SURVEY_ID ); survey->grid_cache = sub->grid_cache; survey->aquifer_cell = sub->aquifer_cell; survey->name = util_alloc_string_copy( name ); - survey->porv = util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->porv ); - survey->pressure = util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->pressure ); + survey->porv = (double*)util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->porv ); + survey->pressure = (double*)util_calloc( ecl_grid_cache_get_size( sub->grid_cache ) , sizeof * survey->pressure ); return survey; } @@ -144,7 +144,7 @@ static double ecl_subsidence_survey_eval( const ecl_subsidence_survey_type * bas const ecl_grid_cache_type * grid_cache = base_survey->grid_cache; const int size = ecl_grid_cache_get_size( grid_cache ); - double * weight = util_calloc( size , sizeof * weight ); + double * weight = (double*)util_calloc( size , sizeof * weight ); double deltaz; int index; @@ -174,7 +174,7 @@ static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_t const double * cell_volume = ecl_grid_cache_get_volume( grid_cache ); const int size = ecl_grid_cache_get_size( grid_cache ); double scale_factor = 1e4 *(1 + poisson_ratio) * ( 1 - 2*poisson_ratio) / ( 4*M_PI*( 1 - poisson_ratio) * youngs_modulus ); - double * weight = util_calloc( size , sizeof * weight ); + double * weight = (double*)util_calloc( size , sizeof * weight ); double deltaz; for (int index = 0; index < size; index++) { @@ -202,7 +202,7 @@ static double ecl_subsidence_survey_eval_geertsma( const ecl_subsidence_survey_t */ ecl_subsidence_type * ecl_subsidence_alloc( const ecl_grid_type * ecl_grid, const ecl_file_type * init_file) { - ecl_subsidence_type * ecl_subsidence = util_malloc( sizeof * ecl_subsidence ); + ecl_subsidence_type * ecl_subsidence = (ecl_subsidence_type*)util_malloc( sizeof * ecl_subsidence ); ecl_subsidence->init_file = init_file; ecl_subsidence->grid_cache = ecl_grid_cache_alloc( ecl_grid ); ecl_subsidence->aquifer_cell = ecl_grav_common_alloc_aquifer_cell( ecl_subsidence->grid_cache , init_file ); @@ -232,7 +232,7 @@ static ecl_subsidence_survey_type * ecl_subsidence_get_survey( const ecl_subside if (name == NULL) return NULL; // Calling scope must determine if this is OK? else - return hash_get( subsidence->surveys , name ); + return (ecl_subsidence_survey_type*)hash_get( subsidence->surveys , name ); } diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum.c b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp similarity index 82% rename from ThirdParty/Ert/lib/ecl/ecl_sum.c rename to ThirdParty/Ert/lib/ecl/ecl_sum.cpp index f9e68cd797..070a70d00b 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum.cpp @@ -22,22 +22,23 @@ #include #include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include /** @@ -95,6 +96,7 @@ struct ecl_sum_struct { UTIL_TYPE_ID_DECLARATION; ecl_smspec_type * smspec; /* Internalized version of the SMSPEC file. */ ecl_sum_data_type * data; /* The data - can be NULL. */ + ecl_sum_type * restart_case; bool fmt_case; @@ -121,7 +123,7 @@ UTIL_IS_INSTANCE_FUNCTION( ecl_sum , ECL_SUM_ID ); The actual loading is implemented in the ecl_sum_data.c file. */ -void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { +void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * input_arg) { util_safe_free( ecl_sum->ecl_case ); util_safe_free( ecl_sum->path ); util_safe_free( ecl_sum->abs_path ); @@ -130,9 +132,9 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { { char *path , *base, *ext; - util_alloc_file_components( ecl_case , &path , &base , &ext); + util_alloc_file_components( input_arg, &path , &base , &ext); - ecl_sum->ecl_case = util_alloc_string_copy( ecl_case ); + ecl_sum->ecl_case = util_alloc_filename( path, base, NULL ); ecl_sum->path = util_alloc_string_copy( path ); ecl_sum->base = util_alloc_string_copy( base ); ecl_sum->ext = util_alloc_string_copy( ext ); @@ -149,7 +151,10 @@ void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case) { static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key_join_string) { - ecl_sum_type * ecl_sum = util_malloc( sizeof * ecl_sum ); + if (!ecl_util_path_access(input_arg)) + return NULL; + + ecl_sum_type * ecl_sum = (ecl_sum_type*)util_malloc( sizeof * ecl_sum ); UTIL_TYPE_ID_INIT( ecl_sum , ECL_SUM_ID ); ecl_sum->ecl_case = NULL; @@ -162,6 +167,7 @@ static ecl_sum_type * ecl_sum_alloc__( const char * input_arg , const char * key ecl_sum->smspec = NULL; ecl_sum->data = NULL; + ecl_sum->restart_case = NULL; return ecl_sum; } @@ -177,11 +183,17 @@ static bool ecl_sum_fread_data( ecl_sum_type * ecl_sum , const stringlist_type * static void ecl_sum_fread_history( ecl_sum_type * ecl_sum ) { - ecl_sum_type * history = ecl_sum_fread_alloc_case__( ecl_smspec_get_restart_case( ecl_sum->smspec ) , ":" , true); - if (history) { - ecl_sum_data_add_case(ecl_sum->data , history->data ); - ecl_sum_free( history ); + char * restart_header = ecl_util_alloc_filename(NULL, + ecl_smspec_get_restart_case(ecl_sum->smspec), + ECL_SUMMARY_HEADER_FILE, + ecl_smspec_get_formatted(ecl_sum->smspec), + -1); + ecl_sum_type * restart_case = ecl_sum_fread_alloc_case__(restart_header, ":" , true); + if (restart_case) { + ecl_sum->restart_case = restart_case; + ecl_sum_data_add_case(ecl_sum->data , restart_case->data ); } + free(restart_header); } @@ -244,9 +256,11 @@ static bool ecl_sum_fread_case( ecl_sum_type * ecl_sum , bool include_restart) { ecl_sum_type * ecl_sum_fread_alloc(const char *header_file , const stringlist_type *data_files , const char * key_join_string, bool include_restart) { ecl_sum_type * ecl_sum = ecl_sum_alloc__( header_file , key_join_string ); - if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart)) { - ecl_sum_free( ecl_sum ); - ecl_sum = NULL; + if (ecl_sum) { + if (!ecl_sum_fread( ecl_sum , header_file , data_files , include_restart)) { + ecl_sum_free( ecl_sum ); + ecl_sum = NULL; + } } return ecl_sum; } @@ -274,6 +288,15 @@ smspec_node_type * ecl_sum_add_var( ecl_sum_type * ecl_sum , const char * keywor return smspec_node; } +smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node) { + return ecl_sum_add_var(ecl_sum, + smspec_node_get_keyword(node), + smspec_node_get_wgname(node), + smspec_node_get_num(node), + smspec_node_get_unit(node), + smspec_node_get_default(node)); +} + smspec_node_type * ecl_sum_add_blank_var( ecl_sum_type * ecl_sum , float default_value) { smspec_node_type * smspec_node = smspec_node_alloc_new( -1 , default_value ); @@ -299,23 +322,49 @@ ecl_sum_tstep_type * ecl_sum_add_tstep( ecl_sum_type * ecl_sum , int report_step return ecl_sum_data_add_new_tstep( ecl_sum->data , report_step , sim_seconds ); } +static ecl_sum_type * ecl_sum_alloc_writer__( const char * ecl_case , const char * restart_case , int restart_step, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { -ecl_sum_type * ecl_sum_alloc_restart_writer( const char * ecl_case , const char * restart_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { - ecl_sum_type * ecl_sum = ecl_sum_alloc__( ecl_case , key_join_string ); - ecl_sum_set_unified( ecl_sum , unified ); - ecl_sum_set_fmt_case( ecl_sum , fmt_output ); + if (ecl_sum) { + ecl_sum_set_unified( ecl_sum , unified ); + ecl_sum_set_fmt_case( ecl_sum , fmt_output ); - ecl_sum->smspec = ecl_smspec_alloc_writer( key_join_string , restart_case, sim_start , time_in_days , nx , ny , nz ); - ecl_sum->data = ecl_sum_data_alloc_writer( ecl_sum->smspec ); + if (restart_case) + ecl_sum->smspec = ecl_smspec_alloc_restart_writer( key_join_string , restart_case, restart_step, sim_start , time_in_days , nx , ny , nz ); + else + ecl_sum->smspec = ecl_smspec_alloc_writer( key_join_string, sim_start, time_in_days, nx, ny, nz); + ecl_sum->data = ecl_sum_data_alloc_writer( ecl_sum->smspec ); + } return ecl_sum; } + +ecl_sum_type * ecl_sum_alloc_restart_writer2( const char * ecl_case , const char * restart_case , int restart_step, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + return ecl_sum_alloc_writer__(ecl_case, restart_case, restart_step, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); +} + + +/* + This does not take in the restart_step argument is depcrecated. You should use the + ecl_sum_alloc_restart_writer2() function. +*/ + +ecl_sum_type * ecl_sum_alloc_restart_writer( const char * ecl_case , const char * restart_case, bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { + int restart_step = 0; + return ecl_sum_alloc_writer__(ecl_case, restart_case, restart_step, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); +} + + + + + + ecl_sum_type * ecl_sum_alloc_writer( const char * ecl_case , bool fmt_output , bool unified , const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz) { - return ecl_sum_alloc_restart_writer(ecl_case, NULL, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); + return ecl_sum_alloc_writer__(ecl_case, NULL, 0, fmt_output, unified, key_join_string, sim_start, time_in_days, nx, ny, nz); } + void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ) { ecl_sum_fwrite_smspec( ecl_sum ); ecl_sum_data_fwrite( ecl_sum->data , ecl_sum->ecl_case , ecl_sum->fmt_case , ecl_sum->unified ); @@ -342,10 +391,13 @@ void ecl_sum_free_data( ecl_sum_type * ecl_sum ) { void ecl_sum_free( ecl_sum_type * ecl_sum ) { - if (ecl_sum->data != NULL) + if (ecl_sum->restart_case) + ecl_sum_free(ecl_sum->restart_case); + + if (ecl_sum->data) ecl_sum_free_data( ecl_sum ); - if (ecl_sum->smspec != NULL) + if (ecl_sum->smspec) ecl_smspec_free( ecl_sum->smspec ); util_safe_free( ecl_sum->path ); @@ -390,7 +442,10 @@ void ecl_sum_free__(void * __ecl_sum) { ecl_sum_type * ecl_sum_fread_alloc_case__(const char * input_file , const char * key_join_string , bool include_restart){ - ecl_sum_type * ecl_sum = ecl_sum_alloc__(input_file , key_join_string); + ecl_sum_type * ecl_sum = ecl_sum_alloc__(input_file , key_join_string); + if (!ecl_sum) + return NULL; + if (ecl_sum_fread_case( ecl_sum , include_restart)) return ecl_sum; else { @@ -662,6 +717,9 @@ double ecl_sum_get_general_var(const ecl_sum_type * ecl_sum , int time_index , c return ecl_sum_data_iget( ecl_sum->data , time_index , params_index); } +#ifdef __cplusplus +extern "C" { + void ecl_sum_get_interp_vector(const ecl_sum_type * ecl_sum, time_t sim_time, const ecl_sum_vector_type * key_words, double_vector_type * data){ ecl_sum_data_get_interp_vector(ecl_sum->data, sim_time, key_words, data); } @@ -670,6 +728,9 @@ void ecl_sum_fwrite_interp_csv_line(const ecl_sum_type * ecl_sum, time_t sim_tim ecl_sum_data_fwrite_interp_csv_line(ecl_sum->data, sim_time, key_words, fp); } +} +#endif + double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var) { @@ -690,6 +751,67 @@ const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const /*****************************************************************/ + +ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times) { + time_t start_time = ecl_sum_get_data_start(ecl_sum); + + if ( time_t_vector_get_first(times) < start_time ) + return NULL; + if ( time_t_vector_get_last(times) > ecl_sum_get_end_time(ecl_sum) ) + return NULL; + if ( !time_t_vector_is_sorted(times, false) ) + return NULL; + + const int * grid_dims = ecl_smspec_get_grid_dims(ecl_sum->smspec); + + bool time_in_days = false; + const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, 0); + if ( util_string_equal(smspec_node_get_unit(node), "DAYS" ) ) + time_in_days = true; + + ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_writer( ecl_case , ecl_sum->fmt_case , ecl_sum->unified , ecl_sum->key_join_string , start_time , time_in_days , grid_dims[0] , grid_dims[1] , grid_dims[2] ); + + + + for (int i = 0; i < ecl_smspec_num_nodes(ecl_sum->smspec); i++) { + const smspec_node_type * node = ecl_smspec_iget_node(ecl_sum->smspec, i); + if (util_string_equal(smspec_node_get_gen_key1(node), "TIME")) + continue; + + if (!smspec_node_is_valid(node)) + continue; + + ecl_sum_add_smspec_node( ecl_sum_resampled, node ); + } + + /* + The SMSPEC header structure has been completely initialized, it is time to + start filling it up with data. + */ + ecl_sum_vector_type * ecl_sum_vector = ecl_sum_vector_alloc(ecl_sum, true); + double_vector_type * data = double_vector_alloc( ecl_sum_vector_get_size(ecl_sum_vector) , 0); + + + for (int report_step = 0; report_step < time_t_vector_size(times); report_step++) { + time_t t = time_t_vector_iget(times, report_step); + + /* Look up interpolated data in the original case. */ + ecl_sum_get_interp_vector( ecl_sum, t, ecl_sum_vector, data); + + /* Add timestep corresponding to the interpolated data in the resampled case. */ + ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum_resampled , report_step , t - start_time); + for (int data_index = 0; data_index < ecl_sum_vector_get_size(ecl_sum_vector); data_index++) { + double value = double_vector_iget(data,data_index); + int params_index = data_index + 1; // The +1 shift is because the first element in the tstep is time value. + ecl_sum_tstep_iset(tstep, params_index, value); + } + } + double_vector_free( data ); + ecl_sum_vector_free( ecl_sum_vector ); + return ecl_sum_resampled; +} + + double ecl_sum_iget( const ecl_sum_type * ecl_sum , int time_index , int param_index) { return ecl_sum_data_iget(ecl_sum->data , time_index , param_index); } @@ -791,6 +913,38 @@ void ecl_sum_init_data_vector( const ecl_sum_type * ecl_sum , double_vector_type } +void ecl_sum_init_double_vector__(const ecl_sum_type * ecl_sum, int params_index, double * data) { + ecl_sum_data_init_double_vector(ecl_sum->data, params_index, data); +} + + +void ecl_sum_init_double_vector(const ecl_sum_type * ecl_sum, const char * gen_key, double * data) { + int params_index = ecl_sum_get_general_var_params_index(ecl_sum, gen_key); + ecl_sum_init_double_vector__(ecl_sum, params_index, data); +} + +void ecl_sum_init_double_vector_interp(const ecl_sum_type * ecl_sum, const char * gen_key, const time_t_vector_type * time_points, double * data) { + const smspec_node_type * node = ecl_smspec_get_general_var_node( ecl_sum->smspec , gen_key); + ecl_sum_data_init_double_vector_interp(ecl_sum->data, node, time_points, data); +} + + + + +void ecl_sum_init_datetime64_vector(const ecl_sum_type * ecl_sum, int64_t * data, int multiplier) { + ecl_sum_data_init_datetime64_vector(ecl_sum->data, data, multiplier); +} + +void ecl_sum_init_double_frame(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, double * data) { + ecl_sum_data_init_double_frame(ecl_sum->data, keywords, data); +} + + +void ecl_sum_init_double_frame_interp(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, const time_t_vector_type * time_points, double * data) { + ecl_sum_data_init_double_frame_interp(ecl_sum->data, keywords, time_points, data); +} + + double_vector_type * ecl_sum_alloc_data_vector( const ecl_sum_type * ecl_sum , int data_index , bool report_only) { return ecl_sum_data_alloc_data_vector( ecl_sum->data , data_index , report_only ); } @@ -861,9 +1015,6 @@ time_t ecl_sum_iget_sim_time( const ecl_sum_type * ecl_sum , int index ) { return ecl_sum_data_iget_sim_time( ecl_sum->data , index ); } -const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum) { - return ecl_sum_data_get_sim_time( ecl_sum->data ); -} time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ) { return ecl_sum_data_get_data_start( ecl_sum->data ); @@ -975,7 +1126,7 @@ static void ecl_sum_fprintf_header( const ecl_sum_type * ecl_sum , const stringl void ecl_sum_fprintf(const ecl_sum_type * ecl_sum , FILE * stream , const stringlist_type * var_list , bool report_only , const ecl_sum_fmt_type * fmt) { bool_vector_type * has_var = bool_vector_alloc( stringlist_get_size( var_list ), false ); int_vector_type * var_index = int_vector_alloc( stringlist_get_size( var_list ), -1 ); - char * date_string = util_malloc( DATE_STRING_LENGTH * sizeof * date_string); + char * date_string = (char*)util_malloc( DATE_STRING_LENGTH * sizeof * date_string); char * current_locale = NULL; if (fmt->locale != NULL) @@ -1053,6 +1204,14 @@ void ecl_sum_export_csv(const ecl_sum_type * ecl_sum , const char * filename , } +const ecl_sum_type * ecl_sum_get_restart_case(const ecl_sum_type * ecl_sum) { + return ecl_sum->restart_case; +} + +int ecl_sum_get_restart_step(const ecl_sum_type * ecl_sum) { + return ecl_smspec_get_restart_step(ecl_sum->smspec); +} + const char * ecl_sum_get_case(const ecl_sum_type * ecl_sum) { return ecl_sum->ecl_case; @@ -1300,3 +1459,34 @@ time_t_vector_type * ecl_sum_alloc_time_solution( const ecl_sum_type * ecl_sum , } return solution; } + + +ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type * ecl_sum) { + return ecl_smspec_get_unit_system(ecl_sum->smspec); +} + +double ecl_sum_iget_last_value(const ecl_sum_type * ecl_sum, int param_index) { + return ecl_sum_data_iget_last_value(ecl_sum->data, param_index); +} + +double ecl_sum_get_last_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key) { + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node)); +} + +double ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node) { + return ecl_sum_iget_last_value(ecl_sum, smspec_node_get_params_index(node)); +} + +double ecl_sum_iget_first_value(const ecl_sum_type * ecl_sum, int param_index) { + return ecl_sum_data_iget_first_value(ecl_sum->data, param_index); +} + +double ecl_sum_get_first_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key) { + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum , gen_key ); + return ecl_sum_iget_first_value(ecl_sum, smspec_node_get_params_index(node)); +} + +double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node) { + return ecl_sum_iget_first_value(ecl_sum, smspec_node_get_params_index(node)); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp similarity index 80% rename from ThirdParty/Ert/lib/ecl/ecl_sum_data.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp index c0b28cdc43..a1d3e0f3f1 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_data.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_data.cpp @@ -17,24 +17,24 @@ */ #include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include @@ -206,25 +206,21 @@ #define INVALID_MINISTEP_NR -1 - +#define INVALID_TIME_T 0 struct ecl_sum_data_struct { ecl_smspec_type * smspec; /* A shared reference - only used for providing good error messages. */ vector_type * data; /* Vector of ecl_sum_tstep_type instances. */ - int first_ministep; - int last_ministep; double days_start; double sim_length; int_vector_type * report_first_index ; /* Indexed by report_step - giving first internal_index in report_step. */ int_vector_type * report_last_index; /* Indexed by report_step - giving last internal_index in report_step. */ int first_report_step; int last_report_step; - time_t __min_time; /* An internal member used during the load of - restarted cases; see doc in ecl_sum_data_append_tstep. */ bool index_valid; - time_interval_type * sim_time; /* The time interval sim_time goes from the first time value where we have - data to the end of the simulation. In the case of restarts the start - value might disagree with the simulation start reported by the smspec file. */ + time_t start_time; /* In the case of restarts the start might disagree with the value reported + in the smspec file. */ + time_t end_time; }; @@ -237,7 +233,6 @@ struct ecl_sum_data_struct { vector_free( data->data ); int_vector_free( data->report_first_index ); int_vector_free( data->report_last_index ); - time_interval_free( data->sim_time ); free(data); } @@ -256,22 +251,19 @@ static void ecl_sum_data_clear_index( ecl_sum_data_type * data ) { data->last_report_step = -1024 * 1024; data->days_start = 0; data->sim_length = -1; - data->first_ministep = INVALID_MINISTEP_NR; - data->last_ministep = INVALID_MINISTEP_NR; data->index_valid = false; - time_interval_reopen( data->sim_time ); + data->start_time = INVALID_TIME_T; + data->end_time = INVALID_TIME_T; } ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { - ecl_sum_data_type * data = util_malloc( sizeof * data ); + ecl_sum_data_type * data = (ecl_sum_data_type*)util_malloc( sizeof * data ); data->data = vector_alloc_new(); data->smspec = smspec; - data->__min_time = 0; data->report_first_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); data->report_last_index = int_vector_alloc( 0 , INVALID_MINISTEP_NR ); - data->sim_time = time_interval_alloc_open(); ecl_sum_data_clear_index( data ); return data; @@ -301,7 +293,7 @@ ecl_sum_data_type * ecl_sum_data_alloc(ecl_smspec_type * smspec) { static ecl_sum_tstep_type * ecl_sum_data_iget_ministep( const ecl_sum_data_type * data , int internal_index ) { - return vector_iget( data->data , internal_index ); + return (ecl_sum_tstep_type*)vector_iget( data->data , internal_index ); } @@ -438,11 +430,10 @@ void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case -const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data) { return data->sim_time; } -time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return time_interval_get_end( data->sim_time ); } +time_t ecl_sum_data_get_sim_end (const ecl_sum_data_type * data ) { return data->end_time; } -time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return time_interval_get_start( data->sim_time ); } +time_t ecl_sum_data_get_data_start ( const ecl_sum_data_type * data ) { return data->start_time; } double ecl_sum_data_get_first_day( const ecl_sum_data_type * data) { return data->days_start; } @@ -471,8 +462,13 @@ double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ) { */ bool ecl_sum_data_check_sim_time( const ecl_sum_data_type * data , time_t sim_time) { - return (time_interval_contains(data->sim_time, sim_time) - || (sim_time == time_interval_get_end(data->sim_time))); + if (sim_time < data->start_time) + return false; + + if (sim_time > data->end_time) + return false; + + return true; } @@ -521,15 +517,12 @@ bool ecl_sum_data_check_sim_days( const ecl_sum_data_type * data , double sim_da static int ecl_sum_data_get_index_from_sim_time( const ecl_sum_data_type * data , time_t sim_time) { - time_t data_start_time = time_interval_get_start(data->sim_time); - time_t sim_end = time_interval_get_end(data->sim_time); - if (!ecl_sum_data_check_sim_time(data, sim_time)) { fprintf(stderr , "Simulation start: "); util_fprintf_date_utc( ecl_smspec_get_start_time( data->smspec ) , stderr ); - fprintf(stderr , "Data start......: "); util_fprintf_date_utc( data_start_time , stderr ); - fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( sim_end , stderr ); + fprintf(stderr , "Data start......: "); util_fprintf_date_utc( data->start_time , stderr ); + fprintf(stderr , "Simulation end .: "); util_fprintf_date_utc( data->end_time , stderr ); fprintf(stderr , "Requested date .: "); util_fprintf_date_utc( sim_time , stderr ); - util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data_start_time , sim_end); + util_abort("%s: invalid time_t instance:%d interval: [%d,%d]\n",__func__, sim_time , data->start_time , data->end_time); } /* @@ -682,48 +675,11 @@ static void ecl_sum_data_append_tstep__( ecl_sum_data_type * data , ecl_sum_tste sorted by ministep_nr before the data instance is returned. */ - /* - We keep track of the earliest (in true time sence) tstep we - have added so far; this is done somewhat manuyally because we need - this information before the index is ready. - - The __min_time field is used to limit loading of restarted data in - time periods where both the main case and the source case we have - restarted from have data. This situation typically arises when we - have restarted a simulation from a report step before the end of - the initial simulation: - - Simulation 1: T1-------------TR------------T2 - | - Simulation 2: \-----------------------T3 - - - In the time interval [TR,T2] we have data from two simulations, we - want to use only the data from simulation 2 in this period. The - decision whether to to actually append the ministep or not must - have been performed by the scope calling this function; when a - ministep has arrived here it will be added. - */ - - if (data->__min_time == 0) - data->__min_time = ecl_sum_tstep_get_sim_time( tstep ); - else { - if (ecl_sum_tstep_get_sim_time( tstep ) < data->__min_time) - data->__min_time = ecl_sum_tstep_get_sim_time( tstep ); - } - vector_append_owned_ref( data->data , tstep , ecl_sum_tstep_free__); data->index_valid = false; } -static void ecl_sum_data_update_end_info( ecl_sum_data_type * sum_data ) { - const ecl_sum_tstep_type * last_ministep = vector_get_last_const( sum_data->data ); - - sum_data->last_ministep = ecl_sum_tstep_get_ministep( last_ministep ); - sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep ); - time_interval_update_end( sum_data->sim_time , ecl_sum_tstep_get_sim_time( last_ministep )); -} static int cmp_ministep( const void * arg1 , const void * arg2) { const ecl_sum_tstep_type * ministep1 = ecl_sum_tstep_safe_cast_const( arg1 ); @@ -753,9 +709,8 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { /* Identify various global first and last values. */ { - const ecl_sum_tstep_type * first_ministep = ecl_sum_data_iget_ministep( sum_data , 0 ); - sum_data->first_ministep = ecl_sum_tstep_get_ministep( first_ministep ); - + const ecl_sum_tstep_type * first_ministep = (const ecl_sum_tstep_type*)vector_iget_const( sum_data->data, 0 ); + const ecl_sum_tstep_type * last_ministep = (const ecl_sum_tstep_type*)vector_get_last_const( sum_data->data ); /* In most cases the days_start and data_start_time will agree with the global simulation start; however in the case where we @@ -764,9 +719,10 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { will be a difference. */ sum_data->days_start = ecl_sum_tstep_get_sim_days( first_ministep ); - time_interval_update_start( sum_data->sim_time , ecl_sum_tstep_get_sim_time( first_ministep )); + sum_data->sim_length = ecl_sum_tstep_get_sim_days( last_ministep ); + sum_data->start_time = ecl_sum_tstep_get_sim_time( first_ministep); + sum_data->end_time = ecl_sum_tstep_get_sim_time( last_ministep ); } - ecl_sum_data_update_end_info( sum_data ); /* Build up the report -> ministep mapping. */ { @@ -775,27 +731,27 @@ static void ecl_sum_data_build_index( ecl_sum_data_type * sum_data ) { const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( sum_data , internal_index ); int report_step = ecl_sum_tstep_get_report(ministep); - /* Indexing internal_index - report_step */ - { - int current_first_index = int_vector_safe_iget( sum_data->report_first_index , report_step ); - if (current_first_index < 0) /* i.e. currently not set. */ + /* Indexing internal_index - report_step */ + { + int current_first_index = int_vector_safe_iget( sum_data->report_first_index , report_step ); + if (current_first_index < 0) /* i.e. currently not set. */ int_vector_iset( sum_data->report_first_index , report_step , internal_index); - else - if (internal_index < current_first_index) - int_vector_iset( sum_data->report_first_index , report_step , internal_index); - } + else + if (internal_index < current_first_index) + int_vector_iset( sum_data->report_first_index , report_step , internal_index); + } - { - int current_last_index = int_vector_safe_iget( sum_data->report_last_index , report_step ); - if (current_last_index < 0) - int_vector_iset( sum_data->report_last_index , report_step , internal_index); - else - if (internal_index > current_last_index) - int_vector_iset( sum_data->report_last_index , report_step , internal_index); - } + { + int current_last_index = int_vector_safe_iget( sum_data->report_last_index , report_step ); + if (current_last_index < 0) + int_vector_iset( sum_data->report_last_index , report_step , internal_index); + else + if (internal_index > current_last_index) + int_vector_iset( sum_data->report_last_index , report_step , internal_index); + } - sum_data->first_report_step = util_int_min( sum_data->first_report_step , report_step ); - sum_data->last_report_step = util_int_max( sum_data->last_report_step , report_step ); + sum_data->first_report_step = util_int_min( sum_data->first_report_step , report_step ); + sum_data->last_report_step = util_int_max( sum_data->last_report_step , report_step ); } } sum_data->index_valid = true; @@ -816,7 +772,7 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int ecl_sum_tstep_type * prev_tstep = NULL; if (vector_get_size( data->data ) > 0) - prev_tstep = vector_get_last( data->data ); + prev_tstep = (ecl_sum_tstep_type*)vector_get_last( data->data ); ecl_sum_data_append_tstep__( data , tstep ); { @@ -833,9 +789,11 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int if (ecl_sum_tstep_get_report( prev_tstep ) == ecl_sum_tstep_get_report( tstep )) { // Same report step if (ecl_sum_tstep_get_sim_days( prev_tstep ) < ecl_sum_tstep_get_sim_days( tstep )) { // This tstep will become the new latest tstep int internal_index = vector_get_size( data->data ) - 1; - - ecl_sum_data_update_end_info( data ); int_vector_iset( data->report_last_index , report_step , internal_index ); + + data->sim_length = ecl_sum_tstep_get_sim_days( tstep ); + data->end_time = ecl_sum_tstep_get_sim_time(tstep); + rebuild_index = false; } } @@ -877,7 +835,6 @@ ecl_sum_tstep_type * ecl_sum_data_add_new_tstep( ecl_sum_data_type * data , int */ static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , - time_t load_end , int report_step , const ecl_file_view_type * summary_view, const ecl_smspec_type * smspec) { @@ -892,22 +849,15 @@ static void ecl_sum_data_add_ecl_file(ecl_sum_data_type * data , ecl_kw_type * params_kw = ecl_file_view_iget_named_kw( summary_view , PARAMS_KW , ikw); { - ecl_sum_tstep_type * tstep; int ministep_nr = ecl_kw_iget_int( ministep_kw , 0 ); - tstep = ecl_sum_tstep_alloc_from_file( report_step , - ministep_nr , - params_kw , - ecl_file_view_get_src_file( summary_view ), - smspec ); - - if (tstep != NULL) { - if (load_end == 0 || (ecl_sum_tstep_get_sim_time( tstep ) < load_end)) + ecl_sum_tstep_type * tstep = ecl_sum_tstep_alloc_from_file( report_step , + ministep_nr , + params_kw , + ecl_file_view_get_src_file( summary_view ), + smspec ); + + if (tstep) ecl_sum_data_append_tstep__( data , tstep ); - else - /* This tstep is in a time-period overlapping with data we - already have; discard this. */ - ecl_sum_tstep_free( tstep ); - } } } } @@ -927,12 +877,18 @@ void ecl_sum_data_add_case(ecl_sum_data_type * self, const ecl_sum_data_type * o ecl_sum_tstep_type * other_tstep = ecl_sum_data_iget_ministep( other , tstep_nr ); /* - The dataset 'self' is the authorative in the timeinterval where - it has data, so if 'other' also has data in the same time interval - that is discarded. + The dataset 'self' is the authorative in the timeinterval where it has + data, so if 'other' also has data in the same time interval that is + discarded. In most cases 'other' will represent a history case, and 'self' + is a prediction which has been restarted. + + After implementing the time_interval_contains() based check it turned out + that the smspec structure also contains a restart_step integer value in + the DIMENS vector which could probably be used to achieve the same thing. + That field is currently not used. */ - if (!time_interval_contains( self->sim_time , ecl_sum_tstep_get_sim_time( other_tstep ))) { + if (!ecl_sum_data_check_sim_time(self, ecl_sum_tstep_get_sim_time(other_tstep))) { ecl_sum_tstep_type * new_tstep; if (header_equal) @@ -968,7 +924,7 @@ static bool ecl_sum_data_check_file( ecl_file_type * ecl_file ) { call to ecl_sum_data_build_index(). */ -static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , const stringlist_type * filelist) { +bool ecl_sum_data_fread(ecl_sum_data_type * data , const stringlist_type * filelist) { if (stringlist_get_size( filelist ) == 0) return false; @@ -992,7 +948,7 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c { ecl_file_type * ecl_file = ecl_file_open( data_file , 0); if (ecl_file && ecl_sum_data_check_file( ecl_file )) { - ecl_sum_data_add_ecl_file( data , load_end , report_step , ecl_file_get_global_view( ecl_file ) , data->smspec); + ecl_sum_data_add_ecl_file( data , report_step , ecl_file_get_global_view( ecl_file ) , data->smspec); ecl_file_close( ecl_file ); } } @@ -1011,7 +967,7 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c */ ecl_file_view_type * summary_view = ecl_file_get_summary_view(ecl_file , report_step - 1 ); if (summary_view) { - ecl_sum_data_add_ecl_file( data , load_end , report_step , summary_view , data->smspec); + ecl_sum_data_add_ecl_file( data , report_step , summary_view , data->smspec); report_step++; } else break; } @@ -1030,22 +986,9 @@ static bool ecl_sum_data_fread__( ecl_sum_data_type * data , time_t load_end , c } } -bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist) { - return ecl_sum_data_fread__( data , 0 , filelist ); -} -static time_t ecl_sum_data_get_load_end( const ecl_sum_data_type * data ) { - return data->__min_time; -} - - - -void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist) { - time_t load_end = ecl_sum_data_get_load_end( data ); - ecl_sum_data_fread__( data , load_end , filelist ); -} @@ -1061,7 +1004,7 @@ void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_typ ecl_sum_data_type * ecl_sum_data_fread_alloc( ecl_smspec_type * smspec , const stringlist_type * filelist , bool include_restart) { ecl_sum_data_type * data = ecl_sum_data_alloc( smspec ); - ecl_sum_data_fread__( data , 0 , filelist ); + ecl_sum_data_fread( data , filelist ); /*****************************************************************/ /* OK - now we have loaded all the data. Must sort the internal @@ -1180,12 +1123,10 @@ double ecl_sum_data_interp_get(const ecl_sum_data_type * data , int time_index1 } -static double ecl_sum_data_vector_iget(const ecl_sum_data_type * data, time_t sim_time, const ecl_sum_vector_type * keylist, int key_index, +static double ecl_sum_data_vector_iget(const ecl_sum_data_type * data, time_t sim_time, int params_index, bool is_rate, int time_index1 , int time_index2 , double weight1 , double weight2 ) { - int params_index = ecl_sum_vector_iget_param_index(keylist, key_index); double value = 0.0; - bool is_rate = ecl_sum_vector_iget_is_rate(keylist, key_index); if (is_rate) { int time_index = ecl_sum_data_get_index_from_sim_time(data, sim_time); // uses step function since it is a rate @@ -1205,15 +1146,35 @@ void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data, time_t ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); for (int i = 0; i < num_keywords; i++) { - double value = ecl_sum_data_vector_iget( data, sim_time, keylist , i , time_index1, time_index2, weight1, weight2); + if (ecl_sum_vector_iget_valid(keylist, i)) { + int params_index = ecl_sum_vector_iget_param_index(keylist, i); + bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); + double value = ecl_sum_data_vector_iget( data, sim_time, params_index , is_rate, time_index1, time_index2, weight1, weight2); - if (i == 0) - fprintf(fp, "%f", value); - else - fprintf(fp, ",%f", value); + if (i == 0) + fprintf(fp, "%f", value); + else + fprintf(fp, ",%f", value); + } else { + if (i == 0) + fputs("", fp); + else + fputs(",", fp); + } } } + +/* + If the keylist contains invalid indices the corresponding element in the + results vector will *not* be updated; i.e. it is smart to initialize the + results vector with an invalid-value marker before calling this function: + + double_vector_type * results = double_vector_alloc( ecl_sum_vector_get_size(keys), NAN); + ecl_sum_data_get_interp_vector( data, sim_time, keys, results); + +*/ + void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, double_vector_type * results){ int num_keywords = ecl_sum_vector_get_size(keylist); double weight1, weight2; @@ -1222,8 +1183,12 @@ void ecl_sum_data_get_interp_vector( const ecl_sum_data_type * data , time_t sim ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); double_vector_reset( results ); for (int i = 0; i < num_keywords; i++) { - double value = ecl_sum_data_vector_iget( data, sim_time, keylist , i , time_index1, time_index2, weight1, weight2); - double_vector_iset( results, i , value ); + if (ecl_sum_vector_iget_valid(keylist, i)) { + int params_index = ecl_sum_vector_iget_param_index(keylist, i); + bool is_rate = ecl_sum_vector_iget_is_rate(keylist, i); + double value = ecl_sum_data_vector_iget( data, sim_time, params_index, is_rate, time_index1, time_index2, weight1, weight2); + double_vector_iset( results, i , value ); + } } } @@ -1269,7 +1234,7 @@ int ecl_sum_data_get_report_step_from_days(const ecl_sum_data_type * data , doub for (i=1; i < int_vector_size( data->report_last_index ); i++) { int ministep_index = int_vector_iget( data->report_last_index , i ); - const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index ); + const ecl_sum_tstep_type * ministep = (const ecl_sum_tstep_type*)vector_iget_const( data->data , ministep_index ); double_vector_iset( days_map , i , ecl_sum_tstep_get_sim_days( ministep )); int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep )); @@ -1323,7 +1288,7 @@ int ecl_sum_data_get_report_step_from_time(const ecl_sum_data_type * data , time for (i=1; i < int_vector_size( data->report_last_index ); i++) { int ministep_index = int_vector_iget( data->report_last_index , i ); - const ecl_sum_tstep_type * ministep = vector_iget_const( data->data , ministep_index ); + const ecl_sum_tstep_type * ministep = (const ecl_sum_tstep_type*)vector_iget_const( data->data , ministep_index ); time_t_vector_iset( time_map , i , ecl_sum_tstep_get_sim_time( ministep )); int_vector_iset( report_map , i , ecl_sum_tstep_get_report( ministep )); @@ -1389,14 +1354,6 @@ int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data ) { } -int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data ) { - return data->first_ministep; -} - -int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data ) { - return data->last_ministep; -} - /*****************************************************************/ /* High level vector routines */ @@ -1414,7 +1371,7 @@ void ecl_sum_data_init_time_vector( const ecl_sum_data_type * data , time_t_vect } } else { int i; - for (i = 0; i < vector_get_size(data->data); i++) { + for (i = 1; i < vector_get_size(data->data); i++) { const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i ); time_t_vector_append( time_vector , ecl_sum_tstep_get_sim_time( ministep )); } @@ -1455,6 +1412,132 @@ double_vector_type * ecl_sum_data_alloc_data_vector( const ecl_sum_data_type * d } +void ecl_sum_data_init_double_vector(const ecl_sum_data_type * data, int params_index, double * output_data) { + int i; + for (i = 0; i < vector_get_size(data->data); i++) { + const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i ); + output_data[i] = ecl_sum_tstep_iget(ministep, params_index); + } +} + +void ecl_sum_data_init_datetime64_vector(const ecl_sum_data_type * data, int64_t * output_data, int multiplier) { + int i; + for (i = 0; i < vector_get_size(data->data); i++) { + const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep( data , i ); + output_data[i] = ecl_sum_tstep_get_sim_time(ministep) * multiplier; + } +} + +void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data, + const smspec_node_type * smspec_node, + const time_t_vector_type * time_points, + double * output_data) { + bool is_rate = smspec_node_is_rate(smspec_node); + int params_index = smspec_node_get_params_index(smspec_node); + time_t start_time = ecl_sum_data_get_data_start(data); + time_t end_time = ecl_sum_data_get_sim_end(data); + double start_value = 0; + double end_value = 0; + + if (!is_rate) { + start_value = ecl_sum_data_iget_first_value(data, params_index); + end_value = ecl_sum_data_iget_last_value(data, params_index); + } + + for (int time_index=0; time_index < time_t_vector_size(time_points); time_index++) { + time_t sim_time = time_t_vector_iget( time_points, time_index); + double value; + if (sim_time < start_time) + value = start_value; + + else if (sim_time > end_time) + value = end_value; + + else { + int time_index1, time_index2; + double weight1, weight2; + ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); + value = ecl_sum_data_vector_iget( data, + sim_time, + params_index, + is_rate, + time_index1, + time_index2, + weight1, + weight2); + } + + output_data[time_index] = value; + } +} + + + + +void ecl_sum_data_init_double_frame(const ecl_sum_data_type * data, const ecl_sum_vector_type * keywords, double *output_data) { + int time_stride = ecl_sum_vector_get_size(keywords); + int key_stride = 1; + for (int time_index=0; time_index < vector_get_size(data->data); time_index++) { + const ecl_sum_tstep_type * ministep = ecl_sum_data_iget_ministep(data , time_index); + for (int key_index = 0; key_index < ecl_sum_vector_get_size(keywords); key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index * time_stride; + + output_data[data_index] = ecl_sum_tstep_iget(ministep, param_index); + } + } +} + + +void ecl_sum_data_init_double_frame_interp(const ecl_sum_data_type * data, + const ecl_sum_vector_type * keywords, + const time_t_vector_type * time_points, + double * output_data) { + int num_keywords = ecl_sum_vector_get_size(keywords); + int time_stride = num_keywords; + int key_stride = 1; + time_t start_time = ecl_sum_data_get_data_start(data); + time_t end_time = ecl_sum_data_get_sim_end(data); + + + for (int time_index=0; time_index < time_t_vector_size(time_points); time_index++) { + time_t sim_time = time_t_vector_iget( time_points, time_index); + if (sim_time < start_time) { + for (int key_index = 0; key_index < num_keywords; key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index*time_stride; + bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + if (is_rate) + output_data[data_index] = 0; + else + output_data[data_index] = ecl_sum_data_iget_first_value(data, param_index); + } + } else if (sim_time > end_time) { + for (int key_index = 0; key_index < num_keywords; key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index*time_stride; + bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + if (is_rate) + output_data[data_index] = 0; + else + output_data[data_index] = ecl_sum_data_iget_last_value(data, param_index); + } + } else { + double weight1, weight2; + int time_index1, time_index2; + + ecl_sum_data_init_interp_from_sim_time(data, sim_time, &time_index1, &time_index2, &weight1, &weight2); + + for (int key_index = 0; key_index < num_keywords; key_index++) { + int param_index = ecl_sum_vector_iget_param_index(keywords, key_index); + int data_index = key_index*key_stride + time_index*time_stride; + bool is_rate = ecl_sum_vector_iget_is_rate(keywords, key_index); + double value = ecl_sum_data_vector_iget( data, sim_time, param_index , is_rate, time_index1, time_index2, weight1, weight2); + output_data[data_index] = value; + } + } + } +} /** This function will return the total number of ministeps in the @@ -1530,3 +1613,18 @@ bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , cons } return compatible; } + + +double ecl_sum_data_iget_last_value(const ecl_sum_data_type * data, int param_index) { + const ecl_sum_tstep_type * tstep = (const ecl_sum_tstep_type*)vector_get_last_const(data->data); + return ecl_sum_tstep_iget( tstep, param_index); +} + +double ecl_sum_data_get_last_value(const ecl_sum_data_type * data, int param_index) { + return ecl_sum_data_iget_last_value(data, param_index); +} + +double ecl_sum_data_iget_first_value(const ecl_sum_data_type * data, int param_index) { + const ecl_sum_tstep_type * tstep = (const ecl_sum_tstep_type*) vector_iget_const(data->data, 0); + return ecl_sum_tstep_iget(tstep, param_index); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_index.c b/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/ecl_sum_index.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp index 92f8d73bc5..051aca0b97 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_index.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_index.cpp @@ -16,7 +16,7 @@ for more details. */ -#include +#include /* This file contains all the internalized information from parsing a diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.c b/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/ecl_sum_tstep.c rename to ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp index 8228400d02..86eeaf7ecc 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.c +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_tstep.cpp @@ -19,14 +19,14 @@ #include #include -#include -#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define ECL_SUM_TSTEP_ID 88631 @@ -72,10 +72,10 @@ struct ecl_sum_tstep_struct { ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * src , const ecl_smspec_type * new_smspec, float default_value , const int * params_map) { int params_size = ecl_smspec_get_params_size( new_smspec ); - ecl_sum_tstep_type * target = util_alloc_copy(src , sizeof * src ); + ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src ); target->smspec = new_smspec; - target->data = util_malloc( params_size * sizeof * target->data ); + target->data = (float*)util_malloc( params_size * sizeof * target->data ); target->data_size = params_size; for (int i=0; i < params_size; i++) { @@ -89,20 +89,20 @@ ecl_sum_tstep_type * ecl_sum_tstep_alloc_remap_copy( const ecl_sum_tstep_type * } ecl_sum_tstep_type * ecl_sum_tstep_alloc_copy( const ecl_sum_tstep_type * src ) { - ecl_sum_tstep_type * target = util_alloc_copy(src , sizeof * src ); - target->data = util_alloc_copy( src->data , src->data_size * sizeof * src->data ); + ecl_sum_tstep_type * target = (ecl_sum_tstep_type*)util_alloc_copy(src , sizeof * src ); + target->data = (float*)util_alloc_copy( src->data , src->data_size * sizeof * src->data ); return target; } static ecl_sum_tstep_type * ecl_sum_tstep_alloc( int report_step , int ministep_nr , const ecl_smspec_type * smspec) { - ecl_sum_tstep_type * tstep = util_malloc( sizeof * tstep ); + ecl_sum_tstep_type * tstep = (ecl_sum_tstep_type*)util_malloc( sizeof * tstep ); UTIL_TYPE_ID_INIT( tstep , ECL_SUM_TSTEP_ID); tstep->smspec = smspec; tstep->report_step = report_step; tstep->ministep = ministep_nr; tstep->data_size = ecl_smspec_get_params_size( smspec ); - tstep->data = util_calloc( tstep->data_size , sizeof * tstep->data ); + tstep->data = (float*)util_calloc( tstep->data_size , sizeof * tstep->data ); return tstep; } @@ -282,7 +282,7 @@ void ecl_sum_tstep_fwrite( const ecl_sum_tstep_type * ministep , const int_vecto ecl_kw_type * params_kw = ecl_kw_alloc( PARAMS_KW , compact_size , ECL_FLOAT ); const int * index = int_vector_get_ptr( index_map ); - float * data = ecl_kw_get_ptr( params_kw ); + float * data = (float*)ecl_kw_get_ptr( params_kw ); { int i; diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c deleted file mode 100644 index 5e22358d18..0000000000 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.c +++ /dev/null @@ -1,111 +0,0 @@ -/* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'ecl_sum_vector.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include -#include -#include - -#include -#include -#include -#include -#include - - -#define ECL_SUM_VECTOR_TYPE_ID 8768778 - -struct ecl_sum_vector_struct { - UTIL_TYPE_ID_DECLARATION; - int_vector_type * node_index_list; - bool_vector_type * is_rate_list; - stringlist_type * key_list; - const ecl_sum_type * ecl_sum; -}; - - -void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){ - int_vector_free(ecl_sum_vector->node_index_list); - bool_vector_free(ecl_sum_vector->is_rate_list); - stringlist_free(ecl_sum_vector->key_list); -} - - -UTIL_IS_INSTANCE_FUNCTION( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID ) - - -ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum){ - ecl_sum_vector_type * ecl_sum_vector = util_malloc( sizeof * ecl_sum_vector ); - UTIL_TYPE_ID_INIT( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID); - ecl_sum_vector->ecl_sum = ecl_sum; - ecl_sum_vector->node_index_list = int_vector_alloc(0,0); - ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false); - ecl_sum_vector->key_list = stringlist_alloc_new( ); - return ecl_sum_vector; -} - - -bool ecl_sum_vector_add_key( ecl_sum_vector_type * ecl_sum_vector, const char * key){ - if (ecl_sum_has_general_var( ecl_sum_vector->ecl_sum , key)) { - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); - int params_index = smspec_node_get_params_index( node ); - bool is_rate_key = smspec_node_is_rate( node); - - int_vector_append(ecl_sum_vector->node_index_list, params_index); - bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key); - stringlist_append_copy( ecl_sum_vector->key_list, key ); - return true; - } else - return false; -} - - - -void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char * pattern){ - stringlist_type * keylist = ecl_sum_alloc_matching_general_var_list(ecl_sum_vector->ecl_sum , pattern); - - int num_keywords = stringlist_get_size(keylist); - int i; - for(i = 0; i < num_keywords ;i++){ - const char * key = stringlist_iget(keylist, i); - const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); - int params_index = smspec_node_get_params_index( node ); - bool is_rate_key = smspec_node_is_rate( node); - - int_vector_append(ecl_sum_vector->node_index_list, params_index); - bool_vector_append(ecl_sum_vector->is_rate_list, is_rate_key); - stringlist_append_copy( ecl_sum_vector->key_list, key ); - } - stringlist_free(keylist); -} - -int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector){ - return int_vector_size(ecl_sum_vector->node_index_list); -} - -bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index){ - return bool_vector_iget(ecl_sum_vector->is_rate_list, index); -} - -int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index){ - return int_vector_iget(ecl_sum_vector->node_index_list, index); -} - - -const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index){ - return stringlist_iget( ecl_sum_vector->key_list , index); -} diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp new file mode 100644 index 0000000000..731d7a5cf5 --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/ecl_sum_vector.cpp @@ -0,0 +1,162 @@ +/* + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_sum_vector.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ +#include +#include +#include +#include + +#include +#include +#include +#include +#include + + +#define ECL_SUM_VECTOR_TYPE_ID 8768778 + +struct ecl_sum_vector_struct { + UTIL_TYPE_ID_DECLARATION; + int_vector_type * node_index_list; + bool_vector_type * is_rate_list; + stringlist_type * key_list; + const ecl_sum_type * ecl_sum; +}; + + +void ecl_sum_vector_free( ecl_sum_vector_type * ecl_sum_vector ){ + int_vector_free(ecl_sum_vector->node_index_list); + bool_vector_free(ecl_sum_vector->is_rate_list); + stringlist_free(ecl_sum_vector->key_list); + free(ecl_sum_vector); +} + + +UTIL_IS_INSTANCE_FUNCTION( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID ) + +static void ecl_sum_vector_add_node(ecl_sum_vector_type * vector, const smspec_node_type * node, const char * key ) { + int params_index = smspec_node_get_params_index( node ); + bool is_rate_key = smspec_node_is_rate( node); + + int_vector_append(vector->node_index_list, params_index); + bool_vector_append(vector->is_rate_list, is_rate_key); + stringlist_append_copy( vector->key_list, key ); +} + + +ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum, bool add_keywords) { + ecl_sum_vector_type * ecl_sum_vector = (ecl_sum_vector_type*)util_malloc( sizeof * ecl_sum_vector ); + UTIL_TYPE_ID_INIT( ecl_sum_vector , ECL_SUM_VECTOR_TYPE_ID); + ecl_sum_vector->ecl_sum = ecl_sum; + ecl_sum_vector->node_index_list = int_vector_alloc(0,0); + ecl_sum_vector->is_rate_list = bool_vector_alloc(0,false); + ecl_sum_vector->key_list = stringlist_alloc_new( ); + if (add_keywords) { + const ecl_smspec_type * smspec = ecl_sum_get_smspec(ecl_sum); + for (int i=0; i < ecl_smspec_num_nodes(smspec); i++) { + const smspec_node_type * node = ecl_smspec_iget_node( smspec , i ); + if (!smspec_node_is_valid(node)) + continue; + + const char * key = smspec_node_get_gen_key1(node); + /* + The TIME keyword is special case handled to not be included; that is + to match the same special casing in the key matching function. + */ + if (!util_string_equal(key, "TIME")) + ecl_sum_vector_add_node( ecl_sum_vector, node, key); + } + } + return ecl_sum_vector; +} + +static void ecl_sum_vector_add_invalid_key(ecl_sum_vector_type * vector, const char * key) { + int_vector_append(vector->node_index_list, -1); + bool_vector_append(vector->is_rate_list, false); + stringlist_append_copy(vector->key_list, key); +} + + +/* + This function will allocate a keyword vector for the keys in the @ecl_sum + argument passed in, it will contain all the same keys as in the input argument + @src_vector. If the @src_vector contains keys which are not present in + @ecl_sum an entry marked as *invalid* will be added. The whole point about + this function is to ensure that calls to: + + ecl_sum_fwrite_interp_csv_line( ) + + will result in nicely aligned output even if the different summary cases do + not have the exact same keys. +*/ + +ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type * src_vector, const ecl_sum_type * ecl_sum) { + ecl_sum_vector_type * new_vector = ecl_sum_vector_alloc(ecl_sum, false); + for (int i=0; i < stringlist_get_size(src_vector->key_list); i++) { + const char * key = stringlist_iget(src_vector->key_list, i); + if (ecl_sum_has_general_var(ecl_sum, key)) + ecl_sum_vector_add_key(new_vector, key); + else + ecl_sum_vector_add_invalid_key(new_vector, key); + } + return new_vector; +} + + + +bool ecl_sum_vector_add_key( ecl_sum_vector_type * ecl_sum_vector, const char * key){ + if (ecl_sum_has_general_var( ecl_sum_vector->ecl_sum , key)) { + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); + ecl_sum_vector_add_node(ecl_sum_vector, node, key); + return true; + } else + return false; +} + +void ecl_sum_vector_add_keys( ecl_sum_vector_type * ecl_sum_vector, const char * pattern){ + stringlist_type * keylist = ecl_sum_alloc_matching_general_var_list(ecl_sum_vector->ecl_sum , pattern); + + int num_keywords = stringlist_get_size(keylist); + int i; + for(i = 0; i < num_keywords ;i++){ + const char * key = stringlist_iget(keylist, i); + const smspec_node_type * node = ecl_sum_get_general_var_node( ecl_sum_vector->ecl_sum , key ); + ecl_sum_vector_add_node(ecl_sum_vector, node, key); + } + stringlist_free(keylist); +} + +int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector){ + return int_vector_size(ecl_sum_vector->node_index_list); +} + +bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index){ + return bool_vector_iget(ecl_sum_vector->is_rate_list, index); +} + +bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index) { + return (int_vector_iget(ecl_sum_vector->node_index_list, index) >= 0); +} + +int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index){ + return int_vector_iget(ecl_sum_vector->node_index_list, index); +} + + +const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index){ + return stringlist_iget( ecl_sum_vector->key_list , index); +} diff --git a/ThirdParty/Ert/lib/ecl/ecl_type.c b/ThirdParty/Ert/lib/ecl/ecl_type.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/ecl_type.c rename to ThirdParty/Ert/lib/ecl/ecl_type.cpp index a259bb5428..acf8bf4043 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_type.c +++ b/ThirdParty/Ert/lib/ecl/ecl_type.cpp @@ -20,8 +20,8 @@ #include #include -#include -#include +#include +#include /*****************************************************************/ /* The string names for the different ECLIPSE low-level @@ -37,7 +37,7 @@ static char * alloc_string_name(const ecl_data_type ecl_type) { return util_alloc_sprintf( "C%03d", - ecl_type_get_sizeof_ctype_fortio(ecl_type) + ecl_type_get_sizeof_iotype(ecl_type) ); } @@ -64,11 +64,11 @@ ecl_data_type ecl_type_create(const ecl_type_enum type, const size_t element_siz ecl_type_create_from_type(type) ); - if(ecl_type_get_sizeof_ctype_fortio(ecl_type) != element_size) + if(ecl_type_get_sizeof_iotype(ecl_type) != element_size) util_abort( "%s: element_size mismatch for type %d, was: %d, expected: %d\n", __func__, type, - element_size, ecl_type_get_sizeof_ctype_fortio(ecl_type) + element_size, ecl_type_get_sizeof_iotype(ecl_type) ); return ecl_type; @@ -146,17 +146,25 @@ ecl_data_type ecl_type_create_from_name( const char * type_name ) { } -int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type ecl_type) { - if(ecl_type_is_char(ecl_type) || ecl_type_is_string(ecl_type)) - return ecl_type.element_size - 1; - else - return ecl_type_get_sizeof_ctype(ecl_type); +int ecl_type_get_sizeof_ctype(const ecl_data_type ecl_type) { + return ecl_type.element_size; } -int ecl_type_get_sizeof_ctype(const ecl_data_type ecl_type) { + +int ecl_type_get_sizeof_iotype(const ecl_data_type ecl_type) { + if (ecl_type_is_bool(ecl_type)) + return sizeof(int); + + if (ecl_type_is_char(ecl_type)) + return ecl_type.element_size -1; + + if (ecl_type_is_string(ecl_type)) + return ecl_type.element_size - 1; + return ecl_type.element_size; } + bool ecl_type_is_numeric(const ecl_data_type ecl_type) { return (ecl_type_is_int(ecl_type) || ecl_type_is_float(ecl_type) || diff --git a/ThirdParty/Ert/lib/ecl/ecl_type_python.c b/ThirdParty/Ert/lib/ecl/ecl_type_python.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/ecl_type_python.c rename to ThirdParty/Ert/lib/ecl/ecl_type_python.cpp index 8e5f843dd9..98bd5f8673 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_type_python.c +++ b/ThirdParty/Ert/lib/ecl/ecl_type_python.cpp @@ -1,14 +1,18 @@ -#include -#include -#include +#include +#include +#include /** * * Functions only to be used by the *PYTHON* prototype for EclDataType * */ + +#ifdef __cplusplus +extern "C" { + ecl_data_type * ecl_type_alloc_copy_python(const ecl_data_type * src_type) { - ecl_data_type * data_type = util_malloc(sizeof * src_type); + ecl_data_type * data_type = (ecl_data_type*)util_malloc(sizeof * src_type); memcpy(data_type, src_type, sizeof * data_type); return data_type; } @@ -40,10 +44,12 @@ const char * ecl_type_alloc_name_python(const ecl_data_type * ecl_type) { return ecl_type_alloc_name(*ecl_type); } -int ecl_type_get_sizeof_ctype_fortio_python(const ecl_data_type * ecl_type) { - return ecl_type_get_sizeof_ctype_fortio(*ecl_type); + +int ecl_type_get_sizeof_iotype_python(const ecl_data_type * ecl_type) { + return ecl_type_get_sizeof_iotype(*ecl_type); } + int ecl_type_get_sizeof_ctype_python(const ecl_data_type * ecl_type) { return ecl_type_get_sizeof_ctype(*ecl_type); } @@ -106,3 +112,7 @@ ecl_data_type * ecl_kw_get_data_type_python( const ecl_kw_type * ecl_kw ) { void ecl_kw_fread_indexed_data_python(fortio_type * fortio, offset_type data_offset, const ecl_data_type * data_type, int element_count, const int_vector_type* index_map, char* buffer) { return ecl_kw_fread_indexed_data(fortio, data_offset, *data_type, element_count, index_map, buffer); } + + +} +#endif diff --git a/ThirdParty/Ert/lib/ecl/ecl_util.c b/ThirdParty/Ert/lib/ecl/ecl_util.cpp similarity index 84% rename from ThirdParty/Ert/lib/ecl/ecl_util.c rename to ThirdParty/Ert/lib/ecl/ecl_util.cpp index 6b1dae13f9..f94bcb8f6c 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_util.c +++ b/ThirdParty/Ert/lib/ecl/ecl_util.cpp @@ -24,13 +24,13 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include #define ECL_PHASE_NAME_OIL "SOIL" // SHould match the keywords found in restart file @@ -55,22 +55,6 @@ #define ECL_INIT_UFMT_PATTERN "INIT" #define ECL_RFT_UFMT_PATTERN "RFT" -#ifdef ERT_WINDOWS -/* - The filename matching function on windows onyl recognizes the '*' - and '?' wildcard characters. -*/ - #define ECL_RESTART_FMT_PATTERN "F????" - #define ECL_SUMMARY_FMT_PATTERN "A????" - #define ECL_RESTART_UFMT_PATTERN "X????" - #define ECL_SUMMARY_UFMT_PATTERN "S????" -#else - #define ECL_RESTART_FMT_PATTERN "F[0-9][0-9][0-9][0-9]" - #define ECL_SUMMARY_FMT_PATTERN "A[0-9][0-9][0-9][0-9]" - #define ECL_RESTART_UFMT_PATTERN "X[0-9][0-9][0-9][0-9]" - #define ECL_SUMMARY_UFMT_PATTERN "S[0-9][0-9][0-9][0-9]" -#endif - @@ -122,37 +106,15 @@ char * ecl_util_alloc_base_guess(const char * path) { -int ecl_util_filename_report_nr(const char *filename) { - char *ext = strrchr(filename , '.'); - - if (ext == NULL) - return -1; - if (ext[1] == 'X' || ext[1] == 'F' || ext[1] == 'S' || ext[1] == 'A') - return atoi(&ext[2]); - return -1; +int ecl_util_filename_report_nr(const char *filename) { + int report_nr = -1; + ecl_util_get_file_type(filename, NULL, &report_nr); + return report_nr; } -/* -bool ecl_util_numeric_extension(const char * extension) { - - const char digit_ascii_min = 48; - const char digit_ascii_max = 57; - bool valid = true; - int pos = 1; - while (valid && pos <= 5) { - char c = extension[pos]; - valid = (valid & (c >= digit_ascii_min && c <= digit_ascii_max)); - if (!valid) - break; - } - - return valid; -} -*/ - /* We accept mixed lowercase/uppercase Eclipse file extensions even if Eclipse itself does not accept them. @@ -252,39 +214,26 @@ ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int to the fundamental type, it is also determined whether the file is formatted or not, and in the case of summary/restart files, which report number this corresponds to. - - */ -ecl_file_enum ecl_util_get_file_type(const char * filename, bool *_fmt_file, int * _report_nr) { - - char *ext = strrchr(filename , '.'); - if (ext != NULL) { - ext++; - return ecl_util_inspect_extension( ext , _fmt_file , _report_nr); - } else +ecl_file_enum ecl_util_get_file_type(const char * filename, bool *fmt_file, int * report_nr) { + char *ext = (char*)strrchr(filename , '.'); + if (ext == NULL) return ECL_OTHER_FILE; + return ecl_util_inspect_extension( &ext[1] , fmt_file , report_nr); } - - static const char * ecl_util_get_file_pattern( ecl_file_enum file_type , bool fmt_file ) { if (fmt_file) { switch( file_type ) { case( ECL_OTHER_FILE ): return ECL_OTHER_FILE_FMT_PATTERN; /* '*' */ break; - case( ECL_RESTART_FILE ): - return ECL_RESTART_FMT_PATTERN; - break; case( ECL_UNIFIED_RESTART_FILE ): return ECL_UNIFIED_RESTART_FMT_PATTERN; break; - case( ECL_SUMMARY_FILE ): - return ECL_SUMMARY_FMT_PATTERN; - break; case( ECL_UNIFIED_SUMMARY_FILE ): return ECL_UNIFIED_SUMMARY_FMT_PATTERN; break; @@ -312,15 +261,9 @@ static const char * ecl_util_get_file_pattern( ecl_file_enum file_type , bool fm case( ECL_OTHER_FILE ): return ECL_OTHER_FILE_UFMT_PATTERN; /* '*' */ break; - case( ECL_RESTART_FILE ): - return ECL_RESTART_UFMT_PATTERN; - break; case( ECL_UNIFIED_RESTART_FILE ): return ECL_UNIFIED_RESTART_UFMT_PATTERN; break; - case( ECL_SUMMARY_FILE ): - return ECL_SUMMARY_UFMT_PATTERN; - break; case( ECL_UNIFIED_SUMMARY_FILE ): return ECL_UNIFIED_SUMMARY_UFMT_PATTERN; break; @@ -392,6 +335,28 @@ const char * ecl_util_file_type_name( ecl_file_enum file_type ) { return NULL; } +static bool valid_base(const char * input_base, bool * upper_case) { + bool upper = false; + bool lower = false; + const char * base = strrchr(input_base, UTIL_PATH_SEP_CHAR); + if (base == NULL) + base = input_base; + + for (int i=0; i < strlen(base); i++) { + char c = base[i]; + + if (isupper(c)) + upper = true; + + if (islower(c)) + lower = true; + + } + + if (upper_case) + *upper_case = upper; + return !(lower && upper); +} @@ -408,6 +373,11 @@ const char * ecl_util_file_type_name( ecl_file_enum file_type ) { */ static char * ecl_util_alloc_filename_static(const char * path, const char * base , ecl_file_enum file_type , bool fmt_file, int report_nr, bool must_exist) { + bool upper_case; + if (!valid_base(base, &upper_case)) + return NULL; + + char * filename; char * ext; switch (file_type) { @@ -484,6 +454,11 @@ static char * ecl_util_alloc_filename_static(const char * path, const char * bas ext = NULL; } + if (!upper_case) { + for (int i=0; i < strlen(ext); i++) + ext[i] = tolower(ext[i]); + } + filename = util_alloc_filename(path , base , ext); free(ext); @@ -570,24 +545,134 @@ int ecl_util_fname_report_cmp(const void *f1, const void *f2) { starts. */ +static bool numeric_extension_predicate(const char * filename, const char * base, const char leading_char) { + if (strncmp(filename, base, strlen(base)) != 0) + return false; + + const char * ext_start = strrchr(filename, '.'); + if (!ext_start) + return false; + + if (strlen(ext_start) != 6) + return false; + + if (ext_start[1] != leading_char) + return false; + + for (int i=0; i < 4; i++) + if (!isdigit(ext_start[i+2])) + return false; + + return true; +} + + +static bool summary_UPPERCASE_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'A'); +} + +static bool summary_UPPERCASE_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'S'); +} + +static bool summary_lowercase_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'a'); +} + +static bool summary_lowercase_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 's'); +} + +static bool restart_UPPERCASE_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'F'); +} + +static bool restart_UPPERCASE_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'X'); +} + +static bool restart_lowercase_ASCII(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'f'); +} + +static bool restart_lowercase_BINARY(const char * filename, const void * base) { + return numeric_extension_predicate(filename, (const char*)base, 'x'); +} + +static int ecl_util_select_predicate_filelist(const char * path, const char * base, ecl_file_enum file_type, bool fmt_file, bool upper_case, stringlist_type * filelist) { + file_pred_ftype * predicate = NULL; + char * full_path = NULL; + char * pure_base = NULL; + { + char * tmp = util_alloc_filename(path, base, NULL); + util_alloc_file_components(tmp, &full_path, &pure_base, NULL); + free(tmp); + } + + if (file_type == ECL_SUMMARY_FILE) { + if (fmt_file) { + if (upper_case) + predicate = summary_UPPERCASE_ASCII; + else + predicate = summary_lowercase_ASCII; + } else { + if (upper_case) + predicate = summary_UPPERCASE_BINARY; + else + predicate = summary_lowercase_BINARY; + } + } else if (file_type == ECL_RESTART_FILE) { + if (fmt_file) { + if (upper_case) + predicate = restart_UPPERCASE_ASCII; + else + predicate = restart_lowercase_ASCII; + } else { + if (upper_case) + predicate = restart_UPPERCASE_BINARY; + else + predicate = restart_lowercase_BINARY; + } + } else + util_abort("%s: internal error - method called with wrong file type: %d\n", __func__, file_type); + + stringlist_select_files(filelist, full_path, predicate, pure_base); + stringlist_sort( filelist , ecl_util_fname_report_cmp ); + free(pure_base); + free(full_path); + return stringlist_get_size(filelist); +} int ecl_util_select_filelist( const char * path , const char * base , ecl_file_enum file_type , bool fmt_file , stringlist_type * filelist) { - char * file_pattern; - char * base_pattern; - const char * extension = ecl_util_get_file_pattern( file_type , fmt_file ); - if (base == NULL) - base_pattern = util_alloc_string_copy( "*" ); - else - base_pattern = util_alloc_string_copy( base ); + bool valid_case = true; + bool upper_case = true; + stringlist_clear(filelist); - file_pattern = util_alloc_filename( NULL , base_pattern , extension ); - stringlist_select_matching_files( filelist , path , file_pattern ); - if ((file_type == ECL_SUMMARY_FILE) || (file_type == ECL_RESTART_FILE)) - stringlist_sort( filelist , ecl_util_fname_report_cmp ); + if (base) + valid_case = valid_base(base, &upper_case); - free( base_pattern ); - free( file_pattern ); + if (valid_case) { + if (file_type == ECL_SUMMARY_FILE || file_type == ECL_RESTART_FILE) + return ecl_util_select_predicate_filelist(path, base, file_type, fmt_file, upper_case, filelist); + + char * ext_pattern = util_alloc_string_copy(ecl_util_get_file_pattern( file_type , fmt_file )); + char * file_pattern; + + if (!upper_case) { + for (int i=0; i < strlen(ext_pattern); i++) + ext_pattern[i] = tolower(ext_pattern[i]); + } + + if (base) + file_pattern = util_alloc_filename(NULL , base, ext_pattern); + else + file_pattern = util_alloc_filename(NULL, "*", ext_pattern); + + stringlist_select_matching_files( filelist , path , file_pattern ); + free( file_pattern ); + free( ext_pattern ); + } return stringlist_get_size( filelist ); } @@ -1126,7 +1211,7 @@ time_t ecl_util_get_start_date(const char * data_file) { util_abort("%s: sorry - could not find \"/\" termination of START keyword in data_file: \n",__func__ , data_file); buffer_size = (util_ftell(stream) - start_pos) ; - buffer = util_calloc( buffer_size + 1 , sizeof * buffer ); + buffer = (char*)util_calloc( buffer_size + 1 , sizeof * buffer ); util_fseek( stream , start_pos , SEEK_SET); util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__); buffer[buffer_size] = '\0'; @@ -1163,7 +1248,7 @@ static int ecl_util_get_num_parallel_cpu__(basic_parser_type* parser, FILE* stre util_abort("%s: sorry - could not find \"/\" termination of PARALLEL keyword in data_file: \n",__func__ , data_file); buffer_size = (util_ftell(stream) - start_pos) ; - buffer = util_calloc( buffer_size + 1 , sizeof * buffer ); + buffer = (char*)util_calloc( buffer_size + 1 , sizeof * buffer ); util_fseek( stream , start_pos , SEEK_SET); util_fread( buffer , sizeof * buffer , buffer_size ,stream , __func__); buffer[buffer_size] = '\0'; @@ -1274,29 +1359,7 @@ ert_ecl_unit_enum ecl_util_get_unit_set(const char * data_file) { bool ecl_util_valid_basename( const char * basename ) { - - char * eclbasename = util_split_alloc_filename(basename); - - int upper_count = 0; - int lower_count = 0; - int index; - - for (index = 0; index < strlen( eclbasename ); index++) { - int c = eclbasename[index]; - if (isalpha(c)) { - if (isupper(c)) - upper_count++; - else - lower_count++; - } - } - - free(eclbasename); - - if ((lower_count * upper_count) != 0) - return false; - else - return true; + return valid_base(basename, NULL); } @@ -1437,3 +1500,59 @@ void ecl_util_set_date_values(time_t t , int * mday , int * month , int * year) } +#ifdef ERT_HAVE_UNISTD +#include +#endif + +/* + This is a small function which tries to give a sensible answer to the + question: Do I have read access to this eclipse simulation? The ecl_case + argument can either be a directory or the full path to a file, the filename + need not exists. The approach is as follows: + + 1. If @ecl_case corresponds to an existing filesystem entry - just return + access(ecl_case, R_OK). + + 2. If @ecl_case corresponds to a non-existing entry: + + a) If there is a directory part - return access(dir, R_OK). + b) No directory part - return access(cwd, R_OK); + + For the case 2b) the situation is that we test for read access to CWD, + that could in principle be denied - but that is a highly contrived + situation and we just return true. + + ecl_util_access_path("PATH") -> access("PATH", R_OK); + ecl_util_access_path("PATH/FILE_EXISTS") -> access("PATH/FILE_EXISTS", R_OK); + ecl_util_access_path("PATH/FILE_DOES_NOT_EXIST") -> access("PATH", R_OK); + ecl_util_access_path("PATH_DOES_NOT_EXIST") -> true +*/ + +bool ecl_util_path_access(const char * ecl_case) { + if (util_access(ecl_case, R_OK)) + return true; + + if (util_access(ecl_case, F_OK)) + return false; + + /* Check if the input argument corresponds to an existing directory and one + additional element, in that case we do an access check on the directory part. */ + + { + bool path_access; + char * dir_name; + const char * path_sep = strrchr(ecl_case, UTIL_PATH_SEP_CHAR); + + if (!path_sep) + /* We are trying to access CWD - we return true without actually checking + access. */ + return true; + + + dir_name = util_alloc_substring_copy(ecl_case, 0, path_sep - ecl_case); + path_access = util_access(dir_name, R_OK); + free(dir_name); + return path_access; + } + return false; +} diff --git a/ThirdParty/Ert/lib/ecl/fault_block.c b/ThirdParty/Ert/lib/ecl/fault_block.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/fault_block.c rename to ThirdParty/Ert/lib/ecl/fault_block.cpp index d0b4f91e86..c8faddd136 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block.c +++ b/ThirdParty/Ert/lib/ecl/fault_block.cpp @@ -23,11 +23,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include #define FAULT_BLOCK_ID 3297376 @@ -52,7 +52,7 @@ static UTIL_SAFE_CAST_FUNCTION( fault_block , FAULT_BLOCK_ID ) fault_block_type * fault_block_alloc( const fault_block_layer_type * parent_layer , int block_id ) { - fault_block_type * block = util_malloc( sizeof * block ); + fault_block_type * block = (fault_block_type*)util_malloc( sizeof * block ); UTIL_TYPE_ID_INIT( block , FAULT_BLOCK_ID ); block->parent_layer = parent_layer; block->grid = fault_block_layer_get_grid( parent_layer ); diff --git a/ThirdParty/Ert/lib/ecl/fault_block_layer.c b/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp similarity index 96% rename from ThirdParty/Ert/lib/ecl/fault_block_layer.c rename to ThirdParty/Ert/lib/ecl/fault_block_layer.cpp index 9466515b42..8f44f521cb 100644 --- a/ThirdParty/Ert/lib/ecl/fault_block_layer.c +++ b/ThirdParty/Ert/lib/ecl/fault_block_layer.cpp @@ -34,7 +34,7 @@ The fault_block object is implemented as a separate object type in the fault_block.c file; however the fault blocks should be closely linked to the layer object in the fault_block_layer structure - it - is therefor not possible/legal to create a fault block instance by + is therefore not possible/legal to create a fault block instance by itself. To support that encapsulation the fault_block.c file is included here, and the functions: @@ -201,7 +201,7 @@ fault_block_layer_type * fault_block_layer_alloc( const ecl_grid_type * grid , i if ((k < 0) || (k >= ecl_grid_get_nz( grid ))) return NULL; else { - fault_block_layer_type * layer = util_malloc( sizeof * layer ); + fault_block_layer_type * layer = (fault_block_layer_type*)util_malloc( sizeof * layer ); UTIL_TYPE_ID_INIT( layer , FAULT_BLOCK_LAYER_ID); layer->grid = grid; layer->k = k; @@ -215,7 +215,7 @@ fault_block_layer_type * fault_block_layer_alloc( const ecl_grid_type * grid , i fault_block_type * fault_block_layer_iget_block( const fault_block_layer_type * layer , int storage_index) { - return vector_iget( layer->blocks , storage_index ); + return (fault_block_type*)vector_iget( layer->blocks , storage_index ); } @@ -224,7 +224,7 @@ fault_block_type * fault_block_layer_get_block( const fault_block_layer_type * l if (storage_index < 0) return NULL; else - return vector_iget( layer->blocks , storage_index ); + return (fault_block_type*)vector_iget( layer->blocks , storage_index ); } @@ -233,7 +233,7 @@ fault_block_type * fault_block_layer_safe_get_block( fault_block_layer_type * la if (storage_index < 0) return fault_block_layer_add_block( layer , block_id ); else - return vector_iget( layer->blocks , storage_index ); + return (fault_block_type*)vector_iget( layer->blocks , storage_index ); } diff --git a/ThirdParty/Ert/lib/ecl/fortio.c b/ThirdParty/Ert/lib/ecl/fortio.c index c9aad26b78..65478d7102 100644 --- a/ThirdParty/Ert/lib/ecl/fortio.c +++ b/ThirdParty/Ert/lib/ecl/fortio.c @@ -97,7 +97,7 @@ UTIL_IS_INSTANCE_FUNCTION( fortio , FORTIO_ID ); UTIL_SAFE_CAST_FUNCTION( fortio, FORTIO_ID ); static fortio_type * fortio_alloc__(const char *filename , bool fmt_file , bool endian_flip_header , bool stream_owner , bool writable) { - fortio_type * fortio = util_malloc(sizeof * fortio ); + fortio_type * fortio = (fortio_type*)util_malloc(sizeof * fortio ); UTIL_TYPE_ID_INIT( fortio, FORTIO_ID ); fortio->filename = util_alloc_string_copy(filename); fortio->endian_flip_header = endian_flip_header; diff --git a/ThirdParty/Ert/lib/ecl/grid_dims.c b/ThirdParty/Ert/lib/ecl/grid_dims.cpp similarity index 89% rename from ThirdParty/Ert/lib/ecl/grid_dims.c rename to ThirdParty/Ert/lib/ecl/grid_dims.cpp index 0d013fd5a8..1d2115b089 100644 --- a/ThirdParty/Ert/lib/ecl/grid_dims.c +++ b/ThirdParty/Ert/lib/ecl/grid_dims.cpp @@ -18,9 +18,9 @@ #include -#include +#include -#include +#include void grid_dims_init( grid_dims_type * dims , int nx, int ny , int nz , int nactive) { @@ -33,7 +33,7 @@ void grid_dims_init( grid_dims_type * dims , int nx, int ny , int nz , int nacti grid_dims_type * grid_dims_alloc( int nx, int ny , int nz , int nactive) { - grid_dims_type * dims = util_malloc( sizeof * dims ); + grid_dims_type * dims = (grid_dims_type*)util_malloc( sizeof * dims ); grid_dims_init( dims , nx , ny , nz , nactive ); return dims; } diff --git a/ThirdParty/Ert/lib/ecl/layer.c b/ThirdParty/Ert/lib/ecl/layer.cpp similarity index 98% rename from ThirdParty/Ert/lib/ecl/layer.c rename to ThirdParty/Ert/lib/ecl/layer.cpp index 20a2180eec..7a79809f31 100644 --- a/ThirdParty/Ert/lib/ecl/layer.c +++ b/ThirdParty/Ert/lib/ecl/layer.cpp @@ -18,10 +18,10 @@ #include #include -#include -#include +#include +#include -#include +#include #define LAYER_TYPE_ID 55185409 @@ -50,14 +50,14 @@ UTIL_SAFE_CAST_FUNCTION( layer , LAYER_TYPE_ID ) layer_type * layer_alloc(int nx , int ny) { - layer_type * layer = util_malloc( sizeof * layer ); + layer_type * layer = (layer_type*)util_malloc( sizeof * layer ); UTIL_TYPE_ID_INIT( layer , LAYER_TYPE_ID ); layer->nx = nx; layer->ny = ny; layer->cell_sum = 0; { int data_size = (layer->nx + 1)* (layer->ny + 1); - layer->data = util_malloc( data_size * sizeof * layer->data ); + layer->data = (cell_type*)util_malloc( data_size * sizeof * layer->data ); { int g; for (g=0; g < data_size; g++) { @@ -524,7 +524,7 @@ static void layer_trace_block_content__( layer_type * layer , bool erase , int i static bool * layer_alloc_visited_mask( const layer_type * layer ) { int total_size = (layer->nx + 1)* (layer->ny + 1); - bool * visited = util_malloc( total_size * sizeof * visited ); + bool * visited = (bool*)util_malloc( total_size * sizeof * visited ); int g; for (g = 0; g < total_size; g++) visited[g] = false; diff --git a/ThirdParty/Ert/lib/ecl/nnc_info.c b/ThirdParty/Ert/lib/ecl/nnc_info.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/nnc_info.c rename to ThirdParty/Ert/lib/ecl/nnc_info.cpp index a60e1f4c9e..3db9cf4c42 100644 --- a/ThirdParty/Ert/lib/ecl/nnc_info.c +++ b/ThirdParty/Ert/lib/ecl/nnc_info.cpp @@ -18,13 +18,13 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #define NNC_INFO_TYPE_ID 675415078 @@ -41,7 +41,7 @@ UTIL_IS_INSTANCE_FUNCTION( nnc_info , NNC_INFO_TYPE_ID ) nnc_info_type * nnc_info_alloc(int lgr_nr) { - nnc_info_type * nnc_info = util_malloc( sizeof * nnc_info ); + nnc_info_type * nnc_info = (nnc_info_type*)util_malloc( sizeof * nnc_info ); UTIL_TYPE_ID_INIT(nnc_info , NNC_INFO_TYPE_ID); nnc_info->lgr_list = vector_alloc_new(); nnc_info->lgr_index_map = int_vector_alloc(0, -1); @@ -56,7 +56,7 @@ nnc_info_type * nnc_info_alloc_copy( const nnc_info_type * src_info ) { int ivec; for (ivec = 0; ivec < vector_get_size( src_info->lgr_list ); ivec++) { - nnc_vector_type * copy_vector = nnc_vector_alloc_copy( vector_iget_const( src_info->lgr_list , ivec)); + nnc_vector_type * copy_vector = nnc_vector_alloc_copy( (const nnc_vector_type*)vector_iget_const( src_info->lgr_list , ivec)); nnc_info_add_vector( copy_info , copy_vector ); } @@ -112,12 +112,12 @@ nnc_vector_type * nnc_info_get_vector( const nnc_info_type * nnc_info , int lgr_ if (-1 == lgr_index) return NULL; else - return vector_iget( nnc_info->lgr_list , lgr_index ); + return (nnc_vector_type*)vector_iget( nnc_info->lgr_list , lgr_index ); } nnc_vector_type * nnc_info_iget_vector( const nnc_info_type * nnc_info , int lgr_index) { - return vector_iget( nnc_info->lgr_list , lgr_index ); + return (nnc_vector_type*)vector_iget( nnc_info->lgr_list , lgr_index ); } @@ -189,7 +189,7 @@ int nnc_info_get_total_size( const nnc_info_type * nnc_info ) { int num_nnc = 0; int ivec; for (ivec = 0; ivec < vector_get_size( nnc_info->lgr_list ); ivec++) { - const nnc_vector_type * nnc_vector = vector_iget( nnc_info->lgr_list , ivec ); + const nnc_vector_type * nnc_vector = (const nnc_vector_type*)vector_iget( nnc_info->lgr_list , ivec ); num_nnc += nnc_vector_get_size( nnc_vector ); } return num_nnc; diff --git a/ThirdParty/Ert/lib/ecl/nnc_vector.c b/ThirdParty/Ert/lib/ecl/nnc_vector.cpp similarity index 91% rename from ThirdParty/Ert/lib/ecl/nnc_vector.c rename to ThirdParty/Ert/lib/ecl/nnc_vector.cpp index 253e44f4be..385fa91fe4 100644 --- a/ThirdParty/Ert/lib/ecl/nnc_vector.c +++ b/ThirdParty/Ert/lib/ecl/nnc_vector.cpp @@ -19,12 +19,12 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include +#include @@ -45,7 +45,7 @@ static UTIL_SAFE_CAST_FUNCTION(nnc_vector , NNC_VECTOR_TYPE_ID) nnc_vector_type * nnc_vector_alloc(int lgr_nr) { - nnc_vector_type * nnc_vector = util_malloc( sizeof * nnc_vector ); + nnc_vector_type * nnc_vector = (nnc_vector_type*)util_malloc( sizeof * nnc_vector ); UTIL_TYPE_ID_INIT(nnc_vector , NNC_VECTOR_TYPE_ID); nnc_vector->grid_index_list = int_vector_alloc(0,0); nnc_vector->nnc_index_list = int_vector_alloc(0,0); @@ -54,7 +54,7 @@ nnc_vector_type * nnc_vector_alloc(int lgr_nr) { } nnc_vector_type * nnc_vector_alloc_copy(const nnc_vector_type * src_vector) { - nnc_vector_type * copy_vector = util_malloc( sizeof * src_vector ); + nnc_vector_type * copy_vector = (nnc_vector_type*)util_malloc( sizeof * src_vector ); UTIL_TYPE_ID_INIT(copy_vector , NNC_VECTOR_TYPE_ID); copy_vector->lgr_nr = src_vector->lgr_nr; diff --git a/ThirdParty/Ert/lib/ecl/smspec_node.c b/ThirdParty/Ert/lib/ecl/smspec_node.cpp similarity index 97% rename from ThirdParty/Ert/lib/ecl/smspec_node.c rename to ThirdParty/Ert/lib/ecl/smspec_node.cpp index 412b027731..a59428f3fb 100644 --- a/ThirdParty/Ert/lib/ecl/smspec_node.c +++ b/ThirdParty/Ert/lib/ecl/smspec_node.cpp @@ -21,20 +21,20 @@ #include #include -#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include @@ -197,7 +197,7 @@ char * smspec_alloc_completion_num_key( const char * join_string , const char * To support ECLIPSE behaviour where new wells/groups can be created during the simulation it must be possible to create a smspec node with an initially unknown well/group name; all gen_key formats which - use the wgname value must therefor accept a NULL value for wgname. + use the wgname value must therefore accept a NULL value for wgname. */ static char * smspec_alloc_wgname_key( const char * join_string , const char * keyword , const char * wgname) { @@ -363,7 +363,7 @@ float smspec_node_get_default( const smspec_node_type * smspec_node ) { smspec_node_type * smspec_node_alloc_new(int params_index, float default_value) { - smspec_node_type * node = util_malloc( sizeof * node ); + smspec_node_type * node = (smspec_node_type*)util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , SMSPEC_TYPE_ID); node->params_index = params_index; @@ -404,7 +404,7 @@ static void smspec_node_set_lgr_name( smspec_node_type * index , const char * lg static void smspec_node_set_lgr_ijk( smspec_node_type * index , int lgr_i , int lgr_j , int lgr_k) { if (index->lgr_ijk == NULL) - index->lgr_ijk = util_calloc( 3 , sizeof * index->lgr_ijk ); + index->lgr_ijk = (int*)util_calloc( 3 , sizeof * index->lgr_ijk ); index->lgr_ijk[0] = lgr_i; index->lgr_ijk[1] = lgr_j; @@ -434,7 +434,7 @@ static void smspec_node_set_num( smspec_node_type * index , const int grid_dims[ index->num = num; if ((index->var_type == ECL_SMSPEC_COMPLETION_VAR) || (index->var_type == ECL_SMSPEC_BLOCK_VAR)) { int global_index = num - 1; - index->ijk = util_calloc( 3 , sizeof * index->ijk ); + index->ijk = (int*)util_calloc( 3 , sizeof * index->ijk ); index->ijk[2] = global_index / ( grid_dims[0] * grid_dims[1] ); global_index -= index->ijk[2] * (grid_dims[0] * grid_dims[1]); index->ijk[1] = global_index / grid_dims[0] ; global_index -= index->ijk[1] * grid_dims[0]; @@ -776,7 +776,7 @@ smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) { if( !node ) return NULL; { - smspec_node_type* copy = util_malloc( sizeof * copy ); + smspec_node_type* copy = (smspec_node_type*)util_malloc( sizeof * copy ); UTIL_TYPE_ID_INIT( copy, SMSPEC_TYPE_ID ); copy->gen_key1 = util_alloc_string_copy( node->gen_key1 ); copy->gen_key2 = util_alloc_string_copy( node->gen_key2 ); @@ -788,14 +788,14 @@ smspec_node_type* smspec_node_alloc_copy( const smspec_node_type* node ) { copy->ijk = NULL; if( node->ijk ) { - copy->ijk = util_calloc( 3 , sizeof * node->ijk ); + copy->ijk = (int*)util_calloc( 3 , sizeof * node->ijk ); memcpy( copy->ijk, node->ijk, 3 * sizeof( * node->ijk ) ); } copy->lgr_name = util_alloc_string_copy( node->lgr_name ); copy->lgr_ijk = NULL; if( node->lgr_ijk ) { - copy->lgr_ijk = util_calloc( 3 , sizeof * node->lgr_ijk ); + copy->lgr_ijk = (int*)util_calloc( 3 , sizeof * node->lgr_ijk ); memcpy( copy->lgr_ijk, node->lgr_ijk, 3 * sizeof( * node->lgr_ijk ) ); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c index b4adf52270..efc1727ef0 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_grid_corner.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2014 Statoil ASA, Norway. - - The file 'ecl_grid_corner.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2014 Statoil ASA, Norway. + + The file 'ecl_grid_corner.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include #include @@ -40,7 +40,10 @@ void test_invalid( ecl_grid_type * grid) { void test_OK( const ecl_grid_type * grid) { double x,y,z; - + double x8[8]; + double y8[8]; + double z8[8]; + ecl_grid_get_corner_xyz( grid , 0,0,0,&x,&y,&z); test_assert_double_equal( x,0 ); test_assert_double_equal( y,0 ); @@ -55,6 +58,14 @@ void test_OK( const ecl_grid_type * grid) { test_assert_double_equal( x,10 ); test_assert_double_equal( y,10 ); test_assert_double_equal( z,10 ); + + ecl_grid_export_cell_corners1(grid, 456, x8, y8, z8); + for (int i=0; i < 8; i++) { + ecl_grid_get_cell_corner_xyz1(grid, 456, i, &x,&y,&z); + test_assert_double_equal(x,x8[i]); + test_assert_double_equal(y,y8[i]); + test_assert_double_equal(z,z8[i]); + } } @@ -65,7 +76,7 @@ int main( int argc , char ** argv) { test_invalid( grid ); test_OK(grid); - + ecl_grid_free( grid ); exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c index 9a95fdfe7e..5ebcee8f88 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_kw_init.c @@ -18,6 +18,7 @@ #include #include +#include #include #include @@ -57,9 +58,29 @@ void test_float() { } +void test_bool() { + size_t N = 100; + bool * data = util_malloc(N * sizeof * data); + ecl_kw_type * kw = ecl_kw_alloc("BOOL", N , ECL_BOOL); + for (int i=0; i < N/2; i++) { + ecl_kw_iset_bool(kw, 2*i, true); + ecl_kw_iset_bool(kw, 2*i + 1, false); + + data[2*i] = true; + data[2*i + 1] = false; + } + + const bool * internal_data = ecl_kw_get_bool_ptr(kw); + + test_assert_int_equal( memcmp(internal_data, data, N * sizeof * data), 0); + ecl_kw_free(kw); + free(data); +} + int main( int argc , char ** argv) { test_int(); test_double(); test_float(); + test_bool(); exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c b/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c index d89181e6fe..649541b669 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_lfs.c @@ -1,25 +1,23 @@ /* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ecl_win64.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2013 Statoil ASA, Norway. + + The file 'ecl_win64.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include #include -#include - #include #include #include @@ -32,11 +30,10 @@ int main( int argc , char ** argv) { int num_kw = 1000; // Total file size should roughly exceed 2GB int kw_size = 600000; ecl_kw_type * kw = ecl_kw_alloc("KW" , kw_size , ECL_INT ); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); int i; offset_type file_size; - for (i=0; i < kw_size; i++) - ecl_kw_iset_int( kw , i , rng_get_int( rng , 912732 )); + for (i=0; i < kw_size; i++) + ecl_kw_iset_int( kw , i , i); { fortio_type * fortio = fortio_open_writer( "LARGE_FILE.UNRST" , false , ECL_ENDIAN_FLIP); @@ -73,7 +70,7 @@ int main( int argc , char ** argv) { fortio_fclose( fortio ); printf("Seek OK \n"); } - + printf("Doing ecl_file_open(..)\n"); { @@ -87,6 +84,6 @@ int main( int argc , char ** argv) { } remove( "LARGE_FILE.UNRST" ); - + exit(0); } diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c index 98d832f818..961601dd2b 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_smspec.c @@ -20,7 +20,7 @@ #include #include - +#include #include void test_sort( ecl_smspec_type * smspec ) @@ -39,6 +39,18 @@ void test_sort( ecl_smspec_type * smspec ) } +void test_copy(const ecl_smspec_type * smspec1) { + ecl_sum_type * ecl_sum2 = ecl_sum_alloc_writer("CASE", false, true, ":", 0, true, 100, 100, 100); + ecl_smspec_type * smspec2 = ecl_sum_get_smspec(ecl_sum2); + for (int i=0; i < ecl_smspec_num_nodes(smspec1); i++) { + const smspec_node_type * node = ecl_smspec_iget_node(smspec1, i); + ecl_sum_add_smspec_node(ecl_sum2, node); + } + test_assert_true( ecl_smspec_equal(smspec1, smspec2)); + ecl_sum_free(ecl_sum2); +} + + int main(int argc, char ** argv) { const char * case1 = argv[1]; const char * case2 = argv[2]; diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c new file mode 100644 index 0000000000..142e8073ae --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_alloc_resampled_test.c @@ -0,0 +1,98 @@ + +#include + +#include +#include + +ecl_sum_type * test_alloc_ecl_sum() { + time_t start_time = util_make_date_utc( 1,1,2010 ); + ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( "/tmp/CASE" , false , true , ":" , start_time , true , 10 , 10 , 10 ); + double sim_seconds = 0; + + int num_dates = 4; + double ministep_length = 86400; // seconds in a day + + smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); + smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); + smspec_node_type * node3 = ecl_sum_add_var( ecl_sum , "WWCT" , "OP-1" , 0 , "(1)" , 0.0 ); + + for (int report_step = 0; report_step < num_dates; report_step++) { + { + ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum , report_step + 1 , sim_seconds ); + ecl_sum_tstep_set_from_node( tstep , node1 , report_step*2.0 ); + ecl_sum_tstep_set_from_node( tstep , node2 , report_step*4.0 + 2.0 ); + ecl_sum_tstep_set_from_node( tstep , node3 , report_step*6.0 + 4.0 ); + } + sim_seconds += ministep_length * 3; + + } + return ecl_sum; +} + +void test_correct_time_vector() { + + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 2,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 4,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 6,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 8,1,2010 )); + ecl_sum_type * ecl_sum_resampled = ecl_sum_alloc_resample(ecl_sum, "kk", t); + test_assert_int_equal( ecl_sum_get_report_time(ecl_sum_resampled, 2) , util_make_date_utc( 6,1,2010 )); + + const ecl_smspec_type * smspec_resampled = ecl_sum_get_smspec(ecl_sum_resampled); + const smspec_node_type * node1 = ecl_smspec_iget_node(smspec_resampled, 1); + const smspec_node_type * node2 = ecl_smspec_iget_node(smspec_resampled, 2); + const smspec_node_type * node3 = ecl_smspec_iget_node(smspec_resampled, 3); + test_assert_string_equal( "BPR" , smspec_node_get_keyword(node2) ); + test_assert_string_equal( "BARS" , smspec_node_get_unit(node2) ); + + test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 6,1,2010 ), node1) ); + test_assert_double_equal(3.33333, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 2,1,2010 ), node2) ); + test_assert_double_equal(10.0000, ecl_sum_get_from_sim_time( ecl_sum_resampled, util_make_date_utc( 4,1,2010 ), node3) ); + + + ecl_sum_free(ecl_sum_resampled); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + +void test_time_before() { + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 1,1,2009 )); + test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) ); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + +void test_time_after() { + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 1,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 11,1,2010 )); + test_assert_NULL( ecl_sum_alloc_resample(ecl_sum, "kk", t) ); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + +void test_not_sorted() { + ecl_sum_type * ecl_sum = test_alloc_ecl_sum(); + time_t_vector_type * t = time_t_vector_alloc( 0 , 0 ); + time_t_vector_append(t, util_make_date_utc( 1,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 3,1,2010 )); + time_t_vector_append(t, util_make_date_utc( 2,1,2010 )); + test_assert_NULL( ecl_sum_alloc_resample( ecl_sum, "kk", t) ); + time_t_vector_free(t); + ecl_sum_free(ecl_sum); +} + + +int main() { + test_correct_time_vector(); + test_time_before(); + test_time_after(); + test_not_sorted(); + return 0; +} + diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c index 11523e1ae9..d10a2142b3 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_test.c @@ -63,7 +63,7 @@ void test_is_oil_producer( const ecl_sum_type * ecl_sum) { int main( int argc , char ** argv) { const char * case1 = argv[1]; - + ecl_sum_type * ecl_sum1 = ecl_sum_fread_alloc_case( case1 , ":"); test_assert_true( ecl_sum_is_instance( ecl_sum1 )); diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c index a66c9f9f02..f1691a943d 100644 --- a/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_sum_writer.c @@ -61,7 +61,7 @@ double write_summary( const char * name , time_t start_time , int nx , int ny , int write_restart_summary(const char * name, const char * restart_name , int start_report_step, double sim_seconds, time_t start_time , int nx , int ny , int nz , int num_dates, int num_ministep, double ministep_length) { ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer( name , restart_name, false , true , ":" , start_time , true , nx , ny , nz ); - + smspec_node_type * node1 = ecl_sum_add_var( ecl_sum , "FOPT" , NULL , 0 , "Barrels" , 99.0 ); smspec_node_type * node2 = ecl_sum_add_var( ecl_sum , "BPR" , NULL , 567 , "BARS" , 0.0 ); @@ -70,8 +70,6 @@ int write_restart_summary(const char * name, const char * restart_name , int sta int num_report_steps = start_report_step + num_dates; for (int report_step = start_report_step; report_step < num_report_steps; report_step++) { for (int step = 0; step < num_ministep; step++) { - - { ecl_sum_tstep_type * tstep = ecl_sum_add_tstep( ecl_sum , report_step + 1 , sim_seconds ); ecl_sum_tstep_set_from_node( tstep , node1 , sim_seconds); @@ -147,7 +145,7 @@ void test_ecl_sum_alloc_restart_writer() { int num_ministep = 10; double ministep_length = 36000; // Seconds - int sim_seconds = write_summary( name1 , start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); + int sim_seconds = write_summary( name1 , start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); sim_seconds = write_restart_summary( name2 , name1 , num_dates, sim_seconds, start_time , nx , ny , nz , num_dates , num_ministep , ministep_length); ecl_sum_type * case1 = ecl_sum_fread_alloc_case( name1 , ":" ); @@ -157,20 +155,20 @@ void test_ecl_sum_alloc_restart_writer() { test_assert_true( ecl_sum_has_key( case2 , "FOPT" )); ecl_file_type * restart_file = ecl_file_open( "CASE2.SMSPEC" , 0 ); - ecl_file_view_type * view_file = ecl_file_get_global_view( restart_file ); + ecl_file_view_type * view_file = ecl_file_get_global_view( restart_file ); test_assert_true( ecl_file_view_has_kw(view_file, RESTART_KW)); - ecl_kw_type * kw = ecl_file_view_iget_kw(view_file, 0); - test_assert_int_equal(8, ecl_kw_get_size(kw)); - test_assert_string_equal( "CASE1 ", ecl_kw_iget_ptr( kw , 0 ) ); - test_assert_string_equal( " ", ecl_kw_iget_ptr( kw , 1 ) ); + ecl_kw_type * restart_kw = ecl_file_view_iget_named_kw(view_file, "RESTART", 0); + test_assert_int_equal(8, ecl_kw_get_size(restart_kw)); + test_assert_string_equal( "CASE1 ", ecl_kw_iget_ptr( restart_kw , 0 ) ); + test_assert_string_equal( " ", ecl_kw_iget_ptr( restart_kw , 1 ) ); - for (int time_index=0; time_index < ecl_sum_get_data_length( case1 ); time_index++) + for (int time_index=0; time_index < ecl_sum_get_data_length( case1 ); time_index++) test_assert_double_equal( ecl_sum_get_general_var( case1 , time_index , "FOPT"), ecl_sum_get_general_var( case2 , time_index , "FOPT")); ecl_sum_free(case2); ecl_sum_free(case1); ecl_file_close(restart_file); - + } test_work_area_free( work_area ); } @@ -186,27 +184,35 @@ void test_long_restart_names() { const char * name = "THE_CASE"; test_work_area_type * work_area = test_work_area_alloc("sum_write_restart_long_name"); { + int restart_step = 77; time_t start_time = util_make_date_utc( 1,1,2010 ); - ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer( name , restart_case , false , true , ":" , start_time , true , 3, 3, 3); + ecl_sum_type * ecl_sum = ecl_sum_alloc_restart_writer2( name , restart_case , restart_step, false , true , ":" , start_time , true , 3, 3, 3); ecl_sum_fwrite( ecl_sum ); ecl_sum_free(ecl_sum); - + ecl_file_type * smspec_file = ecl_file_open( "THE_CASE.SMSPEC" , 0 ); - ecl_file_view_type * view_file = ecl_file_get_global_view( smspec_file ); + ecl_file_view_type * view_file = ecl_file_get_global_view( smspec_file ); test_assert_true( ecl_file_view_has_kw(view_file, RESTART_KW)); - ecl_kw_type * kw = ecl_file_view_iget_kw(view_file, 0); - test_assert_int_equal(8, ecl_kw_get_size(kw)); + ecl_kw_type * restart_kw = ecl_file_view_iget_named_kw(view_file, "RESTART", 0); + test_assert_int_equal(8, ecl_kw_get_size(restart_kw)); for (int n = 0; n < 8; n++) { char s[9]; sprintf(s, "WWWWGGG%d", n); - test_assert_string_equal(s, ecl_kw_iget_char_ptr(kw, n) ); + test_assert_string_equal(s, ecl_kw_iget_char_ptr(restart_kw, n) ); + } + ecl_file_close( smspec_file); + { + ecl_smspec_type * smspec = ecl_smspec_alloc_restart_writer( ":" , "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", 10, start_time, true, 3, 3 ,3); + /* + Restart case is too long - it is ignored. + */ + test_assert_NULL( ecl_smspec_get_restart_case( smspec)); + ecl_smspec_free( smspec); } - - test_assert_NULL( ecl_smspec_alloc_writer( ":" , "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ", start_time, true, 3, 3 ,3) ); } test_work_area_free( work_area ); - + } int main( int argc , char ** argv) { diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c b/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c new file mode 100644 index 0000000000..45b2256f85 --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_filenames.c @@ -0,0 +1,120 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + The file 'ecl_util_filenames.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ +#include +#include + +#include +#include +#include +#include + +#include + + +void test_filename_report_nr() { + test_assert_int_equal(78, ecl_util_filename_report_nr("Path/with/mixedCASE/case.x0078")); + test_assert_int_equal(78, ecl_util_filename_report_nr("Case.X0078")); + test_assert_int_equal(ECL_EGRID_FILE, ecl_util_get_file_type("path/WITH/xase/MyGrid.EGrid", NULL, NULL)); +} + +void test_filename_case() { + test_assert_NULL( ecl_util_alloc_filename(NULL, "mixedBase", ECL_EGRID_FILE, false, -1)); + test_assert_string_equal( ecl_util_alloc_filename(NULL, "UPPER", ECL_EGRID_FILE, false, -1), "UPPER.EGRID"); + test_assert_string_equal( ecl_util_alloc_filename(NULL , "lower", ECL_EGRID_FILE, false, -1), "lower.egrid"); +} + + +void test_file_list() { + test_work_area_type * work_area = test_work_area_alloc("RESTART_FILES"); + stringlist_type * s = stringlist_alloc_new(); + + for (int i = 0; i < 10; i += 2) { + char * fname = ecl_util_alloc_filename(NULL, "case", ECL_RESTART_FILE, true, i); + FILE * stream = util_fopen(fname, "w"); + fclose(stream); + free( fname); + } + + for (int i = 0; i < 10; i += 2) { + char * fname = util_alloc_sprintf("Case.F%04d", i); + FILE * stream = util_fopen(fname, "w"); + fclose(stream); + free( fname); + } + + + ecl_util_select_filelist(NULL , "case" , ECL_RESTART_FILE, true, s); + test_assert_int_equal( stringlist_get_size(s), 5); + for (int i = 0; i < 5; i++) { + char * fname = ecl_util_alloc_filename(NULL, "case", ECL_RESTART_FILE, true, 2*i); + test_assert_string_equal( fname, stringlist_iget(s,i)); + free( fname); + } + + ecl_util_select_filelist(NULL , "Case" , ECL_RESTART_FILE, true, s); + test_assert_int_equal( stringlist_get_size(s), 0); + + + util_make_path("path"); + for (int i=0; i < 10; i++) { + char * summary_file1 = ecl_util_alloc_filename("path", "CASE1", ECL_SUMMARY_FILE, false, i ); + char * summary_file2 = ecl_util_alloc_filename("path", "CASE2", ECL_SUMMARY_FILE, true, i); + char * restart_file1 = ecl_util_alloc_filename("path", "CASE1", ECL_RESTART_FILE, false, i); + + FILE * f1 = fopen(summary_file1, "w"); + fclose(f1); + + FILE * f2 = fopen(summary_file2, "w"); + fclose(f2); + + FILE * f3 = fopen(restart_file1, "w"); + fclose(f3); + + free(summary_file1); + free(summary_file2); + free(restart_file1); + } + printf("-----------------------------------------------------------------\n"); + ecl_util_select_filelist(NULL, "path/CASE1", ECL_SUMMARY_FILE, false, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + ecl_util_select_filelist(NULL, "path/CASE1", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 0); + + ecl_util_select_filelist(NULL, "path/CASE2", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + ecl_util_select_filelist("path", "CASE1", ECL_SUMMARY_FILE, false, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + ecl_util_select_filelist("path", "CASE1", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 0); + + ecl_util_select_filelist("path", "CASE2", ECL_SUMMARY_FILE, true, s); + test_assert_int_equal(stringlist_get_size(s), 10); + + stringlist_free(s); + test_work_area_free(work_area); +} + + +int main(int argc , char ** argv) { + test_filename_report_nr(); + test_filename_case(); + test_file_list(); +} diff --git a/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c b/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c new file mode 100644 index 0000000000..1273184503 --- /dev/null +++ b/ThirdParty/Ert/lib/ecl/tests/ecl_util_path_access.c @@ -0,0 +1,53 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + The file 'ecl_util_path_access.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ +#include +#include +#include + +#include +#include +#include + +#include + + +void test_relative_access() { + test_work_area_type * work_area = test_work_area_alloc("access"); + test_assert_false( ecl_util_path_access("No/directory/does/not/exist")); + + util_make_path("path"); + test_assert_true( ecl_util_path_access("path")); + test_assert_true( ecl_util_path_access("path/FILE_DOES_NOT_EXIST")); + + { + FILE * f = util_fopen("path/file", "w"); + fprintf(f,"Hello\n"); + fclose(f); + } + test_assert_true( ecl_util_path_access("path/file")); + chmod("path/file", 0); + test_assert_false( ecl_util_path_access("path/file")); + + test_assert_true( ecl_util_path_access("ECLIPSE_CASE")); + test_work_area_free( work_area ); +} + + +int main(int argc, char ** argv) { + test_relative_access(); +} diff --git a/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp b/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp index 3191250797..7c3e30215c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp +++ b/ThirdParty/Ert/lib/ecl/tests/eclxx_kw.cpp @@ -20,10 +20,13 @@ #include #include -#include +#include + +#include #include #include +#include void test_kw_name() { ERT::EclKW< int > kw1( "short", 1 ); @@ -54,10 +57,10 @@ void test_kw_vector_string() { std::vector< const char* > vec = { "short", "sweet", - "padded ", - "verylongkeyword" + "padded " }; + std::vector too_long = {"1234567890"}; ERT::EclKW< const char* > kw( "XYZ", vec ); test_assert_size_t_equal( kw.size(), vec.size() ); @@ -65,10 +68,38 @@ void test_kw_vector_string() { test_assert_string_equal( kw.at( 0 ), "short " ); test_assert_string_equal( kw.at( 1 ), "sweet " ); test_assert_string_equal( kw.at( 2 ), vec.at( 2 ) ); - test_assert_string_equal( kw.at( 3 ), "verylong" ); - test_assert_string_not_equal( kw.at( 2 ), "verylongkeyword" ); + + test_assert_throw( ERT::EclKW("XY", too_long), std::range_error); +} + +void test_kw_vector_std_string() { + std::vector< const char* > vec = { + "short", + "sweet", + "padded ", + }; + std::vector too_long = {"1234567890"}; + ERT::EclKW< std::string > kw( "XYZ", vec ); + + test_assert_size_t_equal( kw.size(), vec.size() ); + + test_assert_string_equal( kw.at( 0 ).c_str(), "short " ); + test_assert_string_equal( kw.at( 1 ).c_str(), "sweet " ); + test_assert_string_equal( kw.at( 2 ).c_str(), vec.at( 2 ) ); + + test_assert_throw( ERT::EclKW("XY", too_long), std::range_error); +} + +void test_logical() { + //std::vector vec = {true,false,true,false}; + // ERT::EclKW kw("BOOL", vec); + // test_assert_int_equal(kw.size(), vec.size()); + + // for (size_t i=0; i < vec.size(); i++) + // test_assert_true( kw.at(i) == vec[i] ); } + void test_move_semantics_no_crash() { std::vector< int > vec = { 1, 2, 3, 4, 5 }; ERT::EclKW< int > kw1( "XYZ", vec ); @@ -96,13 +127,103 @@ void test_resize() { test_assert_int_equal( kw1.size() , 100 ); } +void test_data() { + std::vector d_data = {1,2,3,4}; + std::vector f_data = {10,20,30,40}; + std::vector i_data = {100,200,300,400}; + std::vector b_data = {true,false}; + std::vector s_data = {"S1", "S2", "S3"}; + + ERT::EclKW d_kw("DOUBLE", d_data); + auto d_data2 = d_kw.data(); + for (size_t i=0; i < d_data.size(); i++) + test_assert_true(d_data[i] == d_data2[i]); + + ERT::EclKW f_kw("FLOATx", f_data); + auto f_data2 = f_kw.data(); + for (size_t i=0; i < f_data.size(); i++) + test_assert_true(f_data[i] == f_data2[i]); + + ERT::EclKW i_kw("INT", i_data); + auto i_data2 = i_kw.data(); + for (size_t i=0; i < i_data.size(); i++) + test_assert_true(i_data[i] == i_data2[i]); + + //ERT::EclKW b_kw("bbb", b_data); + //auto b_data2 = b_kw.data(); + //for (size_t i=0; i < b_data.size(); i++) + // test_assert_true(b_data[i] == b_data2[i]); + + ERT::EclKW s_kw("sss", s_data); + auto s_data2 = s_kw.data(); + for (size_t i=0; i < s_data.size(); i++) + test_assert_true(s_data[i] == s_data2[i]); + +} + + +void test_read_write() { + std::vector d_data = {1,2,3,4}; + std::vector f_data = {10,20,30,40}; + std::vector i_data = {100,200,300,400}; + std::vector b_data = {true,false}; + std::vector s_data = {"S1", "S2", "S3"}; + + { + ERT::TestArea ta("test_fwrite"); + { + ERT::FortIO f("test_file", std::ios_base::out); + ERT::write_kw(f, "DOUBLE", d_data); + ERT::write_kw(f, "FLOAT", f_data); + ERT::write_kw(f, "INT", i_data); + ERT::write_kw(f, "BOOL", b_data); + ERT::write_kw(f, "STRING", s_data); + } + + { + ecl_file_type * f = ecl_file_open("test_file", 0); + ecl_kw_type * d_kw = ecl_file_iget_named_kw(f, "DOUBLE", 0); + ecl_kw_type * f_kw = ecl_file_iget_named_kw(f, "FLOAT", 0); + ecl_kw_type * i_kw = ecl_file_iget_named_kw(f, "INT", 0); + ecl_kw_type * b_kw = ecl_file_iget_named_kw(f, "BOOL", 0); + ecl_kw_type * s_kw = ecl_file_iget_named_kw(f, "STRING", 0); + + for (size_t i=0; i < d_data.size(); i++) + test_assert_true(d_data[i] == ecl_kw_iget_double(d_kw,i)); + + for (size_t i=0; i < f_data.size(); i++) + test_assert_true(f_data[i] == ecl_kw_iget_float(f_kw,i)); + + for (size_t i=0; i < i_data.size(); i++) + test_assert_true(i_data[i] == ecl_kw_iget_int(i_kw,i)); + + for (size_t i=0; i < b_data.size(); i++) + test_assert_true(b_data[i] == ecl_kw_iget_bool(b_kw,i)); + + for (size_t i=0; i < s_data.size(); i++) { + std::string s8 = ecl_kw_iget_char_ptr(s_kw, i); + test_assert_int_equal(s8.size(), 8); + s8.erase(s8.find_last_not_of(' ')+1); + test_assert_true( s_data[i] == s8); + } + + ecl_file_close(f); + } + } +} + + int main (int argc, char **argv) { test_kw_name(); test_kw_vector_assign(); test_kw_vector_string(); + test_kw_vector_std_string(); + test_logical(); test_move_semantics_no_crash(); test_exception_assing_ref_wrong_type(); test_resize(); + test_data(); + test_read_write(); } diff --git a/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c b/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c index bd6d410d3a..39daebd45e 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_branch_collection.c @@ -62,8 +62,12 @@ int main(int argc , char ** argv) { test_assert_true( well_segment_is_instance( well_branch_collection_iget_start_segment( branches , 0 ))); test_assert_true( well_segment_is_instance( well_branch_collection_get_start_segment( branches , 78 ))); test_assert_true( well_branch_collection_has_branch( branches , 78 )); + + well_segment_free( segment2 ); + well_segment_free( segment1 ); } + free( rseg_data ); well_branch_collection_free( branches ); exit(0); diff --git a/ThirdParty/Ert/lib/ecl/tests/well_conn.c b/ThirdParty/Ert/lib/ecl/tests/well_conn.c index b788d95f7c..a1c8583eb3 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_conn.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_conn.c @@ -77,6 +77,8 @@ int main(int argc , char ** argv) { test_assert_true( well_conn_equal( conn , conn2 )); test_assert_false( well_conn_equal( conn , conn3 )); test_assert_double_equal( CF , well_conn_get_connection_factor( conn )); + well_conn_free( conn3 ); + well_conn_free( conn2 ); well_conn_free( conn ); } @@ -107,6 +109,7 @@ int main(int argc , char ** argv) { well_conn_dir_enum dir = well_conn_dirX; well_conn_type * conn = well_conn_alloc_fracture(i,j,k,CF,dir,open); test_assert_not_NULL( conn ); + well_conn_free( conn ); } { diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment.c b/ThirdParty/Ert/lib/ecl/tests/well_segment.c index a3f1cce752..79426e62fd 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment.c @@ -72,6 +72,7 @@ int main(int argc , char ** argv) { test_assert_true( well_segment_nearest_wellhead( ws )); test_assert_false( well_segment_main_stem( ws )); + well_segment_free( ws ); } @@ -81,6 +82,7 @@ int main(int argc , char ** argv) { well_segment_type * ws = well_segment_alloc(89 , outlet_segment_id , branch_nr, rseg_data); test_assert_false( well_segment_active( ws )); + well_segment_free( ws ); } { @@ -96,6 +98,7 @@ int main(int argc , char ** argv) { well_segment_link_strict( ws , outlet ); // This relinks - not very logical; refcount gets wrong. well_segment_free( ws ); + well_segment_free( outlet ); } { @@ -109,6 +112,7 @@ int main(int argc , char ** argv) { test_assert_int_equal( well_segment_get_link_count( outlet ) , 0 ); well_segment_free( ws ); + well_segment_free( outlet ); } free( rseg_data ); exit(0); diff --git a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c index c1dbdf2591..b3886e604c 100644 --- a/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c +++ b/ThirdParty/Ert/lib/ecl/tests/well_segment_conn.c @@ -55,6 +55,10 @@ int main(int argc , char ** argv) { test_assert_true( well_conn_collection_is_instance( well_segment_get_connections( ws , ECL_GRID_GLOBAL_GRID))); test_assert_true( well_conn_collection_is_instance( well_segment_get_global_connections( ws))); test_assert_NULL( well_segment_get_connections( ws , "doesNotExist")); + + well_conn_free( conn1 ); + well_conn_free( conn2 ); + well_segment_free( ws ); } free( rseg_data ); exit(0); diff --git a/ThirdParty/Ert/lib/ecl/well_branch_collection.c b/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp similarity index 87% rename from ThirdParty/Ert/lib/ecl/well_branch_collection.c rename to ThirdParty/Ert/lib/ecl/well_branch_collection.cpp index 959159de67..dfc43b96b3 100644 --- a/ThirdParty/Ert/lib/ecl/well_branch_collection.c +++ b/ThirdParty/Ert/lib/ecl/well_branch_collection.cpp @@ -18,14 +18,14 @@ #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include +#include +#include +#include #define WELL_BRANCH_COLLECTION_TYPE_ID 67177087 @@ -43,7 +43,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_branch_collection , WELL_BRANCH_COLLECTION_ well_branch_collection_type * well_branch_collection_alloc() { - well_branch_collection_type * branch_collection = util_malloc( sizeof * branch_collection ); + well_branch_collection_type * branch_collection = (well_branch_collection_type*)util_malloc( sizeof * branch_collection ); UTIL_TYPE_ID_INIT( branch_collection , WELL_BRANCH_COLLECTION_TYPE_ID ); branch_collection->__start_segments = vector_alloc_new(); branch_collection->index_map = int_vector_alloc(0 , -1 ); @@ -82,7 +82,7 @@ bool well_branch_collection_has_branch( const well_branch_collection_type * bran const well_segment_type * well_branch_collection_iget_start_segment( const well_branch_collection_type * branches , int index ) { if (index < vector_get_size( branches->__start_segments)) - return vector_iget_const( branches->__start_segments , index); + return (const well_segment_type*)vector_iget_const( branches->__start_segments , index); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_conn.c b/ThirdParty/Ert/lib/ecl/well_conn.cpp similarity index 77% rename from ThirdParty/Ert/lib/ecl/well_conn.c rename to ThirdParty/Ert/lib/ecl/well_conn.cpp index 74e87521b7..aaa394901c 100644 --- a/ThirdParty/Ert/lib/ecl/well_conn.c +++ b/ThirdParty/Ert/lib/ecl/well_conn.cpp @@ -19,14 +19,14 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include +#include +#include #define WELL_CONN_NORMAL_WELL_SEGMENT_ID -999 @@ -92,7 +92,7 @@ UTIL_SAFE_CAST_FUNCTION( well_conn , WELL_CONN_TYPE_ID) static well_conn_type * well_conn_alloc__( int i , int j , int k , double connection_factor , well_conn_dir_enum dir , bool open, int segment_id, bool matrix_connection) { if (well_conn_assert_direction( dir , matrix_connection)) { - well_conn_type * conn = util_malloc( sizeof * conn ); + well_conn_type * conn = (well_conn_type*)util_malloc( sizeof * conn ); UTIL_TYPE_ID_INIT( conn , WELL_CONN_TYPE_ID ); conn->i = i; conn->j = j; @@ -142,9 +142,6 @@ well_conn_type * well_conn_alloc_fracture_MSW( int i , int j , int k , double co return well_conn_alloc__(i , j , k , connection_factor , dir , open , segment_id , false); } - - - /* Observe that the (ijk) and branch values are shifted to zero offset to be aligned with the rest of the ert libraries. @@ -157,73 +154,74 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , int conn_nr ) { const int icon_offset = header->niconz * ( header->ncwmax * well_nr + conn_nr ); - int IC = ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_INDEX ); - if (IC > 0) { - well_conn_type * conn; - int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_INDEX ) - 1; - int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_INDEX ) - 1; - int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_INDEX ) - 1; - double connection_factor = -1; - bool matrix_connection = true; - bool open; - well_conn_dir_enum dir = well_conn_fracX; - - /* Set the status */ - { - int int_status = ecl_kw_iget_int( icon_kw , icon_offset + ICON_STATUS_INDEX ); - if (int_status > 0) - open = true; - else - open = false; - } + int IC =ecl_kw_iget_int( icon_kw , icon_offset + ICON_IC_INDEX ); + if (IC <= 0) + return NULL; /* IC < 0: Connection not in current LGR. */ - /* Set the K value and fracture flag. */ - { - if (header->dualp) { - int geometric_nz = header->nz / 2; - if (k >= geometric_nz) { - k -= geometric_nz; - matrix_connection = false; - } - } - } + /* + Out in the wild we have encountered files where the integer value used to + indicate direction has had an invalid value for some connections. In this + case we just return NULL and forget about the connection - it seems to work. + */ + int int_direction = ecl_kw_iget_int( icon_kw , icon_offset + ICON_DIRECTION_INDEX ); + if ((int_direction < 0) || (int_direction > ICON_FRACY)) { + fprintf(stderr,"Invalid direction value:%d encountered for well - connection ignored\n",int_direction); + return NULL; + } + + + int i = ecl_kw_iget_int( icon_kw , icon_offset + ICON_I_INDEX ) - 1; + int j = ecl_kw_iget_int( icon_kw , icon_offset + ICON_J_INDEX ) - 1; + int k = ecl_kw_iget_int( icon_kw , icon_offset + ICON_K_INDEX ) - 1; + double connection_factor = -1; + bool matrix_connection = true; + bool is_open = (ecl_kw_iget_int(icon_kw, icon_offset + ICON_STATUS_INDEX) > 0); + well_conn_dir_enum dir = well_conn_fracX; - /* Set the direction flag */ - { - int int_direction = ecl_kw_iget_int( icon_kw , icon_offset + ICON_DIRECTION_INDEX ); - if (int_direction == ICON_DEFAULT_DIR_VALUE) - int_direction = ICON_DEFAULT_DIR_TARGET; - - switch (int_direction) { - case(ICON_DIRX): - dir = well_conn_dirX; - break; - case(ICON_DIRY): - dir = well_conn_dirY; - break; - case(ICON_DIRZ): - dir = well_conn_dirZ; - break; - case(ICON_FRACX): - dir = well_conn_fracX; - break; - case(ICON_FRACY): - dir = well_conn_fracY; - break; - default: - util_abort("%s: icon direction value:%d not recognized\n",__func__ , int_direction); + /* Set the K value and fracture flag. */ + { + if (header->dualp) { + int geometric_nz = header->nz / 2; + if (k >= geometric_nz) { + k -= geometric_nz; + matrix_connection = false; } } + } - if (scon_kw) { - const int scon_offset = header->nsconz * ( header->ncwmax * well_nr + conn_nr ); - connection_factor = ecl_kw_iget_as_double(scon_kw , scon_offset + SCON_CF_INDEX); - } + /* Set the direction flag */ + if (int_direction == ICON_DEFAULT_DIR_VALUE) + int_direction = ICON_DEFAULT_DIR_TARGET; + + switch (int_direction) { + case(ICON_DIRX): + dir = well_conn_dirX; + break; + case(ICON_DIRY): + dir = well_conn_dirY; + break; + case(ICON_DIRZ): + dir = well_conn_dirZ; + break; + case(ICON_FRACX): + dir = well_conn_fracX; + break; + case(ICON_FRACY): + dir = well_conn_fracY; + break; + } + + if (scon_kw) { + const int scon_offset = header->nsconz * ( header->ncwmax * well_nr + conn_nr ); + connection_factor = ecl_kw_iget_as_double(scon_kw , scon_offset + SCON_CF_INDEX); + } + + { int segment_id = ecl_kw_iget_int( icon_kw , icon_offset + ICON_SEGMENT_INDEX ) - ECLIPSE_WELL_SEGMENT_OFFSET + WELL_SEGMENT_OFFSET; - conn = well_conn_alloc__(i,j,k,connection_factor,dir,open,segment_id,matrix_connection); + well_conn_type * conn = well_conn_alloc__(i,j,k,connection_factor,dir,is_open,segment_id,matrix_connection); if (xcon_kw) { const int xcon_offset = header->nxconz * (header->ncwmax * well_nr + conn_nr); @@ -242,8 +240,7 @@ well_conn_type * well_conn_alloc_from_kw( const ecl_kw_type * icon_kw , */ return conn; - } else - return NULL; /* IC < 0: Connection not in current LGR. */ + } } @@ -279,9 +276,9 @@ well_conn_type * well_conn_alloc_wellhead( const ecl_kw_type * iwel_kw , const e } if (matrix_connection) - return well_conn_alloc( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ ); + return well_conn_alloc( conn_i , conn_j , conn_k , connection_factor , (well_conn_dir_enum)open , well_conn_dirZ ); else - return well_conn_alloc_fracture( conn_i , conn_j , conn_k , connection_factor , open , well_conn_dirZ ); + return well_conn_alloc_fracture( conn_i , conn_j , conn_k , connection_factor , (well_conn_dir_enum)open , well_conn_dirZ ); } else // The well is completed in this LGR - however the wellhead is in another LGR. return NULL; diff --git a/ThirdParty/Ert/lib/ecl/well_conn_collection.c b/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp similarity index 86% rename from ThirdParty/Ert/lib/ecl/well_conn_collection.c rename to ThirdParty/Ert/lib/ecl/well_conn_collection.cpp index 6277279614..2e77fd61a3 100644 --- a/ThirdParty/Ert/lib/ecl/well_conn_collection.c +++ b/ThirdParty/Ert/lib/ecl/well_conn_collection.cpp @@ -18,16 +18,16 @@ #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include #define WELL_CONN_COLLECTION_TYPE_ID 67150087 @@ -43,7 +43,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_conn_collection , WELL_CONN_COLLECTION_TYPE well_conn_collection_type * well_conn_collection_alloc() { - well_conn_collection_type * wellcc = util_malloc( sizeof * wellcc ); + well_conn_collection_type * wellcc = (well_conn_collection_type*)util_malloc( sizeof * wellcc ); UTIL_TYPE_ID_INIT( wellcc , WELL_CONN_COLLECTION_TYPE_ID ); wellcc->connection_list = vector_alloc_new(); return wellcc; @@ -86,15 +86,16 @@ int well_conn_collection_get_size( const well_conn_collection_type * wellcc ) { const well_conn_type * well_conn_collection_iget_const(const well_conn_collection_type * wellcc , int index) { int size = well_conn_collection_get_size( wellcc ); if (index < size) - return vector_iget_const( wellcc->connection_list , index ); + return (const well_conn_type*)vector_iget_const( wellcc->connection_list , index ); else return NULL; } + well_conn_type * well_conn_collection_iget(const well_conn_collection_type * wellcc , int index) { int size = well_conn_collection_get_size( wellcc ); if (index < size) - return vector_iget( wellcc->connection_list , index ); + return (well_conn_type*)vector_iget( wellcc->connection_list , index ); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_info.c b/ThirdParty/Ert/lib/ecl/well_info.cpp similarity index 95% rename from ThirdParty/Ert/lib/ecl/well_info.c rename to ThirdParty/Ert/lib/ecl/well_info.cpp index d57fdf8de3..d2e00429b4 100644 --- a/ThirdParty/Ert/lib/ecl/well_info.c +++ b/ThirdParty/Ert/lib/ecl/well_info.cpp @@ -19,23 +19,23 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include /* @@ -192,7 +192,7 @@ struct well_info_struct { */ well_info_type * well_info_alloc( const ecl_grid_type * grid) { - well_info_type * well_info = util_malloc( sizeof * well_info ); + well_info_type * well_info = (well_info_type*)util_malloc( sizeof * well_info ); well_info->wells = hash_alloc(); well_info->well_names = stringlist_alloc_new(); well_info->grid = grid; @@ -205,7 +205,7 @@ bool well_info_has_well( well_info_type * well_info , const char * well_name ) { } well_ts_type * well_info_get_ts( const well_info_type * well_info , const char *well_name) { - return hash_get( well_info->wells , well_name ); + return (well_ts_type*)hash_get( well_info->wells , well_name ); } static void well_info_add_new_ts( well_info_type * well_info , const char * well_name) { diff --git a/ThirdParty/Ert/lib/ecl/well_rseg_loader.c b/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp similarity index 85% rename from ThirdParty/Ert/lib/ecl/well_rseg_loader.c rename to ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp index f457cf1f77..29e507409b 100644 --- a/ThirdParty/Ert/lib/ecl/well_rseg_loader.c +++ b/ThirdParty/Ert/lib/ecl/well_rseg_loader.cpp @@ -18,15 +18,15 @@ #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include #include @@ -41,14 +41,14 @@ struct well_rseg_loader_struct { well_rseg_loader_type * well_rseg_loader_alloc(ecl_file_view_type * rst_view) { - well_rseg_loader_type * loader = util_malloc(sizeof * loader); + well_rseg_loader_type * loader = (well_rseg_loader_type*)util_malloc(sizeof * loader); int element_count = 4; loader->rst_view = rst_view; loader->relative_index_map = int_vector_alloc(0, 0); loader->absolute_index_map = int_vector_alloc(0, 0); - loader->buffer = util_malloc(element_count * sizeof(double)); + loader->buffer = (char*)util_malloc(element_count * sizeof(double)); loader->kw = RSEG_KW; int_vector_append(loader->relative_index_map, RSEG_DEPTH_INDEX); diff --git a/ThirdParty/Ert/lib/ecl/well_segment.c b/ThirdParty/Ert/lib/ecl/well_segment.cpp similarity index 92% rename from ThirdParty/Ert/lib/ecl/well_segment.c rename to ThirdParty/Ert/lib/ecl/well_segment.cpp index b1b4912cdd..8209506788 100644 --- a/ThirdParty/Ert/lib/ecl/well_segment.c +++ b/ThirdParty/Ert/lib/ecl/well_segment.cpp @@ -18,17 +18,17 @@ #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define WELL_SEGMENT_TYPE_ID 2209166 @@ -53,7 +53,7 @@ static UTIL_SAFE_CAST_FUNCTION( well_segment , WELL_SEGMENT_TYPE_ID ) well_segment_type * well_segment_alloc(int segment_id , int outlet_segment_id , int branch_id , const double * rseg_data) { - well_segment_type * segment = util_malloc( sizeof * segment ); + well_segment_type * segment = (well_segment_type*)util_malloc( sizeof * segment ); UTIL_TYPE_ID_INIT( segment , WELL_SEGMENT_TYPE_ID ); segment->link_count = 0; @@ -212,7 +212,7 @@ bool well_segment_add_connection( well_segment_type * segment , const char * gri hash_insert_hash_owned_ref( segment->connections , grid_name , well_conn_collection_alloc() , well_conn_collection_free__ ); { - well_conn_collection_type * connections = hash_get( segment->connections , grid_name ); + well_conn_collection_type * connections = (well_conn_collection_type*)hash_get( segment->connections , grid_name ); well_conn_collection_add_ref( connections , conn ); } return true; @@ -223,7 +223,7 @@ bool well_segment_add_connection( well_segment_type * segment , const char * gri const well_conn_collection_type * well_segment_get_connections(const well_segment_type * segment , const char * grid_name ) { if (well_segment_has_grid_connections( segment , grid_name)) - return hash_get( segment->connections , grid_name); + return (const well_conn_collection_type*)hash_get( segment->connections , grid_name); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_segment_collection.c b/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/well_segment_collection.c rename to ThirdParty/Ert/lib/ecl/well_segment_collection.cpp index a919ea0c33..dadfe69449 100644 --- a/ThirdParty/Ert/lib/ecl/well_segment_collection.c +++ b/ThirdParty/Ert/lib/ecl/well_segment_collection.cpp @@ -18,18 +18,18 @@ #include -#include -#include +#include +#include -#include -#include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include struct well_segment_collection_struct { @@ -40,7 +40,7 @@ struct well_segment_collection_struct { well_segment_collection_type * well_segment_collection_alloc(void) { - well_segment_collection_type * segment_collection = util_malloc( sizeof * segment_collection ); + well_segment_collection_type * segment_collection = (well_segment_collection_type*)util_malloc( sizeof * segment_collection ); segment_collection->__segment_storage = vector_alloc_new(); segment_collection->segment_index_map = int_vector_alloc( 0 , -1 ); @@ -77,7 +77,7 @@ void well_segment_collection_add( well_segment_collection_type * segment_collect well_segment_type * well_segment_collection_iget( const well_segment_collection_type * segment_collection , int index) { - return vector_iget( segment_collection->__segment_storage , index ); + return (well_segment_type*)vector_iget( segment_collection->__segment_storage , index ); } diff --git a/ThirdParty/Ert/lib/ecl/well_state.c b/ThirdParty/Ert/lib/ecl/well_state.cpp similarity index 93% rename from ThirdParty/Ert/lib/ecl/well_state.c rename to ThirdParty/Ert/lib/ecl/well_state.cpp index 91d91862a6..7ee3129efe 100644 --- a/ThirdParty/Ert/lib/ecl/well_state.c +++ b/ThirdParty/Ert/lib/ecl/well_state.cpp @@ -25,27 +25,27 @@ #include #include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include /* @@ -193,7 +193,7 @@ UTIL_IS_INSTANCE_FUNCTION( well_state , WELL_STATE_TYPE_ID) well_state_type * well_state_alloc(const char * well_name , int global_well_nr , bool open, well_type_enum type , int report_nr, time_t valid_from) { - well_state_type * well_state = util_malloc( sizeof * well_state ); + well_state_type * well_state = (well_state_type*)util_malloc( sizeof * well_state ); UTIL_TYPE_ID_INIT( well_state , WELL_STATE_TYPE_ID ); well_state->index_wellhead = vector_alloc_new(); well_state->name_wellhead = hash_alloc(); @@ -340,7 +340,7 @@ static int well_state_get_lgr_well_nr( const well_state_type * well_state , cons while (true) { bool found = false; { - char * lgr_well_name = util_alloc_strip_copy( ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); + char * lgr_well_name = (char*)util_alloc_strip_copy( (const char*)ecl_kw_iget_ptr( zwel_kw , well_nr * header->nzwelz) ); if ( strcmp( well_state->name , lgr_well_name) == 0) found = true; @@ -425,7 +425,7 @@ static void well_state_add_connections__( well_state_type * well_state , xcon_kw = ecl_file_view_iget_named_kw(rst_view, XCON_KW, 0); } - well_conn_collection_type * wellcc = hash_get( well_state->connections , grid_name ); + well_conn_collection_type * wellcc = (well_conn_collection_type*)hash_get( well_state->connections , grid_name ); well_conn_collection_load_from_kw( wellcc , iwel_kw , icon_kw , scon_kw, xcon_kw , well_nr , header ); } ecl_rsthead_free( header ); @@ -518,7 +518,7 @@ bool well_state_add_MSW2( well_state_type * well_state , hash_iter_type * grid_iter = hash_iter_alloc( well_state->connections ); while (!hash_iter_is_complete( grid_iter )) { const char * grid_name = hash_iter_get_next_key( grid_iter ); - const well_conn_collection_type * connections = hash_get( well_state->connections , grid_name ); + const well_conn_collection_type * connections = (const well_conn_collection_type*)hash_get( well_state->connections , grid_name ); well_segment_collection_add_connections( well_state->segments , grid_name , connections ); } hash_iter_free( grid_iter ); @@ -581,7 +581,7 @@ well_state_type * well_state_alloc_from_file2( ecl_file_view_type * file_view , { const int zwel_offset = global_header->nzwelz * global_well_nr; - name = util_alloc_strip_copy(ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name + name = (char*)util_alloc_strip_copy((const char*)ecl_kw_iget_ptr( global_zwel_kw , zwel_offset )); // Hardwired max 8 characters in Well Name } well_state = well_state_alloc(name , global_well_nr , open , type , report_nr , global_header->sim_time); @@ -631,20 +631,20 @@ time_t well_state_get_sim_time( const well_state_type * well_state ) { Will return NULL if no wellhead in this grid. */ const well_conn_type * well_state_iget_wellhead( const well_state_type * well_state , int grid_nr) { - return vector_safe_iget_const( well_state->index_wellhead , grid_nr ); + return (const well_conn_type*)vector_safe_iget_const( well_state->index_wellhead , grid_nr ); } const well_conn_type * well_state_get_wellhead( const well_state_type * well_state , const char * grid_name) { if (hash_has_key( well_state->name_wellhead , grid_name)) - return hash_get( well_state->name_wellhead , grid_name ); + return (const well_conn_type*)hash_get( well_state->name_wellhead , grid_name ); else return NULL; } const well_conn_type * well_state_get_global_wellhead( const well_state_type * well_state ) { if (hash_has_key( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID)) - return hash_get( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID ); + return (const well_conn_type*)hash_get( well_state->name_wellhead , ECL_GRID_GLOBAL_GRID ); else return NULL; } @@ -672,7 +672,7 @@ const char * well_state_get_name( const well_state_type * well_state ) { const well_conn_collection_type * well_state_get_grid_connections( const well_state_type * well_state , const char * grid_name) { if (hash_has_key( well_state->connections , grid_name)) - return hash_get( well_state->connections , grid_name); + return (const well_conn_collection_type*)hash_get( well_state->connections , grid_name); else return NULL; } diff --git a/ThirdParty/Ert/lib/ecl/well_ts.c b/ThirdParty/Ert/lib/ecl/well_ts.cpp similarity index 90% rename from ThirdParty/Ert/lib/ecl/well_ts.c rename to ThirdParty/Ert/lib/ecl/well_ts.cpp index 9680131eb1..2a51809e72 100644 --- a/ThirdParty/Ert/lib/ecl/well_ts.c +++ b/ThirdParty/Ert/lib/ecl/well_ts.cpp @@ -62,12 +62,12 @@ #include #include -#include -#include +#include +#include -#include -#include -#include +#include +#include +#include @@ -91,7 +91,7 @@ struct well_ts_struct { /******************************************************************/ static well_node_type * well_node_alloc( well_state_type * well_state) { - well_node_type * node = util_malloc( sizeof * node ); + well_node_type * node = (well_node_type*)util_malloc( sizeof * node ); UTIL_TYPE_ID_INIT( node , WELL_NODE_TYPE_ID ); node->report_nr = well_state_get_report_nr( well_state ); node->sim_time = well_state_get_sim_time( well_state ); @@ -131,7 +131,7 @@ static int well_node_time_cmp( const void * arg1 , const void * arg2) { /*****************************************************************/ static well_ts_type * well_ts_alloc_empty( ) { - well_ts_type * well_ts = util_malloc( sizeof * well_ts ); + well_ts_type * well_ts = (well_ts_type*)util_malloc( sizeof * well_ts ); UTIL_TYPE_ID_INIT( well_ts , WELL_TS_TYPE_ID ); well_ts->ts = vector_alloc_new(); @@ -157,8 +157,8 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , return 0; else { - const well_node_type * first_node = vector_iget_const( well_ts->ts , 0 ); - const well_node_type * last_node = vector_get_last_const( well_ts->ts ); + const well_node_type * first_node = (const well_node_type*)vector_iget_const( well_ts->ts , 0 ); + const well_node_type * last_node = (const well_node_type*)vector_get_last_const( well_ts->ts ); if (use_report) { if (report_step < first_node->report_nr) @@ -181,7 +181,7 @@ static int well_ts_get_index__( const well_ts_type * well_ts , int report_step , while (true) { int center_index = (lower_index + upper_index) / 2; - const well_node_type * center_node = vector_iget_const( well_ts->ts , center_index ); + const well_node_type * center_node = (const well_node_type*)vector_iget_const( well_ts->ts , center_index ); double cmp; if (use_report) cmp = center_node->report_nr - report_step; @@ -221,11 +221,11 @@ static int well_ts_get_index( const well_ts_type * well_ts , int report_step , t // Inline check that the index is correct { bool OK = true; - const well_node_type * node = vector_iget_const( well_ts->ts , index ); + const well_node_type * node = (const well_node_type*)vector_iget_const( well_ts->ts , index ); well_node_type * next_node = NULL; if (index < (vector_get_size( well_ts->ts ) - 1)) - next_node = vector_iget( well_ts->ts , index + 1); + next_node = (well_node_type*)vector_iget( well_ts->ts , index + 1); if (use_report) { if (index < 0) { @@ -268,7 +268,7 @@ void well_ts_add_well( well_ts_type * well_ts , well_state_type * well_state ) { vector_append_owned_ref( well_ts->ts , new_node , well_node_free__ ); if (vector_get_size( well_ts->ts ) > 1) { - const well_node_type * last_node = vector_get_last_const(well_ts->ts ); + const well_node_type * last_node = (const well_node_type*)vector_get_last_const(well_ts->ts ); if (new_node->sim_time < last_node->sim_time) // The new node is chronologically before the previous node; // i.e. we must sort the nodes in time. This should probably happen @@ -309,7 +309,7 @@ well_state_type * well_ts_get_last_state( const well_ts_type * well_ts) { well_state_type * well_ts_iget_state( const well_ts_type * well_ts , int index) { - well_node_type * node = vector_iget( well_ts->ts , index ); + well_node_type * node = (well_node_type*)vector_iget( well_ts->ts , index ); return node->well_state; } diff --git a/ThirdParty/Ert/lib/ert_api_config.h.in b/ThirdParty/Ert/lib/ert_api_config.h.in index 11b43d6b19..0a74e7d730 100644 --- a/ThirdParty/Ert/lib/ert_api_config.h.in +++ b/ThirdParty/Ert/lib/ert_api_config.h.in @@ -1,4 +1,3 @@ -#cmakedefine ERT_HAVE_LAPACK #cmakedefine ERT_HAVE_ZLIB #cmakedefine ERT_HAVE_ISFINITE #cmakedefine ERT_HAVE_GETOPT @@ -8,6 +7,7 @@ #cmakedefine ERT_HAVE_OPENDIR #cmakedefine ERT_HAVE_SYMLINK #cmakedefine ERT_HAVE_READLINKAT +#cmakedefine ERT_HAVE_READLINKAT_DECLARATION #cmakedefine ERT_HAVE_GLOB #cmakedefine ERT_HAVE_GETUID #cmakedefine ERT_HAVE_REGEXP diff --git a/ThirdParty/Ert/lib/ert_api_config.hpp.in b/ThirdParty/Ert/lib/ert_api_config.hpp.in new file mode 100644 index 0000000000..78411e4360 --- /dev/null +++ b/ThirdParty/Ert/lib/ert_api_config.hpp.in @@ -0,0 +1 @@ +#include diff --git a/ThirdParty/Ert/lib/geometry/geo_pointset.c b/ThirdParty/Ert/lib/geometry/geo_pointset.cpp similarity index 92% rename from ThirdParty/Ert/lib/geometry/geo_pointset.c rename to ThirdParty/Ert/lib/geometry/geo_pointset.cpp index 32eaa2ea2d..970b2fd2cb 100644 --- a/ThirdParty/Ert/lib/geometry/geo_pointset.c +++ b/ThirdParty/Ert/lib/geometry/geo_pointset.cpp @@ -21,9 +21,9 @@ #include #include -#include +#include -#include +#include #define INIT_SIZE 256 @@ -42,17 +42,17 @@ struct geo_pointset_struct { static void geo_pointset_resize( geo_pointset_type * pointset, int new_alloc_size) { - pointset->xcoord = util_realloc( pointset->xcoord , new_alloc_size * sizeof * pointset->xcoord ); - pointset->ycoord = util_realloc( pointset->ycoord , new_alloc_size * sizeof * pointset->ycoord ); + pointset->xcoord = (double*)util_realloc( pointset->xcoord , new_alloc_size * sizeof * pointset->xcoord ); + pointset->ycoord = (double*)util_realloc( pointset->ycoord , new_alloc_size * sizeof * pointset->ycoord ); if (pointset->internal_z) - pointset->zcoord = util_realloc( pointset->zcoord , new_alloc_size * sizeof * pointset->zcoord); + pointset->zcoord = (double*)util_realloc( pointset->zcoord , new_alloc_size * sizeof * pointset->zcoord); pointset->alloc_size = new_alloc_size; } geo_pointset_type * geo_pointset_alloc( bool internal_z) { - geo_pointset_type * pointset = util_malloc( sizeof * pointset ); + geo_pointset_type * pointset = (geo_pointset_type*)util_malloc( sizeof * pointset ); pointset->xcoord = NULL; pointset->ycoord = NULL; pointset->zcoord = NULL; diff --git a/ThirdParty/Ert/lib/geometry/geo_polygon.c b/ThirdParty/Ert/lib/geometry/geo_polygon.cpp similarity index 95% rename from ThirdParty/Ert/lib/geometry/geo_polygon.c rename to ThirdParty/Ert/lib/geometry/geo_polygon.cpp index 1780a9d0db..516d90de04 100644 --- a/ThirdParty/Ert/lib/geometry/geo_polygon.c +++ b/ThirdParty/Ert/lib/geometry/geo_polygon.cpp @@ -21,12 +21,12 @@ #include #include -#include -#include -#include +#include +#include +#include -#include -#include +#include +#include @@ -45,7 +45,7 @@ UTIL_IS_INSTANCE_FUNCTION( geo_polygon , GEO_POLYGON_TYPE_ID); geo_polygon_type * geo_polygon_alloc(const char * name) { - geo_polygon_type * polygon = util_malloc( sizeof * polygon ); + geo_polygon_type * polygon = (geo_polygon_type*)util_malloc( sizeof * polygon ); UTIL_TYPE_ID_INIT( polygon , GEO_POLYGON_TYPE_ID ); polygon->xcoord = double_vector_alloc( 0 , 0 ); @@ -189,11 +189,11 @@ void geo_polygon_iget_xy(const geo_polygon_type * polygon , int index , double * bool geo_polygon_segment_intersects(const geo_polygon_type * polygon , double x1 , double y1 , double x2 , double y2) { bool intersects = false; - double ** points = util_malloc( 4 * sizeof * points); + double ** points = (double**)util_malloc( 4 * sizeof * points); { int i; for (i = 0; i < 4; i++) - points[i] = util_malloc( 2 * sizeof * points[i]); + points[i] = (double*)util_malloc( 2 * sizeof * points[i]); } points[0][0] = x1; diff --git a/ThirdParty/Ert/lib/geometry/geo_polygon_collection.c b/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp similarity index 86% rename from ThirdParty/Ert/lib/geometry/geo_polygon_collection.c rename to ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp index 269a9032fa..f02ddb1374 100644 --- a/ThirdParty/Ert/lib/geometry/geo_polygon_collection.c +++ b/ThirdParty/Ert/lib/geometry/geo_polygon_collection.cpp @@ -20,13 +20,13 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include +#include +#include @@ -42,7 +42,7 @@ struct geo_polygon_collection_struct { UTIL_IS_INSTANCE_FUNCTION( geo_polygon_collection , GEO_POLYGON_COLLECTION_TYPE_ID) geo_polygon_collection_type * geo_polygon_collection_alloc( ) { - geo_polygon_collection_type * polygons = util_malloc( sizeof * polygons ); + geo_polygon_collection_type * polygons = (geo_polygon_collection_type*)util_malloc( sizeof * polygons ); UTIL_TYPE_ID_INIT( polygons , GEO_POLYGON_COLLECTION_TYPE_ID ); polygons->polygon_list = vector_alloc_new(); polygons->polygon_map = hash_alloc(); @@ -106,10 +106,10 @@ void geo_polygon_collection_free( geo_polygon_collection_type * polygons ) { geo_polygon_type * geo_polygon_collection_iget_polygon(const geo_polygon_collection_type * polygons , int index) { - return vector_iget( polygons->polygon_list , index ); + return (geo_polygon_type*)vector_iget( polygons->polygon_list , index ); } geo_polygon_type * geo_polygon_collection_get_polygon(const geo_polygon_collection_type * polygons , const char * polygon_name) { - return hash_get( polygons->polygon_map , polygon_name ); + return (geo_polygon_type*)hash_get( polygons->polygon_map , polygon_name ); } diff --git a/ThirdParty/Ert/lib/geometry/geo_region.c b/ThirdParty/Ert/lib/geometry/geo_region.cpp similarity index 92% rename from ThirdParty/Ert/lib/geometry/geo_region.c rename to ThirdParty/Ert/lib/geometry/geo_region.cpp index e1def85bec..76a1a1f11a 100644 --- a/ThirdParty/Ert/lib/geometry/geo_region.c +++ b/ThirdParty/Ert/lib/geometry/geo_region.cpp @@ -20,15 +20,15 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include -#include -#include -#include -#include +#include +#include +#include +#include #define GEO_REGION_TYPE_ID 4431973 @@ -47,14 +47,14 @@ struct geo_region_struct { static UTIL_SAFE_CAST_FUNCTION( geo_region , GEO_REGION_TYPE_ID ) geo_region_type * geo_region_alloc( const geo_pointset_type * pointset , bool preselect) { - geo_region_type * region = util_malloc( sizeof * region ); + geo_region_type * region = (geo_region_type*)util_malloc( sizeof * region ); UTIL_TYPE_ID_INIT( region , GEO_REGION_TYPE_ID ); region->pointset = pointset; region->pointset_size = geo_pointset_get_size( pointset ); region->preselect = preselect; region->index_list = int_vector_alloc( 0, 0); - region->active_mask = util_calloc( region->pointset_size , sizeof * region->active_mask ); + region->active_mask = (bool*)util_calloc( region->pointset_size , sizeof * region->active_mask ); geo_region_reset( region ); return region; diff --git a/ThirdParty/Ert/lib/geometry/geo_surface.c b/ThirdParty/Ert/lib/geometry/geo_surface.cpp similarity index 97% rename from ThirdParty/Ert/lib/geometry/geo_surface.c rename to ThirdParty/Ert/lib/geometry/geo_surface.cpp index 7d9b443c77..c3b25e25e4 100644 --- a/ThirdParty/Ert/lib/geometry/geo_surface.c +++ b/ThirdParty/Ert/lib/geometry/geo_surface.cpp @@ -20,11 +20,11 @@ #include #include -#include -#include +#include +#include -#include -#include +#include +#include #define __PI 3.14159265 #define GEO_SURFACE_TYPE_ID 111743 @@ -61,7 +61,7 @@ static void geo_surface_copy_header( const geo_surface_type * src , geo_surface_ } static geo_surface_type * geo_surface_alloc_empty( bool internal_z ) { - geo_surface_type * surface = util_malloc( sizeof * surface ); + geo_surface_type * surface = (geo_surface_type*)util_malloc( sizeof * surface ); UTIL_TYPE_ID_INIT( surface , GEO_SURFACE_TYPE_ID ) surface->pointset = geo_pointset_alloc( internal_z ); return surface; @@ -242,7 +242,7 @@ static bool geo_surface_fload_irap( geo_surface_type * surface , const char * fi double * zcoord = NULL; if (loadz) { - zcoord = util_calloc( surface->nx * surface->ny , sizeof * zcoord ); + zcoord = (double*)util_calloc( surface->nx * surface->ny , sizeof * zcoord ); read_ok = geo_surface_fscanf_zcoord( surface , stream , zcoord ); } diff --git a/ThirdParty/Ert/lib/geometry/geo_util.c b/ThirdParty/Ert/lib/geometry/geo_util.cpp similarity index 98% rename from ThirdParty/Ert/lib/geometry/geo_util.c rename to ThirdParty/Ert/lib/geometry/geo_util.cpp index a0a7a1d077..2dda526704 100644 --- a/ThirdParty/Ert/lib/geometry/geo_util.c +++ b/ThirdParty/Ert/lib/geometry/geo_util.cpp @@ -21,9 +21,9 @@ #include #include -#include +#include -#include +#include #define EPSILON 0.000001 diff --git a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp index d703a71751..68f834428d 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp +++ b/ThirdParty/Ert/lib/include/ert/ecl/EclKW.hpp @@ -26,11 +26,9 @@ #include #include -#include -#include -#include - #include +#include +#include #include namespace ERT { @@ -45,12 +43,27 @@ namespace ERT { template<> struct ecl_type< int > { static const ecl_type_enum type { ECL_INT_TYPE }; }; + template<> struct ecl_type + { static const ecl_type_enum type {ECL_BOOL_TYPE}; }; + template<> struct ecl_type< char* > { static const ecl_type_enum type { ECL_CHAR_TYPE }; }; template<> struct ecl_type< const char* > { static const ecl_type_enum type { ECL_CHAR_TYPE }; }; + /* + Both std::string and char* are mapped to the eight character string type + ECL_CHAR_TYPE. That implies that the variable length string type + ECL_STRING is invisible from this API. + */ + + template<> struct ecl_type< std::string > + { static const ecl_type_enum type { ECL_CHAR_TYPE}; }; + + template<> struct ecl_type + { static const ecl_type_enum type {ECL_CHAR_TYPE}; }; + template class EclKW_ref { public: @@ -98,21 +111,36 @@ namespace ERT { ecl_kw_type* m_kw = nullptr; }; +template<> +inline bool EclKW_ref< bool >::at( size_t i ) const { + return ecl_kw_iget_bool( this->m_kw, i ); +} + + template<> inline const char* EclKW_ref< const char* >::at( size_t i ) const { return ecl_kw_iget_char_ptr( this->m_kw, i ); } +template<> +inline std::string EclKW_ref< std::string >::at( size_t i ) const { + return ecl_kw_iget_char_ptr( this->m_kw, i ); +} + + + /* - The current implementation of "string" storage in the underlying C - ecl_kw structure does not lend itself to easily implement - operator[]. We have therefor explicitly deleted it here. + The current implementation of "string" and "bool" storage in the underlying C + ecl_kw structure does not lend itself to easily implement operator[]. We have + therefore explicitly deleted them here. */ template<> const char*& EclKW_ref< const char* >::operator[]( size_t i ) = delete; +template<> +bool& EclKW_ref::operator[]( size_t i) = delete; template< typename T > class EclKW : public EclKW_ref< T > { @@ -151,6 +179,14 @@ class EclKW : public EclKW_ref< T > { target[ i ] = T( data[ i ] ); } + + std::vector data() const { + const T* ptr = static_cast(ecl_kw_get_ptr(this->m_kw)); + std::vector vector; + vector.assign(ptr, ptr + this->size()); + return vector; + } + static EclKW load( FortIO& fortio ) { ecl_kw_type* c_ptr = ecl_kw_fread_alloc( fortio.get() ); @@ -159,16 +195,87 @@ class EclKW : public EclKW_ref< T > { return EclKW( c_ptr ); } + }; + template<> inline EclKW< const char* >::EclKW( const std::string& kw, const std::vector< const char* >& data ) : EclKW( kw, data.size() ) { auto* ptr = this->get(); - for( size_t i = 0; i < data.size(); ++i ) + for( size_t i = 0; i < data.size(); ++i ) { + if (strlen(data[i]) > 8) + throw std::range_error("Strings must be maximum 8 characters long"); ecl_kw_iset_string8( ptr, i, data[ i ] ); + } +} + +template<> inline +EclKW< std::string >::EclKW( const std::string& kw, + const std::vector< std::string >& data ) : + EclKW( kw, data.size() ) +{ + auto* ptr = this->get(); + for( size_t i = 0; i < data.size(); ++i ) { + if (data[i].size() > 8) + throw std::range_error("Strings must be maximum 8 characters long"); + ecl_kw_iset_string8( ptr, i, data[ i ].c_str() ); + } +} + + +template<> +template<> inline +EclKW< std::string >::EclKW( const std::string& kw, + const std::vector< const char* >& data ) : + EclKW( kw, data.size() ) +{ + auto* ptr = this->get(); + for( size_t i = 0; i < data.size(); ++i) { + if (strlen(data[i]) > 8) + throw std::range_error("Strings must be maximum 8 characters long"); + ecl_kw_iset_string8( ptr, i, data[ i ]); + } +} + +template<> inline +EclKW::EclKW( const std::string& kw, const std::vector< bool >& data ) : + EclKW( kw, data.size() ) +{ + for (size_t i = 0; i < data.size(); i++) + ecl_kw_iset_bool( this->m_kw, i, data[i]); +} + +template<> inline +std::vector EclKW::data() const +{ + std::vector strings; + auto* ptr = this->get(); + for( size_t i = 0; i < this->size(); ++i ) { + std::string s8 = ecl_kw_iget_char_ptr(ptr, i); + s8.erase(s8.find_last_not_of(' ')+1); + strings.push_back( s8 ); + } + return strings; +} + +/* + Will write an ecl_kw instance to the open Fortio file. +*/ +template +void write_kw(FortIO& fortio, const std::string& kw, const std::vector& data) { + EclKW ecl_kw(kw, data); + ecl_kw_fwrite(ecl_kw.get(), fortio.get()); +} + +/* + Will write an empty ecl_kw instance of type 'MESS' to the Fortio file. +*/ +inline void write_mess(FortIO& fortio, const std::string& kw) { + ecl_kw_type * ecl_kw = ecl_kw_alloc(kw.c_str(), 0, ECL_MESS); + ecl_kw_fwrite(ecl_kw, fortio.get()); } } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp new file mode 100644 index 0000000000..4b1a822b03 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_box.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp new file mode 100644 index 0000000000..289c1dd7c4 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_coarse_cell.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp new file mode 100644 index 0000000000..a0b3ac55e9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_endian_flip.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp new file mode 100644 index 0000000000..6fade2adb9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp new file mode 100644 index 0000000000..35352ecfd1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_kw.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp new file mode 100644 index 0000000000..4fbb391a83 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_file_view.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h index c3f78f2029..67c44b9bfb 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.h @@ -18,7 +18,7 @@ #ifndef ERT_ECL_GRAV_H #define ERT_ECL_GRAV_H -#ifdef __plusplus +#ifdef __cplusplus extern "C" { #endif @@ -36,11 +36,12 @@ ecl_grav_type * ecl_grav_alloc( const ecl_grid_type * ecl_grid, const ecl ecl_grav_survey_type * ecl_grav_add_survey_FIP( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); ecl_grav_survey_type * ecl_grav_add_survey_PORMOD( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); ecl_grav_survey_type * ecl_grav_add_survey_RPORV( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); +ecl_grav_survey_type * ecl_grav_add_survey_RFIP( ecl_grav_type * grav , const char * name , const ecl_file_view_type * restart_file ); double ecl_grav_eval( const ecl_grav_type * grav , const char * base, const char * monitor , ecl_region_type * region , double utm_x, double utm_y , double depth, int phase_mask); void ecl_grav_new_std_density( ecl_grav_type * grav , ecl_phase_enum phase , double default_density); void ecl_grav_add_std_density( ecl_grav_type * grav , ecl_phase_enum phase , int pvtnum , double density); -#ifdef __plusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp new file mode 100644 index 0000000000..9dbd0ae404 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp new file mode 100644 index 0000000000..df878a9337 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_calc.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp new file mode 100644 index 0000000000..555ef8dc1c --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grav_common.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h index 3c9cd71060..5ae7b115db 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.h @@ -76,6 +76,7 @@ extern "C" { double ecl_grid_get_cell_dz3( const ecl_grid_type * grid , int i , int j , int k); double ecl_grid_get_cell_thickness3( const ecl_grid_type * grid , int i , int j , int k); + void ecl_grid_get_distance(const ecl_grid_type * grid , int global_index1, int global_index2 , double *dx , double *dy , double *dz); double ecl_grid_get_cdepth1A(const ecl_grid_type * grid , int active_index); double ecl_grid_get_cdepth1(const ecl_grid_type * grid , int global_index); double ecl_grid_get_cdepth3(const ecl_grid_type * grid , int i, int j , int k); @@ -118,6 +119,9 @@ extern "C" { ecl_grid_type * ecl_grid_alloc_regular( int nx, int ny , int nz , const double * ivec, const double * jvec , const double * kvec , const int * actnum); ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const int * actnum); ecl_grid_type * ecl_grid_alloc_dxv_dyv_dzv_depthz( int nx, int ny , int nz , const double * dxv , const double * dyv , const double * dzv , const double * depthz , const int * actnum); + ecl_kw_type * ecl_grid_alloc_volume_kw( const ecl_grid_type * grid , bool active_size); + ecl_kw_type * ecl_grid_alloc_mapaxes_kw( const ecl_grid_type * grid ); + ecl_kw_type * ecl_grid_alloc_coord_kw( const ecl_grid_type * grid); bool ecl_grid_exists( const char * case_input ); char * ecl_grid_alloc_case_filename( const char * case_input ); @@ -254,6 +258,7 @@ extern "C" { void ecl_grid_reset_actnum( ecl_grid_type * grid , const int * actnum ); void ecl_grid_compressed_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw); void ecl_grid_global_kw_copy( const ecl_grid_type * grid , ecl_kw_type * target_kw , const ecl_kw_type * src_kw); + void ecl_grid_export_cell_corners1(const ecl_grid_type * grid, int global_index, double *x, double *y, double *z); UTIL_IS_INSTANCE_HEADER( ecl_grid ); UTIL_SAFE_CAST_HEADER( ecl_grid ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp new file mode 100644 index 0000000000..a27e4887ee --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp new file mode 100644 index 0000000000..32ca2236ef --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_cache.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp new file mode 100644 index 0000000000..d32e7d5d77 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_grid_dims.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp new file mode 100644 index 0000000000..ef37a89689 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_init_file.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h index 6792346101..c33f01274b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.h @@ -18,6 +18,9 @@ #ifndef ERT_ECL_IO_CONFIG_H #define ERT_ECL_IO_CONFIG_H +#ifdef __cplusplus +extern "C" { +#endif typedef struct ecl_io_config_struct ecl_io_config_type; @@ -38,4 +41,7 @@ bool ecl_io_config_get_unified_summary(ecl_io_config_type *); ecl_io_config_type * ecl_io_config_alloc(bool ,bool ,bool); void ecl_io_config_free(ecl_io_config_type * ); +#ifdef __cplusplus +} +#endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp new file mode 100644 index 0000000000..fdbe583b39 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_io_config.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h index 60d3561b3e..21b22bd385 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.h @@ -72,7 +72,6 @@ extern "C" { void ecl_kw_fwrite_data(const ecl_kw_type *_ecl_kw , fortio_type *fortio); bool ecl_kw_fread_realloc_data(ecl_kw_type *ecl_kw, fortio_type *fortio); ecl_data_type ecl_kw_get_data_type(const ecl_kw_type *); - size_t ecl_kw_get_sizeof_ctype(const ecl_kw_type *); const char * ecl_kw_get_header8(const ecl_kw_type *); const char * ecl_kw_get_header(const ecl_kw_type * ecl_kw ); ecl_kw_type * ecl_kw_alloc_empty(void); @@ -88,6 +87,7 @@ extern "C" { bool ecl_kw_fread_realloc(ecl_kw_type *, fortio_type *); void ecl_kw_fread(ecl_kw_type * , fortio_type * ); ecl_kw_type * ecl_kw_fread_alloc(fortio_type *); + ecl_kw_type * ecl_kw_alloc_actnum(const ecl_kw_type * porv_kw, float porv_limit); void ecl_kw_free_data(ecl_kw_type *); void ecl_kw_fread_indexed_data(fortio_type * fortio, offset_type data_offset, ecl_data_type, int element_count, const int_vector_type* index_map, char* buffer); void ecl_kw_free(ecl_kw_type *); @@ -119,6 +119,7 @@ extern "C" { ecl_kw_type * ecl_kw_alloc( const char * header , int size , ecl_data_type ); ecl_kw_type * ecl_kw_alloc_new(const char * , int , ecl_data_type , const void * ); ecl_kw_type * ecl_kw_alloc_new_shared(const char * , int , ecl_data_type , void * ); + ecl_kw_type * ecl_kw_alloc_global_copy(const ecl_kw_type * src, const ecl_kw_type * actnum); void ecl_kw_fwrite_param(const char * , bool , const char * , ecl_data_type , int , void * ); void ecl_kw_fwrite_param_fortio(fortio_type *, const char * , ecl_data_type , int , void * ); void ecl_kw_summarize(const ecl_kw_type * ecl_kw); @@ -140,6 +141,9 @@ extern "C" { bool ecl_kw_fskip_data(ecl_kw_type *ecl_kw, fortio_type *fortio); bool ecl_kw_fread_data(ecl_kw_type *ecl_kw, fortio_type *fortio); void ecl_kw_fskip_header( fortio_type * fortio); + bool ecl_kw_size_and_numeric_type_equal( const ecl_kw_type * kw1, const ecl_kw_type * kw2); + bool ecl_kw_inplace_safe_div(ecl_kw_type * target_kw, const ecl_kw_type * divisor); + void ecl_kw_inplace_sqrt( ecl_kw_type * kw ); bool ecl_kw_is_kw_file(fortio_type * fortio); @@ -174,6 +178,7 @@ extern "C" { ecl_kw_type * ecl_kw_alloc_scatter_copy( const ecl_kw_type * src_kw , int target_size , const int * mapping, void * def_value); + void ecl_kw_inplace_add_squared(ecl_kw_type * target_kw, const ecl_kw_type * add_kw); void ecl_kw_inplace_add( ecl_kw_type * target_kw , const ecl_kw_type * add_kw); void ecl_kw_inplace_sub( ecl_kw_type * target_kw , const ecl_kw_type * sub_kw); void ecl_kw_inplace_div( ecl_kw_type * target_kw , const ecl_kw_type * div_kw); @@ -262,6 +267,8 @@ extern "C" { void ecl_kw_fix_uninitialized(ecl_kw_type * ecl_kw , int nx , int ny , int nz, const int * actnum); + ecl_type_enum ecl_kw_get_type(const ecl_kw_type *); + #include #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp new file mode 100644 index 0000000000..f4ed8bfb4a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/ecl/ecl_sum_file.c b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp similarity index 69% rename from ThirdParty/Ert/lib/ecl/ecl_sum_file.c rename to ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp index 0d9a033d8c..eb27171f48 100644 --- a/ThirdParty/Ert/lib/ecl/ecl_sum_file.c +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_grdecl.hpp @@ -1,7 +1,7 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. + Copyright (C) 2018 Statoil ASA, Norway. - The file 'ecl_sum_file.c' is part of ERT - Ensemble based Reservoir Tool. + This file is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,12 +16,5 @@ for more details. */ -#include -#include -#include -#include - -struct ecl_sum_struct { - -}; +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h index 71d31dc402..8c0f50db65 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.h @@ -303,7 +303,9 @@ values (2e20) are denoted with '*'. #define INTEHEAD_TIMESTEP_INDEX 67 #define INTEHEAD_REPORT_STEP 68 #define INTEHEAD_IPROG_INDEX 94 -#define INTEHEAD_REPORT_INDEX 219 (report_steps-1) + +// The value seems to be: report_step - 1; might be previous? +#define INTEHEAD_REPORT_INDEX 219 #define INTEHEAD_METRIC_VALUE 1 @@ -339,6 +341,7 @@ values (2e20) are denoted with '*'. #define LOGIHEAD_REV_ENDPOINT_SCALING_INDEX 18 #define LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX 19 #define LOGIHEAD_MISC_DISPLACEMENT_INDEX 35 +#define LOGIHEAD_CONSTANT_OILCOMPR_INDEX (39-1) /* Constant oil compressibility (PVCDO)? */ #define LOGIHEAD_SCALE_WATER_PC_AT_MAX_SAT_INDEX 55 #define LOGIHEAD_SCALE_GAS_PC_AT_MAX_SAT_INDEX 56 @@ -450,12 +453,16 @@ values (2e20) are denoted with '*'. keyword in the SMSPEC files. Observe that these magic indices differ from the magic indices used to look up grid dimensions from the DIMENS keyword in GRID files. */ -#define DIMENS_SMSPEC_SIZE_INDEX 0 -#define DIMENS_SMSPEC_NX_INDEX 1 -#define DIMENS_SMSPEC_NY_INDEX 2 -#define DIMENS_SMSPEC_NZ_INDEX 3 - -#define DIMENS_SIZE 6 // Do not know what the two last items are? +#define DIMENS_SMSPEC_SIZE_INDEX 0 +#define DIMENS_SMSPEC_NX_INDEX 1 +#define DIMENS_SMSPEC_NY_INDEX 2 +#define DIMENS_SMSPEC_NZ_INDEX 3 +#define DIMENS_SMSPEC_RESTART_STEP_INDEX 5 +#define DIMENS_SIZE 6 + +#define INTEHEAD_SMSPEC_SIZE 2 +#define INTEHEAD_SMSPEC_UNIT_INDEX 0 +#define INTEHEAD_SMSPEC_IPROG_INDEX 1 /* Summary data files: */ diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp new file mode 100644 index 0000000000..d7cfba7c96 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_kw_magic.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp new file mode 100644 index 0000000000..5cca194e38 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_data.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp new file mode 100644 index 0000000000..e2d16c2eb3 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_export.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp new file mode 100644 index 0000000000..8c9f3c9ab7 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_nnc_geometry.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h index 87be80a3a0..9ad8e40310 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.h @@ -70,10 +70,13 @@ typedef struct ecl_region_struct ecl_region_type; bool ecl_region_contains_global( const ecl_region_type * ecl_region , int global_index); bool ecl_region_contains_active( const ecl_region_type * ecl_region , int active_index); + void ecl_region_select_true( ecl_region_type * region , const ecl_kw_type * ecl_kw); void ecl_region_invert_selection( ecl_region_type * region ); void ecl_region_select_all( ecl_region_type * region); void ecl_region_deselect_all( ecl_region_type * region ); + void ecl_region_deselect_true( ecl_region_type * region , const ecl_kw_type * ecl_kw); + void ecl_region_select_false( ecl_region_type * region , const ecl_kw_type * ecl_kw); void ecl_region_select_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value); void ecl_region_deselect_in_interval( ecl_region_type * region , const ecl_kw_type * ecl_kw, float min_value , float max_value); @@ -152,6 +155,7 @@ typedef struct ecl_region_struct ecl_region_type; void ecl_region_select_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value); void ecl_region_deselect_from_layer( ecl_region_type * region , const layer_type * layer , int k , int layer_value); + void ecl_region_deselect_false( ecl_region_type * region , const ecl_kw_type * ecl_kw); /*****************************************************************/ @@ -170,6 +174,16 @@ typedef struct ecl_region_struct ecl_region_type; bool ecl_region_equal( const ecl_region_type * region1 , const ecl_region_type * region2); + void ecl_region_scale_kw_float( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , float value , bool force_active); + void ecl_region_scale_kw_double( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , double value , bool force_active); + void ecl_region_scale_kw_int( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , int value , bool force_active); + void ecl_region_shift_kw_int( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , int value , bool force_active); + void ecl_region_shift_kw_double( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , double value , bool force_active); + void ecl_region_shift_kw_float( ecl_region_type * ecl_region , ecl_kw_type * ecl_kw , float value , bool force_active); + + const int_vector_type * ecl_region_get_kw_index_list( ecl_region_type * ecl_region , const ecl_kw_type * ecl_kw , bool force_active); + + /*****************************************************************/ /* set/get the name */ void ecl_region_set_name( ecl_region_type * region , const char * name ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp new file mode 100644 index 0000000000..d51112ae82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_region.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp new file mode 100644 index 0000000000..65ba3f48fc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_cell.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp new file mode 100644 index 0000000000..3545ee0d42 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_file.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h index 8faef7cda0..b7f6418cbd 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.h @@ -67,6 +67,8 @@ int ecl_rft_node_cmp( const ecl_rft_node_type * n1 , const ecl_rft_node_type * n void ecl_rft_node_append_cell( ecl_rft_node_type * rft_node , ecl_rft_cell_type * cell); ecl_rft_node_type * ecl_rft_node_alloc_new(const char * well_name, const char * data_type_string, const time_t recording_date, const double days); +ecl_rft_enum ecl_rft_node_get_type(const ecl_rft_node_type * rft_node); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp new file mode 100644 index 0000000000..623405e7d0 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rft_node.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp new file mode 100644 index 0000000000..9ecc8a91e1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rst_file.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h index 28aa0dbaee..cf58ec3e53 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.h @@ -95,6 +95,8 @@ extern "C" { double ecl_rsthead_get_sim_days( const ecl_rsthead_type * header ); int ecl_rsthead_get_report_step( const ecl_rsthead_type * header ); time_t ecl_rsthead_get_sim_time( const ecl_rsthead_type * header ); + int ecl_rsthead_get_nxconz( const ecl_rsthead_type * rsthead ); + int ecl_rsthead_get_ncwmax( const ecl_rsthead_type * rsthead ); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp new file mode 100644 index 0000000000..44550950a1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_rsthead.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h index 1afed73c7d..f42e5c338b 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.h @@ -29,6 +29,7 @@ extern "C" { #include #include +#include #include typedef struct ecl_smspec_struct ecl_smspec_type; @@ -54,7 +55,11 @@ typedef struct ecl_smspec_struct ecl_smspec_type; bool ecl_smspec_needs_wgname( ecl_smspec_var_type var_type ); const char * ecl_smspec_get_var_type_name( ecl_smspec_var_type var_type ); ecl_smspec_var_type ecl_smspec_identify_var_type(const char * var); - ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , const char * restart_case, time_t sim_start , bool time_in_days , int nx , int ny , int nz); + ecl_smspec_type * ecl_smspec_alloc_empty(bool write_mode , const char * key_join_string); + + ecl_smspec_type * ecl_smspec_alloc_restart_writer( const char * key_join_string , const char * restart_case, int restart_step, time_t sim_start , bool time_in_days , int nx , int ny , int nz); + + ecl_smspec_type * ecl_smspec_alloc_writer( const char * key_join_string , time_t sim_start , bool time_in_days , int nx , int ny , int nz); void ecl_smspec_fwrite( const ecl_smspec_type * smspec , const char * ecl_case , bool fmt_file ); ecl_smspec_type * ecl_smspec_fread_alloc(const char *header_file, const char * key_join_string , bool include_restart); @@ -128,6 +133,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; stringlist_type * ecl_smspec_alloc_group_list( const ecl_smspec_type * smspec , const char * pattern); stringlist_type * ecl_smspec_alloc_well_var_list( const ecl_smspec_type * smspec ); const char * ecl_smspec_get_simulation_path(const ecl_smspec_type * ecl_smspec); + int ecl_smspec_get_restart_step(const ecl_smspec_type * ecl_smspec); const char * ecl_smspec_get_restart_case( const ecl_smspec_type * ecl_smspec); const char * ecl_smspec_get_join_string( const ecl_smspec_type * smspec); const float_vector_type * ecl_smspec_get_params_default( const ecl_smspec_type * ecl_smspec ); @@ -144,6 +150,7 @@ typedef struct ecl_smspec_struct ecl_smspec_type; bool ecl_smspec_equal( const ecl_smspec_type * self , const ecl_smspec_type * other); void ecl_smspec_sort( ecl_smspec_type * smspec ); + ert_ecl_unit_enum ecl_smspec_get_unit_system(const ecl_smspec_type * smspec); #ifdef __cplusplus } diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp new file mode 100644 index 0000000000..7f59f6a7fe --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_smspec.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h index 7da533e338..71d0747a1f 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.h @@ -19,7 +19,7 @@ #ifndef ERT_ECL_SUBSIDENCE_H #define ERT_ECL_SUBSIDENCE_H -#ifdef __plusplus +#ifdef __cplusplus extern "C" { #endif @@ -43,8 +43,12 @@ extern "C" { ecl_region_type * region , double utm_x, double utm_y , double depth, double compressibility, double poisson_ratio); + double ecl_subsidence_eval_geertsma( const ecl_subsidence_type * subsidence , const char * base, const char * monitor , ecl_region_type * region , + double utm_x, double utm_y , double depth, + double youngs_modulus, double poisson_ratio, double seabed); -#ifdef __plusplus + +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp new file mode 100644 index 0000000000..a8b535ef8a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_subsidence.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h index 60080768bc..780add6010 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.h @@ -30,13 +30,11 @@ extern "C" { #include #include #include -#include #include #include #include - typedef struct { char * locale; const char * sep; @@ -54,6 +52,8 @@ extern "C" { /*****************************************************************/ + /* This is a forward declaration. */ +typedef struct ecl_sum_vector_struct ecl_sum_vector_type; typedef struct ecl_sum_struct ecl_sum_type; @@ -94,6 +94,7 @@ typedef struct ecl_sum_struct ecl_sum_type; ecl_sum_type * ecl_sum_fread_alloc(const char * , const stringlist_type * data_files, const char * key_join_string, bool include_restart); ecl_sum_type * ecl_sum_fread_alloc_case(const char * , const char * key_join_string); ecl_sum_type * ecl_sum_fread_alloc_case__(const char * , const char * key_join_string , bool include_restart); + ecl_sum_type * ecl_sum_alloc_resample(const ecl_sum_type * ecl_sum, const char * ecl_case, const time_t_vector_type * times); bool ecl_sum_case_exists( const char * input_file ); /* Accessor functions : */ @@ -136,6 +137,8 @@ typedef struct ecl_sum_struct ecl_sum_type; double ecl_sum_get_general_var_from_sim_days( const ecl_sum_type * ecl_sum , double sim_days , const char * var); double ecl_sum_get_general_var_from_sim_time( const ecl_sum_type * ecl_sum , time_t sim_time , const char * var); const char * ecl_sum_get_general_var_unit( const ecl_sum_type * ecl_sum , const char * var); + ert_ecl_unit_enum ecl_sum_get_unit_system(const ecl_sum_type * ecl_sum); + /***************/ void ecl_sum_fprintf(const ecl_sum_type * , FILE * , const stringlist_type * , bool report_only , const ecl_sum_fmt_type * fmt); @@ -143,6 +146,7 @@ typedef struct ecl_sum_struct ecl_sum_type; /* Time related functions */ + int ecl_sum_get_restart_step(const ecl_sum_type * ecl_sum); int ecl_sum_get_first_gt( const ecl_sum_type * ecl_sum , int param_index , double limit); int ecl_sum_get_first_lt( const ecl_sum_type * ecl_sum , int param_index , double limit); int ecl_sum_get_last_report_step( const ecl_sum_type * ecl_sum ); @@ -165,11 +169,11 @@ typedef struct ecl_sum_struct ecl_sum_type; time_t ecl_sum_get_data_start( const ecl_sum_type * ecl_sum ); time_t ecl_sum_get_end_time( const ecl_sum_type * ecl_sum); time_t ecl_sum_get_start_time(const ecl_sum_type * ); - const time_interval_type * ecl_sum_get_sim_time( const ecl_sum_type * ecl_sum); const char * ecl_sum_get_base(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_path(const ecl_sum_type * ecl_sum ); const char * ecl_sum_get_abs_path(const ecl_sum_type * ecl_sum ); + const ecl_sum_type * ecl_sum_get_restart_case(const ecl_sum_type * ecl_sum); const char * ecl_sum_get_case(const ecl_sum_type * ); bool ecl_sum_same_case( const ecl_sum_type * ecl_sum , const char * input_file ); @@ -200,6 +204,18 @@ typedef struct ecl_sum_struct ecl_sum_type; int ecl_sum_iget_report_end( const ecl_sum_type * ecl_sum , int report_step ); int ecl_sum_iget_report_start( const ecl_sum_type * ecl_sum , int report_step ); + ecl_sum_type * ecl_sum_alloc_restart_writer2( const char * ecl_case, + const char * restart_case, + int restart_step, + bool fmt_output, + bool unified, + const char * key_join_string, + time_t sim_start, + bool time_in_days, + int nx, + int ny, + int nz); + void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * input_arg); ecl_sum_type * ecl_sum_alloc_restart_writer(const char * ecl_case , const char * restart_case , @@ -218,9 +234,9 @@ typedef struct ecl_sum_struct ecl_sum_type; time_t sim_start , bool time_in_days , int nx , int ny , int nz); - void ecl_sum_set_case( ecl_sum_type * ecl_sum , const char * ecl_case); void ecl_sum_fwrite( const ecl_sum_type * ecl_sum ); void ecl_sum_fwrite_smspec( const ecl_sum_type * ecl_sum ); + smspec_node_type * ecl_sum_add_smspec_node(ecl_sum_type * ecl_sum, const smspec_node_type * node); smspec_node_type * ecl_sum_add_var(ecl_sum_type * ecl_sum , const char * keyword , const char * wgname , @@ -253,6 +269,18 @@ typedef struct ecl_sum_struct ecl_sum_type; double_vector_type * ecl_sum_alloc_days_solution( const ecl_sum_type * ecl_sum , const char * gen_key , double cmp_value , bool rates_clamp_lower); time_t_vector_type * ecl_sum_alloc_time_solution( const ecl_sum_type * ecl_sum , const char * gen_key , double cmp_value , bool rates_clamp_lower); + double ecl_sum_iget_last_value(const ecl_sum_type * ecl_sum, int param_index); + double ecl_sum_get_last_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key); + double ecl_sum_get_last_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node); + double ecl_sum_iget_first_value(const ecl_sum_type * ecl_sum, int param_index); + double ecl_sum_get_first_value_gen_key(const ecl_sum_type * ecl_sum, const char * gen_key); + double ecl_sum_get_first_value_node(const ecl_sum_type * ecl_sum, const smspec_node_type *node); + + void ecl_sum_init_datetime64_vector(const ecl_sum_type * ecl_sum, int64_t * data, int multiplier); + void ecl_sum_init_double_vector_interp(const ecl_sum_type * ecl_sum, const char * gen_key, const time_t_vector_type * time_points, double * data); + void ecl_sum_init_double_vector(const ecl_sum_type * ecl_sum, const char * gen_key, double * data); + void ecl_sum_init_double_frame(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, double * data); + void ecl_sum_init_double_frame_interp(const ecl_sum_type * ecl_sum, const ecl_sum_vector_type * keywords, const time_t_vector_type * time_points, double * data); UTIL_IS_INSTANCE_HEADER( ecl_sum ); #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp new file mode 100644 index 0000000000..7370f32e97 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h index df2caa42a7..929c1114a6 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.h @@ -24,12 +24,12 @@ extern "C" { #endif #include +#include #include #include #include #include -#include #include #include @@ -41,7 +41,6 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_fwrite_step( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified, int report_step); void ecl_sum_data_fwrite( const ecl_sum_data_type * data , const char * ecl_case , bool fmt_case , bool unified); bool ecl_sum_data_fread( ecl_sum_data_type * data , const stringlist_type * filelist); - void ecl_sum_data_fread_restart( ecl_sum_data_type * data , const stringlist_type * filelist); ecl_sum_data_type * ecl_sum_data_alloc_writer( ecl_smspec_type * smspec ); ecl_sum_data_type * ecl_sum_data_alloc( ecl_smspec_type * smspec); double ecl_sum_data_time2days( const ecl_sum_data_type * data , time_t sim_time); @@ -57,7 +56,6 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; time_t ecl_sum_data_get_data_start( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_report_time( const ecl_sum_data_type * data , int report_step); double ecl_sum_data_get_first_day( const ecl_sum_data_type * data); - const time_interval_type * ecl_sum_data_get_sim_time( const ecl_sum_data_type * data); time_t ecl_sum_data_get_sim_start ( const ecl_sum_data_type * data ); time_t ecl_sum_data_get_sim_end ( const ecl_sum_data_type * data ); double ecl_sum_data_get_sim_length( const ecl_sum_data_type * data ); @@ -74,8 +72,6 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; void ecl_sum_data_free( ecl_sum_data_type * ); int ecl_sum_data_get_last_report_step( const ecl_sum_data_type * data ); int ecl_sum_data_get_first_report_step( const ecl_sum_data_type * data ); - int ecl_sum_data_get_first_ministep( const ecl_sum_data_type * data ); - int ecl_sum_data_get_last_ministep( const ecl_sum_data_type * data ); double ecl_sum_data_get_from_sim_time( const ecl_sum_data_type * data , time_t sim_time , const smspec_node_type * smspec_node); double ecl_sum_data_get_from_sim_days( const ecl_sum_data_type * data , double sim_days , const smspec_node_type * smspec_node); @@ -91,8 +87,23 @@ typedef struct ecl_sum_data_struct ecl_sum_data_type ; bool ecl_sum_data_report_step_equal( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2); bool ecl_sum_data_report_step_compatible( const ecl_sum_data_type * data1 , const ecl_sum_data_type * data2); void ecl_sum_data_fwrite_interp_csv_line(const ecl_sum_data_type * data , time_t sim_time, const ecl_sum_vector_type * keylist, FILE *fp); - - double_vector_type * ecl_sum_data_alloc_seconds_solution( const ecl_sum_data_type * data , const smspec_node_type * node , double value, bool rates_clamp_lower); + double ecl_sum_data_get_last_value(const ecl_sum_data_type * data, int param_index); + double ecl_sum_data_iget_last_value(const ecl_sum_data_type * data, int param_index); + double ecl_sum_data_iget_first_value(const ecl_sum_data_type * data, int param_index); + void ecl_sum_data_init_double_vector(const ecl_sum_data_type * data, int params_index, double * output_data); + void ecl_sum_data_init_datetime64_vector(const ecl_sum_data_type * data, int64_t * output_data, int multiplier); + + void ecl_sum_data_init_double_frame(const ecl_sum_data_type * data, const ecl_sum_vector_type * keywords, double *output_data); + double_vector_type * ecl_sum_data_alloc_seconds_solution( const ecl_sum_data_type * data , const smspec_node_type * node , double value, bool rates_clamp_lower); + void ecl_sum_data_init_double_frame_interp(const ecl_sum_data_type * data, + const ecl_sum_vector_type * keywords, + const time_t_vector_type * time_points, + double * output_data); + + void ecl_sum_data_init_double_vector_interp(const ecl_sum_data_type * data, + const smspec_node_type * smspec_node, + const time_t_vector_type * time_points, + double * output_data); #ifdef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp new file mode 100644 index 0000000000..9d54a02f6c --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_data.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp new file mode 100644 index 0000000000..1317fbf5a4 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_index.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp new file mode 100644 index 0000000000..5350247752 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_tstep.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h index d460a23129..6994160437 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.h @@ -30,14 +30,19 @@ extern "C" { typedef struct ecl_sum_vector_struct ecl_sum_vector_type; void ecl_sum_vector_free( ecl_sum_vector_type * keylist ); - ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum); + ecl_sum_vector_type * ecl_sum_vector_alloc(const ecl_sum_type * ecl_sum, bool add_keywords); bool ecl_sum_vector_add_key( ecl_sum_vector_type * keylist, const char * key); void ecl_sum_vector_add_keys( ecl_sum_vector_type * keylist, const char * pattern); + const char* ecl_sum_vector_iget_key(const ecl_sum_vector_type * ecl_sum_vector, int index); bool ecl_sum_vector_iget_is_rate(const ecl_sum_vector_type * ecl_sum_vector, int index); int ecl_sum_vector_iget_param_index(const ecl_sum_vector_type * ecl_sum_vector, int index); int ecl_sum_vector_get_size(const ecl_sum_vector_type * ecl_sum_vector); + bool ecl_sum_vector_iget_valid(const ecl_sum_vector_type * ecl_sum_vector, int index); + + ecl_sum_vector_type * ecl_sum_vector_alloc_layout_copy(const ecl_sum_vector_type * src_vector, const ecl_sum_type * ecl_sum); + UTIL_IS_INSTANCE_HEADER( ecl_sum_vector); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp new file mode 100644 index 0000000000..8b06dae566 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_sum_vector.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h index 4848e34dc7..a218330974 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.h @@ -59,7 +59,6 @@ typedef enum { {.value = 5 , .name = "ECL_MESS_TYPE"}, \ {.value = 7 , .name = "ECL_STRING_TYPE"} -#define ECL_TYPE_ENUM_SIZE 7 /* Character data in ECLIPSE files comes as an array of fixed-length @@ -68,7 +67,6 @@ typedef enum { */ #define ECL_STRING8_LENGTH 8 // 'Normal' 8 characters 'CHAR' type. -#define ECL_STRING10_LENGTH 10 // 'Normal' 8 characters 'CHAR' type. #define ECL_TYPE_LENGTH 4 struct ecl_type_struct { @@ -81,7 +79,7 @@ struct ecl_type_struct { #define ECL_INT ecl_data_type{ ECL_INT_TYPE, sizeof(int)} #define ECL_FLOAT ecl_data_type{ ECL_FLOAT_TYPE, sizeof(float)} #define ECL_DOUBLE ecl_data_type{ ECL_DOUBLE_TYPE, sizeof(double)} -#define ECL_BOOL ecl_data_type{ ECL_BOOL_TYPE, sizeof(int)} +#define ECL_BOOL ecl_data_type{ ECL_BOOL_TYPE, sizeof(bool)} #define ECL_CHAR ecl_data_type{ ECL_CHAR_TYPE, ECL_STRING8_LENGTH + 1} #define ECL_MESS ecl_data_type{ ECL_MESS_TYPE, 0} #define ECL_STRING(size) ecl_data_type{ECL_STRING_TYPE, (size) + 1} @@ -94,7 +92,7 @@ struct ecl_type_struct { #define ECL_INT (ecl_data_type) {.type = ECL_INT_TYPE, .element_size = sizeof(int)} #define ECL_FLOAT (ecl_data_type) {.type = ECL_FLOAT_TYPE, .element_size = sizeof(float)} #define ECL_DOUBLE (ecl_data_type) {.type = ECL_DOUBLE_TYPE, .element_size = sizeof(double)} -#define ECL_BOOL (ecl_data_type) {.type = ECL_BOOL_TYPE, .element_size = sizeof(int)} +#define ECL_BOOL (ecl_data_type) {.type = ECL_BOOL_TYPE, .element_size = sizeof(bool)} #define ECL_MESS (ecl_data_type) {.type = ECL_MESS_TYPE, .element_size = 0} #define ECL_STRING(size) (ecl_data_type) {.type = ECL_STRING_TYPE, .element_size = (size) + 1} @@ -114,7 +112,7 @@ ecl_type_enum ecl_type_get_type(const ecl_data_type); char * ecl_type_alloc_name(const ecl_data_type); int ecl_type_get_sizeof_ctype(const ecl_data_type); -int ecl_type_get_sizeof_ctype_fortio(const ecl_data_type); +int ecl_type_get_sizeof_iotype(const ecl_data_type); bool ecl_type_is_equal(const ecl_data_type, const ecl_data_type); @@ -129,8 +127,8 @@ bool ecl_type_is_bool(const ecl_data_type); bool ecl_type_is_string(const ecl_data_type); // Temporary fixup for OPM. -char * ecl_type_get_name(const ecl_data_type); - +char * ecl_type_get_name(const ecl_data_type); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp new file mode 100644 index 0000000000..982417c0ea --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_type.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp new file mode 100644 index 0000000000..09fd7dbafa --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_units.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h index 67cca9cde2..7dea54f480 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.h @@ -96,7 +96,6 @@ typedef enum { #define ECL_PHASE_ENUM_DEFS {.value = 1 , .name = "ECL_OIL_PHASE"}, {.value = 2 , .name = "ECL_GAS_PHASE"} , {.value = 4 , .name = "ECL_WATER_PHASE"} #define ECL_PHASE_ENUM_SIZE 3 - typedef enum { ECL_METRIC_UNITS = 1, ECL_FIELD_UNITS = 2, @@ -118,8 +117,8 @@ bool ecl_util_unified_file(const char *filename); const char * ecl_util_file_type_name( ecl_file_enum file_type ); char * ecl_util_alloc_base_guess(const char *); int ecl_util_filename_report_nr(const char *); -ecl_file_enum ecl_util_get_file_type(const char * , bool * , int * ); ecl_file_enum ecl_util_inspect_extension(const char * ext , bool *_fmt_file, int * _report_nr); +ecl_file_enum ecl_util_get_file_type(const char * filename, bool * fmt_file, int * report_nr); char * ecl_util_alloc_filename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/); char * ecl_util_alloc_exfilename(const char * /* path */, const char * /* base */, ecl_file_enum , bool /* fmt_file */ , int /*report_nr*/); void ecl_util_memcpy_typed_data(void *, const void * , ecl_data_type , ecl_data_type , int ); @@ -145,7 +144,7 @@ int ecl_util_select_filelist( const char * path , const char * base void ecl_util_append_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date , bool force_append_end); void ecl_util_init_month_range( time_t_vector_type * date_list , time_t start_date , time_t end_date); void ecl_util_set_date_values(time_t t , int * mday , int * month , int * year); - +bool ecl_util_path_access(const char * ecl_case); #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp new file mode 100644 index 0000000000..6118488a7e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/ecl_util.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp b/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp new file mode 100644 index 0000000000..901d2167b2 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/fault_block.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp new file mode 100644 index 0000000000..d2266cd641 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/fault_block_layer.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp b/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp new file mode 100644 index 0000000000..215e1daf11 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/grid_dims.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/layer.h b/ThirdParty/Ert/lib/include/ert/ecl/layer.h index bf9dfcf58d..f1aacf1135 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl/layer.h +++ b/ThirdParty/Ert/lib/include/ert/ecl/layer.h @@ -76,6 +76,9 @@ extern "C" { void layer_add_barrier( layer_type * layer , int c1 , int c2); void layer_memcpy(layer_type * target_layer , const layer_type * src_layer); void layer_update_active( layer_type * layer , const ecl_grid_type * grid , int k); + void layer_clear_cells( layer_type * layer); + void layer_update_connected_cells( layer_type * layer , int i , int j , int org_value , int new_value); + void layer_assign( layer_type * layer, int value); void layer_cells_equal( const layer_type * layer , int value , int_vector_type * i_list , int_vector_type * j_list); int layer_count_equal( const layer_type * layer , int value ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp new file mode 100644 index 0000000000..97de3b6bcc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/layer.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp new file mode 100644 index 0000000000..93b5b155e1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/nnc_info.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp b/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp new file mode 100644 index 0000000000..c2194dcd82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/nnc_vector.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp new file mode 100644 index 0000000000..0a6f2f7f18 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl/smspec_node.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp new file mode 100644 index 0000000000..3815a62422 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_branch_collection.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp new file mode 100644 index 0000000000..98459f44e6 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp new file mode 100644 index 0000000000..bbbecd3e6e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_conn_collection.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp new file mode 100644 index 0000000000..9daefcf46f --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_const.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp new file mode 100644 index 0000000000..df5625079d --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_info.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp new file mode 100644 index 0000000000..3fbdb9a8e3 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_rseg_loader.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp new file mode 100644 index 0000000000..1a423cf493 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp new file mode 100644 index 0000000000..f15cf65a7e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_segment_collection.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h index 163b4cecb8..aa9427c858 100644 --- a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.h @@ -97,6 +97,10 @@ extern "C" { double well_state_get_gas_rate( const well_state_type * well_state ); double well_state_get_water_rate( const well_state_type * well_state); double well_state_get_volume_rate( const well_state_type * well_state); + double well_state_get_water_rate_si( const well_state_type * well_state); + double well_state_get_oil_rate_si( const well_state_type * well_state ); + double well_state_get_volume_rate_si( const well_state_type * well_state); + double well_state_get_gas_rate_si( const well_state_type * well_state ); UTIL_IS_INSTANCE_HEADER( well_state ); diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp new file mode 100644 index 0000000000..4166742c82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_state.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp b/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp new file mode 100644 index 0000000000..9f4463d1c7 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/ecl_well/well_ts.hpp @@ -0,0 +1,20 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + + +#include diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp new file mode 100644 index 0000000000..a1f54f309d --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_pointset.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp new file mode 100644 index 0000000000..47a0198653 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp new file mode 100644 index 0000000000..0b956ad4b8 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_polygon_collection.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp new file mode 100644 index 0000000000..aca4548a42 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_region.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h index a6707372a0..0e6dd12801 100644 --- a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.h @@ -46,6 +46,16 @@ extern "C" { int geo_surface_get_ny( const geo_surface_type * surface ); void geo_surface_iget_xy( const geo_surface_type* surface, int index, double* x, double* y); + void geo_surface_shift( const geo_surface_type * src , double value); + void geo_surface_scale( const geo_surface_type * src , double value); + void geo_surface_isub( geo_surface_type * self , const geo_surface_type * other); + void geo_surface_iset_zvalue(geo_surface_type * surface, int index , double value); + void geo_surface_assign_value( const geo_surface_type * src , double value); + geo_surface_type * geo_surface_alloc_copy( const geo_surface_type * src , bool copy_zdata); + void geo_surface_iadd( geo_surface_type * self , const geo_surface_type * other); + void geo_surface_imul( geo_surface_type * self , const geo_surface_type * other); + void geo_surface_isqrt( geo_surface_type * surface ); + #ifdef __cplusplus } #endif diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp new file mode 100644 index 0000000000..f4030b6ca1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_surface.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp b/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp new file mode 100644 index 0000000000..b0b3bf1e52 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/geometry/geo_util.hpp @@ -0,0 +1,19 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This file is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include diff --git a/ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp b/ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp deleted file mode 100644 index 0fc46cd011..0000000000 --- a/ThirdParty/Ert/lib/include/ert/nexus/nexus_plot.hpp +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus_plot.hpp' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef NEXUS_PLOT_H -#define NEXUS_PLOT_H - -#include -#include -#include -#include -#include - -typedef struct ecl_sum_struct ecl_sum_type; - -namespace nex { - -struct bad_header : public std::runtime_error { - using std::runtime_error::runtime_error; -}; -struct read_error : public std::runtime_error { - using std::runtime_error::runtime_error; -}; -struct unexpected_eof : public std::runtime_error { - using std::runtime_error::runtime_error; -}; - -class NexusPlot { -public: - NexusPlot( const std::string& ); - NexusPlot( std::istream& ); - - int32_t num_classes = 0; - int32_t day, month, year; - int32_t nx, ny, nz; - int32_t ncomp; - std::vector class_names; - std::vector vars_in_class; - std::vector< std::vector > var_names; - - ecl_sum_type* ecl_summary( const std::string& ecl_case ); - -private: - void load( std::istream& ); -}; - -} - -#endif // NEXUS_PLOT_H diff --git a/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp b/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp new file mode 100644 index 0000000000..94c71385e1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/arg_pack.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef ARG_PACK_CXX +#define ARG_PACK_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/buffer.hpp b/ThirdParty/Ert/lib/include/ert/util/buffer.hpp new file mode 100644 index 0000000000..b002e8981e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/buffer.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef BUFFER_CXX +#define BUFFER_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp b/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp new file mode 100644 index 0000000000..3af2a9706b --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/ecl_version.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef ECL_VERSION_CXX +#define ECL_VERSION_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash.h b/ThirdParty/Ert/lib/include/ert/util/hash.h index dcc862f0cc..cc7dfbb200 100644 --- a/ThirdParty/Ert/lib/include/ert/util/hash.h +++ b/ThirdParty/Ert/lib/include/ert/util/hash.h @@ -1,19 +1,19 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'hash.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'hash.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #ifndef ERT_HASH_H @@ -35,10 +35,7 @@ typedef void (hash_apply_ftype) (void * ); UTIL_SAFE_CAST_HEADER(hash); UTIL_SAFE_CAST_HEADER_CONST(hash); -void hash_lock (hash_type * ); -void hash_unlock(hash_type * ); hash_type * hash_alloc(void); -hash_type * hash_alloc_unlocked(void); void hash_iter_complete(hash_type * ); void hash_free(hash_type *); void hash_free__(void *); @@ -55,12 +52,12 @@ void hash_safe_del(hash_type * , const char * ); void hash_clear(hash_type *); int hash_get_size(const hash_type *); void hash_set_keylist(const hash_type * , char **); -char ** hash_alloc_keylist(hash_type *); -stringlist_type * hash_alloc_stringlist(hash_type * ); +char ** hash_alloc_keylist(const hash_type *); +stringlist_type * hash_alloc_stringlist(const hash_type * ); -char ** hash_alloc_sorted_keylist (hash_type *hash , int ( hash_get_cmp_value ) (const void *)); -char ** hash_alloc_key_sorted_list(hash_type *hash, int (*cmp)(const void *, const void *)); -bool hash_key_list_compare( hash_type * hash1, hash_type * hash2); +char ** hash_alloc_sorted_keylist (const hash_type *hash , int ( hash_get_cmp_value ) (const void *)); +char ** hash_alloc_key_sorted_list(const hash_type *hash, int (*cmp)(const void *, const void *)); +bool hash_key_list_compare(const hash_type * hash1, const hash_type * hash2); void hash_insert_hash_owned_ref(hash_type *, const char * , const void *, free_ftype *); void hash_resize(hash_type *hash, int new_size); diff --git a/ThirdParty/Ert/lib/include/ert/util/hash.hpp b/ThirdParty/Ert/lib/include/ert/util/hash.hpp new file mode 100644 index 0000000000..1a2758952a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/hash.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef HASH_CXX +#define HASH_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp b/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp new file mode 100644 index 0000000000..2d6176c592 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/hash_node.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef HASH_NODE_CXX +#define HASH_NODE_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp b/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp new file mode 100644 index 0000000000..70c64a0b03 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/hash_sll.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef HASH_SLL_CXX +#define HASH_SLL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/lars.h b/ThirdParty/Ert/lib/include/ert/util/lars.h deleted file mode 100644 index 4acdeb37c6..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/lars.h +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lars.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - - -#ifndef ERT_LARS_H -#define ERT_LARS_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -typedef struct lars_struct lars_type; - -int lars_get_sample( const lars_type * lars ); -int lars_get_nvar( const lars_type * lars ); -lars_type * lars_alloc1( int nsample , int nvars); -lars_type * lars_alloc2( matrix_type * X , matrix_type * Y , bool internal_copy ); -void lars_estimate(lars_type * lars , int max_vars , double max_beta , bool verbose); -void lars_isetX( lars_type * lars, int sample, int var , double value); -void lars_isetY( lars_type * lars, int sample, double value); -void lars_select_beta( lars_type * lars , int beta_index); -void lars_free( lars_type * lars ); -double lars_eval1( const lars_type * lars , const matrix_type * x); -double lars_eval2( const lars_type * lars , double * x); -double lars_getY0( const lars_type * lars); -double lars_iget_beta( const lars_type * lars , int index); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/log.h b/ThirdParty/Ert/lib/include/ert/util/log.h deleted file mode 100644 index dcaad30d89..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/log.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'log.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_LOG_H -#define ERT_LOG_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -//Same as pythons default log levels, but with different numeric values. -typedef enum { - LOG_CRITICAL=0, //OOM. - LOG_ERROR=1, //When something we really expected to work does not, e.g. IO failure. - LOG_WARNING=2, //Important, but not error. E.g. combination of settings which can be intended, but probably are not. - LOG_INFO=3, //Entering functions/parts of the code - LOG_DEBUG=4 //Inside the for-loop, when you need the nitty gritty details. Think TRACE. -} message_level_type; - - -typedef struct log_struct log_type; - - FILE * log_get_stream(log_type * logh ); - void log_reopen( log_type * logh , const char * filename ); - log_type * log_open(const char *filename, int log_level); - void log_add_message(log_type *logh, int message_level , FILE * dup_stream , char* message, bool free_message); - void log_add_message_str(log_type *logh, message_level_type message_level , const char* message); - void log_add_fmt_message(log_type * logh , int message_level , FILE * dup_stream , const char * fmt , ...); - int log_get_level( const log_type * logh); - void log_set_level( log_type * logh , int new_level); - void log_close( log_type * logh ); - void log_sync(log_type * logh); - const char * log_get_filename( const log_type * logh ); - int log_get_level( const log_type * logh); - void log_set_level( log_type * logh , int log_level); - bool log_is_open( const log_type * logh); - bool log_include_message(const log_type *logh , int message_level); - int log_get_msg_count(const log_type * logh); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/lookup_table.h b/ThirdParty/Ert/lib/include/ert/util/lookup_table.h index d08cc7c421..a2ebb1d32e 100644 --- a/ThirdParty/Ert/lib/include/ert/util/lookup_table.h +++ b/ThirdParty/Ert/lib/include/ert/util/lookup_table.h @@ -37,7 +37,7 @@ typedef struct lookup_table_struct lookup_table_type; double lookup_table_get_max_value( lookup_table_type * lookup_table ); double lookup_table_get_min_value( lookup_table_type * lookup_table ); double lookup_table_get_max_arg( lookup_table_type * lookup_table ); - double lookup_table_get_max_arg( lookup_table_type * lookup_table ); + double lookup_table_get_min_arg( lookup_table_type * lookup_table ); int lookup_table_get_size( const lookup_table_type * lt ); void lookup_table_set_low_limit( lookup_table_type * lt , double limit); bool lookup_table_has_low_limit(const lookup_table_type * lt ); diff --git a/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp b/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp new file mode 100644 index 0000000000..a3fcd045ac --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/lookup_table.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef LOOKUP_TABLE_CXX +#define LOOKUP_TABLE_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/matrix.h b/ThirdParty/Ert/lib/include/ert/util/matrix.h deleted file mode 100644 index cdbcc26640..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/matrix.h +++ /dev/null @@ -1,194 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_MATRIX_H -#define ERT_MATRIX_H -#include -#include -#include - -#include -#include -#include -#include - -#ifdef HAVE_THREAD_POOL -#include -#endif - -#ifdef _MSC_VER -#define __forceinline inline -#elif __GNUC__ -/* Also clang defines the __GNUC__ symbol */ -#define __forceinline inline __attribute__((always_inline)) -#endif - - -#ifdef __cplusplus -extern "C" { -#endif - -struct matrix_struct { - UTIL_TYPE_ID_DECLARATION; - char * name; /* A name of the matrix - for printing - can be NULL. */ - double * data; /* The actual storage */ - bool data_owner; /* is this matrix instance the owner of data? */ - size_t data_size; /* What is the length of data (number of double values). */ - - int rows; /* The number of rows in the matrix. */ - int columns; /* The number of columns in the matrix. */ - int alloc_rows; - int alloc_columns; - int row_stride; /* The distance in data between two conscutive row values. */ - int column_stride; /* The distance in data between to consecutive column values. */ - - /* - Observe that the stride is considered an internal property - if - the matrix is stored to disk and then recovered the strides might - change, and also matrix_alloc_copy() will not respect strides. - */ -}; - -typedef struct matrix_struct matrix_type; - - __forceinline size_t GET_INDEX( const matrix_type * m , size_t i , size_t j) {return m->row_stride *i + m->column_stride *j;} - matrix_type * matrix_fread_alloc(FILE * stream); - void matrix_fread(matrix_type * matrix , FILE * stream); - void matrix_fwrite(const matrix_type * matrix , FILE * stream); - bool matrix_check_dims( const matrix_type * m , int rows , int columns); - void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * stream ); - void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stream ); - void matrix_dump_csv( const matrix_type * matrix ,const char * filename); - void matrix_pretty_fprint(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream); - void matrix_pretty_fprint_submat(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream, int m, int M, int n, int N); - matrix_type * matrix_alloc(int rows, int columns); - matrix_type * matrix_alloc_identity(int dim); - matrix_type * matrix_safe_alloc(int rows, int columns); - bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content); - bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool copy_content); - matrix_type * matrix_alloc_sub_copy( const matrix_type * src , int row_offset , int column_offset , int rows, int columns); - matrix_type * matrix_alloc_copy(const matrix_type * src); - matrix_type * matrix_alloc_column_compressed_copy(const matrix_type * src, const bool_vector_type * mask); - void matrix_column_compressed_memcpy(matrix_type * target, const matrix_type * src, const bool_vector_type * mask); - matrix_type * matrix_safe_alloc_copy(const matrix_type * src); - matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src); - - matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns); - void matrix_free(matrix_type * matrix); - void matrix_safe_free( matrix_type * matrix ); - void matrix_pretty_print(const matrix_type * matrix , const char * name , const char * fmt); - void matrix_set(matrix_type * matrix, double value); - void matrix_set_name( matrix_type * matrix , const char * name); - void matrix_scale(matrix_type * matrix, double value); - void matrix_shift(matrix_type * matrix, double value); - - void matrix_assign(matrix_type * A , const matrix_type * B); - void matrix_inplace_add(matrix_type * A , const matrix_type * B); - void matrix_inplace_sub(matrix_type * A , const matrix_type * B); - void matrix_inplace_mul(matrix_type * A , const matrix_type * B); - void matrix_inplace_div(matrix_type * A , const matrix_type * B); - void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C); - void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C); - void matrix_transpose(const matrix_type * A , matrix_type * T); - void matrix_inplace_add_column(matrix_type * A , const matrix_type * B, int colA , int colB); - void matrix_inplace_sub_column(matrix_type * A , const matrix_type * B, int colA , int colB); - void matrix_inplace_transpose(matrix_type * A ); - - void matrix_iset_safe(matrix_type * matrix , int i , int j, double value); - void matrix_iset(matrix_type * matrix , int i , int j, double value); - double matrix_iget(const matrix_type * matrix , int i , int j); - double matrix_iget_safe(const matrix_type * matrix , int i , int j); - void matrix_iadd(matrix_type * matrix , int i , int j , double value); - void matrix_isub(matrix_type * matrix , int i , int j , double value); - void matrix_imul(matrix_type * matrix , int i , int j , double value); - - - void matrix_inplace_matmul(matrix_type * A, const matrix_type * B); - void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads); -#ifdef HAVE_THREAD_POOL - void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool); -#endif - - void matrix_shift_column(matrix_type * matrix , int column, double shift); - void matrix_shift_row(matrix_type * matrix , int row , double shift); - double matrix_get_column_sum(const matrix_type * matrix , int column); - double matrix_get_row_sum(const matrix_type * matrix , int column); - double matrix_get_column_sum2(const matrix_type * matrix , int column); - double matrix_get_row_abssum(const matrix_type * matrix , int row); - double matrix_get_column_abssum(const matrix_type * matrix , int column); - double matrix_get_row_sum2(const matrix_type * matrix , int column); - void matrix_subtract_row_mean(matrix_type * matrix); - void matrix_subtract_and_store_row_mean(matrix_type * matrix, matrix_type * row_mean); - void matrix_scale_column(matrix_type * matrix , int column , double scale_factor); - void matrix_scale_row(matrix_type * matrix , int row , double scale_factor); - void matrix_set_const_column(matrix_type * matrix , const double value , int column); - void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int src_column, int target_column); - void matrix_set_const_row(matrix_type * matrix , const double value , int row); - - double * matrix_get_data(const matrix_type * matrix); - double matrix_orthonormality( const matrix_type * matrix ); - - matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size); - void matrix_set_column(matrix_type * matrix , const double * data , int column); - void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column); - void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content); - void matrix_shrink_header(matrix_type * matrix , int rows , int columns); - void matrix_full_size( matrix_type * matrix ); - int matrix_get_rows(const matrix_type * matrix); - int matrix_get_columns(const matrix_type * matrix); - int matrix_get_row_stride(const matrix_type * matrix); - int matrix_get_column_stride(const matrix_type * matrix); - void matrix_get_dims(const matrix_type * matrix , int * rows , int * columns , int * row_stride , int * column_stride); - bool matrix_is_quadratic(const matrix_type * matrix); - bool matrix_equal( const matrix_type * m1 , const matrix_type * m2); - bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2); - - void matrix_diag_set_scalar(matrix_type * matrix , double value); - void matrix_diag_set(matrix_type * matrix , const double * diag); - void matrix_random_init(matrix_type * matrix , rng_type * rng); - void matrix_matlab_dump(const matrix_type * matrix, const char * filename); - - void matrix_imul_col( matrix_type * matrix , int column , double factor); - double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2); - double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2); - matrix_type * matrix_alloc_view(double * data , int rows , int columns); - matrix_type * matrix_alloc_transpose( const matrix_type * A); - void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix , int target_row, int src_row); - void matrix_copy_block( matrix_type * target_matrix , int target_row , int target_column , int rows , int columns, - const matrix_type * src_matrix , int src_row , int src_column); - - void matrix_scalar_set( matrix_type * matrix , double value); - void matrix_inplace_diag_sqrt(matrix_type *Cd); - void matrix_create_identiy(int n,matrix_type *Id); - double matrix_trace(const matrix_type *matrix); - double matrix_diag_std(const matrix_type * Sk,double mean); - double matrix_det2( const matrix_type * A); - double matrix_det3( const matrix_type * A); - double matrix_det4( const matrix_type * A); - - #ifdef ERT_HAVE_ISFINITE - bool matrix_is_finite(const matrix_type * matrix); - void matrix_assert_finite( const matrix_type * matrix ); - #endif - - UTIL_SAFE_CAST_HEADER( matrix ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/matrix_blas.h b/ThirdParty/Ert/lib/include/ert/util/matrix_blas.h deleted file mode 100644 index de28979c5f..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/matrix_blas.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_blas.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_MATRIX_BLAS -#define ERT_MATRIX_BLAS -#include - -#include - - -#ifdef __cplusplus -extern "C" { -#endif - - -void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB , double alpha , double beta); -void matrix_matmul_with_transpose(matrix_type * C, const matrix_type * A , const matrix_type * B , bool transA , bool transB); -void matrix_matmul(matrix_type * A, const matrix_type *B , const matrix_type * C); -matrix_type * matrix_alloc_matmul(const matrix_type * A, const matrix_type * B); -void matrix_dgemv(const matrix_type * A , const double * x , double * y , bool transA , double alpha , double beta); -void matrix_mul_vector(const matrix_type * A , const double * x , double * y); -void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col); -matrix_type * matrix_alloc_gram( const matrix_type * X , bool col); - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h b/ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h deleted file mode 100644 index 0ddb89545e..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/matrix_lapack.h +++ /dev/null @@ -1,93 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_lapack.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#ifndef ERT_MATRIX_LAPACK_H -#define ERT_MATRIX_LAPACK_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - -/** - This enum is just a simple way to label the different ways the - singular vectors in U and VT are returned to the calling scope. The - low level lapack routine uses a character variable, indicated - below. -*/ - - - - - - typedef enum { - /* A */ DGESVD_ALL, /* Returns all the singular vectors in U/VT. */ - /* S */ DGESVD_MIN_RETURN, /* Return the first min(m,n) vectors in U/VT. */ - /* O */ DGESVD_MIN_OVERWRITE, /* Return the first min(m,n) vectors of U/VT by overwriteing in A. */ - /* N */ DGESVD_NONE} /* Do not compute any singular vectors for U/VT */ - dgesvd_vector_enum; - - - typedef enum { - /* A */ DSYEVX_ALL, /* Compute all the eigenvalues */ - /* V */ DSYEVX_VALUE_INTERVAL, /* Computes eigenvalues in half open interval - for more details. -*/ - - -#ifndef ERT_MATRIX_STAT_H -#define ERT_MATRIX_STAT_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -typedef enum { - LLSQ_SUCCESS = 0, - LLSQ_INVALID_DIM = 1, - LLSQ_UNDETERMINED = 2 -} llsq_result_enum; - - -llsq_result_enum matrix_stat_llsq_estimate( matrix_type * beta , const matrix_type * X , const matrix_type * Y , const matrix_type * S); -llsq_result_enum matrix_stat_polyfit( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/menu.h b/ThirdParty/Ert/lib/include/ert/util/menu.h deleted file mode 100644 index 6306a4abde..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/menu.h +++ /dev/null @@ -1,51 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'menu.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_MENU_H -#define ERT_MENU_H - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -typedef struct menu_struct menu_type; -typedef struct menu_item_struct menu_item_type; - -typedef void (menu_func_type) (void *); -typedef void (arg_free_ftype) (void *); - -menu_type * menu_alloc(const char * , const char * , const char *); -void menu_run(const menu_type * ); -void menu_free(menu_type * ); -menu_item_type * menu_get_item(const menu_type * , char ); -menu_item_type * menu_add_item(menu_type *, const char * , const char * , menu_func_type * , void * , arg_free_ftype * ); -void menu_add_separator(menu_type * ); -void menu_add_helptext(menu_type * , const char * ); -menu_item_type * menu_get_item(const menu_type * , char ); -void menu_set_title(menu_type *, const char *); - -void menu_item_set_label( menu_item_type * , const char *); -void menu_item_disable( menu_item_type * item ); -void menu_item_enable( menu_item_type * item ); -void menu_add_helptext(menu_type * menu, const char * label ); - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/msg.h b/ThirdParty/Ert/lib/include/ert/util/msg.h deleted file mode 100644 index 02b7674a1d..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/msg.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'msg.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_MSG_H -#define ERT_MSG_H -#ifdef __cplusplus -extern "C" { -#endif -#include - -#include - - -typedef struct msg_struct msg_type; - - - -msg_type * msg_alloc(const char * , bool debug); -void msg_show(msg_type * ); -void msg_free(msg_type * , bool); -void msg_update(msg_type * , const char * ); -void msg_update_int(msg_type * , const char * , int ); -void msg_hide(msg_type *); -void msg_clear_msg(msg_type * msg); - - -UTIL_SAFE_CAST_HEADER( msg ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h b/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h index 396185b107..ebe515e384 100644 --- a/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h +++ b/ThirdParty/Ert/lib/include/ert/util/msvc_stdbool.h @@ -4,12 +4,12 @@ - The ERT code makes use of stdbool in many places. The msvc C compiler does not have a stdbool header, i.e. the #include - statements fail when compiling. + statements fail when compiling. - When included in a C++ project the compiler already has a bool - defined; it is therefor important not to redefine this symbol if + defined; it is therefore important not to redefine this symbol if we are compiling C++. - + */ #ifndef __cplusplus diff --git a/ThirdParty/Ert/lib/include/ert/util/mzran.hpp b/ThirdParty/Ert/lib/include/ert/util/mzran.hpp new file mode 100644 index 0000000000..512eb56ad9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/mzran.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef MZRAN_CXX +#define MZRAN_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp b/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp new file mode 100644 index 0000000000..6618717f82 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/node_ctype.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef NODE_CTYPE_CXX +#define NODE_CTYPE_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/node_data.hpp b/ThirdParty/Ert/lib/include/ert/util/node_data.hpp new file mode 100644 index 0000000000..91f5d8c634 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/node_data.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef NODE_DATA_CXX +#define NODE_DATA_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/parser.hpp b/ThirdParty/Ert/lib/include/ert/util/parser.hpp new file mode 100644 index 0000000000..72e400d2d1 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/parser.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef PARSER_CXX +#define PARSER_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/path_fmt.h b/ThirdParty/Ert/lib/include/ert/util/path_fmt.h deleted file mode 100644 index da7fd5db67..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/path_fmt.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'path_fmt.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_PATH_FMT_H -#define ERT_PATH_FMT_H - -#include -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct path_fmt_struct path_fmt_type; - - path_fmt_type * path_fmt_alloc_directory_fmt(const char * ); - path_fmt_type * path_fmt_alloc_path_fmt(const char * ); - path_fmt_type * path_fmt_copyc(const path_fmt_type *); - path_fmt_type * path_fmt_scanf_alloc(const char * , int , const node_ctype * , bool ); - char * path_fmt_alloc_path(const path_fmt_type * , bool , ...); - char * path_fmt_alloc_file(const path_fmt_type * , bool , ...); - void path_fmt_free(path_fmt_type * ); - void path_fmt_free__( void * arg ); - const char * path_fmt_get_fmt(const path_fmt_type * ); - void path_fmt_reset_fmt(path_fmt_type * , const char * ); - void path_fmt_make_path(const path_fmt_type * ); - path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp b/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp new file mode 100644 index 0000000000..2dbea35ffd --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/path_stack.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef PATH_STACK_CXX +#define PATH_STACK_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp b/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp new file mode 100644 index 0000000000..53758b9ea9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/perm_vector.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef PERM_VECTOR_CXX +#define PERM_VECTOR_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/regression.h b/ThirdParty/Ert/lib/include/ert/util/regression.h deleted file mode 100644 index 564461e768..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/regression.h +++ /dev/null @@ -1,34 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'regression.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_REGRESSION_H -#define ERT_REGRESSION_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif -double regression_scale( matrix_type * X , matrix_type * Y , matrix_type * X_mean , matrix_type * X_norm); -double regression_unscale(const matrix_type * beta , const matrix_type * X_norm , const matrix_type * X_mean , double Y_mean , matrix_type * beta0); -void regression_augmented_OLS(const matrix_type * X , const matrix_type * Y , const matrix_type *E, matrix_type * beta); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/rng.hpp b/ThirdParty/Ert/lib/include/ert/util/rng.hpp new file mode 100644 index 0000000000..d75be17013 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/rng.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef RNG_CXX +#define RNG_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/set.hpp b/ThirdParty/Ert/lib/include/ert/util/set.hpp new file mode 100644 index 0000000000..4a5936ab31 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/set.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef SET_CXX +#define SET_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp b/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp new file mode 100644 index 0000000000..df855a99cc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/ssize_t.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef SSIZE_T_CXX +#define SSIZE_T_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/statistics.hpp b/ThirdParty/Ert/lib/include/ert/util/statistics.hpp new file mode 100644 index 0000000000..2d1fe6f10a --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/statistics.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STATISTICS_CXX +#define STATISTICS_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/stepwise.h b/ThirdParty/Ert/lib/include/ert/util/stepwise.h deleted file mode 100644 index f1eb0a4f21..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/stepwise.h +++ /dev/null @@ -1,42 +0,0 @@ -#ifndef ERT_STEPWISE_H -#define ERT_STEPWISE_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - typedef struct stepwise_struct stepwise_type; - - - stepwise_type * stepwise_alloc1(int nsample, int nvar, rng_type * rng, const matrix_type* St, const matrix_type* Et); - stepwise_type * stepwise_alloc0(rng_type * rng); - void stepwise_free( stepwise_type * stepwise); - - void stepwise_set_Y0( stepwise_type * stepwise , matrix_type * Y); - void stepwise_set_X0( stepwise_type * stepwise , matrix_type * X); - void stepwise_set_E0( stepwise_type * stepwise , matrix_type * E); - void stepwise_set_beta( stepwise_type * stepwise , matrix_type * b); - void stepwise_set_R2( stepwise_type * stepwise , const double R2); - void stepwise_set_active_set( stepwise_type * stepwise , bool_vector_type * a); - void stepwise_isetY0( stepwise_type * stepwise , int i , double value ); - double stepwise_get_R2(const stepwise_type * stepwise ); - int stepwise_get_nvar( stepwise_type * stepwise ); - int stepwise_get_nsample( stepwise_type * stepwise ); - int stepwise_get_n_active( stepwise_type * stepwise ); - bool_vector_type * stepwise_get_active_set( stepwise_type * stepwise ); - double stepwise_iget_beta(const stepwise_type * stepwise, const int index ); - double stepwise_get_sum_beta(const stepwise_type * stepwise ); - - void stepwise_estimate( stepwise_type * stepwise , double deltaR2_limit , int CV_blocks); - double stepwise_eval( const stepwise_type * stepwise , const matrix_type * x ); - - - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/string_util.hpp b/ThirdParty/Ert/lib/include/ert/util/string_util.hpp new file mode 100644 index 0000000000..4cfb76138f --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/string_util.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STRING_UTIL_CXX +#define STRING_UTIL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/stringlist.h b/ThirdParty/Ert/lib/include/ert/util/stringlist.h index 597bba63c9..85f6e130cf 100644 --- a/ThirdParty/Ert/lib/include/ert/util/stringlist.h +++ b/ThirdParty/Ert/lib/include/ert/util/stringlist.h @@ -25,7 +25,6 @@ #include #include #include -#include #ifdef __cplusplus extern "C" { @@ -34,6 +33,9 @@ extern "C" { typedef struct stringlist_struct stringlist_type; typedef int ( string_cmp_ftype) (const void * , const void *); +typedef bool ( file_pred_ftype) (const char *, const void *); + + int stringlist_select_files(stringlist_type * names, const char * path, file_pred_ftype * predicate, const void * pred_arg); const char * stringlist_get_last( const stringlist_type * stringlist ); char * stringlist_pop( stringlist_type * stringlist); @@ -103,8 +105,6 @@ typedef int ( string_cmp_ftype) (const void * , const void *); char ** stringlist_alloc_char_ref(const stringlist_type * stringlist); void stringlist_fread(stringlist_type * , FILE * ); void stringlist_fwrite(const stringlist_type * , FILE * ); - void stringlist_buffer_fread( stringlist_type * s , buffer_type * buffer ); - void stringlist_buffer_fwrite( const stringlist_type * s , buffer_type * buffer ); void stringlist_sort(stringlist_type * , string_cmp_ftype * string_cmp); void stringlist_reverse( stringlist_type * s ); void stringlist_python_sort( stringlist_type * s , int cmp_flag); diff --git a/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp b/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp new file mode 100644 index 0000000000..ea149225dc --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/stringlist.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STRINGLIST_CXX +#define STRINGLIST_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp b/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp new file mode 100644 index 0000000000..d91ac14230 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/struct_vector.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef STRUCT_VECTOR_CXX +#define STRUCT_VECTOR_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/subst_func.h b/ThirdParty/Ert/lib/include/ert/util/subst_func.h deleted file mode 100644 index 5dc1369ff5..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/subst_func.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'subst_func.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_SUBST_FUNC_H -#define ERT_SUBST_FUNC_H -#ifdef __cplusplus -extern "C" { -#endif - -#include - -typedef char * (subst_func_ftype) (const stringlist_type * , void * ); -typedef struct subst_func_struct subst_func_type; -typedef struct subst_func_pool_struct subst_func_pool_type; - - - char * subst_func_eval( const subst_func_type * subst_func , const stringlist_type * args); - -/*****************************************************************/ - - subst_func_pool_type * subst_func_pool_alloc( ); - void subst_func_pool_free( subst_func_pool_type * pool ); - void subst_func_pool_add_func( subst_func_pool_type * pool , const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg); -subst_func_type * subst_func_pool_get_func( const subst_func_pool_type * pool , const char * func_name ); -bool subst_func_pool_has_func( const subst_func_pool_type * pool , const char * func_name ); -UTIL_IS_INSTANCE_HEADER( subst_func_pool ); - -/*****************************************************************/ -char * subst_func_randint( const stringlist_type * args , void * arg); -char * subst_func_randfloat( const stringlist_type * args , void * arg); -char * subst_func_add( const stringlist_type * args , void * arg); -char * subst_func_mul( const stringlist_type * args , void * arg); -char * subst_func_exp( const stringlist_type * args , void * arg); -char * subst_func_log( const stringlist_type * args , void * arg); -char * subst_func_pow10( const stringlist_type * args , void * arg); - - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/test_util.h b/ThirdParty/Ert/lib/include/ert/util/test_util.h index 131ef67735..b1326deeef 100644 --- a/ThirdParty/Ert/lib/include/ert/util/test_util.h +++ b/ThirdParty/Ert/lib/include/ert/util/test_util.h @@ -36,6 +36,8 @@ extern "C" { void test_error_exit( const char * fmt , ...); + void * test_argpack_is_stringlist( void * arg ); + void * thread_pool_test_func1( void * arg ); #define test_exit( fmt, ...) test_exit__( __FILE__ , __LINE__ , fmt , __VA_ARGS__); void test_exit__(const char * file , int line , const char * fmt , ...); diff --git a/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp b/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp new file mode 100644 index 0000000000..5d9fbc90bd --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/test_work_area.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TEST_WORK_AREA_CXX +#define TEST_WORK_AREA_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/thread_pool.h b/ThirdParty/Ert/lib/include/ert/util/thread_pool.h deleted file mode 100644 index 23abb308a2..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/thread_pool.h +++ /dev/null @@ -1,43 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#ifndef ERT_THREAD_POOL_H -#define ERT_THREAD_POOL_H - -#ifdef __cplusplus -extern "C" { -#endif - -#include - - typedef struct thread_pool_struct thread_pool_type; - - void thread_pool_join(thread_pool_type * ); - thread_pool_type * thread_pool_alloc(int , bool start_queue); - void thread_pool_add_job(thread_pool_type * ,void * (*) (void *) , void *); - void thread_pool_free(thread_pool_type *); - void thread_pool_restart( thread_pool_type * tp ); - void * thread_pool_iget_return_value( const thread_pool_type * pool , int queue_index ); - int thread_pool_get_max_running( const thread_pool_type * pool ); - bool thread_pool_try_join(thread_pool_type * pool, int timeout_seconds); - -#ifdef __cplusplus -} -#endif - - -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/time_interval.h b/ThirdParty/Ert/lib/include/ert/util/time_interval.h deleted file mode 100644 index 6d2f13cb83..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/time_interval.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'time_interval.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_TIME_INTERVAL_H -#define ERT_TIME_INTERVAL_H -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - - typedef struct time_interval_struct time_interval_type; - - time_interval_type * time_interval_alloc( time_t start_time , time_t end_time ); - time_interval_type * time_interval_alloc_open( ); - time_interval_type * time_interval_alloc_copy( const time_interval_type * src); - void time_interval_reopen( time_interval_type * time_interval); - void time_interval_free( time_interval_type * ti ); - bool time_interval_is_empty( time_interval_type * ti ); - bool time_interval_update( time_interval_type * ti , time_t start_time , time_t end_time); - bool time_interval_contains( const time_interval_type * ti , time_t t); - bool time_interval_has_overlap( const time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_is_adjacent( const time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_update_start( time_interval_type * ti , time_t start_time ); - bool time_interval_update_end( time_interval_type * ti , time_t end_time ); - time_t time_interval_get_start( const time_interval_type * ti); - time_t time_interval_get_end( const time_interval_type * ti); - bool time_interval_extend( time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_intersect( time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_equal( const time_interval_type * t1 , const time_interval_type * t2); - bool time_interval_arg_before( const time_interval_type * ti , time_t arg); - bool time_interval_arg_after( const time_interval_type * ti , time_t arg); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp b/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp new file mode 100644 index 0000000000..26073dbf06 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/time_interval.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TIME_INTERVAL_CXX +#define TIME_INTERVAL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/timer.hpp b/ThirdParty/Ert/lib/include/ert/util/timer.hpp new file mode 100644 index 0000000000..14a83dd14f --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/timer.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TIMER_CXX +#define TIMER_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/type_macros.hpp b/ThirdParty/Ert/lib/include/ert/util/type_macros.hpp new file mode 100644 index 0000000000..704643272e --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/type_macros.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TYPE_MACROS_CXX +#define TYPE_MACROS_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp b/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp new file mode 100644 index 0000000000..142f711db9 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/type_vector_functions.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef TYPE_VECTOR_FUNCTIONS_CXX +#define TYPE_VECTOR_FUNCTIONS_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/ui_return.h b/ThirdParty/Ert/lib/include/ert/util/ui_return.h deleted file mode 100644 index 43044a9348..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/ui_return.h +++ /dev/null @@ -1,57 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ui_return.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_UI_RETURN_H -#define ERT_UI_RETURN_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct ui_return_struct ui_return_type; - - -typedef enum { - UI_RETURN_OK = 1, - UI_RETURN_FAIL = 2 -} ui_return_status_enum; - - - -ui_return_type * ui_return_alloc(ui_return_status_enum status); -void ui_return_free(ui_return_type * ui_return); -ui_return_status_enum ui_return_get_status(const ui_return_type * ui_return); -int ui_return_get_error_count(const ui_return_type * ui_return); -bool ui_return_add_error(ui_return_type * ui_return, const char * error_msg); -void ui_return_add_help(ui_return_type * ui_return, const char * help_text); -const char * ui_return_get_first_error(const ui_return_type * ui_return); -const char * ui_return_get_last_error(const ui_return_type * ui_return); -const char * ui_return_get_help(const ui_return_type * ui_return); -const char * ui_return_iget_error( const ui_return_type * ui_return , int index); - - -UTIL_IS_INSTANCE_HEADER(ui_return); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/util.h b/ThirdParty/Ert/lib/include/ert/util/util.h index 56c7408f5e..84b406b9d3 100644 --- a/ThirdParty/Ert/lib/include/ert/util/util.h +++ b/ThirdParty/Ert/lib/include/ert/util/util.h @@ -43,6 +43,9 @@ #define UTIL_PATH_SEP_CHAR '/' /* A simple character used when we want an actual char instance (i.e. not a pointer). */ #endif +#define UTIL_WINDOWS_PATH_SEP_CHAR '\\' +#define UTIL_POSIX_PATH_SEP_CHAR '/' + #define UTIL_NEWLINE_STRING " \n" #define UTIL_DEFAULT_MKDIR_MODE 0777 /* Directories are by default created with mode a+rwx - and then comes the umask ... */ @@ -134,8 +137,6 @@ typedef enum {left_pad = 0, bool util_sscanf_date_utc(const char * , time_t *); bool util_sscanf_isodate(const char * , time_t *); bool util_sscanf_percent(const char * string, double * value); - char * util_alloc_stdin_line(void); - char * util_realloc_stdin_line(char * ); bool util_is_executable(const char * ); bool util_entry_exists( const char * entry ); bool util_file_exists(const char *); @@ -162,8 +163,10 @@ typedef enum {left_pad = 0, void util_move_file(const char * src_file , const char * target_file); void util_move_file4( const char * src_name , const char * target_name , const char *src_path , const char * target_path); bool util_copy_file(const char * , const char * ); + bool util_copy_file__(const char * src_file , const char * target_file, size_t buffer_size , void * buffer , bool abort_on_error); char * util_alloc_cwd(void); bool util_is_cwd( const char * path ); + char * util_alloc_normal_path( const char * input_path ); char * util_alloc_realpath(const char * ); char * util_alloc_realpath__(const char * input_path); bool util_string_match(const char * string , const char * pattern); @@ -175,7 +178,6 @@ typedef enum {left_pad = 0, void util_usleep( unsigned long micro_seconds ); void util_yield(void); - char * util_blocking_alloc_stdin_line(unsigned long ); int util_roundf( float x ); int util_round( double x ); @@ -213,7 +215,7 @@ typedef enum {left_pad = 0, int util_count_file_lines(FILE * ); FILE * util_mkdir_fopen( const char * filename , const char * mode ); int util_fmove( FILE * stream , long offset , long shift); - FILE * util_fopen(const char * , const char *); + FILE * util_fopen(const char * , const char *); FILE * util_fopen__(const char * filename , const char * mode); void util_fclose( FILE * stream ); bool util_fopen_test(const char *, const char *); @@ -238,14 +240,7 @@ typedef enum {left_pad = 0, bool util_sscanf_int(const char * , int * ); const char * util_parse_int(const char * , int * , bool *); const char * util_skip_sep(const char * , const char * , bool *); - int util_scanf_int_with_limits(const char * , int , int , int ); - char * util_scanf_int_with_limits_return_char(const char * , int , int , int ); - void util_printf_prompt(const char * , int , char , const char *); - int util_scanf_int(const char * , int); - char * util_scanf_int_return_char(const char * , int); - double util_scanf_double(const char * prompt , int prompt_len); - char * util_scanf_alloc_string(const char * ); - bool util_sscanf_double(const char * , double * ); + bool util_sscanf_double(const char * , double * ); //char * util_alloc_full_path(const char *, const char *); char * util_alloc_filename(const char * , const char * , const char * ); char * util_realloc_filename(char * , const char * , const char * , const char * ); @@ -340,9 +335,6 @@ typedef enum {left_pad = 0, double util_double_min(double , double ); void util_fskip_lines(FILE * , int); bool util_same_file(const char * , const char * ); - void util_read_path(const char * , int , bool , char * ); - char * util_fscanf_alloc_filename(const char * , int , int); - void util_read_string(const char * , int , char * ); void util_fread (void *, size_t , size_t , FILE * , const char * ); void util_fwrite(const void *, size_t , size_t , FILE * , const char * ); time_t util_fread_time_t(FILE * stream); @@ -382,17 +374,21 @@ typedef enum {left_pad = 0, int util_fnmatch( const char * pattern , const char * string ); void util_time_utc( time_t * t , struct tm * ts ); - char ** util_alloc_PATH_list(void); - char * util_alloc_PATH_executable(const char * executable ); - char * util_isscanf_alloc_envvar( const char * string , int env_index ); - void util_setenv( const char * variable , const char * value); - const char * util_interp_setenv( const char * variable , const char * value); - void util_unsetenv( const char * variable); - char * util_alloc_envvar( const char * value ); bool util_is_link(const char * ); // Will always return false on windows int util_chdir(const char * path); bool util_chdir_file( const char * filename ); +#ifdef ERT_HAVE_UNISTD +#include + bool util_access(const char * entry, mode_t mode); +#else + bool util_access(const char * entry, int mode); +#define F_OK 0 +#define R_OK 4 +#define W_OK 2 +#define X_OK 1 +#endif + #define UTIL_FWRITE_SCALAR(s,stream) { if (fwrite(&s , sizeof s , 1 , stream) != 1) util_abort("%s: write failed: %s\n",__func__ , strerror(errno)); } #define UTIL_FREAD_SCALAR(s,stream) { \ @@ -495,9 +491,6 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type void util_abort__(const char * file , const char * function , int line , const char * fmt , ...); void util_abort_signal(int ); -void util_abort_append_version_info(const char * ); -void util_abort_free_version_info(void); -void util_abort_set_executable( const char * argv0 ); @@ -521,9 +514,6 @@ void util_abort_set_executable( const char * argv0 ); #ifdef ERT_HAVE_SPAWN pid_t util_spawn(const char *executable, int argc, const char **argv, const char *stdout_file, const char *stderr_file); int util_spawn_blocking(const char *executable, int argc, const char **argv, const char *stdout_file, const char *stderr_file); -#ifdef ERT_HAVE_PING - bool util_ping( const char * hostname); -#endif #endif diff --git a/ThirdParty/Ert/lib/include/ert/util/util.hpp b/ThirdParty/Ert/lib/include/ert/util/util.hpp new file mode 100644 index 0000000000..8d293d4382 --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/util.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef UTIL_CXX +#define UTIL_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/util_env.h b/ThirdParty/Ert/lib/include/ert/util/util_env.h deleted file mode 100644 index 2270867ae1..0000000000 --- a/ThirdParty/Ert/lib/include/ert/util/util_env.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'util_env.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#ifndef ERT_UTIL_ENV_H -#define ERT_UTIL_ENV_H - - - -#ifdef __cplusplus -extern"C" { -#endif - - char * util_alloc_PATH_executable(const char * executable ); - void util_setenv( const char * variable , const char * value); - const char * util_interp_setenv( const char * variable , const char * value); - void util_unsetenv( const char * variable); - char * util_alloc_envvar( const char * value ); - -#ifdef __cplusplus -} -#endif -#endif diff --git a/ThirdParty/Ert/lib/include/ert/util/vector.hpp b/ThirdParty/Ert/lib/include/ert/util/vector.hpp new file mode 100644 index 0000000000..99ddd5a31c --- /dev/null +++ b/ThirdParty/Ert/lib/include/ert/util/vector.hpp @@ -0,0 +1,24 @@ +/* + Copyright (C) 2018 Statoil ASA, Norway. + + This is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT is distributed in the hope that it will be useful, but WITHOUT ANY + WARRANTY; without even the implied warranty of MERCHANTABILITY or1 + FITNESS FOR A PARTICULAR PURPOSE. + + See the GNU General Public License at + for more details. +*/ + +#ifndef VECTOR_CXX +#define VECTOR_CXX + +#include + +#endif diff --git a/ThirdParty/Ert/lib/nexus/nexus_plot.cpp b/ThirdParty/Ert/lib/nexus/nexus_plot.cpp deleted file mode 100644 index c3c404bf8f..0000000000 --- a/ThirdParty/Ert/lib/nexus/nexus_plot.cpp +++ /dev/null @@ -1,170 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus_plot.cpp' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include - -#include -#ifdef HAVE_NETINET_IN_H -#include -#elif defined(HAVE_ARPA_INET_H) -#include -#elif defined(HAVE_WINSOCK2_H) -#include -#endif - -#include -#include - - -const std::string NEXUS_PLOT_TYPE_HEADER = "PLOT BIN "; - -namespace { - -template< int N > -std::string read_str(std::istream& stream) { - std::array< char, N> buf; - stream.read( buf.data(), N ); - return std::string( buf.data(), N ); -} - -struct hinfo { - int32_t num_classes; - int32_t day, month, year; - int32_t nx, ny, nz; - int32_t ncomp; - std::vector class_names; - std::vector vars_in_class; - std::vector< std::vector > var_names; -}; - -hinfo headerinfo( std::istream& stream ) { - stream.seekg(4 + 10 + 562 + 264, std::ios::beg); - - std::array< int32_t, 8 > buf {}; - stream.read( (char*)buf.data(), buf.max_size() * 4 ); - if ( !stream.good() ) throw nex::unexpected_eof(""); - - auto ntoh = []( int32_t x ) { return ntohl( x ); }; - std::transform( buf.begin(), buf.end(), buf.begin(), ntoh ); - auto negative = []( int32_t x ) { return x < 0; }; - if ( std::any_of( buf.begin(), buf.end(), negative ) ) - throw nex::bad_header("Negative value, corrupted file"); - - hinfo h = { - buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], - {}, - std::vector< int32_t >( buf[0], 0 ), - std::vector< std::vector >( buf[0], - std::vector()), - }; - - stream.seekg(8, std::ios::cur); - std::array< char, 8 > class_name; - for (int i = 0; i < h.num_classes; i++) { - stream.read(class_name.data(), 8); - h.class_names.push_back(std::string( class_name.data(), 8 )); - } - - stream.seekg(8, std::ios::cur); - stream.read((char*) h.vars_in_class.data(), h.num_classes * 4); - std::transform( h.vars_in_class.begin(), - h.vars_in_class.end(), - h.vars_in_class.begin(), - ntoh ); - if (std::any_of( h.vars_in_class.begin(), h.vars_in_class.end(), negative)) - throw nex::bad_header("Negative value, corrupted file"); - - stream.seekg(8, std::ios::cur); - for (int i = 0; i < h.num_classes; ++i) { - stream.seekg(4, std::ios::cur); - std::vector< char > var_names( h.vars_in_class[i] * 4, 0 ); - stream.read( var_names.data(), h.vars_in_class[i] * 4 ); - for (int k = 0; k < h.vars_in_class[i]; ++k) - h.var_names[i].push_back( std::string( var_names.data() + k*4 ,4 )); - stream.seekg(8, std::ios::cur); - } - stream.seekg(4, std::ios::cur); - - return h; -} - -} - -nex::NexusPlot::NexusPlot( const std::string& filename ) { - std::ifstream stream(filename, std::ios::binary); - if ( !stream.good() ) - throw nex::read_error("Could not open file " + filename); - this->load(stream); -} - -nex::NexusPlot::NexusPlot( std::istream& stream ) { - this->load(stream); -} - -void nex::NexusPlot::load(std::istream& stream) { - struct stream_guard { - stream_guard( std::istream& stream ) : - mask( stream.exceptions() ), - s( stream ) {} - ~stream_guard() { this->s.exceptions( this->mask ); } - std::ios::iostate mask; - std::istream& s; - } g { stream }; - stream.exceptions( std::ios::goodbit ); - - stream.seekg(4, std::ios::beg); // skip 4 bytes - auto type_header = read_str<10>(stream); - - if (type_header.compare(NEXUS_PLOT_TYPE_HEADER) != 0 || !stream.good()) - throw nex::bad_header("Could not verify file type"); - - auto header = headerinfo( stream ); - this->num_classes = header.num_classes; - this->day = header.day; - this->month = header.month; - this->year = header.year; - this->nx = header.nx; - this->ny = header.ny; - this->nz = header.nz; - this->ncomp = header.ncomp; - this->class_names = header.class_names; - this->vars_in_class = header.vars_in_class; - this->var_names = header.var_names; -} - -ecl_sum_type* nex::NexusPlot::ecl_summary( const std::string& ecl_case ) { - bool unified = true; - bool fmt_output = false; - const char* key_join_string = ":"; - time_t sim_start = 0; - bool time_in_days = true; - - ecl_sum_type * ecl_sum = ecl_sum_alloc_writer( ecl_case.c_str(), - fmt_output, - unified, - key_join_string, - sim_start, - time_in_days, - this->nx, this->ny, this->nz); - - return ecl_sum; -} diff --git a/ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp b/ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp deleted file mode 100644 index 6c8620c958..0000000000 --- a/ThirdParty/Ert/lib/nexus/tests/nexus2ecl.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus2ecl.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include -#include -#include -#include - -#include -#include - -#include - -#include - - -void test_create_ecl_sum(char *root_folder) { - test_work_area_type *work_area = test_work_area_alloc("nexus_header"); - - std::stringstream ss; - ss << root_folder << "/test-data/local/nexus/SPE1.plt"; - std::cout << ss.str() << std::endl; - nex::NexusPlot plt = nex::NexusPlot { ss.str() }; - - ecl_sum_type *ecl_sum = plt.ecl_summary( "ECL_CASE" ); - test_assert_true( ecl_sum_is_instance( ecl_sum )); - ecl_sum_fwrite( ecl_sum ); - ecl_sum_free( ecl_sum ); - test_assert_true( util_file_exists( "ECL_CASE.SMSPEC")); - - test_work_area_free(work_area); -} - - - -int main(int argc, char **argv) { - util_install_signals(); - test_create_ecl_sum(argv[1]); - exit(0); -} diff --git a/ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp b/ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp deleted file mode 100644 index 34e778cd68..0000000000 --- a/ThirdParty/Ert/lib/nexus/tests/nexus_plot_load.cpp +++ /dev/null @@ -1,142 +0,0 @@ -/* - Copyright (C) 2017 Statoil ASA, Norway. - - The file 'nexus_plot_constructor.cpp' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include - - -#include -#include - -void test_invalid_header1() { - std::stringstream stream( "xxxxINVALID_HEADER" ); - test_assert_throw(nex::NexusPlot { stream }, nex::bad_header); -} - -void test_invalid_header2() { - std::stringstream stream( "xxx" ); - test_assert_throw(nex::NexusPlot { stream }, nex::bad_header); -} - -void test_valid_header() { - std::stringstream stream( "xxxxPLOT BIN " ); - test_assert_throw(nex::NexusPlot { stream }, nex::unexpected_eof); -} - -void test_spe1_header(char *argv) { - std::stringstream ss; - ss << argv << "/test-data/local/nexus/SPE1.plt"; - auto plt = nex::NexusPlot { ss.str() }; - - std::array< std::string, 9 > class_names = { - "WELL ", "WLLYR ", "NODE ", "CONN ", "REGION ", "FIELD ", - "CONNLIST", "TARGET ", "FLOSTA " - }; - std::array< int, 9 > vars_in_class = { - 56, 52, 4, 43, 69, 58, 20, 25, 25 - }; - - std::array< std::vector< std::string >, 9 > var_names = { - std::vector< std::string > { - "COP ", "CGP ", "CWP ", "CGI ", "CWI ", "QOP ", "QGP ", "QWP ", - "QGI ", "QWI ", "BHP ", "WPH ", "WKH ", "WPAV", "THP ", "COWP", - "QOWP", "GOR ", "WCUT", "WOR ", "QGLG", "CGLG", "DRDN", "DRMX", - "CROP", "CRGP", "CRWP", "CROI", "CRGI", "CRWI", "ROP ", "RGP ", - "RWP ", "ROI ", "RGI ", "RWI ", "ONTM", "ALQ ", "API ", "QCDP", - "CCDP", "YCDP", "ACTV", "STAT", "Q1P ", "Q1I ", "C1P ", "C1I ", - "X1P ", "Y1P ", "Q2P ", "Q2I ", "C2P ", "C2I ", "X2P ", "Y2P " }, - std::vector< std::string > { - "QOP ", "QGP ", "QWP ", "COP ", "CGP ", "CWP ", "CGI ", "CWI ", - "PRES", "HEAD", "RW ", "SKIN", "WI ", "WBC ", "PWB ", "QGI ", - "QWI ", "COWP", "QOWP", "GOR ", "WCUT", "ACTV", "CROP", "CRGP", - "CRWP", "CROI", "CRGI", "CRWI", "ROP ", "RGP ", "RWP ", "ROI ", - "RGI ", "RWI ", "QCDP", "CCDP", "YCDP", "API ", "MD ", "FSEC", - "Q1P ", "Q1I ", "C1P ", "C1I ", "X1P ", "Y1P ", "Q2P ", "Q2I ", - "C2P ", "C2I ", "X2P ", "Y2P " }, - std::vector< std::string > { "PNOD", "PDAT", "TNOD", "ACTV" }, - std::vector< std::string > { - "QGAS", "QOIL", "QWTR", "CGAS", "COIL", "CWTR", "CBFG", "CBFO", - "CBFW", "QGIS", "QOIS", "QWIS", "P_IN", "POUT", "T_IN", "TOUT", - "ACTV", "STAT", "CSTR", "ITRG", "ONTM", "ALQ ", "SETM", "SETA", - "POWM", "POWA", "SPDM", "SPDA", "API ", "DELP", "QTOT", "GVF ", - "EFF ", "POSN", "WCUT", "GOR ", "WOR ", "Q1 ", "Q2 ", "X1 ", - "X2 ", "Y1 ", "Y2 " }, - std::vector< std::string > { - "COP ", "CGP ", "CWP ", "COI ", "CGI ", "CWI ", "PAVT", "PAVH", - "OIP ", "GIP ", "WIP ", "QOP ", "QGP ", "QWP ", "QOI ", "QGI ", - "QWI ", "OIN ", "GIN ", "WIN ", "SO ", "SG ", "SW ", "OREC", - "FGIP", "CIP ", "PAVE", "PAVD", "ROIP", "RGIP", "RWIP", "MRO ", - "MRG ", "MRW ", "NFLX", "PV ", "HCPV", "TAVT", "TAVH", "CROP", - "CRGP", "CRWP", "CROI", "CRGI", "CRWI", "ROP ", "RGP ", "RWP ", - "ROI ", "RGI ", "RWI ", "QCDP", "CCDP", "YCDP", "API ", "GOR ", - "WCUT", "WOR ", "Z1 ", "Z2 ", "MC1 ", "MC2 ", "MC3 ", "C1P ", - "C2P ", "C3P ", "C1I ", "C2I ", "C3I " }, - std::vector< std::string > { - "COP ", "CGP ", "CWP ", "CGI ", "CWI ", "QOP ", "QGP ", "QWP ", - "QGI ", "QWI ", "COWP", "QOWP", "GOR ", "OREC", "GREC", "PAVT", - "PAVH", "QGLG", "CGLG", "WCUT", "NFLX", "CROP", "CRGP", "CRWP", - "CROI", "CRGI", "CRWI", "ROP ", "RGP ", "RWP ", "ROI ", "RGI ", - "RWI ", "OIP ", "GIP ", "WIP ", "QCDP", "CCDP", "YCDP", "WLLS", - "PRDW", "GLFW", "WINJ", "GINJ", "ACTW", "API ", "Q1P ", "Q1I ", - "C1P ", "C1I ", "X1P ", "Y1P ", "Q2P ", "Q2I ", "C2P ", "C2I ", - "X2P ", "Y2P " }, - std::vector< std::string > { - "QOP ", "QGP ", "QWP ", "QOI ", "QGI ", "QWI ", "COP ", "CGP ", - "CWP ", "COI ", "CGI ", "CWI ", "API ", "WCUT", "GOR ", "WOR ", - "Q1P ", "Q1I ", "Q2P ", "Q2I " }, - std::vector< std::string > { - "SQO ", "SQG ", "SQW ", "SQL ", "SQA ", "SQH ", "RQO ", "RQG ", - "RQW ", "RQL ", "RQA ", "RQH ", "TSQO", "TSQG", "TSQW", "TSQL", - "TSQA", "TSQH", "TRQO", "TRQG", "TRQW", "TRQL", "TRQA", "TRQH", - "P " }, - std::vector< std::string > { - "QOP ", "QGP ", "QWP ", "QOI ", "QGI ", "QWI ", "COP ", "CGP ", - "CWP ", "COI ", "CGI ", "CWI ", "WLLS", "PRDW", "GLFW", "WINJ", - "GINJ", "ACTW", "WCUT", "GOR ", "WOR ", "Q1P ", "Q1I ", "Q2P ", - "Q2I " } - }; - - test_assert_int_equal(plt.num_classes, 9); - test_assert_int_equal(plt.day, 1); - test_assert_int_equal(plt.month, 1); - test_assert_int_equal(plt.year, 1980); - test_assert_int_equal(plt.nx, 1); - test_assert_int_equal(plt.ny, 1); - test_assert_int_equal(plt.nz, 1); - test_assert_int_equal(plt.ncomp, 2); - for (int i = 0; i < plt.num_classes; i++) - test_assert_std_string_equal(class_names[i], plt.class_names[i]); - for (int i = 0; i < plt.num_classes; i++) - test_assert_int_equal(vars_in_class[i], plt.vars_in_class[i]); - for (int i = 0; i < plt.num_classes; ++i) { - for (int k = 0; k < plt.vars_in_class[i]; ++k) { - test_assert_std_string_equal(var_names[i][k], plt.var_names[i][k]); - } - } -} - -int main(int argc, char* argv[]) { - test_invalid_header1(); - test_invalid_header2(); - test_valid_header(); - test_spe1_header(argv[1]); - return 0; -} diff --git a/ThirdParty/Ert/lib/util/TestArea.cpp b/ThirdParty/Ert/lib/util/TestArea.cpp index bc6212e2ef..afd204f9ea 100644 --- a/ThirdParty/Ert/lib/util/TestArea.cpp +++ b/ThirdParty/Ert/lib/util/TestArea.cpp @@ -17,7 +17,7 @@ */ #include -#include +#include #include #include #include diff --git a/ThirdParty/Ert/lib/util/arg_pack.c b/ThirdParty/Ert/lib/util/arg_pack.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/arg_pack.c rename to ThirdParty/Ert/lib/util/arg_pack.cpp index ce67984434..e204c11be0 100644 --- a/ThirdParty/Ert/lib/util/arg_pack.c +++ b/ThirdParty/Ert/lib/util/arg_pack.cpp @@ -21,13 +21,13 @@ #include #include -#include -#include -#include +#include +#include +#include /** - This file implements a arg_pack structure which is a small + This file implements an arg_pack structure which is a small convienence utility to pack several arguments into one argument. The generic use situtation is when calling functions like e.g. pthread_create() which take one (void *) as argument. You can diff --git a/ThirdParty/Ert/lib/util/buffer.c b/ThirdParty/Ert/lib/util/buffer.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/buffer.c rename to ThirdParty/Ert/lib/util/buffer.cpp index a590ce8c22..a1546dd32f 100644 --- a/ThirdParty/Ert/lib/util/buffer.c +++ b/ThirdParty/Ert/lib/util/buffer.cpp @@ -23,11 +23,11 @@ #include #include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include @@ -272,7 +272,7 @@ void buffer_fseek(buffer_type * buffer , ssize_t offset , int whence) { a buffer with content_size == 20 we can seek to position 20. */ - if ((new_pos >= 0) && (new_pos <= buffer->content_size)) + if ((new_pos >= 0) && (new_pos <= (ssize_t)buffer->content_size)) buffer->pos = new_pos; else util_abort("%s: tried to seek to position:%ld - outside of bounds: [0,%d) \n", @@ -839,7 +839,7 @@ void buffer_fwrite_string(buffer_type * buffer , const char * string) { void buffer_fprintf(const buffer_type * buffer, const char * fmt, FILE * stream) { - int index=0; + size_t index=0; size_t offset = 0; while (true) { char fmt_char = fmt[index]; @@ -891,7 +891,7 @@ static size_t __compress_bound (size_t sourceLen) Return value is the size (in bytes) of the compressed buffer. */ size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t byte_size) { - size_t compressed_size = 0; + unsigned long compressed_size = 0; bool abort_on_error = true; buffer->content_size = buffer->pos; /* Invalidating possible buffer content coming after the compressed content; that is uninterpretable anyway. */ @@ -916,7 +916,7 @@ size_t buffer_fwrite_compressed(buffer_type * buffer, const void * ptr , size_t */ size_t buffer_fread_compressed(buffer_type * buffer , size_t compressed_size , void * target_ptr , size_t target_size) { size_t remaining_size = buffer->content_size - buffer->pos; - size_t uncompressed_size = target_size; + unsigned long uncompressed_size = target_size; if (remaining_size < compressed_size) util_abort("%s: trying to read beyond end of buffer\n",__func__); diff --git a/ThirdParty/Ert/lib/util/ecl_version.c b/ThirdParty/Ert/lib/util/ecl_version.cpp similarity index 93% rename from ThirdParty/Ert/lib/util/ecl_version.c rename to ThirdParty/Ert/lib/util/ecl_version.cpp index 664fa9efd2..24acac01e9 100644 --- a/ThirdParty/Ert/lib/util/ecl_version.c +++ b/ThirdParty/Ert/lib/util/ecl_version.cpp @@ -1,5 +1,5 @@ -#include -#include +#include +#include #define xstr(s) #s #define str(s) xstr(s) diff --git a/ThirdParty/Ert/lib/util/hash.c b/ThirdParty/Ert/lib/util/hash.cpp similarity index 78% rename from ThirdParty/Ert/lib/util/hash.c rename to ThirdParty/Ert/lib/util/hash.cpp index 2062537f76..60b62b6590 100644 --- a/ThirdParty/Ert/lib/util/hash.c +++ b/ThirdParty/Ert/lib/util/hash.cpp @@ -23,19 +23,13 @@ #include #include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_PTHREAD -#include -typedef pthread_rwlock_t lock_type; -#else -typedef int lock_type; -#endif +#include +#include +#include +#include +#include +#include + #ifdef __cplusplus extern "C" { @@ -71,8 +65,6 @@ struct hash_struct { double resize_fill; hash_sll_type **table; hashf_type *hashf; - - lock_type rwlock; }; @@ -83,54 +75,12 @@ typedef struct hash_sort_node { } hash_sort_type; -/*****************************************************************/ -/* locking */ -/*****************************************************************/ -#ifdef HAVE_PTHREAD - -static void __hash_rdlock(hash_type * hash) { - int lock_error = pthread_rwlock_tryrdlock( &hash->rwlock ); - if (lock_error != 0) - util_abort("%s: did not get hash->read_lock - fix locking in calling scope\n",__func__); -} - - -static void __hash_wrlock(hash_type * hash) { - int lock_error = pthread_rwlock_trywrlock( &hash->rwlock ); - if (lock_error != 0) - util_abort("%s: did not get hash->write_lock - fix locking in calling scope\n",__func__); -} - - -static void __hash_unlock( hash_type * hash) { - pthread_rwlock_unlock( &hash->rwlock ); -} - - -static void LOCK_DESTROY( lock_type * rwlock ) { - pthread_rwlock_destroy( rwlock ); -} - -static void LOCK_INIT( lock_type * rwlock ) { - pthread_rwlock_init( rwlock , NULL); -} - -#else - -static void __hash_rdlock(hash_type * hash) {} -static void __hash_wrlock(hash_type * hash) {} -static void __hash_unlock(hash_type * hash) {} -static void LOCK_DESTROY(lock_type * rwlock) {} -static void LOCK_INIT(lock_type * rwlock) {} - -#endif - /*****************************************************************/ /* Low level access functions */ /*****************************************************************/ -static void * __hash_get_node_unlocked(const hash_type *__hash , const char *key, bool abort_on_error) { +static void * __hash_get_node(const hash_type *__hash , const char *key, bool abort_on_error) { hash_type * hash = (hash_type *) __hash; /* The net effect is no change - but .... ?? */ hash_node_type * node = NULL; { @@ -146,23 +96,6 @@ static void * __hash_get_node_unlocked(const hash_type *__hash , const char *key } -/* - This function looks up a hash_node from the hash. This is the common - low-level function to get content from the hash. The function takes - read-lock which is held during execution. - - Would strongly preferred that the hash_type * was const - but that is - difficult due to locking requirements. -*/ - -static void * __hash_get_node(const hash_type *hash_in , const char *key, bool abort_on_error) { - hash_node_type * node; - hash_type * hash = (hash_type *)hash_in; - __hash_rdlock( hash ); - node = (hash_node_type*)__hash_get_node_unlocked(hash , key , abort_on_error); - __hash_unlock( hash ); - return node; -} static node_data_type * hash_get_node_data(const hash_type *hash , const char *key) { @@ -215,46 +148,37 @@ void hash_resize(hash_type *hash, int new_size) { /** - This is the low-level function for inserting a hash node. This - function takes a write-lock which is held during the execution of - the function. + This is the low-level function for inserting a hash node. */ static void __hash_insert_node(hash_type *hash , hash_node_type *node) { - __hash_wrlock( hash ); + uint32_t table_index = hash_node_get_table_index(node); { - uint32_t table_index = hash_node_get_table_index(node); - { - /* - If a node with the same key already exists in the table - it is removed. - */ - hash_node_type *existing_node = (hash_node_type*)__hash_get_node_unlocked(hash , hash_node_get_key(node) , false); - if (existing_node != NULL) { - hash_sll_del_node(hash->table[table_index] , existing_node); - hash->elements--; - } + /* + If a node with the same key already exists in the table + it is removed. + */ + hash_node_type *existing_node = (hash_node_type*)__hash_get_node(hash , hash_node_get_key(node) , false); + if (existing_node != NULL) { + hash_sll_del_node(hash->table[table_index] , existing_node); + hash->elements--; } - - hash_sll_add_node(hash->table[table_index] , node); - hash->elements++; - if ((1.0 * hash->elements / hash->size) > hash->resize_fill) - hash_resize(hash , hash->size * 2); } - __hash_unlock( hash ); + + hash_sll_add_node(hash->table[table_index] , node); + hash->elements++; + if ((1.0 * hash->elements / hash->size) > hash->resize_fill) + hash_resize(hash , hash->size * 2); } /** - This function deletes a node from the hash_table. Observe that this - function does *NOT* do any locking - it is the repsonsibility of - the calling functions: hash_del() and hash_clear() to take the - necessary write lock. + This function deletes a node from the hash_table. */ -static void hash_del_unlocked__(hash_type *hash , const char *key) { +static void hash_del__(hash_type *hash , const char *key) { const uint32_t global_index = hash->hashf(key , strlen(key)); const uint32_t table_index = (global_index % hash->size); hash_node_type *node = hash_sll_get(hash->table[table_index] , global_index , key); @@ -297,40 +221,32 @@ static hash_node_type * hash_internal_iter_next(const hash_type *hash , const ha This is the low level function which traverses a hash table and allocates a char ** list of keys. - It takes a read-lock which is held during the execution of the - function. The locking guarantees that the list of keys is valid - when this function is exited, but the the hash table can be - subsequently updated. - If the hash table is empty NULL is returned. */ -static char ** hash_alloc_keylist__(hash_type *hash , bool lock) { +static char ** hash_alloc_keylist__(const hash_type *hash) { char **keylist; - if (lock) __hash_rdlock( hash ); - { - if (hash->elements > 0) { - int i = 0; - hash_node_type *node = NULL; - keylist = (char**)calloc(hash->elements , sizeof *keylist); - { - uint32_t i = 0; - while (i < hash->size && hash_sll_empty(hash->table[i])) - i++; - - if (i < hash->size) - node = hash_sll_get_head(hash->table[i]); - } - - while (node != NULL) { - const char *key = hash_node_get_key(node); - keylist[i] = util_alloc_string_copy(key); - node = hash_internal_iter_next(hash , node); + if (hash->elements > 0) { + int i = 0; + hash_node_type *node = NULL; + keylist = (char**)calloc(hash->elements , sizeof *keylist); + { + uint32_t i = 0; + while (i < hash->size && hash_sll_empty(hash->table[i])) i++; - } - } else keylist = NULL; - } - if (lock) __hash_unlock( hash ); + + if (i < hash->size) + node = hash_sll_get_head(hash->table[i]); + } + + while (node != NULL) { + const char *key = hash_node_get_key(node); + keylist[i] = util_alloc_string_copy(key); + node = hash_internal_iter_next(hash , node); + i++; + } + } else + keylist = NULL; return keylist; } @@ -420,9 +336,7 @@ double hash_get_double(const hash_type * hash , const char * key) { /*****************************************************************/ void hash_del(hash_type *hash , const char *key) { - __hash_wrlock( hash ); - hash_del_unlocked__(hash , key); - __hash_unlock( hash ); + hash_del__(hash , key); } /** @@ -431,28 +345,21 @@ void hash_del(hash_type *hash , const char *key) { */ void hash_safe_del(hash_type * hash , const char * key) { - __hash_wrlock( hash ); - if (__hash_get_node_unlocked(hash , key , false)) - hash_del_unlocked__(hash , key); - __hash_unlock( hash ); + if (__hash_get_node(hash , key , false)) + hash_del__(hash , key); } void hash_clear(hash_type *hash) { - __hash_wrlock( hash ); - { - int old_size = hash_get_size(hash); - if (old_size > 0) { - char **keyList = hash_alloc_keylist__( hash , false); - int i; - for (i=0; i < old_size; i++) { - hash_del_unlocked__(hash , keyList[i]); - free(keyList[i]); - } - free(keyList); + int old_size = hash_get_size(hash); + if (old_size > 0) { + char **keyList = hash_alloc_keylist__( hash ); + for (int i=0; i < old_size; i++) { + hash_del__(hash , keyList[i]); + free(keyList[i]); } + free(keyList); } - __hash_unlock( hash ); } @@ -512,8 +419,6 @@ static hash_type * __hash_alloc(int size, double resize_fill , hashf_type *hashf hash->table = hash_sll_alloc_table(hash->size); hash->elements = 0; hash->resize_fill = resize_fill; - LOCK_INIT( &hash->rwlock ); - return hash; } @@ -522,11 +427,6 @@ hash_type * hash_alloc() { return __hash_alloc(HASH_DEFAULT_SIZE , 0.50 , hash_index); } -// Purely a helper in the process of removing the internal locking -// in the hash implementation. -hash_type * hash_alloc_unlocked() { - return __hash_alloc(HASH_DEFAULT_SIZE , 0.50 , hash_index); -} UTIL_SAFE_CAST_FUNCTION( hash , HASH_TYPE_ID) @@ -538,7 +438,6 @@ void hash_free(hash_type *hash) { for (i=0; i < hash->size; i++) hash_sll_free(hash->table[i]); free(hash->table); - LOCK_DESTROY( &hash->rwlock ); free(hash); } @@ -548,13 +447,13 @@ void hash_free__(void * void_hash) { } -char ** hash_alloc_keylist(hash_type *hash) { - return hash_alloc_keylist__(hash , true); +char ** hash_alloc_keylist(const hash_type *hash) { + return hash_alloc_keylist__(hash); } -stringlist_type * hash_alloc_stringlist(hash_type * hash) { +stringlist_type * hash_alloc_stringlist(const hash_type * hash) { stringlist_type * stringlist = stringlist_alloc_new(); - char ** keylist = hash_alloc_keylist__(hash , true); + char ** keylist = hash_alloc_keylist__(hash); int i; for (i = 0; i < hash_get_size( hash ); i++) stringlist_append_owned_ref( stringlist , keylist[i] ); @@ -684,7 +583,7 @@ static int hash_sortlist_cmp(const void *_p1 , const void *_p2) { } -static char ** __hash_alloc_ordered_keylist(hash_type *hash , int ( hash_get_cmp_value) (const void * )) { +static char ** __hash_alloc_ordered_keylist(const hash_type *hash , int ( hash_get_cmp_value) (const void * )) { int i; char **sorted_keylist; char **tmp_keylist = hash_alloc_keylist(hash); @@ -705,7 +604,7 @@ static char ** __hash_alloc_ordered_keylist(hash_type *hash , int ( hash_get_cmp } -char ** hash_alloc_sorted_keylist(hash_type *hash , int ( hash_get_cmp_value) (const void *)) { +char ** hash_alloc_sorted_keylist(const hash_type *hash , int ( hash_get_cmp_value) (const void *)) { char ** key_list; key_list = __hash_alloc_ordered_keylist(hash , hash_get_cmp_value); @@ -722,7 +621,7 @@ static int key_cmp(const void *_s1 , const void *_s2) { } -static char ** __hash_alloc_key_sorted_list(hash_type *hash, int (*cmp) (const void * , const void *)) { +static char ** __hash_alloc_key_sorted_list(const hash_type *hash, int (*cmp) (const void * , const void *)) { char **keylist = hash_alloc_keylist(hash); qsort(keylist , hash_get_size(hash) , sizeof *keylist , cmp); @@ -731,7 +630,7 @@ static char ** __hash_alloc_key_sorted_list(hash_type *hash, int (*cmp) (const v -char ** hash_alloc_key_sorted_list(hash_type * hash, int (*cmp) (const void *, const void *)) +char ** hash_alloc_key_sorted_list(const hash_type * hash, int (*cmp) (const void *, const void *)) { char ** key_list; @@ -742,7 +641,7 @@ char ** hash_alloc_key_sorted_list(hash_type * hash, int (*cmp) (const void *, c -bool hash_key_list_compare(hash_type * hash1, hash_type * hash2) +bool hash_key_list_compare(const hash_type * hash1, const hash_type * hash2) { bool has_equal_keylist; int i,size1, size2; diff --git a/ThirdParty/Ert/lib/util/hash_node.c b/ThirdParty/Ert/lib/util/hash_node.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/hash_node.c rename to ThirdParty/Ert/lib/util/hash_node.cpp index 4d9f6bbbf5..c77b19f993 100644 --- a/ThirdParty/Ert/lib/util/hash_node.c +++ b/ThirdParty/Ert/lib/util/hash_node.cpp @@ -22,9 +22,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/hash_sll.c b/ThirdParty/Ert/lib/util/hash_sll.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/hash_sll.c rename to ThirdParty/Ert/lib/util/hash_sll.cpp index a91b683be6..569d59f948 100644 --- a/ThirdParty/Ert/lib/util/hash_sll.c +++ b/ThirdParty/Ert/lib/util/hash_sll.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/lars.c b/ThirdParty/Ert/lib/util/lars.c deleted file mode 100644 index f7585904b9..0000000000 --- a/ThirdParty/Ert/lib/util/lars.c +++ /dev/null @@ -1,448 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'lars.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#define LARS_TYPE_ID 77125439 - -struct lars_struct { - UTIL_TYPE_ID_DECLARATION; - matrix_type * X; - matrix_type * Y; - bool data_owner; - double Y0; - matrix_type * beta0; - - matrix_type * beta; - matrix_type * X_norm; - matrix_type * X_mean; - double Y_mean; -}; - - - -static lars_type * lars_alloc__() { - lars_type * lars = (lars_type*)util_malloc( sizeof * lars ); - UTIL_TYPE_ID_INIT( lars , LARS_TYPE_ID ); - lars->X = NULL; - lars->Y = NULL; - - lars->X_norm = NULL; - lars->X_mean = NULL; - lars->beta = NULL; - lars->beta0 = NULL; - lars->Y = 0; - - return lars; -} - -lars_type * lars_alloc1( int nsample , int nvars) { - lars_type * lars = lars_alloc__(); - lars->X = matrix_alloc( nsample , nvars ); - lars->Y = matrix_alloc( nsample , 1 ); - lars->data_owner = true; - return lars; -} - - -lars_type * lars_alloc2( matrix_type * X , matrix_type * Y , bool internal_copy ) { - lars_type * lars = lars_alloc__(); - if (internal_copy) { - lars->X = matrix_alloc_copy( X ); - lars->Y = matrix_alloc_copy( Y ); - lars->data_owner = true; - } else { - lars->X = X; - lars->Y = Y; - lars->data_owner = false; - } - return lars; -} - -int lars_get_sample( const lars_type * lars ) { - return matrix_get_rows( lars->X ); -} - - -int lars_get_nvar( const lars_type * lars ) { - return matrix_get_columns( lars->X ); -} - - -void lars_isetX( lars_type * lars, int sample, int var , double value) { - matrix_iset( lars->X , sample , var , value ); -} - -void lars_isetY( lars_type * lars, int sample, double value) { - matrix_iset( lars->Y , sample , 0 , value ); -} - -#define MATRIX_SAFE_FREE( m ) if (m != NULL) matrix_free( m ) -void lars_free( lars_type * lars ) { - - if (lars->data_owner) { - MATRIX_SAFE_FREE( lars->X ); - MATRIX_SAFE_FREE( lars->Y ); - } - MATRIX_SAFE_FREE( lars->X_norm ); - MATRIX_SAFE_FREE( lars->X_mean ); - MATRIX_SAFE_FREE( lars->beta ); - MATRIX_SAFE_FREE( lars->beta0 ); - - free( lars ); -} -#undef MATRIX_SAFE_FREE - -/*****************************************************************/ - -static double sgn(double x) { - return copysign(1 , x); // C99 -} - - -static void lars_estimate_init( lars_type * lars, matrix_type * X , matrix_type * Y) { - int nvar = matrix_get_columns( lars->X ); - - matrix_assign( X , lars->X ); - matrix_assign( Y , lars->Y ); - if (lars->X_norm != NULL) - matrix_free( lars->X_norm ); - lars->X_norm = matrix_alloc(1 , nvar ); - - if (lars->X_mean != NULL) - matrix_free( lars->X_mean ); - lars->X_mean = matrix_alloc(1 , nvar ); - - if (lars->beta != NULL) - matrix_free( lars->beta ); - lars->beta = matrix_alloc( nvar , nvar ); - lars->Y_mean = regression_scale( X , Y , lars->X_mean , lars->X_norm); -} - - -double lars_getY0( const lars_type * lars) { - return lars->Y0; -} - -double lars_iget_beta( const lars_type * lars , int index) { - return matrix_iget( lars->beta0 , index , 0 ); -} - - - -void lars_select_beta( lars_type * lars , int beta_index) { - int nvars = matrix_get_rows( lars->beta ); - if (lars->beta0 == NULL) - lars->beta0 = matrix_alloc( nvars , 1 ); - { - matrix_type * beta_vector = matrix_alloc( nvars , 1 ); - matrix_copy_column( beta_vector , lars->beta , 0 , beta_index ); - lars->Y0 = regression_unscale( beta_vector , lars->X_norm , lars->X_mean , lars->Y_mean , lars->beta0 ); - matrix_free( beta_vector ); - } -} - - - -/* - The algorithm can very briefly be summarized as: - - 1. Determine the covariate with greatest correlation to the data and - add this covariate to the model. In the current implementation the - correlations are stored in the matrix @C and the greatest - correlation is stored in the scalar variable @maxC. - - 2. Determine an update direction in the set of active covariates - which is equiangular to all covariates. - - 3. Determine the step length @gamma - which is the exact step length - before a new covariate will enter the active set at the current - correlation level. - - 4. Update the beta estimate and the current 'location' mu. -*/ - -void lars_estimate(lars_type * lars , int max_vars , double max_beta , bool verbose) { - int nvars = matrix_get_columns( lars->X ); - int nsample = matrix_get_rows( lars->X ); - matrix_type * X = matrix_alloc( nsample, nvars ); // Allocate local X and Y variables - matrix_type * Y = matrix_alloc( nsample, 1 ); // which will hold the normalized data - lars_estimate_init( lars , X , Y); // during the estimation process. - { - matrix_type * G = matrix_alloc_gram( X , true ); - matrix_type * mu = matrix_alloc( nsample , 1 ); - matrix_type * C = matrix_alloc( nvars , 1 ); - matrix_type * Y_mu = matrix_alloc_copy( Y ); - int_vector_type * active_set = int_vector_alloc(0,0); - int_vector_type * inactive_set = int_vector_alloc(0,0); - int active_size; - - - if ((max_vars <= 0) || (max_vars > nvars)) - max_vars = nvars; - - { - int i; - for (i=0; i < nvars; i++) - int_vector_iset( inactive_set , i , i ); - } - matrix_set( mu , 0 ); - - while (true) { - double maxC = 0; - - /* - The first step is to calculate the correlations between the - covariates, and the current residual. All the currently inactive - covariates are searched; the covariate with the greatest - correlation with (Y - mu) is selected and added to the active set. - */ - matrix_sub( Y_mu , Y , mu ); // Y_mu = Y - mu - matrix_dgemm( C , X , Y_mu , true , false , 1.0 , 0); // C = X' * Y_mu - { - int i; - int max_set_index = 0; - - for (i=0; i < int_vector_size( inactive_set ); i++) { - int set_index = i; - int var_index = int_vector_iget( inactive_set , set_index ); - double value = fabs( matrix_iget(C , var_index , 0) ); - if (value > maxC) { - maxC = value; - max_set_index = set_index; - } - } - /* - Remove element corresponding to max_set_index from the - inactive set and add it to the active set: - */ - int_vector_append( active_set , int_vector_idel( inactive_set , max_set_index )); - } - active_size = int_vector_size( active_set ); - /* - Now we have calculated the correlations between all the - covariates and the current residual @Y_mu. The correlations are - stored in the matrix @C. The value of the maximum correlation is - stored in @maxC. - - Based on the value of @maxC we have added one new covariate to - the model, technically by moving the index from @inactive_set to - @active_set. - */ - - /*****************************************************************/ - - - { - matrix_type * weights = matrix_alloc( active_size , 1); - double scale; - - /*****************************************************************/ - /* This scope should compute and initialize the variables - @weights and @scale. */ - { - matrix_type * subG = matrix_alloc( active_size , active_size ); - matrix_type * STS = matrix_alloc( active_size , active_size ); - matrix_type * sign_vector = matrix_alloc( active_size , 1); - int i , j; - - /* - STS = S' o S where 'o' is the Schur product and S is given - by: - - [ s1 s2 s3 s4 ] - S = [ s1 s2 s3 s4 ] - [ s1 s2 s3 s4 ] - [ s1 s2 s3 s4 ] - - Where si is the sign of the correlation between (active) - variable 'i' and Y_mu. - */ - - - for (i=0; i < active_size ; i++) { - int vari = int_vector_iget( active_set , i ); - double signi = sgn( matrix_iget( C , vari , 0)); - matrix_iset( sign_vector , i , 0 , signi ); - for (j=0; j < active_size; j++) { - int varj = int_vector_iget( active_set , j ); - double signj = sgn( matrix_iget( C , varj , 0)); - - matrix_iset( STS , i , j , signi * signj ); - } - } - - // Extract the elements from G corresponding to active indices and - // copy to the matrix subG: - for (i=0; i < active_size ; i++) { - int ii = int_vector_iget( active_set , i ); - for (j=0; j < active_size; j++) { - int jj = int_vector_iget( active_set , j ); - - matrix_iset( subG , i , j , matrix_iget(G , ii , jj)); - } - } - - // Weights - matrix_inplace_mul( subG , STS ); - matrix_inv( subG ); - - { - matrix_type * ones = matrix_alloc( active_size , 1 ); - matrix_type * GA1 = matrix_alloc( active_size , 1 ); - - matrix_set( ones , 1.0 ); - matrix_matmul( GA1 , subG , ones ); - scale = 1.0 / sqrt( matrix_get_column_sum( GA1 , 0 )); - - matrix_mul( weights , GA1 , sign_vector ); - matrix_scale( weights , scale ); - - matrix_free( GA1 ); - matrix_free( ones ); - } - - matrix_free( sign_vector ); - matrix_free( subG ); - matrix_free( STS ); - } - - /******************************************************************/ - /* The variables weight and scale have been calculated, proceed - to calculate the step length @gamma. */ - { - int i; - double gamma; - - { - matrix_type * u = matrix_alloc( nsample , 1 ); - int j; - - for (i=0; i < nsample; i++) { - double row_sum = 0; - for (j =0; j < active_size; j++) - row_sum += matrix_iget( X , i , int_vector_iget( active_set , j)) * matrix_iget(weights , j , 0 ); - - matrix_iset( u , i , 0 , row_sum ); - } - - gamma = maxC / scale; - if (active_size < matrix_get_columns( X )) { - matrix_type * equi_corr = matrix_alloc( nvars , 1 ); - matrix_dgemm( equi_corr , X , u , true , false , 1.0 , 0); // equi_corr = X'·u - for (i=0; i < (nvars - active_size); i++) { - int var_index = int_vector_iget( inactive_set , i ); - double gamma1 = (maxC - matrix_iget(C , var_index , 0 )) / ( scale - matrix_iget( equi_corr , var_index , 0)); - double gamma2 = (maxC + matrix_iget(C , var_index , 0 )) / ( scale + matrix_iget( equi_corr , var_index , 0)); - - if ((gamma1 > 0) && (gamma1 < gamma)) - gamma = gamma1; - - if ((gamma2 > 0) && (gamma2 < gamma)) - gamma = gamma2; - - } - matrix_free( equi_corr ); - } - /* Update the current estimated 'location' mu. */ - matrix_scale( u , gamma ); - matrix_inplace_add( mu , u ); - matrix_free( u ); - } - - /* - We have calculated the step length @gamma, and the @weights. Update the @beta matrix. - */ - for (i=0; i < active_size; i++) - matrix_iset( lars->beta , int_vector_iget( active_set , i ) , active_size - 1 , gamma * matrix_iget( weights , i , 0)); - - if (active_size > 1) - for (i=0; i < nvars; i++) - matrix_iadd( lars->beta , i , active_size - 1 , matrix_iget( lars->beta , i , active_size - 2)); - - matrix_free( weights ); - } - } - - if (active_size == max_vars) - break; - - if (max_beta > 0) { - double beta_norm2 = matrix_get_column_abssum( lars->beta , active_size - 1 ); - if (beta_norm2 > max_beta) { - // We stop - we will use an interpolation between this beta estimate and - // the previous, to ensure that the |beta| = max_beta criteria is satisfied. - if (active_size >= 2) { - double beta_norm1 = matrix_get_column_abssum( lars->beta , active_size - 2 ); - double s = (max_beta - beta_norm1)/(beta_norm2 - beta_norm1); - { - int j; - for (j=0; j < nvars; j++) { - double beta1 = matrix_iget( lars->beta , j , active_size - 2 ); - double beta2 = matrix_iget( lars->beta , j , active_size - 1 ); - matrix_iset( lars->beta , j , active_size - 1 , beta1 + s*(beta2 - beta1)); - } - } - } - break; - } - } - } - matrix_free( G ); - matrix_free( mu ); - matrix_free( C ); - matrix_free( Y_mu ); - int_vector_free( active_set ); - int_vector_free( inactive_set ); - matrix_resize( lars->beta , nvars , active_size , true ); - if (verbose) - matrix_pretty_fprint( lars->beta , "beta" , "%12.5f" , stdout ); - lars_select_beta( lars , active_size - 1); - } - matrix_free( X ); - matrix_free( Y ); -} - - -double lars_eval1( const lars_type * lars , const matrix_type * x) { - return lars->Y0 + matrix_row_column_dot_product( x , 0 , lars->beta0 , 0 ); -} - - -double lars_eval2( const lars_type * lars , double * x) { - matrix_type * x_view = matrix_alloc_view( x , 1 , matrix_get_columns( lars->X_mean )); - double y = lars_eval1( lars , x_view ); - matrix_free( x_view ); - return y; -} - - - - - diff --git a/ThirdParty/Ert/lib/util/log.c b/ThirdParty/Ert/lib/util/log.c deleted file mode 100644 index 7e74ebc28b..0000000000 --- a/ThirdParty/Ert/lib/util/log.c +++ /dev/null @@ -1,253 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'log.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ert/util/build_config.h" - -#ifdef HAVE_FSYNC -#include -#endif - -#ifdef HAVE_PTHREAD -#include -#endif - -#include -#include - -struct log_struct { - char * filename; - FILE * stream; - int fd; - int log_level; - int msg_count; -#ifdef HAVE_PTHREAD - pthread_mutex_t mutex; -#endif -}; - - - -static void log_delete_empty(const log_type * logh) { - if (logh->filename && util_file_exists( logh->filename ) ) { - size_t file_size = util_file_size( logh->filename ); - if (file_size == 0) - remove( logh->filename ); - } -} - -void log_reopen(log_type *logh , const char *filename) { - if (logh->stream != NULL) { /* Close the existing file descriptor. */ - fclose( logh->stream ); - log_delete_empty( logh ); - } - - logh->filename = util_realloc_string_copy( logh->filename , filename ); -#ifdef HAVE_PTHREAD - pthread_mutex_lock( &logh->mutex ); -#endif - - if (filename != NULL) { - logh->stream = util_mkdir_fopen( filename , "a+"); - logh->fd = fileno( logh->stream ); - } else { /* It is ~OK to open a log with NULL filename, but then - log_reopen() with a VALID filename must be - called before it is actually used. */ - logh->stream = NULL; - logh->fd = -1; - } - logh->msg_count = 0; -#ifdef HAVE_PTHREAD - pthread_mutex_unlock( &logh->mutex ); -#endif -} - - -const char * log_get_filename( const log_type * logh ) { - return logh->filename; -} - -int log_get_msg_count( const log_type * logh) { - return logh->msg_count; -} - -int log_get_level( const log_type * logh) { - return logh->log_level; -} - -/** - * If an incoming message is below or equal to the configured log_level, it is included. So a high log_level will - * include more messages. - */ -void log_set_level( log_type * logh , int log_level) { - logh->log_level = log_level; -} - - - -log_type * log_open( const char * filename , int log_level) { - log_type *logh; - - logh = (log_type*)util_malloc(sizeof *logh ); - - logh->msg_count = 0; - logh->log_level = log_level; - logh->filename = NULL; - logh->stream = NULL; -#ifdef HAVE_PTHREAD - pthread_mutex_init( &logh->mutex , NULL ); -#endif - if (filename != NULL && log_level > 0) - log_reopen( logh , filename); - - return logh; -} - - -/** - * The message_level is compared to the configured log_level. Low message_level means "more important". - */ -bool log_include_message(const log_type *logh , int message_level) { - if (message_level <= logh->log_level) - return true; - else - return false; -} - -/** - * Adds a string to the log if message_level is below the threshold. It is the callers duty to either free the string - * or make sure that it is a string literal. - */ -void log_add_message_str(log_type *logh, message_level_type message_level , const char* message){ - //The conversion to (char*) is safe since free_message=false - log_add_message(logh,message_level, NULL, (char*) message,false); -} - - -/** - If dup_stream != NULL the message (without the date/time header) is duplicated on this stream. -*/ -void log_add_message(log_type *logh, int message_level , FILE * dup_stream , char* message, bool free_message) { - if (log_include_message(logh,message_level)) { - - if (logh->stream == NULL) - util_abort("%s: logh->stream == NULL - must call log_reset_filename() first \n",__func__); - -#ifdef HAVE_PTHREAD - pthread_mutex_lock( &logh->mutex ); -#endif - { - struct tm time_fields; - time_t epoch_time; - - time(&epoch_time); - util_time_utc(&epoch_time , &time_fields); - - if (message != NULL) - fprintf(logh->stream,"%02d/%02d - %02d:%02d:%02d %s\n",time_fields.tm_mday, time_fields.tm_mon + 1, time_fields.tm_hour , time_fields.tm_min , time_fields.tm_sec , message); - else - fprintf(logh->stream,"%02d/%02d - %02d:%02d:%02d \n",time_fields.tm_mday, time_fields.tm_mon + 1, time_fields.tm_hour , time_fields.tm_min , time_fields.tm_sec); - - /** We duplicate the message to the stream 'dup_stream'. */ - if ((dup_stream != NULL) && (message != NULL)) - fprintf(dup_stream , "%s\n", message); - - log_sync( logh ); - logh->msg_count++; - } -#ifdef HAVE_PTHREAD - pthread_mutex_unlock( &logh->mutex ); -#endif - if (free_message) - free( message ); - } -} - - - - - -/** - * Adds a formated log message if message_level is below the threshold, fmt is expected to be the format string, - * and "..." contains any arguments to it. - */ -void log_add_fmt_message(log_type * logh , int message_level , FILE * dup_stream , const char * fmt , ...) { - if (log_include_message(logh,message_level)) { - char * message; - va_list ap; - va_start(ap , fmt); - message = util_alloc_sprintf_va( fmt , ap ); - log_add_message( logh , message_level , dup_stream , message , true); - va_end(ap); - } -} - - - - - - -/** - This function can be used to get low level to the FILE pointer of - the stream. To 'ensure' that the data actually hits the disk - you should call log_sync() after writing. - - It is your responsabiulity to avoid racing++ when using the - log_get_stream() function. -*/ - -FILE * log_get_stream(log_type * logh ) { - return logh->stream; -} - - -void log_sync(log_type * logh) { -#ifdef HAVE_FSYNC - fsync( logh->fd ); -#endif - util_fseek( logh->stream , 0 , SEEK_END ); -} - - - -void log_close( log_type * logh ) { - if ((logh->stream != stdout) && (logh->stream != stderr) && (logh->stream != NULL)) - fclose( logh->stream ); /* This closes BOTH the FILE * stream and the integer file descriptor. */ - - log_delete_empty( logh ); - util_safe_free( logh->filename ); - free( logh ); -} - - -bool log_is_open( const log_type * logh) { - if (logh->stream != NULL) - return true; - else - return false; -} diff --git a/ThirdParty/Ert/lib/util/lookup_table.c b/ThirdParty/Ert/lib/util/lookup_table.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/lookup_table.c rename to ThirdParty/Ert/lib/util/lookup_table.cpp index 0e0a139461..f6d0bdf640 100644 --- a/ThirdParty/Ert/lib/util/lookup_table.c +++ b/ThirdParty/Ert/lib/util/lookup_table.cpp @@ -19,10 +19,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include struct lookup_table_struct { bool data_owner; diff --git a/ThirdParty/Ert/lib/util/matrix.c b/ThirdParty/Ert/lib/util/matrix.c deleted file mode 100644 index 8d2b28111e..0000000000 --- a/ThirdParty/Ert/lib/util/matrix.c +++ /dev/null @@ -1,1751 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -/** - This is V E R Y S I M P L E matrix implementation. It is not - designed to be fast/efficient or anything. It is purely a minor - support functionality for the enkf program, and should N O T be - considered as general matrix functionality. -*/ - - - -/** - Many of matrix functions can potentially involve laaarge amounts of - memory. The functions: - - o matrix_alloc(), matrix_resize() and matrix_alloc_copy() will - abort with util_abort() if the memory requirements can not be - satisfied. - - o The corresponding functions matrix_safe_alloc(), - matrix_safe_resize() and matrix_safe_alloc_copy() will not abort, - instead NULL or an unchanged matrix will be returned. When using - these functons it is the responsability of the calling scope to - check return values. - - So the expression "safe" should be interpreted as 'can not abort' - - however the responsability of the calling scope is greater when it - comes to using these functions - things can surely blow up! -*/ - -#ifdef __cplusplus -extern "C" { -#endif - -#define MATRIX_TYPE_ID 712108 - -/*#define GET_INDEX(m,i,j) (m->row_stride * (i) + m->column_stride * (j))*/ - -/* - This GET_INDEX function has been forcely inlined for performance. -*/ -/*static size_t GET_INDEX( const matrix_type * m , size_t i , size_t j) { - return m->row_stride *i + m->column_stride *j; -}*/ - -static size_t MATRIX_DATA_SIZE( const matrix_type * m) { - size_t col = m->columns; - size_t stride = m->column_stride; - - return col*stride; -} - - - - -static void matrix_init_header(matrix_type * matrix , int rows , int columns , int row_stride , int column_stride) { - - if (!((column_stride * columns <= row_stride) || (row_stride * rows <= column_stride))) - util_abort("%s: invalid stride combination \n",__func__); - - matrix->data_size = 0; - matrix->alloc_rows = rows; - matrix->alloc_columns = columns; - matrix->row_stride = row_stride; - matrix->column_stride = column_stride; - - matrix_full_size( matrix ); -} - - -/** - This is the low-level function allocating storage. If the input - flag 'safe_mode' is equal to true, the function will return NULL if - the allocation fails, otherwise the function will abort() if the - allocation fails. - - Before returning all elements will be initialized to zero. - - 1. It is based on first free() of the original pointer, and then - subsequently calling malloc() to get new storage. This is to - avoid prohibitive temporary memory requirements during the - realloc() call. - - 2. If the malloc() fails the function will return NULL, i.e. you - will NOT keep the original data pointer. I.e. in this case the - matrix will be invalid. It is the responsability of the calling - scope to do the right thing. - - 3. realloc() functionality - i.e. keeping the original content of - the matrix is implemented at higher level. The memory layout of - the matrix will in general change anyway; so the promise made - by realloc() is not very interesting. -*/ - -static void matrix_realloc_data__( matrix_type * matrix , bool safe_mode ) { - if (matrix->data_owner) { - size_t data_size = MATRIX_DATA_SIZE( matrix ); - if (matrix->data_size == data_size) return; - if (matrix->data != NULL) - free(matrix->data); - - if (safe_mode) { - /* - If safe_mode == true it is 'OK' to fail in the allocation, - otherwise we use util_malloc() which will abort if the memory - is not available. - */ - matrix->data = (double*)malloc( sizeof * matrix->data * data_size ); - } else - matrix->data = (double*)util_malloc( sizeof * matrix->data * data_size ); - - - /* Initializing matrix content to zero. */ - if (matrix->data != NULL) { - size_t i; - for (i = 0; i < data_size; i++) - matrix->data[i] = 0; - } else - data_size = 0; - - /** - Observe that if the allocation failed the matrix will - be returned with data == NULL, and data_size == 0. - */ - matrix->data_size = data_size; - } else - util_abort("%s: can not manipulate memory when is not data owner\n",__func__); -} - - -UTIL_SAFE_CAST_FUNCTION( matrix , MATRIX_TYPE_ID ) - -/** - The matrix objecty is NOT ready for use after this function. -*/ -static matrix_type * matrix_alloc_empty( ) { - matrix_type * matrix = (matrix_type*)util_malloc( sizeof * matrix ); - UTIL_TYPE_ID_INIT( matrix , MATRIX_TYPE_ID ); - matrix->name = NULL; - return matrix; -} - -/* - The freshly allocated matrix is explicitly initialized to zero. If - the variable safe_mode equals true the function will return NULL if - the allocation of data fails, otherwise it will abort() if the - allocation fails. -*/ -static matrix_type * matrix_alloc_with_stride(int rows , int columns , int row_stride , int column_stride, bool safe_mode) { - matrix_type * matrix = NULL; - if ((rows > 0) && (columns > 0)) { - matrix = matrix_alloc_empty(); - matrix->data = NULL; - matrix->data_size = 0; - matrix_init_header( matrix , rows , columns , row_stride , column_stride); - matrix->data_owner = true; - matrix_realloc_data__( matrix , safe_mode ); - if (safe_mode) { - if (matrix->data == NULL) { - /* Allocation failed - we return NULL */ - matrix_free(matrix); - matrix = NULL; - } - } - } - return matrix; -} - - -void matrix_set_name( matrix_type * matrix , const char * name) { - matrix->name = util_realloc_string_copy( matrix->name , name ); -} - - -/** - This function will allocate a matrix object where the data is - shared with the 'src' matrix. A matrix allocated in this way can be - used with all the matrix_xxx functions, but you should be careful - when exporting the data pointer to e.g. lapack routines. -*/ - -matrix_type * matrix_alloc_shared(const matrix_type * src , int row , int column , int rows , int columns) { - if (((row + rows) > src->rows) || ((column + columns) > src->columns)) - util_abort("%s: Invalid matrix subsection src:[%d,%d] Offset:[%d,%d] SubSize:[%d,%d] \n", - __func__, - src->rows , src->columns, - row,column, - rows,columns); - - { - matrix_type * matrix = matrix_alloc_empty(); - - matrix_init_header( matrix , rows , columns , src->row_stride , src->column_stride); - matrix->data = &src->data[ GET_INDEX(src , row , column) ]; - matrix->data_owner = false; - - return matrix; - } -} - - -matrix_type * matrix_alloc_view(double * data , int rows , int columns) { - matrix_type * matrix = matrix_alloc_empty(); - - matrix_init_header( matrix , rows , columns , 1 , rows); - matrix->data = data; - matrix->data_owner = false; - - return matrix; -} - - -/** - This function will allocate a matrix structure; this matrix - structure will TAKE OWNERSHIP OF THE SUPPLIED DATA. This means that - it is (at the very best) highly risky to use the data pointer in - the calling scope after the matrix has been allocated. If the - supplied pointer is too small it is immediately realloced ( in - which case the pointer in the calling scope will be immediately - invalid). -*/ - -matrix_type * matrix_alloc_steal_data(int rows , int columns , double * data , int data_size) { - matrix_type * matrix = matrix_alloc_empty(); - matrix_init_header( matrix , rows , columns , 1 , rows ); - matrix->data_size = data_size; /* Can in general be different from rows * columns */ - matrix->data_owner = true; - matrix->data = data; - if (data_size < rows * columns) - matrix_realloc_data__(matrix , false); - - return matrix; -} - - - -/*****************************************************************/ - -static matrix_type * matrix_alloc__(int rows, int columns , bool safe_mode) { - return matrix_alloc_with_stride( rows , columns , 1 , rows , safe_mode ); /* Must be the stride (1,rows) to use the lapack routines. */ -} - -matrix_type * matrix_alloc(int rows, int columns) { - return matrix_alloc__( rows , columns , false ); -} - -matrix_type * matrix_safe_alloc(int rows, int columns) { - return matrix_alloc__( rows , columns , true ); -} - -matrix_type * matrix_alloc_identity(int dim) { - if (dim < 1) - util_abort("%s: identity matrix must have positive size. \n",__func__); - - matrix_type * idty = matrix_alloc(dim, dim); - for (int i = 0; i < dim; ++i) - matrix_iset(idty, i, i, 1); - return idty; -} - -/*****************************************************************/ - -/** - Will not respect strides - that is considered low level data - layout. -*/ -static matrix_type * matrix_alloc_copy__( const matrix_type * src , bool safe_mode) { - matrix_type * copy = matrix_alloc__( matrix_get_rows( src ), matrix_get_columns( src ) , safe_mode); - if (copy != NULL) - matrix_assign(copy , src); - return copy; -} - - -matrix_type * matrix_alloc_copy(const matrix_type * src) { - return matrix_alloc_copy__(src , false ); -} - -matrix_type * matrix_alloc_column_compressed_copy(const matrix_type * src, const bool_vector_type * mask) { - if (bool_vector_size( mask ) != matrix_get_columns( src )) - util_abort("%s: size mismatch. Src matrix has %d rows mask has:%d elements\n", __func__ , matrix_get_rows( src ) , bool_vector_size( mask )); - { - int target_columns = bool_vector_count_equal( mask , true ); - matrix_type * target = matrix_alloc( matrix_get_rows( src ) , target_columns ); - - matrix_column_compressed_memcpy( target , src , mask ); - return target; - } -} - - -void matrix_column_compressed_memcpy(matrix_type * target, const matrix_type * src, const bool_vector_type * mask) { - if (bool_vector_count_equal( mask , true ) != matrix_get_columns( target )) - util_abort("%s: size mismatch. \n",__func__); - - if (bool_vector_size( mask ) != matrix_get_columns( src)) - util_abort("%s: size mismatch. \n",__func__); - - { - int target_col = 0; - int src_col; - for (src_col = 0; src_col < bool_vector_size( mask ); src_col++) { - if (bool_vector_iget( mask , src_col)) { - matrix_copy_column( target , src , target_col , src_col); - target_col++; - } - } - } -} - - - -matrix_type * matrix_realloc_copy(matrix_type * T , const matrix_type * src) { - if (T == NULL) - return matrix_alloc_copy( src ); - else { - matrix_resize( T , src->rows , src->columns , false ); - matrix_assign( T , src ); - return T; - } -} - - - - -/** - Will return NULL if allocation of the copy failed. -*/ - -matrix_type * matrix_safe_alloc_copy(const matrix_type * src) { - return matrix_alloc_copy__(src , true); -} - -void matrix_copy_block( matrix_type * target_matrix , int target_row , int target_column , int rows , int columns, - const matrix_type * src_matrix , int src_row , int src_column) { - matrix_type * target_view = matrix_alloc_shared(target_matrix , target_row , target_column , rows , columns); - matrix_type * src_view = matrix_alloc_shared( src_matrix , src_row , src_column , rows , columns); - matrix_assign( target_view , src_view ); - matrix_free( target_view ); - matrix_free( src_view ); -} - -matrix_type * matrix_alloc_sub_copy( const matrix_type * src , int row_offset , int column_offset , int rows, int columns) { - matrix_type * copy = matrix_alloc( rows, columns ); - matrix_copy_block( copy , 0 , 0 , rows , columns , src , row_offset , column_offset ); - return copy; -} - - -/*****************************************************************/ - -static bool matrix_resize__(matrix_type * matrix , int rows , int columns , bool copy_content , bool safe_mode) { - if (!matrix->data_owner) - util_abort("%s: sorry - can not resize shared matrizes. \n",__func__); - { - bool resize_OK = true; - - if ((rows != matrix->rows) || (columns != matrix->columns)) { - int copy_rows = util_int_min( rows , matrix->rows ); - int copy_columns = util_int_min( columns , matrix->columns); - matrix_type * copy_view = NULL; - matrix_type * copy = NULL; - - if (copy_content) { - copy_view = matrix_alloc_shared( matrix , 0 , 0 , copy_rows , copy_columns); /* This is the part of the old matrix which should be copied over to the new. */ - copy = matrix_alloc_copy__( copy_view , safe_mode ); /* Now copy contains the part of the old matrix which should be copied over - with private storage. */ - } - { - int old_rows , old_columns, old_row_stride , old_column_stride; - matrix_get_dims( matrix , &old_rows , &old_columns , &old_row_stride , &old_column_stride); /* Storing the old header information - in case the realloc() fails. */ - - matrix_init_header(matrix , rows , columns , 1 , rows); /* Resetting the header for the matrix */ - matrix_realloc_data__(matrix , safe_mode); - if (matrix->data != NULL) { /* Realloc succeeded */ - if (copy_content) { - matrix_type * target_view = matrix_alloc_shared(matrix , 0 , 0 , copy_rows , copy_columns); - matrix_assign( target_view , copy); - matrix_free( target_view ); - } - } else { - /* Failed to realloc new storage; RETURNING AN INVALID MATRIX */ - matrix_init_header(matrix , old_rows , old_columns , old_row_stride , old_column_stride); - resize_OK = false; - } - } - - if (copy_content) { - matrix_free(copy_view); - matrix_free(copy); - } - } - return resize_OK; - } -} - - -/** - If copy content is true the content of the old matrix is carried - over to the new one, otherwise the new matrix is cleared. - - Will always return true (or abort). -*/ -bool matrix_resize(matrix_type * matrix , int rows , int columns , bool copy_content) { - return matrix_resize__(matrix , rows , columns , copy_content , false); -} - - -/** - Return true if the resize succeded, otherwise it will return false - and leave the matrix unchanged. When resize implies expanding a - dimension, the newly created elements will be explicitly - initialized to zero. - - If copy_content is set to false the new matrix will be fully - initialized to zero. -*/ - -bool matrix_safe_resize(matrix_type * matrix , int rows , int columns , bool copy_content) { - return matrix_resize__(matrix , rows , columns , copy_content , true); -} - - - -/** - This function will ensure that the matrix has at least 'rows' - rows. If the present matrix already has >= rows it will return - immediately, otherwise the matrix will be resized. -*/ - -void matrix_ensure_rows(matrix_type * matrix, int rows, bool copy_content) { - if (matrix->rows < rows) - matrix_resize( matrix , rows , matrix->columns , copy_content); -} - - - -/** - This function will reduce the size of the matrix. It will only - affect the headers, and not touch the actual memory of the matrix. -*/ - -void matrix_shrink_header(matrix_type * matrix , int rows , int columns) { - - if (rows <= matrix->rows) - matrix->rows = rows; - - if (columns <= matrix->columns) - matrix->columns = columns; - -} - - -void matrix_full_size( matrix_type * matrix ) { - matrix->rows = matrix->alloc_rows; - matrix->columns = matrix->alloc_columns; -} - - -/*****************************************************************/ - -static void matrix_free_content(matrix_type * matrix) { - if (matrix->data_owner) - util_safe_free(matrix->data); - util_safe_free( matrix->name ); -} - -void matrix_free(matrix_type * matrix) { - matrix_free_content( matrix ); - free(matrix); -} - - -void matrix_safe_free( matrix_type * matrix ) { - if (matrix != NULL) - matrix_free( matrix ); -} - - -/*****************************************************************/ -void matrix_pretty_fprint_submat(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream, int m, int M, int n, int N) { - int i,j; - - if (m<0 || m>M || M >= matrix->rows || n<0 || n>N || N >= matrix->columns) - util_abort("%s: matrix:%s not compatible with print subdimensions. \n",__func__ , matrix->name); - - fprintf(stream , "%s =" , name); - for (i=m; i < M; i++) { - fprintf(stream , " ["); - for (j=n; j < N; j++) - fprintf(stream , fmt , matrix_iget(matrix , i,j)); - fprintf(stream , "]\n"); - } -} -/*****************************************************************/ - -void matrix_pretty_fprint(const matrix_type * matrix , const char * name , const char * fmt , FILE * stream) { - int i,j; - for (i=0; i < matrix->rows; i++) { - - if (i == (matrix->rows / 2)) - fprintf(stream , "%s =" , name); - else { - int l; - for (l = 0; l < strlen(name) + 2; l++) - fprintf(stream , " "); - } - - fprintf(stream , " ["); - for (j=0; j < matrix->columns; j++) - fprintf(stream , fmt , matrix_iget(matrix , i,j)); - fprintf(stream , "]\n"); - } -} - - -void matrix_pretty_print(const matrix_type * matrix , const char * name , const char * fmt) { - matrix_pretty_fprint(matrix , name , fmt , stdout ); -} - - -void matrix_fprintf( const matrix_type * matrix , const char * fmt , FILE * stream ) { - int i,j; - for (i=0; i < matrix->rows; i++) { - for (j=0; j < matrix->columns; j++) - fprintf(stream , fmt , matrix_iget( matrix , i , j)); - fprintf(stream , "\n"); - } -} - - -void matrix_dump_csv( const matrix_type * matrix ,const char * filename) { - FILE * stream = util_fopen(filename , "w"); - for (int i=0; i < matrix->rows; i++) { - for (int j=0; j < matrix->columns - 1; j++) - fprintf(stream , "%g, " , matrix_iget( matrix , i , j)); - fprintf(stream , "%g\n" , matrix_iget( matrix , i , matrix->columns - 1)); - } - fclose( stream ); -} - - -void matrix_fwrite(const matrix_type * matrix , FILE * stream) { - util_fwrite_int( matrix->rows , stream ); - util_fwrite_int( matrix->columns , stream ); - - if (matrix->column_stride == matrix->rows) - util_fwrite( matrix->data , sizeof * matrix->data , matrix->columns * matrix->rows , stream , __func__); - else { - int column; - for (column=0; column < matrix->columns; column++) { - if (matrix->row_stride == 1) { - const double * column_data = &matrix->data[ column * matrix->column_stride ]; - util_fwrite( column_data , sizeof * column_data , matrix->rows , stream , __func__); - } else { - int row; - for (row=0; row < matrix->rows; row++) - util_fwrite_double( matrix->data[ GET_INDEX( matrix , row , column )] , stream); - } - } - } -} - - -void matrix_fread(matrix_type * matrix , FILE * stream) { - int rows = util_fread_int( stream ); - int columns = util_fread_int( stream ); - - matrix_resize( matrix , rows , columns , false); - if (matrix->column_stride == matrix->rows) - util_fread( matrix->data , sizeof * matrix->data , matrix->columns * matrix->rows , stream , __func__); - else { - int column; - for (column=0; column < matrix->columns; column++) { - if (matrix->row_stride == 1) { - double * column_data = &matrix->data[ column * matrix->column_stride ]; - util_fread( column_data , sizeof * column_data , matrix->rows , stream , __func__); - } else { - int row; - for (row=0; row < matrix->rows; row++) - matrix->data[ GET_INDEX( matrix , row , column )] = util_fread_double( stream ); - } - } - } -} - -matrix_type * matrix_fread_alloc(FILE * stream) { - matrix_type * matrix = matrix_alloc(1,1); - matrix_fread(matrix , stream); - return matrix; -} - - -/** - [ a11 a12 ] - [ a21 a22 ] - - - - - row_major_order == true - ----------------------- - a_11 - a_12 - a_21 - a_22 - - - row_major_order == false - ----------------------- - a_11 - a_12 - a_21 - a_22 - - - The @orw_major_order parameter ONLY affects the layout on the file, - and NOT the memory layout of the matrix. -*/ - - -static void __fscanf_and_set( matrix_type * matrix , int row , int col , FILE * stream) { - double value; - if (fscanf(stream , "%lg" , &value) == 1) - matrix_iset( matrix , row , col , value ); - else - util_abort("%s: reading of matrix failed at row:%d col:%d \n",__func__ , row , col); -} - - -void matrix_fscanf_data( matrix_type * matrix , bool row_major_order , FILE * stream ) { - int row,col; - if (row_major_order) { - for (row = 0; row < matrix->columns; row++) { - for (col = 0; col < matrix->columns; col++) { - __fscanf_and_set( matrix , row , col ,stream); - } - } - } else { - for (row = 0; row < matrix->columns; row++) { - for (col = 0; col < matrix->columns; col++) { - __fscanf_and_set( matrix , row , col , stream); - } - } - } -} - - - -/*****************************************************************/ -/* Functions which manipulate one element in the matrix. */ - -static void matrix_assert_ij( const matrix_type * matrix , int i , int j) { - if ((i < 0) || (i >= matrix->rows) || (j < 0) || (j >= matrix->columns)) - util_abort("%s: (i,j) = (%d,%d) invalid. Matrix size: %d x %d \n",__func__ , i,j,matrix->rows , matrix->columns); -} - - -static void matrix_assert_equal_rows( const matrix_type * m1 , const matrix_type * m2) { - if (m1->rows != m2->rows) - util_abort("%s: size mismatch in binary matrix operation %d %d \n",__func__ , m1->rows , m2->rows); -} - - -static void matrix_assert_equal_columns( const matrix_type * m1 , const matrix_type * m2) { - if (m1->columns != m2->columns) - util_abort("%s: size mismatch in binary matrix operation %d %d \n",__func__ , m1->columns , m2->columns); -} - - -void matrix_iset(matrix_type * matrix , int i , int j, double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] = value; -} - - - -void matrix_iset_safe(matrix_type * matrix , int i , int j, double value) { - matrix_assert_ij( matrix , i , j ); - matrix_iset( matrix , i , j , value ); -} - - -double matrix_iget(const matrix_type * matrix , int i , int j) { - return matrix->data[ GET_INDEX(matrix , i, j) ]; -} - - -double matrix_iget_safe(const matrix_type * matrix , int i , int j) { - matrix_assert_ij( matrix , i , j ); - return matrix_iget( matrix , i , j ); -} - - -void matrix_iadd(matrix_type * matrix , int i , int j , double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] += value; -} - - -void matrix_isub(matrix_type * matrix , int i , int j , double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] -= value; -} - - -void matrix_imul(matrix_type * matrix , int i , int j , double value) { - matrix->data[ GET_INDEX(matrix , i,j) ] *= value; -} - - -/*****************************************************************/ -/* One scalar operating on all the elements in the matrix */ - -void matrix_set(matrix_type * matrix, double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix_iset(matrix , i , j , value); -} - - -void matrix_shift(matrix_type * matrix, double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix_iadd(matrix , i , j , value); -} - - -void matrix_scale(matrix_type * matrix, double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix_imul(matrix , i , j , value); -} - -/*****************************************************************/ -/* Functions working on rows & columns */ - -void matrix_set_many_on_column(matrix_type * matrix , int row_offset , int elements , const double * data , int column) { - if ((row_offset + elements) <= matrix->rows) { - if (matrix->row_stride == 1) /* Memory is continous ... */ - memcpy( &matrix->data[ GET_INDEX( matrix , row_offset , column) ] , data , elements * sizeof * data); - else { - int i; - for (i = 0; i < elements; i++) - matrix->data[ row_offset + GET_INDEX( matrix , i , column) ] = data[i]; - } - } else - util_abort("%s: range violation \n" , __func__); -} - -void matrix_set_column(matrix_type * matrix , const double * data , int column) { - matrix_set_many_on_column( matrix , 0 , matrix->rows , data , column ); -} - - -void matrix_set_const_column(matrix_type * matrix , const double value , int column) { - int row; - for (row = 0; row < matrix->rows; row++) - matrix->data[ GET_INDEX( matrix , row , column) ] = value; -} - - -void matrix_set_const_row(matrix_type * matrix , const double value , int row) { - int column; - for (column = 0; column < matrix->columns; column++) - matrix->data[ GET_INDEX( matrix , row , column) ] = value; -} - - -void matrix_copy_column(matrix_type * target_matrix, const matrix_type * src_matrix , int target_column, int src_column) { - matrix_assert_equal_rows( target_matrix , src_matrix ); - { - int row; - for(row = 0; row < target_matrix->rows; row++) - target_matrix->data[ GET_INDEX( target_matrix, row , target_column)] = src_matrix->data[ GET_INDEX( src_matrix, row, src_column)]; - } -} - - -void matrix_scale_column(matrix_type * matrix , int column , double scale_factor) { - int row; - for (row = 0; row < matrix->rows; row++) - matrix->data[ GET_INDEX( matrix , row , column) ] *= scale_factor; -} - -void matrix_scale_row(matrix_type * matrix , int row , double scale_factor) { - int column; - for (column = 0; column < matrix->columns; column++) - matrix->data[ GET_INDEX( matrix , row , column) ] *= scale_factor; -} - -void matrix_copy_row(matrix_type * target_matrix, const matrix_type * src_matrix , int target_row, int src_row) { - matrix_assert_equal_columns( target_matrix , src_matrix ); - { - int col; - for(col = 0; col < target_matrix->columns; col++) - target_matrix->data[ GET_INDEX( target_matrix , target_row , col)] = src_matrix->data[ GET_INDEX( src_matrix, src_row, col)]; - } -} - - -/*****************************************************************/ -/* Functions for dot products between rows/columns in matrices. */ - -double matrix_column_column_dot_product(const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2) { - if (m1->rows != m2->rows) - util_abort("%s: size mismatch \n",__func__); - - if (col1 >= m1->columns || col2 >= m2->columns) - util_abort("%s: size mismatch \n",__func__); - { - int row; - double sum = 0; - for( row = 0; row < m1->rows; row++) - sum += m1->data[ GET_INDEX(m1 , row , col1) ] * m2->data[ GET_INDEX(m2, row , col2) ]; - - return sum; - } -} - - -double matrix_row_column_dot_product(const matrix_type * m1 , int row1 , const matrix_type * m2 , int col2) { - if (m1->columns != m2->rows) - util_abort("%s: size mismatch: m1:[%d,%d] m2:[%d,%d] \n",__func__ , matrix_get_rows( m1 ) , matrix_get_columns( m1 ) , matrix_get_rows( m2 ) , matrix_get_columns( m2 )); - - { - int k; - double sum = 0; - for( k = 0; k < m1->columns; k++) - sum += m1->data[ GET_INDEX(m1 , row1 , k) ] * m2->data[ GET_INDEX(m2, k , col2) ]; - - return sum; - } -} - - - - -/*****************************************************************/ -/* Matrix - matrix operations */ - - -/* Implements assignement: A = B */ -void matrix_assign(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - if (A->row_stride == B->row_stride) { - if (A->columns == A->row_stride) /** Memory is just one continous block */ - memcpy( A->data , B->data , A->rows * A->columns * sizeof * A->data); - else { - /* Copying columns of data */ - for (j = 0; j < A->columns; j++) - memcpy( &A->data[ GET_INDEX(A , 0 , j)] , &B->data[ GET_INDEX(B , 0 , j) ] , A->rows * sizeof * A->data); - } - } else { - /* Copying element by element */ - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ]; - } - } else - util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d] \n",__func__ , A->rows , A->columns , B->rows , B->columns); -} - - - -void matrix_inplace_sub_column(matrix_type * A , const matrix_type * B, int colA , int colB) { - if ((A->rows == B->rows) && - (colA < A->columns) && - (colB < B->columns)) { - int row; - - for (row = 0; row < A->rows; row++) - A->data[ GET_INDEX(A , row , colA)] -= B->data[ GET_INDEX(B , row , colB)]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - -void matrix_inplace_add_column(matrix_type * A , const matrix_type * B, int colA , int colB) { - if ((A->rows == B->rows) && - (colA < A->columns) && - (colB < B->columns)) { - int row; - - for (row = 0; row < A->rows; row++) - A->data[ GET_INDEX(A , row , colA)] += B->data[ GET_INDEX(B , row , colB)]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - -/* Updates matrix A by adding in matrix B - elementwise. */ -void matrix_inplace_add(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] += B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/* Updates matrix A by multiplying in matrix B - elementwise - i.e. Schur product. */ -void matrix_inplace_mul(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] *= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/* - Schur product: A = B * C -*/ - -void matrix_mul( matrix_type * A , const matrix_type * B , const matrix_type * C) { - if ((A->rows == B->rows) && (A->columns == B->columns) && (A->rows == C->rows) && (A->columns == C->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ] * C->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - - -/* Updates matrix A by subtracting matrix B - elementwise. */ -void matrix_inplace_sub(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] -= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch A:[%d,%d] B:[%d,%d]\n",__func__ , - matrix_get_rows(A), - matrix_get_columns(A), - matrix_get_rows(B), - matrix_get_columns(B)); -} - - -/* Does the matrix operation: - - A = B - C - - elementwise. -*/ -void matrix_sub(matrix_type * A , const matrix_type * B , const matrix_type * C) { - if ((A->rows == B->rows) && (A->columns == B->columns) && (A->rows == C->rows) && (A->columns == C->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] = B->data[ GET_INDEX(B,i,j) ] - C->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - - - -/* Updates matrix A by dividing matrix B - elementwise. */ -void matrix_inplace_div(matrix_type * A , const matrix_type * B) { - if ((A->rows == B->rows) && (A->columns == B->columns)) { - int i,j; - - for (j = 0; j < A->columns; j++) - for (i=0; i < A->rows; i++) - A->data[ GET_INDEX(A,i,j) ] /= B->data[ GET_INDEX(B,i,j) ]; - - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/** - Observe that A and T should not overlap, i.e. the call - - matrix_transpose(X , X) - - will fail in mysterious ways. -*/ - -void matrix_transpose(const matrix_type * A , matrix_type * T) { - if ((A->columns == T->rows) && (A->rows == T->columns)) { - int i,j; - for (i=0; i < A->rows; i++) { - for (j=0; j < A->columns; j++) { - size_t src_index = GET_INDEX(A , i , j ); - size_t target_index = GET_INDEX(T , j , i ); - - T->data[ target_index ] = A->data[ src_index ]; - } - } - } else - util_abort("%s: size mismatch\n",__func__); -} - - -void matrix_inplace_transpose(matrix_type * A ) { - matrix_type * B = matrix_alloc_transpose( A ); - matrix_free_content( A ); - memcpy( A , B , sizeof * A ); - free( B ); -} - - - -matrix_type * matrix_alloc_transpose( const matrix_type * A) { - matrix_type * B = matrix_alloc( matrix_get_columns( A ) , matrix_get_rows( A )); - matrix_transpose( A , B ); - return B; -} - - - -/** - For this function to work the following must be satisfied: - - columns in A == rows in B == columns in B - - For general matrix multiplactions where A = B * C all have - different dimensions you can use matrix_matmul() (which calls the - BLAS routine dgemm()); -*/ - - -void matrix_inplace_matmul(matrix_type * A, const matrix_type * B) { - if ((A->columns == B->rows) && (B->rows == B->columns)) { - double * tmp = (double*)util_malloc( sizeof * A->data * A->columns ); - int i,j,k; - - for (i=0; i < A->rows; i++) { - - /* Clearing the tmp vector */ - for (k=0; k < B->rows; k++) - tmp[k] = 0; - - for (j=0; j < B->rows; j++) { - double scalar_product = 0; - for (k=0; k < A->columns; k++) - scalar_product += A->data[ GET_INDEX(A,i,k) ] * B->data[ GET_INDEX(B,k,j) ]; - - /* Assign first to tmp[j] */ - tmp[j] = scalar_product; - } - for (j=0; j < A->columns; j++) - A->data[ GET_INDEX(A , i, j) ] = tmp[j]; - } - free(tmp); - } else - util_abort("%s: size mismatch: A:[%d,%d] B:[%d,%d]\n",__func__ , matrix_get_rows(A) , matrix_get_columns(A) , matrix_get_rows(B) , matrix_get_columns(B)); -} - -/*****************************************************************/ -/* If the current build has a thread_pool implementation enabled a - proper matrix_implace_matmul_mt() function will be built, otherwise - only the serial version matrix_inplace_matmul() will be used. */ - - -#ifdef ERT_HAVE_THREAD_POOL - -static void * matrix_inplace_matmul_mt__(void * arg) { - - arg_pack_type * arg_pack = arg_pack_safe_cast( arg ); - int row_offset = arg_pack_iget_int( arg_pack , 0 ); - int rows = arg_pack_iget_int( arg_pack , 1 ); - matrix_type * A = (matrix_type*) arg_pack_iget_ptr( arg_pack , 2 ); - const matrix_type * B = (const matrix_type*)arg_pack_iget_const_ptr( arg_pack , 3 ); - - matrix_type * A_view = matrix_alloc_shared( A , row_offset , 0 , rows , matrix_get_columns( A )); - matrix_inplace_matmul( A_view , B ); - matrix_free( A_view ); - return NULL; -} - -/** - Observe that the calling scope is responsible for passing a - thread_pool in suitable state to this function. This implies one of - the following: - - 1. The thread_pool is newly created, with the @start_queue - argument set to false. - - 2. The thread_pool has been joined __without__ an interevening - call to thread_pool_restart(). - - If the thread_pool has not been correctly prepared, according to - this specification, it will be crash and burn. -*/ - -void matrix_inplace_matmul_mt2(matrix_type * A, const matrix_type * B , thread_pool_type * thread_pool){ - int num_threads = thread_pool_get_max_running( thread_pool ); - arg_pack_type ** arglist = (arg_pack_type**)util_malloc( num_threads * sizeof * arglist ); - int it; - thread_pool_restart( thread_pool ); - { - int rows = matrix_get_rows( A ) / num_threads; - int rows_mod = matrix_get_rows( A ) % num_threads; - int row_offset = 0; - - for (it = 0; it < num_threads; it++) { - int row_size; - arglist[it] = arg_pack_alloc(); - row_size = rows; - if (it < rows_mod) - row_size += 1; - - arg_pack_append_int(arglist[it] , row_offset ); - arg_pack_append_int(arglist[it] , row_size ); - arg_pack_append_ptr(arglist[it] , A ); - arg_pack_append_const_ptr(arglist[it] , B ); - - thread_pool_add_job( thread_pool , matrix_inplace_matmul_mt__ , arglist[it]); - row_offset += row_size; - } - } - thread_pool_join( thread_pool ); - - for (it = 0; it < num_threads; it++) - arg_pack_free( arglist[it] ); - free( arglist ); -} - -void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ - thread_pool_type * thread_pool = thread_pool_alloc( num_threads , false ); - matrix_inplace_matmul_mt2( A , B , thread_pool ); - thread_pool_free( thread_pool ); -} - -#else - -void matrix_inplace_matmul_mt1(matrix_type * A, const matrix_type * B , int num_threads){ - matrix_inplace_matmul( A , B ); -} - -#endif - - - - -/*****************************************************************/ -/* Row/column functions */ - -double matrix_get_row_sum(const matrix_type * matrix , int row) { - double sum = 0; - int j; - for (j=0; j < matrix->columns; j++) - sum += matrix->data[ GET_INDEX( matrix , row , j ) ]; - return sum; -} - - -double matrix_get_column_sum(const matrix_type * matrix , int column) { - double sum = 0; - int i; - for (i=0; i < matrix->rows; i++) - sum += matrix->data[ GET_INDEX( matrix , i , column ) ]; - return sum; -} - - -double matrix_get_column_abssum(const matrix_type * matrix , int column) { - double sum = 0; - int i; - for (i=0; i < matrix->rows; i++) - sum += fabs( matrix->data[ GET_INDEX( matrix , i , column ) ] ); - return sum; -} - - -double matrix_get_row_sum2(const matrix_type * matrix , int row) { - double sum2 = 0; - int j; - for ( j=0; j < matrix->columns; j++) { - double m = matrix->data[ GET_INDEX( matrix , row , j ) ]; - sum2 += m*m; - } - return sum2; -} - - -double matrix_get_row_abssum(const matrix_type * matrix , int row) { - double sum_abs = 0; - int j; - for ( j=0; j < matrix->columns; j++) { - double m = matrix->data[ GET_INDEX( matrix , row , j ) ]; - sum_abs += fabs( m ); - } - return sum_abs; -} - -/** - Return the sum of the squares on column. -*/ -double matrix_get_column_sum2(const matrix_type * matrix , int column) { - double sum2 = 0; - int i; - for ( i=0; i < matrix->rows; i++) { - double m = matrix->data[ GET_INDEX( matrix , i , column ) ]; - sum2 += m*m; - } - return sum2; -} - - - -void matrix_shift_column(matrix_type * matrix , int column, double shift) { - int i; - for ( i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX( matrix , i , column) ] += shift; -} - - -void matrix_shift_row(matrix_type * matrix , int row , double shift) { - int j; - for ( j=0; j < matrix->columns; j++) - matrix->data[ GET_INDEX( matrix , row , j ) ] += shift; -} - - - -/** - For each row in the matrix we will do the operation - - R -> R - -*/ - -void matrix_subtract_row_mean(matrix_type * matrix) { - int i; - for ( i=0; i < matrix->rows; i++) { - double row_mean = matrix_get_row_sum(matrix , i) / matrix->columns; - matrix_shift_row( matrix , i , -row_mean); - } -} - -void matrix_subtract_and_store_row_mean(matrix_type * matrix, matrix_type * row_mean) { - int i; - for ( i=0; i < matrix->rows; i++) { - double mean = matrix_get_row_sum(matrix , i) / matrix->columns; - matrix_shift_row( matrix , i , -mean); - matrix_iset(row_mean , i , 0, mean ); - } -} - -void matrix_imul_col( matrix_type * matrix , int column , double factor) { - int i; - for ( i=0; i < matrix->rows; i++) - matrix_imul( matrix , i , column , factor ); -} - - -/*****************************************************************/ -/** - This function will return the double data pointer of the matrix, - when you use this explicitly you ARE ON YOUR OWN. -*/ - -double * matrix_get_data(const matrix_type * matrix) { - return matrix->data; -} - -/** - The query functions below can be used to ask for the dimensions & - strides of the matrix. -*/ - -int matrix_get_rows(const matrix_type * matrix) { - return matrix->rows; -} - -int matrix_get_columns(const matrix_type * matrix) { - return matrix->columns; -} - -int matrix_get_row_stride(const matrix_type * matrix) { - return matrix->row_stride; -} - -int matrix_get_column_stride(const matrix_type * matrix) { - return matrix->column_stride; -} - - -void matrix_get_dims(const matrix_type * matrix , int * rows , int * columns , int * row_stride , int * column_stride) { - - *rows = matrix->rows; - *columns = matrix->columns; - *row_stride = matrix->row_stride; - *column_stride = matrix->column_stride; - -} - - -bool matrix_is_quadratic(const matrix_type * matrix) { - if (matrix->rows == matrix->columns) - return true; - else - return false; -} - -/** - Goes through all the elements in the matrix - and return true if they are all finite. -*/ - -#ifdef ERT_HAVE_ISFINITE - -bool matrix_is_finite(const matrix_type * matrix) { - int i,j; - for (i = 0; i < matrix->rows; i++) - for (j =0; j< matrix->columns; j++) - if ( !isfinite( matrix->data[ GET_INDEX( matrix , i , j) ])) { - printf("%s(%d,%d) = %g \n",matrix->name , i,j,matrix->data[ GET_INDEX( matrix , i , j) ]); - return false; - } - - return true; -} - -void matrix_assert_finite( const matrix_type * matrix ) { - if (!matrix_is_finite( matrix )) { - if ((matrix->rows * matrix->columns) < 400) - matrix_pretty_fprint( matrix , matrix->name , " %6.3f" , stdout); - - util_abort("%s: matrix:%s is not finite. \n",__func__ , matrix->name); - } -} - -#endif - - - -/** - This function will return the largest deviance from orthonormal - conditions for the matrix - i.e. when this function returns - 0.000000 the matrix is perfectly orthonormal; otherwise it is the - responsability of the calling scope to evaluate. -*/ - -double matrix_orthonormality( const matrix_type * matrix ) { - double max_dev = 0.0; - int col1,col2; - for (col1=0; col1 < matrix->columns; col1++) { - for (col2=col1; col2 < matrix->columns; col2++) { - double dot_product = matrix_column_column_dot_product( matrix , col1 , matrix , col2); - double dev; - - if (col1 == col2) - dev = fabs( dot_product - 1.0 ); - else - dev = fabs( dot_product ); - - if (dev > max_dev) - max_dev = dev; - } - } - return max_dev; -} - - - - - -/** - Return true if the two matrices m1 and m2 are equal. The equality - test is based on element-by-element memcmp() comparison, i.e. the - there is ZERO numerical tolerance in the comparison. - - If the two matrices do not have equal dimension false is returned. -*/ - -bool matrix_equal( const matrix_type * m1 , const matrix_type * m2) { - if (! ((m1->rows == m2->rows) && (m1->columns == m2->columns))) - return false; - { - int i,j; - for (i=0; i < m1->rows; i++) { - for (j=0; j < m1->columns; j++) { - int index1 = GET_INDEX(m1 , i , j); - int index2 = GET_INDEX(m2 , i , j); - double d1 = m1->data[ index1 ]; - double d2 = m2->data[ index2 ]; - - if (d1 != d2) - return false; - } - } - } - - /** OK - we came all the way through - they are equal. */ - return true; -} - - -bool matrix_columns_equal( const matrix_type * m1 , int col1 , const matrix_type * m2 , int col2) { - if (m1->rows != m2->rows) - return false; - - { - int row; - for (row=0; row < m1->rows; row++) { - if (memcmp( &m1->data[ GET_INDEX(m1 , row , col1)] , &m2->data[ GET_INDEX(m2 , row , col2)] , sizeof * m1->data) != 0) - return false; - } - } - - return true; -} - - -/*****************************************************************/ -/* Various special matrices */ - - -/** - Will set the diagonal elements in matrix to the values in diag, - and all remaining elements to zero. Assumes that matrix is - rectangular. -*/ - -void matrix_diag_set(matrix_type * matrix , const double * diag) { - if (matrix->rows == matrix->columns) { - int i; - matrix_set(matrix , 0); - for ( i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , i) ] = diag[i]; - } else - util_abort("%s: size mismatch \n",__func__); -} - - -/** - Will set the scalar @value on all the diagonal elements of the - matrix; all off-diagonal elements are explicitly set to zero. -*/ - -void matrix_diag_set_scalar(matrix_type * matrix , double value) { - if (matrix->rows == matrix->columns) { - int i; - matrix_set(matrix , 0); - for ( i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , i) ] = value; - } else - util_abort("%s: size mismatch \n",__func__); -} - - -void matrix_scalar_set( matrix_type * matrix , double value) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , j) ] = value; -} - - - -/** - Fills the matrix with uniformly distributed random numbers in - [0,1). -*/ - -void matrix_random_init(matrix_type * matrix , rng_type * rng) { - int i,j; - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - matrix->data[ GET_INDEX(matrix , i , j) ] = rng_get_double( rng ); -} - - - -void matrix_clear( matrix_type * matrix ) { - matrix_set( matrix , 0 ); -} - - - -/** - This function dumps the following binary file: - - rows - columns - data(1,1) - data(2,1) - data(3,1) - .... - data(1,2) - data(2,2) - .... - - Not exactly a matlab format. - - The following matlab code can be used to instatiate a matrix based - on the file: - - function m = load_matrix(filename) - fid = fopen(filename); - dims = fread(fid , 2 , 'int32'); - m = fread(fid , [dims(1) , dims(2)] , 'double'); - fclose(fid); - - - >> A = load_matrix( 'filename' ); -*/ - - -void matrix_matlab_dump(const matrix_type * matrix, const char * filename) { - FILE * stream = util_fopen( filename , "w"); - int i,j; - util_fwrite_int( matrix->rows , stream); - util_fwrite_int( matrix->columns , stream); - - for (j=0; j < matrix->columns; j++) - for (i=0; i < matrix->rows; i++) - util_fwrite_double( matrix->data[ GET_INDEX(matrix , i , j) ] , stream); - - fclose(stream); -} - - -// Comment -void matrix_inplace_diag_sqrt(matrix_type *Cd) -{ - int nrows = Cd->rows; - - if (Cd->rows != Cd->columns) { - util_abort("%s: size mismatch \n",__func__); - } - else{ - int i; - for ( i=0; idata[GET_INDEX(Cd , i , i)] = sqrt(Cd->data[GET_INDEX(Cd , i , i)]); - } - } -} - - - -double matrix_trace(const matrix_type *matrix) { - - int nrows = matrix->rows; - double sum = 0; - - if (matrix->rows != matrix->columns) { - util_abort("%s: matrix is not square \n",__func__); - } - else{ - int i; - for ( i=0; idata[GET_INDEX(matrix , i , i)]; - } - } - return sum; -} - - -bool matrix_check_dims( const matrix_type * m , int rows , int columns) { - if (m) { - if ((m->rows == rows) && (m->columns == columns)) - return true; - else - return false; - } else { - util_abort("%s: internal error - trying to dereference NULL matrix pointer \n",__func__); - return false; - } -} - - -double matrix_diag_std(const matrix_type * Sk,double mean) -{ - - if (Sk->rows != Sk->columns) { - util_abort("%s: matrix is not square \n",__func__); - return 0; - } - else{ - int nrows = Sk->rows; - double std = 0; - int i; - - for ( i=0; idata[GET_INDEX(Sk , i , i)] - mean; - std += d*d; - } - - - std = sqrt(std / nrows); - return std; - } -} - -/** - The matrix_det3() and matrix_det4() are explicit implementations of - the determinant of a 3x3 and 4x4 matrices. The ecl_grid class uses - these determinants determine whether a point is inside a cell. By - using this explicit implementation the ecl_grid library has no - LAPACK dependency. -*/ - -double matrix_det2( const matrix_type * A) { - if ((A->rows == 2) && (A->columns == 2)) { - double a00 = A->data[GET_INDEX(A,0,0)]; - double a01 = A->data[GET_INDEX(A,0,1)]; - double a10 = A->data[GET_INDEX(A,1,0)]; - double a11 = A->data[GET_INDEX(A,1,1)]; - - return a00 * a11 - a10 * a01; - } else { - util_abort("%s: hardcoded for 2x2 matrices A is: %d x %d \n",__func__, A->rows , A->columns); - return 0; - } -} - -double matrix_det3( const matrix_type * A) { - if ((A->rows == 3) && (A->columns == 3)) { - double a = A->data[GET_INDEX(A,0,0)]; - double b = A->data[GET_INDEX(A,0,1)]; - double c = A->data[GET_INDEX(A,0,2)]; - - double d = A->data[GET_INDEX(A,1,0)]; - double e = A->data[GET_INDEX(A,1,1)]; - double f = A->data[GET_INDEX(A,1,2)]; - - double g = A->data[GET_INDEX(A,2,0)]; - double h = A->data[GET_INDEX(A,2,1)]; - double i = A->data[GET_INDEX(A,2,2)]; - - return a*e*i + b*f*g + c*d*h - c*e*g - b*d*i - a*f*h; - } else { - util_abort("%s: hardcoded for 3x3 matrices A is: %d x %d \n",__func__, A->rows , A->columns); - return 0; - } -} - - -double matrix_det4( const matrix_type * A) { - if ((A->rows == 4) && (A->columns == 4)) { - double a00 = A->data[GET_INDEX(A,0,0)]; - double a01 = A->data[GET_INDEX(A,0,1)]; - double a02 = A->data[GET_INDEX(A,0,2)]; - double a03 = A->data[GET_INDEX(A,0,3)]; - double a10 = A->data[GET_INDEX(A,1,0)]; - double a11 = A->data[GET_INDEX(A,1,1)]; - double a12 = A->data[GET_INDEX(A,1,2)]; - double a13 = A->data[GET_INDEX(A,1,3)]; - double a20 = A->data[GET_INDEX(A,2,0)]; - double a21 = A->data[GET_INDEX(A,2,1)]; - double a22 = A->data[GET_INDEX(A,2,2)]; - double a23 = A->data[GET_INDEX(A,2,3)]; - double a30 = A->data[GET_INDEX(A,3,0)]; - double a31 = A->data[GET_INDEX(A,3,1)]; - double a32 = A->data[GET_INDEX(A,3,2)]; - double a33 = A->data[GET_INDEX(A,3,3)]; - - /* - double det = (a00*(a11*(a22*a33 - a23*a32)-a12*(a21*a33 - a23*a31)+a13*(a21*a32 - a22*a31)) - - a01*(a10*(a22*a33 - a23*a32)-a12*(a20*a33 - a23*a30)+a13*(a20*a32 - a22*a30)) + - a02*(a10*(a21*a33 - a23*a31)-a11*(a20*a33 - a23*a30)+a13*(a20*a31 - a21*a30)) - - a03*(a10*(a21*a32 - a22*a31)-a11*(a20*a32 - a22*a30)+a12*(a20*a31 - a21*a30))); - */ - double det = 0; - - { - double factors[24] = { a00*a12*a23*a31, - a00*a13*a21*a32, - a00*a11*a22*a33, - a01*a10*a23*a32, - a01*a12*a20*a33, - a01*a13*a22*a30, - a02*a10*a21*a33, - a02*a11*a23*a30, - a02*a13*a20*a31, - a03*a10*a22*a31, - a03*a11*a20*a32, - a03*a12*a21*a30 - -a02*a13*a21*a30, - -a03*a10*a21*a32, - -a03*a11*a22*a30, - -a03*a12*a20*a31, - -a00*a11*a23*a32, - -a00*a12*a21*a33, - -a00*a13*a22*a31, - -a01*a10*a22*a33, - -a01*a12*a23*a30, - -a01*a13*a20*a32, - -a02*a10*a23*a31, - -a02*a11*a20*a33}; - int i; - - for (i = 0; i < 12; i++) - det += (factors[i] + factors[i + 12]); - } - - return det; - } else { - util_abort("%s: hardcoded for 4x4 matrices A is: %d x %d \n",__func__, A->rows , A->columns); - return 0; - } -} - - -#ifdef __cplusplus -} -#endif diff --git a/ThirdParty/Ert/lib/util/matrix_blas.c b/ThirdParty/Ert/lib/util/matrix_blas.c deleted file mode 100644 index 2ac5438433..0000000000 --- a/ThirdParty/Ert/lib/util/matrix_blas.c +++ /dev/null @@ -1,286 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_blas.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/*****************************************************************/ -void dgemm_(char * , char * , int * , int * , int * , double * , double * , int * , double * , int * , double * , double * , int *); -void dgemv_(char * , int * , int * , double * , double * , int * , const double * , int * , double * , double * , int * ); -/*****************************************************************/ - - - -/** - y = alpha * op(A)*x + beta * y - - alpha,beta: scalars - x,y : vectors - A : matrix - - - x and y are entered as (double * ). -*/ - - -void matrix_dgemv(const matrix_type * A , const double *x , double * y, bool transA , double alpha , double beta) { - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - int lda = matrix_get_column_stride( A ); - int incx = 1; - int incy = 1; - - char transA_c; - if (transA) - transA_c = 'T'; - else - transA_c = 'N'; - - dgemv_(&transA_c , &m , &n , &alpha , matrix_get_data( A ) , &lda , x , &incx , &beta , y , &incy); -} - - -/** - y = A*x -*/ - -void matrix_mul_vector(const matrix_type * A , const double * x , double * y) { - matrix_dgemv(A , x , y , false , 1 , 0); -} - - - -static void dgemm_debug(const matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB) { - printf("\nC = [%d , %d]\n",matrix_get_rows( C ) , matrix_get_columns(C)); - - printf("A: [%d , %d]", matrix_get_rows( A ) , matrix_get_columns(A)); - if (transA) - printf("^T"); - - printf("\nB: [%d , %d]", matrix_get_rows( B ) , matrix_get_columns(B)); - if (transB) - printf("^T"); - - printf("\n\n"); - printf("[%d ,%d] = ",matrix_get_rows( C ) , matrix_get_columns(C)); - if (transA) - printf("[%d ,%d] x ",matrix_get_rows( A ) , matrix_get_columns(A)); - else - printf("[%d ,%d] x ",matrix_get_columns( A ) , matrix_get_rows(A)); - - - if (transB) - printf("[%d ,%d]\n",matrix_get_rows( B ) , matrix_get_columns(B)); - else - printf("[%d ,%d]\n",matrix_get_columns( B ) , matrix_get_rows(B)); - - -} - - - -/** - C = alpha * op(A) * op(B) + beta * C - - op(·) can either be unity or Transpose. -*/ - -void matrix_dgemm(matrix_type *C , const matrix_type *A , const matrix_type * B , bool transA, bool transB , double alpha , double beta) { - int m = matrix_get_rows( C ); - int n = matrix_get_columns( C ); - int lda = matrix_get_column_stride( A ); - int ldb = matrix_get_column_stride( B ); - int ldc = matrix_get_column_stride( C ); - char transA_c; - char transB_c; - int k , innerA, innerB , outerA , outerB; - - if (transA) - k = matrix_get_rows( A ); - else - k = matrix_get_columns( A ); - - - if (transA) { - innerA = matrix_get_rows(A); - outerA = matrix_get_columns(A); - transA_c = 'T'; - } else { - innerA = matrix_get_columns(A); - outerA = matrix_get_rows(A); - transA_c = 'N'; - } - - - if (transB) { - innerB = matrix_get_columns( B ); - outerB = matrix_get_rows( B ); - transB_c = 'T'; - } else { - transB_c = 'N'; - innerB = matrix_get_rows( B ); - outerB = matrix_get_columns( B ); - } - - /* - This is the dimension check which must pass: - - -------------------------------------------------- - A | B | Columns(A) = Rows(B) - Trans(A) | Trans(B) | Rows(A) = Columns(B) - A | Trans(B) | Columns(A) = Columns(B) - Trans(A) | B | Rows(A) = Rows(B) - -------------------------------------------------- - - -------------------------------------------------- - A | Rows(A) = Rows(C) - Trans(A) | Columns(A) = Rows(C) - B | Columns(B) = Columns(C) - Trans(B) | Rows(B) = Columns(B) - -------------------------------------------------- - - */ - - if (innerA != innerB) { - dgemm_debug(C,A,B,transA , transB); - util_abort("%s: matrix size mismatch between A and B \n", __func__); - } - - - if (outerA != matrix_get_rows( C )) { - dgemm_debug(C,A,B,transA , transB); - printf("outerA:%d rows(C):%d \n",outerA , matrix_get_rows( C )); - util_abort("%s: matrix size mismatch between A and C \n",__func__); - } - - - if (outerB != matrix_get_columns( C )) { - dgemm_debug(C,A,B,transA , transB); - util_abort("%s: matrix size mismatch between B and C \n",__func__); - } - - if (ldc < util_int_max(1 , m)) { - dgemm_debug(C,A,B,transA , transB); - fprintf(stderr,"Tried to capture blas message: \"** On entry to DGEMM parameter 13 had an illegal value\"\n"); - fprintf(stderr,"m:%d ldc:%d ldc should be >= max(1,%d) \n",m,ldc,m); - util_abort("%s: invalid value for ldc\n",__func__); - } - - - dgemm_(&transA_c , // 1 - &transB_c , // 2 - &m , // 3 - &n , // 4 - &k , // 5 - &alpha , // 6 - matrix_get_data( A ) , // 7 - &lda , // 8 - matrix_get_data( B ) , // 9 - &ldb , // 10 - &beta , // 11 - matrix_get_data( C ) , // 12 - &ldc); // 13 -} - - - -void matrix_matmul_with_transpose(matrix_type * C, const matrix_type * A , const matrix_type * B , bool transA , bool transB) { - matrix_dgemm( C , A , B , transA , transB , 1 , 0); -} - - -/* - This function does a general matrix multiply of A * B, and stores - the result in C. -*/ - -void matrix_matmul(matrix_type * C, const matrix_type * A , const matrix_type * B) { - matrix_dgemm( C , A , B , false , false , 1 , 0); -} - - -/** - Allocates new matrix C = A·B -*/ - -matrix_type * matrix_alloc_matmul(const matrix_type * A, const matrix_type * B) { - matrix_type * C = matrix_alloc( matrix_get_rows( A ) , matrix_get_columns( B )); - matrix_matmul( C , A , B ); - return C; -} - - - - - -/*****************************************************************/ -/** - Will calculate the Gram matrix: G = X'*X -*/ - -void matrix_gram_set( const matrix_type * X , matrix_type * G, bool col) { - int G_rows = matrix_get_rows( G ); - int G_cols = matrix_get_columns( G ); - int X_rows = matrix_get_rows( X ); - int X_cols = matrix_get_columns( X ); - if (col) { - // Calculate X' · X - if ((G_rows == G_cols) && (X_cols == G_rows)) - matrix_dgemm( G , X , X , true , false , 1 , 0); - else - util_abort("%s: dimension mismatch \n",__func__); - } else { - // Calculate X · X' - if ((G_rows == G_cols) && (X_rows == G_rows)) - matrix_dgemm( G , X , X , false , true , 1 , 0); - else - util_abort("%s: dimension mismatch \n",__func__); - } -} - - -/** - If col == true: G = X' · X - col == false: G = X · X' -*/ - - -matrix_type * matrix_alloc_gram( const matrix_type * X , bool col) { - int X_rows = matrix_get_rows( X ); - int X_columns = matrix_get_columns( X ); - matrix_type * G; - - if (col) - G = matrix_alloc( X_columns , X_columns ); - else - G = matrix_alloc( X_rows , X_rows ); - - matrix_gram_set( X , G , col); - return G; -} - -#ifdef __cplusplus -} -#endif diff --git a/ThirdParty/Ert/lib/util/matrix_lapack.c b/ThirdParty/Ert/lib/util/matrix_lapack.c deleted file mode 100644 index 2a62b0fcbd..0000000000 --- a/ThirdParty/Ert/lib/util/matrix_lapack.c +++ /dev/null @@ -1,640 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'matrix_lapack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include - -#include -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - The external lapack routines -*/ -/*****************************************************************/ -void dgesv_(int * n, - int * nrhs, - double * A, - int * lda, - long int * ipivot, - double * B, - int * ldb, - int * info); -void dgesvd_(char * jobu, - char * jobvt, - int * m, - int * n, - double * A, - int * lda, - double * S, - double * U, - int * ldu, - double * VT, - int * ldvt, - double * work, - int * worksize, - int * info); -void dsyevx_(char * jobz, - char * range, - char * uplo, - int *n, - double * A, - int * lda, - double * vl, - double * vu, - int * il, - int * iu, - double * abstol, - int * m, - double * w, - double *z, - int * ldz, - double * work, - int * lwork, - int * iwork, - int * ifail, - int * info); -void dgeqrf_(int * m, - int * n, - double * A, - int * lda, - double * tau, - double * work, - int * lwork, - int * info); -void dorgqr_(int * m, - int * n, - int * k, - double * A, - int * lda, - double * tau, - double * work, - int * lwork, - int * info); -void dgetrf_(int * M, - int * n, - double * A, - int * lda, - int * ipiv, - int * info); -void dgedi_(double * A, - int * lda, - int * n, - int * ipiv, - double * det, - double * work, - int * job); -void dgetri_(int * n, - double * A, - int * lda, - int * ipiv, - double * work, - int * work_size, - int * info); -/*****************************************************************/ - - - - - - -/** - This file implements (very thin) interfaces for the matrix_type to - some lapack functions. The file does not contain any data - structures, only functions. -*/ - - - -static void matrix_lapack_assert_fortran_layout( const matrix_type * matrix ) { - int rows, columns, row_stride , column_stride; - matrix_get_dims( matrix , &rows , &columns , &row_stride , &column_stride); - if (!( (column_stride >= rows) && (row_stride == 1))) - util_abort("%s: lapack routines require Fortran layout of memory - aborting \n",__func__); -} - - -static void matrix_lapack_assert_square(const matrix_type * matrix) { - matrix_lapack_assert_fortran_layout(matrix ); - { - int rows, columns, row_stride , column_stride; - matrix_get_dims( matrix , &rows , &columns , &row_stride , &column_stride); - if (rows != columns) - util_abort("%s: must have square matrices \n",__func__); - } -} - - -/*****************************************************************/ -/** - Solves the linear equations Ax = B. The solution is stored in B on - return. -*/ - - -void matrix_dgesv(matrix_type * A , matrix_type * B) { - matrix_lapack_assert_square( A ); - matrix_lapack_assert_fortran_layout( B ); - { - int n = matrix_get_rows( A ); - int lda = matrix_get_column_stride( A ); - int ldb = matrix_get_column_stride( B ); - int nrhs = matrix_get_columns( B ); - long int * ipivot = (long int*)util_calloc( n , sizeof * ipivot ); - int info; - - dgesv_(&n , &nrhs , matrix_get_data( A ) , &lda , ipivot , matrix_get_data( B ), &ldb , &info); - if (info != 0) - util_abort("%s: low level lapack routine: dgesv() failed with info:%d \n",__func__ , info); - free(ipivot); - } -} - - -/*****************************************************************/ -/** - Singular Value Decomposition -*/ - - -/** - This little function translates between an integer identifier - (i.e. and enum instance) to one of the characters used by the low - level lapack routine to indicate how the singular vectors should be - returned to the calling scope. - - The meaning of the different enum values is documented in the enum - definition in the header file matrix_lapack.h. -*/ - -static char dgesvd_get_vector_job( dgesvd_vector_enum vector_job) { - char job = 'X'; - switch (vector_job) { - case(DGESVD_ALL): - job = 'A'; - break; - case(DGESVD_MIN_RETURN): - job = 'S'; - break; - case(DGESVD_MIN_OVERWRITE): - job = 'O'; - break; - case(DGESVD_NONE): - job = 'N'; - break; - default: - util_abort("%s: internal error - unrecognized code:%d \n",vector_job); - } - return job; -} - - - -/** - If jobu == DGSEVD_NONE the U matrix can be NULL, same for jobvt. -*/ - -void matrix_dgesvd(dgesvd_vector_enum jobu , dgesvd_vector_enum jobvt , matrix_type * A , double * S , matrix_type * U , matrix_type * VT) { - char _jobu = dgesvd_get_vector_job( jobu ); - char _jobvt = dgesvd_get_vector_job( jobvt ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - int lda = matrix_get_column_stride( A ); - int ldu, ldvt; - double * VT_data , *U_data; - int info = 0; - int min_worksize = util_int_max(3* util_int_min(m , n) + util_int_max(m , n) , 5 * util_int_min(m , n)); - double * work; - int worksize; - - - if (U == NULL) { - ldu = 1; - U_data = NULL; - if (jobu != DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } else { - ldu = matrix_get_column_stride( U ); - U_data = matrix_get_data( U ); - if (jobu == DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } - - if (VT == NULL) { - ldvt = 1; /* Will fail if set to zero */ - VT_data = NULL; - if (jobvt != DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } else { - ldvt = matrix_get_column_stride( VT ); - VT_data = matrix_get_data( VT ); - if (jobvt == DGESVD_NONE) - util_abort("%s: internal error \n",__func__); - } - - /* - Query the routine for optimal worksize. - */ - - work = (double*)util_calloc( 1 , sizeof * work ); - worksize = -1; - dgesvd_(&_jobu , /* 1 */ - &_jobvt , /* 2 */ - &m , /* 3 */ - &n , /* 4 */ - matrix_get_data( A ) , /* 5 */ - &lda , /* 6 */ - S , /* 7 */ - U_data , /* 8 */ - &ldu , /* 9 */ - VT_data , /* 10 */ - &ldvt , /* 11 */ - work , /* 12 */ - &worksize , /* 13 */ - &info); /* 14 */ - - - /* Try to allocate optimal worksize. */ - worksize = (int) work[0]; - double * tmp = (double*)realloc( work , sizeof * work * worksize ); - if (tmp == NULL) { - /* Could not allocate optimal worksize - settle for the minimum. This can not fail. */ - worksize = min_worksize; - free(work); - work = (double*)util_calloc( worksize , sizeof * work ); - }else{ - work = tmp; /* The request for optimal worksize succeeded */ - } - - dgesvd_(&_jobu , &_jobvt , &m , &n , matrix_get_data( A ) , &lda , S , U_data , &ldu , VT_data , &ldvt , work , &worksize , &info); - free( work ); -} - - - -/******************************************************************/ -/* Eigenvalues of a symmetric matrix */ -/* Return value is the number of eigenvalues found. */ -/******************************************************************/ - -int matrix_dsyevx(bool compute_eig_vectors , - dsyevx_eig_enum which_values , /* DSYEVX | DSYEVX_VALUE_INTERVAL | DSYEVX_INDEX_INTERVAL */ - dsyevx_uplo_enum uplo, - matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ - double VL , /* Lower limit when using DSYEVX_VALUE_INTERVAL */ - double VU , /* Upper limit when using DSYEVX_VALUE_INTERVAL */ - int IL , /* Lower index when using DSYEVX_INDEX_INTERVAL */ - int IU , /* Upper index when using DSYEVX_INDEX_INTERVAL */ - double *eig_values , /* The calcualated eigenvalues */ - matrix_type * Z ) { /* The eigenvectors as columns vectors */ - - int lda = matrix_get_column_stride( A ); - int n = matrix_get_rows( A ); - char jobz; - char range; - char uplo_c; - - if (compute_eig_vectors) - jobz = 'V'; - else - jobz = 'N'; - - switch(which_values) { - case(DSYEVX_ALL): - range = 'A'; - break; - case(DSYEVX_VALUE_INTERVAL): - range = 'V'; - break; - case(DSYEVX_INDEX_INTERVAL): - range = 'I'; - break; - default: - util_abort("%s: internal error \n",__func__); - } - - if (uplo == DSYEVX_AUPPER) - uplo_c = 'U'; - else if (uplo == DSYEVX_ALOWER) - uplo_c = 'L'; - else - util_abort("%s: internal error \n",__func__); - - - if (!matrix_is_quadratic( A )) - util_abort("%s: matrix A must be quadratic \n",__func__); - - { - int num_eigenvalues , ldz, info , worksize; - int * ifail = (int*) util_calloc( n , sizeof * ifail ); - int * iwork = (int*) util_calloc( 5 * n , sizeof * iwork ); - double * work = (double*)util_calloc( 1 , sizeof * work ); - double * z_data; - double abstol = 0.0; /* SHopuld */ - - - if (compute_eig_vectors) { - ldz = matrix_get_column_stride( Z ); - z_data = matrix_get_data( Z ); - } else { - /* In this case we can accept that Z == NULL */ - ldz = 1; - z_data = NULL; - } - - /* First call to determine optimal worksize. */ - worksize = -1; - info = 0; - dsyevx_( &jobz, /* 1 */ - &range, /* 2 */ - &uplo_c, /* 3 */ - &n, /* 4 */ - matrix_get_data( A ), /* 5 */ - &lda , /* 6 */ - &VL , /* 7 */ - &VU , /* 8 */ - &IL , /* 9 */ - &IU , /* 10 */ - &abstol , /* 11 */ - &num_eigenvalues , /* 12 */ - eig_values , /* 13 */ - z_data , /* 14 */ - &ldz , /* 15 */ - work , /* 16 */ - &worksize , /* 17 */ - iwork , /* 18 */ - ifail , /* 19 */ - &info); /* 20 */ - - - worksize = (int) work[0]; - { - double * tmp = (double*)realloc(work , sizeof * work * worksize ); - if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, - try again with the minimum. - */ - worksize = 8 * n; - work = (double*)util_realloc(work , sizeof * work * worksize ); - } else - work = tmp; /* The request for optimal worksize succeeded */ - } - /* Second call: do the job */ - info = 0; - dsyevx_( &jobz, - &range, - &uplo_c, - &n, - matrix_get_data( A ), - &lda , - &VL , - &VU , - &IL , - &IU , - &abstol , - &num_eigenvalues , - eig_values , - z_data , - &ldz , - work , - &worksize , - iwork , - ifail , - &info); - - free( ifail ); - free( work ); - free( iwork ); - return num_eigenvalues; - } -} - - -/** - Wrapper function to compute all eigenvalues + eigenvectors with the - matrix_dsyevx() function. -*/ - -int matrix_dsyevx_all(dsyevx_uplo_enum uplo, - matrix_type * A , /* The input matrix - is modified by the dsyevx() function. */ - double *eig_values , /* The calcualated eigenvalues */ - matrix_type * Z ) { /* The eigenvectors as columns vectors */ - int num_eigenvalues; - num_eigenvalues = matrix_dsyevx(true , DSYEVX_ALL , uplo , A , 0,0,0,0, eig_values , Z); - return num_eigenvalues; - -} - - - -/*****************************************************************/ -/* Function to compute QR factorization withe the routine dgeqrf */ - -void matrix_dgeqrf(matrix_type * A , double * tau) { - int lda = matrix_get_column_stride( A ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - double * work = (double*)util_calloc(1 , sizeof * work ); - int worksize; - int info; - - - /* Determine optimal worksize. */ - worksize = -1; - dgeqrf_(&m , &n , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dgerqf routine failed with info:%d \n",__func__ , info); - worksize = ( int ) work[0]; - { - double * tmp = (double*)realloc(work , sizeof * work * worksize ); - if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, - try again with the minimum. - */ - worksize = n; - work = (double*)util_realloc(work , sizeof * work * worksize ); - } else - work = tmp; /* The request for optimal worksize succeeded */ - } - - - /* Second call - do the actual computation. */ - dgeqrf_(&m , &n , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dgerqf routine failed with info:%d \n",__func__ , info); - free( work ); -} - - -/** - Typically to be used after the matrix_dgeqrf() function to construct a orthormal matrix. -*/ - -void matrix_dorgqr(matrix_type * A , double * tau, int num_reflectors) { /* num_reflectors == length of tau. */ - int lda = matrix_get_column_stride( A ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - double * work = (double*)util_malloc(sizeof * work ); - int worksize; - int info; - - - /* Determine optimal worksize. */ - worksize = -1; - dorgqr_(&m , &n , &num_reflectors , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dorgqf routine failed with info:%d \n",__func__ , info); - worksize = ( int ) work[0]; - { - double * tmp = (double*)realloc(work , sizeof * work * worksize ); - if (tmp == NULL) { - /* - OK - we could not get the optimal worksize, - try again with the minimum. - */ - worksize = n; - work = (double*)util_realloc(work , sizeof * work * worksize ); - } else - work = tmp; /* The request for optimal worksize succeeded */ - } - - - /* Second call - do the actual computation. */ - dorgqr_(&m , &n , &num_reflectors , matrix_get_data( A ), &lda , tau , work , &worksize , &info); - if (info != 0) - util_abort("%s: dorqf routine failed with info:%d \n",__func__ , info); - free( work ); -} - -/*****************************************************************/ - -/*****************************************************************/ -/* Factorization */ - -/* Currently only used as 'support' function for the matrix_det function. */ -static void matrix_dgetrf__( matrix_type * A, int * ipiv, int * info) { - int lda = matrix_get_column_stride( A ); - int m = matrix_get_rows( A ); - int n = matrix_get_columns( A ); - - dgetrf_( &m , &n , matrix_get_data( A ) , &lda , ipiv , info); -} - - -/** - Calculated the determinant of A. The matrix content will be - destroyed. -*/ - -double matrix_det( matrix_type *A ) { - matrix_lapack_assert_square( A ); - { - - int dgetrf_info; - double det = 1; - double det_scale = 0; - int n = matrix_get_columns( A ); - int * ipiv = (int*)util_malloc( n * sizeof * ipiv ); - matrix_dgetrf__( A , ipiv , &dgetrf_info ); - { - int i; - for (i=0; i < n; i++) { - det *= matrix_iget(A , i , i); - if (det == 0) return 0; /* Holy fuck - a float == comparison ?? */ - - if (ipiv[i] != (i + 1)) /* A permutation has taken place. */ - det *= -1; - - - /* Try to avoid overflow/underflow by factoring out the order of magnitude. */ - while (fabs(det) > 10.0) { - det /= 10; - det_scale += 1; - } - - while (fabs(det) < 1.0) { - det *= 10; - det_scale -= 1; - } - } - } - - free( ipiv ); - return det * pow(10 , det_scale ); - } -} - - - - - -/*****************************************************************/ -/* The matrix will be inverted in-place, the inversion is based on LU - factorisation in the routine matrix_dgetrf__( ). - - The return value: - - =0 : Success - >0 : Singular matrix - <0 : Invalid input -*/ - - - - -int matrix_inv( matrix_type * A ) { - matrix_lapack_assert_square( A ); - { - int dgetrf_info; - int info; - int n = matrix_get_columns( A ); - int * ipiv = (int*)util_malloc( n * sizeof * ipiv ); - matrix_dgetrf__( A , ipiv , &dgetrf_info ); - { - int lda = matrix_get_column_stride( A ); - double * work = (double*)util_malloc( sizeof * work ); - int work_size; - - /* First call: determine optimal worksize: */ - work_size = -1; - dgetri_( &n , matrix_get_data( A ), &lda , ipiv , work , &work_size , &info); - - if (info == 0) { - work_size = (int) work[0]; - work = (double*)util_realloc( work , sizeof * work * work_size ); - dgetri_( &n , matrix_get_data( A ), &lda , ipiv , work , &work_size , &info); - } else - util_abort("%s: dgetri_ returned info:%d \n",__func__ , info); - - free( work ); - } - free( ipiv ); - return info; - } -} - - -#ifdef __cplusplus -} -#endif - diff --git a/ThirdParty/Ert/lib/util/matrix_stat.c b/ThirdParty/Ert/lib/util/matrix_stat.c deleted file mode 100644 index d8b47300f5..0000000000 --- a/ThirdParty/Ert/lib/util/matrix_stat.c +++ /dev/null @@ -1,114 +0,0 @@ -/* - Copyright (C) 2015 Statoil ASA, Norway. - - The file 'matrix_stat.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - - -llsq_result_enum matrix_stat_llsq_estimate( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S) { - if (matrix_get_rows( beta ) != matrix_get_columns( X0 )) - return LLSQ_INVALID_DIM; - - if (matrix_get_rows( X0 ) != matrix_get_rows( Y0 )) - return LLSQ_INVALID_DIM; - - if (S && matrix_get_rows( S ) != matrix_get_rows( Y0 )) - return LLSQ_INVALID_DIM; - - if (matrix_get_rows(beta) > matrix_get_rows( X0 )) - return LLSQ_UNDETERMINED; - - { - int num_data = matrix_get_rows( X0 ); - int num_var = matrix_get_columns( X0 ); - matrix_type * XX = matrix_alloc( num_var , num_var ); - matrix_type * A = matrix_alloc( num_var , num_data ); - - matrix_type * X,*Y; - - if (S == NULL) { - X = (matrix_type *) X0; - Y = (matrix_type *) Y0; - } else { - X = matrix_alloc_copy( X0 ); - Y = matrix_alloc_copy( Y0 ); - - { - int row,col; - for (row = 0; row < matrix_get_rows( X0 ); row++) { - double sigma = matrix_iget(S , row , 0); - double weigth = 1.0 / (sigma * sigma ); - - for (col = 0; col < matrix_get_columns( X0 ); col++) - matrix_imul( X , row , col , weigth ); - - matrix_imul( Y , row , col , weigth ); - } - } - } - - matrix_matmul_with_transpose( XX , X , X , true , false ); - matrix_inv( XX ); - matrix_matmul_with_transpose( A , XX , X , false , true ); - matrix_matmul(beta , A , Y); - - matrix_free( XX ); - matrix_free( A ); - if (S) { - matrix_free( X ); - matrix_free( Y ); - } - } - - return LLSQ_SUCCESS; -} - - - - -llsq_result_enum matrix_stat_polyfit( matrix_type * beta , const matrix_type * X0 , const matrix_type * Y0 , const matrix_type * S) { - int num_data = matrix_get_rows( X0 ); - int num_var = matrix_get_rows( beta ); - llsq_result_enum result; - matrix_type * X = matrix_alloc( num_data , num_var ); - int row,col; - - for (row = 0; row < matrix_get_rows( X0 ); row++) { - double x1 = matrix_iget( X0 , row , 0 ); - double xp = 1; - for (col = 0; col < num_var; col++) { - matrix_iset(X , row , col , xp); - xp *= x1; - } - } - - result = matrix_stat_llsq_estimate( beta , X , Y0 , S); - matrix_free( X ); - return result; -} - diff --git a/ThirdParty/Ert/lib/util/menu.c b/ThirdParty/Ert/lib/util/menu.c deleted file mode 100644 index f2b791045b..0000000000 --- a/ThirdParty/Ert/lib/util/menu.c +++ /dev/null @@ -1,462 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'menu.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include - -#include -#include -#include - -/** - This file implements a simple character based menu system. The menu - consists of a list of items, where each item has a description, a - function to call, an argument to send to this function, and a set - of keys which will invoke this function. - - - Example: - - menu_type * menu = menu_alloc("Tittel paa menyen" , "qQ"); - menu_add_item(menu , "Alternativ 1" , "1aA" , func1 , arg1); - menu_add_item(menu , "Alternativ 2" , 2Bb" , func2 , arg2); - menu_run(menu); - menu_free(menu); - - In this case we will get a menu looking like this: - - - Tittel paa menyen - 1: Alternativ 1 - 2: Alternativ 2 - q: Quit - ==> __ - - Now typing '1' will invoke the function func1() with argument - arg1. In addition the characters 'a' and 'A' can also be used to - invoke the same function. Function func2(arg2) is invoked with '2', - 'b' or 'B'; finally the menu is exited with 'q' or 'Q' (the - arguments to the alloc call). - - - Observe that (in the current implementation) only single characters - are allowed as activator keys for the various items. I.e. 'save' to - save is not an option' -*/ - - - - - -struct menu_item_struct { - bool separator; /* If this is a separator - in that case all the following fields are moot. */ - bool helptext; /* If this is help text - Only label is present */ - char * key_set; /* The characters which will activate this item , e.g. "sS" - must be a \0 terminated string */ - char * label; /* The label/description of this menu item */ - menu_func_type * func; /* The function called when this item is activated. */ - void * arg; /* The argument passed to func. */ - int label_length; /* The length of the label - zero for separators. */ - arg_free_ftype * free_arg; /* Destructor for the argument - will typically be NULL */ - bool enabled; -}; - - - - -struct menu_struct { - vector_type * items; /* Vector of menu_item_type instances */ - char * quit_keys; /* The keys which can be used to quit from this menu - typically "qQ" */ - char * title; /* The title of this menu */ - char * quit_label; /* The text printed on the back/quit item at the bottom. */ - char * complete_key_set; /* A string containing all the allowed characters - to validata input */ -}; - - - -/** - Free's the menu occupied by one menu item. -*/ -static void menu_item_free(menu_item_type * item) { - if (!item->separator) { - free(item->label); - } - if (!item->separator && !item->helptext){ - free(item->key_set); - } - - - if (item->free_arg != NULL) - item->free_arg(item->arg); - - free(item); -} - -static void menu_item_free__(void * arg) { - menu_item_free( (menu_item_type *) arg ); -} - - - -/** - This function returns true if the first argument contains _any_ of the characters in - the second argument. It is implemented by repeated calss to strchr(); -*/ - -static bool __string_contains(const char * string , const char * char_set) { - bool contains = false; - int i = 0; - do { - if (strchr(string , char_set[i]) != NULL) - contains = true; - i++; - } while (!contains && i < strlen(char_set)); - return contains; -} - - - -/** - This function allocates an empty menu, with title 'title'. This - particular menu will exit when one the keys in quit_keys is - entered. */ - - -menu_type * menu_alloc(const char * title , const char * quit_label , const char * quit_keys) { - menu_type * menu = (menu_type*)util_malloc(sizeof * menu ); - - menu->title = util_alloc_sprintf_escape( title , 0 ); - menu->quit_keys = util_alloc_string_copy( quit_keys ); - menu->items = vector_alloc_new(); - menu->complete_key_set = util_alloc_string_copy( quit_keys ); - menu->quit_label = util_alloc_string_copy( quit_label ); - - return menu; -} - -static menu_item_type * menu_item_alloc_empty() { - menu_item_type * item = (menu_item_type*)util_malloc(sizeof * item ); - - item->label = NULL; - item->key_set = NULL; - item->func = NULL; - item->arg = NULL; - item->separator = false; - item->helptext = false; - item->label_length = 0; - item->free_arg = NULL; - item->enabled = true; - - return item; -} - - -/** - Low level function doing the actual append of a complete item. -*/ -static void menu_append_item__(menu_type * menu , menu_item_type * item) { - vector_append_owned_ref( menu->items , item , menu_item_free__); -} - - -void menu_set_title(menu_type * menu, const char * title) { - menu->title = util_realloc_string_copy(menu->title, title); -} - - -void menu_item_disable( menu_item_type * item ) { - item->enabled = false; -} - -void menu_item_enable( menu_item_type * item ) { - item->enabled = true; -} - - -char menu_item_get_key( const menu_item_type * item ) { - if (item->enabled) - return item->key_set[0]; - else - return '-'; -} - - -void menu_item_call( const menu_item_type * item ) { - if (item->enabled) - item->func(item->arg); -} - - - -void menu_item_set_label(menu_item_type * item , const char * label) { - item->label = util_realloc_string_copy(item->label , label); - item->label_length = strlen(item->label); -} - -/** - Adds (appends) an item to the menu. - - - Obsereve that several keys can be used to invoke a particular - function, however *only* the first key in the key_set is displayed - when the menu is printed on stdout. -*/ - -menu_item_type * menu_add_item(menu_type * menu , const char * label , const char * key_set , menu_func_type * func, void * arg , arg_free_ftype * free_arg) { - if (__string_contains(menu->complete_key_set , key_set)) - util_abort("%s:fatal error when building menu - key(s) in:%s already in use \n",__func__ , key_set); - { - menu_item_type * item = menu_item_alloc_empty(); - item->key_set = util_alloc_string_copy(key_set); - item->func = func; - item->arg = arg; - item->separator = false; - item->helptext = false; - item->free_arg = free_arg; - menu_append_item__(menu , item); - menu_item_set_label(item , label); - menu->complete_key_set = util_strcat_realloc(menu->complete_key_set , key_set); - return item; - } -} - - - - -/** - Will add a '-------------' line to the menu. -*/ -void menu_add_separator(menu_type * menu) { - menu_item_type * item = menu_item_alloc_empty(); - item->separator = true; - menu_append_item__(menu , item); -} - - -/** - Will print helptext to screen -*/ - -void menu_add_helptext(menu_type * menu, const char * label ) { - menu_item_type * item = menu_item_alloc_empty(); - item->helptext = true; - menu_append_item__(menu , item); - menu_item_set_label(item , label); -} - - - - - -/** level == 0 : top line - level == 1 : separator line - level == 2 : bottom line -*/ - -static void __print_line(int l , int level) { - int i; - if (level == 0) - fputc('/' , stdout); - else if (level == 1) - fputc('|' , stdout); - else - fputc('\\' , stdout); - - - for (i=1; i < (l - 1); i++) - fputc('-' , stdout); - - - if (level == 0) - fputc('\\' , stdout); - else if (level == 1) - fputc('|' , stdout); - else - fputc('/' , stdout); - - - fputc('\n' , stdout); -} - -static void __print_sep(int l) { - int i; - printf("| "); - for (i=0; i < l; i++) - fputc('-' , stdout); - printf(" |\n"); -} - - -static void __print_helptext(char * label, int l){ - bool end_reached = false; - char * label_copy = util_alloc_string_copy( label ); - char * first_part = "Dummy3"; - char * second_part = "Dummy4"; - while(!end_reached){ - int i; - if(strlen(label_copy) > l){ - util_binary_split_string_from_max_length(label_copy , " ", l , &first_part , &second_part); - printf("| %s",first_part); - for (i=strlen(first_part); i < l; i++) - fputc(' ' , stdout); - printf(" |\n"); - label_copy = util_realloc_string_copy(label_copy, second_part); - } - else{ - printf("| %s",label_copy); - for (i=strlen(label_copy); i < l; i++) - fputc(' ' , stdout); - printf(" |\n"); - end_reached = true; - } - } -} - - - - -static void menu_display(const menu_type * menu) { - int i; - int length = strlen(menu->title); - for (i = 0; i < vector_get_size(menu->items); i++) { - const menu_item_type * item = (const menu_item_type*)vector_iget_const( menu->items , i); - if(!item->helptext) - length = util_int_max(length , item->label_length); - if(item->helptext) - length = util_int_max(length , 60); /* Hardcoded length for helptext*/ - } - - - printf("\n"); - __print_line(length + 10 , 0); - printf("| "); - util_fprintf_string(menu->title , length + 6 , center_pad , stdout); printf(" |\n"); - __print_line(length + 10 , 1); - for (i=0; i < vector_get_size(menu->items); i++) { - const menu_item_type * item = (const menu_item_type*)vector_iget_const( menu->items , i); - if (item->separator) - __print_sep(length + 6); - else if (item->helptext) - __print_helptext(item->label,length); - else { - printf("| %c: ", menu_item_get_key( item )); - util_fprintf_string(item->label , length + 3 , right_pad , stdout); - printf(" |\n"); - } - } - __print_sep(length + 6); - printf("| %c: ",menu->quit_keys[0]); - util_fprintf_string(menu->quit_label , length + 3 , right_pad , stdout); - printf(" |\n"); - __print_line(length + 10 , 2); - printf("\n"); -} - - - -/** - Reads a string from stdin: If the string is longer than one single - character it is discarded, if it is exactly one character long we - check if it is in the menus set of available command characters, - and return it *IF* it is a valid character. I.e. the return value - from this function is *GUARANTEED* to correspond to a menu item. - - Observe that the function ends with a call to getchar() - this - should remove the traling from the stdin input buffer. -*/ - -static int menu_read_cmd(const menu_type * menu) { - char cmd[256]; - - do { - printf("==> "); - fflush(stdout); fscanf(stdin , "%s" , cmd); /* We read a full string - - but we only consider it if it is exactly *ONE* character long. */ - } while ((strchr(menu->complete_key_set , cmd[0]) == NULL) || strlen(cmd) > 1); - - getchar(); /* Discards trailing from standard input buffer? */ - return cmd[0]; -} - - - - -menu_item_type * menu_get_item(const menu_type * menu, char cmd) { - int item_index = 0; - menu_item_type * item = NULL; - while (item_index < vector_get_size(menu->items)) { - menu_item_type * current_item = (menu_item_type*)vector_iget(menu->items , item_index); - if (!current_item->separator || !current_item->helptext) { - if (strchr(current_item->key_set , cmd) != NULL) { - item = current_item; - break; - } - item_index++; - } - } - - if (item == NULL) - util_abort("%s: could not locate item with key: %c \n",__func__ , cmd); - return item; -} - - - -void menu_run(const menu_type * menu) { - while (1) { - int cmd; - - - menu_display(menu); - cmd = menu_read_cmd(menu); - if (strchr(menu->quit_keys , cmd) != NULL) /* We have recieved a quit command - leave the building. */ - break; - - /* - OK - we start looking through all the available commands to see - which this is. */ - { - int item_index = 0; - while (1) { - const menu_item_type * item = (const menu_item_type*)vector_iget_const(menu->items , item_index); - if (!item->separator) { - if(!item->helptext) { - if (strchr(item->key_set , cmd) != NULL) { - /* Calling the function ... */ - menu_item_call( item ); - break; - } - } - } - item_index++; - } - } - } -} - - - -void menu_free(menu_type * menu) { - free(menu->quit_keys); - free(menu->title); - free(menu->complete_key_set); - free(menu->quit_label); - vector_free(menu->items); - free(menu); -} diff --git a/ThirdParty/Ert/lib/util/msg.c b/ThirdParty/Ert/lib/util/msg.c deleted file mode 100644 index bedc0c49f1..0000000000 --- a/ThirdParty/Ert/lib/util/msg.c +++ /dev/null @@ -1,161 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'msg.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include - -#include -#include -#include - -#define MSG_TYPE_ID 1999867 - -struct msg_struct { - UTIL_TYPE_ID_DECLARATION; - char * prompt; - char * msg; - int msg_len; - bool visible; - bool debug; -}; - - -static void __msg_assert_visible(const msg_type * msg) { - if (!msg->visible) - util_abort("%s: you must call msg_show() first - aborting.\n",__func__); -} - - -static void __blank_string(int len) { - int i; - for (i = 0; i < len; i++) - fputc('\b' , stdout); - - for (i = 0; i < len; i++) - fputc(' ' , stdout); - - for (i = 0; i < len; i++) - fputc('\b' , stdout); - -} - - -void msg_clear_msg(msg_type * msg) { - __msg_assert_visible(msg); - __blank_string(msg->msg_len); - if (msg->msg != NULL) { - free(msg->msg); - msg->msg_len = 0; - msg->msg = NULL; - } -} - - - -static void msg_clear_prompt(const msg_type * msg) { - __blank_string(strlen(msg->prompt)); -} - - -void msg_hide(msg_type * msg) { - msg_clear_msg(msg); - msg_clear_prompt(msg); - msg->visible = false; -} - - -void msg_set_prompt(msg_type * msg , const char * prompt) { - msg->prompt = util_realloc_string_copy(msg->prompt , prompt); -} - - -void msg_print_msg(const msg_type * msg) { - if (msg->msg != NULL) - printf("%s" , msg->msg); - fflush(stdout); -} - - -void msg_show(msg_type * msg) { - if (!msg->visible) { - printf("%s" , msg->prompt); - msg_print_msg(msg); - msg->visible = true; - } -} - - -void msg_update(msg_type * msg , const char * new_msg) { - __msg_assert_visible(msg); - if (!msg->debug) - msg_clear_msg(msg); - - { - msg->msg = util_realloc_string_copy(msg->msg , new_msg); - if (new_msg == NULL) - msg->msg_len = 0; - else - msg->msg_len = strlen(new_msg); - } - - if (msg->debug) - printf("%s\n",msg->msg); - else - msg_print_msg(msg); -} - - -void msg_update_int(msg_type * msg , const char * fmt , int value) { - char buffer[16]; - sprintf(buffer , fmt , value); - msg_update(msg , buffer); -} - - -UTIL_SAFE_CAST_FUNCTION( msg , MSG_TYPE_ID ) - -msg_type * msg_alloc(const char * prompt, bool debug) { - msg_type * msg = (msg_type*)util_malloc(sizeof * msg ); - UTIL_TYPE_ID_INIT( msg , MSG_TYPE_ID); - msg->prompt = util_alloc_string_copy(prompt); - - msg->msg = NULL; - msg->msg_len = 0; - msg->visible = false; - msg->debug = debug; - return msg; -} - - -void msg_free(msg_type * msg , bool clear) { - if (clear) - msg_hide(msg); - else - printf("\n"); - - free(msg->prompt); - if (msg->msg != NULL) - free(msg->msg); - - free(msg); -} - - - diff --git a/ThirdParty/Ert/lib/util/mzran.c b/ThirdParty/Ert/lib/util/mzran.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/mzran.c rename to ThirdParty/Ert/lib/util/mzran.cpp index 326cfb083d..a6c54eb9b4 100644 --- a/ThirdParty/Ert/lib/util/mzran.c +++ b/ThirdParty/Ert/lib/util/mzran.cpp @@ -19,9 +19,9 @@ #include #include -#include -#include -#include +#include +#include +#include /*****************************************************************/ /* diff --git a/ThirdParty/Ert/lib/util/node_ctype.c b/ThirdParty/Ert/lib/util/node_ctype.cpp similarity index 95% rename from ThirdParty/Ert/lib/util/node_ctype.c rename to ThirdParty/Ert/lib/util/node_ctype.cpp index 08c9219273..32aa3790e3 100644 --- a/ThirdParty/Ert/lib/util/node_ctype.c +++ b/ThirdParty/Ert/lib/util/node_ctype.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include const char * node_ctype_name(node_ctype ctype) { diff --git a/ThirdParty/Ert/lib/util/node_data.c b/ThirdParty/Ert/lib/util/node_data.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/node_data.c rename to ThirdParty/Ert/lib/util/node_data.cpp index c45362b7a6..88af1a6abd 100644 --- a/ThirdParty/Ert/lib/util/node_data.c +++ b/ThirdParty/Ert/lib/util/node_data.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include /* diff --git a/ThirdParty/Ert/lib/util/parser.c b/ThirdParty/Ert/lib/util/parser.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/parser.c rename to ThirdParty/Ert/lib/util/parser.cpp index 1105a61f46..0d1c1fdc11 100644 --- a/ThirdParty/Ert/lib/util/parser.c +++ b/ThirdParty/Ert/lib/util/parser.cpp @@ -20,9 +20,9 @@ #include #include -#include -#include -#include +#include +#include +#include #define PARSER_ESCAPE_CHAR '\\' @@ -498,7 +498,7 @@ static bool fseek_quote_end( char quoter , FILE * stream ) { static bool fgetc_while_equal( FILE * stream , const char * string , bool case_sensitive) { bool equal = true; long int current_pos = util_ftell(stream); - int string_index; + size_t string_index; for ( string_index = 0; string_index < strlen(string); string_index++) { int c = fgetc( stream ); if (!case_sensitive) @@ -625,7 +625,7 @@ void basic_parser_strip_buffer(const basic_parser_type * parser , char ** __buff char * src = *__buffer; char * target = (char*)util_calloc( ( strlen( *__buffer ) + 1) , sizeof * target ); - int src_position = 0; + size_t src_position = 0; int target_position = 0; while (src_position < strlen( src )) { int comment_length; diff --git a/ThirdParty/Ert/lib/util/path_fmt.c b/ThirdParty/Ert/lib/util/path_fmt.c deleted file mode 100644 index 49191ab623..0000000000 --- a/ThirdParty/Ert/lib/util/path_fmt.c +++ /dev/null @@ -1,314 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'path_fmt.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include - -#include "ert/util/build_config.h" -#include -#include -#include -#include - -/** -The basic idea of the path_fmt_type is that it should be possible for -a user to specify an arbirtrary path *WITH* embedded format -strings. It is implemented with the the help av variable length -argument lists. This has the following disadvantages: - - o The code gets ugly - really ugly. - - o It is difficult to provide type-safety on user input. - -Example: - - -path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt("/tmp/ECLIPSE/%s/Run-%d"); - - -Here we have allocated a path_fmt instance which will require two -additional arguments when a full path is created, a string for the -"%s" placeholder and an integer for the %d placeholder: - -char * path = path_fmt_alloc(path_fmt , "BaseCase" , 67); - -=> path = /tmp/ECLIPSE/Basecase/Run-67 - -*/ - -#define PATH_FMT_ID 7519200 - - -struct path_fmt_struct { - UTIL_TYPE_ID_DECLARATION; - char *fmt; - char *file_fmt; - bool is_directory; -}; - - -static UTIL_SAFE_CAST_FUNCTION( path_fmt , PATH_FMT_ID) - -void path_fmt_reset_fmt(path_fmt_type * path , const char * fmt) { - path->fmt = util_realloc_string_copy(path->fmt , fmt); - if (path->is_directory) - path->file_fmt = util_alloc_sprintf("%s/%%s" , fmt); -} - - - -static path_fmt_type * path_fmt_alloc__(const char * fmt , bool is_directory) { - path_fmt_type * path = (path_fmt_type*)util_malloc(sizeof * path ); - UTIL_TYPE_ID_INIT(path , PATH_FMT_ID); - path->fmt = NULL; - path->file_fmt = NULL; - path->is_directory = is_directory; - - path_fmt_reset_fmt(path , fmt); - return path; -} - - -/** - - This function is used to allocate a path_fmt instance which is - intended to hold a directory, if the second argument is true, the - resulting directory will be automatically created when - path_fmt_alloc_path() is later invoked. - - Example: - ------- - path_fmt_type * path_fmt = path_fmt_alloc_directory_fmt("/tmp/scratch/member%d/%d.%d" , true); - .... - .... - char * path = path_fmt_alloc_path(path_fmt , 10 , 12 , 15); - char * file = path_fmt_alloc_file(path_fmt , 8 , 12 , 17, "SomeFile"); - - After the two last function calls we will have: - - o path = "/tmp/scratch/member10/12.15" - and this directory has - been created. - - o file = "/tmp/scratch/member8/12.17/SomeFile - and the directory - /tmp/scratch/member8/12.17 has been created. - - - Observe that the functionality is implemented with the help av - variable length argument lists, and **NO** checking of argument list - versus format string is performed. -*/ - - -path_fmt_type * path_fmt_alloc_directory_fmt(const char * fmt) { - return path_fmt_alloc__(fmt , true); -} - - - -/* - Most general. Can afterwards be used to allocate strings - representing both directories and files. -*/ - -path_fmt_type * path_fmt_alloc_path_fmt(const char * fmt) { - return path_fmt_alloc__(fmt , false ); -} - - - -/** - Present the user with a prompt, and reads format specifier string - from stdin. Currently not possible to specify argument types. -*/ - -path_fmt_type * path_fmt_scanf_alloc(const char * prompt , int types , const node_ctype * type_list, bool is_directory) { - char * fmt; - fmt = util_scanf_alloc_string(prompt); - return path_fmt_alloc__(fmt , is_directory); -} - -path_fmt_type * path_fmt_copyc(const path_fmt_type *path) { - path_fmt_type *new_path = path_fmt_alloc__(path->fmt , path->is_directory); - return new_path; -} - -char * path_fmt_alloc_path_va(const path_fmt_type * path ,bool auto_mkdir, va_list ap) { - char * new_path = util_alloc_sprintf_va(path->fmt , ap ); - if (auto_mkdir) - if (! util_is_directory(new_path) ) - util_make_path(new_path); - return new_path; -} - - -char * path_fmt_alloc_path(const path_fmt_type * path , bool auto_mkdir , ...) { - char * new_path; - va_list ap; - va_start(ap , auto_mkdir); - new_path = path_fmt_alloc_path_va(path ,auto_mkdir , ap); - va_end(ap); - return new_path; -} - - - -/** - This function is used to allocate a filename (full path) from a - path_fmt instance: - - Eaxample: - - path_fmt_type * path_fmt = path_fmt_alloc_directory("/tmp/path%d/X.%02d"); - char * file = path_fmt_alloc_file(path_fmt , 100 , 78 , "SomeFile.txt") - - This will allocate the filename: /tmp/path100/X.78/SomeFile.txt; if - it does not already exist, the underlying directory will be - created. Observe that there is nothing special about the filename - argument (i.e. 'SomeFile.txt' in the current example), it is just - the last argument to the path_fmt_alloc_file() function call - - however it must be a string; i.e. if you are making a purely numeric - filename you must convert to a string. - - Observe that the handling of the variable length argument lists gets - seriously ugly. - - ----------------------------------------------------------------- - - If auto_mkdir == true the function behaves in two different ways - depending on whether the path_instance was allocated as a directory - or as a path: - - * [Directory]: When the path_fmt instance was allocated as a - directory, "/%s" format decriptor will be appended to the format. - - * [Path]: The resulting string will be split on "/", and the path - component will be created. -*/ - - -char * path_fmt_alloc_file(const path_fmt_type * path , bool auto_mkdir , ...) { - if (path->is_directory) { - char * filename; - va_list tmp_va , ap; - va_start(ap , auto_mkdir); - UTIL_VA_COPY(tmp_va , ap); - filename = util_alloc_sprintf_va( path->file_fmt , tmp_va ); - if (auto_mkdir) { - const char * __path = util_alloc_sprintf_va( path->fmt , tmp_va ); - if (! util_is_directory(__path)) - util_make_path( __path ); - free((char *) __path ); - } - va_end(ap); - return filename; - } else { - - char * filename; - va_list tmp_va , ap; - va_start(ap , auto_mkdir); - UTIL_VA_COPY(tmp_va , ap); - filename = util_alloc_sprintf_va( path->fmt , tmp_va ); - if (auto_mkdir) { - char * __path; - util_alloc_file_components(filename , &__path , NULL , NULL); - util_make_path(__path); - free(__path); - } - va_end(ap); - - return filename; - } -} - - - -/** - This function is used to assert that the format in a path_fmt - instance is according to specification. What is checked is that the - format string contains %d, %lfg and %s in as specified in the - input_types vector. - - Observe that %s is mapped to void_pointer - as the node_ctype does not - have typed pointers. -*/ - - -/* -void path_fmt_assert_fmt(const path_fmt_type * path , int num_input , const node_ctype * input_types) { - int input_nr = 0; - int char_nr = 0; - do { - if (path->fmt[char_nr] == '%') { - - } - } -} -*/ - -/* - fmt == NULL - ----------- - The function will return NULL, possibly freeing the incoming - path_fmt instance if that is different from NULL. - - - fmt != NULL - ----------- - The current path_fmt instance will be updated, or a new created. The - new/updated path_fmt instance is returned. -*/ - -path_fmt_type * path_fmt_realloc_path_fmt( path_fmt_type * path_fmt, const char * fmt ) { - if (fmt == NULL) { - if (path_fmt != NULL) - path_fmt_free( path_fmt ); - return NULL; - } else { - if (path_fmt == NULL) - return path_fmt_alloc_path_fmt( fmt ); - else { - path_fmt_reset_fmt( path_fmt , fmt ); - return path_fmt; - } - } -} - - -const char * path_fmt_get_fmt(const path_fmt_type * path) { - if (path == NULL) - return NULL; - else - return path->fmt; -} - - -void path_fmt_free(path_fmt_type * path) { - free(path->fmt); - if (path->is_directory) - free(path->file_fmt); - free(path); -} - - -void path_fmt_free__( void * arg ) { - path_fmt_type * path_fmt = path_fmt_safe_cast( arg ); - path_fmt_free( path_fmt ); -} diff --git a/ThirdParty/Ert/lib/util/path_stack.c b/ThirdParty/Ert/lib/util/path_stack.cpp similarity index 83% rename from ThirdParty/Ert/lib/util/path_stack.c rename to ThirdParty/Ert/lib/util/path_stack.cpp index 824be798f4..3f71a9191b 100644 --- a/ThirdParty/Ert/lib/util/path_stack.c +++ b/ThirdParty/Ert/lib/util/path_stack.cpp @@ -1,30 +1,31 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'path_stack.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include +#include #include #include #include -#include -#include -#include +#include +#include +#include /** This file implements the structure path_stack which is vaguely @@ -47,22 +48,22 @@ struct path_stack_struct { /** This will create a new path_stack instance; it will push anything - on the current stack of paths. + on the current stack of paths. */ path_stack_type * path_stack_alloc() { path_stack_type * path_stack = (path_stack_type*)util_malloc( sizeof * path_stack ); - path_stack->stack = stringlist_alloc_new(); - path_stack->storage = stringlist_alloc_new(); - return path_stack; + path_stack->stack = stringlist_alloc_new(); + path_stack->storage = stringlist_alloc_new(); + return path_stack; } -/* +/* This will destroy the storage taken by the current path_stack instance. This function will NOT pop any elements off the stack; so if you have not manully clerad the stack with the right number of path_stack_pop() calls, you will (probably) destroy the path stack - instance with an incorrect value of cwd. + instance with an incorrect value of cwd. */ void path_stack_free( path_stack_type * path_stack ) { @@ -85,7 +86,7 @@ bool path_stack_push( path_stack_type * path_stack , const char * path ) { if (path != NULL) if (util_chdir( path ) != 0) return false; - + path_stack_push_cwd( path_stack ); return true; } diff --git a/ThirdParty/Ert/lib/util/perm_vector.c b/ThirdParty/Ert/lib/util/perm_vector.cpp similarity index 94% rename from ThirdParty/Ert/lib/util/perm_vector.c rename to ThirdParty/Ert/lib/util/perm_vector.cpp index ff4a1b323b..0b6ccde713 100644 --- a/ThirdParty/Ert/lib/util/perm_vector.c +++ b/ThirdParty/Ert/lib/util/perm_vector.cpp @@ -17,9 +17,9 @@ */ #include -#include -#include -#include +#include +#include +#include #define PERM_VECTOR_TYPE_ID 661433 diff --git a/ThirdParty/Ert/lib/util/regression.c b/ThirdParty/Ert/lib/util/regression.c deleted file mode 100644 index 4b1c3b8dba..0000000000 --- a/ThirdParty/Ert/lib/util/regression.c +++ /dev/null @@ -1,143 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'regression.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include - -#include -#include -#include -#include -#include - - - -/** - Will normalize the the data in X and Y: - - 1. Y -> Y - - 2. For each column: X -> X - - 3. For each column: ||X|| = 1 - - The mean Y value is returned from the function, and the mean X and - normalization factor for X is returned, for each column, in the - matrices (row vectors) X_mean and X_norm. -*/ - - -double regression_scale(matrix_type * X , matrix_type * Y , matrix_type * X_mean , matrix_type * X_norm) { - int nvar = matrix_get_columns( X ); - int nsample = matrix_get_rows( X ); - - if ( matrix_get_rows( Y ) != nsample) - util_abort("%s: dimension mismatch X:[%d,%d] Y:%d \n",__func__ , nsample , nvar , matrix_get_rows( Y )); - - if ( matrix_get_columns( X_norm ) != nvar) - util_abort("%s: dimension mismtach X_norm \n",__func__); - - if ( matrix_get_columns( X_mean ) != nvar) - util_abort("%s: dimension mismtach X_mean \n",__func__); - - { - double y_mean = matrix_get_column_sum( Y , 0 ) / nsample; - matrix_shift_column( Y , 0 , -y_mean ); - - { - int col; - for (col = 0; col < nvar; col++) { - double mean = matrix_get_column_sum(X , col ) / nsample; - matrix_shift_column(X , col , -mean); - matrix_iset( X_mean , 0 , col , mean ); - } - - for (col=0; col < nvar; col++) { - double norm = 1.0/sqrt( (1.0 / (nsample - 1)) * matrix_get_column_sum2( X , col )); - matrix_iset( X_norm , 0 , col , norm ); - } - } - return y_mean; - } -} - - -double regression_unscale(const matrix_type * beta , const matrix_type * X_norm , const matrix_type * X_mean , double Y_mean , matrix_type * beta0) { - int nvars = matrix_get_rows( beta0 ); - int k; - double yshift = 0; - - for (k=0; k < nvars; k++) { - double scaled_beta = matrix_iget( beta , k , 0 ) * matrix_iget( X_norm , 0 , k); - matrix_iset( beta0 , k , 0 , scaled_beta); - yshift += scaled_beta * matrix_iget( X_mean , 0 , k ); - } - return Y_mean - yshift; -} - - -/** - Performs an ordinary least squares estimation of the parameter - vector beta. - - beta = inv(X'·X)·X'·y -*/ - -void regression_augmented_OLS( const matrix_type * X , const matrix_type * Y , const matrix_type* Z, matrix_type * beta) { - /* - Solves the following especial augmented regression problem: - - [Y ; 0] = [X ; Z] beta + epsilon - - where 0 is the zero matrix of same size as Y. - - The solution to this OLS is: - - inv(X'X + Z'Z) * X' * Y - - The semicolon denotes row concatenation and the apostrophe the transpose. - - */ - int nvar = matrix_get_columns( X ); - matrix_type * Xt = matrix_alloc_transpose( X ); - matrix_type * Xinv = matrix_alloc( nvar , nvar); - matrix_matmul( Xinv , Xt , X ); - - matrix_type * Zt = matrix_alloc_transpose( Z ); - matrix_type * ZtZ = matrix_alloc( nvar , nvar); - matrix_matmul( ZtZ , Zt , Z ); - - // Xinv <- X'X + Z'Z - matrix_inplace_add(Xinv, ZtZ); - - // Sometimes the inversion fails - add a small regularization to diagonal - for (int i = 0; i < nvar; ++i) - matrix_iadd(Xinv, i, i, 1e-10); - - matrix_inv( Xinv ); // Xinv is always invertible - { - matrix_type * tmp = matrix_alloc_matmul( Xinv , Xt ); - matrix_matmul( beta , tmp , Y ); - matrix_free( tmp ); - } - - matrix_free( Xt ); - matrix_free( Xinv ); - matrix_free( Zt ); - matrix_free( ZtZ ); -} - diff --git a/ThirdParty/Ert/lib/util/rng.c b/ThirdParty/Ert/lib/util/rng.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/rng.c rename to ThirdParty/Ert/lib/util/rng.cpp index 2408cd5baf..c940eed166 100644 --- a/ThirdParty/Ert/lib/util/rng.c +++ b/ThirdParty/Ert/lib/util/rng.cpp @@ -20,10 +20,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define RNG_TYPE_ID 66154432 #ifdef __cplusplus @@ -263,7 +263,7 @@ unsigned int rng_get_max_int(const rng_type * rng) { void rng_shuffle( rng_type * rng , char * data , size_t element_size , size_t num_elements) { void * tmp = util_malloc( element_size ); - int index1; + size_t index1; for ( index1=0; index1 < num_elements; index1++) { int index2 = rng_get_int( rng , num_elements ); diff --git a/ThirdParty/Ert/lib/util/set.c b/ThirdParty/Ert/lib/util/set.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/set.c rename to ThirdParty/Ert/lib/util/set.cpp index 68fbd7a9fc..0ee87f81f5 100644 --- a/ThirdParty/Ert/lib/util/set.c +++ b/ThirdParty/Ert/lib/util/set.cpp @@ -21,10 +21,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define SET_TYPE_ID 816523 @@ -40,7 +40,7 @@ static UTIL_SAFE_CAST_FUNCTION( set , SET_TYPE_ID ) set_type * set_alloc(int size, const char ** keyList) { set_type * set = (set_type*) malloc(sizeof * set); UTIL_TYPE_ID_INIT( set , SET_TYPE_ID ); - set->key_hash = hash_alloc_unlocked(); + set->key_hash = hash_alloc(); { int ikey; for (ikey = 0; ikey < size; ikey++) diff --git a/ThirdParty/Ert/lib/util/statistics.c b/ThirdParty/Ert/lib/util/statistics.cpp similarity index 97% rename from ThirdParty/Ert/lib/util/statistics.c rename to ThirdParty/Ert/lib/util/statistics.cpp index cc6734198e..ead3d3ff45 100644 --- a/ThirdParty/Ert/lib/util/statistics.c +++ b/ThirdParty/Ert/lib/util/statistics.cpp @@ -19,9 +19,9 @@ #include #include -#include -#include -#include +#include +#include +#include double statistics_mean( const double_vector_type * data_vector ) { diff --git a/ThirdParty/Ert/lib/util/stepwise.c b/ThirdParty/Ert/lib/util/stepwise.c deleted file mode 100644 index 4a166bc1f9..0000000000 --- a/ThirdParty/Ert/lib/util/stepwise.c +++ /dev/null @@ -1,456 +0,0 @@ -#include -#include - -#include -#include -#include -#include -#include -#include - - - -#define STEPWISE_TYPE_ID 8722106 - -struct stepwise_struct { - UTIL_TYPE_ID_DECLARATION; - - matrix_type * X0; // Externally supplied data. - matrix_type * E0; // Externally supplied data. - matrix_type * Y0; - - matrix_type * beta; // Quantities estimated by the stepwise algorithm - double Y_mean; - matrix_type * X_mean; - matrix_type * X_norm; - bool_vector_type * active_set; - rng_type * rng; // Needed in the cross-validation - double R2; // Final R2 -}; - - - -static double stepwise_estimate__( stepwise_type * stepwise , bool_vector_type * active_rows) { - matrix_type * X; - matrix_type * E; - matrix_type * Y; - - double y_mean = 0; - int ncols = matrix_get_columns( stepwise->X0 ); - int nrows = matrix_get_rows( stepwise->X0 ); - - int nsample = bool_vector_count_equal( active_rows , true ); - int nvar = bool_vector_count_equal( stepwise->active_set , true ); - - - matrix_set( stepwise->beta , 0 ); // It is essential to make sure that old finite values in the beta0 vector do not hang around. - - - /* - Extracting the data used for regression, and storing them in the - temporary local matrices X and Y. Selecting data is based both on - which varibles are active (stepwise->active_set) and which rows - should be used for regression, versus which should be used for - validation (@active_rows). - */ - if ((nsample < nrows) || (nvar < ncols)) { - X = matrix_alloc( nsample , nvar ); - E = matrix_alloc( nsample , nvar ); - Y = matrix_alloc( nsample , 1); - - { - int icol,irow; // Running over all values. - int arow,acol; // Running over active values. - arow = 0; - for (irow = 0; irow < nrows; irow++) { - if (bool_vector_iget( active_rows , irow )) { - acol = 0; - for (icol = 0; icol < ncols; icol++) { - if (bool_vector_iget( stepwise->active_set , icol )) { - matrix_iset( X , arow , acol , matrix_iget( stepwise->X0 , irow , icol )); - matrix_iset( E , arow , acol , matrix_iget( stepwise->E0 , irow , icol )); - acol++; - } - } - - matrix_iset( Y , arow , 0 , matrix_iget( stepwise->Y0 , irow , 0 )); - arow++; - } - } - } - } else { - X = matrix_alloc_copy( stepwise->X0 ); - E = matrix_alloc_copy( stepwise->E0 ); - Y = matrix_alloc_copy( stepwise->Y0 ); - } - - - { - - if (stepwise->X_mean != NULL) - matrix_free( stepwise->X_mean); - - stepwise->X_mean = matrix_alloc( 1 , nvar ); - - if (stepwise->X_norm != NULL) - matrix_free( stepwise->X_norm); - - stepwise->X_norm = matrix_alloc( 1 , nvar ); - - matrix_type * beta = matrix_alloc( nvar , 1); /* This is the beta vector as estimated from the OLS estimator. */ - - regression_augmented_OLS( X , Y , E, beta ); - - - /* - In this code block the beta/tmp_beta vector which is dense with - fewer elements than the full model is scattered into the beta0 - vector which has full size and @nvar elements. - */ - { - int ivar,avar; - avar = 0; - for (ivar = 0; ivar < ncols; ivar++) { - if (bool_vector_iget( stepwise->active_set , ivar )) { - matrix_iset( stepwise->beta , ivar , 0 , matrix_iget( beta , avar , 0)); - avar++; - } - } - } - - - matrix_free( beta ); - } - - matrix_free( X ); - matrix_free( E ); - matrix_free( Y ); - return y_mean; -} - - - - -static double stepwise_eval__( const stepwise_type * stepwise , const matrix_type * x ) { - return matrix_row_column_dot_product( x , 0 , stepwise->beta , 0 ); -} - - - -static double stepwise_test_var( stepwise_type * stepwise , int test_var , int blocks) { - double prediction_error = 0; - - bool_vector_iset( stepwise->active_set , test_var , true ); // Temporarily activate this variable - { - - int nvar = matrix_get_columns( stepwise->X0 ); - int nsample = matrix_get_rows( stepwise->X0 ); - int block_size = nsample / blocks; - bool_vector_type * active_rows = bool_vector_alloc( nsample, true ); - - - - - - /*True Cross-Validation: */ - int * randperms = (int*)util_calloc( nsample , sizeof * randperms ); - for (int i=0; i < nsample; i++) - randperms[i] = i; - - /* Randomly perturb ensemble indices */ - rng_shuffle_int( stepwise->rng , randperms , nsample ); - - - for (int iblock = 0; iblock < blocks; iblock++) { - - int validation_start = iblock * block_size; - int validation_end = validation_start + block_size - 1; - - if (iblock == (blocks - 1)) - validation_end = nsample - 1; - - /* - Ensure that the active_rows vector has a block consisting of - the interval [validation_start : validation_end] which is set to - false, and the remaining part of the vector is set to true. - */ - { - bool_vector_set_all(active_rows, true); - /* - If blocks == 1 that means all datapoint are used in the - regression, and then subsequently reused in the R2 - calculation. - */ - if (blocks > 1) { - for (int i = validation_start; i <= validation_end; i++) { - bool_vector_iset( active_rows , randperms[i] , false ); - } - } - } - - - /* - Evaluate the prediction error on the validation part of the - dataset. - */ - { - stepwise_estimate__( stepwise , active_rows ); - { - int irow; - matrix_type * x_vector = matrix_alloc( 1 , nvar ); - //matrix_type * e_vector = matrix_alloc( 1 , nvar ); - for (irow=validation_start; irow <= validation_end; irow++) { - matrix_copy_row( x_vector , stepwise->X0 , 0 , randperms[irow]); - //matrix_copy_row( e_vector , stepwise->E0 , 0 , randperms[irow]); - { - double true_value = matrix_iget( stepwise->Y0 , randperms[irow] , 0 ); - double estimated_value = stepwise_eval__( stepwise , x_vector ); - prediction_error += (true_value - estimated_value) * (true_value - estimated_value); - //double e_estimated_value = stepwise_eval__( stepwise , e_vector ); - //prediction_error += e_estimated_value*e_estimated_value; - } - - } - matrix_free( x_vector ); - } - } - } - - free( randperms ); - bool_vector_free( active_rows ); - } - - /*inactivate the test_var-variable after completion*/ - bool_vector_iset( stepwise->active_set , test_var , false ); - return prediction_error; -} - - -void stepwise_estimate( stepwise_type * stepwise , double deltaR2_limit , int CV_blocks) { - int nvar = matrix_get_columns( stepwise->X0 ); - int nsample = matrix_get_rows( stepwise->X0 ); - double currentR2 = -1; - bool_vector_type * active_rows = bool_vector_alloc( nsample , true ); - - - /*Reset beta*/ - for (int i = 0; i < nvar; i++) { - matrix_iset(stepwise->beta, i , 0 , 0.0); - } - - - - bool_vector_set_all( stepwise->active_set , false ); - - double MSE_min = 10000000; - double Prev_MSE_min = MSE_min; - double minR2 = -1; - - while (true) { - int best_var = 0; - Prev_MSE_min = MSE_min; - - /* - Go through all the inactive variables, and calculate the - resulting prediction error IF this particular variable is added; - keep track of the variable which gives the lowest prediction error. - */ - for (int ivar = 0; ivar < nvar; ivar++) { - if (!bool_vector_iget( stepwise->active_set , ivar)) { - double newR2 = stepwise_test_var(stepwise , ivar , CV_blocks); - if ((minR2 < 0) || (newR2 < minR2)) { - minR2 = newR2; - best_var = ivar; - } - } - } - - /* - If the best relative improvement in prediction error is better - than @deltaR2_limit, the corresponding variable is added to the - active set, and we return to repeat the loop one more - time. Otherwise we just exit. - */ - - { - MSE_min = minR2; - double deltaR2 = MSE_min / Prev_MSE_min; - - if (( currentR2 < 0) || deltaR2 < deltaR2_limit) { - bool_vector_iset( stepwise->active_set , best_var , true ); - currentR2 = minR2; - bool_vector_set_all(active_rows, true); - stepwise_estimate__( stepwise , active_rows ); - } else { - /* The gain in prediction error is so small that we just leave the building. */ - /* NB! Need one final compuation of beta (since the test_var function does not reset the last tested beta value !) */ - bool_vector_set_all(active_rows, true); - stepwise_estimate__( stepwise , active_rows ); - break; - } - - if (bool_vector_count_equal( stepwise->active_set , true) == matrix_get_columns( stepwise->X0 )) { - stepwise_estimate__( stepwise , active_rows ); - break; /* All variables are active. */ - } - } - } - - stepwise_set_R2(stepwise, currentR2); - bool_vector_free( active_rows ); -} - - - -double stepwise_eval( const stepwise_type * stepwise , const matrix_type * x ) { - double yHat = stepwise_eval__(stepwise, x ); - return yHat; -} - - - -static stepwise_type * stepwise_alloc__( int nsample , int nvar , rng_type * rng) { - stepwise_type * stepwise = (stepwise_type*)util_malloc( sizeof * stepwise ); - - stepwise->X_mean = NULL; - stepwise->X_norm = NULL; - stepwise->Y_mean = 0.0; - stepwise->rng = rng; - stepwise->X0 = NULL; - stepwise->E0 = NULL; - stepwise->Y0 = NULL; - stepwise->active_set = bool_vector_alloc( nvar , true ); - stepwise->beta = matrix_alloc( nvar , 1 ); - - return stepwise; -} - - -stepwise_type * stepwise_alloc0( rng_type * rng) { - stepwise_type * stepwise = (stepwise_type*)util_malloc( sizeof * stepwise ); - - stepwise->rng = rng; - stepwise->X0 = NULL; - stepwise->E0 = NULL; - stepwise->Y0 = NULL; - stepwise->beta = NULL; - stepwise->active_set = NULL; - stepwise->X_mean = NULL; - stepwise->X_norm = NULL; - stepwise->Y_mean = 0.0; - stepwise->R2 = -1.0; - - return stepwise; -} - - - -stepwise_type * stepwise_alloc1( int nsample , int nvar, rng_type * rng, const matrix_type* St, const matrix_type* Et) { - stepwise_type * stepwise = stepwise_alloc__( nsample , nvar , rng); - - stepwise->rng = rng; - stepwise->X0 = matrix_alloc_copy(St); // It would be nice to get rid of these copies, but due to data race it is not possible at the moment - stepwise->E0 = matrix_alloc_copy(Et); - stepwise->Y0 = NULL; //matrix_alloc( nsample , 1 ); - - return stepwise; -} - - -void stepwise_set_Y0( stepwise_type * stepwise , matrix_type * Y) { - stepwise->Y0 = Y; -} - -void stepwise_set_X0( stepwise_type * stepwise , matrix_type * X) { - stepwise->X0 = X; -} - -void stepwise_set_E0( stepwise_type * stepwise , matrix_type * E) { - stepwise->E0 = E; -} - - -void stepwise_set_beta( stepwise_type * stepwise , matrix_type * b) { -if (stepwise->beta != NULL) - matrix_free( stepwise->beta ); - - stepwise->beta = b; -} - -void stepwise_set_active_set( stepwise_type * stepwise , bool_vector_type * a) { - if (stepwise->active_set != NULL) - bool_vector_free( stepwise->active_set ); - - stepwise->active_set = a; -} - -void stepwise_set_R2( stepwise_type * stepwise , const double R2) { - stepwise->R2 = R2; -} - -matrix_type * stepwise_get_X0( stepwise_type * stepwise ) { - return stepwise->X0; -} - -matrix_type * stepwise_get_Y0( stepwise_type * stepwise ) { - return stepwise->Y0; -} - -double stepwise_get_R2(const stepwise_type * stepwise ) { - return stepwise->R2; -} - -int stepwise_get_nsample( stepwise_type * stepwise ) { - return matrix_get_rows( stepwise->X0 ); -} - -int stepwise_get_nvar( stepwise_type * stepwise ) { - return matrix_get_columns( stepwise->X0 ); -} - -int stepwise_get_n_active( stepwise_type * stepwise ) { - return bool_vector_count_equal( stepwise->active_set , true); -} - -bool_vector_type * stepwise_get_active_set( stepwise_type * stepwise ) { - return stepwise->active_set; -} - -double stepwise_iget_beta(const stepwise_type * stepwise, const int index ) { - return matrix_iget( stepwise->beta, index, 0); -} - -double stepwise_get_sum_beta(const stepwise_type * stepwise ) { - return matrix_get_column_abssum( stepwise->beta, 0); -} - -void stepwise_isetY0( stepwise_type * stepwise , int i , double value ) { - matrix_iset( stepwise->Y0, i , 0 , value ); -} - - -void stepwise_free( stepwise_type * stepwise ) { - if (stepwise->active_set != NULL) { - bool_vector_free( stepwise->active_set ); - } - - - if (stepwise->beta != NULL) - matrix_free( stepwise->beta ); - - - if (stepwise->X_mean != NULL) - matrix_free( stepwise->X_mean ); - - - if (stepwise->X_norm != NULL) - matrix_free( stepwise->X_norm ); - - - matrix_free( stepwise->X0 ); - matrix_free( stepwise->E0 ); - matrix_free( stepwise->Y0 ); - - free( stepwise ); -} - diff --git a/ThirdParty/Ert/lib/util/string_util.c b/ThirdParty/Ert/lib/util/string_util.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/string_util.c rename to ThirdParty/Ert/lib/util/string_util.cpp index ec7c85b654..509c565c5b 100644 --- a/ThirdParty/Ert/lib/util/string_util.c +++ b/ThirdParty/Ert/lib/util/string_util.cpp @@ -17,13 +17,15 @@ */ #include +#include +#include -#include -#include -#include -#include -#include -#include +#include +#include +#include +#include +#include +#include /*****************************************************************/ @@ -57,7 +59,7 @@ static bool valid_characters( const char * range_string ) { bool valid = false; if (range_string) { - int offset = 0; + size_t offset = 0; valid = true; while (true) { char c = range_string[offset]; diff --git a/ThirdParty/Ert/lib/util/stringlist.c b/ThirdParty/Ert/lib/util/stringlist.cpp similarity index 92% rename from ThirdParty/Ert/lib/util/stringlist.c rename to ThirdParty/Ert/lib/util/stringlist.cpp index b074aabe56..bf134c4f03 100644 --- a/ThirdParty/Ert/lib/util/stringlist.c +++ b/ThirdParty/Ert/lib/util/stringlist.cpp @@ -21,17 +21,20 @@ #include #include +#ifdef ERT_HAVE_OPENDIR +#include +#include +#endif + #ifdef ERT_HAVE_GLOB #include #else #include #endif -#include -#include -#include -#include - +#include +#include +#include #define STRINGLIST_TYPE_ID 671855 @@ -621,13 +624,6 @@ stringlist_type * stringlist_alloc_from_split( const char * input_string , const /*****************************************************************/ -void stringlist_buffer_fwrite( const stringlist_type * s , buffer_type * buffer ) { - int i; - int size = stringlist_get_size( s ); - buffer_fwrite_int( buffer , size ); - for (i=0; i < size; i++) - buffer_fwrite_string(buffer , stringlist_iget(s , i) ); -} void stringlist_fwrite(const stringlist_type * s, FILE * stream) { @@ -652,13 +648,6 @@ void stringlist_fread(stringlist_type * s, FILE * stream) { } -void stringlist_buffer_fread( stringlist_type * s , buffer_type * buffer ) { - int size = buffer_fread_int( buffer ); - int i; - stringlist_clear(s); - for (i=0; i < size; i++) - stringlist_append_owned_ref( s , buffer_fread_alloc_string( buffer )); -} @@ -729,7 +718,7 @@ int stringlist_select_matching(stringlist_type * names , const char * pattern) { stringlist_clear( names ); { - int i; + size_t i; glob_t * pglob = (glob_t*)util_malloc( sizeof * pglob ); int glob_flags = 0; glob( pattern , glob_flags , NULL , pglob); @@ -772,6 +761,68 @@ int stringlist_select_matching_files(stringlist_type * names , const char * path #endif } + +int stringlist_select_files(stringlist_type * names, const char * path, file_pred_ftype * predicate, const void * pred_arg) { + stringlist_clear(names); + char * path_arg = path ? util_alloc_string_copy(path) : util_alloc_cwd(); + +#ifdef ERT_HAVE_OPENDIR + DIR * dir = opendir(path_arg); + if (!dir) { + free(path_arg); + return 0; + } + + while (true) { + struct dirent * entry = readdir(dir); + if (!entry) + break; + + if (util_string_equal(entry->d_name, ".")) + continue; + + if (util_string_equal(entry->d_name, "..")) + continue; + + if (predicate && !predicate(entry->d_name, pred_arg)) + continue; + + stringlist_append_owned_ref(names, util_alloc_filename(path, entry->d_name, NULL)); + } + + closedir(dir); + +#else + + WIN32_FIND_DATA file_data; + HANDLE file_handle; + char * pattern = util_alloc_filename( path_arg , "*", NULL ); + + file_handle = FindFirstFile( pattern , &file_data ); + if (file_handle != INVALID_HANDLE_VALUE) { + do { + if (util_string_equal(file_data.cFileName, ".")) + continue; + + if (util_string_equal(file_data.cFileName, "..")) + continue; + + if (predicate && !predicate(file_data.cFileName, pred_arg)) + continue; + + stringlist_append_owned_ref(names, util_alloc_filename(path, file_data.cFileName, NULL)); + } while (FindNextFile( file_handle , &file_data) != 0); + FindClose( file_handle ); + } + free( pattern ); + +#endif + + free(path_arg); + return stringlist_get_size(names); +} + + int stringlist_append_matching_elements(stringlist_type * target , const stringlist_type * src , const char * pattern) { int ielm; int match_count = 0; @@ -790,12 +841,17 @@ int stringlist_append_matching_elements(stringlist_type * target , const stringl return stringlist_append_matching_elements( target , src , pattern ); } + +static int void_strcmp(const void* s1, const void *s2) { + return strcmp((char*)s1, (char*)s2); +} + bool stringlist_unique(const stringlist_type * stringlist ) { bool unique = true; stringlist_type * cpy = stringlist_alloc_shallow_copy(stringlist); - stringlist_sort(cpy, strcmp); + stringlist_sort(cpy, void_strcmp); for (int i = 0; i < stringlist_get_size(cpy) - 1; i++) { const char* s1 = stringlist_iget(cpy, i); const char* s2 = stringlist_iget(cpy, i+1); diff --git a/ThirdParty/Ert/lib/util/struct_vector.c b/ThirdParty/Ert/lib/util/struct_vector.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/struct_vector.c rename to ThirdParty/Ert/lib/util/struct_vector.cpp index d50d108ea8..c79891b810 100644 --- a/ThirdParty/Ert/lib/util/struct_vector.c +++ b/ThirdParty/Ert/lib/util/struct_vector.cpp @@ -19,8 +19,8 @@ #include #include -#include -#include +#include +#include #define STRUCT_VECTOR_TYPE_ID 772562097 diff --git a/ThirdParty/Ert/lib/util/subst_func.c b/ThirdParty/Ert/lib/util/subst_func.c deleted file mode 100644 index 5484872acd..0000000000 --- a/ThirdParty/Ert/lib/util/subst_func.c +++ /dev/null @@ -1,210 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'subst_func.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - - -#include -#include - -#include -#include -#include -#include -#include - - -#define SUBST_FUNC_TYPE_ID 646781 -#define SUBST_FUNC_POOL_TYPE_ID 7641 - -struct subst_func_pool_struct { - UTIL_TYPE_ID_DECLARATION; - hash_type * func_table; -}; - - - -struct subst_func_struct { - UTIL_TYPE_ID_DECLARATION; - subst_func_ftype * func; - char * name; - char * doc_string; /* doc_string for this function - can be NULL. */ - bool vararg; - int argc_min; - int argc_max; - void * arg; /* 100% unmanaged void argument passed in from the construction. */ -}; - - - -char * subst_func_eval( const subst_func_type * subst_func , const stringlist_type * args) { - if (!subst_func->vararg) { - /* Checking that we have the right number of arguments. */ - int argc = stringlist_get_size( args ); - if (argc < subst_func->argc_min || argc > subst_func->argc_max) { - fprintf(stderr,"Fatal error when appying function:%s - got %d arguments: [",subst_func->name , argc); - stringlist_fprintf(args , " " , stderr); - fprintf(stderr,"] expected %d-%d arguments.\n", subst_func->argc_min , subst_func->argc_max); - util_abort("%s: Fatal error - aborting \n",__func__); - } - } - printf("Running:%s \n",subst_func->name); - return subst_func->func( args , subst_func->arg ); -} - - -subst_func_type * subst_func_alloc( const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg) { - subst_func_type * subst_func = (subst_func_type*)util_malloc( sizeof * subst_func ); - UTIL_TYPE_ID_INIT( subst_func , SUBST_FUNC_TYPE_ID ); - subst_func->func = func; - subst_func->name = util_alloc_string_copy( func_name ); - subst_func->vararg = vararg; - subst_func->argc_min = argc_min; - subst_func->argc_max = argc_max; - subst_func->doc_string = util_alloc_string_copy( doc_string ); - subst_func->arg = arg; - return subst_func; -} - - -void subst_func_free( subst_func_type * subst_func ) { - util_safe_free( subst_func->doc_string ); - free( subst_func->name ); - free( subst_func ); -} - - -UTIL_SAFE_CAST_FUNCTION( subst_func , SUBST_FUNC_TYPE_ID); - -static void subst_func_free__( void * arg ) { - subst_func_free( subst_func_safe_cast( arg )); -} - - - - -/*****************************************************************/ - -UTIL_IS_INSTANCE_FUNCTION( subst_func_pool , SUBST_FUNC_POOL_TYPE_ID); - -subst_func_pool_type * subst_func_pool_alloc( ) { - subst_func_pool_type * pool = (subst_func_pool_type*)util_malloc( sizeof * pool ); - UTIL_TYPE_ID_INIT( pool , SUBST_FUNC_POOL_TYPE_ID ); - pool->func_table = hash_alloc_unlocked(); - return pool; -} - - - -void subst_func_pool_free( subst_func_pool_type * pool ) { - hash_free( pool->func_table ); - free( pool ); -} - - -void subst_func_pool_add_func( subst_func_pool_type * pool , const char * func_name , const char * doc_string , subst_func_ftype * func , bool vararg, int argc_min , int argc_max , void * arg) { - subst_func_type * subst_func = subst_func_alloc( func_name , doc_string , func , vararg , argc_min , argc_max , arg); - hash_insert_hash_owned_ref( pool->func_table , func_name , subst_func , subst_func_free__); -} - - -subst_func_type * subst_func_pool_get_func( const subst_func_pool_type * pool , const char * func_name ) { - return (subst_func_type*)hash_get( pool->func_table , func_name ); -} - -bool subst_func_pool_has_func( const subst_func_pool_type * pool , const char * func_name ) { - return hash_has_key( pool->func_table , func_name ); -} - - -/*****************************************************************/ - -char * subst_func_randint( const stringlist_type * args , void * arg) { - rng_type * rng = rng_safe_cast( arg ); - return util_alloc_sprintf("%u" , rng_forward( rng )); -} - -char * subst_func_randfloat( const stringlist_type * args , void * arg) { - rng_type * rng = rng_safe_cast( arg ); - return util_alloc_sprintf("%12.10f" , 1e9 * rng_get_double( rng )); -} - - -char * subst_func_exp( const stringlist_type * args , void * ext_arg) { - double arg; - if (util_sscanf_double( stringlist_iget(args , 0 ) , &arg)) - return util_alloc_sprintf("%g" , exp(arg)); - else - return NULL; -} - - -char * subst_func_log( const stringlist_type * args , void * ext_arg) { - double arg; - if (util_sscanf_double( stringlist_iget(args , 0 ) , &arg)) - return util_alloc_sprintf("%g" , log(arg)); - else - return NULL; -} - - -char * subst_func_pow10( const stringlist_type * args , void * ext_arg) { - double arg; - if (util_sscanf_double( stringlist_iget(args , 0 ) , &arg)) - return util_alloc_sprintf("%g" , pow(10 , arg)); - else - return NULL; -} - - - -char * subst_func_add( const stringlist_type * args , void * ext_arg) { - double sum = 0; - bool OK = true; - int index; - for (index = 0; index < stringlist_get_size( args ); index++) { - double term; - if (util_sscanf_double( stringlist_iget(args , index ) , &term)) - sum += term; - else - OK = false; - } - - if (OK) - return util_alloc_sprintf("%g" , sum); - else - return NULL; -} - - -char * subst_func_mul( const stringlist_type * args , void * ext_arg) { - double product = 0; - bool OK = true; - int index; - for (index = 0; index < stringlist_get_size( args ); index++) { - double factor; - if (util_sscanf_double( stringlist_iget(args , index ) , &factor)) - product *= factor; - else - OK = false; - } - - - if (OK) - return util_alloc_sprintf("%g" , product); - else - return NULL; -} diff --git a/ThirdParty/Ert/lib/util/test_util.c b/ThirdParty/Ert/lib/util/test_util.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/test_util.c rename to ThirdParty/Ert/lib/util/test_util.cpp index 3d2684d540..9115af6feb 100644 --- a/ThirdParty/Ert/lib/util/test_util.c +++ b/ThirdParty/Ert/lib/util/test_util.cpp @@ -24,12 +24,12 @@ #include #include -#include "ert/util/build_config.h" -#include -#include -#include -#include -#include +#include "ert/util/build_config.hpp" +#include +#include +#include +#include +#include void test_error_exit( const char * fmt , ...) { char * s; diff --git a/ThirdParty/Ert/lib/util/test_work_area.c b/ThirdParty/Ert/lib/util/test_work_area.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/test_work_area.c rename to ThirdParty/Ert/lib/util/test_work_area.cpp index dbb9823b5d..09e394fa92 100644 --- a/ThirdParty/Ert/lib/util/test_work_area.c +++ b/ThirdParty/Ert/lib/util/test_work_area.cpp @@ -16,7 +16,7 @@ for more details. */ -#include +#include #ifdef ERT_HAVE_GETUID #include @@ -29,12 +29,11 @@ #include #include -#include -#include -#include -#include +#include +#include +#include -#include +#include #ifdef ERT_HAVE_OPENDIR #include #include @@ -173,18 +172,20 @@ UTIL_IS_INSTANCE_FUNCTION( test_work_area , TEST_WORK_AREA_TYPE_ID) static test_work_area_type * test_work_area_alloc_with_prefix(const char * prefix , const char * test_name, bool change_dir) { if (test_name) { - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); + unsigned int random_int; + util_fread_dev_urandom( sizeof random_int, (char *) &random_int); + random_int = random_int % 100000000; + #ifdef ERT_HAVE_GETUID uid_t uid = getuid(); struct passwd * pw = getpwuid( uid ); char * user_name = util_alloc_string_copy( pw->pw_name ); #else - char * user_name = util_alloc_sprintf("ert-test-%08d" , rng_get_int(rng , 100000000)); + char * user_name = util_alloc_sprintf("ert-test-%08u" , random_int); #endif - char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name , rng_get_int( rng , 100000000 )); + char * test_path = util_alloc_sprintf( TEST_PATH_FMT , user_name , test_name , random_int); test_work_area_type * work_area = test_work_area_alloc__( prefix , test_path, change_dir); free( test_path ); - rng_free( rng ); free( user_name ); return work_area; } else diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c deleted file mode 100644 index 8b84bb56b8..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_PATH_test.c +++ /dev/null @@ -1,59 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include -#include - -#include -#include -#include - - - -int main(int argc , char ** argv) { - unsetenv("PATH"); - { - char ** path_list = util_alloc_PATH_list(); - if (path_list[0] != NULL) - test_error_exit("Failed on empty PATH\n"); - - util_free_NULL_terminated_stringlist( path_list ); - } - - - setenv("PATH" , "/usr/bin:/bin:/usr/local/bin" , 1); - { - char ** path_list = util_alloc_PATH_list(); - if (strcmp(path_list[0] , "/usr/bin") != 0) - test_error_exit("Failed on first path element\n"); - - if (strcmp(path_list[1] , "/bin") != 0) - test_error_exit("Failed on second path element\n"); - - if (strcmp(path_list[2] , "/usr/local/bin") != 0) - test_error_exit("Failed on third path element\n"); - - if (path_list[3] != NULL) - test_error_exit("Failed termination \n"); - - util_free_NULL_terminated_stringlist( path_list ); - } - - - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_filename.c b/ThirdParty/Ert/lib/util/tests/ert_util_filename.c index 4bd358ecd9..0612a98071 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_filename.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_filename.c @@ -1,19 +1,19 @@ /* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2012 Statoil ASA, Norway. + + The file 'ert_util_PATH_test.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #include @@ -29,7 +29,7 @@ void test_dirname() { const char * src_file1 = "/some/very/long/path/file.txt"; const char * src_file2 = "relative/path/file.txt"; const char * src_file3 = "file.txt"; - + char * path1 = util_split_alloc_dirname( src_file1 ); char * path2 = util_split_alloc_dirname( src_file2 ); char * path3 = util_split_alloc_dirname( src_file3 ); @@ -48,7 +48,7 @@ void test_filename() { const char * src_file1 = "/some/very/long/path/file1.txt"; const char * src_file2 = "relative/path/file2"; const char * src_file3 = "/tmp"; - + char * file1 = util_split_alloc_filename( src_file1 ); char * file2 = util_split_alloc_filename( src_file2 ); char * file3 = util_split_alloc_filename( src_file3 ); @@ -61,13 +61,24 @@ void test_filename() { } +void test_alloc_filename_empty_strings() { + const char * path = ""; + const char * filename = "file"; + const char * extension = ""; + + char * alloc_filename = util_alloc_filename( path, filename , extension); + test_assert_string_equal( alloc_filename , filename ); + free( alloc_filename ); + +} int main(int argc , char ** argv) { - + test_dirname(); test_filename(); + test_alloc_filename_empty_strings(); exit(0); - + } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_logh.c b/ThirdParty/Ert/lib/util/tests/ert_util_logh.c deleted file mode 100644 index 91ae801756..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_logh.c +++ /dev/null @@ -1,110 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_logh.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include - -#include -#include -#include -#include - -#define LOG_FILE "log.txt" - - -void test_open() { - test_work_area_type * work_area = test_work_area_alloc("util/logh"); - { - log_type * logh = log_open( NULL , 0 ); - test_assert_int_equal( 0 , log_get_msg_count( logh )); - test_assert_false( log_is_open( logh )); - log_reopen( logh , LOG_FILE ); - test_assert_true( log_is_open( logh )); - - log_close( logh ); - } - - { - log_type * logh = log_open( LOG_FILE , 0 ); - test_assert_not_NULL(logh); - log_close( logh ); - } - - { - log_type * logh = log_open( LOG_FILE , 1 ); - test_assert_true( log_is_open( logh )); - log_add_message( logh , 1 , NULL , "Message" , false); - test_assert_int_equal( 1 , log_get_msg_count( logh )); - log_close( logh ); - } - - test_work_area_free( work_area ); -} - - -void test_delete_empty() { - test_work_area_type * work_area = test_work_area_alloc("logh_delete_empty"); - { - log_type * logh = log_open( LOG_FILE , 0 ); - test_assert_not_NULL(logh); - log_close( logh ); - - test_assert_false( util_file_exists( LOG_FILE )); - } - - { - log_type * logh = log_open( LOG_FILE , 0 ); - log_reopen( logh , "LOG2.txt"); - log_close( logh ); - - test_assert_false( util_file_exists( LOG_FILE )); - } - - { - log_type * logh = log_open( LOG_FILE , 1 ); - log_add_message( logh , 1 , NULL , "Message" , false); - log_close( logh ); - test_assert_true( util_file_exists( LOG_FILE )); - - logh = log_open( LOG_FILE , 1 ); - log_close( logh ); - test_assert_true( util_file_exists( LOG_FILE )); - } - - test_work_area_free( work_area ); -} - - -/* - Someone else deletes the file before closing - that should not kill the thing. -*/ - -void test_file_deleted() { - log_type * logh = log_open( LOG_FILE , 1 ); - log_add_message( logh , 1 , NULL , "Message" , false); - util_unlink( LOG_FILE ); - test_assert_false( util_file_exists( LOG_FILE )); - log_close( logh ); - test_assert_false( util_file_exists( LOG_FILE )); -} - -int main(int argc , char ** argv) { - test_open(); - test_delete_empty(); - test_file_deleted( ); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_matrix.c b/ThirdParty/Ert/lib/util/tests/ert_util_matrix.c deleted file mode 100644 index c3c47a0953..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_matrix.c +++ /dev/null @@ -1,242 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ert_util_matrix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - - -void test_resize() { - matrix_type * m1 = matrix_alloc(5,5); - matrix_type * m2 = matrix_alloc(5,5); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); - - matrix_random_init( m1 , rng ); - matrix_assign( m2 , m1 ); - - test_assert_true( matrix_equal( m1 , m2 )); - matrix_resize( m1 , 5 , 5 , false ); - test_assert_true( matrix_equal( m1 , m2 )); - matrix_resize( m1 , 5 , 5 , true ); - test_assert_true( matrix_equal( m1 , m2 )); - - rng_free( rng ); - matrix_free( m1 ); - matrix_free( m2 ); -} - - -void test_column_equal() { - matrix_type * m1 = matrix_alloc(5,5); - matrix_type * m2 = matrix_alloc(5,5); - matrix_type * m3 = matrix_alloc(6,5); - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); - - matrix_random_init( m1 , rng ); - matrix_assign( m2 , m1 ); - - test_assert_true( matrix_columns_equal( m1 , 2 , m2 , 2 )); - test_assert_false( matrix_columns_equal( m1 , 2 , m2 , 3 )); - test_assert_false( matrix_columns_equal( m1 , 2 , m3 , 3 )); - - rng_free( rng ); - matrix_free( m1 ); - matrix_free( m2 ); - matrix_free( m3 ); -} - - - - -void test_create_invalid() { - test_assert_NULL( matrix_alloc(0, 100)); - test_assert_NULL( matrix_alloc(100, 0)); - test_assert_NULL( matrix_alloc(0, 0)); - test_assert_NULL( matrix_alloc(-1, -1)); -} - - - -void test_dims() { - const int rows = 10; - const int columns = 13; - matrix_type * m = matrix_alloc(rows , columns); - - test_assert_true( matrix_check_dims(m , rows , columns)); - test_assert_false( matrix_check_dims(m , rows + 1 , columns)); - test_assert_false( matrix_check_dims(m , rows , columns + 1)); - - matrix_free( m ); -} - - - - -void test_readwrite() { - test_work_area_type * test_area = test_work_area_alloc("matrix-test"); - { - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m1 = matrix_alloc(3 , 3); - matrix_type * m2 = matrix_alloc(3 , 3); - matrix_random_init( m1 , rng ); - matrix_assign(m2 , m1); - - test_assert_true( matrix_equal( m1 , m2 ) ); - { - FILE * stream = util_fopen("m1" , "w"); - matrix_fwrite( m1 , stream ); - fclose( stream ); - } - matrix_random_init( m1 , rng ); - test_assert_false( matrix_equal( m1 , m2 ) ); - { - FILE * stream = util_fopen("m1" , "r"); - matrix_free( m1 ); - m1 = matrix_alloc(1,1); - printf("-----------------------------------------------------------------\n"); - matrix_fread( m1 , stream ); - test_assert_int_equal( matrix_get_rows(m1) , matrix_get_rows( m2)); - test_assert_int_equal( matrix_get_columns(m1) , matrix_get_columns( m2)); - util_fseek( stream , 0 , SEEK_SET); - { - matrix_type * m3 = matrix_fread_alloc( stream ); - test_assert_true( matrix_equal( m2 , m3 )); - matrix_free( m3 ); - } - fclose( stream ); - } - test_assert_true( matrix_equal( m1 , m2 ) ); - - matrix_free( m2 ); - matrix_free( m1 ); - rng_free( rng ); - } - test_work_area_free( test_area ); -} - - -void test_diag_std() { - const int N = 25; - double_vector_type * data = double_vector_alloc( 0,0); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m = matrix_alloc( N , N ); - double sum1 = 0; - double sum2 = 0; - int i; - - for (i=0; i < N; i++) { - double R = rng_get_double( rng ); - matrix_iset(m , i , i , R); - double_vector_iset( data , i , R ); - - sum1 += R; - sum2 += R*R; - } - { - double mean = sum1 / N; - double std = sqrt( sum2 / N - mean * mean ); - - test_assert_double_equal( std , matrix_diag_std( m , mean )); - test_assert_double_equal( statistics_std( data ) , matrix_diag_std( m , mean )); - test_assert_double_equal( statistics_mean( data ) , mean ); - } - matrix_free( m ); - rng_free( rng ); -} - - - -void test_masked_copy() { - const int N = 25; - bool_vector_type * mask = bool_vector_alloc(N , true); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m1 = matrix_alloc( N , N ); - matrix_random_init( m1 , rng ); - - bool_vector_iset( mask , 0 , false ); - bool_vector_iset( mask , 10 , false ); - - { - matrix_type * m2 = matrix_alloc_column_compressed_copy( m1 , mask ); - matrix_type * m3 = matrix_alloc( N , N - 2 ); - - test_assert_int_equal( matrix_get_rows( m1 ) , matrix_get_rows( m2 )); - test_assert_int_equal( matrix_get_columns( m1 ) , matrix_get_columns( m2 ) + 2); - - matrix_column_compressed_memcpy( m3 , m1 , mask ); - { - int src_col; - int target_col = 0; - for (src_col = 0; src_col < N; src_col++) { - if (bool_vector_iget( mask , src_col)) { - test_assert_true( matrix_columns_equal( m1 , src_col , m3 , target_col )); - target_col++; - } - } - } - - test_assert_true( matrix_equal( m2 , m3 )); - matrix_free( m3 ); - matrix_free( m2 ); - } - - matrix_free( m1 ); - rng_free( rng ); -} - - -void test_inplace_sub_column() { - const int N = 25; - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_type * m1 = matrix_alloc( N , N ); - matrix_type * m2 = matrix_alloc( N , N ); - - matrix_random_init( m1 , rng ); - matrix_assign( m2 , m1 ); - matrix_inplace_sub_column( m1 , m2 , 0 , 0 ); - { - int row; - for (row = 0; row < N; row++) { - double diff = matrix_iget( m1 , row , 0); - test_assert_true( fabs( diff ) < 1e-6); - } - } -} - - -int main( int argc , char ** argv) { - test_create_invalid(); - test_resize(); - test_column_equal(); - test_dims(); - - test_readwrite(); - test_diag_std(); - test_masked_copy(); - test_inplace_sub_column(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c b/ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c deleted file mode 100644 index 233a46c711..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_lapack.c +++ /dev/null @@ -1,92 +0,0 @@ -/* - Copyright (C) 2015 Statoil ASA, Norway. - - The file 'ert_util_matrix_lapack.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - - - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - - - - -void test_det4() { - matrix_type * m = matrix_alloc(4 , 4 ); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - for (int i=0; i < 10; i++) { - matrix_random_init( m , rng ); - { - double det4 = matrix_det4( m ); - double det = matrix_det( m ); - - test_assert_double_equal( det , det4 ); - } - } - - matrix_free( m ); - rng_free( rng ); -} - - -void test_det3() { - matrix_type * m = matrix_alloc(3 , 3 ); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_random_init( m , rng ); - - { - double det3 = matrix_det3( m ); - double det = matrix_det( m ); - - test_assert_double_equal( det , det3 ); - } - - matrix_free( m ); - rng_free( rng ); -} - - -void test_det2() { - matrix_type * m = matrix_alloc(2,2); - rng_type * rng = rng_alloc(MZRAN , INIT_DEV_URANDOM ); - matrix_random_init( m , rng ); - { - double det2 = matrix_det2( m ); - double det = matrix_det( m ); - - test_assert_double_equal( det , det2 ); - } - matrix_free( m ); - rng_free( rng ); -} - - - -int main( int argc , char ** argv) { - test_det2(); - test_det3(); - test_det4(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c b/ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c deleted file mode 100644 index 6e2ce86bf5..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_matrix_stat.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - Copyright (C) 2015 Statoil ASA, Norway. - - The file 'ert_util_matrix_stat.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include - - - -void test_invalid_dimensions() { - matrix_type * X = matrix_alloc(10,2); - matrix_type * Y = matrix_alloc(11,1); - matrix_type * S = matrix_alloc(10,1); - matrix_type * beta = matrix_alloc(2,1); - - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , S ) == LLSQ_INVALID_DIM ); - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_INVALID_DIM ); - - matrix_resize(beta , 4 , 1 , false ); - matrix_resize(Y , 3 , 1 , false ); - matrix_resize(X , 3 , 4 , false ); - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_UNDETERMINED ); - - matrix_free( Y ); - matrix_free( S ); - matrix_free( beta ); - matrix_free( X ); -} - - -void test_no_sigma() { - const double A = 4.00; - const double B = -2; - const double C = 0.25; - - const double xmin = 0; - const double xmax = 1; - int size = 20; - int P = 3; - matrix_type * X = matrix_alloc(size,P); - matrix_type * Y = matrix_alloc(size,1); - matrix_type * beta = matrix_alloc(P,1); - - int i; - for (i = 0; i < size; i++) { - double x = xmin + i * (xmax - xmin) / (size - 1); - - double y = A + B*x + C*x*x; - matrix_iset( X , i , 0 , 1 ); - matrix_iset( X , i , 1 , x ); - matrix_iset( X , i , 2 , x*x ); - - matrix_iset( Y , i , 0 , y); - } - - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , NULL ) == LLSQ_SUCCESS ); - - test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); - test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); - test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); - - - matrix_free( Y ); - matrix_free( beta ); - matrix_free( X ); -} - - -void test_with_sigma() { - const double A = 4.00; - const double B = -2; - const double C = 0.25; - - const double xmin = 0; - const double xmax = 1; - int size = 20; - int P = 3; - matrix_type * X = matrix_alloc(size,P); - matrix_type * Y = matrix_alloc(size,1); - matrix_type * beta = matrix_alloc(P,1); - matrix_type * S = matrix_alloc(size,1); - - int i; - for (i = 0; i < size; i++) { - double x = xmin + i * (xmax - xmin) / (size - 1); - - double y = A + B*x + C*x*x; - matrix_iset( X , i , 0 , 1 ); - matrix_iset( X , i , 1 , x ); - matrix_iset( X , i , 2 , x*x ); - - matrix_iset( Y , i , 0 , y); - matrix_iset( S , i , 0 , 1); - } - - test_assert_true( matrix_stat_llsq_estimate( beta , X , Y , S ) == LLSQ_SUCCESS ); - - test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); - test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); - test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); - - matrix_free( S ); - matrix_free( Y ); - matrix_free( beta ); - matrix_free( X ); -} - - -void test_polyfit() { - const double A = 4.00; - const double B = -2; - const double C = 0.25; - - const double xmin = 0; - const double xmax = 1; - int size = 20; - int P = 3; - matrix_type * X = matrix_alloc(size,1); - matrix_type * Y = matrix_alloc(size,1); - matrix_type * beta = matrix_alloc(P,1); - - int i; - for (i = 0; i < size; i++) { - double x = xmin + i * (xmax - xmin) / (size - 1); - - double y = A + B*x + C*x*x; - matrix_iset( X , i , 0 , x ); - matrix_iset( Y , i , 0 , y); - } - - test_assert_true( matrix_stat_polyfit( beta , X , Y , NULL) == LLSQ_SUCCESS ); - - test_assert_double_equal( A , matrix_iget( beta , 0 , 0 )); - test_assert_double_equal( B , matrix_iget( beta , 1 , 0 )); - test_assert_double_equal( C , matrix_iget( beta , 2 , 0 )); - - matrix_free( Y ); - matrix_free( beta ); - matrix_free( X ); -} - - - - - -int main() { - util_install_signals(); - test_invalid_dimensions(); - test_no_sigma(); - test_with_sigma(); - test_polyfit(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c b/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c new file mode 100644 index 0000000000..4fbb95ca12 --- /dev/null +++ b/ThirdParty/Ert/lib/util/tests/ert_util_normal_path.c @@ -0,0 +1,73 @@ +/* + Copyright (C) 2017 Statoil ASA, Norway. + + The file 'ert_util_normal_path.c' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. +*/ + +#include +#include + +#include +#include +#include + + +void test_path(const char * input_path, const char * expected_path) { + char * normal_path = util_alloc_normal_path( input_path ); + test_assert_string_equal( normal_path , expected_path ); + free( normal_path ); +} + + +void test_relative() { + test_work_area_type * work_area = test_work_area_alloc("Work"); + util_make_path("level0/level1/level2"); + + test_path( "level0/level1/../", "level0"); + test_path( "level0", "level0"); + test_path( "level0/././level1/../", "level0"); + test_path( "level0/level1/../level1/level2/../", "level0/level1"); + test_path( "level0/level1/../level1/level2/..", "level0/level1"); + test_path( "level0/level1/../level1/level2/../file.txt", "level0/level1/file.txt"); + test_path( "level0/level1/../level1a" , "level0/level1a"); + + test_path( "a/b/c/../c/../.." , "a"); + test_path( "a/b/c/d/e/f" , "a/b/c/d/e/f"); + util_chdir("level0/level1"); + test_path("../../level0/level1/level2/../file.txt" , "file.txt"); + test_path("../../level0/level1/level2/../" , ""); + test_work_area_free( work_area ); +} + +void test_beyond_root() { + test_work_area_type * work_area = test_work_area_alloc("Work"); + char * cwd = util_alloc_cwd( ); + char * backref_cwd1 = util_alloc_sprintf("../../../../../../../../../../../%s" , cwd ); + char * backref_cwd2 = util_alloc_sprintf("/../../../../../../../../../../../%s" , cwd ); + test_path( backref_cwd1 , "" ); + test_path( backref_cwd2 , cwd ); // The input is a semi-absolute path, and we compare with the absolute path cwd(). + free( backref_cwd1 ); + free( backref_cwd2 ); + free( cwd ); + test_work_area_free( work_area ); +} + + + +int main( int argc , char ** argv) { + test_relative( ); + test_beyond_root( ); + exit(0); +} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c index 6b2ce539aa..900b04894d 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_relpath_test.c @@ -64,7 +64,7 @@ int main(int argc , char ** argv) { const char * root7 = "/tmp/root/path"; const char * path7 = "/tmp/root/path"; - const char * true7 = NULL; + const char * true7 = ""; const char * root8 = "/tmp"; const char * path8 = "root/path"; diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c b/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c index 19c268266e..0a81e4194f 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_spawn.c @@ -24,9 +24,7 @@ #include #include #include -#include #include -#include static const char * stdout_msg = "stdout_xxx"; @@ -150,7 +148,6 @@ void test_spawn_redirect() { } void test_spawn_redirect_threaded() { - rng_type * rng = rng_alloc( MZRAN , INIT_DEFAULT ); const int num = 128; // Generate the scripts on disk first @@ -158,7 +155,7 @@ void test_spawn_redirect_threaded() { int * path_codes = (int *)util_calloc(num, sizeof *path_codes); stringlist_type * script_fullpaths = stringlist_alloc_new(); for (int i=0; i < num; i++) { - path_codes[i] = rng_get_int( rng , 1000000); + path_codes[i] = rand() % 1000000; char * path = util_alloc_sprintf("%06d" , path_codes[i]); util_make_path( path ); @@ -180,22 +177,9 @@ void test_spawn_redirect_threaded() { test_assert_true(check_script(script)); } - // Run the scripts in parallel - stringlist_type * script_paths = stringlist_alloc_new(); // free the paths after threads have completed - thread_pool_type * tp = thread_pool_alloc( 8 , true ); - for(int i = 0; i < num; i++) { - char * path = util_alloc_sprintf("%06d" , path_codes[i]); - stringlist_append_owned_ref(script_paths, path); - thread_pool_add_job( tp , test_spawn_redirect__ , path ); - } - thread_pool_join( tp ); - thread_pool_free( tp ); - stringlist_free(script_paths); - stringlist_free(script_fullpaths); util_free(path_codes); test_work_area_free( test_area ); - rng_free( rng ); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c index eeb591f17b..db0817293d 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_stringlist_test.c @@ -17,9 +17,12 @@ */ #include #include +#include +#include #include #include +#include void test_char() { const char * S1 = "S1"; @@ -338,6 +341,54 @@ void test_matching() { } +bool FILE_predicate(const char * name, const void * arg) { + return util_string_equal("FILE.txt", name); +} + +bool not_FILE_predicate(const char * name, const void * arg) { + return !util_string_equal("FILE.txt", name); +} + + +void test_predicate_matching() { + test_work_area_type * work_area = test_work_area_alloc("predicate_test"); + stringlist_type * s = stringlist_alloc_new(); + stringlist_append_ref(s, "s"); + stringlist_select_files(s, "does/not/exist", NULL, NULL); + test_assert_int_equal(stringlist_get_size(s), 0); + + + { + FILE * f = util_fopen("FILE.txt", "w"); + fclose(f); + } + stringlist_select_files(s , test_work_area_get_cwd(work_area), NULL, NULL); + test_assert_int_equal(1, stringlist_get_size(s)); + { + char * exp = util_alloc_abs_path("FILE.txt"); + test_assert_string_equal( exp, stringlist_iget(s, 0)); + free(exp); + } + + stringlist_select_files(s , NULL, NULL, NULL); + test_assert_int_equal(1, stringlist_get_size(s)); + test_assert_string_equal( "FILE.txt", stringlist_iget(s, 0)); + + stringlist_select_files(s , test_work_area_get_cwd(work_area), FILE_predicate, NULL); + test_assert_int_equal(1, stringlist_get_size(s)); + { + char * exp = util_alloc_abs_path("FILE.txt"); + test_assert_string_equal( exp, stringlist_iget(s, 0)); + free(exp); + } + + stringlist_select_files(s , test_work_area_get_cwd(work_area), not_FILE_predicate, NULL); + test_assert_int_equal(0, stringlist_get_size(s)); + + stringlist_free(s); + test_work_area_free(work_area); +} + void test_unique() { stringlist_type * s = stringlist_alloc_new(); @@ -365,5 +416,6 @@ int main( int argc , char ** argv) { test_split(); test_matching(); test_unique(); + test_predicate_matching(); exit(0); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c b/ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c deleted file mode 100644 index 7a40e4e145..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_time_interval.c +++ /dev/null @@ -1,245 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'ert_util_time_interval.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include -#include - -#include -#include -#include - - - -int main( int argc , char ** argv) { - time_t start_time = util_make_date_utc(1,1,2000); - time_t end_time = util_make_date_utc(1,1,2010); - time_t in = util_make_date_utc( 1,1,2005); - time_t before = util_make_date_utc( 1,1,1995); - time_t after = util_make_date_utc( 1,1,2015); - - { - time_interval_type * ti = time_interval_alloc( start_time , end_time ); - test_assert_not_NULL( ti ); - test_assert_false( time_interval_is_empty( ti )); - - test_assert_true( time_interval_contains( ti , start_time )); - test_assert_true( time_interval_contains( ti , in )); - test_assert_false( time_interval_contains( ti , before )); - test_assert_false( time_interval_contains( ti , end_time )); - test_assert_false( time_interval_contains( ti , after )); - - test_assert_false( time_interval_update( ti , end_time , start_time )); - test_assert_true( time_interval_is_empty( ti )); - - test_assert_false( time_interval_contains( ti , start_time )); - test_assert_false( time_interval_contains( ti , in )); - test_assert_false( time_interval_contains( ti , before )); - test_assert_false( time_interval_contains( ti , end_time )); - test_assert_false( time_interval_contains( ti , after )); - - test_assert_true( time_interval_update( ti , start_time , end_time )); - test_assert_false( time_interval_is_empty( ti )); - - time_interval_free( ti ); - } - - { - time_interval_type * ti = time_interval_alloc( end_time , start_time ); - test_assert_not_NULL( ti ); - test_assert_true( time_interval_is_empty( ti )); - test_assert_true( time_interval_update( ti , start_time , end_time )); - test_assert_false( time_interval_is_empty( ti )); - time_interval_free( ti ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( in , after ); - time_interval_type * t3 = time_interval_alloc( end_time , start_time ); - time_interval_type * t4 = time_interval_alloc( before , start_time ); - time_interval_type * t5 = time_interval_alloc( end_time , after ); - - test_assert_true( time_interval_has_overlap( t1 , t2 )); - - test_assert_true( time_interval_is_empty( t3 )); - test_assert_false( time_interval_has_overlap( t1 , t3 )); - test_assert_false( time_interval_has_overlap( t3 , t1 )); - test_assert_false( time_interval_has_overlap( t3 , t3 )); - test_assert_false( time_interval_has_overlap( t4 , t5 )); - test_assert_false( time_interval_has_overlap( t1 , t5 )); - - - time_interval_free( t1 ); - time_interval_free( t2 ); - } - - { - time_interval_type * ti = time_interval_alloc_open(); - - test_assert_false( time_interval_is_empty( ti )); - - test_assert_true( time_interval_contains( ti , start_time )); - test_assert_true( time_interval_contains( ti , in )); - test_assert_true( time_interval_contains( ti , before )); - test_assert_true( time_interval_contains( ti , end_time )); - test_assert_true( time_interval_contains( ti , after )); - - test_assert_true( time_interval_update_start( ti , start_time )); - test_assert_true( time_interval_contains( ti , start_time )); - test_assert_true( time_interval_update_start( ti , in )); - test_assert_false( time_interval_contains( ti , start_time )); - test_assert_false( time_interval_is_empty( ti )); - - test_assert_false( time_interval_update_end( ti , start_time )); - test_assert_true( time_interval_is_empty( ti )); - test_assert_true( time_interval_update_end( ti , end_time )); - test_assert_false( time_interval_is_empty( ti )); - test_assert_false( time_interval_contains( ti , start_time )); - - time_interval_free( ti ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); - test_assert_false( time_interval_is_empty( t1 )); - - test_assert_false( time_interval_update_end( t1 , before )); - test_assert_true( time_interval_is_empty( t1 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( before , time_interval_get_end( t1 )); - - test_assert_true( time_interval_update_end( t1 , in )); - test_assert_false( time_interval_is_empty( t1 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( in , time_interval_get_end( t1 )); - - time_interval_free( t1 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , in ); - time_interval_type * t2 = time_interval_alloc( in , end_time ); - time_interval_type * t3 = time_interval_alloc( start_time , end_time); - - test_assert_true( time_interval_is_adjacent( t1 , t2 )); - test_assert_true( time_interval_is_adjacent( t2 , t1 )); - - test_assert_false( time_interval_is_adjacent( t1 , t3 )); - test_assert_false( time_interval_is_adjacent( t3 , t1 )); - test_assert_false( time_interval_is_adjacent( t2 , t3 )); - test_assert_false( time_interval_is_adjacent( t3 , t2 )); - - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - } - - - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( in , end_time ); - time_interval_type * t3 = time_interval_alloc( end_time , after ); - time_interval_type * t4 = time_interval_alloc( before , start_time ); - - test_assert_true( time_interval_extend(t1 , t2 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); - - test_assert_true( time_interval_extend(t1 , t3 )); - test_assert_time_t_equal( start_time , time_interval_get_start( t1 )); - test_assert_time_t_equal( after , time_interval_get_end( t1 )); - - test_assert_true( time_interval_update_start(t1 , in )); - test_assert_time_t_equal( in , time_interval_get_start( t1 )); - - - test_assert_false( time_interval_extend(t1 , t4 )); - test_assert_time_t_equal( in , time_interval_get_start( t1 )); - test_assert_time_t_equal( after , time_interval_get_end( t1 )); - - - test_assert_true( time_interval_update_end(t4 , in )); - test_assert_true( time_interval_extend(t1 , t4 )); - test_assert_time_t_equal( before , time_interval_get_start( t1 )); - test_assert_time_t_equal( after , time_interval_get_end( t1 )); - - - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - time_interval_free( t4 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( in , end_time ); - time_interval_type * t3 = time_interval_alloc( end_time , after ); - time_interval_type * t4 = time_interval_alloc( before , start_time ); - - test_assert_true( time_interval_intersect(t1 , t2 )); - test_assert_time_t_equal( in , time_interval_get_start( t1 )); - test_assert_time_t_equal( end_time , time_interval_get_end( t1 )); - - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - time_interval_free( t4 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - time_interval_type * t2 = time_interval_alloc( start_time , end_time ); - time_interval_type * t3 = time_interval_alloc( end_time , after ); - time_interval_type * t4 = time_interval_alloc_copy( t1 ); - - test_assert_true( time_interval_equal( t1 , t2 )); - test_assert_false( time_interval_equal( t1 , t3 )); - - test_assert_true( time_interval_equal( t4 , t2 )); - test_assert_false( time_interval_equal( t4 , t3 )); - - test_assert_ptr_not_equal( t4 , t1 ); - time_interval_free( t1 ); - time_interval_free( t2 ); - time_interval_free( t3 ); - time_interval_free( t4 ); - } - - { - time_interval_type * t1 = time_interval_alloc( start_time , end_time ); - - test_assert_true( time_interval_arg_before( t1 , before )); - test_assert_true( time_interval_arg_after( t1 , after)); - - test_assert_false( time_interval_arg_before( t1 , start_time )); - test_assert_false( time_interval_arg_before( t1 , in )); - test_assert_false( time_interval_arg_before( t1 , after )); - - test_assert_false( time_interval_arg_after( t1 , start_time)); - test_assert_false( time_interval_arg_after( t1 , in)); - test_assert_true( time_interval_arg_after( t1 , after)); - - time_interval_free( t1 ); - } - - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c index e5bc248634..05245bc53e 100644 --- a/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c +++ b/ThirdParty/Ert/lib/util/tests/ert_util_type_vector_test.c @@ -343,6 +343,38 @@ void test_empty() { int_vector_free( vec ); } + +void test_equal_index() { + int_vector_type * v1 = int_vector_alloc(0,0); + int_vector_type * v2 = int_vector_alloc(0,0); + int_vector_type * v3 = int_vector_alloc(0,0); + + for (int i=0; i < 5; i++) { + int_vector_iset(v1,i,i); + int_vector_iset(v2,i,i); + int_vector_iset(v3,i,i+1); + } + + test_assert_int_equal( int_vector_first_equal(v1,v2,10), -2); + test_assert_int_equal( int_vector_first_not_equal(v1,v2,10), -2); + + test_assert_int_equal( int_vector_first_equal(v1,v2,0), 0); + test_assert_int_equal( int_vector_first_not_equal(v1,v2,0), -1); + + + int_vector_iset(v1,0,77); + test_assert_int_equal( int_vector_first_equal(v1,v2,0), 1); + test_assert_int_equal( int_vector_first_not_equal(v1,v2,0),0); + test_assert_int_equal( int_vector_first_equal(v1,v3,0), -1); + test_assert_int_equal( int_vector_first_not_equal(v1,v1,0), -1); + + int_vector_free(v1); + int_vector_free(v2); + int_vector_free(v3); +} + + + int main(int argc , char ** argv) { int_vector_type * int_vector = int_vector_alloc( 0 , 99); @@ -433,5 +465,6 @@ int main(int argc , char ** argv) { test_resize(); test_empty(); test_insert_double(); + test_equal_index(); exit(0); } diff --git a/ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c b/ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c deleted file mode 100644 index 82a711d12d..0000000000 --- a/ThirdParty/Ert/lib/util/tests/ert_util_ui_return.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'enkf_ui_return_type.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include - -#include -#include - - - - -void test_create() { - ui_return_status_enum status = UI_RETURN_OK; - ui_return_type * ui_return = ui_return_alloc(status); - test_assert_true( ui_return_is_instance( ui_return )); - test_assert_int_equal( status , ui_return_get_status(ui_return)); - ui_return_free( ui_return ); -} - - -void test_default() { - ui_return_status_enum status = UI_RETURN_OK; - ui_return_type * ui_return = ui_return_alloc(status); - - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - test_assert_NULL( ui_return_get_first_error( ui_return)); - test_assert_NULL( ui_return_get_last_error( ui_return)); - test_assert_NULL( ui_return_get_help(ui_return)); - ui_return_free( ui_return); -} - -void test_errors_inconsistent() { - ui_return_status_enum status = UI_RETURN_OK; - ui_return_type * ui_return = ui_return_alloc(status); - - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - test_assert_false( ui_return_add_error( ui_return , "ERROR1")); - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - ui_return_free( ui_return); -} - - -void test_errors_consistent() { - ui_return_status_enum status = UI_RETURN_FAIL; - ui_return_type * ui_return = ui_return_alloc(status); - - test_assert_int_equal( 0 , ui_return_get_error_count(ui_return)); - test_assert_true( ui_return_add_error( ui_return , "ERROR1")); - test_assert_int_equal(1, ui_return_get_error_count(ui_return)); - test_assert_string_equal("ERROR1", ui_return_get_first_error(ui_return)); - test_assert_string_equal("ERROR1", ui_return_get_last_error(ui_return)); - - test_assert_true(ui_return_add_error(ui_return, "ERROR2")); - test_assert_int_equal(2, ui_return_get_error_count(ui_return)); - test_assert_string_equal("ERROR1", ui_return_get_first_error(ui_return)); - test_assert_string_equal("ERROR2", ui_return_get_last_error(ui_return)); - - test_assert_string_equal("ERROR1" , ui_return_iget_error(ui_return , 0)); - test_assert_string_equal("ERROR2" , ui_return_iget_error(ui_return , 1)); - - ui_return_free( ui_return); -} - - -void test_help() { - ui_return_type * ui_return = ui_return_alloc(UI_RETURN_OK); - - ui_return_add_help(ui_return , "HELP1"); - test_assert_string_equal( "HELP1" , ui_return_get_help(ui_return)); - - ui_return_add_help(ui_return , "HELP2"); - test_assert_string_equal( "HELP1 HELP2" , ui_return_get_help(ui_return)); - - ui_return_free( ui_return); -} - -int main(int argc , char ** argv) { - test_create(); - test_default(); - test_errors_inconsistent(); - exit(0); -} diff --git a/ThirdParty/Ert/lib/util/thread_pool1.c b/ThirdParty/Ert/lib/util/thread_pool1.c deleted file mode 100644 index d365a67e30..0000000000 --- a/ThirdParty/Ert/lib/util/thread_pool1.c +++ /dev/null @@ -1,90 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool1.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#include -#include -#include -#include -#include - -struct thread_pool_struct { - int pool_size; - int jobs_running; - pthread_t *thread_list; -}; - - - - - -static void thread_pool_resize(thread_pool_type * pool, int new_size) { - pool->pool_size = new_size; - pool->thread_list = realloc(pool->thread_list , new_size * sizeof * pool->thread_list); -} - - - -void thread_pool_join(thread_pool_type * pool) { - int i; - if (pool->pool_size == 0) - return; - else { - for (i=0; i < pool->jobs_running; i++) - pthread_join(pool->thread_list[i] , NULL); /* Second argument: void **value_ptr */ - pool->jobs_running = 0; - } -} - - -thread_pool_type * thread_pool_alloc(int pool_size) { - thread_pool_type * pool = util_malloc(sizeof *pool); - pool->thread_list = NULL; - thread_pool_resize(pool , pool_size); - pool->jobs_running = 0; - return pool; -} - - - -void thread_pool_add_job(thread_pool_type * pool , - void * (start_func) (void *) , void *arg) { - - if (pool->pool_size == 0) - start_func(arg); - else { - - if (pool->jobs_running == pool->pool_size) - thread_pool_join(pool); - - { - int pthread_return = pthread_create( &pool->thread_list[pool->jobs_running] , NULL , start_func , arg); - if (pthread_return != 0) - util_abort("%s: failed to add new job pthread_create return value: %d.\n",__func__ , pthread_return); - } - - pool->jobs_running++; - } - -} - -void thread_pool_free(thread_pool_type * pool) { - if (pool->thread_list != NULL) free(pool->thread_list); - free(pool); -} - - diff --git a/ThirdParty/Ert/lib/util/thread_pool_posix.c b/ThirdParty/Ert/lib/util/thread_pool_posix.c deleted file mode 100644 index 8288013b48..0000000000 --- a/ThirdParty/Ert/lib/util/thread_pool_posix.c +++ /dev/null @@ -1,485 +0,0 @@ -/* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'thread_pool_posix.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ - -#define _GNU_SOURCE /* Must define this to get access to pthread_rwlock_t */ -#include -#include -#include -#include -#include -#include - -#include "ert/util/build_config.h" - -#include -#include -#include - - -/** - This file implements a small thread_pool object based on - pthread_create() function calls. The characetristics of this - implementation is as follows: - - 1. The jobs are mangaged by a separate thread - dispatch_thread. - 2. The new jobs are just appended to the queue, the - dispatch_thread sees them in the queue and dispatches them. - 3. The dispatch thread manages a list of thread_pool_job_slot_type - instances - one slot for each actually running job. - - Example - ------- - - 1. Start with creating a thread pool object. The arguments to the - allocater are the (maximum) number of concurrently running - threads and a boolean flag of whether the queue should start - immediately (that is in general the case). - - thread_pool_type * tp = thread_pool_alloc( NUM_THREADS , immediate_start); - - - 2. Add the jobs you want to run: - - thread_pool_add_job( tp , some_function , argument_to_some_function ); - - Here the prototype for the function which is being run is - - void * (some_func) (void *); - - I.e. it expects a (void *) input pointer, and also returns a - (void *) pointer as output. The thread pool implementation does - not touch the input and output of some_function. - - - 3. When all the jobs have been added you inform the thread pool of - that by calling: - - thread_pool_join( tp ); - - This function will not return before all the added jobs have run - to completion. - - - 4. Optional: If you want to get the return value from the function - you supplied, you can use: - - thread_pool_iget_return_value( tp , index ); - - To get the return value from function nr index. - - - 5. Optional: The thread pool will probably mainly be used only once, - but after a join it is possible to reuse a thread pool, but then - you MUST call thread_pool_restart() before adding jobs again. - - - 6. When you are really finished: thread_pool_free( tp ); - -*/ - - -typedef void * (start_func_ftype) (void *) ; - - -/** - Internal struct which is used as queue node. -*/ -typedef struct { - thread_pool_type * pool; /* A back-reference to the thread_pool holding the queue. */ - int slot_index; /* The index in the space [0,max_running) of the job slot where this job is running. */ - int queue_index; /* The index of the current tp_arg in the queue. */ - void * func_arg; /* The arguments to this job - supplied by the calling scope. */ - start_func_ftype * func; /* The function to call - supplied by the calling scope. */ - void * return_value; -} thread_pool_arg_type; - - - -/** - Internal struct used to keep track of the job slots. -*/ -typedef struct { - pthread_t thread; /* The thread variable currently (or more correct:last) running. */ - int run_count; /* The number of times this slot has been used - just to check whether the slot has been used AT ALL when/if joining. */ - bool running; /* Is the job_slot running now?? */ -} thread_pool_job_slot_type; - - - - -#define THREAD_POOL_TYPE_ID 71443207 -struct thread_pool_struct { - UTIL_TYPE_ID_DECLARATION; - thread_pool_arg_type * queue; /* The jobs to be executed are appended in this vector. */ - int queue_index; /* The index of the next job to run. */ - int queue_size; /* The number of jobs in the queue - including those which are complete. [Should be protected / atomic / ... ] */ - int queue_alloc_size; /* The allocated size of the queue. */ - - int max_running; /* The max number of concurrently running jobs. */ - bool join; /* Flag set by the main thread to inform the dispatch thread that joining should start. */ - bool accepting_jobs; /* True|False whether the dispatch thread is running. */ - - thread_pool_job_slot_type * job_slots; /* A vector to @max_running job slots, each slot can be reused several times.*/ - pthread_t dispatch_thread; - pthread_rwlock_t queue_lock; -}; - - -static UTIL_SAFE_CAST_FUNCTION( thread_pool , THREAD_POOL_TYPE_ID ) - - -/** - This function will grow the queue. It is called by the main thread - (i.e. the context of the calling scope), and the queue is read by - the dispatch_thread - i.e. access to the queue must be protected by - rwlock. -*/ - -static void thread_pool_resize_queue( thread_pool_type * pool, int queue_length ) { - pthread_rwlock_wrlock( &pool->queue_lock ); - { - pool->queue = (thread_pool_arg_type*)util_realloc( pool->queue , queue_length * sizeof * pool->queue ); - pool->queue_alloc_size = queue_length; - } - pthread_rwlock_unlock( &pool->queue_lock ); -} - - -/** - This function updates an element in the queue, the function is - called by the executing threads, on the same time the main thread - might be resizing the thread, we therefor take a read lock during - execution of this function. (Write lock is not necessary because we - will not change the queue pointer itself, only something it points - to.) -*/ - -static void thread_pool_iset_return_value( thread_pool_type * pool , int index , void * return_value) { - pthread_rwlock_rdlock( &pool->queue_lock ); - { - pool->queue[ index ].return_value = return_value; - } - pthread_rwlock_unlock( &pool->queue_lock ); -} - - -void * thread_pool_iget_return_value( const thread_pool_type * pool , int queue_index ) { - return pool->queue[ queue_index ].return_value; -} - - -/** - The pthread_create() call which this is all about, does not start - the user supplied function. Instead it will start an instance of - this function, which will do some housekeeping before calling the - user supplied function. -*/ - -static void * thread_pool_start_job( void * arg ) { - thread_pool_arg_type * tp_arg = (thread_pool_arg_type * ) arg; - thread_pool_type * tp = tp_arg->pool; - int slot_index = tp_arg->slot_index; - void * func_arg = tp_arg->func_arg; - start_func_ftype * func = tp_arg->func; - void * return_value; - - - return_value = func( func_arg ); /* Starting the real external function */ - tp->job_slots[ slot_index ].running = false; /* We mark the job as completed. */ - free( arg ); - - if (return_value != NULL) - thread_pool_iset_return_value( tp , tp_arg->queue_index , return_value); - - return NULL; -} - - - -/** - This function is run by the dispatch_thread. The thread will keep - an eye on the queue, and dispatch new jobs when there are free - slots available. -*/ - -static void * thread_pool_main_loop( void * arg ) { - thread_pool_type * tp = thread_pool_safe_cast( arg ); - { - const int usleep_init = 1000; /* The sleep time when there are free slots available - but no jobs wanting to run. */ - int internal_offset = 0; /* Keep track of the (index of) the last job slot fired off - minor time saving. */ - while (true) { - if (tp->queue_size > tp->queue_index) { - /* - There are jobs in the queue which would like to run - - let us see if we can find a slot for them. - */ - int counter = 0; - bool slot_found = false; - do { - int slot_index = (counter + internal_offset) % tp->max_running; - thread_pool_job_slot_type * job_slot = &tp->job_slots[ slot_index ]; - if (!job_slot->running) { - /* OK thread[slot_index] is ready to take this job.*/ - thread_pool_arg_type * tp_arg; - - /* - The queue might be updated by the main thread - we must - take a copy of the node we are interested in. - */ - pthread_rwlock_rdlock( &tp->queue_lock ); - tp_arg = (thread_pool_arg_type*)util_alloc_copy( &tp->queue[ tp->queue_index ] , sizeof * tp_arg ); - pthread_rwlock_unlock( &tp->queue_lock ); - - tp_arg->slot_index = slot_index; - job_slot->running = true; - /* - Here is the actual pthread_create() call creating an - additional running thread. - */ - - /*Cleanup of previous run threads. Needed to avoid memory leak*/ - if (job_slot->run_count > 0) - pthread_join(job_slot->thread, NULL); - - pthread_create( &job_slot->thread , NULL , thread_pool_start_job , tp_arg ); - job_slot->run_count += 1; - tp->queue_index++; - internal_offset += (counter + 1); - slot_found = true; - } else - counter++; - } while (!slot_found && (counter < tp->max_running)); - - if (!slot_found) { - util_yield(); - } - } else - util_usleep(usleep_init); /* There are no jobs wanting to run. */ - - /*****************************************************************/ - /* - We exit explicitly from this loop when both conditions apply: - - 1. tp->join == true : The calling scope has signaled that it will not submit more jobs. - 2. tp->queue_size == tp->queue_index : This function has submitted all the jobs in the queue. - */ - if ((tp->join) && (tp->queue_size == tp->queue_index)) - break; - } /* End of while() loop */ - } - - /* - There are no more jobs in the queue, and the main scope has - signaled that join should start. Observe that we join only the - jobs corresponding to explicitly running job_slots; when a job - slot is used multiple times the first jobs run in the job_slot - will not be explicitly joined. - */ - { - int i; - for (i=0; i < tp->max_running; i++) { - thread_pool_job_slot_type job_slot = tp->job_slots[i]; - if (job_slot.run_count > 0) - pthread_join( job_slot.thread , NULL ); - } - } - /* When we are here all the jobs have completed. */ - return NULL; -} - - - - -/** - This function initializes a couple of counters, and starts up the - dispatch thread. If the thread_pool should be reused after a join, - this function must be called before adding new jobs. - - The functions thread_pool_restart() and thread_pool_join() should - be joined up like open/close and malloc/free combinations. -*/ - -void thread_pool_restart( thread_pool_type * tp ) { - if (tp->accepting_jobs) - util_abort("%s: fatal error - tried restart already running thread pool\n",__func__); - { - tp->join = false; - tp->queue_index = 0; - tp->queue_size = 0; - { - int i; - for (i=0; i < tp->max_running; i++) { - tp->job_slots[i].run_count = 0; - tp->job_slots[i].running = false; - } - } - - /* Starting the dispatch thread. */ - pthread_create( &tp->dispatch_thread , NULL , thread_pool_main_loop , tp ); - tp->accepting_jobs = true; - } -} - - - -/** - This function is called by the calling scope when all the jobs have - been submitted, and we just wait for them to complete. - - This function just sets the join switch to true - this again tells - the dispatch_thread to start the join process on the worker - threads. -*/ - -void thread_pool_join(thread_pool_type * pool) { - pool->join = true; /* Signals to the main thread that joining can start. */ - if (pool->max_running > 0) { - pthread_join( pool->dispatch_thread , NULL ); /* Wait for the main thread to complete. */ - pool->accepting_jobs = false; - } -} - -/* - This will try to join the thread; if the manager thread has not - completed within @timeout_seconds the function will return false. If - the join fails the queue will be reset in a non-joining state and it - will be open for more jobs. Probably not in a 100% sane state. -*/ - -bool thread_pool_try_join(thread_pool_type * pool, int timeout_seconds) { - bool join_ok = true; - - pool->join = true; /* Signals to the main thread that joining can start. */ - if (pool->max_running > 0) { - time_t timeout_time = time( NULL ); - util_inplace_forward_seconds_utc(&timeout_time , timeout_seconds ); - -#ifdef HAVE_TIMEDJOIN - - struct timespec ts; - ts.tv_sec = timeout_time; - ts.tv_nsec = 0; - - { - int join_return = pthread_timedjoin_np( pool->dispatch_thread , NULL , &ts); /* Wait for the main thread to complete. */ - if (join_return == 0) - pool->accepting_jobs = false; - else { - pool->join = false; - join_ok = false; - } - } - -#else - - while(true) { - if (pthread_kill(pool->dispatch_thread, 0) == 0){ - util_yield(); - } else { - pthread_join(pool->dispatch_thread, NULL); - pool->accepting_jobs = false; - break; - } - - time_t now = time(NULL); - - if(util_difftime_seconds(now, timeout_time) <= 0) { - join_ok = false; - break; - } - } - -#endif - - - - } - return join_ok; -} - - - - -/** - max_running is the maximum number of concurrent threads. If - @start_queue is true the dispatch thread will start immediately. If - the function is called with @start_queue == false you must first - call thread_pool_restart() BEFORE you can start adding jobs. -*/ - -thread_pool_type * thread_pool_alloc(int max_running , bool start_queue) { - thread_pool_type * pool = (thread_pool_type*)util_malloc( sizeof *pool ); - UTIL_TYPE_ID_INIT( pool , THREAD_POOL_TYPE_ID ); - pool->job_slots = (thread_pool_job_slot_type*)util_calloc( max_running , sizeof * pool->job_slots ); - pool->max_running = max_running; - pool->queue = NULL; - pool->accepting_jobs = false; - pthread_rwlock_init( &pool->queue_lock , NULL); - thread_pool_resize_queue( pool , 32 ); - if (start_queue) - thread_pool_restart( pool ); - return pool; -} - - - -void thread_pool_add_job(thread_pool_type * pool , start_func_ftype * start_func , void * func_arg ) { - if (pool->max_running == 0) /* Blocking non-threaded mode: */ - start_func( func_arg ); - else { - if (pool->accepting_jobs) { - if (pool->queue_size == pool->queue_alloc_size) - thread_pool_resize_queue( pool , pool->queue_alloc_size * 2); - - /* - The new job is added to the queue - the main thread is watching - the queue and will pick up the new job. - */ - { - int queue_index = pool->queue_size; - - pool->queue[ queue_index ].pool = pool; - pool->queue[ queue_index ].func_arg = func_arg; - pool->queue[ queue_index ].func = start_func; - pool->queue[ queue_index ].return_value = NULL; - pool->queue[ queue_index ].queue_index = queue_index; - } - pool->queue_size++; /* <- This is shared between this thread and the dispatch thread */ - } else - util_abort("%s: thread_pool is not running - restart with thread_pool_restart()?? \n",__func__); - } -} - - - -/* - Observe that this function does not join the worker threads, - i.e. you should call thread_pool_join() first (otherwise the thing - will go up in flames). -*/ - - -void thread_pool_free(thread_pool_type * pool) { - util_safe_free( pool->job_slots ); - util_safe_free( pool->queue ); - free(pool); -} - -int thread_pool_get_max_running( const thread_pool_type * pool ) { - return pool->max_running; -} diff --git a/ThirdParty/Ert/lib/util/time_interval.c b/ThirdParty/Ert/lib/util/time_interval.c deleted file mode 100644 index 32d1a9be54..0000000000 --- a/ThirdParty/Ert/lib/util/time_interval.c +++ /dev/null @@ -1,174 +0,0 @@ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'time_interval.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include - -#include -#include - -#define TIME_INTERVAL_EMPTY (time_t) -1 -#define TIME_T_MAX (time_t) ((1UL << (( sizeof(time_t) << 3) -1 )) -1 ) -#define TIME_T_MIN -TIME_T_MAX - - -struct time_interval_struct { - bool valid; - time_t start_time; - time_t end_time; -}; - - -/* - If you set something invalid - the whole interval is destroyed. -*/ - -bool time_interval_update( time_interval_type * ti , time_t start_time , time_t end_time) { - ti->start_time = start_time; - ti->end_time = end_time; - - ti->valid = (start_time <= end_time) ? true : false; - return ti->valid; -} - - -bool time_interval_update_start( time_interval_type * ti , time_t start_time ) { - return time_interval_update( ti , start_time , ti->end_time ); -} - - -bool time_interval_update_end( time_interval_type * ti , time_t end_time ) { - return time_interval_update( ti , ti->start_time , end_time ); -} - - -void time_interval_reopen( time_interval_type * time_interval) { - time_interval_update( time_interval , TIME_T_MIN , TIME_T_MAX); -} - - -time_interval_type * time_interval_alloc( time_t start_time , time_t end_time ) { - time_interval_type * ti = (time_interval_type*)util_malloc( sizeof * ti ); - time_interval_update( ti , start_time , end_time ); - return ti; -} - - -time_interval_type * time_interval_alloc_open( ) { - return time_interval_alloc( TIME_T_MIN , TIME_T_MAX ); -} - -time_interval_type * time_interval_alloc_copy( const time_interval_type * src) { - return time_interval_alloc( src->start_time , src->end_time ); -} - - -void time_interval_free( time_interval_type * ti ) { - free( ti ); -} - - -bool time_interval_is_empty( time_interval_type * ti ) { - return (ti->end_time <= ti->start_time); -} - - -bool time_interval_contains( const time_interval_type * ti , time_t t) { - if (!ti->valid) - return false; - else { - if (t < ti->start_time) - return false; - else if (t >= ti->end_time) - return false; - else - return true; - } -} - - - -bool time_interval_has_overlap( const time_interval_type * t1 , const time_interval_type * t2) { - if (t1->valid && t2->valid) { - if (time_interval_contains(t1 , t2->start_time)) - return true; - - if (time_interval_contains(t1 , t2->end_time)) - return true; - - return false; - } else - return false; -} - -bool time_interval_is_adjacent( const time_interval_type * t1 , const time_interval_type * t2) { - if ((t1->end_time == t2->start_time) || (t1->start_time == t2->end_time)) - return true; - else - return false; -} - - -time_t time_interval_get_start( const time_interval_type * ti) { - return ti->start_time; -} - - - -time_t time_interval_get_end( const time_interval_type * ti) { - return ti->end_time; -} - - -bool time_interval_extend( time_interval_type * t1 , const time_interval_type * t2) { - if (time_interval_has_overlap(t1,t2) || time_interval_is_adjacent( t1 , t2)) { - time_t start_time = util_time_t_min( t1->start_time , t2->start_time ); - time_t end_time = util_time_t_max( t1->end_time , t2->end_time ); - - return time_interval_update(t1 , start_time , end_time); - } else - return false; -} - - -bool time_interval_intersect( time_interval_type * t1 , const time_interval_type * t2) { - if (time_interval_has_overlap(t1,t2) || time_interval_is_adjacent( t1 , t2)) { - time_t start_time = util_time_t_max( t1->start_time , t2->start_time ); - time_t end_time = util_time_t_min( t1->end_time , t2->end_time ); - - return time_interval_update(t1 , start_time , end_time); - } else - return false; -} - - -bool time_interval_equal( const time_interval_type * t1 , const time_interval_type * t2) { - if ((t1->start_time == t2->start_time) && (t1->end_time == t2->end_time)) - return true; - else - return false; -} - - -bool time_interval_arg_after( const time_interval_type * ti , time_t arg) { - return util_after( arg , ti->end_time ); -} - - -bool time_interval_arg_before( const time_interval_type * ti , time_t arg) { - return util_before( arg , ti->start_time ); -} diff --git a/ThirdParty/Ert/lib/util/timer.c b/ThirdParty/Ert/lib/util/timer.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/timer.c rename to ThirdParty/Ert/lib/util/timer.cpp index e4672fa7c9..49dd562754 100644 --- a/ThirdParty/Ert/lib/util/timer.c +++ b/ThirdParty/Ert/lib/util/timer.cpp @@ -21,8 +21,8 @@ #include #include -#include -#include +#include +#include #ifdef __cplusplus extern "C" { diff --git a/ThirdParty/Ert/lib/util/type_vector_functions.c b/ThirdParty/Ert/lib/util/type_vector_functions.cpp similarity index 93% rename from ThirdParty/Ert/lib/util/type_vector_functions.c rename to ThirdParty/Ert/lib/util/type_vector_functions.cpp index 8aab49197b..2dec9f3f1e 100644 --- a/ThirdParty/Ert/lib/util/type_vector_functions.c +++ b/ThirdParty/Ert/lib/util/type_vector_functions.cpp @@ -18,11 +18,11 @@ #include -#include -#include -#include +#include +#include +#include -#include +#include int_vector_type * bool_vector_alloc_active_list( const bool_vector_type * mask ) { diff --git a/ThirdParty/Ert/lib/util/ui_return.c b/ThirdParty/Ert/lib/util/ui_return.c deleted file mode 100644 index e1b30f8e80..0000000000 --- a/ThirdParty/Ert/lib/util/ui_return.c +++ /dev/null @@ -1,116 +0,0 @@ -/* - - * - * Created on: Aug 28, 2013 - * Author: joaho - */ -/* - Copyright (C) 2013 Statoil ASA, Norway. - - The file 'ui_return.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include - -#include -#include -#include -#include - - -#define UI_RETURN_TYPE_ID 6122209 - -struct ui_return_struct { - UTIL_TYPE_ID_DECLARATION; - ui_return_status_enum status; - stringlist_type * error_list; - char * help_text; -}; - - -UTIL_IS_INSTANCE_FUNCTION(ui_return , UI_RETURN_TYPE_ID) - - -ui_return_type * ui_return_alloc(ui_return_status_enum status) { - ui_return_type * ui_return = (ui_return_type*)util_malloc( sizeof * ui_return ); - UTIL_TYPE_ID_INIT(ui_return , UI_RETURN_TYPE_ID); - ui_return->status = status; - ui_return->help_text = NULL; - ui_return->error_list = stringlist_alloc_new(); - return ui_return; -} - - -void ui_return_free( ui_return_type * ui_return ) { - stringlist_free(ui_return->error_list); - util_safe_free( ui_return->help_text); - free( ui_return); -} - - -ui_return_status_enum ui_return_get_status(const ui_return_type * ui_return) { - return ui_return->status; -} - - -bool ui_return_add_error(ui_return_type *ui_return , const char * error_msg) { - if (ui_return->status != UI_RETURN_OK) - stringlist_append_copy( ui_return->error_list , error_msg); - - return (ui_return->status != UI_RETURN_OK); -} - - -int ui_return_get_error_count( const ui_return_type * ui_return ) { - return stringlist_get_size( ui_return->error_list ); -} - - -const char * ui_return_get_first_error( const ui_return_type * ui_return) { - if (stringlist_get_size(ui_return->error_list)) - return stringlist_front( ui_return->error_list); - else - return NULL; -} - - -const char * ui_return_get_last_error( const ui_return_type * ui_return) { - if (stringlist_get_size(ui_return->error_list)) - return stringlist_back( ui_return->error_list); - else - return NULL; -} - -const char * ui_return_iget_error( const ui_return_type * ui_return , int index) { - return stringlist_iget(ui_return->error_list , index); -} - - -const char * ui_return_get_help(const ui_return_type * ui_return) { - return ui_return->help_text; -} - - -void ui_return_add_help(ui_return_type * ui_return, const char * help_text) { - if (ui_return->help_text) { - int new_length = strlen(ui_return->help_text) + strlen(help_text) + 1 + 1; - ui_return->help_text = (char*)util_realloc(ui_return->help_text , new_length * sizeof * ui_return->help_text); - - strcat(ui_return->help_text , " "); - strcat(ui_return->help_text , help_text); - } else - ui_return->help_text = util_alloc_string_copy( help_text); -} - - diff --git a/ThirdParty/Ert/lib/util/util.c b/ThirdParty/Ert/lib/util/util.c index 9452a37b79..94e42f9c81 100644 --- a/ThirdParty/Ert/lib/util/util.c +++ b/ThirdParty/Ert/lib/util/util.c @@ -183,7 +183,7 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { variables will be by swapping two elements in one operation; this is provided by the util_endian_convert32_64() function. In the case of binary ECLIPSE files this case is quite common, and - therefor worth supporting as a special case. + therefore worth supporting as a special case. */ uint64_t *tmp64 = (uint64_t *) data; @@ -284,7 +284,8 @@ static bool EOL_CHAR(char c) { numbers, but deterministic runtime. */ -void util_fread_dev_random(int buffer_size , char * buffer) { +void util_fread_dev_random(int buffer_size_ , char * buffer) { + size_t buffer_size = buffer_size_; FILE * stream = util_fopen("/dev/random" , "r"); if (fread(buffer , 1 , buffer_size , stream) != buffer_size) util_abort("%s: failed to read:%d bytes from /dev/random \n",__func__ , buffer_size); @@ -293,7 +294,8 @@ void util_fread_dev_random(int buffer_size , char * buffer) { } -void util_fread_dev_urandom(int buffer_size , char * buffer) { +void util_fread_dev_urandom(int buffer_size_ , char * buffer) { + size_t buffer_size = buffer_size_; FILE * stream = util_fopen("/dev/urandom" , "r"); if (fread(buffer , 1 , buffer_size , stream) != buffer_size) util_abort("%s: failed to read:%d bytes from /dev/random \n",__func__ , buffer_size); @@ -401,7 +403,8 @@ bool util_double_approx_equal( double d1 , double d2) { } -char * util_alloc_substring_copy(const char *src , int offset , int N) { +char * util_alloc_substring_copy(const char *src , int offset , int N_) { + size_t N = N_; char *copy; if ((N + offset) < strlen(src)) { copy = (char*)util_calloc(N + 1 , sizeof * copy ); @@ -461,7 +464,7 @@ char * util_realloc_dequoted_string(char *s) { } void util_strupr(char *s) { - int i; + size_t i; for (i=0; i < strlen(s); i++) s[i] = toupper(s[i]); } @@ -478,7 +481,7 @@ char * util_alloc_strupr_copy(const char * s) { Replaces all occurences of c1 in s with c2. */ void util_string_tr(char * s, char c1, char c2) { - int i; + size_t i; for (i=0; i < strlen(s);i++) if (s[i] == c1) s[i] = c2; } @@ -680,56 +683,6 @@ char * util_fscanf_realloc_line(FILE *stream , bool *at_eof , char *line) { -/** - Reads characters from stdin until EOL/EOF is detected. A '\0' is - appended to the resulting string before it is returned. If the - function reads an immediate EOF/EOL, i.e. the user enters an empty - input string, NULL (and not "") is returned. - - Observe that is this function does *not* cooperate very nicely with - fscanf() based input, because fscanf will leave a EOL character in - the input buffer, which will lead to immediate return from this - function. Hence if this function is called after a fscanf() based - function it is essential to preceede this function with one call to - getchar() to clear the EOL character. -*/ - -char * util_alloc_stdin_line(void) { - int input_size = 256; - char * input = (char*)util_calloc(input_size , sizeof * input ); - int index = 0; - bool end = false; - int c; - do { - c = getchar(); - if ((!EOL_CHAR(c)) && (c != EOF)) { - input[index] = c; - index++; - if (index == (input_size - 1)) { /* Reserve space for terminating \0 */ - input_size *= 2; - input = (char*)util_realloc(input , input_size ); - } - } else end = true; - } while (!end); - if (index == 0) { - free(input); - input = NULL; - } else { - input[index] = '\0'; - input = (char*)util_realloc(input , strlen(input) + 1 ); - } - - return input; -} - - - -char * util_realloc_stdin_line(char * p) { - util_safe_free(p); - return util_alloc_stdin_line(); -} - - /** WIndows does not have the usleep() function, on the other hand @@ -764,23 +717,6 @@ void util_yield() { #endif } -/** - This function will allocate and read a line from stdin. If there is - no input waiting on stdin (this typically only applies if stdin is - redirected from a file/PIPE), the function will sleep for 'usec' - microseconds and try again. -*/ - -char * util_blocking_alloc_stdin_line(unsigned long usec) { - char * line; - do { - line = util_alloc_stdin_line(); - if (line == NULL) - util_usleep(usec); - } while (line == NULL); - return line; -} - static char * util_getcwd(char * buffer , int size) { #ifdef HAVE_POSIX_GETCWD return getcwd( buffer , size ); @@ -875,78 +811,67 @@ char * util_alloc_realpath__(const char * input_path) { char * real_path = (char*)util_malloc( strlen(abs_path) + 2 ); real_path[0] = '\0'; + { - bool * mask; char ** path_list; + const char ** path_stack; int path_len; util_path_split( abs_path , &path_len , &path_list ); - mask = (bool*)util_malloc( path_len * sizeof * mask ); - { - int i; - for (i=0; i < path_len; i++) - mask[i] = true; - } + path_stack = (const char **) util_malloc( path_len * sizeof * path_stack ); + for (int i=0; i < path_len; i++) + path_stack[i] = NULL; { - int path_index = 1; // Path can not start with .. - int prev_index = 0; - while (true) { - if (path_index == path_len) - break; + int stack_size = 0; - if (strcmp(path_list[path_index] , BACKREF ) == 0) { - mask[path_index] = false; - mask[prev_index] = false; - prev_index--; - path_index++; - } else if (strcmp( path_list[path_index] , CURRENT) == 0) { - mask[path_index] = false; - path_index++; - } else { - path_index++; - prev_index++; - while (!mask[prev_index]) - prev_index++; + for (int path_index=0; path_index < path_len; path_index++) { + const char * path_elm = path_list[path_index]; + + if (strcmp( path_elm , CURRENT) == 0) + continue; + + /* Backref - pop from stack. */ + if (strcmp(path_elm , BACKREF ) == 0) { + if (stack_size > 0) { + memmove(path_stack, &path_stack[1] , (stack_size - 1) * sizeof * path_stack); + stack_size--; + } + continue; } + + /* Normal path element - push onto stack. */ + memmove(&path_stack[1], path_stack, stack_size * sizeof * path_stack); + path_stack[0] = path_elm; + stack_size++; } /* Build up the new string. */ - { - int i; - bool first = true; - - for (i=0; i < path_len; i++) { - if (mask[i]) { - const char * path_elm = path_list[i]; - if (first) { - + if (stack_size > 0) { + for (int pos = stack_size - 1; pos >= 0; pos--) { + const char * path_elm = path_stack[pos]; + if (pos == (stack_size- 1)) { #ifdef ERT_WINDOWS - // Windows: - // 1) If the path starts with X: - just do nothing - // 2) Else add \\ - for a UNC path. - if (path_elm[1] != ':') { - strcat(real_path, UTIL_PATH_SEP_STRING); - strcat(real_path, UTIL_PATH_SEP_STRING); - } -#else - // Posix: just start with a leading '/' + // Windows: + // 1) If the path starts with X: - just do nothing + // 2) Else add \\ - for a UNC path. + if (path_elm[1] != ':') { strcat(real_path, UTIL_PATH_SEP_STRING); -#endif - strcat( real_path , path_elm); - } else { - strcat(real_path, UTIL_PATH_SEP_STRING); - strcat( real_path , path_elm); - } - - first = false; +#else + // Posix: just start with a leading '/' + strcat(real_path, UTIL_PATH_SEP_STRING); +#endif + strcat( real_path , path_elm); + } else { + strcat(real_path, UTIL_PATH_SEP_STRING); + strcat(real_path , path_elm); } } } } - free(mask); + free( path_stack ); util_free_stringlist( path_list , path_len ); } @@ -1085,10 +1010,7 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { util_free_stringlist( path_list , path_length ); free( root_path ); - if (strlen(rel_path) == 0) { - free(rel_path); - rel_path = NULL; - } return rel_path; + return rel_path; } else { /* One or both the input arguments do not correspond to an @@ -1099,73 +1021,22 @@ char * util_alloc_rel_path( const char * __root_path , const char * path) { } } - - - -/** - This function will allocate a string copy of the env_index'th - occurence of an embedded environment variable from the input - string. - - An environment variable is defined as follows: - - 1. It starts with '$'. - 2. It ends with a characeter NOT in the set [a-Z,0-9,_]. - - The function will return environment variable number 'env_index'. If - no such environment variable can be found in the string the - function will return NULL. - - Observe that the returned string will start with '$'. This is to - simplify subsequent calls to util_string_replace_XXX() functions, - however &ret_value[1] must be used in the subsequent getenv() call: - - { - char * env_var = util_isscanf_alloc_envvar( s , 0 ); - if (env_var != NULL) { - const char * env_value = getenv( &env_var[1] ); // Skip the leading '$'. - if (env_value != NULL) - util_string_replace_inplace( s , env_value ); - else - fprintf(stderr,"** Warning: environment variable: \'%s\' is not defined \n", env_var); - free( env_var ); - } - } - - +/* + This function will return a new string where all "../" and "./" + occurences have been normalized away. The function is based on pure + string scanning, and will not consider the filesystem at + all. */ -char * util_isscanf_alloc_envvar( const char * string , int env_index ) { - int env_count = 0; - const char * offset = string; - const char * env_ptr; - do { - env_ptr = strchr( offset , '$' ); - offset = &env_ptr[1]; - env_count++; - } while ((env_count <= env_index) && (env_ptr != NULL)); +char * util_alloc_normal_path( const char * input_path ) { + if (util_is_abs_path(input_path)) + return util_alloc_realpath__( input_path ); - if (env_ptr != NULL) { - /* - We found an environment variable we are interested in. Find the - end of this variable and return a copy. - */ - int length = 1; - bool cont = true; - do { + char * realpath = util_alloc_realpath__(input_path); + return util_alloc_rel_path( NULL , realpath ); +} - if ( !( isalnum(env_ptr[length]) || env_ptr[length] == '_' )) - cont = false; - else - length++; - if (length == strlen( env_ptr )) - cont = false; - } while (cont); - return util_alloc_substring_copy( env_ptr , 0 , length ); - } else - return NULL; /* Could not find any env variable occurences. */ -} @@ -1267,7 +1138,7 @@ bool util_char_in(char c , int set_size , const char * set) { isspace(). */ bool util_string_isspace(const char * s) { - int index = 0; + size_t index = 0; while (index < strlen(s)) { if (!isspace( s[index] )) return false; @@ -1994,8 +1865,10 @@ bool util_sscanf_bool(const char * buffer , bool * _value) { bool util_fscanf_bool(FILE * stream , bool * value) { char buffer[256]; - fscanf(stream , "%s" , buffer); - return util_sscanf_bool( buffer , value ); + if (fscanf(stream , "%s" , buffer) == 1) + return util_sscanf_bool( buffer , value ); + + return false; } @@ -2026,146 +1899,11 @@ bool util_fscanf_int(FILE * stream , int * value) { } -/** - Prompt .........====> - <-------1------><-2-> - - The section marked with 1 above is the prompt length, i.e. the - input prompt is padded wth one blank, and then padded with - 'fill_char' (in the case above that is '.') characters up to a - total length of prompt_len. Then the the termination string ("===>" - above) is added. Observe the following: - - * A space is _always_ added after the prompt, before the fill char - comes, even if the prompt is too long in the first place. - - * No space is added at the end of the termination string. If - you want a space, that should be included in the termination - string. - -*/ - - -void util_printf_prompt(const char * prompt , int prompt_len, char fill_char , const char * termination) { - int current_len = strlen(prompt) + 1; - printf("%s ",prompt); /* Observe that one ' ' is forced in here. */ - - while (current_len < prompt_len) { - fputc(fill_char , stdout); - current_len++; - } - printf("%s" , termination); - -} - - -/** - This functions presents the user with a prompt, and reads an - integer - the integer value is returned. The functions returns - NULL on empty input. -*/ - -int util_scanf_int(const char * prompt , int prompt_len) { - char input[256]; - int int_value; - bool OK; - do { - util_printf_prompt(prompt , prompt_len, '=', "=> "); - scanf("%s" , input); - OK = util_sscanf_int(input , &int_value); - } while (!OK); - getchar(); /* eating a \r left in the stdin input buffer. */ - return int_value; -} - -/** - This functions presents the user with a prompt, and reads an - integer - the integer value is returned. The functions will loop - indefinitely until a valid integer is entered. -*/ - -char * util_scanf_int_return_char(const char * prompt , int prompt_len) { - char input[256]; - int int_value; - bool OK = false; - while(!OK){ - util_printf_prompt(prompt , prompt_len, '=', "=> "); - fgets(input, prompt_len, stdin); - { - char *newline = strchr(input,'\n'); - if(newline) - *newline = 0; - } - - if(strlen(input) !=0){ - OK = util_sscanf_int(input , &int_value); - } - else { - OK = true; - } - } - return util_alloc_string_copy(input); -} - - -double util_scanf_double(const char * prompt , int prompt_len) { - char input[256]; - double double_value; - bool OK; - do { - util_printf_prompt(prompt , prompt_len, '=', "=> "); - scanf("%s" , input); - OK = util_sscanf_double(input , &double_value); - } while (!OK); - getchar(); /* eating a \r left in the stdin input buffer. */ - return double_value; -} - - - - -/** - The limits are inclusive. -*/ -int util_scanf_int_with_limits(const char * prompt , int prompt_len , int min_value , int max_value) { - int value; - char * new_prompt = util_alloc_sprintf("%s [%d:%d]" , prompt , min_value , max_value); - do { - value = util_scanf_int(new_prompt , prompt_len); - } while (value < min_value || value > max_value); - free(new_prompt); - return value; -} - -/** - The limits are inclusive, yet the function returns the input char and stops on empty string. -*/ -char * util_scanf_int_with_limits_return_char(const char * prompt , int prompt_len , int min_value , int max_value) { - int value = min_value - 1; - char * value_char = NULL; - char * new_prompt = util_alloc_sprintf("%s [%d:%d]" , prompt , min_value , max_value); - while( value < min_value || value > max_value ){ - value_char = util_scanf_int_return_char(new_prompt , prompt_len); - if (strlen(value_char) == 0) - value = min_value; - else - util_sscanf_int(value_char , &value); - } - free(new_prompt); - return value_char; -} - -char * util_scanf_alloc_string(const char * prompt) { - char input[256]; - printf("%s" , prompt); - scanf("%256s" , input); - return util_alloc_string_copy(input); -} @@ -2265,8 +2003,8 @@ char * util_fread_alloc_file_content(const char * filename , int * buffer_size) bool util_copy_stream(FILE *src_stream , FILE *target_stream , size_t buffer_size , void * buffer , bool abort_on_error) { while ( ! feof(src_stream)) { - int bytes_read; - int bytes_written; + size_t bytes_read; + size_t bytes_written; bytes_read = fread (buffer , 1 , buffer_size , src_stream); if (bytes_read < buffer_size && !feof(src_stream)) { @@ -2505,9 +2243,27 @@ int util_fmove( FILE * stream , long offset , long shift) { } +/* + Windows *might* have both the symbols _access() and access(), but we prefer + the _access() symbol as that seems to be preferred by Windows. We therefor do + the #HAVE_WINDOWS__ACCESS check first. +*/ + +#ifdef HAVE_WINDOWS__ACCESS + +bool util_access(const char * entry, int mode) { + return (_access(entry, mode) == 0); +} +#else +#ifdef HAVE_POSIX_ACCESS +bool util_access(const char * entry, mode_t mode) { + return (access(entry, mode) == 0); +} +#endif +#endif /** @@ -2527,20 +2283,8 @@ bool util_file_exists(const char *filename) { */ bool util_entry_exists( const char * entry ) { - stat_type stat_buffer; - int stat_return = util_stat(entry, &stat_buffer); - if (stat_return == 0) - return true; - else { - if (errno == ENOENT) - return false; - else { - util_abort("%s: error checking for entry:%s %d/%s \n",__func__ , entry , errno , strerror(errno)); - return false; - } - } + return util_access(entry, F_OK); } - /*****************************************************************/ @@ -2678,7 +2422,7 @@ bool util_entry_writable( const char * entry ) { -static int util_get_path_length(const char * file) { +static size_t util_get_path_length(const char * file) { if (util_is_directory(file)) return strlen(file); else { @@ -2693,7 +2437,7 @@ static int util_get_path_length(const char * file) { static int util_get_base_length(const char * file) { - int path_length = util_get_path_length(file); + size_t path_length = util_get_path_length(file); const char * base_start; const char * last_point; long character_index; @@ -2896,6 +2640,7 @@ bool util_ftruncate(FILE * stream , long size) { */ bool util_same_file(const char * file1 , const char * file2) { +#ifdef ERT_HAVE_UNISTD stat_type buffer1 , buffer2; int stat1,stat2; @@ -2909,6 +2654,18 @@ bool util_same_file(const char * file1 , const char * file2) { return false; } else return false; // Files which do not exist are no equal! +#else + if (util_file_exists(file1) && util_file_exists(file2)) { + char * abs_path1 = util_alloc_abs_path(file1); + char * abs_path2 = util_alloc_abs_path(file2); + bool same_file = util_string_equal(abs_path1, abs_path2); + free(abs_path1); + free(abs_path2); + return same_file; + } + else + return false; +#endif } @@ -3550,9 +3307,10 @@ char * util_realloc_string_copy(char * old_string , const char *src ) { } -char * util_realloc_substring_copy(char * old_string , const char *src , int len) { +char * util_realloc_substring_copy(char * old_string , const char *src , int len_) { + size_t len = len_; if (src != NULL) { - int str_len; + size_t str_len; char *copy; if (strlen(src) < len) str_len = strlen(src); @@ -3938,7 +3696,7 @@ void util_binary_split_string(const char * __src , const char * sep_set, bool sp char * src; if (__src != NULL) { - int offset = 0; + size_t offset = 0; int len; /* 1: Remove leading split characters. */ while ((offset < strlen(__src)) && (strchr(sep_set , __src[offset]) != NULL)) @@ -4027,7 +3785,7 @@ void util_binary_split_string_from_max_length(const char * __src , const char * char * second_part = NULL; if (__src != NULL) { char * src; - int pos; + size_t pos; /* Removing leading separators. */ pos = 0; while ((pos < strlen(__src)) && (strchr(sep_set , __src[pos]) != NULL)) @@ -4109,7 +3867,7 @@ int static util_string_replace_inplace__(char ** _buffer , const char * expr , c int len_expr = strlen( expr ); int len_subs = strlen( subs ); int size = strlen(buffer); - int offset = 0; + size_t offset = 0; int match_count = 0; char * match = NULL; @@ -4601,14 +4359,14 @@ FILE * util_mkdir_fopen( const char * filename , const char * mode ) { void util_fwrite(const void *ptr , size_t element_size , size_t items, FILE * stream , const char * caller) { - int items_written = fwrite(ptr , element_size , items , stream); + size_t items_written = fwrite(ptr , element_size , items , stream); if (items_written != items) util_abort("%s/%s: only wrote %d/%d items to disk - aborting: %s(%d) .\n",caller , __func__ , items_written , items , strerror(errno) , errno); } void util_fread(void *ptr , size_t element_size , size_t items, FILE * stream , const char * caller) { - int items_read = fread(ptr , element_size , items , stream); + size_t items_read = fread(ptr , element_size , items , stream); if (items_read != items) util_abort("%s/%s: only read %d/%d items from disk - aborting.\n %s(%d) \n",caller , __func__ , items_read , items , strerror(errno) , errno); } @@ -4712,67 +4470,6 @@ void util_free(void * ptr) { -static void util_display_prompt(const char * prompt , int prompt_len2) { - int i; - printf("%s" , prompt); - for (i=0; i < util_int_max(strlen(prompt) , prompt_len2) - strlen(prompt); i++) - fputc(' ' , stdout); - printf(": "); -} - - - -void util_read_string(const char * prompt , int prompt_len , char * s) { - util_display_prompt(prompt , prompt_len); - fscanf(stdin , "%s" , s); -} - - -void util_read_path(const char * prompt , int prompt_len , bool must_exist , char * path) { - bool ok = false; - while (!ok) { - util_read_string(prompt , prompt_len , path); - if (must_exist) - ok = util_is_directory(path); - else - ok = true; - if (!ok) - fprintf(stderr,"Path: %s does not exist - try again.\n",path); - } -} - -/* - exist_status == 0: Just read a string; do not check if it exist or not. - exist_status == 1: Must be existing file. - exist_status == 2: Must NOT exist as entry. -*/ - -char * util_fscanf_alloc_filename(const char * prompt , int prompt_len , int exist_status) { - char * filename = NULL; - while (filename == NULL) { - util_printf_prompt(prompt , prompt_len , '=' , "=> "); - filename = util_alloc_stdin_line(); - if (filename != NULL) { - if (exist_status != 0) { - if (exist_status == 1) { - if (!util_file_exists(filename)) { - fprintf(stderr,"Sorry: %s does not exist. \n",filename); - free( filename ); - filename = NULL; - } - } else if (exist_status == 2) { - if (util_entry_exists( filename )) { - fprintf(stderr,"Sorry: entry %s already exists. \n",filename); - free( filename ); - filename = NULL; - } - } - } - } - } - return filename; -} - /*****************************************************************/ @@ -4798,9 +4495,10 @@ void util_fprintf_int(int value , int width , FILE * stream) { -void util_fprintf_string(const char * s , int width , string_alignement_type alignement , FILE * stream) { +void util_fprintf_string(const char * s , int width_ , string_alignement_type alignement , FILE * stream) { char fmt[32]; - int i; + size_t i; + size_t width = width_; if (alignement == left_pad) { i = 0; if (width > strlen(s)) { @@ -4809,7 +4507,7 @@ void util_fprintf_string(const char * s , int width , string_alignement_type ali } fprintf(stream , "%s", s); } else if (alignement == right_pad) { - sprintf(fmt , "%%-%ds" , width); + sprintf(fmt , "%%-%lus" , width); fprintf(stream , fmt , s); } else { int total_pad = width - strlen(s); @@ -5082,39 +4780,6 @@ const char * util_enum_iget( int index , int size , const util_enum_element_type } -static char * __abort_program_message = NULL; /* Can use util_abort_append_version_info() to fill this with - version info+++ wich will be printed when util_abort() is called. */ -static char * __current_executable = NULL; - - -void util_abort_append_version_info(const char * msg) { - __abort_program_message = util_strcat_realloc( __abort_program_message , msg ); -} - - -void util_abort_free_version_info() { - util_safe_free( __abort_program_message ); - util_safe_free( __current_executable ); - - __current_executable = NULL; - __abort_program_message = NULL; -} - - -void util_abort_set_executable( const char * argv0 ) { - if (util_is_abs_path(argv0)) - __current_executable = util_realloc_string_copy( __current_executable , argv0 ); - else { - char * executable; - if (util_is_executable( argv0 )) - executable = util_alloc_realpath(argv0); - else - executable = util_alloc_PATH_executable( argv0 ); - - util_abort_set_executable( executable ); - free( executable ); - } -} @@ -5248,7 +4913,7 @@ void util_make_path(const char *_path) { int i = 0; active_path = (char*)util_calloc(strlen(path) + 1 , sizeof * active_path ); do { - int n = strcspn(path , UTIL_PATH_SEP_STRING); + size_t n = strcspn(path , UTIL_PATH_SEP_STRING); if (n < strlen(path)) n += 1; path += n; @@ -5346,24 +5011,23 @@ char * util_alloc_filename(const char * path , const char * basename , const cha char * file; int length = strlen(basename) + 1; - if (path != NULL) + if (path && strlen(path)) length += strlen(path) + 1; - if (extension != NULL) + if (extension && strlen(extension)) length += strlen(extension) + 1; - file = (char*)util_calloc(length , sizeof * file ); - - if (path == NULL) { - if (extension == NULL) - memcpy(file , basename , strlen(basename) + 1); - else - sprintf(file , "%s.%s" , basename , extension); - } else { - if (extension == NULL) - sprintf(file , "%s%c%s" , path , UTIL_PATH_SEP_CHAR , basename); - else - sprintf(file , "%s%c%s.%s" , path , UTIL_PATH_SEP_CHAR , basename , extension); + file = (char*) util_calloc(length , sizeof * file ); + file[0] = '\0'; + + if (path && strlen(path)) { + strcat(file, path); + strcat(file, UTIL_PATH_SEP_STRING ); + } + strcat(file, basename); + if (extension && strlen(extension)) { + strcat(file, "."); + strcat(file, extension); } return file; diff --git a/ThirdParty/Ert/lib/util/util_abort_gnu.c b/ThirdParty/Ert/lib/util/util_abort_gnu.c index 153fff6843..1e651fd8b9 100644 --- a/ThirdParty/Ert/lib/util/util_abort_gnu.c +++ b/ThirdParty/Ert/lib/util/util_abort_gnu.c @@ -179,7 +179,7 @@ static void util_fprintf_backtrace(FILE * stream) { if (util_addr2line_lookup(bt_addr[i], &func_name , &file_name , &line_nr)) { int pad_length; - char * function; + const char * function; // Seems it can return true - but with func_name == NULL?! Static/inlinded functions? if (func_name) function = func_name; @@ -282,7 +282,7 @@ void util_abort__(const char * file , const char * function , int line , const c if (__abort_program_message != NULL) { #if !defined(__GLIBC__) /* allocate a temporary buffer to hold the path */ - char* program_invocation_name = alloca (PATH_MAX); + char* program_invocation_name = (char*)alloca (PATH_MAX); # if defined(__APPLE__) uint32_t buflen = PATH_MAX; _NSGetExecutablePath (program_invocation_name, &buflen); diff --git a/ThirdParty/Ert/lib/util/util_abort_simple.c b/ThirdParty/Ert/lib/util/util_abort_simple.c index 9f7363f414..56586fd994 100644 --- a/ThirdParty/Ert/lib/util/util_abort_simple.c +++ b/ThirdParty/Ert/lib/util/util_abort_simple.c @@ -4,7 +4,7 @@ */ #include #include - +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_endian.c b/ThirdParty/Ert/lib/util/util_endian.cpp similarity index 98% rename from ThirdParty/Ert/lib/util/util_endian.c rename to ThirdParty/Ert/lib/util/util_endian.cpp index b2a5d1e2c6..3c88e55545 100644 --- a/ThirdParty/Ert/lib/util/util_endian.c +++ b/ThirdParty/Ert/lib/util/util_endian.cpp @@ -119,7 +119,7 @@ void util_endian_flip_vector(void *data, int element_size , int elements) { variables will be by swapping two elements in one operation; this is provided by the util_endian_convert32_64() function. In the case of binary ECLIPSE files this case is quite common, and - therefor worth supporting as a special case. + therefore worth supporting as a special case. */ uint64_t *tmp64 = (uint64_t *) data; diff --git a/ThirdParty/Ert/lib/util/util_env.c b/ThirdParty/Ert/lib/util/util_env.c deleted file mode 100644 index 753646b86a..0000000000 --- a/ThirdParty/Ert/lib/util/util_env.c +++ /dev/null @@ -1,280 +0,0 @@ -/* - Copyright (C) 2012 Statoil ASA, Norway. - - The file 'util_env.c' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. -*/ -#include -#include -#include - -#include "ert/util/build_config.h" - -#include -#include -#include - -#ifdef HAVE_POSIX_SETENV -#define PATHVAR_SPLIT ":" - -void util_unsetenv( const char * variable ) { - unsetenv( variable ); -} - -void util_setenv( const char * variable , const char * value) { - int overwrite = 1; - setenv( variable , value , overwrite ); -} - -#else - -#include - -#define PATHVAR_SPLIT ";" -void util_setenv( const char * variable , const char * value) { - SetEnvironmentVariable( variable , NULL ); -} - -void util_unsetenv( const char * variable ) { - util_setenv( variable , NULL ); -} -#endif - -/** - Will return a NULL terminated list char ** of the paths in the PATH - variable. -*/ - -char ** util_alloc_PATH_list() { - char ** path_list = NULL; - char * path_env = getenv("PATH"); - if (path_env != NULL) { - int path_size; - - util_split_string(path_env , PATHVAR_SPLIT , &path_size , &path_list); - path_list = (char**)util_realloc( path_list , (path_size + 1) * sizeof * path_list); - path_list[path_size] = NULL; - } else { - path_list = (char**)util_malloc( sizeof * path_list); - path_list[0] = NULL; - } - return path_list; -} - -/** - This function searches through the content of the (currently set) - PATH variable, and allocates a string containing the full path - (first match) to the executable given as input. - - * If the entered executable already is an absolute path, a copy of - the input is returned *WITHOUT* consulting the PATH variable (or - checking that it exists). - - * If the executable starts with "./" getenv("PWD") is prepended. - - * If the executable is not found in the PATH list NULL is returned. -*/ - - -char * util_alloc_PATH_executable(const char * executable) { - if (util_is_abs_path(executable)) { - if (util_is_executable(executable)) - return util_alloc_string_copy(executable); - else - return NULL; - } else if (strncmp(executable , "./" , 2) == 0) { - char * cwd = util_alloc_cwd(); - char * path = util_alloc_filename(cwd , &executable[2] , NULL); - - /* The program has been invoked as ./xxxx */ - if (!(util_is_file(path) && util_is_executable( path ))) { - free( path ); - path = NULL; - } - free( cwd ); - - return path; - } else { - char * full_path = NULL; - char ** path_list = util_alloc_PATH_list(); - int ipath = 0; - - while (true) { - if (path_list[ipath] != NULL) { - char * current_attempt = util_alloc_filename(path_list[ipath] , executable , NULL); - - if ( util_is_file( current_attempt ) && util_is_executable( current_attempt )) { - full_path = current_attempt; - break; - } else { - free(current_attempt); - ipath++; - } - } else - break; - } - - util_free_NULL_terminated_stringlist(path_list); - return full_path; - } -} - - - - - -/** - This function updates an environment variable representing a path, - before actually updating the environment variable the current value - is checked, and the following rules apply: - - 1. If @append == true, and @value is already included in the - environment variable; nothing is done. - - 2. If @append == false, and the variable already starts with - @value, nothing is done. - - A pointer to the updated(?) environment variable is returned. -*/ - -const char * util_update_path_var(const char * variable, const char * value, bool append) { - const char * current_value = getenv( variable ); - if (current_value == NULL) - /* The (path) variable is not currently set. */ - util_setenv( variable , value ); - else { - bool update = true; - - { - char ** path_list; - int num_path; - util_split_string( current_value , ":" , &num_path , &path_list); - if (append) { - int i; - for (i = 0; i < num_path; i++) { - if (util_string_equal( path_list[i] , value)) - update = false; /* The environment variable already contains @value - no point in appending it at the end. */ - } - } else { - if (util_string_equal( path_list[0] , value)) - update = false; /* The environment variable already starts with @value. */ - } - util_free_stringlist( path_list , num_path ); - } - - if (update) { - char * new_value; - if (append) - new_value = util_alloc_sprintf("%s:%s" , current_value , value); - else - new_value = util_alloc_sprintf("%s:%s" , value , current_value); - util_setenv( variable , new_value ); - free( new_value ); - } - - } - return getenv( variable ); -} - - - -/** - This is a thin wrapper around the setenv() call, with the twist - that all $VAR expressions in the @value parameter are replaced with - getenv() calls, so that the function call: - - util_setenv("PATH" , "$HOME/bin:$PATH") - - Should work as in the shell. If the variables referred to with ${} - in @value do not exist the literal string, i.e. '$HOME' is - retained. - - If @value == NULL a call to unsetenv( @variable ) will be issued. -*/ - -const char * util_interp_setenv( const char * variable , const char * value) { - char * interp_value = util_alloc_envvar( value ); - if (interp_value != NULL) { - util_setenv( variable , interp_value); - free( interp_value ); - } else - util_unsetenv( variable ); - - return getenv( variable ); -} - - - -/** - This function will take a string as input, and then replace all if - $VAR expressions with the corresponding environment variable. If - the environament variable VAR is not set, the string literal $VAR - is retained. The return value is a newly allocated string. - - If the input value is NULL - the function will just return NULL; -*/ - - -char * util_alloc_envvar( const char * value ) { - if (value == NULL) - return NULL; - else { - buffer_type * buffer = buffer_alloc( 1024 ); /* Start by filling up a buffer instance with - the current content of @value. */ - buffer_fwrite_char_ptr( buffer , value ); - buffer_rewind( buffer ); - - - while (true) { - if (buffer_strchr( buffer , '$')) { - const char * data = (const char*)buffer_get_data( buffer ); - int offset = buffer_get_offset( buffer ) + 1; /* Points at the first character following the '$' */ - int var_length = 0; - - /* Find the length of the variable name */ - while (true) { - char c; - c = data[offset + var_length]; - if (!(isalnum( c ) || c == '_')) /* Any character which is NOT in the set [a-Z,0-9_] marks the end of the variable. */ - break; - - if (c == '\0') /* The end of the string. */ - break; - - var_length += 1; - } - - { - char * var_name = util_alloc_substring_copy( data , offset - 1 , var_length + 1); /* Include the leading $ */ - const char * var_value = getenv( &var_name[1] ); - - if (var_value != NULL) - buffer_search_replace( buffer , var_name , var_value); /* The actual string replacement. */ - else - buffer_fseek( buffer , var_length , SEEK_CUR ); /* The variable is not defined, and we leave the $name. */ - - free( var_name ); - } - } else break; /* No more $ to replace */ - } - - - buffer_shrink_to_fit( buffer ); - { - char * expanded_value = (char*)buffer_get_data( buffer ); - buffer_free_container( buffer ); - return expanded_value; - } - } -} diff --git a/ThirdParty/Ert/lib/util/util_getuid.c b/ThirdParty/Ert/lib/util/util_getuid.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/util_getuid.c rename to ThirdParty/Ert/lib/util/util_getuid.cpp index 678803a476..4b22ab5752 100644 --- a/ThirdParty/Ert/lib/util/util_getuid.c +++ b/ThirdParty/Ert/lib/util/util_getuid.cpp @@ -1,7 +1,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_lockf.c b/ThirdParty/Ert/lib/util/util_lockf.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/util_lockf.c rename to ThirdParty/Ert/lib/util/util_lockf.cpp index fe3636b85c..9114b9d0d9 100644 --- a/ThirdParty/Ert/lib/util/util_lockf.c +++ b/ThirdParty/Ert/lib/util/util_lockf.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include @@ -20,7 +20,7 @@ If the lock is aquired the function will return true, otherwise it will return false. The lock is only active as long as the lockfile - is open, we therefor have to keep track of the relevant file + is open, we therefore have to keep track of the relevant file descriptor; it is passed back to the calling scope through a reference. Observe that if the locking fails we close the file immediately, and return -1 in the file descriptor argument. diff --git a/ThirdParty/Ert/lib/util/util_opendir.c b/ThirdParty/Ert/lib/util/util_opendir.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/util_opendir.c rename to ThirdParty/Ert/lib/util/util_opendir.cpp index 3205364699..6984baf67f 100644 --- a/ThirdParty/Ert/lib/util/util_opendir.c +++ b/ThirdParty/Ert/lib/util/util_opendir.cpp @@ -2,7 +2,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/Ert/lib/util/util_spawn.c b/ThirdParty/Ert/lib/util/util_spawn.cpp similarity index 72% rename from ThirdParty/Ert/lib/util/util_spawn.c rename to ThirdParty/Ert/lib/util/util_spawn.cpp index 35a2d32112..429e05c95d 100644 --- a/ThirdParty/Ert/lib/util/util_spawn.c +++ b/ThirdParty/Ert/lib/util/util_spawn.cpp @@ -1,5 +1,5 @@ -#include -#include "ert/util/build_config.h" +#include +#include "ert/util/build_config.hpp" #include #include @@ -10,7 +10,7 @@ #include #include -#include +#include extern char **environ; @@ -19,7 +19,18 @@ extern char **environ; #define STDOUT_FILENO 1 #define STDERR_FILENO 2 -static void __init_redirection(posix_spawn_file_actions_t * file_actions, const char *stdout_file, const char *stderr_file) { +static void spawn_init_attributes__(posix_spawnattr_t * attributes) { + posix_spawnattr_init(attributes); + short flags; + + posix_spawnattr_getflags(attributes, &flags); + flags |= POSIX_SPAWN_SETPGROUP; + posix_spawnattr_setflags(attributes, flags); + + posix_spawnattr_setpgroup( attributes, 0); +} + +static void spawn_init_redirection__(posix_spawn_file_actions_t * file_actions, const char *stdout_file, const char *stderr_file) { int status; status = posix_spawn_file_actions_init(file_actions); @@ -62,27 +73,28 @@ static pthread_mutex_t spawn_mutex = PTHREAD_MUTEX_INITIALIZER; */ pid_t util_spawn(const char *executable, int argc, const char **argv, const char *stdout_file, const char *stderr_file) { pid_t pid; - char **__argv = (char**)util_malloc((argc + 2) * sizeof *__argv); + char **argv__ = (char**)util_malloc((argc + 2) * sizeof *argv__); { int iarg; - __argv[0] = (char *) executable; + argv__[0] = (char *) executable; for (iarg = 0; iarg < argc; iarg++) - __argv[iarg + 1] = (char *) argv[iarg]; - __argv[argc + 1] = NULL; + argv__[iarg + 1] = (char *) argv[iarg]; + argv__[argc + 1] = NULL; } { + posix_spawnattr_t spawn_attr; posix_spawn_file_actions_t file_actions; - __init_redirection(&file_actions , stdout_file , stderr_file); - + spawn_init_redirection__(&file_actions , stdout_file , stderr_file); + spawn_init_attributes__(&spawn_attr); pthread_mutex_lock( &spawn_mutex ); { int spawn_status; if (util_is_executable(executable)) { // the executable is in current directory or an absolute path - spawn_status = posix_spawn(&pid, executable, &file_actions, NULL, __argv, environ); + spawn_status = posix_spawn(&pid, executable, &file_actions, &spawn_attr, argv__, environ); } else { // Try to find executable in path - spawn_status = posix_spawnp(&pid, executable, &file_actions, NULL, __argv, environ); + spawn_status = posix_spawnp(&pid, executable, &file_actions, &spawn_attr, argv__, environ); } if (spawn_status != 0) @@ -90,9 +102,10 @@ pid_t util_spawn(const char *executable, int argc, const char **argv, const char } pthread_mutex_unlock( &spawn_mutex ); posix_spawn_file_actions_destroy(&file_actions); + posix_spawnattr_destroy(&spawn_attr); } - free(__argv); + free(argv__); return pid; } @@ -111,30 +124,6 @@ int util_spawn_blocking(const char *executable, int argc, const char **argv, con -/** - The ping program must(?) be setuid root, so implementing a simple - version based on sockets() proved to be nontrivial. - - The PING_CMD is passed as -D from the build system. -*/ - -#ifdef ERT_HAVE_PING -#define xstr(s) #s -#define str(s) xstr(s) -bool util_ping(const char *hostname) { - int wait_status; - const char* args[ 4 ] = { "-c", "3", "-q", hostname }; - wait_status = util_spawn_blocking(str(PING_CMD), 4, args, "/dev/null" , "/dev/null"); - - if (WIFEXITED( wait_status )) { - int ping_status = WEXITSTATUS( wait_status ); - return ping_status == 0; - } else { - return false; - } -} -#endif - diff --git a/ThirdParty/Ert/lib/util/util_symlink.c b/ThirdParty/Ert/lib/util/util_symlink.cpp similarity index 94% rename from ThirdParty/Ert/lib/util/util_symlink.c rename to ThirdParty/Ert/lib/util/util_symlink.cpp index e68796d534..bfa79dd893 100644 --- a/ThirdParty/Ert/lib/util/util_symlink.c +++ b/ThirdParty/Ert/lib/util/util_symlink.cpp @@ -2,9 +2,9 @@ #include #include -#include "ert/util/build_config.h" -#include -#include +#include "ert/util/build_config.hpp" +#include +#include #ifndef ERT_HAVE_SYMLINK @@ -91,12 +91,14 @@ char * util_alloc_link_target(const char * link) { #ifdef ERT_HAVE_READLINKAT +#if !defined(ERT_HAVE_READLINKAT_DECLARATION) /* The manual page says that the readlinkat() function should be in the unistd.h header file, but not on RedHat5. On RedHat6 it is. */ extern ssize_t readlinkat (int __fd, __const char *__restrict __path, char *__restrict __buf, size_t __len); +#endif /* !defined(ERT_HAVE_READLINKAT_DECLARATION) */ char * util_alloc_atlink_target(const char * path , const char * link) { if (util_is_abs_path( link )) diff --git a/ThirdParty/Ert/lib/util/util_unlink.c b/ThirdParty/Ert/lib/util/util_unlink.cpp similarity index 93% rename from ThirdParty/Ert/lib/util/util_unlink.c rename to ThirdParty/Ert/lib/util/util_unlink.cpp index 5f3af54979..4cf13ecfa8 100644 --- a/ThirdParty/Ert/lib/util/util_unlink.c +++ b/ThirdParty/Ert/lib/util/util_unlink.cpp @@ -16,9 +16,9 @@ for more details. */ -#include "ert/util/build_config.h" +#include "ert/util/build_config.hpp" -#include +#include #if defined(HAVE_WINDOWS_UNLINK) diff --git a/ThirdParty/Ert/lib/util/util_zlib.c b/ThirdParty/Ert/lib/util/util_zlib.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/util_zlib.c rename to ThirdParty/Ert/lib/util/util_zlib.cpp index 195de19319..95c813b68b 100644 --- a/ThirdParty/Ert/lib/util/util_zlib.c +++ b/ThirdParty/Ert/lib/util/util_zlib.cpp @@ -5,7 +5,7 @@ #include -#include +#include /** This function reads data from the input pointer data, and writes a @@ -93,7 +93,7 @@ Layout on disk when using util_fwrite_compressed: Observe that the functions util_fwrite_compressed() and util_fread_compressed must be used as a pair, the files can **N O T** be interchanged with normal calls to gzip/gunzip. To avoid confusion -it is therefor strongly advised NOT to give the files a .gz extension. +it is therefore strongly advised NOT to give the files a .gz extension. */ @@ -134,7 +134,7 @@ void util_fwrite_compressed(const void * _data , int size , FILE * stream) { util_compress_buffer(&data[offset] , this_block_size , zbuffer , &compressed_size); fwrite(&compressed_size , sizeof compressed_size , 1 , stream); { - int bytes_written = fwrite(zbuffer , 1 , compressed_size , stream); + unsigned long bytes_written = fwrite(zbuffer , 1 , compressed_size , stream); if (bytes_written < compressed_size) util_abort("%s: wrote only %d/%ld bytes to compressed file - aborting \n",__func__ , bytes_written , compressed_size); } @@ -171,7 +171,7 @@ void util_fread_compressed(void *__data , FILE * stream) { int uncompress_result; fread(&compressed_size , sizeof compressed_size , 1 , stream); { - int bytes_read = fread(zbuffer , 1 , compressed_size , stream); + unsigned long bytes_read = fread(zbuffer , 1 , compressed_size , stream); if (bytes_read < compressed_size) util_abort("%s: read only %d/%d bytes from compressed file - aborting \n",__func__ , bytes_read , compressed_size); diff --git a/ThirdParty/Ert/lib/util/vector.c b/ThirdParty/Ert/lib/util/vector.cpp similarity index 99% rename from ThirdParty/Ert/lib/util/vector.c rename to ThirdParty/Ert/lib/util/vector.cpp index 30ce655bb7..64b0043038 100644 --- a/ThirdParty/Ert/lib/util/vector.c +++ b/ThirdParty/Ert/lib/util/vector.cpp @@ -19,10 +19,10 @@ #include #include -#include -#include -#include -#include +#include +#include +#include +#include #define VECTOR_TYPE_ID 551087 @@ -542,7 +542,7 @@ static int vector_cmp(const void * s1 , const void * s2) { int (* user_cmp) (const void *, const void *) i.e. the same as for qsort. The vector implementation considers - (fully) untyped data, it is therefor the users responsability to + (fully) untyped data, it is therefore the users responsability to ensure that the comparison makes sense. For example: diff --git a/ThirdParty/Ert/lib/util/vector_template.c b/ThirdParty/Ert/lib/util/vector_template.cpp similarity index 96% rename from ThirdParty/Ert/lib/util/vector_template.c rename to ThirdParty/Ert/lib/util/vector_template.cpp index 302bd2193e..80958d44e9 100644 --- a/ThirdParty/Ert/lib/util/vector_template.c +++ b/ThirdParty/Ert/lib/util/vector_template.cpp @@ -95,11 +95,12 @@ #include #include +#include +#include -#include -#include -#include -#include +#include +#include +#include #ifdef __cplusplus extern "C" { @@ -895,6 +896,26 @@ void @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ value1 , @TYP } + +bool @TYPE@_vector_init_linear(@TYPE@_vector_type * vector , @TYPE@ start_value, @TYPE@ end_value, int num_values) { + if (num_values < 2) + return false; + + @TYPE@_vector_reset( vector ); + @TYPE@_vector_iset( vector, 0 , start_value); + { + double slope = (end_value - start_value) / (num_values - 1); + + for (int i=1; i < num_values - 1; i++) { + @TYPE@ value = (@TYPE@) start_value + slope*i; + @TYPE@_vector_iset(vector, i, value); + } + } + @TYPE@_vector_iset( vector, num_values - 1, end_value); + return true; +} + + void @TYPE@_vector_append_many(@TYPE@_vector_type * vector , const @TYPE@ * data , int length) { @TYPE@_vector_set_many( vector , @TYPE@_vector_size( vector ) , data , length); } @@ -1450,31 +1471,6 @@ void @TYPE@_vector_fread( @TYPE@_vector_type * vector , FILE * stream ) { -void @TYPE@_vector_buffer_fwrite(const @TYPE@_vector_type * vector , buffer_type * buffer) { - buffer_fwrite_int( buffer , vector->size ); - buffer_fwrite( buffer , &vector->default_value , sizeof vector->default_value , 1 ); - buffer_fwrite( buffer , vector->data , sizeof * vector->data , vector->size ); -} - - -void @TYPE@_vector_buffer_fread(@TYPE@_vector_type * vector , buffer_type * buffer) { - @TYPE@ default_value; - int size = buffer_fread_int( buffer ); - buffer_fread( buffer , &default_value , sizeof default_value , 1 ); - - @TYPE@_vector_set_default( vector , default_value ); - @TYPE@_vector_realloc_data__( vector , size ); - buffer_fread( buffer , vector->data , sizeof * vector->data , size ); - vector->size = size; -} - - -@TYPE@_vector_type * @TYPE@_vector_buffer_fread_alloc( buffer_type * buffer ) { - @TYPE@_vector_type * vector = @TYPE@_vector_alloc( 0 , 0); - @TYPE@_vector_buffer_fread( vector , buffer ); - return vector; -} - /*****************************************************************/ @@ -1489,6 +1485,51 @@ bool @TYPE@_vector_equal(const @TYPE@_vector_type * vector1 , const @TYPE@_vecto } +int @TYPE@_vector_first_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset) { + if (offset >= vector1->size) + return -2; + + if (offset >= vector2->size) + return -2; + + int index = offset; + while (vector1->data[index] != vector2->data[index]) { + index++; + + if (index == vector1->size) + return -1; + + if (index == vector2->size) + return -1; + } + + return index; +} + + + +int @TYPE@_vector_first_not_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset) { + if (offset >= vector1->size) + return -2; + + if (offset >= vector2->size) + return -2; + + int index = offset; + while (vector1->data[index] == vector2->data[index]) { + index++; + + if (index == vector1->size) + return -1; + + if (index == vector2->size) + return -1; + } + + return index; +} + + void @TYPE@_vector_apply(@TYPE@_vector_type * vector , @TYPE@_ftype * func) { @TYPE@_vector_assert_writable( vector ); diff --git a/ThirdParty/Ert/lib/vector_template.h.in b/ThirdParty/Ert/lib/vector_template.h.in index e8aee46f8c..c11dc38d34 100644 --- a/ThirdParty/Ert/lib/vector_template.h.in +++ b/ThirdParty/Ert/lib/vector_template.h.in @@ -1,37 +1,36 @@ /* - Copyright (C) 2011 Statoil ASA, Norway. - - The file 'vector_template.h' is part of ERT - Ensemble based Reservoir Tool. - - ERT 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. - - ERT 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 - for more details. + Copyright (C) 2011 Statoil ASA, Norway. + + The file 'vector_template.h' is part of ERT - Ensemble based Reservoir Tool. + + ERT 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. + + ERT 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 + for more details. */ #ifndef ERT_@TYPE@_VECTOR_H #define ERT_@TYPE@_VECTOR_H -#ifdef __cplusplus +#ifdef __cplusplus extern "C" { #endif #include #include -#include #include #include typedef struct @TYPE@_vector_struct @TYPE@_vector_type; typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); - + int @TYPE@_vector_lookup_bin( const @TYPE@_vector_type * limits , @TYPE@ value , int guess); int @TYPE@_vector_lookup_bin__( const @TYPE@_vector_type * limits , @TYPE@ value , int guess); void @TYPE@_vector_inplace_div( @TYPE@_vector_type * vector , const @TYPE@_vector_type * inv_factor); @@ -71,10 +70,10 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); void @TYPE@_vector_insert( @TYPE@_vector_type * vector , int index , @TYPE@ value); void @TYPE@_vector_append(@TYPE@_vector_type * , @TYPE@); void @TYPE@_vector_free_container(@TYPE@_vector_type * vector); - void @TYPE@_vector_free(@TYPE@_vector_type *); - void @TYPE@_vector_free__(void *); - void @TYPE@_vector_free_data(@TYPE@_vector_type *); - void @TYPE@_vector_reset(@TYPE@_vector_type *); + void @TYPE@_vector_free(@TYPE@_vector_type *); + void @TYPE@_vector_free__(void *); + void @TYPE@_vector_free_data(@TYPE@_vector_type *); + void @TYPE@_vector_reset(@TYPE@_vector_type *); void @TYPE@_vector_reset__(void * __vector); int @TYPE@_vector_size(const @TYPE@_vector_type * ); void @TYPE@_vector_lshift(@TYPE@_vector_type * vector , int shift); @@ -85,6 +84,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); @TYPE@ * @TYPE@_vector_get_ptr(const @TYPE@_vector_type * ); @TYPE@ * @TYPE@_vector_alloc_data_copy( const @TYPE@_vector_type * vector ); const @TYPE@ * @TYPE@_vector_get_const_ptr(const @TYPE@_vector_type * ); + bool @TYPE@_vector_init_linear(@TYPE@_vector_type * vector , @TYPE@ start_value, @TYPE@ end_value, int num_values); void @TYPE@_vector_init_range(@TYPE@_vector_type * vector , @TYPE@ value1 , @TYPE@ value2 , @TYPE@ delta); void @TYPE@_vector_set_many(@TYPE@_vector_type * , int , const @TYPE@ * , int ); void @TYPE@_vector_set_all(@TYPE@_vector_type * vector , @TYPE@ value); @@ -108,14 +108,13 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); perm_vector_type * @TYPE@_vector_alloc_rsort_perm(const @TYPE@_vector_type * vector); void @TYPE@_vector_fprintf(const @TYPE@_vector_type * vector , FILE * stream , const char * name , const char * fmt); void @TYPE@_vector_fwrite(const @TYPE@_vector_type * vector , FILE * stream); - void @TYPE@_vector_buffer_fread(@TYPE@_vector_type * vector , buffer_type * buffer); @TYPE@_vector_type * @TYPE@_vector_fread_alloc( FILE * stream ); - @TYPE@_vector_type * @TYPE@_vector_buffer_fread_alloc( buffer_type * buffer ); - void @TYPE@_vector_buffer_fwrite(const @TYPE@_vector_type * vector , buffer_type * buffer); void @TYPE@_vector_fread( @TYPE@_vector_type * vector , FILE * stream ); void @TYPE@_vector_fwrite_data( const @TYPE@_vector_type * vector , FILE * stream ); void @TYPE@_vector_fread_data( @TYPE@_vector_type * vector , int size, FILE * stream); bool @TYPE@_vector_equal(const @TYPE@_vector_type * vector1 , const @TYPE@_vector_type * vector2); + int @TYPE@_vector_first_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset); + int @TYPE@_vector_first_not_equal(const @TYPE@_vector_type * vector1, const @TYPE@_vector_type * vector2, int offset); void @TYPE@_vector_apply(@TYPE@_vector_type * vector , @TYPE@_ftype *func); int @TYPE@_vector_count_equal( const @TYPE@_vector_type * vector , @TYPE@ cmp_value); int @TYPE@_vector_element_size( const @TYPE@_vector_type * vector ); @@ -125,7 +124,7 @@ typedef @TYPE@ (@TYPE@_ftype) (@TYPE@); UTIL_SAFE_CAST_HEADER( @TYPE@_vector ); UTIL_IS_INSTANCE_HEADER( @TYPE@_vector ); -#ifdef __cplusplus +#ifdef __cplusplus } #endif #endif diff --git a/ThirdParty/Ert/lib/util/thread_pool.c b/ThirdParty/Ert/lib/vector_template.hpp.in similarity index 71% rename from ThirdParty/Ert/lib/util/thread_pool.c rename to ThirdParty/Ert/lib/vector_template.hpp.in index e23026b4ea..f4574fdda5 100644 --- a/ThirdParty/Ert/lib/util/thread_pool.c +++ b/ThirdParty/Ert/lib/vector_template.hpp.in @@ -1,7 +1,7 @@ /* Copyright (C) 2011 Statoil ASA, Norway. - The file 'thread_pool.c' is part of ERT - Ensemble based Reservoir Tool. + The file 'vector_template.hpp' is part of ERT - Ensemble based Reservoir Tool. ERT is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -16,12 +16,9 @@ for more details. */ -#include "ert/util/build_config.h" -#include +#ifndef ERT_@TYPE@_VECTOR_CXX +#define ERT_@TYPE@_VECTOR_CXX -#ifdef HAVE_PTHREAD -#include "thread_pool_posix.c" -#else -Error - should not be be here. -#endif +#include +#endif diff --git a/ThirdParty/Ert/python/CMakeLists.txt b/ThirdParty/Ert/python/CMakeLists.txt index 031fbc96f5..4ed4cd838e 100644 --- a/ThirdParty/Ert/python/CMakeLists.txt +++ b/ThirdParty/Ert/python/CMakeLists.txt @@ -4,17 +4,36 @@ set( CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/M include(init_python) init_python( 2.7 ) +find_python_package(pandas 0.17 ${PYTHON_INSTALL_PREFIX}) +if (NOT DEFINED PY_pandas) + message(WARNING "Pandas module not found Python wrappers not enabled. Install with: \"pip install pandas\"") + set( ENABLE_PYTHON OFF PARENT_SCOPE ) + return() +endif() find_python_package(numpy 1.7.1 ${PYTHON_INSTALL_PREFIX}) if (NOT DEFINED PY_numpy) - message(WARNING "numpy module not found - Python wrappers not enabled") - set( BUILD_PYTHON OFF PARENT_SCOPE ) + message(WARNING "numpy module not found - Python wrappers not enabled. Install with: \"pip install numpy\"") + set( ENABLE_PYTHON OFF PARENT_SCOPE ) + return() +endif() + +find_python_package(cwrap 1 ${PYTHON_INSTALL_PREFIX}) +if (NOT DEFINED PY_cwrap) + message(WARNING "cwrap module not found Python wrappers not enabled. Install with: \"pip install cwrap\"") + set( ENABLE_PYTHON OFF PARENT_SCOPE ) return() endif() +configure_file(test_env.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/test_env.py ) + +add_subdirectory( ecl ) + +if (INSTALL_ERT_LEGACY) + add_subdirectory( ert ) +endif() if (BUILD_TESTS) add_subdirectory( tests ) endif() -add_subdirectory( python ) diff --git a/ThirdParty/Ert/python/cmake/Modules/init_python.cmake b/ThirdParty/Ert/python/cmake/Modules/init_python.cmake index 74cef5cf30..ae1f201e31 100644 --- a/ThirdParty/Ert/python/cmake/Modules/init_python.cmake +++ b/ThirdParty/Ert/python/cmake/Modules/init_python.cmake @@ -134,7 +134,7 @@ def update_path(): if __name__ == '__main__': update_path( ) - from ecl.test import ErtTestRunner + from ecl.util.test import ErtTestRunner for test_class in sys.argv[1:]: tests = ErtTestRunner.getTestsFromTestClass(test_class) diff --git a/ThirdParty/Ert/python/doc/devel.txt b/ThirdParty/Ert/python/doc/devel.txt index 299ded6513..7bae061d39 100644 --- a/ThirdParty/Ert/python/doc/devel.txt +++ b/ThirdParty/Ert/python/doc/devel.txt @@ -165,16 +165,16 @@ like: typedef struct { ..... ..... - } abs_type; + } abs_type; and "methods" like: abs_type * abs_type_alloc( ) { } - void abs_type_free( abs_type * at ) {} - int abs_type_get_an_int( const abs_type * at) {} + void abs_type_free( abs_type * at ) {} + int abs_type_get_an_int( const abs_type * at) {} void abs_type_set_an_int( abs_type * at , int value) {} -it has therefor been relatively easy to map this onto Python classes +it has therefore been relatively easy to map this onto Python classes and give a pythonic feel to the whole thing. As a ground rule each C file implements one struct; this struct is wrapped in a Python module with the same name and a Python class with CamelCaps naming: diff --git a/ThirdParty/Ert/python/python/ecl/CMakeLists.txt b/ThirdParty/Ert/python/ecl/CMakeLists.txt similarity index 77% rename from ThirdParty/Ert/python/python/ecl/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/CMakeLists.txt index 3ba6f862bc..3a9139aaf2 100644 --- a/ThirdParty/Ert/python/python/ecl/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/CMakeLists.txt @@ -1,11 +1,15 @@ set(PYTHON_SOURCES __init__.py + ecl_type.py + ecl_util.py ) add_python_package("python.ecl" ${PYTHON_INSTALL_PREFIX}/ecl "${PYTHON_SOURCES}" True) -add_subdirectory(ecl) -add_subdirectory(geo) -add_subdirectory(test) +add_subdirectory(eclfile) +add_subdirectory(grid) +add_subdirectory(rft) +add_subdirectory(gravimetry) +add_subdirectory(summary) add_subdirectory(util) add_subdirectory(well) diff --git a/ThirdParty/Ert/python/python/ecl/__init__.py b/ThirdParty/Ert/python/ecl/__init__.py similarity index 77% rename from ThirdParty/Ert/python/python/ecl/__init__.py rename to ThirdParty/Ert/python/ecl/__init__.py index 3163485b17..9988076250 100644 --- a/ThirdParty/Ert/python/python/ecl/__init__.py +++ b/ThirdParty/Ert/python/ecl/__init__.py @@ -1,18 +1,18 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. """ ert - Ensemble Reservoir Tool - a package for reservoir modeling. @@ -28,14 +28,14 @@ shared libraries with the ctypes.CDLL() function. The ctypes.CDLL() function uses the standard methods of the operating system, i.e. standard locations configured with ld.so.conf and the environment -variable LD_LIBRARY_PATH. +variable LD_LIBRARY_PATH. To avoid conflict with other application using the ert libraries the Python code should be able to locate the shared libraries without (necessarily) using the LD_LIBRARY_PATH variable. The default behaviour is to try to load from the library ../../lib64, but by using the enviornment variable ERT_LIBRARY_PATH you can alter how ert looks -for shared libraries. +for shared libraries. 1. By default the code will try to load the shared libraries from '../../lib64' relative to the location of this file. @@ -60,6 +60,7 @@ warnings.simplefilter('always', DeprecationWarning) # see #1437 from cwrap import load as cwrapload +from cwrap import Prototype try: import ert_site_init @@ -79,10 +80,10 @@ # module should contain the variable lib_path pointing to the # directory with shared object files. try: - import __ecl_lib_info - ecl_lib_path = __ecl_lib_info.lib_path - ert_so_version = __ecl_lib_info.so_version - __version__ = __ecl_lib_info.__version__ + from .__ecl_lib_info import EclLibInfo + ecl_lib_path = EclLibInfo.lib_path + ert_so_version = EclLibInfo.so_version + __version__ = EclLibInfo.__version__ except ImportError: pass except AttributeError: @@ -99,27 +100,35 @@ ert_lib_path = os.getenv("ERT_LIBRARY_PATH") else: sys.stderr.write("Warning: Environment variable ERT_LIBRARY_PATH points to nonexisting directory:%s - ignored" % env_lib_path) - + # Check that the final ert_lib_path setting corresponds to an existing # directory. if ecl_lib_path: + if not os.path.isabs(ecl_lib_path): + ecl_lib_path = os.path.abspath(os.path.join(os.path.dirname(__file__), ecl_lib_path)) + if not os.path.isdir( ecl_lib_path ): ecl_lib_path = None - + if sys.hexversion < required_version_hex: raise Exception("ERT Python requires Python 2.7.") -# This load() function is *the* function actually loading shared -# libraries. - def load(name): return cwrapload(name, path=ecl_lib_path, so_version=ert_so_version) +class EclPrototype(Prototype): + lib = load("libecl") -from .util import EclVersion -from .util import updateAbortSignals + def __init__(self, prototype, bind=True): + super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind) + +from .ecl_type import EclTypeEnum, EclDataType +from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil + +from .util.util import EclVersion +from .util.util import updateAbortSignals updateAbortSignals( ) @@ -128,3 +137,4 @@ def root(): Will print the filesystem root of the current ert package. """ return os.path.abspath( os.path.join( os.path.dirname( __file__ ) , "../")) + diff --git a/ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in b/ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in new file mode 100644 index 0000000000..7f80c68807 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/ecl_lib_info_build.py.in @@ -0,0 +1,9 @@ + + +class EclLibInfo(object): + lib_path = "${LIBRARY_OUTPUT_PATH}" + so_version = "${ECL_BINARY_POSTFIX}" + __version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + + def __init__(self): + pass diff --git a/ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in b/ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in new file mode 100644 index 0000000000..12c6c69375 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/ecl_lib_info_install.py.in @@ -0,0 +1,9 @@ + + +class EclLibInfo(object): + lib_path = "../../../../${CMAKE_INSTALL_LIBDIR}" + so_version = "${ECL_BINARY_POSTFIX}" + __version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" + + def __init__(self): + pass diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py b/ThirdParty/Ert/python/ecl/ecl_type.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py rename to ThirdParty/Ert/python/ecl/ecl_type.py index 1ac3cc6556..477aeddb50 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_type.py +++ b/ThirdParty/Ert/python/ecl/ecl_type.py @@ -15,7 +15,7 @@ # for more details. from cwrap import BaseCClass, BaseCEnum -from ecl.ecl import EclPrototype +from ecl import EclPrototype class EclTypeEnum(BaseCEnum): TYPE_NAME="ecl_type_enum" @@ -46,7 +46,7 @@ class EclDataType(BaseCClass): _alloc_from_name = EclPrototype("void* ecl_type_alloc_from_name_python(char*)", bind=False) _free = EclPrototype("void ecl_type_free_python(ecl_data_type)") _get_type = EclPrototype("ecl_type_enum ecl_type_get_type_python(ecl_data_type)") - _get_element_size = EclPrototype("size_t ecl_type_get_sizeof_ctype_fortio_python(ecl_data_type)") + _get_element_size = EclPrototype("size_t ecl_type_get_sizeof_iotype_python(ecl_data_type)") _is_int = EclPrototype("bool ecl_type_is_int_python(ecl_data_type)") _is_char = EclPrototype("bool ecl_type_is_char_python(ecl_data_type)") _is_float = EclPrototype("bool ecl_type_is_float_python(ecl_data_type)") diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py b/ThirdParty/Ert/python/ecl/ecl_util.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py rename to ThirdParty/Ert/python/ecl/ecl_util.py index b7f4f19b05..2742c498fa 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_util.py +++ b/ThirdParty/Ert/python/ecl/ecl_util.py @@ -28,8 +28,8 @@ import ctypes from cwrap import BaseCEnum -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype, ECL_LIB +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype class EclFileEnum(BaseCEnum): TYPE_NAME = "ecl_file_enum" diff --git a/ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt b/ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt new file mode 100644 index 0000000000..d438f38314 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/CMakeLists.txt @@ -0,0 +1,14 @@ +set(PYTHON_SOURCES + __init__.py + ecl_3d_file.py + ecl_file.py + ecl_file_view.py + ecl_init_file.py + ecl_restart_file.py + ecl_kw.py + fortio.py + ecl_3dkw.py + +) + +add_python_package("python.ecl.eclfile" ${PYTHON_INSTALL_PREFIX}/ecl/eclfile "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/eclfile/__init__.py b/ThirdParty/Ert/python/ecl/eclfile/__init__.py new file mode 100644 index 0000000000..c98633910f --- /dev/null +++ b/ThirdParty/Ert/python/ecl/eclfile/__init__.py @@ -0,0 +1,45 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +""" +The eclfile package contains several classes for working directly with ECLIPSE +files. + + fortio/FortIO: This is functionality to read and write binary + fortran files. + + ecl_kw/EclKW: This class holds one ECLIPSE keyword, like SWAT, in + restart format. + + ecl_type/EclDataType: This class is used to represent the data type + of the elements in EclKW. + + ecl_file/EclFile: This class is used to load an ECLIPSE file in + restart format, alternatively only parts of the file can be + loaded. Internally it consists of a collection of EclKW + instances. +""" + +import ecl.util.util + +from .fortio import FortIO, openFortIO +from .ecl_kw import EclKW +from .ecl_file_view import EclFileView +from .ecl_file import EclFile , openEclFile +from .ecl_3dkw import Ecl3DKW +from .ecl_3d_file import Ecl3DFile +from .ecl_init_file import EclInitFile +from .ecl_restart_file import EclRestartFile diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py similarity index 96% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py index 7625a2de7c..0d462a7636 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3d_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_3d_file.py @@ -14,7 +14,7 @@ # See the GNU General Public License at # for more details. -from ecl.ecl import EclFile, Ecl3DKW +from ecl.eclfile import EclFile, Ecl3DKW class Ecl3DFile(EclFile): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py similarity index 99% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py index 0f6a91994a..f19d01f171 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_3dkw.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_3dkw.py @@ -17,7 +17,7 @@ from __future__ import (absolute_import, division, print_function, unicode_literals) -from ecl.util import monkey_the_camel +from ecl.util.util import monkey_the_camel from .ecl_kw import EclKW class Ecl3DKW(EclKW): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py similarity index 99% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_file.py index c8fd6c7280..75ac344456 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_file.py @@ -41,9 +41,12 @@ import ctypes from cwrap import BaseCClass -from ecl.util import CTime -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype, EclKW, EclFileEnum, EclFileView + +from ecl import EclPrototype +from ecl.util.util import CTime +from ecl.util.util import monkey_the_camel +from ecl import EclFileEnum +from ecl.eclfile import EclKW, EclFileView class EclFile(BaseCClass): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py index 1c90a235a7..16b09643c6 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_file_view.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_file_view.py @@ -17,9 +17,9 @@ from __future__ import absolute_import, division, print_function, unicode_literals from six import string_types from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl import EclPrototype class EclFileView(BaseCClass): TYPE_NAME = "ecl_file_view" diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_init_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py similarity index 94% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_init_file.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py index 85c65be5d1..51ae032143 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_init_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_init_file.py @@ -14,7 +14,8 @@ # See the GNU General Public License at # for more details. -from ecl.ecl import EclFileEnum, EclFile, Ecl3DFile +from ecl import EclFileEnum +from ecl.eclfile import EclFile, Ecl3DFile class EclInitFile(Ecl3DFile): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py similarity index 94% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py index 6618abdd90..9f43dda574 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_kw.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_kw.py @@ -45,9 +45,13 @@ import numpy from cwrap import CFILE, BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclDataType -from ecl.ecl import EclTypeEnum, EclUtil, EclPrototype + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclDataType +from ecl import EclTypeEnum, EclUtil + +from .fortio import FortIO def dump_type_deprecation_warning(): warnings.warn("EclTypeEnum is deprecated. " + @@ -102,6 +106,7 @@ class EclKW(BaseCClass): _sub_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_sub_copy(ecl_kw, char*, int, int)") _copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_copy(ecl_kw)") _slice_copyc = EclPrototype("ecl_kw_obj ecl_kw_alloc_slice_copy(ecl_kw, int, int, int)") + _global_copy = EclPrototype("ecl_kw_obj ecl_kw_alloc_global_copy(ecl_kw, ecl_kw)") _fprintf_grdecl = EclPrototype("void ecl_kw_fprintf_grdecl(ecl_kw, FILE)") _fprintf_data = EclPrototype("void ecl_kw_fprintf_data(ecl_kw, char*, FILE)") @@ -128,6 +133,8 @@ class EclKW(BaseCClass): _int_sum = EclPrototype("int ecl_kw_element_sum_int(ecl_kw)") _float_sum = EclPrototype("double ecl_kw_element_sum_float(ecl_kw)") + _iadd_squared = EclPrototype("void ecl_kw_inplace_add_squared(ecl_kw, ecl_kw)") + _isqrt = EclPrototype("void ecl_kw_inplace_sqrt(ecl_kw)") _iadd = EclPrototype("void ecl_kw_inplace_add(ecl_kw, ecl_kw)") _imul = EclPrototype("void ecl_kw_inplace_mul(ecl_kw, ecl_kw)") _idiv = EclPrototype("void ecl_kw_inplace_div(ecl_kw, ecl_kw)") @@ -149,8 +156,11 @@ class EclKW(BaseCClass): _max_min_float = EclPrototype("void ecl_kw_max_min_float(ecl_kw, float*, float*)") _max_min_double = EclPrototype("void ecl_kw_max_min_double(ecl_kw, double*, double*)") _fix_uninitialized = EclPrototype("void ecl_kw_fix_uninitialized(ecl_kw,int, int, int, int*)") + _create_actnum = EclPrototype("ecl_kw_obj ecl_kw_alloc_actnum(ecl_kw, float)") _first_different = EclPrototype("int ecl_kw_first_different(ecl_kw, ecl_kw, int, double, double)") _resize = EclPrototype("void ecl_kw_resize(ecl_kw, int)") + _safe_div = EclPrototype("bool ecl_kw_inplace_safe_div(ecl_kw,ecl_kw)") + @classmethod def createCReference(cls, c_ptr, parent=None): @@ -269,7 +279,7 @@ def read_grdecl(cls, fileH, kw, strict=True, ecl_type=None): Observe that since the grdecl files are quite weakly structured it is difficult to verify the integrity of the - files, malformed input might therefor pass unnoticed before + files, malformed input might therefore pass unnoticed before things blow up at a later stage. [1]: It is possible, but not recommended, to pass in None for @@ -643,6 +653,22 @@ def __div__(self, factor): # No __rdiv__() + def add_squared(self, other): + if not self.is_numeric(): + raise TypeError("Can only be called on numeric types") + + if not self.assert_binary(other): + raise ValueError("Invalid argument to method add_squared") + + self._iadd_squared(other) + + def isqrt(self): + if not self.is_numeric(): + raise TypeError("Can only be called on numeric types") + + self._isqrt() + + def sum(self, mask = None, force_active = False): """ Will calculate the sum of all the elements in the keyword. @@ -899,7 +925,7 @@ def resize(self, new_size): Will set the new size of the kw to @new_size. """ if new_size >= 0: - self._resize(new_size) + self._resize(int(new_size)) # Iteration is based on a pointer to the underlying storage, # that will generally by reset by the resize() call; i.e. we @@ -1117,6 +1143,25 @@ def fprintf_data(self, file, fmt=None): cfile = CFILE(file) self._fprintf_data(fmt, cfile) + def create_actnum(self, porv_limit = 0): + """Will create ACTNUM keyword from PORV keyword. + + This quite specialized method will create an ACTNUM keyword based on + interpreting the current keyword as a PORV keyword. The method will + raise an exception if the current keyword is not ("PORV", FLOAT). The + code implemented in C for speed is essentially: + + actnum = [ 1 if x > porv_limit else 0 for x in self ] + + """ + if not self.data_type.is_float(): + raise TypeError("The PORV keyword must be of type FLOAT") + + if not self.get_name() == "PORV": + raise ValueError("Input argument must be PORV keyword") + + return self._create_actnum(porv_limit) + def fix_uninitialized(self, grid): """ @@ -1156,6 +1201,33 @@ def first_different(self, other, offset=0, epsilon=0, abs_epsilon=None, rel_epsi return self._first_different(other, offset, abs_epsilon, rel_epsilon) + + + + def scatter_copy(self, actnum): + if not isinstance(actnum, EclKW): + raise TypeError("The actnum argument must be of type EclKW") + + return self._global_copy(actnum) + + + def safe_div(self, divisor): + if not len(self) == len(divisor): + raise ValueError("Length mismatch between %s and %s" % (self.name, divisor.name)) + + if not self.is_numeric(): + raise TypeError("The self keyword must be of numeric type") + + if not divisor.is_numeric(): + raise TypeError("Must divide by numeric keyword") + + ok = self._safe_div( divisor ) + if not ok: + raise NotImplementedError("safe_div not implemented for this type combination") + + + + monkey_the_camel(EclKW, 'intKeywords', EclKW.int_keywords, classmethod) monkey_the_camel(EclKW, 'isNumeric', EclKW.is_numeric) monkey_the_camel(EclKW, 'fortIOSize', EclKW.fort_io_size) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py b/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py similarity index 96% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py rename to ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py index 749f1cd912..bdd2e33e8f 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_restart_file.py +++ b/ThirdParty/Ert/python/ecl/eclfile/ecl_restart_file.py @@ -16,9 +16,11 @@ from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclPrototype , EclFile, Ecl3DKW , Ecl3DFile, EclFileEnum +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl import EclFileEnum +from ecl.eclfile import EclFile, Ecl3DFile, Ecl3DKW class EclRestartHead(BaseCClass): TYPE_NAME = "ecl_rsthead" diff --git a/ThirdParty/Ert/python/python/ecl/ecl/fortio.py b/ThirdParty/Ert/python/ecl/eclfile/fortio.py similarity index 99% rename from ThirdParty/Ert/python/python/ecl/ecl/fortio.py rename to ThirdParty/Ert/python/ecl/eclfile/fortio.py index 75d7b917fd..e454a9b8b0 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/fortio.py +++ b/ThirdParty/Ert/python/ecl/eclfile/fortio.py @@ -40,8 +40,8 @@ import os from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype class FortIO(BaseCClass): diff --git a/ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt b/ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt new file mode 100644 index 0000000000..f4b96370f9 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/CMakeLists.txt @@ -0,0 +1,9 @@ +set(PYTHON_SOURCES + __init__.py + ecl_grav.py + ecl_grav_calc.py + ecl_subsidence.py + +) + +add_python_package("python.ecl.gravimetry" ${PYTHON_INSTALL_PREFIX}/ecl/gravimetry "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/gravimetry/__init__.py b/ThirdParty/Ert/python/ecl/gravimetry/__init__.py new file mode 100644 index 0000000000..f218261dda --- /dev/null +++ b/ThirdParty/Ert/python/ecl/gravimetry/__init__.py @@ -0,0 +1,28 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +""" + ecl_grav/EclGrav: Class used to simplify evaluation of ECLIPSE + modelling time-lapse gravitational surveys. + + ecl_subsidence/EclSubsidence: Small class used to evaluate simulated + subsidence from ECLIPSE simulations; analogous to the EcLGrav + functionality. +""" + +from .ecl_subsidence import EclSubsidence +from .ecl_grav_calc import phase_deltag, deltag +from .ecl_grav import EclGrav diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py rename to ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py index caffe5d597..f8d75a3822 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav.py @@ -22,8 +22,11 @@ ecl_grav.c implementation in the libecl library. """ from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPhaseEnum, EclPrototype + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclPhaseEnum +import ecl.eclfile class EclGrav(BaseCClass): """ diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py rename to ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py index ef98811eb8..c00a1e714b 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grav_calc.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_grav_calc.py @@ -14,7 +14,7 @@ # See the GNU General Public License at # for more details. -from ecl.ecl import EclPrototype +from ecl import EclPrototype __arglist = 'double, double, double, ' __arglist += 'ecl_grid, ecl_file, ' diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py b/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py rename to ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py index 1299e4b781..890e4e5ccc 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_subsidence.py +++ b/ThirdParty/Ert/python/ecl/gravimetry/ecl_subsidence.py @@ -23,8 +23,9 @@ ecl_subsidence.c implementation in the libecl library. """ from cwrap import BaseCClass -from ecl.ecl import EclPrototype -from ecl.util import monkey_the_camel +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +import ecl.grid class EclSubsidence(BaseCClass): """ diff --git a/ThirdParty/Ert/python/ecl/grid/CMakeLists.txt b/ThirdParty/Ert/python/ecl/grid/CMakeLists.txt new file mode 100644 index 0000000000..46ed7c3347 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/CMakeLists.txt @@ -0,0 +1,11 @@ +set(PYTHON_SOURCES + __init__.py + cell.py + ecl_grid.py + ecl_region.py + ecl_grid_generator.py +) + +add_python_package("python.ecl.grid" ${PYTHON_INSTALL_PREFIX}/ecl/grid "${PYTHON_SOURCES}" True) + +add_subdirectory(faults) diff --git a/ThirdParty/Ert/python/ecl/grid/__init__.py b/ThirdParty/Ert/python/ecl/grid/__init__.py new file mode 100644 index 0000000000..69d110e0bf --- /dev/null +++ b/ThirdParty/Ert/python/ecl/grid/__init__.py @@ -0,0 +1,35 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +""" + ecl_grid/EclGrid: This will load an ECLIPSE GRID or EGRID file, and + can then subsequently be used for queries about the grid. + + ecl_region/EclRegion: Convenience class to support selecting cells + in a grid based on a wide range of criteria. Can be used as a + mask in operations on EclKW instances. + + ecl_grid_generator/EclGridGenerator: This can be used to generate various + grids. +""" + +import ecl.util.util +import ecl.util.geometry + +from .cell import Cell +from .ecl_grid import EclGrid +from .ecl_region import EclRegion +from .ecl_grid_generator import EclGridGenerator diff --git a/ThirdParty/Ert/python/python/ecl/ecl/cell.py b/ThirdParty/Ert/python/ecl/grid/cell.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/ecl/cell.py rename to ThirdParty/Ert/python/ecl/grid/cell.py diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py similarity index 99% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py rename to ThirdParty/Ert/python/ecl/grid/ecl_grid.py index a2db004a11..1a923140ac 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid.py @@ -31,10 +31,14 @@ import os.path import math import itertools -from cwrap import CFILE, BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import IntVector -from ecl.ecl import EclPrototype, EclDataType, EclKW, FortIO, EclUnitTypeEnum, Cell +from cwrap import CFILE, BaseCClass, load, open as copen + +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector +from ecl import EclDataType, EclUnitTypeEnum +from ecl.eclfile import EclKW, FortIO +from ecl.grid import Cell class EclGrid(BaseCClass): @@ -136,7 +140,7 @@ def load_from_grdecl(cls, filename): """ if os.path.isfile(filename): - with open(filename) as f: + with copen(filename) as f: specgrid = EclKW.read_grdecl(f, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) zcorn = EclKW.read_grdecl(f, "ZCORN") coord = EclKW.read_grdecl(f, "COORD") @@ -826,12 +830,6 @@ def find_cell_xy(self, x, y, k): else: raise IndexError("Invalid layer value:%d" % k) - - @staticmethod - def d_cmp(a,b): - return cmp(a[0], b[0]) - - def find_cell_corner_xy(self, x, y, k): """Will find the corner nr of corner closest to utm coordinates x,y. @@ -864,7 +862,7 @@ def find_cell_corner_xy(self, x, y, k): c3 = i + 1 + (j + 1)*(nx + 1) l = [(d0, c0), (d1,c1), (d2, c2), (d3,c3)] - l.sort(EclGrid.d_cmp) + l.sort(key=lambda k: k[0]) return l[0][1] diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py b/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py rename to ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py index 6837439f39..7bdf798bd3 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_grid_generator.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_grid_generator.py @@ -17,9 +17,12 @@ import itertools, numpy from math import sqrt -from ecl.util import monkey_the_camel -from ecl.util import IntVector -from ecl.ecl import EclGrid, EclKW, EclDataType, EclPrototype +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid def flatten(l): return [elem for sublist in l for elem in sublist] @@ -341,12 +344,11 @@ def assert_zcorn(cls, nx, ny, nz, zcorn, twisted_check=True): @classmethod def __scale_coord(cls, coord, scale, lower_center): coord = numpy.array([ - map(float, coord[i:i+6:]) + list(map(float, coord[i:i+6:])) for i in range(0, len(coord), 6) ]) origo = numpy.array(3*[0.] + list(lower_center) + [0]) scale = numpy.array(3*[1.] + 2*[scale] + [1]) - coord = scale * (coord-origo) + origo return coord.flatten().tolist() @@ -355,7 +357,7 @@ def __misalign_coord(cls, coord, dims, dV): nx, ny, nz = dims coord = numpy.array([ - map(float, coord[i:i+6:]) + list(map(float, coord[i:i+6:])) for i in range(0, len(coord), 6) ]) @@ -378,7 +380,7 @@ def __misalign_coord(cls, coord, dims, dV): @classmethod def __rotate_coord(cls, coord, lower_center): coord = numpy.array([ - map(float, coord[i:i+6:]) + list(map(float, coord[i:i+6:])) for i in range(0, len(coord), 6) ]) @@ -394,7 +396,7 @@ def __rotate_coord(cls, coord, lower_center): @classmethod def __translate_lower_coord(cls, coord, translation): coord = numpy.array([ - map(float, coord[i:i+6:]) + list(map(float, coord[i:i+6:])) for i in range(0, len(coord), 6) ]) translation = numpy.array(3*[0.] + list(translation)) @@ -531,7 +533,7 @@ def extract_actnum(cls, dims, actnum, ijk_bounds): @classmethod def __translate_coord(cls, coord, translation): coord = numpy.array([ - map(float, coord[i:i+6:]) + list(map(float, coord[i:i+6:])) for i in range(0, len(coord), 6) ]) translation = numpy.array(list(translation) + list(translation)) @@ -697,7 +699,7 @@ def assert_ijk_bounds(cls, dims, ijk_bounds): @classmethod def assert_decomposition_change(cls, ijk_bounds, decomposition_change): - if sum(zip(*ijk_bounds)[0])%2 == 1 and not decomposition_change: + if sum(list(zip(*ijk_bounds))[0]) % 2 == 1 and not decomposition_change: raise ValueError( "The subgrid defined by %s " % str(ijk_bounds) + "will cause an unintended decomposition change. " + diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py b/ThirdParty/Ert/python/ecl/grid/ecl_region.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py rename to ThirdParty/Ert/python/ecl/grid/ecl_region.py index 30cf71e9e4..295f0e59f9 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_region.py +++ b/ThirdParty/Ert/python/ecl/grid/ecl_region.py @@ -29,12 +29,15 @@ from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import IntVector +import ecl +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector -from ecl.ecl.faults import Layer -from ecl.ecl import EclKW, EclDataType, EclPrototype -from ecl.geo import CPolyline +from ecl import EclPrototype +from ecl.grid.faults import Layer +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.util.geometry import CPolyline def select_method(select): @@ -64,7 +67,7 @@ def select_method(select): """ def select_wrapper(self , *args , **kwargs): - intersect = kwargs.has_key('intersect') and kwargs['intersect'] + intersect = 'intersect' in kwargs and kwargs['intersect'] if intersect: new_region = EclRegion( self.grid , False ) select(new_region , *args ) @@ -205,11 +208,12 @@ def __deep_copy__(self , memo): """ return self._alloc_copy( ) - def __nonzero__(self): global_list = self.get_global_list() return len(global_list) > 0 - + + def __bool__(self): + return self.__nonzero__() def __iand__(self , other): """ @@ -855,7 +859,7 @@ def scalar_apply_kw( self , target_kw , scalar , func_dict , force_active = Fals Helper function to apply a function with one scalar arg on target_kw. """ data_type = target_kw.data_type - if func_dict.has_key( data_type ): + if data_type in func_dict: func = func_dict[ data_type ] func( target_kw, scalar , force_active ) else: @@ -924,7 +928,11 @@ def idiv_kw( self , target_kw , other , force_active = False): else: raise TypeError("Type mismatch") else: - self.scale_kw( target_kw , 1/other , force_active ) + if target_kw.data_type.is_int(): + scale = 1 // other + else: + scale = 1.0 / other + self.scale_kw( target_kw , scale , force_active ) def copy_kw( self , target_kw , src_kw , force_active = False): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt b/ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt similarity index 60% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt index d7955a8c6e..2e23b67b90 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/grid/faults/CMakeLists.txt @@ -9,4 +9,4 @@ set(PYTHON_SOURCES layer.py ) -add_python_package("python.ecl.ecl.faults" ${PYTHON_INSTALL_PREFIX}/ecl/ecl/faults "${PYTHON_SOURCES}" True) +add_python_package("python.ecl.grid.faults" ${PYTHON_INSTALL_PREFIX}/ecl/grid/faults "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py b/ThirdParty/Ert/python/ecl/grid/faults/__init__.py similarity index 99% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py rename to ThirdParty/Ert/python/ecl/grid/faults/__init__.py index cc9670e15c..996cbd86c5 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/__init__.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/__init__.py @@ -1,3 +1,5 @@ + + from .layer import Layer from .fault_collection import FaultCollection from .fault import Fault diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py b/ThirdParty/Ert/python/ecl/grid/faults/fault.py similarity index 97% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault.py index ae62f8b582..ac5ef42acb 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault.py @@ -14,10 +14,10 @@ # See the GNU General Public License at # for more details. -from ecl.util import monkey_the_camel -from ecl.util import stat -from ecl.util import Matrix -from ecl.geo import Polyline, CPolyline, GeometryTools +import numpy as np + +from ecl.util.util import monkey_the_camel +from ecl.util.geometry import Polyline, CPolyline, GeometryTools from .fault_line import FaultLine from .fault_segments import FaultSegment, SegmentMap @@ -99,20 +99,22 @@ def __sort_fault_lines(self): """ N = len(self.__fault_lines) - x = Matrix(N, 1) - y = Matrix(N, 1) - + x = np.zeros(N) + y = np.zeros(N) for index,line in enumerate(self.__fault_lines): xc,yc = line.center() + x[index] = xc + y[index] = yc + + + - x[index,0] = xc - y[index,0] = yc - # y = beta[0] + beta[1] * x + # y = beta[1] + beta[0] * x # = a + b * x - beta = stat.polyfit(2, x, y) - a = beta[0] - b = beta[1] + beta = np.polyfit(x, y, 1) + a = beta[1] + b = beta[0] perm_list = [] for index,line in enumerate(self.__fault_lines): @@ -197,7 +199,7 @@ def __iter__(self): def has_layer(self, K): - return self.__layer_map.has_key(K) + return K in self.__layer_map def add_layer(self, K): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py similarity index 97% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault_block.py index c4d03db926..e5313170a7 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block.py @@ -17,10 +17,10 @@ import ctypes from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import DoubleVector, IntVector -from ecl.ecl import EclPrototype -from ecl.geo import Polyline, GeometryTools, CPolylineCollection +from ecl.util.util import monkey_the_camel +from ecl.util.util import DoubleVector, IntVector +from ecl import EclPrototype +from ecl.util.geometry import Polyline, GeometryTools, CPolylineCollection class FaultBlockCell(object): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py similarity index 95% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py index 88333268fe..16166c3ea6 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_collection.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_collection.py @@ -17,8 +17,8 @@ from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype class FaultBlockCollection(BaseCClass): @@ -37,7 +37,7 @@ def __init__(self, grid): raise ValueError("Invalid input - failed to create FaultBlockCollection") # The underlying C implementation uses lazy evaluation and - # needs to hold on to the grid reference. We therefor take + # needs to hold on to the grid reference. We therefore take # references to it here, to protect against premature garbage # collection. self.grid_ref = grid diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py similarity index 97% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py index 7bffe6a608..cc84d65981 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_block_layer.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_block_layer.py @@ -17,9 +17,10 @@ from __future__ import print_function from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclDataType, EclPrototype -from ecl.ecl.faults import Fault +from ecl.util.util import monkey_the_camel +from ecl import EclDataType +from ecl import EclPrototype +from ecl.grid.faults import Fault class FaultBlockLayer(BaseCClass): TYPE_NAME = "fault_block_layer" @@ -49,7 +50,7 @@ def __init__(self, grid, k): raise ValueError("Invalid input - failed to create FaultBlockLayer") # The underlying C implementation uses lazy evaluation and - # needs to hold on to the grid reference. We therefor take + # needs to hold on to the grid reference. We therefore take # references to it here, to protect against premature garbage # collection. self.grid_ref = grid diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py similarity index 97% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py index 7daf0fce44..704c5fad87 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_collection.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_collection.py @@ -15,8 +15,8 @@ # for more details. import re -from ecl.util import monkey_the_camel -from ecl.ecl import EclGrid +from ecl.util.util import monkey_the_camel +from ecl.grid import EclGrid from .fault import Fault comment_regexp = re.compile("--.*") @@ -45,7 +45,7 @@ def __init__(self, grid=None, *file_list): def __contains__(self, fault_name): - return self.__fault_map.has_key(fault_name) + return fault_name in self.__fault_map def __len__(self): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py similarity index 94% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault_line.py index 3436d7454d..10ef3da0e8 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_line.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_line.py @@ -17,20 +17,13 @@ from __future__ import print_function import sys -from ecl.util import monkey_the_camel -from ecl.util import DoubleVector,stat -from ecl.geo import CPolyline +from ecl.util.util import monkey_the_camel +from ecl.util.util import DoubleVector +from ecl.util.geometry import CPolyline from .fault_segments import FaultSegment -def cmp_index_pair(p1, p2): - if p1[0] == p2[0]: - return cmp(p1[1], p2[1]) - else: - return cmp(p1[0], p2[0]) - - class FaultLine(object): def __init__(self, grid, k): self.__grid = grid @@ -100,13 +93,13 @@ def __init_ij_polyline(self): for segment in self: corner = segment.getC1() i = corner % (nx + 1) - j = corner / (nx + 1) + j = corner // (nx + 1) pl.append((i,j)) segment = self[-1] corner = segment.getC2() i = corner % (nx + 1) - j = corner / (nx + 1) + j = corner // (nx + 1) pl.append((i,j)) self.__ijpolyline = pl @@ -179,8 +172,10 @@ def __init_neighbor_cells(self): self.__neighborCells.append((g1,g2)) else: - raise Exception("Internal error: found fault segment with variation in two directions") - self.__neighborCells.sort(cmp_index_pair) + raise Exception("Internal error: found fault segment with " + "variation in two directions") + + self.__neighborCells.sort(key=lambda k: (k[0], k[1])) def get_neighbor_cells(self): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py b/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py similarity index 90% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py rename to ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py index 9b579a57d9..7949a44d0e 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/fault_segments.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/fault_segments.py @@ -16,7 +16,7 @@ from __future__ import print_function -from ecl.util import monkey_the_camel +from ecl.util.util import monkey_the_camel class FaultSegment(object): @@ -101,18 +101,18 @@ def verify(self): def add_segment(self, segment): (C1,C2) = segment.getCorners() - if not self.__segment_map.has_key(C1): + if C1 not in self.__segment_map: self.__segment_map[C1] = {} self.__count_map[C1] = 0 - if not self.__segment_map.has_key(C2): + if C2 not in self.__segment_map: self.__segment_map[C2] = {} self.__count_map[C2] = 0 - if not self.__segment_map[C1].has_key(C2): + if C2 not in self.__segment_map[C1]: self.__segment_map[C1][C2] = segment self.__count_map[C1] += 1 - if not self.__segment_map[C2].has_key(C1): + if C1 not in self.__segment_map[C2]: self.__segment_map[C2][C1] = segment self.__count_map[C2] += 1 @@ -134,9 +134,9 @@ def del_segment(self, segment): def pop_start(self): end_segments = [] - for (C, count) in self.__count_map.iteritems(): + for (C, count) in self.__count_map.items(): if count == 1: - end_segments.append(self.__segment_map[C].values()[0]) + end_segments.append(list(self.__segment_map[C].values())[0]) start_segment = end_segments[0] self.delSegment(start_segment) @@ -145,9 +145,9 @@ def pop_start(self): def pop_next(self, segment): (C1,C2) = segment.getCorners() if self.__count_map[C1] >= 1: - next_segment = self.__segment_map[C1].values()[0] + next_segment = list(self.__segment_map[C1].values())[0] elif self.__count_map[C2] >= 1: - next_segment = self.__segment_map[C2].values()[0] + next_segment = list(self.__segment_map[C2].values())[0] else: next_segment = None diff --git a/ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py b/ThirdParty/Ert/python/ecl/grid/faults/layer.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py rename to ThirdParty/Ert/python/ecl/grid/faults/layer.py index 464fd891df..855f8f6be0 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/faults/layer.py +++ b/ThirdParty/Ert/python/ecl/grid/faults/layer.py @@ -16,10 +16,11 @@ import ctypes +from ecl.grid import EclGrid from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import IntVector -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import IntVector +from ecl import EclPrototype class Layer(BaseCClass): diff --git a/ThirdParty/Ert/python/ecl/rft/CMakeLists.txt b/ThirdParty/Ert/python/ecl/rft/CMakeLists.txt new file mode 100644 index 0000000000..2427bbca2a --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/CMakeLists.txt @@ -0,0 +1,8 @@ +set(PYTHON_SOURCES + __init__.py + well_trajectory.py + ecl_rft.py + ecl_rft_cell.py +) + +add_python_package("python.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ecl/rft "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/rft/__init__.py b/ThirdParty/Ert/python/ecl/rft/__init__.py new file mode 100644 index 0000000000..d4efcd32c0 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/rft/__init__.py @@ -0,0 +1,25 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +""" + ecl_rft/[EclRFTFile , EclRFT , EclRFTCell]: Loads an ECLIPSE RFT/PLT + file, and can afterwords be used to support various queries. +""" + +from .well_trajectory import WellTrajectory +from .ecl_rft_cell import EclPLTCell, EclRFTCell +from .ecl_rft import EclRFT, EclRFTFile + diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py b/ThirdParty/Ert/python/ecl/rft/ecl_rft.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py rename to ThirdParty/Ert/python/ecl/rft/ecl_rft.py index 59dda841cc..38411dfd4b 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft.py +++ b/ThirdParty/Ert/python/ecl/rft/ecl_rft.py @@ -21,9 +21,10 @@ from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclRFTCell, EclPLTCell, EclPrototype +from ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl.rft import EclRFTCell, EclPLTCell class EclRFT(BaseCClass): """The EclRFT class contains the information for *one* RFT. diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py b/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py similarity index 99% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py rename to ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py index c875d1f52f..13a80cc4b6 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_rft_cell.py +++ b/ThirdParty/Ert/python/ecl/rft/ecl_rft_cell.py @@ -15,7 +15,7 @@ # for more details. from cwrap import BaseCClass -from ecl.ecl import EclPrototype +from ecl import EclPrototype class RFTCell(BaseCClass): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/rft/well_trajectory.py b/ThirdParty/Ert/python/ecl/rft/well_trajectory.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/ecl/rft/well_trajectory.py rename to ThirdParty/Ert/python/ecl/rft/well_trajectory.py diff --git a/ThirdParty/Ert/python/ecl/summary/CMakeLists.txt b/ThirdParty/Ert/python/ecl/summary/CMakeLists.txt new file mode 100644 index 0000000000..23799c778d --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/CMakeLists.txt @@ -0,0 +1,14 @@ +set(PYTHON_SOURCES + __init__.py + ecl_npv.py + ecl_smspec_node.py + ecl_sum.py + ecl_sum_keyword_vector.py + ecl_sum_node.py + ecl_sum_tstep.py + ecl_sum_vector.py + ecl_cmp.py + ecl_sum_var_type.py +) + +add_python_package("python.ecl.summary" ${PYTHON_INSTALL_PREFIX}/ecl/summary "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/summary/__init__.py b/ThirdParty/Ert/python/ecl/summary/__init__.py new file mode 100644 index 0000000000..946fcf6e8d --- /dev/null +++ b/ThirdParty/Ert/python/ecl/summary/__init__.py @@ -0,0 +1,35 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +""" + ecl_sum/EclSum: This will load summary results from an ECLIPSE run; + both data file(s) and the SMSPEC file. The EclSum object can be + used as basis for queries on summary vectors. +""" + + +import ecl.util.util +import ecl.util.geometry + +from .ecl_sum_var_type import EclSumVarType +from .ecl_sum_tstep import EclSumTStep +from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode +from .ecl_sum_keyword_vector import EclSumKeyWordVector +from .ecl_sum_node import EclSumNode +from .ecl_sum_vector import EclSumVector +from .ecl_npv import EclNPV , NPVPriceVector +from .ecl_cmp import EclCmp + diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py b/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py rename to ThirdParty/Ert/python/ecl/summary/ecl_cmp.py index bd85dcde2b..ce705d20e7 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_cmp.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_cmp.py @@ -14,8 +14,8 @@ # See the GNU General Public License at # for more details. -from ecl.util import monkey_the_camel -from ecl.ecl import EclSum +from ecl.util.util import monkey_the_camel +from ecl.summary import EclSum class EclCase(object): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py b/ThirdParty/Ert/python/ecl/summary/ecl_npv.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py rename to ThirdParty/Ert/python/ecl/summary/ecl_npv.py index df3860203e..67363f2669 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_npv.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_npv.py @@ -18,8 +18,8 @@ import datetime import numbers -from ecl.util import monkey_the_camel -from ecl.ecl import EclSum +from ecl.util.util import monkey_the_camel +from ecl.summary import EclSum class NPVParseKey(object): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py b/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py rename to ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py index 2a903bc964..291b5ec949 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_smspec_node.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_smspec_node.py @@ -15,8 +15,8 @@ # for more details. from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype class EclSMSPECNode(BaseCClass): diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py similarity index 80% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py rename to ThirdParty/Ert/python/ecl/summary/ecl_sum.py index fe6ca681e2..2d2970ad9e 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum.py @@ -21,10 +21,11 @@ libecl/src directory. """ - +import warnings import numpy import datetime import os.path +import ctypes # Observe that there is some convention conflict with the C code # regarding order of arguments: The C code generally takes the time @@ -32,14 +33,14 @@ # argument. In the python code this order has been reversed. from cwrap import BaseCClass, CFILE -from ecl.util import monkey_the_camel -from ecl.util import StringList, CTime, DoubleVector, TimeVector, IntVector +from ecl.util.util import monkey_the_camel +from ecl.util.util import StringList, CTime, DoubleVector, TimeVector, IntVector -from ecl.ecl import EclSumTStep -from ecl.ecl import EclSumVarType -from ecl.ecl.ecl_sum_vector import EclSumVector -from ecl.ecl.ecl_smspec_node import EclSMSPECNode -from ecl.ecl import EclPrototype +from ecl.summary import EclSumTStep +from ecl.summary import EclSumVarType +from ecl.summary.ecl_sum_vector import EclSumVector +from ecl.summary.ecl_smspec_node import EclSMSPECNode +from ecl import EclPrototype, EclUnitTypeEnum #, EclSumKeyWordVector @@ -88,7 +89,9 @@ class EclSum(BaseCClass): TYPE_NAME = "ecl_sum" _fread_alloc_case = EclPrototype("void* ecl_sum_fread_alloc_case__(char*, char*, bool)", bind=False) _fread_alloc = EclPrototype("void* ecl_sum_fread_alloc(char*, stringlist, char*, bool)", bind=False) - _create_restart_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_restart_writer(char*, char*, bool, bool, char*, time_t, bool, int, int, int)", bind = False) + _create_restart_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_restart_writer2(char*, char*, int, bool, bool, char*, time_t, bool, int, int, int)", bind = False) + _create_writer = EclPrototype("ecl_sum_obj ecl_sum_alloc_writer(char*, bool, bool, char*, time_t, bool, int, int, int)", bind = False) + _resample = EclPrototype("ecl_sum_obj ecl_sum_alloc_resample( ecl_sum, char*, time_t_vector)") _iiget = EclPrototype("double ecl_sum_iget(ecl_sum, int, int)") _free = EclPrototype("void ecl_sum_free(ecl_sum)") _data_length = EclPrototype("int ecl_sum_get_data_length(ecl_sum)") @@ -119,7 +122,10 @@ class EclSum(BaseCClass): _get_first_day = EclPrototype("double ecl_sum_get_first_day(ecl_sum)") _get_data_start = EclPrototype("time_t ecl_sum_get_data_start(ecl_sum)") _get_unit = EclPrototype("char* ecl_sum_get_unit(ecl_sum, char*)") + _get_restart_case = EclPrototype("ecl_sum_ref ecl_sum_get_restart_case(ecl_sum)") + _get_restart_step = EclPrototype("int ecl_sum_get_restart_step(ecl_sum)") _get_simcase = EclPrototype("char* ecl_sum_get_case(ecl_sum)") + _get_unit_system = EclPrototype("ecl_unit_enum ecl_sum_get_unit_system(ecl_sum)") _get_base = EclPrototype("char* ecl_sum_get_base(ecl_sum)") _get_path = EclPrototype("char* ecl_sum_get_path(ecl_sum)") _get_abs_path = EclPrototype("char* ecl_sum_get_abs_path(ecl_sum)") @@ -137,7 +143,11 @@ class EclSum(BaseCClass): _add_tstep = EclPrototype("ecl_sum_tstep_ref ecl_sum_add_tstep(ecl_sum, int, double)") _export_csv = EclPrototype("void ecl_sum_export_csv(ecl_sum, char*, stringlist, char*, char*)") _identify_var_type = EclPrototype("ecl_sum_var_type ecl_sum_identify_var_type(char*)", bind = False) - + _get_last_value = EclPrototype("double ecl_sum_get_last_value_gen_key(ecl_sum, char*)") + _get_first_value = EclPrototype("double ecl_sum_get_first_value_gen_key(ecl_sum, char*)") + _init_numpy_vector = EclPrototype("void ecl_sum_init_double_vector(ecl_sum, char*, double*)") + _init_numpy_vector_interp = EclPrototype("void ecl_sum_init_double_vector_interp(ecl_sum, char*, time_t_vector, double*)") + _init_numpy_datetime64 = EclPrototype("void ecl_sum_init_datetime64_vector(ecl_sum, int64*, int)") def __init__(self, load_case, join_string=":", include_restart=True): @@ -209,20 +219,63 @@ def var_type(cls, keyword): @staticmethod - def writer(case, start_time, nx,ny,nz, fmt_output=False, unified=True, time_in_days=True, key_join_string=":"): + def writer(case, + start_time, + nx,ny,nz, + fmt_output=False, + unified=True, + time_in_days=True, + key_join_string=":"): """ The writer is not generally usable. @rtype: EclSum """ - return EclSum._create_restart_writer(case, None, fmt_output, unified, key_join_string, CTime(start_time), time_in_days, nx, ny, nz) + + start = CTime(start_time) + + smry = EclSum._create_writer(case, + fmt_output, + unified, + key_join_string, + start, + time_in_days, + nx, + ny, + nz) + smry._load_case = 'writer' + return smry + @staticmethod - def restart_writer(case, restart_case, start_time, nx,ny,nz, fmt_output=False, unified=True, time_in_days=True, key_join_string=":"): + def restart_writer(case, + restart_case, + restart_step, + start_time, + nx,ny,nz, + fmt_output=False, + unified=True, + time_in_days=True, + key_join_string=":"): """ The writer is not generally usable. @rtype: EclSum """ - return EclSum._create_restart_writer(case, restart_case, fmt_output, unified, key_join_string, CTime(start_time), time_in_days, nx, ny, nz) + + start = CTime(start_time) + + smry = EclSum._create_restart_writer(case, + restart_case, + restart_step, + fmt_output, + unified, + key_join_string, + start, + time_in_days, + nx, + ny, + nz) + smry._load_case = 'restart_writer' + return smry def add_variable(self, variable, wgname=None, num=0, unit="None", default_value=0): return self._add_variable(variable, wgname, num, unit, default_value).setParent(parent=self) @@ -230,7 +283,16 @@ def add_variable(self, variable, wgname=None, num=0, unit="None", default_value= def add_t_step(self, report_step, sim_days): """ @rtype: EclSumTStep """ + # report_step int + if not isinstance(report_step, int): + raise TypeError('Parameter report_step should be int, was %r' % report_step) + try: + float(sim_days) + except TypeError: + raise TypeError('Parameter sim_days should be float, was %r' % sim_days) + sim_seconds = sim_days * 24 * 60 * 60 + return self._add_tstep(report_step, sim_seconds).setParent(parent=self) @@ -268,9 +330,9 @@ def __private_init(self): for i0 in range(length): while True: time_index = index_list[i1] + i1 += 1 if time_index >= 0: break - i1 += 1 self.__daysR[i0] = self._iget_sim_days(time_index) self.__datesR[i0] = self.iget_date(time_index) @@ -338,6 +400,7 @@ def get_values(self, key, report_only=False): also available as the 'values' property of an EclSumVector instance. """ + warnings.warn("The method get_values() has been deprecated - use numpy_vector() instead.", DeprecationWarning) if self.has_key(key): key_index = self._get_general_var_index(key) if report_only: @@ -356,6 +419,121 @@ def get_values(self, key, report_only=False): else: raise KeyError("Summary object does not have key:%s" % key) + def _make_time_vector(self, time_index): + time_points = TimeVector() + for t in time_index: + time_points.append(t) + return time_points + + def numpy_vector(self, key, time_index = None): + """Will return numpy vector of all the values corresponding to @key. + + The optional argument @time_index can be used to limit the time points + where you want evaluation. The time_index argument should be a list of + datetime instances. The values will be interpolated to the time points + given in the time_index vector. If the time points in the time_inedx + vector are outside of the simulated range you will get an extrapolated + value: + + Rates -> 0 + Not rate -> first or last simulated value. + + The function will raise KeyError if the requested key does not exist. + If many keys are needed it will be faster to use the pandas_frame() + function. + """ + if key not in self: + raise KeyError("No such key:%s" % key) + + if time_index is None: + np_vector = numpy.zeros(len(self)) + self._init_numpy_vector(key ,np_vector.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + return np_vector + else: + time_vector = self._make_time_vector(time_index) + np_vector = numpy.zeros(len(time_vector)) + self._init_numpy_vector_interp(key, time_vector, np_vector.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + return np_vector + + + @property + def numpy_dates(self): + """ + Will return numpy vector of numpy.datetime64() values for all the simulated timepoints. + """ + np_dates = numpy.zeros(len(self), dtype="datetime64[ms]") + self._init_numpy_datetime64(np_dates.ctypes.data_as(ctypes.POINTER(ctypes.c_int64)), 1000) + return np_dates + + + @property + def dates(self): + """ + Will return ordinary Python list of datetime.datetime() objects of simulated timepoints. + """ + np_dates = self.numpy_dates + return np_dates.tolist() + + + def pandas_frame(self, time_index = None, column_keys = None): + """Will create a pandas frame with summary data. + + By default you will get all time points in the summary case, but by + using the time_index argument you can control which times you are + interested in. If you have supplied a time_index argument the data will + be interpolated to these time values. If the time points in the + time_index vector are outside of the simulated range you will get an + extrapolated value: + + Rates -> 0 + Not rate -> first or last simulated value. + + + By default the frame will contain all the summary vectors in the case, + but this can be controlled by using the column_keys argument. The + column_keys should be a list of strings, and each summary vector + matching one of the elements in the @column_keys will get a column in + the frame, you can use wildcards like "WWCT:*" and "*:OP". If you + supply a column_keys argument which does not resolve to any valid + summary keys you will get a ValueError exception. + + + sum = EclSum(case) + monthly_dates = sum.time_range(interval="1M") + data = sum.pandas_frame(time_index = monthly_dates, column_keys=["F*PT"]) + + FOPT FGPT FWPT + 2010-01-01 100.7 200.0 25.0 + 2010-02-01 150.7 275.0 67.6 + 2010-03-01 276.7 310.6 67.0 + 2010-04-01 672.7 620.4 78.7 + .... + """ + from ecl.summary import EclSumKeyWordVector + import pandas + if column_keys is None: + keywords = EclSumKeyWordVector(self, add_keywords = True) + else: + keywords = EclSumKeyWordVector(self) + for key in column_keys: + keywords.add_keywords(key) + + + if len(keywords) == 0: + raise ValueError("No valid key") + + if time_index is None: + time_index = self.numpy_dates + data = numpy.zeros([len(time_index), len(keywords)]) + EclSum._init_pandas_frame(self, keywords,data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + else: + time_points = self._make_time_vector(time_index) + data = numpy.zeros([len(time_points), len(keywords)]) + EclSum._init_pandas_frame_interp(self, keywords, time_points, data.ctypes.data_as(ctypes.POINTER(ctypes.c_double))) + + frame = pandas.DataFrame(index = time_index, columns=list(keywords), data=data) + return frame + def get_key_index(self, key): """ @@ -383,7 +561,7 @@ def get_key_index(self, key): return None - def get_last_value(self, key): + def last_value(self, key): """ Will return the last value corresponding to @key. @@ -395,14 +573,31 @@ def get_last_value(self, key): The alternative method 'last' will return a EclSumNode instance with some extra time related information. """ - return self[key].last_value + if not key in self: + raise KeyError("No such key:%s" % key) + + return self._get_last_value(key) + + + def first_value(self, key): + """ + Will return first value corresponding to @key. + """ + if not key in self: + raise KeyError("No such key:%s" % key) + + return self._get_first_value(key) + + def get_last_value(self,key): + warnings.warn("The function get_last_value() is deprecated, use last_value() instead",DeprecationWarning) + return self.last_value(key) def get_last(self, key): """ Will return the last EclSumNode corresponding to @key. If you are only interested in the final value, you can use the - get_last_value() method. + last_value() method. """ return self[key].last @@ -538,14 +733,21 @@ def get_interp(self, key, days=None, date=None): raise ValueError("Must supply either days or date") - def get_interp_row(self, key_list, sim_time): + def get_interp_row(self, key_list, sim_time, invalid_value = -1): ctime = CTime(sim_time) - data = DoubleVector( initial_size = len(key_list) ) + data = DoubleVector( initial_size = len(key_list) , default_value = invalid_value) EclSum._get_interp_vector(self, ctime, key_list, data) return data - def time_range(self, start=None, end=None, interval="1Y", extend_end=True): + def time_range(self, start=None, end=None, interval="1Y", num_timestep = None, extend_end=True): + """Will create a vector of timepoints based on the current case. + + By default the timepoints will be regularly sampled based on the + interval given by the @interval string. Alternatively the total number + of timesteps can be specified, if the @num_timestep option is specified + that will take presedence. + """ (num, timeUnit) = TimeVector.parseTimeUnit(interval) if start is None: @@ -571,6 +773,9 @@ def time_range(self, start=None, end=None, interval="1Y", extend_end=True): raise ValueError("Invalid time interval start after end") + if not num_timestep is None: + return TimeVector.create_linear(CTime(start), CTime(end), num_timestep) + range_start = start range_end = end if not timeUnit == "d": @@ -627,7 +832,7 @@ def blocked_production(self, totalKey, timeRange): if t < CTime(self.start_time): total.append(0) elif t >= CTime(self.end_time): - total.append(self.get_last_value(totalKey)) + total.append(self.last_value(totalKey)) else: total.append(self.get_interp(totalKey, date=t)) tmp = total << 1 @@ -748,6 +953,13 @@ def unit(self, key): return node.unit + @property + def unit_system(self): + """ + Will return the unit system in use for this case. + """ + return self._get_unit_system() + @property def case(self): """ @@ -756,6 +968,22 @@ def case(self): return self._get_simcase() + @property + def restart_step(self): + """ + Will return the report step this case has been restarted from, or -1. + """ + return self._get_restart_step() + + + @property + def restart_case(self): + restart_case = self._get_restart_case() + if restart_case: + restart_case.setParent(parent=self) + return restart_case + + @property def path(self): """ @@ -809,16 +1037,6 @@ def get_days(self, report_only=False): else: return self.__days - @property - def dates(self): - """ - Will return a list of simulation dates. - - The list will be an ordinary Python list, and the dates will - be in terms ordinary Python datetime values. - """ - return self.get_dates(False) - def get_dates(self, report_only=False): """ Will return a list of simulation dates. @@ -1278,10 +1496,15 @@ def export_csv(self, filename, keys=None, date_format="%Y-%m-%d", sep=";"): + def resample(self, new_case_name, time_points): + return self._resample(new_case_name, time_points) + -import ecl.ecl.ecl_sum_keyword_vector -EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False) -EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False) +import ecl.summary.ecl_sum_keyword_vector +EclSum._dump_csv_line = EclPrototype("void ecl_sum_fwrite_interp_csv_line(ecl_sum, time_t, ecl_sum_vector, FILE)", bind=False) +EclSum._get_interp_vector = EclPrototype("void ecl_sum_get_interp_vector(ecl_sum, time_t, ecl_sum_vector, double_vector)", bind=False) +EclSum._init_pandas_frame = EclPrototype("void ecl_sum_init_double_frame(ecl_sum, ecl_sum_vector, double*)", bind=False) +EclSum._init_pandas_frame_interp = EclPrototype("void ecl_sum_init_double_frame_interp(ecl_sum, ecl_sum_vector, time_t_vector, double*)", bind=False) monkey_the_camel(EclSum, 'varType', EclSum.var_type, classmethod) monkey_the_camel(EclSum, 'addVariable', EclSum.add_variable) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py similarity index 85% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py rename to ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py index 1dea8aaa7a..a3fc4c12a6 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_keyword_vector.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_keyword_vector.py @@ -24,22 +24,23 @@ # argument. In the python code this order has been reversed. from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl import EclPrototype class EclSumKeyWordVector(BaseCClass): TYPE_NAME = "ecl_sum_vector" - _alloc = EclPrototype("void* ecl_sum_vector_alloc(ecl_sum)", bind=False) + _alloc = EclPrototype("void* ecl_sum_vector_alloc(ecl_sum, bool)", bind=False) + _alloc_copy = EclPrototype("ecl_sum_vector_obj ecl_sum_vector_alloc_layout_copy(ecl_sum_vector, ecl_sum)") _free = EclPrototype("void ecl_sum_vector_free(ecl_sum_vector)") _add = EclPrototype("bool ecl_sum_vector_add_key(ecl_sum_vector, char*)") _add_multiple = EclPrototype("void ecl_sum_vector_add_keys(ecl_sum_vector, char*)") _get_size = EclPrototype("int ecl_sum_vector_get_size(ecl_sum_vector)") _iget_key = EclPrototype("char* ecl_sum_vector_iget_key(ecl_sum_vector, int)") - def __init__(self, ecl_sum): - c_pointer = self._alloc(ecl_sum) + def __init__(self, ecl_sum, add_keywords = False): + c_pointer = self._alloc(ecl_sum, add_keywords) super(EclSumKeyWordVector, self).__init__(c_pointer) def __getitem__(self, index): @@ -68,5 +69,9 @@ def add_keywords(self, keyword_pattern): def __repr__(self): return self._create_repr('len=%d' % len(self)) + def copy(self, ecl_sum): + return self._alloc_copy(ecl_sum) + + monkey_the_camel(EclSumKeyWordVector, 'addKeyword', EclSumKeyWordVector.add_keyword) monkey_the_camel(EclSumKeyWordVector, 'addKeywords', EclSumKeyWordVector.add_keywords) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_node.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_node.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_node.py rename to ThirdParty/Ert/python/ecl/summary/ecl_sum_node.py diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py similarity index 85% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py rename to ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py index 3a759ae9c5..0b165e6e0a 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_tstep.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_tstep.py @@ -16,9 +16,9 @@ from cwrap import BaseCClass -from ecl.util import monkey_the_camel -from ecl.util import CTime -from ecl.ecl import EclPrototype +from ecl.util.util import monkey_the_camel +from ecl.util.util import CTime +from ecl import EclPrototype @@ -32,7 +32,7 @@ class EclSumTStep(BaseCClass): _get_ministep = EclPrototype("int ecl_sum_tstep_get_ministep(ecl_sum_tstep)") _set_from_key = EclPrototype("void ecl_sum_tstep_set_from_key(ecl_sum_tstep, char*, float)") _get_from_key = EclPrototype("double ecl_sum_tstep_get_from_key(ecl_sum_tstep, char*)") - _has_key = EclPrototype("bool ecl_sum_tstep_has_key(ecl_sum_tstep)") + _has_key = EclPrototype("bool ecl_sum_tstep_has_key(ecl_sum_tstep, char*)") @@ -77,6 +77,15 @@ def __contains__(self, key): def free(self): self._free(self) + def __repr__(self): + d = self._get_sim_days() + t = self._get_sim_time() + r = self._get_report() + m = self._get_ministep() + cnt = 'sim_days={}, sim_time={}, report={}, ministep={}' + return self._create_repr(cnt.format(d, t, r, m)) + + monkey_the_camel(EclSumTStep, 'getSimDays', EclSumTStep.get_sim_days) monkey_the_camel(EclSumTStep, 'getReport', EclSumTStep.get_report) monkey_the_camel(EclSumTStep, 'getMiniStep', EclSumTStep.get_mini_step) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py rename to ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py index d9f9e8cf99..039105f497 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_var_type.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_var_type.py @@ -15,7 +15,7 @@ # for more details. from cwrap import BaseCEnum -from ecl.ecl import ECL_LIB + class EclSumVarType(BaseCEnum): @@ -36,7 +36,7 @@ class EclSumVarType(BaseCEnum): ECL_SMSPEC_LOCAL_WELL_VAR = None ECL_SMSPEC_MISC_VAR = None - + EclSumVarType.addEnum("ECL_SMSPEC_INVALID_VAR", 0) EclSumVarType.addEnum("ECL_SMSPEC_FIELD_VAR", 1) EclSumVarType.addEnum("ECL_SMSPEC_REGION_VAR", 2) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py b/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py rename to ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py index 5cde9f119a..4ec15faedd 100644 --- a/ThirdParty/Ert/python/python/ecl/ecl/ecl_sum_vector.py +++ b/ThirdParty/Ert/python/ecl/summary/ecl_sum_vector.py @@ -16,7 +16,7 @@ from __future__ import print_function import warnings -from ecl.ecl.ecl_sum_node import EclSumNode +from ecl.summary.ecl_sum_node import EclSumNode class EclSumVector(object): @@ -33,7 +33,7 @@ def __init__(self, parent, key, report_only = False): The EclSumVector contains a reference to the parent EclSum structure and this is used to implement several of the properties and methods of the object; the EclSum vector - instances should therefor only be instantiated through the + instances should therefore only be instantiated through the EclSum.get_vector() method, and not manually with the EclSumVector() constructor. """ diff --git a/ThirdParty/Ert/python/ecl/util/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/CMakeLists.txt new file mode 100644 index 0000000000..a4b6f67f33 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/CMakeLists.txt @@ -0,0 +1,10 @@ +set(PYTHON_SOURCES + __init__.py +) + +add_python_package("python.ecl.util" ${PYTHON_INSTALL_PREFIX}/ecl/util "${PYTHON_SOURCES}" True) + +add_subdirectory(enums) +add_subdirectory(util) +add_subdirectory(test) +add_subdirectory(geometry) diff --git a/ThirdParty/Ert/python/tests/geometry/__init__.py b/ThirdParty/Ert/python/ecl/util/__init__.py similarity index 100% rename from ThirdParty/Ert/python/tests/geometry/__init__.py rename to ThirdParty/Ert/python/ecl/util/__init__.py diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt similarity index 71% rename from ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt index fbf4917449..64559cd9b7 100644 --- a/ThirdParty/Ert/python/python/ecl/util/enums/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/util/enums/CMakeLists.txt @@ -2,9 +2,6 @@ set(PYTHON_SOURCES __init__.py rng_alg_type_enum.py rng_init_mode_enum.py - ui_return_status_enum.py - llsq_result_enum.py - message_level_enum.py ) add_python_package("python.ecl.util.enums" ${PYTHON_INSTALL_PREFIX}/ecl/util/enums "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/ecl/util/enums/__init__.py b/ThirdParty/Ert/python/ecl/util/enums/__init__.py new file mode 100644 index 0000000000..ced8c20089 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/enums/__init__.py @@ -0,0 +1,2 @@ +from .rng_init_mode_enum import RngInitModeEnum +from .rng_alg_type_enum import RngAlgTypeEnum diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/rng_alg_type_enum.py b/ThirdParty/Ert/python/ecl/util/enums/rng_alg_type_enum.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/util/enums/rng_alg_type_enum.py rename to ThirdParty/Ert/python/ecl/util/enums/rng_alg_type_enum.py diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/rng_init_mode_enum.py b/ThirdParty/Ert/python/ecl/util/enums/rng_init_mode_enum.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/util/enums/rng_init_mode_enum.py rename to ThirdParty/Ert/python/ecl/util/enums/rng_init_mode_enum.py diff --git a/ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt similarity index 61% rename from ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt index 563a73db75..177b135916 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/util/geometry/CMakeLists.txt @@ -10,4 +10,4 @@ set(PYTHON_SOURCES surface.py ) -add_python_package("python.ecl.geo" ${PYTHON_INSTALL_PREFIX}/ecl/geo "${PYTHON_SOURCES}" True) +add_python_package("python.ecl.util.geometry" ${PYTHON_INSTALL_PREFIX}/ecl/util/geometry "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/geo/__init__.py b/ThirdParty/Ert/python/ecl/util/geometry/__init__.py similarity index 84% rename from ThirdParty/Ert/python/python/ecl/geo/__init__.py rename to ThirdParty/Ert/python/ecl/util/geometry/__init__.py index b2d982a580..e4bc012dc9 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/__init__.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/__init__.py @@ -20,13 +20,6 @@ import ecl from cwrap import Prototype -class GeoPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True): - super(GeoPrototype, self).__init__(GeoPrototype.lib, prototype, bind=bind) - - from .geo_pointset import GeoPointset from .geo_region import GeoRegion from .cpolyline import CPolyline diff --git a/ThirdParty/Ert/python/python/ecl/geo/cpolyline.py b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py similarity index 87% rename from ThirdParty/Ert/python/python/ecl/geo/cpolyline.py rename to ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py index 4014059ed8..227413182b 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/cpolyline.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline.py @@ -20,25 +20,25 @@ import os.path from cwrap import BaseCClass -from ecl.geo import GeoPrototype +from ecl import EclPrototype from .geometry_tools import GeometryTools class CPolyline(BaseCClass): TYPE_NAME = "geo_polygon" - _alloc_new = GeoPrototype("void* geo_polygon_alloc( char* )" , bind = False) - _fread_alloc_irap = GeoPrototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )" , bind = False) - _add_point = GeoPrototype("void geo_polygon_add_point( geo_polygon , double , double )") - _add_point_front = GeoPrototype("void geo_polygon_add_point_front( geo_polygon , double , double )") - _free = GeoPrototype("void geo_polygon_free( geo_polygon )") - _size = GeoPrototype("int geo_polygon_get_size( geo_polygon )") - _iget_xy = GeoPrototype("void geo_polygon_iget_xy( geo_polygon , int , double* , double* )") - _segment_intersects = GeoPrototype("bool geo_polygon_segment_intersects( geo_polygon , double , double, double , double)") - _get_name = GeoPrototype("char* geo_polygon_get_name( geo_polygon )") - _set_name = GeoPrototype("void geo_polygon_set_name( geo_polygon , char* )") - _segment_length = GeoPrototype("double geo_polygon_get_length( geo_polygon)") - _equal = GeoPrototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") + _alloc_new = EclPrototype("void* geo_polygon_alloc( char* )" , bind = False) + _fread_alloc_irap = EclPrototype("geo_polygon_obj geo_polygon_fload_alloc_irap( char* )" , bind = False) + _add_point = EclPrototype("void geo_polygon_add_point( geo_polygon , double , double )") + _add_point_front = EclPrototype("void geo_polygon_add_point_front( geo_polygon , double , double )") + _free = EclPrototype("void geo_polygon_free( geo_polygon )") + _size = EclPrototype("int geo_polygon_get_size( geo_polygon )") + _iget_xy = EclPrototype("void geo_polygon_iget_xy( geo_polygon , int , double* , double* )") + _segment_intersects = EclPrototype("bool geo_polygon_segment_intersects( geo_polygon , double , double, double , double)") + _get_name = EclPrototype("char* geo_polygon_get_name( geo_polygon )") + _set_name = EclPrototype("void geo_polygon_set_name( geo_polygon , char* )") + _segment_length = EclPrototype("double geo_polygon_get_length( geo_polygon)") + _equal = EclPrototype("bool geo_polygon_equal( geo_polygon , geo_polygon )") def __init__(self, name = None , init_points = ()): diff --git a/ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py similarity index 86% rename from ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py rename to ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py index b93f5596d9..335f3092b6 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/cpolyline_collection.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/cpolyline_collection.py @@ -19,20 +19,21 @@ import ctypes from cwrap import BaseCClass -from ecl.geo import GeoPrototype, CPolyline +from ecl import EclPrototype +from ecl.util.geometry import CPolyline class CPolylineCollection(BaseCClass): TYPE_NAME = "geo_polygon_collection" - _alloc_new = GeoPrototype("void* geo_polygon_collection_alloc( )" , bind = False) - _free = GeoPrototype("void geo_polygon_collection_free( geo_polygon_collection )" ) - _size = GeoPrototype("int geo_polygon_collection_size( geo_polygon_collection)" ) - _create_polyline = GeoPrototype("geo_polygon_ref geo_polygon_collection_create_polygon(geo_polygon_collection , char*)" ) - _has_polyline = GeoPrototype("bool geo_polygon_collection_has_polygon(geo_polygon_collection , char*)" ) - _iget = GeoPrototype("geo_polygon_ref geo_polygon_collection_iget_polygon(geo_polygon_collection , int)" ) - _get = GeoPrototype("geo_polygon_ref geo_polygon_collection_get_polygon(geo_polygon_collection , char*)" ) - _add_polyline = GeoPrototype("void geo_polygon_collection_add_polygon(geo_polygon_collection , geo_polygon , bool)") + _alloc_new = EclPrototype("void* geo_polygon_collection_alloc( )" , bind = False) + _free = EclPrototype("void geo_polygon_collection_free( geo_polygon_collection )" ) + _size = EclPrototype("int geo_polygon_collection_size( geo_polygon_collection)" ) + _create_polyline = EclPrototype("geo_polygon_ref geo_polygon_collection_create_polygon(geo_polygon_collection , char*)" ) + _has_polyline = EclPrototype("bool geo_polygon_collection_has_polygon(geo_polygon_collection , char*)" ) + _iget = EclPrototype("geo_polygon_ref geo_polygon_collection_iget_polygon(geo_polygon_collection , int)" ) + _get = EclPrototype("geo_polygon_ref geo_polygon_collection_get_polygon(geo_polygon_collection , char*)" ) + _add_polyline = EclPrototype("void geo_polygon_collection_add_polygon(geo_polygon_collection , geo_polygon , bool)") diff --git a/ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py b/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py similarity index 67% rename from ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py rename to ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py index ff9fa3b2ec..6286de3eef 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/geo_pointset.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/geo_pointset.py @@ -14,28 +14,28 @@ # See the GNU General Public License at # for more details. from cwrap import BaseCClass -from ecl.geo import GeoPrototype +from ecl import EclPrototype class GeoPointset(BaseCClass): TYPE_NAME = "geo_pointset" - _alloc = GeoPrototype("void* geo_pointset_alloc(bool)", bind=False) - _free = GeoPrototype("void geo_pointset_free(geo_pointset)") - #_add_xyz = GeoPrototype("void geo_pointset_add_xyz(geo_pointset, double, double, double)") - _get_size = GeoPrototype("int geo_pointset_get_size(geo_pointset)") - #_iget_xy = GeoPrototype("void geo_pointset_iget_xy(geo_pointset, int, double*, double*)") - #_get_zcoord = GeoPrototype("double* geo_pointset_get_zcoord(geo_pointset)") - _equal = GeoPrototype("bool geo_pointset_equal(geo_pointset, geo_pointset)") - _iget_z = GeoPrototype("double geo_pointset_iget_z(geo_pointset, int)") - #_iset_z = GeoPrototype("void geo_pointset_iset_z(geo_pointset, int, double)") - #_memcpy = GeoPrototype("void geo_pointset_memcpy(geo_pointset, geo_pointset, bool)") - #_shift_z = GeoPrototype("void geo_pointset_shift_z(geo_pointset, double)") - #_assign_z = GeoPrototype("void geo_pointset_assign_z(geo_pointset, double)") - #_scale_z = GeoPrototype("void geo_pointset_scale_z(geo_pointset, double)") - #_imul = GeoPrototype("void geo_pointset_imul(geo_pointset, geo_pointset)") - #_iadd = GeoPrototype("void geo_pointset_iadd(geo_pointset, geo_pointset)") - #_isub = GeoPrototype("void geo_pointset_isub(geo_pointset, geo_pointset)") - #_isqrt = GeoPrototype("void geo_pointset_isqrt(geo_pointset)") + _alloc = EclPrototype("void* geo_pointset_alloc(bool)", bind=False) + _free = EclPrototype("void geo_pointset_free(geo_pointset)") + #_add_xyz = EclPrototype("void geo_pointset_add_xyz(geo_pointset, double, double, double)") + _get_size = EclPrototype("int geo_pointset_get_size(geo_pointset)") + #_iget_xy = EclPrototype("void geo_pointset_iget_xy(geo_pointset, int, double*, double*)") + #_get_zcoord = EclPrototype("double* geo_pointset_get_zcoord(geo_pointset)") + _equal = EclPrototype("bool geo_pointset_equal(geo_pointset, geo_pointset)") + _iget_z = EclPrototype("double geo_pointset_iget_z(geo_pointset, int)") + #_iset_z = EclPrototype("void geo_pointset_iset_z(geo_pointset, int, double)") + #_memcpy = EclPrototype("void geo_pointset_memcpy(geo_pointset, geo_pointset, bool)") + #_shift_z = EclPrototype("void geo_pointset_shift_z(geo_pointset, double)") + #_assign_z = EclPrototype("void geo_pointset_assign_z(geo_pointset, double)") + #_scale_z = EclPrototype("void geo_pointset_scale_z(geo_pointset, double)") + #_imul = EclPrototype("void geo_pointset_imul(geo_pointset, geo_pointset)") + #_iadd = EclPrototype("void geo_pointset_iadd(geo_pointset, geo_pointset)") + #_isub = EclPrototype("void geo_pointset_isub(geo_pointset, geo_pointset)") + #_isqrt = EclPrototype("void geo_pointset_isqrt(geo_pointset)") def __init__(self, external_z=False): diff --git a/ThirdParty/Ert/python/python/ecl/geo/geo_region.py b/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py similarity index 82% rename from ThirdParty/Ert/python/python/ecl/geo/geo_region.py rename to ThirdParty/Ert/python/ecl/util/geometry/geo_region.py index a4238d8650..9d4e290147 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/geo_region.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/geo_region.py @@ -14,8 +14,8 @@ # See the GNU General Public License at # for more details. from cwrap import BaseCClass -from ecl.util import IntVector -from ecl.geo import GeoPrototype +from ecl.util.util import IntVector +from ecl import EclPrototype from .cpolyline import CPolyline from ctypes import c_double @@ -24,18 +24,18 @@ class GeoRegion(BaseCClass): TYPE_NAME = "geo_region" - _alloc = GeoPrototype("void* geo_region_alloc(geo_pointset, bool)", bind=False) - _free = GeoPrototype("void geo_region_free(geo_region)") - _reset = GeoPrototype("void geo_region_reset(geo_region)") - _get_index_list = GeoPrototype("int_vector_ref geo_region_get_index_list(geo_region)") - _select_inside_polygon = GeoPrototype("void geo_region_select_inside_polygon(geo_region, geo_polygon)") - _select_outside_polygon = GeoPrototype("void geo_region_select_outside_polygon(geo_region, geo_polygon)") - _deselect_inside_polygon = GeoPrototype("void geo_region_deselect_inside_polygon(geo_region, geo_polygon)") - _deselect_outside_polygon = GeoPrototype("void geo_region_deselect_outside_polygon(geo_region, geo_polygon)") - _select_above_line = GeoPrototype("void geo_region_select_above_line(geo_region, double*, double*)") - _select_below_line = GeoPrototype("void geo_region_select_below_line(geo_region, double*, double*)") - _deselect_above_line = GeoPrototype("void geo_region_deselect_above_line(geo_region, double*, double*)") - _deselect_below_line = GeoPrototype("void geo_region_deselect_below_line(geo_region, double*, double*)") + _alloc = EclPrototype("void* geo_region_alloc(geo_pointset, bool)", bind=False) + _free = EclPrototype("void geo_region_free(geo_region)") + _reset = EclPrototype("void geo_region_reset(geo_region)") + _get_index_list = EclPrototype("int_vector_ref geo_region_get_index_list(geo_region)") + _select_inside_polygon = EclPrototype("void geo_region_select_inside_polygon(geo_region, geo_polygon)") + _select_outside_polygon = EclPrototype("void geo_region_select_outside_polygon(geo_region, geo_polygon)") + _deselect_inside_polygon = EclPrototype("void geo_region_deselect_inside_polygon(geo_region, geo_polygon)") + _deselect_outside_polygon = EclPrototype("void geo_region_deselect_outside_polygon(geo_region, geo_polygon)") + _select_above_line = EclPrototype("void geo_region_select_above_line(geo_region, double*, double*)") + _select_below_line = EclPrototype("void geo_region_select_below_line(geo_region, double*, double*)") + _deselect_above_line = EclPrototype("void geo_region_deselect_above_line(geo_region, double*, double*)") + _deselect_below_line = EclPrototype("void geo_region_deselect_below_line(geo_region, double*, double*)") def __init__(self, pointset, preselect=False): diff --git a/ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py b/ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py similarity index 98% rename from ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py rename to ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py index 9c33b89010..c3efe43a73 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/geometry_tools.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/geometry_tools.py @@ -1,5 +1,6 @@ from math import sqrt import sys +import six class GeometryTools(object): EPSILON = 0.000001 @@ -104,9 +105,9 @@ def keepLeft(hull, r): return hull - l = reduce(keepLeft, points, []) - u = reduce(keepLeft, reversed(points), []) - l.extend([u[i] for i in xrange(1, len(u) - 1)]) + l = six.functools.reduce(keepLeft, points, []) + u = six.functools.reduce(keepLeft, reversed(points), []) + l.extend([u[i] for i in six.moves.xrange(1, len(u) - 1)]) return l diff --git a/ThirdParty/Ert/python/python/ecl/geo/polyline.py b/ThirdParty/Ert/python/ecl/util/geometry/polyline.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/geo/polyline.py rename to ThirdParty/Ert/python/ecl/util/geometry/polyline.py diff --git a/ThirdParty/Ert/python/python/ecl/geo/surface.py b/ThirdParty/Ert/python/ecl/util/geometry/surface.py similarity index 82% rename from ThirdParty/Ert/python/python/ecl/geo/surface.py rename to ThirdParty/Ert/python/ecl/util/geometry/surface.py index 6dfeae9b9a..ba610cb9bc 100644 --- a/ThirdParty/Ert/python/python/ecl/geo/surface.py +++ b/ThirdParty/Ert/python/ecl/util/geometry/surface.py @@ -13,40 +13,42 @@ # # See the GNU General Public License at # for more details. +from __future__ import division + """ Create a polygon """ import os.path import ctypes -from numpy import zeros from cwrap import BaseCClass -from ecl.geo import GeoPrototype -from ecl.geo import GeoPointset +from ecl import EclPrototype +from ecl.util.geometry import GeoPointset + class Surface(BaseCClass): TYPE_NAME = "surface" - _alloc = GeoPrototype("void* geo_surface_fload_alloc_irap( char* , bool )" , bind = False) - _free = GeoPrototype("void geo_surface_free( surface )") - _new = GeoPrototype("void* geo_surface_alloc_new( int, int, double, double, double, double, double )", bind = False) - _get_nx = GeoPrototype("int geo_surface_get_nx( surface )") - _get_ny = GeoPrototype("int geo_surface_get_ny( surface )") - _iget_zvalue = GeoPrototype("double geo_surface_iget_zvalue( surface , int)") - _iset_zvalue = GeoPrototype("void geo_surface_iset_zvalue( surface , int , double)") - _write = GeoPrototype("void geo_surface_fprintf_irap( surface , char* )") - _equal = GeoPrototype("bool geo_surface_equal( surface , surface )") - _header_equal = GeoPrototype("bool geo_surface_equal_header( surface , surface )") - _copy = GeoPrototype("surface_obj geo_surface_alloc_copy( surface , bool )") - _assign = GeoPrototype("void geo_surface_assign_value( surface , double )") - _scale = GeoPrototype("void geo_surface_scale( surface , double )") - _shift = GeoPrototype("void geo_surface_shift( surface , double )") - _iadd = GeoPrototype("void geo_surface_iadd( surface , surface )") - _imul = GeoPrototype("void geo_surface_imul( surface , surface )") - _isub = GeoPrototype("void geo_surface_isub( surface , surface )") - _isqrt = GeoPrototype("void geo_surface_isqrt( surface )") - _iget_xy = GeoPrototype("void geo_surface_iget_xy(surface, int, double*, double*)") - _get_pointset = GeoPrototype("geo_pointset_ref geo_surface_get_pointset(surface)") + _alloc = EclPrototype("void* geo_surface_fload_alloc_irap( char* , bool )" , bind = False) + _free = EclPrototype("void geo_surface_free( surface )") + _new = EclPrototype("void* geo_surface_alloc_new( int, int, double, double, double, double, double )", bind = False) + _get_nx = EclPrototype("int geo_surface_get_nx( surface )") + _get_ny = EclPrototype("int geo_surface_get_ny( surface )") + _iget_zvalue = EclPrototype("double geo_surface_iget_zvalue( surface , int)") + _iset_zvalue = EclPrototype("void geo_surface_iset_zvalue( surface , int , double)") + _write = EclPrototype("void geo_surface_fprintf_irap( surface , char* )") + _equal = EclPrototype("bool geo_surface_equal( surface , surface )") + _header_equal = EclPrototype("bool geo_surface_equal_header( surface , surface )") + _copy = EclPrototype("surface_obj geo_surface_alloc_copy( surface , bool )") + _assign = EclPrototype("void geo_surface_assign_value( surface , double )") + _scale = EclPrototype("void geo_surface_scale( surface , double )") + _shift = EclPrototype("void geo_surface_shift( surface , double )") + _iadd = EclPrototype("void geo_surface_iadd( surface , surface )") + _imul = EclPrototype("void geo_surface_imul( surface , surface )") + _isub = EclPrototype("void geo_surface_isub( surface , surface )") + _isqrt = EclPrototype("void geo_surface_isqrt( surface )") + _iget_xy = EclPrototype("void geo_surface_iget_xy(surface, int, double*, double*)") + _get_pointset = EclPrototype("geo_pointset_ref geo_surface_get_pointset(surface)") def __init__(self, filename=None, nx=None, ny=None, xinc=None, yinc=None, @@ -116,11 +118,13 @@ def __imul__(self , other): self._scale( other) return self - - def __idiv__(self , other): - self._scale( 1.0/other) + def __itruediv__(self , other): + self._scale(1.0 / other) return self + def __idiv__(self, other): + return self.__itruediv__(other) + def __add__(self , other): copy = self.copy() @@ -140,12 +144,16 @@ def __sub__(self , other): return copy - def __div__(self , other): + def __truediv__(self , other): copy = self.copy() copy /= other return copy + def __div__(self, other): + return self.__truediv__(other) + + def __len__(self): """ The number of values in the surface. diff --git a/ThirdParty/Ert/python/python/ecl/geo/xyz_io.py b/ThirdParty/Ert/python/ecl/util/geometry/xyz_io.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/geo/xyz_io.py rename to ThirdParty/Ert/python/ecl/util/geometry/xyz_io.py diff --git a/ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt similarity index 73% rename from ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt index 9e4bec490d..4d87b9efca 100644 --- a/ThirdParty/Ert/python/python/ecl/test/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/util/test/CMakeLists.txt @@ -13,6 +13,6 @@ set(PYTHON_SOURCES debug_msg.py ) -add_python_package("python.ecl.test" ${PYTHON_INSTALL_PREFIX}/ecl/test "${PYTHON_SOURCES}" True) +add_python_package("python.ecl.util.test" ${PYTHON_INSTALL_PREFIX}/ecl/util/test "${PYTHON_SOURCES}" True) add_subdirectory(ecl_mock) diff --git a/ThirdParty/Ert/python/python/ecl/test/__init__.py b/ThirdParty/Ert/python/ecl/util/test/__init__.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/__init__.py rename to ThirdParty/Ert/python/ecl/util/test/__init__.py diff --git a/ThirdParty/Ert/python/python/ecl/test/debug_msg.py b/ThirdParty/Ert/python/ecl/util/test/debug_msg.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/debug_msg.py rename to ThirdParty/Ert/python/ecl/util/test/debug_msg.py diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt new file mode 100644 index 0000000000..c9fcd038c2 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/CMakeLists.txt @@ -0,0 +1,6 @@ +set(PYTHON_SOURCES + __init__.py + ecl_sum_mock.py +) + +add_python_package("python.ecl.util.test.ecl_mock" ${PYTHON_INSTALL_PREFIX}/ecl/util/test/ecl_mock "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/__init__.py b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/__init__.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/ecl_mock/__init__.py rename to ThirdParty/Ert/python/ecl/util/test/ecl_mock/__init__.py diff --git a/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py new file mode 100644 index 0000000000..9fc8b7a8b1 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/test/ecl_mock/ecl_sum_mock.py @@ -0,0 +1,50 @@ +import datetime +from ecl.summary import EclSum + + +def mock_func(ecl_sum , key , days): + return days * 10 + + +def createEclSum( case, + keys, + sim_start = datetime.date(2010 , 1, 1), + data_start = None, + sim_length_days = 5 * 365, + num_report_step = 5, + num_mini_step = 10, + dims = (20,10,5) , + func_table = {}, + restart_case = None, + restart_step = -1): + + ecl_sum = EclSum.restart_writer(case , restart_case, restart_step, sim_start , dims[0] , dims[1] , dims[2]) + var_list = [] + for (kw,wgname,num,unit) in keys: + var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num, unit =unit) ) + + # This is a bug! This should not be integer division, but tests are written + # around that assumption. + report_step_length = float(sim_length_days // num_report_step) + mini_step_length = float(report_step_length // num_mini_step) + + if data_start is None: + time_offset = 0 + else: + dt = data_start - sim_start + time_offset = dt.total_seconds() / 86400.0 + + for report_step in range(num_report_step): + for mini_step in range(num_mini_step): + days = time_offset + report_step * report_step_length + mini_step * mini_step_length + t_step = ecl_sum.addTStep( report_step + 1 , sim_days = days ) + + for var in var_list: + key = var.getKey1( ) + if key in func_table: + func = func_table[key] + t_step[key] = func( days ) + else: + t_step[key] = mock_func( ecl_sum , key , days) + + return ecl_sum diff --git a/ThirdParty/Ert/python/python/ecl/test/ert_test_context.py b/ThirdParty/Ert/python/ecl/util/test/ert_test_context.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/ert_test_context.py rename to ThirdParty/Ert/python/ecl/util/test/ert_test_context.py diff --git a/ThirdParty/Ert/python/python/ecl/test/ert_test_runner.py b/ThirdParty/Ert/python/ecl/util/test/ert_test_runner.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/ert_test_runner.py rename to ThirdParty/Ert/python/ecl/util/test/ert_test_runner.py diff --git a/ThirdParty/Ert/python/python/ecl/test/extended_testcase.py b/ThirdParty/Ert/python/ecl/util/test/extended_testcase.py similarity index 74% rename from ThirdParty/Ert/python/python/ecl/test/extended_testcase.py rename to ThirdParty/Ert/python/ecl/util/test/extended_testcase.py index 70bf73f918..7f71f31969 100644 --- a/ThirdParty/Ert/python/python/ecl/test/extended_testcase.py +++ b/ThirdParty/Ert/python/ecl/util/test/extended_testcase.py @@ -10,22 +10,23 @@ from unittest import TestCase from .source_enumerator import SourceEnumerator -from ecl.util import installAbortSignals -from ecl.util import Version +from ecl.util.util import installAbortSignals +from ecl.util.util import Version + + +# Function wrapper which can be used to add decorator @log_test to test +# methods. When a test has been decorated with @log_test it will print +# "starting: " when a method is complete and "complete: " +# when the method is complete. Convenient when debugging tests which fail hard +# or lock up. + +def log_test(test): + def wrapper(*args): + sys.stderr.write("starting: %s \n" % test.__name__) + test(*args) + sys.stderr.write("complete: %s \n" % test.__name__) + return wrapper -TESTDATA_ROOT = None -SHARE_ROOT = None -SOURCE_ROOT = None -BUILD_ROOT = None -try: - from test_env import * - assert( os.path.isdir( TESTDATA_ROOT )) - assert( os.path.isdir( SOURCE_ROOT )) - assert( os.path.isdir( BUILD_ROOT )) - if not SHARE_ROOT is None: - assert( os.path.isdir( SHARE_ROOT )) -except ImportError: - sys.stderr.write("Warning: could not import file test_env.py - this might lead to test failures.") class _AssertNotRaisesContext(object): @@ -51,18 +52,20 @@ def __exit__(self, exc_type, exc_value, tb): This class provides some extra functionality for testing values that are almost equal. """ class ExtendedTestCase(TestCase): + TESTDATA_ROOT = None + SHARE_ROOT = None + SOURCE_ROOT = None + + def __init__(self , *args , **kwargs): - self.__testdata_root = None - self.__share_root = None installAbortSignals() super(ExtendedTestCase , self).__init__(*args , **kwargs) def __str__(self): - return 'ExtendedTestCase( TESTADATA_ROOT=%s, SOURCE_ROOT=%s, SHARE_ROOT=%s, BUILD_ROOT=%s)' % (TESTDATA_ROOT, - SOURCE_ROOT, - SHARE_ROOT, - BUILD_ROOT) + return 'ExtendedTestCase( TESTADATA_ROOT=%s, SOURCE_ROOT=%s, SHARE_ROOT=%s)' % (self.TESTDATA_ROOT, + self.SOURCE_ROOT, + self.SHARE_ROOT) def assertFloatEqual(self, first, second, msg=None, tolerance=1e-6): try: @@ -125,31 +128,38 @@ def assertDirectoryDoesNotExist(self, path): self.fail("The directory: %s exists!" % path) def __filesAreEqual(self, first, second): - buffer1 = open(first).read() - buffer2 = open(second).read() + buffer1 = open(first, "rb").read() + buffer2 = open(second, "rb").read() return buffer1 == buffer2 def assertEnumIsFullyDefined(self, enum_class, enum_name, source_path, verbose=False): - enum_values = SourceEnumerator.findEnumerators(enum_name, os.path.join( SOURCE_ROOT , source_path)) + if self.SOURCE_ROOT is None: + raise Exception("SOURCE_ROOT is not set.") + + enum_values = SourceEnumerator.findEnumerators(enum_name, os.path.join( self.SOURCE_ROOT , source_path)) for identifier, value in enum_values: if verbose: print("%s = %d" % (identifier, value)) - self.assertTrue(enum_class.__dict__.has_key(identifier), "Enum does not have identifier: %s" % identifier) + self.assertTrue(identifier in enum_class.__dict__, "Enum does not have identifier: %s" % identifier) class_value = enum_class.__dict__[identifier] self.assertEqual(class_value, value, "Enum value for identifier: %s does not match: %s != %s" % (identifier, class_value, value)) - @staticmethod - def createSharePath(path): - return os.path.realpath(os.path.join(SHARE_ROOT , path)) + @classmethod + def createSharePath(cls, path): + if cls.SHARE_ROOT is None: + raise Exception("Trying to create directory rooted in 'SHARE_ROOT' - variable 'SHARE_ROOT' is not set.") + return os.path.realpath(os.path.join(cls.SHARE_ROOT , path)) - @staticmethod - def createTestPath(path): - return os.path.realpath(os.path.join(TESTDATA_ROOT , path)) + @classmethod + def createTestPath(cls, path): + if cls.TESTDATA_ROOT is None: + raise Exception("Trying to create directory rooted in 'TESTDATA_ROOT' - variable 'TESTDATA_ROOT' has not been set.") + return os.path.realpath(os.path.join(cls.TESTDATA_ROOT , path)) def assertNotRaises(self, func=None): diff --git a/ThirdParty/Ert/python/python/ecl/test/import_test_case.py b/ThirdParty/Ert/python/ecl/util/test/import_test_case.py similarity index 96% rename from ThirdParty/Ert/python/python/ecl/test/import_test_case.py rename to ThirdParty/Ert/python/ecl/util/test/import_test_case.py index 761b029018..13b940d49b 100644 --- a/ThirdParty/Ert/python/python/ecl/test/import_test_case.py +++ b/ThirdParty/Ert/python/ecl/util/test/import_test_case.py @@ -23,16 +23,19 @@ import imp class ImportTestCase(unittest.TestCase): - + def import_file(self, path): return imp.load_source( "module", path) - + def import_module(self , module): mod = importlib.import_module( module ) return mod - + def import_package(self, package): + if "__" in package: + return True module = self.import_module( package ) + path = os.path.dirname( inspect.getfile( module ) ) for entry in sorted(os.listdir(path)): diff --git a/ThirdParty/Ert/python/python/ecl/test/lint_test_case.py b/ThirdParty/Ert/python/ecl/util/test/lint_test_case.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/lint_test_case.py rename to ThirdParty/Ert/python/ecl/util/test/lint_test_case.py diff --git a/ThirdParty/Ert/python/python/ecl/test/path_context.py b/ThirdParty/Ert/python/ecl/util/test/path_context.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/path_context.py rename to ThirdParty/Ert/python/ecl/util/test/path_context.py diff --git a/ThirdParty/Ert/python/python/ecl/test/source_enumerator.py b/ThirdParty/Ert/python/ecl/util/test/source_enumerator.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/source_enumerator.py rename to ThirdParty/Ert/python/ecl/util/test/source_enumerator.py diff --git a/ThirdParty/Ert/python/python/ecl/test/temp_area.py b/ThirdParty/Ert/python/ecl/util/test/temp_area.py similarity index 90% rename from ThirdParty/Ert/python/python/ecl/test/temp_area.py rename to ThirdParty/Ert/python/ecl/util/test/temp_area.py index 4679eed017..4b7d2aa697 100644 --- a/ThirdParty/Ert/python/python/ecl/test/temp_area.py +++ b/ThirdParty/Ert/python/ecl/util/test/temp_area.py @@ -16,7 +16,7 @@ import os import os.path -from ecl.util import UtilPrototype +from ecl import EclPrototype from . import TestArea class TempArea(TestArea): @@ -25,8 +25,8 @@ class TempArea(TestArea): created area. """ - _temp_area_alloc = UtilPrototype("void* temp_area_alloc( char* )" , bind = False) - _temp_area_alloc_relative = UtilPrototype("void* temp_area_alloc_relative( char* , char* )" , bind = False) + _temp_area_alloc = EclPrototype("void* temp_area_alloc( char* )" , bind = False) + _temp_area_alloc_relative = EclPrototype("void* temp_area_alloc_relative( char* , char* )" , bind = False) def __init__(self, name, prefix = None , store_area=False): if prefix: diff --git a/ThirdParty/Ert/python/python/ecl/test/test_area.py b/ThirdParty/Ert/python/ecl/util/test/test_area.py similarity index 68% rename from ThirdParty/Ert/python/python/ecl/test/test_area.py rename to ThirdParty/Ert/python/ecl/util/test/test_area.py index 0d2cb1cf57..22089bd86c 100644 --- a/ThirdParty/Ert/python/python/ecl/test/test_area.py +++ b/ThirdParty/Ert/python/ecl/util/test/test_area.py @@ -1,39 +1,39 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# Copyright (C) 2013 Statoil ASA, Norway. +# +# The file 'test_work_area.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 # for more details. import os.path from cwrap import BaseCClass -from ecl.util import UtilPrototype +from ecl import EclPrototype class TestArea(BaseCClass): - _test_area_alloc = UtilPrototype("void* test_work_area_alloc( char* )" , bind = False) - _test_area_alloc_relative = UtilPrototype("void* test_work_area_alloc_relative( char* , char* )" , bind = False) - _free = UtilPrototype("void test_work_area_free( test_area )") - _install_file = UtilPrototype("void test_work_area_install_file( test_area , char* )") - _copy_directory = UtilPrototype("void test_work_area_copy_directory( test_area , char* )") - _copy_file = UtilPrototype("void test_work_area_copy_file( test_area , char* )") - _copy_directory_content = UtilPrototype("void test_work_area_copy_directory_content( test_area , char* )") - _copy_parent_directory = UtilPrototype("void test_work_area_copy_parent_directory( test_area , char* )") - _copy_parent_content = UtilPrototype("void test_work_area_copy_parent_content( test_area , char* )") - _get_cwd = UtilPrototype("char* test_work_area_get_cwd( test_area )") - _get_original_cwd = UtilPrototype("char* test_work_area_get_original_cwd( test_area )") - _set_store = UtilPrototype("void test_work_area_set_store( test_area , bool)") - _sync = UtilPrototype("void test_work_area_sync( test_area )") - + _test_area_alloc = EclPrototype("void* test_work_area_alloc( char* )" , bind = False) + _test_area_alloc_relative = EclPrototype("void* test_work_area_alloc_relative( char* , char* )" , bind = False) + _free = EclPrototype("void test_work_area_free( test_area )") + _install_file = EclPrototype("void test_work_area_install_file( test_area , char* )") + _copy_directory = EclPrototype("void test_work_area_copy_directory( test_area , char* )") + _copy_file = EclPrototype("void test_work_area_copy_file( test_area , char* )") + _copy_directory_content = EclPrototype("void test_work_area_copy_directory_content( test_area , char* )") + _copy_parent_directory = EclPrototype("void test_work_area_copy_parent_directory( test_area , char* )") + _copy_parent_content = EclPrototype("void test_work_area_copy_parent_content( test_area , char* )") + _get_cwd = EclPrototype("char* test_work_area_get_cwd( test_area )") + _get_original_cwd = EclPrototype("char* test_work_area_get_original_cwd( test_area )") + _set_store = EclPrototype("void test_work_area_set_store( test_area , bool)") + _sync = EclPrototype("void test_work_area_sync( test_area )") + def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): if c_ptr is None: @@ -48,7 +48,7 @@ def __init__(self, test_name, prefix = None , store_area=False , c_ptr = None): super(TestArea, self).__init__(c_ptr) self.set_store( store_area ) - + def get_original_cwd(self): return self._get_original_cwd() @@ -60,7 +60,7 @@ def orgPath(self , path): return path else: return os.path.abspath( os.path.join( self.get_original_cwd( ) , path ) ) - + # All the methods install_file() , copy_directory(), # copy_parent_directory(), copy_parent_content(), @@ -86,7 +86,7 @@ def copy_parent_directory( self , path): else: raise IOError("No such file or directory: %s" % path) - + def copy_parent_content( self , path): if os.path.exists( self.orgPath(path) ): self._copy_parent_content(path) @@ -99,22 +99,22 @@ def copy_directory_content( self, directory): else: raise IOError("No such directory: %s" % directory ) - + def copy_file( self, filename): if os.path.isfile( self.orgPath(filename) ): self._copy_file(filename) else: raise IOError("No such file:%s" % filename) - + def free(self): self._free() - + def set_store(self, store): self._set_store(store) - + def getFullPath(self , path): if not os.path.exists( path ): raise IOError("Path not found:%s" % path) @@ -127,8 +127,8 @@ def getFullPath(self , path): def sync(self): return self._sync( ) - - + + class TestAreaContext(object): def __init__(self, test_name, prefix = None , store_area=False): @@ -145,5 +145,7 @@ def __enter__(self): def __exit__(self, exc_type, exc_val, exc_tb): + self.test_area.free() # free the TestData object (and cd back to the original dir) + self.test_area.free = None # avoid double free del self.test_area return False diff --git a/ThirdParty/Ert/python/python/ecl/test/test_run.py b/ThirdParty/Ert/python/ecl/util/test/test_run.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/test/test_run.py rename to ThirdParty/Ert/python/ecl/util/test/test_run.py diff --git a/ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt b/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt similarity index 60% rename from ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt index 2a950d6958..8374950ce2 100644 --- a/ThirdParty/Ert/python/python/ecl/util/CMakeLists.txt +++ b/ThirdParty/Ert/python/ecl/util/util/CMakeLists.txt @@ -1,33 +1,24 @@ set(PYTHON_SOURCES __init__.py bool_vector.py - buffer.py ctime.py double_vector.py hash.py int_vector.py install_abort_signals.py - log.py lookup_table.py - matrix.py - profiler.py rng.py - stat.py stringlist.py #substitution_list.py thread_pool.py - cthread_pool.py time_vector.py - ui_return.py util_func.py vector_template.py permutation_vector.py version.py arg_pack.py - path_format.py cwd_context.py ) -add_python_package("python.ecl.util" ${PYTHON_INSTALL_PREFIX}/ecl/util "${PYTHON_SOURCES}" True) +add_python_package("python.ecl.util.util" ${PYTHON_INSTALL_PREFIX}/ecl/util/util "${PYTHON_SOURCES}" True) -add_subdirectory(enums) diff --git a/ThirdParty/Ert/python/python/ecl/util/__init__.py b/ThirdParty/Ert/python/ecl/util/util/__init__.py similarity index 86% rename from ThirdParty/Ert/python/python/ecl/util/__init__.py rename to ThirdParty/Ert/python/ecl/util/util/__init__.py index 6519f170c8..feccb678d1 100644 --- a/ThirdParty/Ert/python/python/ecl/util/__init__.py +++ b/ThirdParty/Ert/python/ecl/util/util/__init__.py @@ -43,17 +43,10 @@ from cwrap import Prototype -class UtilPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True, allow_attribute_error=False): - super(UtilPrototype, self).__init__(UtilPrototype.lib, prototype, bind=bind, allow_attribute_error=allow_attribute_error) - - from .version import Version, EclVersion -from .enums import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum +from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum from .ctime import CTime @@ -65,19 +58,11 @@ def __init__(self, prototype, bind=True, allow_attribute_error=False): from .time_vector import TimeVector from .stringlist import StringList from .rng import RandomNumberGenerator -from .matrix import Matrix -from .stat import quantile, quantile_sorted, polyfit -from .log import Log from .lookup_table import LookupTable -from .buffer import Buffer from .hash import Hash, StringHash, DoubleHash, IntegerHash -from .ui_return import UIReturn from .thread_pool import ThreadPool -from .cthread_pool import CThreadPool, startCThreadPool from .install_abort_signals import installAbortSignals, updateAbortSignals -from .profiler import Profiler from .arg_pack import ArgPack -from .path_format import PathFormat from .cwd_context import CWDContext diff --git a/ThirdParty/Ert/python/python/ecl/util/arg_pack.py b/ThirdParty/Ert/python/ecl/util/util/arg_pack.py similarity index 76% rename from ThirdParty/Ert/python/python/ecl/util/arg_pack.py rename to ThirdParty/Ert/python/ecl/util/util/arg_pack.py index e20bd3fe99..4b53e03b18 100644 --- a/ThirdParty/Ert/python/python/ecl/util/arg_pack.py +++ b/ThirdParty/Ert/python/ecl/util/util/arg_pack.py @@ -15,19 +15,19 @@ # for more details. from cwrap import BaseCClass -from ecl.util import UtilPrototype +from ecl import EclPrototype class ArgPack(BaseCClass): TYPE_NAME = "arg_pack" - _alloc = UtilPrototype("void* arg_pack_alloc()" , bind = False) - _append_int = UtilPrototype("void arg_pack_append_int(arg_pack, int)") - _append_double = UtilPrototype("void arg_pack_append_double(arg_pack, double)") - _append_ptr = UtilPrototype("void arg_pack_append_ptr(arg_pack, void*)") + _alloc = EclPrototype("void* arg_pack_alloc()" , bind = False) + _append_int = EclPrototype("void arg_pack_append_int(arg_pack, int)") + _append_double = EclPrototype("void arg_pack_append_double(arg_pack, double)") + _append_ptr = EclPrototype("void arg_pack_append_ptr(arg_pack, void*)") - _size = UtilPrototype("int arg_pack_size(arg_pack)") - _free = UtilPrototype("void arg_pack_free(arg_pack)") + _size = EclPrototype("int arg_pack_size(arg_pack)") + _free = EclPrototype("void arg_pack_free(arg_pack)") def __init__(self, *args): c_ptr = self._alloc() diff --git a/ThirdParty/Ert/python/ecl/util/util/bool_vector.py b/ThirdParty/Ert/python/ecl/util/util/bool_vector.py new file mode 100644 index 0000000000..d688562682 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/bool_vector.py @@ -0,0 +1,154 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate + + +class BoolVector(VectorTemplate): + default_format = "%8d" + + _alloc = EclPrototype("void* bool_vector_alloc( int , bool )" , bind = False) + _create_active_mask = EclPrototype("bool_vector_obj string_util_alloc_active_mask( char* )" , bind = False) + _active_list = EclPrototype("int_vector_obj bool_vector_alloc_active_list(bool_vector)", bind = False) + _alloc_copy = EclPrototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )") + _update_active_mask = EclPrototype("bool string_util_update_active_mask(char*, bool_vector)" , bind = False) + + _strided_copy = EclPrototype("bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)") + _free = EclPrototype("void bool_vector_free( bool_vector )") + _iget = EclPrototype("bool bool_vector_iget( bool_vector , int )") + _safe_iget = EclPrototype("bool bool_vector_safe_iget( bool_vector , int )") + _iset = EclPrototype("void bool_vector_iset( bool_vector , int , bool)") + _size = EclPrototype("int bool_vector_size( bool_vector )") + _append = EclPrototype("void bool_vector_append( bool_vector , bool )") + _idel_block = EclPrototype("void bool_vector_idel_block( bool_vector , bool , bool )") + _idel = EclPrototype("void bool_vector_idel( bool_vector , int )") + _pop = EclPrototype("bool bool_vector_pop( bool_vector )") + _lshift = EclPrototype("void bool_vector_lshift( bool_vector , int )") + _rshift = EclPrototype("void bool_vector_rshift( bool_vector , int )") + _insert = EclPrototype("void bool_vector_insert( bool_vector , int , bool)") + _fprintf = EclPrototype("void bool_vector_fprintf( bool_vector , FILE , char* , char*)") + _sort = EclPrototype("void bool_vector_sort( bool_vector )") + _rsort = EclPrototype("void bool_vector_rsort( bool_vector )") + _reset = EclPrototype("void bool_vector_reset( bool_vector )") + _set_read_only = EclPrototype("void bool_vector_set_read_only( bool_vector , bool )") + _get_read_only = EclPrototype("bool bool_vector_get_read_only( bool_vector )") + _get_max = EclPrototype("bool bool_vector_get_max( bool_vector )") + _get_min = EclPrototype("bool bool_vector_get_min( bool_vector )") + _get_max_index = EclPrototype("int bool_vector_get_max_index( bool_vector , bool)") + _get_min_index = EclPrototype("int bool_vector_get_min_index( bool_vector , bool)") + _shift = EclPrototype("void bool_vector_shift( bool_vector , bool )") + _scale = EclPrototype("void bool_vector_scale( bool_vector , bool )") + _div = EclPrototype("void bool_vector_div( bool_vector , bool )") + _inplace_add = EclPrototype("void bool_vector_inplace_add( bool_vector , bool_vector )") + _inplace_mul = EclPrototype("void bool_vector_inplace_mul( bool_vector , bool_vector )") + _assign = EclPrototype("void bool_vector_set_all( bool_vector , bool)") + _memcpy = EclPrototype("void bool_vector_memcpy(bool_vector , bool_vector )") + _set_default = EclPrototype("void bool_vector_set_default( bool_vector , bool)") + _get_default = EclPrototype("bool bool_vector_get_default( bool_vector )") + _element_size = EclPrototype("int bool_vector_element_size( bool_vector )") + + _permute = EclPrototype("void bool_vector_permute(bool_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj bool_vector_alloc_sort_perm(bool_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj bool_vector_alloc_rsort_perm(bool_vector)") + + _contains = EclPrototype("bool bool_vector_contains(bool_vector, bool)") + _select_unique = EclPrototype("void bool_vector_select_unique(bool_vector)") + _element_sum = EclPrototype("bool bool_vector_sum(bool_vector)") + _get_data_ptr = EclPrototype("bool* bool_vector_get_ptr(bool_vector)") + _count_equal = EclPrototype("int bool_vector_count_equal(bool_vector, bool)") + _init_linear = None + _equal = EclPrototype("bool bool_vector_equal(bool_vector, bool_vector)") + _first_eq = EclPrototype("int bool_vector_first_equal(bool_vector, bool_vector, int)") + _first_neq = EclPrototype("int bool_vector_first_not_equal(bool_vector, bool_vector, int)") + + + def __init__(self, default_value=False, initial_size=0): + super(BoolVector, self).__init__(default_value, initial_size) + + def count(self, value=True): + """ @rtype: int """ + return self._count_equal(self, value) + + @classmethod + def createActiveMask(cls, range_string): + """ + Will create a BoolVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {F,T,F,F,T,T,T,T,F,F,T} + "1,4-7,10X" => {} + + The empty list will evaluate to false + @rtype: BoolVector + """ + return cls._create_active_mask(range_string) + + def updateActiveMask(self, range_string): + """ + Updates a bool vector based on a range string. + @type range_string: str + @type bool_vector: BoolVector + @rtype: bool + """ + return self._update_active_mask(range_string , self) + + @classmethod + def createFromList(cls, size, source_list): + """ + Allocates a bool vector from a Python list of indexes + @rtype: BoolVector + """ + bool_vector = BoolVector(False, size) + + for index in source_list: + index = int(index) + bool_vector[index] = True + + return bool_vector + + def createActiveList(self): + """ @rtype: ecl.util.IntVector """ + return self._active_list(self) + + def _tostr(self, arr = None): + if arr is None: + arr = self + return "".join(['1' if x else '0' for x in arr]) + + def __repr__(self): + """Will return BoolVector(size = 4, content = "0010") at 0x1729 and + if size > 10, will return content = "0001...100", i.e., |content|<=10. + """ + cnt = '' + ls = len(self) + if ls <= 20: + cnt = self._tostr() + else: + a,b = self[:9], self[-8:] + cnt = self._tostr(a) + cnt += "..." + cnt += self._tostr(b) + return 'BoolVector(size = %d, content = "%s") %s' % (ls, cnt, self._ad_str()) + + + @classmethod + def create_linear(cls, start_value, end_value, num_values): + raise NotImplementedError("The init_linear method does not make sense for bool vectors") diff --git a/ThirdParty/Ert/python/python/ecl/util/cthread_pool.py b/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py similarity index 72% rename from ThirdParty/Ert/python/python/ecl/util/cthread_pool.py rename to ThirdParty/Ert/python/ecl/util/util/cthread_pool.py index 5c5824b2b7..39d8c3be91 100644 --- a/ThirdParty/Ert/python/python/ecl/util/cthread_pool.py +++ b/ThirdParty/Ert/python/ecl/util/util/cthread_pool.py @@ -1,32 +1,34 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'cthread_pool.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'cthread_pool.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. import ctypes from cwrap import BaseCClass -from ecl.util import UtilPrototype +from ecl import EclPrototype + +import weakref class CThreadPool(BaseCClass): TYPE_NAME = "thread_pool" - _alloc = UtilPrototype("void* thread_pool_alloc(int, bool)", bind = False) - _free = UtilPrototype("void thread_pool_free(thread_pool)") - _add_job = UtilPrototype("void thread_pool_add_job(thread_pool, void*, void*)") - _join = UtilPrototype("void thread_pool_join(thread_pool)") + _alloc = EclPrototype("void* thread_pool_alloc(int, bool)", bind = False) + _free = EclPrototype("void thread_pool_free(thread_pool)") + _add_job = EclPrototype("void thread_pool_add_job(thread_pool, void*, void*)") + _join = EclPrototype("void thread_pool_join(thread_pool)") def __init__(self, pool_size, start=True): c_ptr = self._alloc(pool_size, start) @@ -35,9 +37,10 @@ def __init__(self, pool_size, start=True): def addTaskFunction(self, name, lib, c_function_name): function = CThreadPool.lookupCFunction(lib, c_function_name) + self_ref = weakref.ref(self) # avoid circular dependencies def wrappedFunction(arg): - return self.addTask(function, arg) + return self_ref().addTask(function, arg) setattr(self, name, wrappedFunction) diff --git a/ThirdParty/Ert/python/python/ecl/util/ctime.py b/ThirdParty/Ert/python/ecl/util/util/ctime.py similarity index 95% rename from ThirdParty/Ert/python/python/ecl/util/ctime.py rename to ThirdParty/Ert/python/ecl/util/util/ctime.py index 04d7d42e2a..0c92ecd893 100644 --- a/ThirdParty/Ert/python/python/ecl/util/ctime.py +++ b/ThirdParty/Ert/python/ecl/util/util/ctime.py @@ -20,14 +20,14 @@ import time from cwrap import BaseCValue -from ecl.util import UtilPrototype +from ecl import EclPrototype class CTime(BaseCValue): TYPE_NAME = "time_t" DATA_TYPE = ctypes.c_long - _timezone = UtilPrototype("char* util_get_timezone()" , bind = False) - _timegm = UtilPrototype("long util_make_datetime_utc(int, int, int, int, int, int)" , bind = False) + _timezone = EclPrototype("char* util_get_timezone()" , bind = False) + _timegm = EclPrototype("long util_make_datetime_utc(int, int, int, int, int, int)" , bind = False) def __init__(self, value): if isinstance(value, int): diff --git a/ThirdParty/Ert/python/python/ecl/util/cwd_context.py b/ThirdParty/Ert/python/ecl/util/util/cwd_context.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/util/cwd_context.py rename to ThirdParty/Ert/python/ecl/util/util/cwd_context.py diff --git a/ThirdParty/Ert/python/ecl/util/util/double_vector.py b/ThirdParty/Ert/python/ecl/util/util/double_vector.py new file mode 100644 index 0000000000..9ba7100958 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/double_vector.py @@ -0,0 +1,77 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'double_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate + + +class DoubleVector(VectorTemplate): + default_format = "%8.4f" + + _alloc = EclPrototype("void* double_vector_alloc( int , double )" , bind = False) + _alloc_copy = EclPrototype("double_vector_obj double_vector_alloc_copy( double_vector )") + _strided_copy = EclPrototype("double_vector_obj double_vector_alloc_strided_copy( double_vector , int , int , int)") + _free = EclPrototype("void double_vector_free( double_vector )") + _iget = EclPrototype("double double_vector_iget( double_vector , int )") + _safe_iget = EclPrototype("double double_vector_safe_iget(double_vector , int )") + _iset = EclPrototype("double double_vector_iset( double_vector , int , double)") + _size = EclPrototype("int double_vector_size( double_vector )") + _append = EclPrototype("void double_vector_append( double_vector , double )") + _idel_block = EclPrototype("void double_vector_idel_block( double_vector , int , int )") + _pop = EclPrototype("double double_vector_pop( double_vector )") + _idel = EclPrototype("void double_vector_idel( double_vector , int )") + _lshift = EclPrototype("void double_vector_lshift( double_vector , int )") + _rshift = EclPrototype("void double_vector_rshift( double_vector , int )") + _insert = EclPrototype("void double_vector_insert( double_vector , int , double)") + _fprintf = EclPrototype("void double_vector_fprintf( double_vector , FILE , char* , char*)") + _sort = EclPrototype("void double_vector_sort( double_vector )") + _rsort = EclPrototype("void double_vector_rsort( double_vector )") + _reset = EclPrototype("void double_vector_reset( double_vector )") + _get_read_only = EclPrototype("bool double_vector_get_read_only( double_vector )") + _set_read_only = EclPrototype("void double_vector_set_read_only( double_vector , bool )") + _get_max = EclPrototype("double double_vector_get_max( double_vector )") + _get_min = EclPrototype("double double_vector_get_min( double_vector )") + _get_max_index = EclPrototype("int double_vector_get_max_index( double_vector , bool)") + _get_min_index = EclPrototype("int double_vector_get_min_index( double_vector , bool)") + _shift = EclPrototype("void double_vector_shift( double_vector , double )") + _scale = EclPrototype("void double_vector_scale( double_vector , double )") + _div = EclPrototype("void double_vector_div( double_vector , double )") + _inplace_add = EclPrototype("void double_vector_inplace_add( double_vector , double_vector )") + _inplace_mul = EclPrototype("void double_vector_inplace_mul( double_vector , double_vector )") + _assign = EclPrototype("void double_vector_set_all( double_vector , double)") + _memcpy = EclPrototype("void double_vector_memcpy(double_vector , double_vector )") + _set_default = EclPrototype("void double_vector_set_default( double_vector , double)") + _get_default = EclPrototype("double double_vector_get_default( double_vector )") + _element_size = EclPrototype("int double_vector_element_size( double_vector )") + + _permute = EclPrototype("void double_vector_permute(double_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj double_vector_alloc_sort_perm(double_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj double_vector_alloc_rsort_perm(double_vector)") + _contains = EclPrototype("bool double_vector_contains(double_vector, double)") + _select_unique = EclPrototype("void double_vector_select_unique(double_vector)") + _element_sum = EclPrototype("double double_vector_sum(double_vector)") + _get_data_ptr = EclPrototype("double* double_vector_get_ptr(double_vector)") + _count_equal = EclPrototype("int double_vector_count_equal(double_vector, double)") + _init_range = EclPrototype("void double_vector_init_range(double_vector, double , double , double)") + _init_linear = EclPrototype("bool double_vector_init_linear(double_vector, double, double, int)") + _equal = EclPrototype("bool double_vector_equal(double_vector, double_vector)") + _first_eq = EclPrototype("int double_vector_first_equal(double_vector, double_vector, int)") + _first_neq = EclPrototype("int double_vector_first_not_equal(double_vector, double_vector, int)") + + + + def __init__(self, default_value=0, initial_size=0): + super(DoubleVector, self).__init__(default_value, initial_size) diff --git a/ThirdParty/Ert/python/python/ecl/util/hash.py b/ThirdParty/Ert/python/ecl/util/util/hash.py similarity index 77% rename from ThirdParty/Ert/python/python/ecl/util/hash.py rename to ThirdParty/Ert/python/ecl/util/util/hash.py index bd2a18289d..3edc600763 100644 --- a/ThirdParty/Ert/python/python/ecl/util/hash.py +++ b/ThirdParty/Ert/python/ecl/util/util/hash.py @@ -16,17 +16,18 @@ from ctypes import c_void_p from cwrap import BaseCClass -from ecl.util import StringList, UtilPrototype +from ecl import EclPrototype +from ecl.util.util import StringList class Hash(BaseCClass): - _alloc = UtilPrototype("void* hash_alloc()" , bind = False) - _free = UtilPrototype("void hash_free(hash)") - _size = UtilPrototype("int hash_get_size(hash)") - _keys = UtilPrototype("stringlist_obj hash_alloc_stringlist(hash)") - _has_key = UtilPrototype("bool hash_has_key(hash, char*)") - _get = UtilPrototype("void* hash_get(hash, char*)") - _insert_ref = UtilPrototype("void hash_insert_ref(hash, char*, void*)") + _alloc = EclPrototype("void* hash_alloc()" , bind = False) + _free = EclPrototype("void hash_free(hash)") + _size = EclPrototype("int hash_get_size(hash)") + _keys = EclPrototype("stringlist_obj hash_alloc_stringlist(hash)") + _has_key = EclPrototype("bool hash_has_key(hash, char*)") + _get = EclPrototype("void* hash_get(hash, char*)") + _insert_ref = EclPrototype("void hash_insert_ref(hash, char*, void*)") """ Base hash class that supports string:void* values @@ -71,8 +72,8 @@ def __str__(self): class StringHash(Hash): - _get_string = UtilPrototype("char* hash_get_string(hash, char*)") - _insert_string = UtilPrototype("void hash_insert_string(hash, char*, char*)") + _get_string = EclPrototype("char* hash_get_string(hash, char*)") + _insert_string = EclPrototype("void hash_insert_string(hash, char*, char*)") def __init__(self): super(StringHash, self).__init__() @@ -91,8 +92,8 @@ def __getitem__(self, key): class IntegerHash(Hash): - _get_int = UtilPrototype("int hash_get_int(hash, char*)") - _insert_int = UtilPrototype("void hash_insert_int(hash, char*, int)") + _get_int = EclPrototype("int hash_get_int(hash, char*)") + _insert_int = EclPrototype("void hash_insert_int(hash, char*, int)") def __init__(self): super(IntegerHash, self).__init__() @@ -111,8 +112,8 @@ def __getitem__(self, key): class DoubleHash(Hash): - _get_double = UtilPrototype("double hash_get_double(hash, char*)") - _insert_double = UtilPrototype("void hash_insert_double(hash, char*, double)") + _get_double = EclPrototype("double hash_get_double(hash, char*)") + _insert_double = EclPrototype("void hash_insert_double(hash, char*, double)") def __init__(self): super(DoubleHash, self).__init__() diff --git a/ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py b/ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py similarity index 53% rename from ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py rename to ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py index 59cddabe75..70b9a22be0 100644 --- a/ThirdParty/Ert/python/python/ecl/util/install_abort_signals.py +++ b/ThirdParty/Ert/python/ecl/util/util/install_abort_signals.py @@ -1,4 +1,4 @@ -from ecl.util import UtilPrototype +from ecl import EclPrototype def installAbortSignals(): @@ -12,5 +12,5 @@ def updateAbortSignals(): update_signals() -install_signals = UtilPrototype("void util_install_signals()") -update_signals = UtilPrototype("void util_update_signals()") +install_signals = EclPrototype("void util_install_signals()") +update_signals = EclPrototype("void util_update_signals()") diff --git a/ThirdParty/Ert/python/ecl/util/util/int_vector.py b/ThirdParty/Ert/python/ecl/util/util/int_vector.py new file mode 100644 index 0000000000..f280603df8 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/int_vector.py @@ -0,0 +1,113 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'int_vector.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate + + +class IntVector(VectorTemplate): + default_format = "%d" + + _alloc = EclPrototype("void* int_vector_alloc( int , int )" , bind = False) + _create_active_list = EclPrototype("int_vector_obj string_util_alloc_active_list( char*)" , bind = False) + _create_value_list = EclPrototype("int_vector_obj string_util_alloc_value_list( char*)" , bind = False) + _alloc_copy = EclPrototype("int_vector_obj int_vector_alloc_copy( int_vector )") + _strided_copy = EclPrototype("int_vector_obj int_vector_alloc_strided_copy( int_vector , int , int , int)") + _free = EclPrototype("void int_vector_free( int_vector )") + _iget = EclPrototype("int int_vector_iget( int_vector , int )") + _safe_iget = EclPrototype("int int_vector_safe_iget( int_vector , int )") + _iset = EclPrototype("int int_vector_iset( int_vector , int , int)") + _size = EclPrototype("int int_vector_size( int_vector )") + _append = EclPrototype("void int_vector_append( int_vector , int )") + _idel_block = EclPrototype("void int_vector_idel_block( int_vector , int , int )") + _pop = EclPrototype("int int_vector_pop( int_vector )") + _idel = EclPrototype("void int_vector_idel( int_vector , int )") + _insert = EclPrototype("void int_vector_insert( int_vector , int , int)") + _lshift = EclPrototype("void int_vector_lshift( int_vector , int )") + _rshift = EclPrototype("void int_vector_rshift( int_vector , int )") + _fprintf = EclPrototype("void int_vector_fprintf( int_vector , FILE , char* , char*)") + _sort = EclPrototype("void int_vector_sort( int_vector )") + _rsort = EclPrototype("void int_vector_rsort( int_vector )") + _reset = EclPrototype("void int_vector_reset( int_vector )") + _set_read_only = EclPrototype("void int_vector_set_read_only( int_vector , bool )") + _get_read_only = EclPrototype("bool int_vector_get_read_only( int_vector )") + _get_max = EclPrototype("int int_vector_get_max( int_vector )") + _get_min = EclPrototype("int int_vector_get_min( int_vector )") + _get_max_index = EclPrototype("int int_vector_get_max_index( int_vector , bool)") + _get_min_index = EclPrototype("int int_vector_get_min_index( int_vector , bool)") + _shift = EclPrototype("void int_vector_shift( int_vector , int )") + _scale = EclPrototype("void int_vector_scale( int_vector , int )") + _div = EclPrototype("void int_vector_div( int_vector , int )") + _inplace_add = EclPrototype("void int_vector_inplace_add( int_vector , int_vector )") + _inplace_mul = EclPrototype("void int_vector_inplace_mul( int_vector , int_vector )") + _assign = EclPrototype("void int_vector_set_all( int_vector , int)") + _memcpy = EclPrototype("void int_vector_memcpy(int_vector , int_vector )") + _set_default = EclPrototype("void int_vector_set_default( int_vector , int)") + _get_default = EclPrototype("int int_vector_get_default( int_vector )") + _element_size = EclPrototype("int int_vector_element_size( int_vector )") + + _permute = EclPrototype("void int_vector_permute(int_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj int_vector_alloc_sort_perm(int_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj int_vector_alloc_rsort_perm(int_vector)") + _contains = EclPrototype("bool int_vector_contains(int_vector, int)") + _select_unique = EclPrototype("void int_vector_select_unique(int_vector)") + _element_sum = EclPrototype("int int_vector_sum(int_vector)") + _get_data_ptr = EclPrototype("int* int_vector_get_ptr(int_vector)") + _count_equal = EclPrototype("int int_vector_count_equal(int_vector, int)") + _init_range = EclPrototype("void int_vector_init_range(int_vector, int , int , int)") + _init_linear = EclPrototype("bool int_vector_init_linear(int_vector, int, int, int)") + _equal = EclPrototype("bool int_vector_equal(int_vector, int_vector)") + _first_eq = EclPrototype("int int_vector_first_equal(int_vector, int_vector, int)") + _first_neq = EclPrototype("int int_vector_first_not_equal(int_vector, int_vector, int)") + + def __init__(self, default_value=0, initial_size=0): + super(IntVector, self).__init__(default_value, initial_size) + + @classmethod + def active_list(cls, range_string): + """Will create a IntVector instance with the values from @range_string. + + The range_string input should be of the type "1,3-5,9,17", + i.e. integer values separated by commas, and dashes to + represent ranges. If the input string contains ANY invalid + characters the returned active list will be empty: + + "1,4-7,10" => {1,4,5,6,7,10} + "1,4-7,10X" => {} + + The empty list will evaluate to false. The values in the input + string are meant to indicate "active values", i.e. the output + values are sorted and repeated values are only counted once: + + "1,1,7,2" => {1,2,7} + + """ + return cls._create_active_list(range_string) + + @classmethod + def valueList(cls , range_string): + """Will create a IntVecter of all the values in the @range_string. + + Will not sort the values, and not uniquiefy - in contrast to + the active_list() method. + + """ + return cls._create_value_list(range_string) + + + def count(self, value): + """ @rtype: int """ + return self._count_equal(value) diff --git a/ThirdParty/Ert/python/python/ecl/util/lookup_table.py b/ThirdParty/Ert/python/ecl/util/util/lookup_table.py similarity index 71% rename from ThirdParty/Ert/python/python/ecl/util/lookup_table.py rename to ThirdParty/Ert/python/ecl/util/util/lookup_table.py index 6497a8273c..4d01ba8732 100644 --- a/ThirdParty/Ert/python/python/ecl/util/lookup_table.py +++ b/ThirdParty/Ert/python/ecl/util/util/lookup_table.py @@ -16,23 +16,23 @@ from cwrap import BaseCClass -from ecl.util import UtilPrototype +from ecl import EclPrototype class LookupTable(BaseCClass): - _alloc = UtilPrototype("void* lookup_table_alloc_empty()" , bind = False) - _max = UtilPrototype("double lookup_table_get_max_value( lookup_table )") - _min = UtilPrototype("double lookup_table_get_min_value( lookup_table )") - _arg_max = UtilPrototype("double lookup_table_get_max_arg( lookup_table )") - _arg_min = UtilPrototype("double lookup_table_get_min_arg( lookup_table )") - _append = UtilPrototype("void lookup_table_append( lookup_table , double , double )") - _size = UtilPrototype("int lookup_table_get_size( lookup_table )") - _interp = UtilPrototype("double lookup_table_interp( lookup_table , double)") - _free = UtilPrototype("void lookup_table_free( lookup_table )") - _set_low_limit = UtilPrototype("void lookup_table_set_low_limit( lookup_table , double)") - _set_high_limit = UtilPrototype("void lookup_table_set_high_limit( lookup_table , double)") - _has_low_limit = UtilPrototype("bool lookup_table_has_low_limit( lookup_table)") - _has_high_limit = UtilPrototype("bool lookup_table_has_high_limit( lookup_table)") + _alloc = EclPrototype("void* lookup_table_alloc_empty()" , bind = False) + _max = EclPrototype("double lookup_table_get_max_value( lookup_table )") + _min = EclPrototype("double lookup_table_get_min_value( lookup_table )") + _arg_max = EclPrototype("double lookup_table_get_max_arg( lookup_table )") + _arg_min = EclPrototype("double lookup_table_get_min_arg( lookup_table )") + _append = EclPrototype("void lookup_table_append( lookup_table , double , double )") + _size = EclPrototype("int lookup_table_get_size( lookup_table )") + _interp = EclPrototype("double lookup_table_interp( lookup_table , double)") + _free = EclPrototype("void lookup_table_free( lookup_table )") + _set_low_limit = EclPrototype("void lookup_table_set_low_limit( lookup_table , double)") + _set_high_limit = EclPrototype("void lookup_table_set_high_limit( lookup_table , double)") + _has_low_limit = EclPrototype("bool lookup_table_has_low_limit( lookup_table)") + _has_high_limit = EclPrototype("bool lookup_table_has_high_limit( lookup_table)") def __init__(self, lower_limit=None, upper_limit=None): super(LookupTable, self).__init__(self._alloc()) diff --git a/ThirdParty/Ert/python/python/ecl/util/matrix.py b/ThirdParty/Ert/python/ecl/util/util/matrix.py similarity index 77% rename from ThirdParty/Ert/python/python/ecl/util/matrix.py rename to ThirdParty/Ert/python/ecl/util/util/matrix.py index cfb99f7046..160763987c 100644 --- a/ThirdParty/Ert/python/python/ecl/util/matrix.py +++ b/ThirdParty/Ert/python/ecl/util/util/matrix.py @@ -29,36 +29,39 @@ from cwrap import BaseCClass,CFILE -from ecl.util import UtilPrototype +from ecl import EclPrototype class Matrix(BaseCClass): - _matrix_alloc = UtilPrototype("void* matrix_alloc(int, int )" , bind = False) - _matrix_alloc_identity = UtilPrototype("matrix_obj matrix_alloc_identity( int )" , bind = False) - _alloc_transpose = UtilPrototype("matrix_obj matrix_alloc_transpose(matrix)") - _inplace_transpose = UtilPrototype("void matrix_inplace_transpose(matrix)") - _copy = UtilPrototype("matrix_obj matrix_alloc_copy(matrix)" ) - _sub_copy = UtilPrototype("matrix_obj matrix_alloc_sub_copy(matrix, int , int , int , int)" ) - _free = UtilPrototype("void matrix_free(matrix)") - _iget = UtilPrototype("double matrix_iget( matrix , int , int )") - _iset = UtilPrototype("void matrix_iset( matrix , int , int , double)") - _set_all = UtilPrototype("void matrix_scalar_set( matrix , double)") - _scale_column = UtilPrototype("void matrix_scale_column(matrix , int , double)") - _scale_row = UtilPrototype("void matrix_scale_row(matrix , int , double)") - _copy_column = UtilPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False) - _rows = UtilPrototype("int matrix_get_rows(matrix)") - _columns = UtilPrototype("int matrix_get_columns(matrix)") - _equal = UtilPrototype("bool matrix_equal(matrix, matrix)") - _pretty_print = UtilPrototype("void matrix_pretty_print(matrix, char*, char*)") - _fprint = UtilPrototype("void matrix_fprintf(matrix, char*, FILE)") - _random_init = UtilPrototype("void matrix_random_init(matrix, rng)") - _dump_csv = UtilPrototype("void matrix_dump_csv(matrix, char*)") + _matrix_alloc = EclPrototype("void* matrix_alloc(int, int )" , bind = False) + _matrix_alloc_identity = EclPrototype("matrix_obj matrix_alloc_identity( int )" , bind = False) + _alloc_transpose = EclPrototype("matrix_obj matrix_alloc_transpose(matrix)") + _inplace_transpose = EclPrototype("void matrix_inplace_transpose(matrix)") + _copy = EclPrototype("matrix_obj matrix_alloc_copy(matrix)" ) + _sub_copy = EclPrototype("matrix_obj matrix_alloc_sub_copy(matrix, int , int , int , int)" ) + _free = EclPrototype("void matrix_free(matrix)") + _iget = EclPrototype("double matrix_iget( matrix , int , int )") + _iset = EclPrototype("void matrix_iset( matrix , int , int , double)") + _set_all = EclPrototype("void matrix_scalar_set( matrix , double)") + _scale_column = EclPrototype("void matrix_scale_column(matrix , int , double)") + _scale_row = EclPrototype("void matrix_scale_row(matrix , int , double)") + _copy_column = EclPrototype("void matrix_copy_column(matrix , matrix , int , int)" , bind = False) + _rows = EclPrototype("int matrix_get_rows(matrix)") + _columns = EclPrototype("int matrix_get_columns(matrix)") + _equal = EclPrototype("bool matrix_equal(matrix, matrix)") + _pretty_print = EclPrototype("void matrix_pretty_print(matrix, char*, char*)") + _fprint = EclPrototype("void matrix_fprintf(matrix, char*, FILE)") + _random_init = EclPrototype("void matrix_random_init(matrix, rng)") + _dump_csv = EclPrototype("void matrix_dump_csv(matrix, char*)") # Requires BLAS. If the library does not have the # matrix_alloc_matmul() function the prototype will have _func = # None, and NotImplementedError( ) will be raised int the # __call__() method if we try to use this function. - _alloc_matmul = UtilPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False, allow_attribute_error = True) + try: + _alloc_matmul = EclPrototype("matrix_obj matrix_alloc_matmul(matrix, matrix)" , bind = False) + except AttributeError: + _alloc_matmul = None # Requires BLAS! @classmethod diff --git a/ThirdParty/Ert/python/python/ecl/util/permutation_vector.py b/ThirdParty/Ert/python/ecl/util/util/permutation_vector.py similarity index 71% rename from ThirdParty/Ert/python/python/ecl/util/permutation_vector.py rename to ThirdParty/Ert/python/ecl/util/util/permutation_vector.py index dabbd3788f..92291ceb4c 100644 --- a/ThirdParty/Ert/python/python/ecl/util/permutation_vector.py +++ b/ThirdParty/Ert/python/ecl/util/util/permutation_vector.py @@ -1,12 +1,12 @@ from cwrap import BaseCClass -from ecl.util import UtilPrototype +from ecl import EclPrototype class PermutationVector(BaseCClass): TYPE_NAME = "permutation_vector" - _free = UtilPrototype("void perm_vector_free( permutation_vector )") - _size = UtilPrototype("int perm_vector_get_size( permutation_vector )") - _iget = UtilPrototype("int perm_vector_iget( permutation_vector , int)") + _free = EclPrototype("void perm_vector_free( permutation_vector )") + _size = EclPrototype("int perm_vector_get_size( permutation_vector )") + _iget = EclPrototype("int perm_vector_iget( permutation_vector , int)") def __init__(self): diff --git a/ThirdParty/Ert/python/python/ecl/util/rng.py b/ThirdParty/Ert/python/ecl/util/util/rng.py similarity index 77% rename from ThirdParty/Ert/python/python/ecl/util/rng.py rename to ThirdParty/Ert/python/ecl/util/util/rng.py index a747d31887..e03af1c3f2 100644 --- a/ThirdParty/Ert/python/python/ecl/util/rng.py +++ b/ThirdParty/Ert/python/ecl/util/util/rng.py @@ -16,22 +16,22 @@ import os.path from cwrap import BaseCClass -from ecl.util import UtilPrototype +from ecl import EclPrototype from ecl.util.enums import RngInitModeEnum, RngAlgTypeEnum class RandomNumberGenerator(BaseCClass): TYPE_NAME = "rng" - _rng_alloc = UtilPrototype("void* rng_alloc(rng_alg_type_enum, rng_init_mode_enum)" , bind = False) - _free = UtilPrototype("void rng_free(rng)") - _get_double = UtilPrototype("double rng_get_double(rng)") - _get_int = UtilPrototype("int rng_get_int(rng, int)") - _get_max_int = UtilPrototype("uint rng_get_max_int(rng)") - _state_size = UtilPrototype("int rng_state_size(rng)") - _set_state = UtilPrototype("void rng_set_state(rng , char*)") - _load_state = UtilPrototype("void rng_load_state(rng , char*)") - _save_state = UtilPrototype("void rng_save_state(rng , char*)") + _rng_alloc = EclPrototype("void* rng_alloc(rng_alg_type_enum, rng_init_mode_enum)" , bind = False) + _free = EclPrototype("void rng_free(rng)") + _get_double = EclPrototype("double rng_get_double(rng)") + _get_int = EclPrototype("int rng_get_int(rng, int)") + _get_max_int = EclPrototype("uint rng_get_max_int(rng)") + _state_size = EclPrototype("int rng_state_size(rng)") + _set_state = EclPrototype("void rng_set_state(rng , char*)") + _load_state = EclPrototype("void rng_load_state(rng , char*)") + _save_state = EclPrototype("void rng_save_state(rng , char*)") def __init__(self, alg_type=RngAlgTypeEnum.MZRAN, init_mode=RngInitModeEnum.INIT_CLOCK): assert isinstance(alg_type, RngAlgTypeEnum) diff --git a/ThirdParty/Ert/python/python/ecl/util/stringlist.py b/ThirdParty/Ert/python/ecl/util/util/stringlist.py similarity index 88% rename from ThirdParty/Ert/python/python/ecl/util/stringlist.py rename to ThirdParty/Ert/python/ecl/util/util/stringlist.py index f4e22b03c6..fcdc185d88 100644 --- a/ThirdParty/Ert/python/python/ecl/util/stringlist.py +++ b/ThirdParty/Ert/python/ecl/util/util/stringlist.py @@ -32,28 +32,28 @@ """ from __future__ import absolute_import, division, print_function, unicode_literals from six import string_types -from ecl.util import UtilPrototype +from ecl import EclPrototype from cwrap import BaseCClass class StringList(BaseCClass): TYPE_NAME = "stringlist" - _alloc = UtilPrototype("void* stringlist_alloc_new( )", bind = False) - _free = UtilPrototype("void stringlist_free(stringlist )") - _append = UtilPrototype("void stringlist_append_copy(stringlist , char* )") - _iget = UtilPrototype("char* stringlist_iget(stringlist , int )") - _front = UtilPrototype("char* stringlist_front( stringlist )") - _back = UtilPrototype("char* stringlist_back( stringlist )") - _iget_copy = UtilPrototype("char* stringlist_iget_copy(stringlist, int)") - _iset = UtilPrototype("void stringlist_iset_copy( stringlist , int , char* )") - _get_size = UtilPrototype("int stringlist_get_size( stringlist )") - _contains = UtilPrototype("bool stringlist_contains(stringlist , char*)") - _equal = UtilPrototype("bool stringlist_equal(stringlist , stringlist)") - _sort = UtilPrototype("void stringlist_python_sort( stringlist , int)") - _pop = UtilPrototype("char* stringlist_pop(stringlist)") - _last = UtilPrototype("char* stringlist_get_last(stringlist)") - _find_first = UtilPrototype("int stringlist_find_first(stringlist, char*)") + _alloc = EclPrototype("void* stringlist_alloc_new( )", bind = False) + _free = EclPrototype("void stringlist_free(stringlist )") + _append = EclPrototype("void stringlist_append_copy(stringlist , char* )") + _iget = EclPrototype("char* stringlist_iget(stringlist , int )") + _front = EclPrototype("char* stringlist_front( stringlist )") + _back = EclPrototype("char* stringlist_back( stringlist )") + _iget_copy = EclPrototype("char* stringlist_iget_copy(stringlist, int)") + _iset = EclPrototype("void stringlist_iset_copy( stringlist , int , char* )") + _get_size = EclPrototype("int stringlist_get_size( stringlist )") + _contains = EclPrototype("bool stringlist_contains(stringlist , char*)") + _equal = EclPrototype("bool stringlist_equal(stringlist , stringlist)") + _sort = EclPrototype("void stringlist_python_sort( stringlist , int)") + _pop = EclPrototype("char* stringlist_pop(stringlist)") + _last = EclPrototype("char* stringlist_get_last(stringlist)") + _find_first = EclPrototype("int stringlist_find_first(stringlist, char*)") def __init__(self, initial=None): """ diff --git a/ThirdParty/Ert/python/python/ecl/util/thread_pool.py b/ThirdParty/Ert/python/ecl/util/util/thread_pool.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/util/thread_pool.py rename to ThirdParty/Ert/python/ecl/util/util/thread_pool.py diff --git a/ThirdParty/Ert/python/ecl/util/util/time_vector.py b/ThirdParty/Ert/python/ecl/util/util/time_vector.py new file mode 100644 index 0000000000..cffcb411f8 --- /dev/null +++ b/ThirdParty/Ert/python/ecl/util/util/time_vector.py @@ -0,0 +1,177 @@ +# Copyright (C) 2014 Statoil ASA, Norway. +# +# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. +import datetime +import re + +from ecl import EclPrototype +from ecl.util.util import VectorTemplate, CTime + + +class TimeVector(VectorTemplate): + TYPE_NAME = "time_t_vector" + default_format = "%d" + + _alloc = EclPrototype("void* time_t_vector_alloc(int, time_t )" , bind = False) + _alloc_copy = EclPrototype("time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )") + _strided_copy = EclPrototype("time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , int , int , int)") + _free = EclPrototype("void time_t_vector_free( time_t_vector )") + _iget = EclPrototype("time_t time_t_vector_iget( time_t_vector , int )") + _safe_iget = EclPrototype("time_t time_t_vector_safe_iget( time_t_vector , int )") + _iset = EclPrototype("time_t time_t_vector_iset( time_t_vector , int , time_t)") + _size = EclPrototype("int time_t_vector_size( time_t_vector )") + _append = EclPrototype("void time_t_vector_append( time_t_vector , time_t )") + _idel_block = EclPrototype("void time_t_vector_idel_block( time_t_vector , int , int )") + _idel = EclPrototype("void time_t_vector_idel( time_t_vector , int )") + _pop = EclPrototype("time_t time_t_vector_pop( time_t_vector )") + _lshift = EclPrototype("void time_t_vector_lshift( time_t_vector , int )") + _rshift = EclPrototype("void time_t_vector_rshift( time_t_vector , int )") + _insert = EclPrototype("void time_t_vector_insert( time_t_vector , int , time_t)") + _fprintf = EclPrototype("void time_t_vector_fprintf( time_t_vector , FILE , char* , char*)") + _sort = EclPrototype("void time_t_vector_sort( time_t_vector )") + _rsort = EclPrototype("void time_t_vector_rsort( time_t_vector )") + _reset = EclPrototype("void time_t_vector_reset( time_t_vector )") + _set_read_only = EclPrototype("void time_t_vector_set_read_only( time_t_vector , bool )") + _get_read_only = EclPrototype("bool time_t_vector_get_read_only( time_t_vector )") + _get_max = EclPrototype("time_t time_t_vector_get_max( time_t_vector )") + _get_min = EclPrototype("time_t time_t_vector_get_min( time_t_vector )") + _get_max_index = EclPrototype("int time_t_vector_get_max_index( time_t_vector , bool)") + _get_min_index = EclPrototype("int time_t_vector_get_min_index( time_t_vector , bool)") + _shift = EclPrototype("void time_t_vector_shift( time_t_vector , time_t )") + _scale = EclPrototype("void time_t_vector_scale( time_t_vector , time_t )") + _div = EclPrototype("void time_t_vector_div( time_t_vector , time_t )") + _inplace_add = EclPrototype("void time_t_vector_inplace_add( time_t_vector , time_t_vector )") + _inplace_mul = EclPrototype("void time_t_vector_inplace_mul( time_t_vector , time_t_vector )") + _assign = EclPrototype("void time_t_vector_set_all( time_t_vector , time_t)") + _memcpy = EclPrototype("void time_t_vector_memcpy(time_t_vector , time_t_vector )") + _set_default = EclPrototype("void time_t_vector_set_default( time_t_vector , time_t)") + _get_default = EclPrototype("time_t time_t_vector_get_default( time_t_vector )") + _element_size = EclPrototype("int time_t_vector_element_size( time_t_vector )") + + _permute = EclPrototype("void time_t_vector_permute(time_t_vector, permutation_vector)") + _sort_perm = EclPrototype("permutation_vector_obj time_t_vector_alloc_sort_perm(time_t_vector)") + _rsort_perm = EclPrototype("permutation_vector_obj time_t_vector_alloc_rsort_perm(time_t_vector)") + _contains = EclPrototype("bool time_t_vector_contains(time_t_vector, time_t)") + _select_unique = EclPrototype("void time_t_vector_select_unique(time_t_vector)") + _element_sum = EclPrototype("time_t time_t_vector_sum(time_t_vector)") + _count_equal = EclPrototype("int time_t_vector_count_equal(time_t_vector, time_t)") + _init_range = EclPrototype("void time_t_vector_init_range(time_t_vector, time_t , time_t , time_t)") + _init_linear = EclPrototype("bool time_t_vector_init_linear(time_t_vector, time_t, time_t, int)") + _equal = EclPrototype("bool time_t_vector_equal(time_t_vector, time_t_vector)") + _first_eq = EclPrototype("int time_t_vector_first_equal(time_t_vector, time_t_vector, int)") + _first_neq = EclPrototype("int time_t_vector_first_not_equal(time_t_vector, time_t_vector, int)") + + + + def __init__(self, default_value=None, initial_size=0): + if default_value is None: + super(TimeVector, self).__init__(CTime(0), initial_size) + else: + try: + default = CTime(default_value) + except: + raise ValueError("default value invalid - must be type ctime() or date/datetime") + + super(TimeVector, self).__init__(default, initial_size) + + @classmethod + def parseTimeUnit(cls, deltaString): + deltaRegexp = re.compile("(?P\d*)(?P[dmy])", re.IGNORECASE) + matchObj = deltaRegexp.match(deltaString) + if matchObj: + try: + num = int(matchObj.group("num")) + except: + num = 1 + + timeUnit = matchObj.group("unit").lower() + return num, timeUnit + else: + raise TypeError("The delta string must be on form \'1d\', \'2m\', \'Y\' for one day, two months or one year respectively") + + def __str__(self): + """ + Returns string representantion of vector. + """ + string_list = [] + for d in self: + string_list.append("%s" % d) + + return str(string_list) + + def append(self, value): + self._append(CTime(value)) + + def __contains__(self, value): + return self._contains(CTime(value)) + + def nextTime(self, num, timeUnit): + currentTime = self[-1].datetime() + hour = currentTime.hour + minute = currentTime.minute + second = currentTime.second + + if timeUnit == "d": + td = datetime.timedelta(days=num) + currentTime += td + else: + day = currentTime.day + month = currentTime.month + year = currentTime.year + + if timeUnit == "y": + year += num + else: + month += num - 1 + (deltaYear, newMonth) = divmod(month, 12) + month = newMonth + 1 + year += deltaYear + currentTime = datetime.datetime(year, month, day, hour, minute, second) + + return currentTime + + def appendTime(self, num, timeUnit): + next = self.nextTime(num, timeUnit) + self.append(CTime(next)) + + @classmethod + def createRegular(cls, start, end, deltaString): + """ + The last element in the vector will be <= end; i.e. if the + question of whether the range is closed in the upper end + depends on the commensurability of the [start,end] interval + and the delta: + + createRegular(0 , 10 , delta=3) => [0,3,6,9] + createRegular(0 , 10 , delta=2) => [0,2,4,6,8,10] + """ + start = CTime(start) + end = CTime(end) + if start > end: + raise ValueError("The time interval is invalid start is after end") + + (num, timeUnit) = cls.parseTimeUnit(deltaString) + + timeVector = TimeVector() + currentTime = start + while currentTime <= end: + ct = CTime(currentTime) + timeVector.append(ct) + currentTime = timeVector.nextTime(num, timeUnit) + + return timeVector + + def getDataPtr(self): + raise NotImplementedError("The getDataPtr() function is not implemented for time_t vectors") diff --git a/ThirdParty/Ert/python/python/ecl/util/util_func.py b/ThirdParty/Ert/python/ecl/util/util/util_func.py similarity index 90% rename from ThirdParty/Ert/python/python/ecl/util/util_func.py rename to ThirdParty/Ert/python/ecl/util/util/util_func.py index 0d9e4aa2ac..cb7cf236d6 100644 --- a/ThirdParty/Ert/python/python/ecl/util/util_func.py +++ b/ThirdParty/Ert/python/ecl/util/util/util_func.py @@ -17,9 +17,9 @@ Module with utility functions from util.c """ -from ecl.util import UtilPrototype +from ecl import EclPrototype -strcmp_int = UtilPrototype("int util_strcmp_int( char* , char* )") +strcmp_int = EclPrototype("int util_strcmp_int( char* , char* )") """ Function to compare strings with embedded integers. @@ -45,7 +45,7 @@ @type: (str, str) -> int """ -strcmp_float = UtilPrototype("int util_strcmp_float( char* , char* )") +strcmp_float = EclPrototype("int util_strcmp_float( char* , char* )") """ Function to compare strings with embedded numbers. diff --git a/ThirdParty/Ert/python/python/ecl/util/vector_template.py b/ThirdParty/Ert/python/ecl/util/util/vector_template.py similarity index 93% rename from ThirdParty/Ert/python/python/ecl/util/vector_template.py rename to ThirdParty/Ert/python/ecl/util/util/vector_template.py index 56b96c582b..ca4d1a506a 100644 --- a/ThirdParty/Ert/python/python/ecl/util/vector_template.py +++ b/ThirdParty/Ert/python/ecl/util/util/vector_template.py @@ -1,18 +1,18 @@ # Copyright (C) 2014 Statoil ASA, Norway. -# +# # The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. +# +# ERT 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. +# +# ERT 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 +# for more details. """ Typed vectors IntVector, DoubleVector and BoolVector. @@ -22,7 +22,7 @@ vec = IntVector( default_value = 66 ) vec[0] = 10 - vec[2] = 10 + vec[2] = 10 After the 'vec[2] = 10' statement the vector has grown to contain three elements. The element vec[1] has not been explicitly assigned by @@ -34,7 +34,7 @@ will give '66'. The main part of the implementation is in terms of an "abstract base class" TVector. The TVector class should be not instantiated directly, instead the child classes IntVector, -DoubleVector or BoolVector should be used. +DoubleVector or BoolVector should be used. The C-level has implementations for several fundamental types like float and size_t not currently implemented in the Python version. @@ -45,9 +45,8 @@ import sys from cwrap import CFILE, BaseCClass -from ecl.util import UtilPrototype - + class VectorTemplate(BaseCClass): @@ -84,7 +83,30 @@ def __bool__(self): def __nonzero__(self): return self.__bool__( ) - + + + def __eq__(self, other): + return self._equal(other) + + + def __ne__(self,other): + return not self.__eq__(other) + + def first_eq(self, other, offset = 0): + index = self._first_eq(other, offset) + if index <= -2: + raise ValueError("Invalid offset") + + return index + + + def first_neq(self, other, offset = 0): + index = self._first_neq(other, offset) + if index <= -2: + raise ValueError("Invalid offset") + + return index + def copy(self): """ @@ -98,7 +120,7 @@ def __irshift__(self,shift): raise ValueError("The shift must be positive") self._rshift(shift) return self - + def __ilshift__(self,shift): if shift < 0: raise ValueError("The shift must be positive") @@ -130,7 +152,7 @@ def __init__(self, default_value=0, initial_size=0): c_pointer = self._alloc(initial_size, default_value) super(VectorTemplate, self).__init__(c_pointer) self.element_size = self._element_size() - + def __contains__(self , value): return self._contains( value) @@ -140,7 +162,7 @@ def pop(self): return self._pop() else: raise ValueError("Trying to pop from empty vector") - + def str_data(self, width, index1, index2, fmt): """ @@ -243,7 +265,7 @@ def __IADD(self, delta, add): Low-level function implementing inplace add. The __IADD__ function implements the operation: - + v += a The variable which is added, i.e. @delta, can either be of the @@ -258,7 +280,7 @@ def __IADD(self, delta, add): """ if type(self) == type(delta): if len(self) == len(delta): - # This is vector + vector operation. + # This is vector + vector operation. if not add: delta *= -1 self._inplace_add(delta) @@ -356,15 +378,23 @@ def __mul__(self, factor): def __rmul__(self, factor): return self.__mul__(factor) - def __div__(self, divisor): if isinstance(divisor, int) or isinstance(divisor, float): - copy = self._alloc_copy( ) + copy = self._alloc_copy() copy._div(divisor) return copy else: raise TypeError("Divisor has wrong type:%s" % type(divisor)) + def __truediv__(self, divisor): + return self.__div__(divisor) + + def __idiv__(self, divisor): + return self.__div__(divisor) + + def __itruediv__(self, divisor): + return self.__div__(divisor) + # End mathematical operations ################################################################# @@ -380,7 +410,7 @@ def assign(self, value): v1 = IntVector() v2 = IntVector() - + v1[10] = 77 v2.assign( v1 ) # Now v2 contains identicall content to v1 .... @@ -453,7 +483,7 @@ def append(self, value): def deleteBlock(self, index, block_size): """ Remove a block of size @block_size starting at @index. - + After the removal data will be left shifted. """ self._idel_block(index, block_size) @@ -520,7 +550,7 @@ def asList(self): l = [0] * len(self) for (index,value) in enumerate(self): l[index] = value - + return l def selectUnique(self): @@ -552,6 +582,16 @@ def initRange(self , min_value , max_value , delta): else: self._init_range( min_value , max_value , delta ) + + @classmethod + def create_linear(cls, start_value, end_value, num_values): + vector = cls() + if not vector._init_linear(start_value, end_value, num_values): + raise ValueError("init_linear arguments invalid") + + return vector + + @classmethod def createRange(cls , min_value , max_value , delta): """ diff --git a/ThirdParty/Ert/python/python/ecl/util/version.py b/ThirdParty/Ert/python/ecl/util/util/version.py similarity index 84% rename from ThirdParty/Ert/python/python/ecl/util/version.py rename to ThirdParty/Ert/python/ecl/util/util/version.py index dbbc66c74d..95df9f0fd5 100644 --- a/ThirdParty/Ert/python/python/ecl/util/version.py +++ b/ThirdParty/Ert/python/ecl/util/util/version.py @@ -1,4 +1,4 @@ -from ecl.util import UtilPrototype +from ecl import EclPrototype def cmp_method(method): @@ -99,12 +99,12 @@ def getGitCommit(self, short=False): class EclVersion(Version): - _build_time = UtilPrototype("char* ecl_version_get_build_time()") - _git_commit = UtilPrototype("char* ecl_version_get_git_commit()") - _major_version = UtilPrototype("int ecl_version_get_major_version()") - _minor_version = UtilPrototype("int ecl_version_get_minor_version()") - _micro_version = UtilPrototype("char* ecl_version_get_micro_version()") - _is_devel = UtilPrototype("bool ecl_version_is_devel_version()") + _build_time = EclPrototype("char* ecl_version_get_build_time()", bind = False) + _git_commit = EclPrototype("char* ecl_version_get_git_commit()", bind = False) + _major_version = EclPrototype("int ecl_version_get_major_version()", bind = False) + _minor_version = EclPrototype("int ecl_version_get_minor_version()", bind = False) + _micro_version = EclPrototype("char* ecl_version_get_micro_version()", bind = False) + _is_devel = EclPrototype("bool ecl_version_is_devel_version()", bind = False) def __init__(self): major = self._major_version( ) diff --git a/ThirdParty/Ert/python/python/ecl/well/CMakeLists.txt b/ThirdParty/Ert/python/ecl/well/CMakeLists.txt similarity index 100% rename from ThirdParty/Ert/python/python/ecl/well/CMakeLists.txt rename to ThirdParty/Ert/python/ecl/well/CMakeLists.txt diff --git a/ThirdParty/Ert/python/python/ecl/well/__init__.py b/ThirdParty/Ert/python/ecl/well/__init__.py similarity index 58% rename from ThirdParty/Ert/python/python/ecl/well/__init__.py rename to ThirdParty/Ert/python/ecl/well/__init__.py index 8616443f30..979df95428 100644 --- a/ThirdParty/Ert/python/python/ecl/well/__init__.py +++ b/ThirdParty/Ert/python/ecl/well/__init__.py @@ -1,16 +1,9 @@ import ecl -import ecl.util -import ecl.geo -import ecl.ecl +import ecl.util.util +import ecl.util.geometry from cwrap import Prototype -class WellPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True): - super(WellPrototype, self).__init__(WellPrototype.lib, prototype, bind=bind) - from .well_type_enum import WellTypeEnum from .well_connection_direction_enum import WellConnectionDirectionEnum from .well_connection import WellConnection diff --git a/ThirdParty/Ert/python/python/ecl/well/well_connection.py b/ThirdParty/Ert/python/ecl/well/well_connection.py similarity index 55% rename from ThirdParty/Ert/python/python/ecl/well/well_connection.py rename to ThirdParty/Ert/python/ecl/well/well_connection.py index 8dc86af3ac..522d19ee0c 100644 --- a/ThirdParty/Ert/python/python/ecl/well/well_connection.py +++ b/ThirdParty/Ert/python/ecl/well/well_connection.py @@ -1,29 +1,30 @@ from cwrap import BaseCClass -from ecl.well import WellPrototype, WellConnectionDirectionEnum +from ecl import EclPrototype +from ecl.well import WellConnectionDirectionEnum class WellConnection(BaseCClass): TYPE_NAME = "well_connection" - _i = WellPrototype("int well_conn_get_i(well_connection)") - _j = WellPrototype("int well_conn_get_j(well_connection)") - _k = WellPrototype("int well_conn_get_k(well_connection)") - _segment_id = WellPrototype("int well_conn_get_segment_id(well_connection)") - _is_open = WellPrototype("bool well_conn_open(well_connection)") - _is_msw = WellPrototype("bool well_conn_MSW(well_connection)") - _fracture_connection = WellPrototype("bool well_conn_fracture_connection(well_connection)") - _matrix_connection = WellPrototype("bool well_conn_matrix_connection(well_connection)") - _connection_factor = WellPrototype("double well_conn_get_connection_factor(well_connection)") - _equal = WellPrototype("bool well_conn_equal(well_connection, well_connection)") - _get_dir = WellPrototype("void* well_conn_get_dir(well_connection)") - _oil_rate = WellPrototype("double well_conn_get_oil_rate(well_connection)") - _gas_rate = WellPrototype("double well_conn_get_gas_rate(well_connection)") - _water_rate = WellPrototype("double well_conn_get_water_rate(well_connection)") - _volume_rate = WellPrototype("double well_conn_get_volume_rate(well_connection)") - - _oil_rate_si = WellPrototype("double well_conn_get_oil_rate_si(well_connection)") - _gas_rate_si = WellPrototype("double well_conn_get_gas_rate_si(well_connection)") - _water_rate_si = WellPrototype("double well_conn_get_water_rate_si(well_connection)") - _volume_rate_si = WellPrototype("double well_conn_get_volume_rate_si(well_connection)") + _i = EclPrototype("int well_conn_get_i(well_connection)") + _j = EclPrototype("int well_conn_get_j(well_connection)") + _k = EclPrototype("int well_conn_get_k(well_connection)") + _segment_id = EclPrototype("int well_conn_get_segment_id(well_connection)") + _is_open = EclPrototype("bool well_conn_open(well_connection)") + _is_msw = EclPrototype("bool well_conn_MSW(well_connection)") + _fracture_connection = EclPrototype("bool well_conn_fracture_connection(well_connection)") + _matrix_connection = EclPrototype("bool well_conn_matrix_connection(well_connection)") + _connection_factor = EclPrototype("double well_conn_get_connection_factor(well_connection)") + _equal = EclPrototype("bool well_conn_equal(well_connection, well_connection)") + _get_dir = EclPrototype("void* well_conn_get_dir(well_connection)") + _oil_rate = EclPrototype("double well_conn_get_oil_rate(well_connection)") + _gas_rate = EclPrototype("double well_conn_get_gas_rate(well_connection)") + _water_rate = EclPrototype("double well_conn_get_water_rate(well_connection)") + _volume_rate = EclPrototype("double well_conn_get_volume_rate(well_connection)") + + _oil_rate_si = EclPrototype("double well_conn_get_oil_rate_si(well_connection)") + _gas_rate_si = EclPrototype("double well_conn_get_gas_rate_si(well_connection)") + _water_rate_si = EclPrototype("double well_conn_get_water_rate_si(well_connection)") + _volume_rate_si = EclPrototype("double well_conn_get_volume_rate_si(well_connection)") def __init__(self): raise NotImplementedError("Class can not be instantiated directly") @@ -64,6 +65,9 @@ def connectionFactor(self): def __eq__(self, other): return self._equal(other) + def __hash__(self): + return id(self) + def __ne__(self, other): return not self == other diff --git a/ThirdParty/Ert/python/python/ecl/well/well_connection_direction_enum.py b/ThirdParty/Ert/python/ecl/well/well_connection_direction_enum.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/well/well_connection_direction_enum.py rename to ThirdParty/Ert/python/ecl/well/well_connection_direction_enum.py diff --git a/ThirdParty/Ert/python/python/ecl/well/well_info.py b/ThirdParty/Ert/python/ecl/well/well_info.py similarity index 80% rename from ThirdParty/Ert/python/python/ecl/well/well_info.py rename to ThirdParty/Ert/python/ecl/well/well_info.py index 3ec514854c..938341ace0 100644 --- a/ThirdParty/Ert/python/python/ecl/well/well_info.py +++ b/ThirdParty/Ert/python/ecl/well/well_info.py @@ -16,22 +16,23 @@ from os.path import isfile from cwrap import BaseCClass -from ecl.ecl import EclGrid -from ecl.ecl.ecl_file import EclFile -from ecl.well import WellTimeLine, WellPrototype +from ecl.grid import EclGrid +from ecl.eclfile.ecl_file import EclFile +from ecl.well import WellTimeLine +from ecl import EclPrototype class WellInfo(BaseCClass): TYPE_NAME = "well_info" - _alloc = WellPrototype("void* well_info_alloc(ecl_grid)", bind = False) - _free = WellPrototype("void well_info_free(well_info)") - _load_rstfile = WellPrototype("void well_info_load_rstfile(well_info, char*, bool)") - _load_rst_eclfile = WellPrototype("void well_info_load_rst_eclfile(well_info, ecl_file, bool)") - _get_well_count = WellPrototype("int well_info_get_num_wells(well_info)") - _iget_well_name = WellPrototype("char* well_info_iget_well_name(well_info, int)") - _has_well = WellPrototype("bool well_info_has_well(well_info, char*)") - _get_ts = WellPrototype("well_time_line_ref well_info_get_ts(well_info, char*)") + _alloc = EclPrototype("void* well_info_alloc(ecl_grid)", bind = False) + _free = EclPrototype("void well_info_free(well_info)") + _load_rstfile = EclPrototype("void well_info_load_rstfile(well_info, char*, bool)") + _load_rst_eclfile = EclPrototype("void well_info_load_rst_eclfile(well_info, ecl_file, bool)") + _get_well_count = EclPrototype("int well_info_get_num_wells(well_info)") + _iget_well_name = EclPrototype("char* well_info_iget_well_name(well_info, int)") + _has_well = EclPrototype("bool well_info_has_well(well_info, char*)") + _get_ts = EclPrototype("well_time_line_ref well_info_get_ts(well_info, char*)") def __init__(self, grid, rst_file=None, load_segment_information=True): diff --git a/ThirdParty/Ert/python/python/ecl/well/well_segment.py b/ThirdParty/Ert/python/ecl/well/well_segment.py similarity index 60% rename from ThirdParty/Ert/python/python/ecl/well/well_segment.py rename to ThirdParty/Ert/python/ecl/well/well_segment.py index 6e7aeb2f40..9fefeefe8f 100644 --- a/ThirdParty/Ert/python/python/ecl/well/well_segment.py +++ b/ThirdParty/Ert/python/ecl/well/well_segment.py @@ -1,20 +1,20 @@ from cwrap import BaseCClass -from ecl.well import WellPrototype +from ecl import EclPrototype class WellSegment(BaseCClass): TYPE_NAME = "well_segment" - _active = WellPrototype("bool well_segment_active(well_segment)") - _main_stem = WellPrototype("bool well_segment_main_stem(well_segment)") - _nearest_wellhead = WellPrototype("bool well_segment_nearest_wellhead(well_segment)") - _id = WellPrototype("int well_segment_get_id(well_segment)") - _link_count = WellPrototype("int well_segment_get_link_count(well_segment)") - _branch_id = WellPrototype("int well_segment_get_branch_id(well_segment)") - _outlet_id = WellPrototype("int well_segment_get_outlet_id(well_segment)") - _depth = WellPrototype("double well_segment_get_depth(well_segment)") - _length = WellPrototype("double well_segment_get_length(well_segment)") - _total_length = WellPrototype("double well_segment_get_total_length(well_segment)") - _diameter = WellPrototype("double well_segment_get_diameter(well_segment)") + _active = EclPrototype("bool well_segment_active(well_segment)") + _main_stem = EclPrototype("bool well_segment_main_stem(well_segment)") + _nearest_wellhead = EclPrototype("bool well_segment_nearest_wellhead(well_segment)") + _id = EclPrototype("int well_segment_get_id(well_segment)") + _link_count = EclPrototype("int well_segment_get_link_count(well_segment)") + _branch_id = EclPrototype("int well_segment_get_branch_id(well_segment)") + _outlet_id = EclPrototype("int well_segment_get_outlet_id(well_segment)") + _depth = EclPrototype("double well_segment_get_depth(well_segment)") + _length = EclPrototype("double well_segment_get_length(well_segment)") + _total_length = EclPrototype("double well_segment_get_total_length(well_segment)") + _diameter = EclPrototype("double well_segment_get_diameter(well_segment)") def __init__(self): raise NotImplementedError("Class can not be instantiated directly") diff --git a/ThirdParty/Ert/python/python/ecl/well/well_state.py b/ThirdParty/Ert/python/ecl/well/well_state.py similarity index 58% rename from ThirdParty/Ert/python/python/ecl/well/well_state.py rename to ThirdParty/Ert/python/ecl/well/well_state.py index 6d0cadf567..7771fef53a 100644 --- a/ThirdParty/Ert/python/python/ecl/well/well_state.py +++ b/ThirdParty/Ert/python/ecl/well/well_state.py @@ -1,36 +1,38 @@ from cwrap import BaseCClass -from ecl.well import WellTypeEnum, WellConnection, WellPrototype -from ecl.util import CTime + +from ecl import EclPrototype +from ecl.well import WellTypeEnum, WellConnection +from ecl.util.util import CTime class WellState(BaseCClass): TYPE_NAME = "well_state" - _global_connections_size = WellPrototype("int well_conn_collection_get_size(void*)", bind = False) - _global_connections_iget = WellPrototype("well_connection_ref well_conn_collection_iget(void*, int)", bind = False) - _segment_collection_size = WellPrototype("int well_segment_collection_get_size(void*)", bind = False) - _segment_collection_iget = WellPrototype("well_segment_ref well_segment_collection_iget(void*, int)", bind = False) - _has_global_connections = WellPrototype("bool well_state_has_global_connections(well_state)") - _get_global_connections = WellPrototype("void* well_state_get_global_connections(well_state)") - _get_segment_collection = WellPrototype("void* well_state_get_segments(well_state)") - _branches = WellPrototype("void* well_state_get_branches(well_state)") - _segments = WellPrototype("void* well_state_get_segments(well_state)") - _get_name = WellPrototype("char* well_state_get_name(well_state)") - _is_open = WellPrototype("bool well_state_is_open(well_state)") - _is_msw = WellPrototype("bool well_state_is_MSW(well_state)") - _well_number = WellPrototype("int well_state_get_well_nr(well_state)") - _report_number = WellPrototype("int well_state_get_report_nr(well_state)") - _has_segment_data = WellPrototype("bool well_state_has_segment_data(well_state)") - _sim_time = WellPrototype("time_t well_state_get_sim_time(well_state)") - _well_type = WellPrototype("well_type_enum well_state_get_type(well_state)") - _oil_rate = WellPrototype("double well_state_get_oil_rate(well_state)") - _gas_rate = WellPrototype("double well_state_get_gas_rate(well_state)") - _water_rate = WellPrototype("double well_state_get_water_rate(well_state)") - _volume_rate = WellPrototype("double well_state_get_volume_rate(well_state)") - _oil_rate_si = WellPrototype("double well_state_get_oil_rate_si(well_state)") - _gas_rate_si = WellPrototype("double well_state_get_gas_rate_si(well_state)") - _water_rate_si = WellPrototype("double well_state_get_water_rate_si(well_state)") - _volume_rate_si = WellPrototype("double well_state_get_volume_rate_si(well_state)") - _get_global_well_head = WellPrototype("well_connection_ref well_state_get_global_wellhead(well_state)") + _global_connections_size = EclPrototype("int well_conn_collection_get_size(void*)", bind = False) + _global_connections_iget = EclPrototype("well_connection_ref well_conn_collection_iget(void*, int)", bind = False) + _segment_collection_size = EclPrototype("int well_segment_collection_get_size(void*)", bind = False) + _segment_collection_iget = EclPrototype("well_segment_ref well_segment_collection_iget(void*, int)", bind = False) + _has_global_connections = EclPrototype("bool well_state_has_global_connections(well_state)") + _get_global_connections = EclPrototype("void* well_state_get_global_connections(well_state)") + _get_segment_collection = EclPrototype("void* well_state_get_segments(well_state)") + _branches = EclPrototype("void* well_state_get_branches(well_state)") + _segments = EclPrototype("void* well_state_get_segments(well_state)") + _get_name = EclPrototype("char* well_state_get_name(well_state)") + _is_open = EclPrototype("bool well_state_is_open(well_state)") + _is_msw = EclPrototype("bool well_state_is_MSW(well_state)") + _well_number = EclPrototype("int well_state_get_well_nr(well_state)") + _report_number = EclPrototype("int well_state_get_report_nr(well_state)") + _has_segment_data = EclPrototype("bool well_state_has_segment_data(well_state)") + _sim_time = EclPrototype("time_t well_state_get_sim_time(well_state)") + _well_type = EclPrototype("well_type_enum well_state_get_type(well_state)") + _oil_rate = EclPrototype("double well_state_get_oil_rate(well_state)") + _gas_rate = EclPrototype("double well_state_get_gas_rate(well_state)") + _water_rate = EclPrototype("double well_state_get_water_rate(well_state)") + _volume_rate = EclPrototype("double well_state_get_volume_rate(well_state)") + _oil_rate_si = EclPrototype("double well_state_get_oil_rate_si(well_state)") + _gas_rate_si = EclPrototype("double well_state_get_gas_rate_si(well_state)") + _water_rate_si = EclPrototype("double well_state_get_water_rate_si(well_state)") + _volume_rate_si = EclPrototype("double well_state_get_volume_rate_si(well_state)") + _get_global_well_head = EclPrototype("well_connection_ref well_state_get_global_wellhead(well_state)") def __init__(self): raise NotImplementedError("Class can not be instantiated directly") diff --git a/ThirdParty/Ert/python/python/ecl/well/well_time_line.py b/ThirdParty/Ert/python/ecl/well/well_time_line.py similarity index 75% rename from ThirdParty/Ert/python/python/ecl/well/well_time_line.py rename to ThirdParty/Ert/python/ecl/well/well_time_line.py index bc42a20e82..2f9f4b835c 100644 --- a/ThirdParty/Ert/python/python/ecl/well/well_time_line.py +++ b/ThirdParty/Ert/python/ecl/well/well_time_line.py @@ -1,11 +1,12 @@ from cwrap import BaseCClass -from ecl.well import WellState, WellPrototype +from ecl import EclPrototype +from ecl.well import WellState class WellTimeLine(BaseCClass): TYPE_NAME = "well_time_line" - _size = WellPrototype("int well_ts_get_size(well_time_line)") - _name = WellPrototype("char* well_ts_get_name(well_time_line)") - _iget = WellPrototype("well_state_ref well_ts_iget_state(well_time_line, int)") + _size = EclPrototype("int well_ts_get_size(well_time_line)") + _name = EclPrototype("char* well_ts_get_name(well_time_line)") + _iget = EclPrototype("well_state_ref well_ts_iget_state(well_time_line, int)") def __init__(self): raise NotImplementedError("Class can not be instantiated directly") diff --git a/ThirdParty/Ert/python/python/ecl/well/well_type_enum.py b/ThirdParty/Ert/python/ecl/well/well_type_enum.py similarity index 100% rename from ThirdParty/Ert/python/python/ecl/well/well_type_enum.py rename to ThirdParty/Ert/python/ecl/well/well_type_enum.py diff --git a/ThirdParty/Ert/python/python/legacy/ert/CMakeLists.txt b/ThirdParty/Ert/python/ert/CMakeLists.txt similarity index 100% rename from ThirdParty/Ert/python/python/legacy/ert/CMakeLists.txt rename to ThirdParty/Ert/python/ert/CMakeLists.txt diff --git a/ThirdParty/Ert/python/ert/__init__.py b/ThirdParty/Ert/python/ert/__init__.py new file mode 100644 index 0000000000..7eaa381b15 --- /dev/null +++ b/ThirdParty/Ert/python/ert/__init__.py @@ -0,0 +1,4 @@ +try: + from .local import * +except ImportError: + pass diff --git a/ThirdParty/Ert/python/ert/ecl/__init__.py b/ThirdParty/Ert/python/ert/ecl/__init__.py new file mode 100644 index 0000000000..bd632f46cc --- /dev/null +++ b/ThirdParty/Ert/python/ert/ecl/__init__.py @@ -0,0 +1,26 @@ +from ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil +from ecl import EclTypeEnum, EclDataType +from ecl.summary import EclSumVarType +from ecl.summary import EclSumTStep +from ecl.summary import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode +from ecl.summary import EclSumKeyWordVector +from ecl.rft import EclPLTCell, EclRFTCell +from ecl.rft import EclRFT, EclRFTFile +from ecl.eclfile import FortIO, openFortIO +from ecl.eclfile import EclKW +from ecl.eclfile import Ecl3DKW +from ecl.eclfile import EclFileView +from ecl.eclfile import EclFile , openEclFile +from ecl.eclfile import Ecl3DFile +from ecl.eclfile import EclInitFile +from ecl.eclfile import EclRestartFile +from ecl.grid import EclGrid +from ecl.grid import EclRegion +from ecl.gravimetry import EclSubsidence +from ecl.gravimetry import phase_deltag, deltag +from ecl.gravimetry import EclGrav +from ecl.summary import EclSumNode +from ecl.summary import EclSumVector +from ecl.summary import EclNPV , NPVPriceVector +from ecl.summary import EclCmp +from ecl.grid import EclGridGenerator diff --git a/ThirdParty/Ert/python/ert/ecl/faults/__init__.py b/ThirdParty/Ert/python/ert/ecl/faults/__init__.py new file mode 100644 index 0000000000..fa0ef626a9 --- /dev/null +++ b/ThirdParty/Ert/python/ert/ecl/faults/__init__.py @@ -0,0 +1,7 @@ +from ecl.grid.faults import Layer +from ecl.grid.faults import FaultCollection +from ecl.grid.faults import Fault +from ecl.grid.faults import FaultLine +from ecl.grid.faults import FaultSegment , SegmentMap +from ecl.grid.faults import FaultBlock , FaultBlockCell +from ecl.grid.faults import FaultBlockLayer diff --git a/ThirdParty/Ert/python/ert/geo/__init__.py b/ThirdParty/Ert/python/ert/geo/__init__.py new file mode 100644 index 0000000000..ececa79587 --- /dev/null +++ b/ThirdParty/Ert/python/ert/geo/__init__.py @@ -0,0 +1,8 @@ +from ecl.util.geometry import GeoPointset +from ecl.util.geometry import GeoRegion +from ecl.util.geometry import CPolyline +from ecl.util.geometry import CPolylineCollection +from ecl.util.geometry import Polyline +from ecl.util.geometry import XYZIo +from ecl.util.geometry import GeometryTools +from ecl.util.geometry import Surface diff --git a/ThirdParty/Ert/python/ert/test/__init__.py b/ThirdParty/Ert/python/ert/test/__init__.py new file mode 100644 index 0000000000..bacdd1adf8 --- /dev/null +++ b/ThirdParty/Ert/python/ert/test/__init__.py @@ -0,0 +1,10 @@ +from ecl.util.test import TestRun +from ecl.util.test import path_exists +from ecl.util.test import ExtendedTestCase +from ecl.util.test import SourceEnumerator +from ecl.util.test import TestArea , TestAreaContext +from ecl.util.test import TempArea , TempAreaContext +from ecl.util.test import ErtTestRunner +from ecl.util.test import PathContext +from ecl.util.test import LintTestCase +from ecl.util.test import ImportTestCase diff --git a/ThirdParty/Ert/python/ert/util/__init__.py b/ThirdParty/Ert/python/ert/util/__init__.py new file mode 100644 index 0000000000..48e2d7bff7 --- /dev/null +++ b/ThirdParty/Ert/python/ert/util/__init__.py @@ -0,0 +1,21 @@ +from ecl.util.util import Version +from ecl.util.util import RngAlgTypeEnum, RngInitModeEnum +from ecl.util.util import CTime +from ecl.util.util import PermutationVector +from ecl.util.util import VectorTemplate +from ecl.util.util import DoubleVector +from ecl.util.util import IntVector +from ecl.util.util import BoolVector +from ecl.util.util import TimeVector +from ecl.util.util import StringList +from ecl.util.util import RandomNumberGenerator +from ecl.util.util import LookupTable +from ecl.util.util import Hash, StringHash, DoubleHash, IntegerHash +from ecl.util.util import ThreadPool +from ecl.util.util import installAbortSignals, updateAbortSignals +from ecl.util.util import ArgPack + +try: + from res.util import SubstitutionList +except ImportError: + pass diff --git a/ThirdParty/Ert/python/python/legacy/ert/well/__init__.py b/ThirdParty/Ert/python/ert/well/__init__.py similarity index 100% rename from ThirdParty/Ert/python/python/legacy/ert/well/__init__.py rename to ThirdParty/Ert/python/ert/well/__init__.py diff --git a/ThirdParty/Ert/python/python/CMakeLists.txt b/ThirdParty/Ert/python/python/CMakeLists.txt deleted file mode 100644 index 59be104ca7..0000000000 --- a/ThirdParty/Ert/python/python/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -configure_file(test_env.py.in ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/test_env.py ) - -add_subdirectory(cwrap) -add_subdirectory( ecl ) - -if (INSTALL_ERT_LEGACY) - add_subdirectory( legacy/ert ) -endif() diff --git a/ThirdParty/Ert/python/python/cwrap/CMakeLists.txt b/ThirdParty/Ert/python/python/cwrap/CMakeLists.txt deleted file mode 100644 index a6b98b1b08..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - basecclass.py - basecenum.py - basecvalue.py - cfile.py - clib.py - metacwrap.py - prototype.py -) - -add_python_package("cwrap" ${PYTHON_INSTALL_PREFIX}/cwrap "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/cwrap/__init__.py b/ThirdParty/Ert/python/python/cwrap/__init__.py deleted file mode 100644 index 027cab1f70..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/__init__.py +++ /dev/null @@ -1,52 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -""" -The cwrap package contains several small utility modules to simplify -the process of interacting with a C library: - - clib: This module contains the function load() which will load a - shared library using the ctypes.CDLL(); the function has - facilities for trying several different names when loading the - library. - - cfile: This module implemenets the class CFILE which can be used to - extract the underlying FILE pointer from a Python filehandle, to - facilitate use of Python filehandles for functions expecting a - FILE pointer. -""" - -__author__ = 'Jean-Paul Balabanian, Joakim Hove, and PG Drange' -__copyright__ = 'Copyright 2016, Statoil ASA' -__credits__ = __author__ -__license__ = 'GPL' -__version__ = '0.0.1' -__maintainer__ = __author__ -__email__ = __author__ -__status__ = 'Prototype' - -from .basecclass import BaseCClass -from .basecenum import BaseCEnum -from .basecvalue import BaseCValue - -from .cfile import CFILE -from .clib import load, lib_name - -from .metacwrap import MetaCWrap -from .prototype import REGISTERED_TYPES, Prototype, PrototypeError - -__all__ = ['BaseCClass', 'BaseCEnum', 'BaseCValue', 'CFILE', - 'MetaCWrap', 'Prototype', 'load', 'lib_name'] diff --git a/ThirdParty/Ert/python/python/cwrap/basecclass.py b/ThirdParty/Ert/python/python/cwrap/basecclass.py deleted file mode 100644 index 306a8375bd..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/basecclass.py +++ /dev/null @@ -1,156 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -import six - -import ctypes -from .metacwrap import MetaCWrap - -@six.add_metaclass(MetaCWrap) -class BaseCClass(object): - namespaces = {} - - def __init__(self, c_pointer, parent=None, is_reference=False): - if not c_pointer: - raise ValueError("Must have a valid (not null) pointer value!") - - if c_pointer < 0: - raise ValueError("The pointer value is negative! This may be correct, but usually is not!") - - self.__c_pointer = c_pointer - self.__parent = parent - self.__is_reference = is_reference - - def __new__(cls, *more, **kwargs): - obj = super(BaseCClass, cls).__new__(cls) - obj.__c_pointer = None - obj.__parent = None - obj.__is_reference = False - - return obj - - def _address(self): - return self.__c_pointer - - def _ad_str(self): - return 'at 0x%x' % self._address() - - @classmethod - def from_param(cls, c_class_object): - if c_class_object is not None and not isinstance(c_class_object, BaseCClass): - raise ValueError("c_class_object must be a BaseCClass instance!") - - if c_class_object is None: - return ctypes.c_void_p() - else: - return ctypes.c_void_p(c_class_object.__c_pointer) - - @classmethod - def createPythonObject(cls, c_pointer): - if c_pointer is not None: - new_obj = cls.__new__(cls) - BaseCClass.__init__(new_obj, c_pointer=c_pointer, parent=None, is_reference=False) - return new_obj - else: - return None - - @classmethod - def createCReference(cls, c_pointer, parent=None): - if c_pointer is not None: - new_obj = cls.__new__(cls) - BaseCClass.__init__(new_obj, c_pointer=c_pointer, parent=parent, is_reference=True) - return new_obj - else: - return None - - @classmethod - def storageType(cls): - return ctypes.c_void_p - - def convertToCReference(self, parent): - self.__is_reference = True - self.__parent = parent - - - def setParent(self, parent=None): - if self.__is_reference: - self.__parent = parent - else: - raise UserWarning("Can only set parent on reference types!") - - return self - - def isReference(self): - """ @rtype: bool """ - return self.__is_reference - - def parent(self): - return self.__parent - - def __eq__(self, other): - # This is the last resort comparison function; it will do a - # plain pointer comparison on the underlying C object; or - # Python is-same-object comparison. - if isinstance(other, BaseCClass): - return self.__c_pointer == other.__c_pointer - else: - return super(BaseCClass , self) == other - - def __hash__(self): - # Similar to last resort comparison; this returns the hash of the - # underlying C pointer. - return hash(self.__c_pointer) - - def free(self): - raise NotImplementedError("A BaseCClass requires a free method implementation!") - - def _create_repr(self, args = ''): - """Representation on the form (e.g.) 'EclFile(...) at 0x1729'.""" - return "{0}({1}) {2}".format(self.__class__.__name__, args, self._ad_str()) - - def __repr__(self): - """Representation on the form (e.g.) 'EclFile(...) at 0x1729'.""" - return self._create_repr() - - def __del__(self): - if self.free is not None: - if not self.__is_reference: - # Important to check the c_pointer; in the case of failed object creation - # we can have a Python object with c_pointer == None. - if self.__c_pointer: - self.free() - - def _invalidateCPointer(self): - self.__c_pointer = None - - - def __bool__(self): - """The BaseCClass instance will evaluate to true if it is bound to an - underlying C object, otherwise it will evaluate to False. More - elaborate bool tests should be implemented in the derived - class. - """ - if self.__c_pointer: - return True - else: - return False - - - def __nonzero__(self): - return self.__bool__( ) diff --git a/ThirdParty/Ert/python/python/cwrap/basecenum.py b/ThirdParty/Ert/python/python/cwrap/basecenum.py deleted file mode 100644 index b86e1b0d64..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/basecenum.py +++ /dev/null @@ -1,169 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from __future__ import absolute_import, division, print_function, unicode_literals - -import six - -import ctypes -from .metacwrap import MetaCWrap - -@six.add_metaclass(MetaCWrap) -class BaseCEnum(object): - enum_namespace = {} - - def __init__(self, *args, **kwargs): - if not self in self.enum_namespace[self.__class__]: - raise NotImplementedError("Can not be instantiated directly!") - - def __new__(cls, *args, **kwargs): - if len(args) == 1: - enum = cls.__resolveEnum(args[0]) - - if enum is None: - raise ValueError("Unknown enum value: %i" % args[0]) - - return enum - else: - obj = super(BaseCEnum, cls).__new__(cls, *args) - obj.name = None - obj.value = None - return obj - - @classmethod - def from_param(cls, c_class_object): - if not isinstance(c_class_object, BaseCEnum): - raise ValueError("c_class_object must be an BaseCEnum instance!") - return c_class_object.value - - @classmethod - def addEnum(cls, name, value): - name = str(name) - if not isinstance(value, int): - raise ValueError("Value must be an integer!") - - enum = cls.__new__(cls) - enum.name = name - enum.value = value - - setattr(cls, name, enum) - - if cls not in cls.enum_namespace: - cls.enum_namespace[cls] = [] - - cls.enum_namespace[cls].append(enum) - - @classmethod - def enums(cls): - return list(cls.enum_namespace[cls]) - - def __eq__(self, other): - if isinstance(other, self.__class__): - return self.value == other.value - - if isinstance(other, int): - return self.value == other - - return False - - def __hash__(self): - return hash(self.value) - - def __str__(self): - return self.name - - def __repr__(self): - cn = self.__class__.__name__ - na = self.name - va = self.value - return '%s(name = "%s", value = %s)' % (cn, na, va) - - def __add__(self, other): - self.__assertOtherIsSameType(other) - value = self.value + other.value - return self.__resolveOrCreateEnum(value) - - def __or__(self, other): - self.__assertOtherIsSameType(other) - value = self.value | other.value - return self.__resolveOrCreateEnum(value) - - - def __xor__(self, other): - self.__assertOtherIsSameType(other) - value = self.value ^ other.value - return self.__resolveOrCreateEnum(value) - - def __and__(self, other): - self.__assertOtherIsSameType(other) - value = self.value & other.value - return self.__resolveOrCreateEnum(value) - - def __int__(self): - return self.value - - def __contains__(self, item): - return self & item == item - - @classmethod - def __createEnum(cls, value): - enum = cls.__new__(cls) - enum.name = "Unnamed '%s' enum with value: %i" % (str(cls.__name__), value) - enum.value = value - return enum - - @classmethod - def __resolveOrCreateEnum(cls, value): - enum = cls.__resolveEnum(value) - - if enum is not None: - return enum - - return cls.__createEnum(value) - - @classmethod - def __resolveEnum(cls, value): - for enum in cls.enum_namespace[cls]: - if enum.value == value: - return enum - return None - - def __assertOtherIsSameType(self, other): - assert isinstance(other, self.__class__), "Can only operate on enums of same type: %s =! %s" % ( - self.__class__.__name__, other.__class__.__name__) - - - @classmethod - def populateEnum(cls, library, enum_provider_function): - try: - func = getattr(library, enum_provider_function) - except AttributeError: - raise ValueError("Could not find enum description function: %s - can not load enum: %s." % (enum_provider_function, cls.__name__)) - - func.restype = ctypes.c_char_p - func.argtypes = [ctypes.c_int, ctypes.POINTER(ctypes.c_int)] - - index = 0 - while True: - value = ctypes.c_int() - name = func(index, ctypes.byref(value)) - - if name: - cls.addEnum(name, value.value) - index += 1 - else: - break - diff --git a/ThirdParty/Ert/python/python/cwrap/basecvalue.py b/ThirdParty/Ert/python/python/cwrap/basecvalue.py deleted file mode 100644 index 2c9f582792..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/basecvalue.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -import six - -from ctypes import (pointer, c_long, c_int, c_bool, c_float, c_double, c_byte, - c_short, c_char, c_ubyte, c_ushort, c_uint, c_ulong) - -from .metacwrap import MetaCWrap - -@six.add_metaclass(MetaCWrap) -class BaseCValue(object): - DATA_TYPE = None - LEGAL_TYPES = [c_byte, c_ubyte, c_short, c_ushort, c_int, c_uint, c_long, c_ulong, c_bool, c_char, c_float, c_double] - - def __init__(self, value): - super(BaseCValue, self).__init__() - - if not self.DATA_TYPE in self.LEGAL_TYPES: - raise ValueError("DATA_TYPE must be one of these CTypes classes: %s" % BaseCValue.LEGAL_TYPES) - - self.__value = self.cast(value) - - - def value(self): - return self.__value.value - - @classmethod - def storageType(cls): - return cls.type() - - @classmethod - def type(cls): - return cls.DATA_TYPE - - @classmethod - def cast(cls, value): - return cls.DATA_TYPE(value) - - def setValue(self, value): - self.__value = self.cast(value) - - def asPointer(self): - return pointer(self.__value) - - @classmethod - def from_param(cls, c_value_object): - if c_value_object is not None and not isinstance(c_value_object, BaseCValue): - raise ValueError("c_class_object must be a BaseCValue instance!") - - return c_value_object.__value diff --git a/ThirdParty/Ert/python/python/cwrap/cfile.py b/ThirdParty/Ert/python/python/cwrap/cfile.py deleted file mode 100644 index 4b46d420f9..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/cfile.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -import ctypes -import six -from .prototype import Prototype, PrototypeError -from .basecclass import BaseCClass - -class CFILE(BaseCClass): - """ - Utility class to map a Python file handle <-> FILE* in C - """ - TYPE_NAME = "FILE" - - _as_file = Prototype(ctypes.pythonapi, "void* PyFile_AsFile(py_object)") - - def __init__(self, py_file): - """ - Takes a python file handle and looks up the underlying FILE * - - The purpose of the CFILE class is to be able to use python - file handles when calling C functions which expect a FILE - pointer. A CFILE instance should be created based on the - Python file handle, and that should be passed to the function - expecting a FILE pointer. - - The implementation is based on the ctypes object - pythonapi which is ctypes wrapping of the CPython api. - - C-function: - void fprintf_hello(FILE * stream , const char * msg); - - Python wrapper: - lib = clib.load( "lib.so" ) - fprintf_hello = Prototype(lib, "void fprintf_hello( FILE , char* )") - - Python use: - py_fileH = open("file.txt" , "w") - fprintf_hello( CFILE( py_fileH ) , "Message ...") - py_fileH.close() - - If the supplied argument is not of type py_file the function - will raise a TypeException. - - Examples: ecl.ecl.ecl_kw.EclKW.fprintf_grdecl() - """ - c_ptr = self._as_file(py_file) - try: - super(CFILE, self).__init__(c_ptr) - except ValueError as e: - raise TypeError("Sorry - the supplied argument is not a valid Python file handle!") - - self.py_file = py_file - - - def __del__(self): - pass diff --git a/ThirdParty/Ert/python/python/cwrap/clib.py b/ThirdParty/Ert/python/python/cwrap/clib.py deleted file mode 100644 index 8fb87a6518..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/clib.py +++ /dev/null @@ -1,90 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'clib.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. -"""Convenience module for loading shared library. -""" - -import platform -import ctypes -import os - -so_extension = {"linux" : "so", - "linux2" : "so", - "linux3" : "so", - "win32" : "dll", - "win64" : "dll", - "darwin" : "dylib" } - - -# Passing None to the CDLL() function means to open a lib handle to -# the current runnning process, i.e. like dlopen( NULL ). We must -# special case this to avoid creating the bogus argument 'None.so'. - -def lib_name(lib , path = None , so_version = ""): - if lib is None: - return None - else: - platform_key = platform.system().lower() - - if platform_key == "darwin": - so_name = "%s%s.%s" % (lib, so_version, so_extension[ platform_key ]) - else: - so_name = "%s.%s%s" % (lib, so_extension[ platform_key ], so_version) - - if path: - return os.path.join( path , so_name ) - else: - return so_name - - - - -def load( lib, so_version = None, path = None): - """Thin wrapper around the ctypes.CDLL function for loading shared - library. - - If the path argument is non Null the function will first try to - load with full path. If that fails it wil also try to load without - a path component, invoking normal dlopen() semantics. - """ - - dll = None - lib_files = [ lib_name( lib , path = path , so_version = so_version) ] - if path: - lib_files.append( lib_name( lib , path = None , so_version = so_version) ) - - for lib_file in lib_files: - try: - dll = ctypes.CDLL(lib_file , ctypes.RTLD_GLOBAL) - return dll - except Exception as exc: - error = exc - - error_msg = "\nFailed to load shared library:%s\n\ndlopen() error: %s\n" % (lib , error) - - LD_LIBRARY_PATH = os.getenv("LD_LIBRARY_PATH") - if not LD_LIBRARY_PATH: - LD_LIBRARY_PATH = "" - - error_msg += """ -The runtime linker has searched through the default location of shared -libraries, and also the locations mentioned in your LD_LIBRARY_PATH -variable. Your current LD_LIBRARY_PATH setting is: - - LD_LIBRARY_PATH: %s - -You might need to update this variable? -""" % LD_LIBRARY_PATH - raise ImportError(error_msg) diff --git a/ThirdParty/Ert/python/python/cwrap/metacwrap.py b/ThirdParty/Ert/python/python/cwrap/metacwrap.py deleted file mode 100644 index 52ccb970ce..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/metacwrap.py +++ /dev/null @@ -1,67 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) -import six - -import re -from types import MethodType - -from .prototype import Prototype - - -def snakeCase(name): - s1 = re.sub('(.)([A-Z][a-z]+)', r'\1_\2', name) - return re.sub('([a-z0-9])([A-Z])', r'\1_\2', s1).lower() - - -class MetaCWrap(type): - def __init__(cls, name, bases, attrs): - super(MetaCWrap, cls).__init__(name, bases, attrs) - - is_return_type = False - storage_type = None - - if "TYPE_NAME" in attrs: - type_name = attrs["TYPE_NAME"] - else: - type_name = snakeCase(name) - - if hasattr(cls, "DATA_TYPE") or hasattr(cls, "enums"): - is_return_type = True - - if hasattr(cls, "storageType"): - storage_type = cls.storageType() - - Prototype.registerType(type_name, cls, is_return_type=is_return_type, storage_type=storage_type) - - if hasattr(cls, "createCReference"): - Prototype.registerType("%s_ref" % type_name, cls.createCReference, is_return_type=True, storage_type=storage_type) - - if hasattr(cls, "createPythonObject"): - Prototype.registerType("%s_obj" % type_name, cls.createPythonObject, is_return_type=True, storage_type=storage_type) - - - for key, attr in attrs.items(): - if isinstance(attr, Prototype): - attr.resolve() - attr.__name__ = key - - if attr.shouldBeBound(): - method = MethodType(attr, None, cls) - #method = six.create_bound_method(attr, cls) - setattr(cls, key, method) diff --git a/ThirdParty/Ert/python/python/cwrap/prototype.py b/ThirdParty/Ert/python/python/cwrap/prototype.py deleted file mode 100644 index 28348e31d7..0000000000 --- a/ThirdParty/Ert/python/python/cwrap/prototype.py +++ /dev/null @@ -1,177 +0,0 @@ -# Copyright (C) 2016 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -import ctypes -import inspect -import re - -import sys - -class TypeDefinition(object): - def __init__(self, type_class_or_function, is_return_type, storage_type): - self.storage_type = storage_type - self.is_return_type = is_return_type - self.type_class_or_function = type_class_or_function - - -REGISTERED_TYPES = {} -""":type: dict[str,TypeDefinition]""" - - -def _registerType(type_name, type_class_or_function, is_return_type=True, storage_type=None): - if type_name in REGISTERED_TYPES: - raise PrototypeError("Type: '%s' already registered!" % type_name) - - REGISTERED_TYPES[type_name] = TypeDefinition(type_class_or_function, is_return_type, storage_type) - - # print("Registered: %s for class: %s" % (type_name, repr(type_class_or_function))) - -_registerType("void", None) -_registerType("void*", ctypes.c_void_p) -_registerType("uint", ctypes.c_uint) -_registerType("uint*", ctypes.POINTER(ctypes.c_uint)) -_registerType("int", ctypes.c_int) -_registerType("int*", ctypes.POINTER(ctypes.c_int)) -_registerType("int64", ctypes.c_int64) -_registerType("int64*", ctypes.POINTER(ctypes.c_int64)) -_registerType("size_t", ctypes.c_size_t) -_registerType("size_t*", ctypes.POINTER(ctypes.c_size_t)) -_registerType("bool", ctypes.c_bool) -_registerType("bool*", ctypes.POINTER(ctypes.c_bool)) -_registerType("long", ctypes.c_long) -_registerType("long*", ctypes.POINTER(ctypes.c_long)) -_registerType("char", ctypes.c_char) -_registerType("char*", ctypes.c_char_p) -_registerType("char**", ctypes.POINTER(ctypes.c_char_p)) -_registerType("float", ctypes.c_float) -_registerType("float*", ctypes.POINTER(ctypes.c_float)) -_registerType("double", ctypes.c_double) -_registerType("double*", ctypes.POINTER(ctypes.c_double)) -_registerType("py_object", ctypes.py_object) - -PROTOTYPE_PATTERN = "(?P[a-zA-Z][a-zA-Z0-9_*]*) +(?P[a-zA-Z]\w*) *[(](?P[a-zA-Z0-9_*, ]*)[)]" - -class PrototypeError(Exception): - pass - - -class Prototype(object): - pattern = re.compile(PROTOTYPE_PATTERN) - - def __init__(self, lib, prototype, bind=False, allow_attribute_error=False): - super(Prototype, self).__init__() - self._lib = lib - self._prototype = prototype - self._bind = bind - self._func = None - self.__name__ = prototype - self._resolved = False - self._allow_attribute_error = allow_attribute_error - - - - def _parseType(self, type_name): - """Convert a prototype definition type from string to a ctypes legal type.""" - type_name = type_name.strip() - - if type_name in REGISTERED_TYPES: - type_definition = REGISTERED_TYPES[type_name] - return type_definition.type_class_or_function, type_definition.storage_type - raise ValueError("Unknown type: %s" % type_name) - - - def shouldBeBound(self): - return self._bind - - def resolve(self): - match = re.match(Prototype.pattern, self._prototype) - if not match: - raise PrototypeError("Illegal prototype definition: %s\n" % self._prototype) - else: - restype = match.groupdict()["return"] - function_name = match.groupdict()["function"] - self.__name__ = function_name - arguments = match.groupdict()["arguments"].split(",") - - try: - func = getattr(self._lib, function_name) - except AttributeError: - if self._allow_attribute_error: - return - raise PrototypeError("Can not find function: %s in library: %s" % (function_name , self._lib)) - - if not restype in REGISTERED_TYPES or not REGISTERED_TYPES[restype].is_return_type: - sys.stderr.write("The type used as return type: %s is not registered as a return type.\n" % restype) - - return_type = self._parseType(restype) - - if inspect.isclass(return_type): - sys.stderr.write(" Correct type may be: %s_ref or %s_obj.\n" % (restype, restype)) - - return None - - return_type, storage_type = self._parseType(restype) - - func.restype = return_type - - if storage_type is not None: - func.restype = storage_type - - def returnFunction(result, func, arguments): - return return_type(result) - - func.errcheck = returnFunction - - if len(arguments) == 1 and arguments[0].strip() == "": - func.argtypes = [] - else: - argtypes = [self._parseType(arg)[0] for arg in arguments] - if len(argtypes) == 1 and argtypes[0] is None: - argtypes = [] - func.argtypes = argtypes - - self._func = func - - - def __call__(self, *args): - if not self._resolved: - self.resolve() - self._resolved = True - - if self._func is None: - if self._allow_attribute_error: - raise NotImplementedError("Function:%s has not been properly resolved - missing library symbol?" % self.__name__) - else: - raise PrototypeError("Prototype has not been properly resolved") - - return self._func(*args) - - def __repr__(self): - bound = "" - if self.shouldBeBound(): - bound = ", bind=True" - - return 'Prototype("%s"%s)' % (self._prototype, bound) - - @classmethod - def registerType(cls, type_name, type_class_or_function, is_return_type=True, storage_type=None): - if storage_type is None and (inspect.isfunction(type_class_or_function)): - storage_type = ctypes.c_void_p - - _registerType(type_name, - type_class_or_function, - is_return_type = is_return_type, - storage_type = storage_type) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt deleted file mode 100644 index 9b9ba88b03..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/CMakeLists.txt +++ /dev/null @@ -1,37 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - ecl_3d_file.py - ecl_3dkw.py - ecl_file.py - ecl_file_view.py - ecl_grav.py - ecl_grav_calc.py - ecl_grid.py - ecl_init_file.py - ecl_kw.py - ecl_npv.py - ecl_region.py - ecl_restart_file.py - ecl_rft.py - ecl_rft_cell.py - ecl_smspec_node.py - ecl_subsidence.py - ecl_sum.py - ecl_sum_keyword_vector.py - ecl_sum_node.py - ecl_sum_tstep.py - ecl_sum_vector.py - ecl_util.py - fortio.py - ecl_sum_keyword_vector.py - ecl_cmp.py - ecl_sum_var_type.py - ecl_type.py - ecl_grid_generator.py - cell.py -) - -add_python_package("python.ecl.ecl" ${PYTHON_INSTALL_PREFIX}/ecl/ecl "${PYTHON_SOURCES}" True) - -add_subdirectory(faults) -add_subdirectory(rft) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/__init__.py b/ThirdParty/Ert/python/python/ecl/ecl/__init__.py deleted file mode 100644 index 8f0d16b365..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/__init__.py +++ /dev/null @@ -1,115 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file '__init__.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. -""" -Package for working with ECLIPSE files. - -The ecl package contains several classes for working with ECLIPSE -files. The ecl package is a wrapper around the libecl library from the -ERT distribution. Mainly the package is organized with modules -ecl_xxx.py with a class EclXXX. The module ecl_xxx.py will generaly -wrap the content of the c-file ecl_xxx.c The main content is: - - fortio/FortIO: This is functionality to read and write binary - fortran files. - - ecl_kw/EclKW: This class holds one ECLIPSE keyword, like SWAT, in - restart format. - - ecl_type/EclDataType: This class is used to represent the data type - of the elements in EclKW. - - ecl_file/EclFile: This class is used to load an ECLIPSE file in - restart format, alternatively only parts of the file can be - loaded. Internally it consists of a collection of EclKW - instances. - - ecl_grid/EclGrid: This will load an ECLIPSE GRID or EGRID file, and - can then subsequently be used for queries about the grid. - - ecl_grid_generator/EclGridGenerator: This can be used to generate various - grids. - - ecl_sum/EclSum: This will load summary results from an ECLIPSE run; - both data file(s) and the SMSPEC file. The EclSum object can be - used as basis for queries on summary vectors. - - ecl_rft/[EclRFTFile , EclRFT , EclRFTCell]: Loads an ECLIPSE RFT/PLT - file, and can afterwords be used to support various queries. - - ecl_region/EclRegion: Convenience class to support selecting cells - in a grid based on a wide range of criteria. Can be used as a - mask in operations on EclKW instances. - - ecl_grav/EclGrav: Class used to simplify evaluation of ECLIPSE - modelling time-lapse gravitational surveys. - - ecl_subsidence/EclSubsidence: Small class used to evaluate simulated - subsidence from ECLIPSE simulations; analogous to the EcLGrav - functionality. - -In addition there are some modules which do not follow the one class -per module organization: - - ecl_util: This is mainly a collection of constants, and a few - stateless functions. - - ecl: This module is purely for convenience, all the symbols in the - package are explicitly imported into this module, ensuring that - all symbols in the package are available under the common - namespace 'ecl'. - -""" -import ecl.util -import ecl.geo - -from cwrap import Prototype - - -class EclPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=True): - super(EclPrototype, self).__init__(EclPrototype.lib, prototype, bind=bind) - -ECL_LIB = ecl.load("libecl") - -from .cell import Cell -from .ecl_util import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil -from .ecl_type import EclTypeEnum, EclDataType -from .ecl_sum_var_type import EclSumVarType -from .ecl_sum_tstep import EclSumTStep -from .ecl_sum import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode -from .ecl_sum_keyword_vector import EclSumKeyWordVector -from .ecl_rft_cell import EclPLTCell, EclRFTCell -from .ecl_rft import EclRFT, EclRFTFile -from .fortio import FortIO, openFortIO -from .ecl_kw import EclKW -from .ecl_3dkw import Ecl3DKW -from .ecl_file_view import EclFileView -from .ecl_file import EclFile , openEclFile -from .ecl_3d_file import Ecl3DFile -from .ecl_init_file import EclInitFile -from .ecl_restart_file import EclRestartFile -from .ecl_grid import EclGrid -from .ecl_region import EclRegion -from .ecl_subsidence import EclSubsidence -from .ecl_grav_calc import phase_deltag, deltag -from .ecl_grav import EclGrav -from .ecl_sum_node import EclSumNode -from .ecl_sum_vector import EclSumVector -from .ecl_npv import EclNPV , NPVPriceVector -from .ecl_cmp import EclCmp -from .ecl_grid_generator import EclGridGenerator diff --git a/ThirdParty/Ert/python/python/ecl/ecl/local.cmake b/ThirdParty/Ert/python/python/ecl/ecl/local.cmake deleted file mode 100644 index f2431a2a7a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/local.cmake +++ /dev/null @@ -1,13 +0,0 @@ -set( ECL_LOCAL_TARGET "" CACHE FILE "Name of optional external ecl_local module") - -if (EXISTS ${ECL_LOCAL_TARGET}) - if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E remove "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - endif() - - EXECUTE_PROCESS( COMMAND ${CMAKE_COMMAND} -E create_symlink "${ECL_LOCAL_TARGET}" "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") -endif() - -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/ecl_local.py") - add_python_package( "Python ecl.ecl.ecl_local" ${PYTHON_INSTALL_PREFIX}/ecl/ecl "ecl_local.py" True) -endif() diff --git a/ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt deleted file mode 100644 index d41bccb489..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/rft/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - well_trajectory.py -) - -add_python_package("python.ecl.ecl.rft" ${PYTHON_INSTALL_PREFIX}/ecl/ecl/rft "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py b/ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py deleted file mode 100644 index d5a91dfba7..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl/rft/__init__.py +++ /dev/null @@ -1 +0,0 @@ -from .well_trajectory import WellTrajectory diff --git a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in b/ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in deleted file mode 100644 index eaf570f7ca..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_build.py.in +++ /dev/null @@ -1,3 +0,0 @@ -lib_path = "${LIBRARY_OUTPUT_PATH}" -so_version = "${ECL_BINARY_POSTFIX}" -__version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" diff --git a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in b/ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in deleted file mode 100644 index fc3e9a08d5..0000000000 --- a/ThirdParty/Ert/python/python/ecl/ecl_lib_info_install.py.in +++ /dev/null @@ -1,3 +0,0 @@ -lib_path = "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}" -so_version = "${ECL_BINARY_POSTFIX}" -__version__ = "${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR}.${ECL_VERSION_MICRO}" diff --git a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt b/ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt deleted file mode 100644 index bfa1896cd5..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -set(PYTHON_SOURCES - __init__.py - ecl_sum_mock.py -) - -add_python_package("python.ecl.test.ecl_mock" ${PYTHON_INSTALL_PREFIX}/ecl/test/ecl_mock "${PYTHON_SOURCES}" True) diff --git a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py b/ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py deleted file mode 100644 index eb2b779229..0000000000 --- a/ThirdParty/Ert/python/python/ecl/test/ecl_mock/ecl_sum_mock.py +++ /dev/null @@ -1,30 +0,0 @@ -import datetime -from ecl.ecl import EclSum - - -def mock_func(ecl_sum , key , days): - return days * 10 - - -def createEclSum( case , keys , start = datetime.date(2010 , 1, 1) , sim_length_days = 5 * 365 , num_report_step = 5, num_mini_step = 10, dims = (20,10,5) , func_table = {}): - ecl_sum = EclSum.writer(case , start , dims[0] , dims[1] , dims[2]) - var_list = [] - for (kw,wgname,num) in keys: - var_list.append( ecl_sum.addVariable( kw , wgname = wgname , num = num) ) - - report_step_length = sim_length_days / num_report_step - mini_step_length = report_step_length / num_mini_step - for report_step in range(num_report_step): - for mini_step in range(num_mini_step): - days = report_step * report_step_length + mini_step * mini_step_length - t_step = ecl_sum.addTStep( report_step + 1 , sim_days = days ) - - for var in var_list: - key = var.getKey1( ) - if key in func_table: - func = func_table[key] - t_step[key] = func( days ) - else: - t_step[key] = mock_func( ecl_sum , key , days) - - return ecl_sum diff --git a/ThirdParty/Ert/python/python/ecl/util/bool_vector.py b/ThirdParty/Ert/python/python/ecl/util/bool_vector.py deleted file mode 100644 index 9f920628a9..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/bool_vector.py +++ /dev/null @@ -1,143 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from ecl.util import VectorTemplate, UtilPrototype - - -class BoolVector(VectorTemplate): - default_format = "%8d" - - _alloc = UtilPrototype("void* bool_vector_alloc( int , bool )" , bind = False) - _create_active_mask = UtilPrototype("bool_vector_obj string_util_alloc_active_mask( char* )" , bind = False) - _active_list = UtilPrototype("int_vector_obj bool_vector_alloc_active_list(bool_vector)", bind = False) - _alloc_copy = UtilPrototype("bool_vector_obj bool_vector_alloc_copy( bool_vector )") - _update_active_mask = UtilPrototype("bool string_util_update_active_mask(char*, bool_vector)" , bind = False) - - _strided_copy = UtilPrototype("bool_vector_obj bool_vector_alloc_strided_copy( bool_vector , int , int , int)") - _free = UtilPrototype("void bool_vector_free( bool_vector )") - _iget = UtilPrototype("bool bool_vector_iget( bool_vector , int )") - _safe_iget = UtilPrototype("bool bool_vector_safe_iget( bool_vector , int )") - _iset = UtilPrototype("void bool_vector_iset( bool_vector , int , bool)") - _size = UtilPrototype("int bool_vector_size( bool_vector )") - _append = UtilPrototype("void bool_vector_append( bool_vector , bool )") - _idel_block = UtilPrototype("void bool_vector_idel_block( bool_vector , bool , bool )") - _idel = UtilPrototype("void bool_vector_idel( bool_vector , int )") - _pop = UtilPrototype("bool bool_vector_pop( bool_vector )") - _lshift = UtilPrototype("void bool_vector_lshift( bool_vector , int )") - _rshift = UtilPrototype("void bool_vector_rshift( bool_vector , int )") - _insert = UtilPrototype("void bool_vector_insert( bool_vector , int , bool)") - _fprintf = UtilPrototype("void bool_vector_fprintf( bool_vector , FILE , char* , char*)") - _sort = UtilPrototype("void bool_vector_sort( bool_vector )") - _rsort = UtilPrototype("void bool_vector_rsort( bool_vector )") - _reset = UtilPrototype("void bool_vector_reset( bool_vector )") - _set_read_only = UtilPrototype("void bool_vector_set_read_only( bool_vector , bool )") - _get_read_only = UtilPrototype("bool bool_vector_get_read_only( bool_vector )") - _get_max = UtilPrototype("bool bool_vector_get_max( bool_vector )") - _get_min = UtilPrototype("bool bool_vector_get_min( bool_vector )") - _get_max_index = UtilPrototype("int bool_vector_get_max_index( bool_vector , bool)") - _get_min_index = UtilPrototype("int bool_vector_get_min_index( bool_vector , bool)") - _shift = UtilPrototype("void bool_vector_shift( bool_vector , bool )") - _scale = UtilPrototype("void bool_vector_scale( bool_vector , bool )") - _div = UtilPrototype("void bool_vector_div( bool_vector , bool )") - _inplace_add = UtilPrototype("void bool_vector_inplace_add( bool_vector , bool_vector )") - _inplace_mul = UtilPrototype("void bool_vector_inplace_mul( bool_vector , bool_vector )") - _assign = UtilPrototype("void bool_vector_set_all( bool_vector , bool)") - _memcpy = UtilPrototype("void bool_vector_memcpy(bool_vector , bool_vector )") - _set_default = UtilPrototype("void bool_vector_set_default( bool_vector , bool)") - _get_default = UtilPrototype("bool bool_vector_get_default( bool_vector )") - _element_size = UtilPrototype("int bool_vector_element_size( bool_vector )") - - _permute = UtilPrototype("void bool_vector_permute(bool_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj bool_vector_alloc_sort_perm(bool_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj bool_vector_alloc_rsort_perm(bool_vector)") - - _contains = UtilPrototype("bool bool_vector_contains(bool_vector, bool)") - _select_unique = UtilPrototype("void bool_vector_select_unique(bool_vector)") - _element_sum = UtilPrototype("bool bool_vector_sum(bool_vector)") - _get_data_ptr = UtilPrototype("bool* bool_vector_get_ptr(bool_vector)") - _count_equal = UtilPrototype("int bool_vector_count_equal(bool_vector, bool)") - - def __init__(self, default_value=False, initial_size=0): - super(BoolVector, self).__init__(default_value, initial_size) - - def count(self, value=True): - """ @rtype: int """ - return self._count_equal(self, value) - - @classmethod - def createActiveMask(cls, range_string): - """ - Will create a BoolVector instance with the values from @range_string. - - The range_string input should be of the type "1,3-5,9,17", - i.e. integer values separated by commas, and dashes to - represent ranges. If the input string contains ANY invalid - characters the returned active list will be empty: - - "1,4-7,10" => {F,T,F,F,T,T,T,T,F,F,T} - "1,4-7,10X" => {} - - The empty list will evaluate to false - @rtype: BoolVector - """ - return cls._create_active_mask(range_string) - - def updateActiveMask(self, range_string): - """ - Updates a bool vector based on a range string. - @type range_string: str - @type bool_vector: BoolVector - @rtype: bool - """ - return self._update_active_mask(range_string , self) - - @classmethod - def createFromList(cls, size, source_list): - """ - Allocates a bool vector from a Python list of indexes - @rtype: BoolVector - """ - bool_vector = BoolVector(False, size) - - for index in source_list: - index = int(index) - bool_vector[index] = True - - return bool_vector - - def createActiveList(self): - """ @rtype: ecl.util.IntVector """ - return self._active_list(self) - - def _tostr(self, arr = None): - if arr is None: - arr = self - return "".join(['1' if x else '0' for x in arr]) - - def __repr__(self): - """Will return BoolVector(size = 4, content = "0010") at 0x1729 and - if size > 10, will return content = "0001...100", i.e., |content|<=10. - """ - cnt = '' - ls = len(self) - if ls <= 20: - cnt = self._tostr() - else: - a,b = self[:9], self[-8:] - cnt = self._tostr(a) - cnt += "..." - cnt += self._tostr(b) - return 'BoolVector(size = %d, content = "%s") %s' % (ls, cnt, self._ad_str()) diff --git a/ThirdParty/Ert/python/python/ecl/util/buffer.py b/ThirdParty/Ert/python/python/ecl/util/buffer.py deleted file mode 100644 index 44a96cfd62..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/buffer.py +++ /dev/null @@ -1,29 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'buffer.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class Buffer(BaseCClass): - _alloc = UtilPrototype("void* buffer_alloc(int)" , bind = False) - _free = UtilPrototype("void buffer_free(buffer)") - - def __init__(self, size): - super(Buffer, self).__init__(self._alloc(size)) - - def free(self): - self._free() diff --git a/ThirdParty/Ert/python/python/ecl/util/double_vector.py b/ThirdParty/Ert/python/python/ecl/util/double_vector.py deleted file mode 100644 index 28a39cfc20..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/double_vector.py +++ /dev/null @@ -1,70 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'double_vector.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from ecl.util import VectorTemplate, UtilPrototype - - -class DoubleVector(VectorTemplate): - default_format = "%8.4f" - - _alloc = UtilPrototype("void* double_vector_alloc( int , double )" , bind = False) - _alloc_copy = UtilPrototype("double_vector_obj double_vector_alloc_copy( double_vector )") - _strided_copy = UtilPrototype("double_vector_obj double_vector_alloc_strided_copy( double_vector , int , int , int)") - _free = UtilPrototype("void double_vector_free( double_vector )") - _iget = UtilPrototype("double double_vector_iget( double_vector , int )") - _safe_iget = UtilPrototype("double double_vector_safe_iget(double_vector , int )") - _iset = UtilPrototype("double double_vector_iset( double_vector , int , double)") - _size = UtilPrototype("int double_vector_size( double_vector )") - _append = UtilPrototype("void double_vector_append( double_vector , double )") - _idel_block = UtilPrototype("void double_vector_idel_block( double_vector , int , int )") - _pop = UtilPrototype("double double_vector_pop( double_vector )") - _idel = UtilPrototype("void double_vector_idel( double_vector , int )") - _lshift = UtilPrototype("void double_vector_lshift( double_vector , int )") - _rshift = UtilPrototype("void double_vector_rshift( double_vector , int )") - _insert = UtilPrototype("void double_vector_insert( double_vector , int , double)") - _fprintf = UtilPrototype("void double_vector_fprintf( double_vector , FILE , char* , char*)") - _sort = UtilPrototype("void double_vector_sort( double_vector )") - _rsort = UtilPrototype("void double_vector_rsort( double_vector )") - _reset = UtilPrototype("void double_vector_reset( double_vector )") - _get_read_only = UtilPrototype("bool double_vector_get_read_only( double_vector )") - _set_read_only = UtilPrototype("void double_vector_set_read_only( double_vector , bool )") - _get_max = UtilPrototype("double double_vector_get_max( double_vector )") - _get_min = UtilPrototype("double double_vector_get_min( double_vector )") - _get_max_index = UtilPrototype("int double_vector_get_max_index( double_vector , bool)") - _get_min_index = UtilPrototype("int double_vector_get_min_index( double_vector , bool)") - _shift = UtilPrototype("void double_vector_shift( double_vector , double )") - _scale = UtilPrototype("void double_vector_scale( double_vector , double )") - _div = UtilPrototype("void double_vector_div( double_vector , double )") - _inplace_add = UtilPrototype("void double_vector_inplace_add( double_vector , double_vector )") - _inplace_mul = UtilPrototype("void double_vector_inplace_mul( double_vector , double_vector )") - _assign = UtilPrototype("void double_vector_set_all( double_vector , double)") - _memcpy = UtilPrototype("void double_vector_memcpy(double_vector , double_vector )") - _set_default = UtilPrototype("void double_vector_set_default( double_vector , double)") - _get_default = UtilPrototype("double double_vector_get_default( double_vector )") - _element_size = UtilPrototype("int double_vector_element_size( double_vector )") - - _permute = UtilPrototype("void double_vector_permute(double_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj double_vector_alloc_sort_perm(double_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj double_vector_alloc_rsort_perm(double_vector)") - _contains = UtilPrototype("bool double_vector_contains(double_vector, double)") - _select_unique = UtilPrototype("void double_vector_select_unique(double_vector)") - _element_sum = UtilPrototype("double double_vector_sum(double_vector)") - _get_data_ptr = UtilPrototype("double* double_vector_get_ptr(double_vector)") - _count_equal = UtilPrototype("int double_vector_count_equal(double_vector, double)") - _init_range = UtilPrototype("void double_vector_init_range(double_vector, double , double , double)") - - def __init__(self, default_value=0, initial_size=0): - super(DoubleVector, self).__init__(default_value, initial_size) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/__init__.py b/ThirdParty/Ert/python/python/ecl/util/enums/__init__.py deleted file mode 100644 index 85882d14bd..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/__init__.py +++ /dev/null @@ -1,5 +0,0 @@ -from .rng_init_mode_enum import RngInitModeEnum -from .rng_alg_type_enum import RngAlgTypeEnum -from .ui_return_status_enum import UIReturnStatusEnum -from .llsq_result_enum import LLSQResultEnum -from .message_level_enum import MessageLevelEnum diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py deleted file mode 100644 index 3a0c70c2f1..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/llsq_result_enum.py +++ /dev/null @@ -1,13 +0,0 @@ -from cwrap import BaseCEnum - - -class LLSQResultEnum(BaseCEnum): - TYPE_NAME = "llsq_result_enum" - LLSQ_SUCCESS = None - LLSQ_INVALID_DIM = None - LLSQ_UNDETERMINED = None - - -LLSQResultEnum.addEnum("LLSQ_SUCCESS" , 0) -LLSQResultEnum.addEnum("LLSQ_INVALID_DIM" , 1) -LLSQResultEnum.addEnum("LLSQ_UNDETERMINED" , 2) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py deleted file mode 100644 index efb2a61006..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/message_level_enum.py +++ /dev/null @@ -1,18 +0,0 @@ -from cwrap import BaseCEnum - - -class MessageLevelEnum(BaseCEnum): - TYPE_NAME = "message_level_enum" - - LOG_CRITICAL = None - LOG_ERROR = None - LOG_WARNING = None - LOG_INFO = None - LOG_DEBUG = None - - -MessageLevelEnum.addEnum("LOG_CRITICAL", 0) -MessageLevelEnum.addEnum("LOG_ERROR", 1) -MessageLevelEnum.addEnum("LOG_WARNING", 2) -MessageLevelEnum.addEnum("LOG_INFO", 3) -MessageLevelEnum.addEnum("LOG_DEBUG", 4) diff --git a/ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py b/ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py deleted file mode 100644 index 5c810ec127..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/enums/ui_return_status_enum.py +++ /dev/null @@ -1,11 +0,0 @@ -from cwrap import BaseCEnum - - -class UIReturnStatusEnum(BaseCEnum): - TYPE_NAME = "ui_return_status" - UI_RETURN_OK = None - UI_RETURN_FAIL = None - - -UIReturnStatusEnum.addEnum("UI_RETURN_OK", 1) -UIReturnStatusEnum.addEnum("UI_RETURN_FAIL", 2) diff --git a/ThirdParty/Ert/python/python/ecl/util/int_vector.py b/ThirdParty/Ert/python/python/ecl/util/int_vector.py deleted file mode 100644 index 277a76f9eb..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/int_vector.py +++ /dev/null @@ -1,108 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'int_vector.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from ecl.util import VectorTemplate, UtilPrototype - - -class IntVector(VectorTemplate): - default_format = "%d" - - _alloc = UtilPrototype("void* int_vector_alloc( int , int )" , bind = False) - _create_active_list = UtilPrototype("int_vector_obj string_util_alloc_active_list( char*)" , bind = False) - _create_value_list = UtilPrototype("int_vector_obj string_util_alloc_value_list( char*)" , bind = False) - _alloc_copy = UtilPrototype("int_vector_obj int_vector_alloc_copy( int_vector )") - _strided_copy = UtilPrototype("int_vector_obj int_vector_alloc_strided_copy( int_vector , int , int , int)") - _free = UtilPrototype("void int_vector_free( int_vector )") - _iget = UtilPrototype("int int_vector_iget( int_vector , int )") - _safe_iget = UtilPrototype("int int_vector_safe_iget( int_vector , int )") - _iset = UtilPrototype("int int_vector_iset( int_vector , int , int)") - _size = UtilPrototype("int int_vector_size( int_vector )") - _append = UtilPrototype("void int_vector_append( int_vector , int )") - _idel_block = UtilPrototype("void int_vector_idel_block( int_vector , int , int )") - _pop = UtilPrototype("int int_vector_pop( int_vector )") - _idel = UtilPrototype("void int_vector_idel( int_vector , int )") - _insert = UtilPrototype("void int_vector_insert( int_vector , int , int)") - _lshift = UtilPrototype("void int_vector_lshift( int_vector , int )") - _rshift = UtilPrototype("void int_vector_rshift( int_vector , int )") - _fprintf = UtilPrototype("void int_vector_fprintf( int_vector , FILE , char* , char*)") - _sort = UtilPrototype("void int_vector_sort( int_vector )") - _rsort = UtilPrototype("void int_vector_rsort( int_vector )") - _reset = UtilPrototype("void int_vector_reset( int_vector )") - _set_read_only = UtilPrototype("void int_vector_set_read_only( int_vector , bool )") - _get_read_only = UtilPrototype("bool int_vector_get_read_only( int_vector )") - _get_max = UtilPrototype("int int_vector_get_max( int_vector )") - _get_min = UtilPrototype("int int_vector_get_min( int_vector )") - _get_max_index = UtilPrototype("int int_vector_get_max_index( int_vector , bool)") - _get_min_index = UtilPrototype("int int_vector_get_min_index( int_vector , bool)") - _shift = UtilPrototype("void int_vector_shift( int_vector , int )") - _scale = UtilPrototype("void int_vector_scale( int_vector , int )") - _div = UtilPrototype("void int_vector_div( int_vector , int )") - _inplace_add = UtilPrototype("void int_vector_inplace_add( int_vector , int_vector )") - _inplace_mul = UtilPrototype("void int_vector_inplace_mul( int_vector , int_vector )") - _assign = UtilPrototype("void int_vector_set_all( int_vector , int)") - _memcpy = UtilPrototype("void int_vector_memcpy(int_vector , int_vector )") - _set_default = UtilPrototype("void int_vector_set_default( int_vector , int)") - _get_default = UtilPrototype("int int_vector_get_default( int_vector )") - _element_size = UtilPrototype("int int_vector_element_size( int_vector )") - - _permute = UtilPrototype("void int_vector_permute(int_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj int_vector_alloc_sort_perm(int_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj int_vector_alloc_rsort_perm(int_vector)") - _contains = UtilPrototype("bool int_vector_contains(int_vector, int)") - _select_unique = UtilPrototype("void int_vector_select_unique(int_vector)") - _element_sum = UtilPrototype("int int_vector_sum(int_vector)") - _get_data_ptr = UtilPrototype("int* int_vector_get_ptr(int_vector)") - _count_equal = UtilPrototype("int int_vector_count_equal(int_vector, int)") - _init_range = UtilPrototype("void int_vector_init_range(int_vector, int , int , int)") - - def __init__(self, default_value=0, initial_size=0): - super(IntVector, self).__init__(default_value, initial_size) - - @classmethod - def active_list(cls, range_string): - """Will create a IntVector instance with the values from @range_string. - - The range_string input should be of the type "1,3-5,9,17", - i.e. integer values separated by commas, and dashes to - represent ranges. If the input string contains ANY invalid - characters the returned active list will be empty: - - "1,4-7,10" => {1,4,5,6,7,10} - "1,4-7,10X" => {} - - The empty list will evaluate to false. The values in the input - string are meant to indicate "active values", i.e. the output - values are sorted and repeated values are only counted once: - - "1,1,7,2" => {1,2,7} - - """ - return cls._create_active_list(range_string) - - @classmethod - def valueList(cls , range_string): - """Will create a IntVecter of all the values in the @range_string. - - Will not sort the values, and not uniquiefy - in contrast to - the active_list() method. - - """ - return cls._create_value_list(range_string) - - - def count(self, value): - """ @rtype: int """ - return self._count_equal(value) diff --git a/ThirdParty/Ert/python/python/ecl/util/log.py b/ThirdParty/Ert/python/python/ecl/util/log.py deleted file mode 100644 index 2e766b83a6..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/log.py +++ /dev/null @@ -1,44 +0,0 @@ -# Copyright (C) 2012 Statoil ASA, Norway. -# -# The file 'log.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from __future__ import print_function -from cwrap import BaseCClass -from ecl.util import UtilPrototype - - -class Log(BaseCClass): - _get_filename = UtilPrototype("char* log_get_filename(log)") - _reopen = UtilPrototype("void log_reopen(log, char*)") - _get_level = UtilPrototype("int log_get_level(log)") - _set_level = UtilPrototype("void log_set_level(log, int)") - - def __init__(self): - raise NotImplementedError("Class can not be instantiated directly!") - - def get_filename(self): - return self._get_filename() - # return "ert_config.log" - - def reopen(self, filename): - print('Logfile cannot be reopened') - # cfunc.reopen( self , filename) - - def get_level(self): - return self._get_level() - - def set_level(self, level): - pass - # self._set_level(self, level) diff --git a/ThirdParty/Ert/python/python/ecl/util/path_format.py b/ThirdParty/Ert/python/python/ecl/util/path_format.py deleted file mode 100644 index 07d565c46f..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/path_format.py +++ /dev/null @@ -1,42 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from cwrap import BaseCClass -from ecl.util import UtilPrototype - -# The path_fmt implementation hinges strongly on variable length -# argument lists in C - not clear if/how that maps over to Python, -# this Python class therefor has *very* limited functionality. - - -class PathFormat(BaseCClass): - TYPE_NAME = "path_fmt" - _alloc = UtilPrototype("void* path_fmt_alloc_directory_fmt(char*)", bind = False) - _str = UtilPrototype("char* path_fmt_get_fmt(path_fmt)") - _free = UtilPrototype("void path_fmt_free(path_fmt)") - - def __init__(self, path_fmt): - c_ptr = self._alloc( path_fmt ) - if c_ptr: - super(PathFormat, self).__init__(c_ptr) - else: - raise ValueError('Unable to construct path format "%s"' % path_fmt) - - def __repr__(self): - return self._create_repr('fmt=%s' % self._str()) - - def free(self): - self._free( ) diff --git a/ThirdParty/Ert/python/python/ecl/util/profiler.py b/ThirdParty/Ert/python/python/ecl/util/profiler.py deleted file mode 100644 index ab35189cc9..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/profiler.py +++ /dev/null @@ -1,34 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals - -try: - from StringIO import StringIO -except ImportError: - from io import StringIO - -import cProfile -import pstats -import sys - - -class Profiler(object): - - __profiler = None - """ :type: Profile """ - - @classmethod - def startProfiler(cls, subcalls=True, builtins=True): - cls.__profiler = cProfile.Profile() - cls.__profiler.enable(subcalls=subcalls, builtins=builtins) - - @classmethod - def stopProfiler(cls, sort_method="cumulative"): - if cls.__profiler is not None: - cls.__profiler.disable() - stream = StringIO() - stats_printer = pstats.Stats(cls.__profiler, stream=stream).sort_stats(sort_method) - stats_printer.print_stats() - cls.__profiler = None - print(stream.getvalue()) - else: - sys.stderr.write("WARNING: Profiler has not been started!\n") - diff --git a/ThirdParty/Ert/python/python/ecl/util/stat.py b/ThirdParty/Ert/python/python/ecl/util/stat.py deleted file mode 100644 index d219a7869a..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/stat.py +++ /dev/null @@ -1,78 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'stat.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. -from collections import Sequence - -from cwrap import PrototypeError -from ecl.util import LLSQResultEnum, UtilPrototype, Matrix - - -quantile = UtilPrototype("double statistics_empirical_quantile(double_vector, double)") -"""@type: (ecl.util.DoubleVector, float)->float""" - -quantile_sorted = UtilPrototype("double statistics_empirical_quantile(double_vector, double)") -"""@type: (ecl.util.DoubleVector, float)->float""" - -try: - _polyfit = UtilPrototype("llsq_result_enum matrix_stat_polyfit(matrix, matrix, matrix, matrix)") -except PrototypeError: - _polyfit = None - -def polyfit(n, x, y, s=None): - """ - @type n: int - @type x: Matrix or Sequence - @type y: Matrix or Sequence - @type s: Matrix or Sequence or None - @return: tuple - """ - if _polyfit is None: - raise NotImplementedError("Sorry - your ert distribution has been built without lapack support") - - if isinstance(x, Matrix): - xm = x - else: - xm = Matrix(len(x), 1) - for i in range(len(x)): - xm[i, 0] = x[i] - - if isinstance(y, Matrix): - ym = y - else: - ym = Matrix(len(y), 1) - for i in range(len(y)): - ym[i, 0] = y[i] - - if s: - if isinstance(s, Matrix): - sm = s - else: - sm = Matrix(len(s), 1) - for i in range(len(s)): - sm[i, 0] = s[i] - else: - sm = s - - beta = Matrix(n, 1) - res = _polyfit(beta, xm, ym, sm) - - if not res == LLSQResultEnum.LLSQ_SUCCESS: - raise Exception("Linear Least Squares Estimator failed?") - - l = [] - for i in range(n): - l.append(beta[i, 0]) - - return tuple(l) diff --git a/ThirdParty/Ert/python/python/ecl/util/time_vector.py b/ThirdParty/Ert/python/python/ecl/util/time_vector.py deleted file mode 100644 index 7821057fc7..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/time_vector.py +++ /dev/null @@ -1,170 +0,0 @@ -# Copyright (C) 2014 Statoil ASA, Norway. -# -# The file 'vector_template.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. -import datetime -import re - -from ecl.util import VectorTemplate, CTime, UtilPrototype - - -class TimeVector(VectorTemplate): - TYPE_NAME = "time_t_vector" - default_format = "%d" - - _alloc = UtilPrototype("void* time_t_vector_alloc(int, time_t )" , bind = False) - _alloc_copy = UtilPrototype("time_t_vector_obj time_t_vector_alloc_copy(time_t_vector )") - _strided_copy = UtilPrototype("time_t_vector_obj time_t_vector_alloc_strided_copy(time_t_vector , int , int , int)") - _free = UtilPrototype("void time_t_vector_free( time_t_vector )") - _iget = UtilPrototype("time_t time_t_vector_iget( time_t_vector , int )") - _safe_iget = UtilPrototype("time_t time_t_vector_safe_iget( time_t_vector , int )") - _iset = UtilPrototype("time_t time_t_vector_iset( time_t_vector , int , time_t)") - _size = UtilPrototype("int time_t_vector_size( time_t_vector )") - _append = UtilPrototype("void time_t_vector_append( time_t_vector , time_t )") - _idel_block = UtilPrototype("void time_t_vector_idel_block( time_t_vector , int , int )") - _idel = UtilPrototype("void time_t_vector_idel( time_t_vector , int )") - _pop = UtilPrototype("time_t time_t_vector_pop( time_t_vector )") - _lshift = UtilPrototype("void time_t_vector_lshift( time_t_vector , int )") - _rshift = UtilPrototype("void time_t_vector_rshift( time_t_vector , int )") - _insert = UtilPrototype("void time_t_vector_insert( time_t_vector , int , time_t)") - _fprintf = UtilPrototype("void time_t_vector_fprintf( time_t_vector , FILE , char* , char*)") - _sort = UtilPrototype("void time_t_vector_sort( time_t_vector )") - _rsort = UtilPrototype("void time_t_vector_rsort( time_t_vector )") - _reset = UtilPrototype("void time_t_vector_reset( time_t_vector )") - _set_read_only = UtilPrototype("void time_t_vector_set_read_only( time_t_vector , bool )") - _get_read_only = UtilPrototype("bool time_t_vector_get_read_only( time_t_vector )") - _get_max = UtilPrototype("time_t time_t_vector_get_max( time_t_vector )") - _get_min = UtilPrototype("time_t time_t_vector_get_min( time_t_vector )") - _get_max_index = UtilPrototype("int time_t_vector_get_max_index( time_t_vector , bool)") - _get_min_index = UtilPrototype("int time_t_vector_get_min_index( time_t_vector , bool)") - _shift = UtilPrototype("void time_t_vector_shift( time_t_vector , time_t )") - _scale = UtilPrototype("void time_t_vector_scale( time_t_vector , time_t )") - _div = UtilPrototype("void time_t_vector_div( time_t_vector , time_t )") - _inplace_add = UtilPrototype("void time_t_vector_inplace_add( time_t_vector , time_t_vector )") - _inplace_mul = UtilPrototype("void time_t_vector_inplace_mul( time_t_vector , time_t_vector )") - _assign = UtilPrototype("void time_t_vector_set_all( time_t_vector , time_t)") - _memcpy = UtilPrototype("void time_t_vector_memcpy(time_t_vector , time_t_vector )") - _set_default = UtilPrototype("void time_t_vector_set_default( time_t_vector , time_t)") - _get_default = UtilPrototype("time_t time_t_vector_get_default( time_t_vector )") - _element_size = UtilPrototype("int time_t_vector_element_size( time_t_vector )") - - _permute = UtilPrototype("void time_t_vector_permute(time_t_vector, permutation_vector)") - _sort_perm = UtilPrototype("permutation_vector_obj time_t_vector_alloc_sort_perm(time_t_vector)") - _rsort_perm = UtilPrototype("permutation_vector_obj time_t_vector_alloc_rsort_perm(time_t_vector)") - _contains = UtilPrototype("bool time_t_vector_contains(time_t_vector, time_t)") - _select_unique = UtilPrototype("void time_t_vector_select_unique(time_t_vector)") - _element_sum = UtilPrototype("time_t time_t_vector_sum(time_t_vector)") - _count_equal = UtilPrototype("int time_t_vector_count_equal(time_t_vector, time_t)") - _init_range = UtilPrototype("void time_t_vector_init_range(time_t_vector, time_t , time_t , time_t)") - - def __init__(self, default_value=None, initial_size=0): - if default_value is None: - super(TimeVector, self).__init__(CTime(0), initial_size) - else: - try: - default = CTime(default_value) - except: - raise ValueError("default value invalid - must be type ctime() or date/datetime") - - super(TimeVector, self).__init__(default, initial_size) - - @classmethod - def parseTimeUnit(cls, deltaString): - deltaRegexp = re.compile("(?P\d*)(?P[dmy])", re.IGNORECASE) - matchObj = deltaRegexp.match(deltaString) - if matchObj: - try: - num = int(matchObj.group("num")) - except: - num = 1 - - timeUnit = matchObj.group("unit").lower() - return num, timeUnit - else: - raise TypeError("The delta string must be on form \'1d\', \'2m\', \'Y\' for one day, two months or one year respectively") - - def __str__(self): - """ - Returns string representantion of vector. - """ - string_list = [] - for d in self: - string_list.append("%s" % d) - - return str(string_list) - - def append(self, value): - self._append(CTime(value)) - - def __contains__(self, value): - return self._contains(CTime(value)) - - def nextTime(self, num, timeUnit): - currentTime = self[-1].datetime() - hour = currentTime.hour - minute = currentTime.minute - second = currentTime.second - - if timeUnit == "d": - td = datetime.timedelta(days=num) - currentTime += td - else: - day = currentTime.day - month = currentTime.month - year = currentTime.year - - if timeUnit == "y": - year += num - else: - month += num - 1 - (deltaYear, newMonth) = divmod(month, 12) - month = newMonth + 1 - year += deltaYear - currentTime = datetime.datetime(year, month, day, hour, minute, second) - - return currentTime - - def appendTime(self, num, timeUnit): - next = self.nextTime(num, timeUnit) - self.append(CTime(next)) - - @classmethod - def createRegular(cls, start, end, deltaString): - """ - The last element in the vector will be <= end; i.e. if the - question of whether the range is closed in the upper end - depends on the commensurability of the [start,end] interval - and the delta: - - createRegular(0 , 10 , delta=3) => [0,3,6,9] - createRegular(0 , 10 , delta=2) => [0,2,4,6,8,10] - """ - start = CTime(start) - end = CTime(end) - if start > end: - raise ValueError("The time interval is invalid start is after end") - - (num, timeUnit) = cls.parseTimeUnit(deltaString) - - timeVector = TimeVector() - currentTime = start - while currentTime <= end: - ct = CTime(currentTime) - timeVector.append(ct) - currentTime = timeVector.nextTime(num, timeUnit) - - return timeVector - - def getDataPtr(self): - raise NotImplementedError("The getDataPtr() function is not implemented for time_t vectors") diff --git a/ThirdParty/Ert/python/python/ecl/util/ui_return.py b/ThirdParty/Ert/python/python/ecl/util/ui_return.py deleted file mode 100644 index cfe4b28180..0000000000 --- a/ThirdParty/Ert/python/python/ecl/util/ui_return.py +++ /dev/null @@ -1,116 +0,0 @@ -# Copyright (C) 2013 Statoil ASA, Norway. -# -# The file 'ui_return.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from __future__ import (absolute_import, division, - print_function, unicode_literals) - -from cwrap import BaseCClass -from ecl.util import UtilPrototype -from .enums import UIReturnStatusEnum - - -class UIReturn(BaseCClass): - TYPE_NAME = "ui_return" - - _alloc = UtilPrototype("void* ui_return_alloc( ui_return_status )" , bind = False) - _free = UtilPrototype("void ui_return_free(ui_return)") - _get_status = UtilPrototype("ui_return_status ui_return_get_status(ui_return)") - _get_help = UtilPrototype("char* ui_return_get_help(ui_return)") - _add_help = UtilPrototype("void ui_return_add_help(ui_return)") - _add_error = UtilPrototype("void ui_return_add_error(ui_return)") - _num_error = UtilPrototype("int ui_return_get_error_count(ui_return)") - _last_error = UtilPrototype("char* ui_return_get_last_error(ui_return)") - _first_error = UtilPrototype("char* ui_return_get_first_error(ui_return)") - _iget_error = UtilPrototype("char* ui_return_iget_error(ui_return , int)") - - def __init__(self , status): - c_ptr = self._alloc(status) - if c_ptr: - super(UIReturn, self).__init__(c_ptr) - else: - raise ValueError('Unable to construct UIReturn with status = %s' % str(status)) - - - def __nonzero__(self): - if self.status() == UIReturnStatusEnum.UI_RETURN_OK: - return True - else: - return False - - - def __len__(self): - return self._num_error() - - - def __getitem__(self , index): - if isinstance(index , int): - if index < 0: - index += len(self) - if 0 <= index < len(self): - return self._iget_error( index) - else: - raise IndexError('Invalid index. Valid range: [0, %d)' % len(self)) - else: - raise TypeError("Lookup type must be integer") - - - def iget_error(self , index): - return self[index] - - - def help_text(self): - help_text = self._get_help() - if help_text: - return help_text - else: - return "" - - def add_help(self, help_text): - self._add_help(help_text) - - - def status(self): - return self._get_status() - - - def __assert_error(self): - if self.status() == UIReturnStatusEnum.UI_RETURN_OK: - raise ValueError("Can not add error messages to object in state RETURN_OK") - - - def add_error(self, error): - self.__assert_error() - self._add_error(error) - - - def last_error(self): - self.__assert_error() - return self._last_error() - - - def first_error(self): - self.__assert_error() - return self._first_error() - - - def free(self): - self._free() - - def __repr__(self): - ec = len(self) - st = self.status() - ad = self._ad_str() - return 'UIReturn(error_count = %d, status = %s) %s' % (ec, st, ad) diff --git a/ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py deleted file mode 100644 index bdc9ad8458..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/ecl/__init__.py +++ /dev/null @@ -1,26 +0,0 @@ -from ecl.ecl import EclFileEnum, EclFileFlagEnum, EclPhaseEnum, EclUnitTypeEnum , EclUtil -from ecl.ecl import EclTypeEnum, EclDataType -from ecl.ecl import EclSumVarType -from ecl.ecl import EclSumTStep -from ecl.ecl import EclSum #, EclSumVector, EclSumNode, EclSMSPECNode -from ecl.ecl import EclSumKeyWordVector -from ecl.ecl import EclPLTCell, EclRFTCell -from ecl.ecl import EclRFT, EclRFTFile -from ecl.ecl import FortIO, openFortIO -from ecl.ecl import EclKW -from ecl.ecl import Ecl3DKW -from ecl.ecl import EclFileView -from ecl.ecl import EclFile , openEclFile -from ecl.ecl import Ecl3DFile -from ecl.ecl import EclInitFile -from ecl.ecl import EclRestartFile -from ecl.ecl import EclGrid -from ecl.ecl import EclRegion -from ecl.ecl import EclSubsidence -from ecl.ecl import phase_deltag, deltag -from ecl.ecl import EclGrav -from ecl.ecl import EclSumNode -from ecl.ecl import EclSumVector -from ecl.ecl import EclNPV , NPVPriceVector -from ecl.ecl import EclCmp -from ecl.ecl import EclGridGenerator diff --git a/ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py deleted file mode 100644 index 2d336c1fd6..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/ecl/faults/__init__.py +++ /dev/null @@ -1,7 +0,0 @@ -from ecl.ecl.faults import Layer -from ecl.ecl.faults import FaultCollection -from ecl.ecl.faults import Fault -from ecl.ecl.faults import FaultLine -from ecl.ecl.faults import FaultSegment , SegmentMap -from ecl.ecl.faults import FaultBlock , FaultBlockCell -from ecl.ecl.faults import FaultBlockLayer diff --git a/ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py deleted file mode 100644 index 67f4193aa3..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/geo/__init__.py +++ /dev/null @@ -1,8 +0,0 @@ -from ecl.geo import GeoPointset -from ecl.geo import GeoRegion -from ecl.geo import CPolyline -from ecl.geo import CPolylineCollection -from ecl.geo import Polyline -from ecl.geo import XYZIo -from ecl.geo import GeometryTools -from ecl.geo import Surface diff --git a/ThirdParty/Ert/python/python/legacy/ert/test/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/test/__init__.py deleted file mode 100644 index 912a43a595..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/test/__init__.py +++ /dev/null @@ -1,10 +0,0 @@ -from ecl.test import TestRun -from ecl.test import path_exists -from ecl.test import ExtendedTestCase -from ecl.test import SourceEnumerator -from ecl.test import TestArea , TestAreaContext -from ecl.test import TempArea , TempAreaContext -from ecl.test import ErtTestRunner -from ecl.test import PathContext -from ecl.test import LintTestCase -from ecl.test import ImportTestCase diff --git a/ThirdParty/Ert/python/python/legacy/ert/util/__init__.py b/ThirdParty/Ert/python/python/legacy/ert/util/__init__.py deleted file mode 100644 index 926907fc6a..0000000000 --- a/ThirdParty/Ert/python/python/legacy/ert/util/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -from ecl.util import Version -from ecl.util import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum -from ecl.util import CTime -from ecl.util import PermutationVector -from ecl.util import VectorTemplate -from ecl.util import DoubleVector -from ecl.util import IntVector -from ecl.util import BoolVector -from ecl.util import TimeVector -from ecl.util import StringList -from ecl.util import RandomNumberGenerator -from ecl.util import Matrix -from ecl.util import quantile, quantile_sorted, polyfit -from ecl.util import Log -from ecl.util import LookupTable -from ecl.util import Buffer -from ecl.util import Hash, StringHash, DoubleHash, IntegerHash -from ecl.util import UIReturn -from ecl.util import ThreadPool -from ecl.util import CThreadPool, startCThreadPool -from ecl.util import installAbortSignals, updateAbortSignals -from ecl.util import Profiler -from ecl.util import ArgPack -from ecl.util import PathFormat - -try: - from res.util import SubstitutionList -except ImportError: - pass \ No newline at end of file diff --git a/ThirdParty/Ert/python/python/test_env.py.in b/ThirdParty/Ert/python/test_env.py.in similarity index 100% rename from ThirdParty/Ert/python/python/test_env.py.in rename to ThirdParty/Ert/python/test_env.py.in diff --git a/ThirdParty/Ert/python/tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/CMakeLists.txt index a343151dff..7f02af2e52 100644 --- a/ThirdParty/Ert/python/tests/CMakeLists.txt +++ b/ThirdParty/Ert/python/tests/CMakeLists.txt @@ -1,20 +1,20 @@ -set(TEST_SOURCES - __init__.py +configure_file( + __init__.py + "${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}/tests/__init__.py" + @ONLY ) -add_python_package("python.tests" "${PYTHON_INSTALL_PREFIX}/tests" "${TEST_SOURCES}" False) set(CTEST_PYTHONPATH ${PROJECT_BINARY_DIR}/${PYTHON_INSTALL_PREFIX}) -add_subdirectory(geometry) -add_subdirectory(util) -add_subdirectory(ecl) -add_subdirectory(well) -add_subdirectory(cwrap) -add_subdirectory(global) +add_subdirectory(geometry_tests) +add_subdirectory(util_tests) +add_subdirectory(ecl_tests) +add_subdirectory(well_tests) +add_subdirectory(global_tests) +add_subdirectory(bin_tests) if (INSTALL_ERT_LEGACY) - add_subdirectory(legacy) + add_subdirectory(legacy_tests) endif() - configure_file( test_install.in ${EXECUTABLE_OUTPUT_PATH}/test_install @ONLY ) diff --git a/ThirdParty/Ert/python/tests/__init__.py b/ThirdParty/Ert/python/tests/__init__.py index e69de29bb2..918cbb6acc 100644 --- a/ThirdParty/Ert/python/tests/__init__.py +++ b/ThirdParty/Ert/python/tests/__init__.py @@ -0,0 +1,82 @@ +import os.path +import types +from ecl.util.test import ExtendedTestCase +from functools import wraps +from functools import partial +import unittest +from unittest import SkipTest + +def source_root(): + src = '@CMAKE_CURRENT_SOURCE_DIR@/../..' + if os.path.isdir(src): + return os.path.realpath(src) + + # If the file was not correctly configured by cmake, look for the source + # folder, assuming the build folder is inside the source folder. + path_list = os.path.dirname(os.path.abspath(__file__)).split("/") + while len(path_list) > 0: + git_path = os.path.join(os.sep, "/".join(path_list), ".git") + if os.path.isdir(git_path): + return os.path.join(os.sep, *path_list) + path_list.pop() + raise RuntimeError('Cannot find the source folder') + + +# Decorator which is used to mark either an entire test class or individual +# test methods as requiring Statoil testdata. If Statoil testdata has not been +# configured as part of the build process these tests will be skipped. +# +# Ideally the statoil_test() implementation should just be a suitable wrapper of: +# +# skipUnless(EclTest.STATOIL_DATA, "Missing Statoil testdata") +# +# but that has been surprisingly difficult to achieve. The current +# implemenation is based on the skip() function from the unittest/case.py +# module in the Python standard distribution. There are unfortunately several +# problems with this: +# +# 1. It is based on accessing the __unittest_skip attribute of the TestCase +# class, that is certainly a private detail which we should not access. +# +# 2. The decorator must be invoked with an empty parenthesis when decorating a +# class, that is not required when decorating method: +# +# +# @statoil_test() +# class StatoilTest(EclTest): +# # This test class will be skipped entirely if we do not have access to +# # Statoil testdata. +# +# +# class XTest(EclTest): +# +# @statoil_test +# def test_method(self): + +def statoil_test(): + """ + Will mark a test method or an entire test class as dependent on Statoil testdata. + """ + def decorator(test_item): + if not isinstance(test_item, type): + if not EclTest.STATOIL_DATA: + @functools.wraps(test_item) + def skip_wrapper(*args, **kwargs): + raise SkipTest("Missing Statoil testdata") + test_item = skip_wrapper + + if not EclTest.STATOIL_DATA: + test_item.__unittest_skip__ = True + test_item.__unittest_skip_why__ = "Missing Statoil testdata" + return test_item + return decorator + + + + +class EclTest(ExtendedTestCase): + SOURCE_ROOT = source_root() + TESTDATA_ROOT = os.path.join(SOURCE_ROOT, "test-data") + STATOIL_DATA = os.path.islink(os.path.join(TESTDATA_ROOT, "Statoil")) + + diff --git a/ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt new file mode 100644 index 0000000000..420cbe1d98 --- /dev/null +++ b/ThirdParty/Ert/python/tests/bin_tests/CMakeLists.txt @@ -0,0 +1,8 @@ +set(TEST_SOURCES + __init__.py + test_summary_resample.py +) + +add_python_package("python.tests.bin_tests" ${PYTHON_INSTALL_PREFIX}/tests/bin_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.bin_tests.test_summary_resample.SummaryResampleTest) diff --git a/ThirdParty/Ert/python/tests/global/__init__.py b/ThirdParty/Ert/python/tests/bin_tests/__init__.py similarity index 100% rename from ThirdParty/Ert/python/tests/global/__init__.py rename to ThirdParty/Ert/python/tests/bin_tests/__init__.py diff --git a/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py new file mode 100644 index 0000000000..c265382c00 --- /dev/null +++ b/ThirdParty/Ert/python/tests/bin_tests/test_summary_resample.py @@ -0,0 +1,93 @@ +# Copyright (C) 2018 Statoil ASA, Norway. +# +# This file is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +import os.path +import subprocess +from subprocess import CalledProcessError as CallError + +from ecl.grid import Cell, EclGrid +from ecl.summary import EclSum +from tests import EclTest +from ecl.util.test.ecl_mock import createEclSum +from ecl.util.test import TestAreaContext + + +def fopr(days): + return days + +def fopt(days): + return days + +def fgpt(days): + if days < 50: + return days + else: + return 100 - days + +def create_case(num_mini_step = 10, case = "CSV"): + length = 100 + return createEclSum(case, [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY"), ("FGPT" , None , 0, "SM3")], + sim_length_days = length, + num_report_step = 10, + num_mini_step = num_mini_step, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FGPT" : fgpt }) + + + +class SummaryResampleTest(EclTest): + + @classmethod + def setUpClass(cls): + cls.script = os.path.join(cls.SOURCE_ROOT, "bin/summary_resample") + cls.case = create_case() + + def test_run_default(self): + with TestAreaContext(""): + self.case.fwrite() + + # Too few arguments + with self.assertRaises(CallError): + subprocess.check_call([self.script]) + + # Too few arguments + with self.assertRaises(CallError): + subprocess.check_call([self.script, "CSV"]) + + # Invalid first arguments + with self.assertRaises(CallError): + subprocess.check_call([self.script, "DOES_NOT_EXIST", "OUTPUT"]) + + # Should run OK: + subprocess.check_call([self.script, "CSV", "OUTPUT"]) + output_case = EclSum("OUTPUT") + self.assertEqual( output_case.get_data_start_time(), self.case.get_data_start_time()) + self.assertEqual( output_case.get_end_time(), self.case.get_end_time()) + + with self.assertRaises(CallError): + subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=does/not/exist"]) + + refcase = create_case( num_mini_step = 7, case = "REFCASE") + refcase.fwrite() + subprocess.check_call([self.script, "CSV", "OUTPUT", "--refcase=REFCASE"]) + output_case = EclSum("OUTPUT") + self.assertEqual( output_case.get_data_start_time(), refcase.get_data_start_time()) + self.assertEqual( output_case.get_end_time(), refcase.get_end_time()) + time_points = output_case.alloc_time_vector(False) + t1 = output_case.alloc_time_vector(False) + t2 = refcase.alloc_time_vector(False) + self.assertEqual(t1,t2) diff --git a/ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt b/ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt deleted file mode 100644 index 56200ef2d9..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/CMakeLists.txt +++ /dev/null @@ -1,17 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_basecclass.py - test_basecenum.py - test_basecvalue.py - test_metawrap.py - test_cfile.py -) - -add_python_package("python.tests.cwrap" ${PYTHON_INSTALL_PREFIX}/tests/cwrap "${TEST_SOURCES}" False) - -addPythonTest(tests.cwrap.test_basecclass.BaseCClassTest) -addPythonTest(tests.cwrap.test_basecenum.BaseCEnumTest) -addPythonTest(tests.cwrap.test_basecvalue.BaseCValueTest) -addPythonTest(tests.cwrap.test_metawrap.MetaWrapTest) -addPythonTest(tests.cwrap.test_cfile.CFILETest) - diff --git a/ThirdParty/Ert/python/tests/cwrap/test_basecclass.py b/ThirdParty/Ert/python/tests/cwrap/test_basecclass.py deleted file mode 100644 index f2925d67b6..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_basecclass.py +++ /dev/null @@ -1,19 +0,0 @@ -from cwrap import BaseCClass -from ecl.test import ExtendedTestCase - - -class BaseCClassTest(ExtendedTestCase): - - def test_none_assertion(self): - self.assertFalse(None > 0) - - def test_creation(self): - with self.assertRaises(ValueError): - obj = BaseCClass(0) - - - obj = BaseCClass( 10 ) - self.assertTrue( obj ) - - obj._invalidateCPointer( ) - self.assertFalse( obj ) diff --git a/ThirdParty/Ert/python/tests/cwrap/test_basecenum.py b/ThirdParty/Ert/python/tests/cwrap/test_basecenum.py deleted file mode 100644 index b5f44efa95..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_basecenum.py +++ /dev/null @@ -1,91 +0,0 @@ -from cwrap import BaseCEnum -from ecl.test import ExtendedTestCase - - - -class BaseCEnumTest(ExtendedTestCase): - def test_base_c_enum(self): - class enum(BaseCEnum): - pass - - enum.addEnum("ONE", 1) - enum.addEnum("TWO", 2) - enum.addEnum("THREE", 3) - enum.addEnum("FOUR", 4) - - class enum2(BaseCEnum): - pass - - enum2.addEnum("ONE", 1) - enum2.addEnum("TWO", 4) - - self.assertEqual(enum.ONE, 1) - self.assertEqual(enum.TWO, 2) - self.assertEqual(enum.FOUR, 4) - - self.assertListEqual(enum.enums(), [enum.ONE, enum.TWO, enum.THREE, enum.FOUR]) - - self.assertEqual(enum(4), enum.FOUR) - - self.assertNotEqual(enum2(4), enum.FOUR) - self.assertEqual(enum2(4), enum2.TWO) - - self.assertEqual(str(enum.ONE), "ONE") - - - self.assertEqual(enum.ONE + enum.TWO, enum.THREE) - self.assertEqual(enum.ONE + enum.FOUR, 5) - - with self.assertRaises(ValueError): - e = enum(5) - - - self.assertEqual(enum.THREE & enum.ONE, enum.ONE) - self.assertEqual(enum.ONE | enum.TWO, enum.THREE) - self.assertEqual(enum.THREE ^ enum.TWO, enum.ONE) - - - with self.assertRaises(AssertionError): - e = enum.ONE + enum2.ONE - - with self.assertRaises(AssertionError): - e = enum.ONE & enum2.ONE - - with self.assertRaises(AssertionError): - e = enum.ONE | enum2.ONE - - with self.assertRaises(AssertionError): - e = enum.ONE ^ enum2.ONE - - - def test_in_operator(self): - class PowerOf2(BaseCEnum): - pass - - PowerOf2.addEnum("ONE", 1) - PowerOf2.addEnum("TWO", 2) - PowerOf2.addEnum("FOUR", 4) - - three = PowerOf2.ONE | PowerOf2.TWO - - self.assertEqual(int(three), 3) - - self.assertIn(PowerOf2.TWO, three) - self.assertIn(PowerOf2.ONE, three) - self.assertNotIn(PowerOf2.FOUR, three) - - def test_repr_and_str(self): - class MyLonelyEnum(BaseCEnum): - pass - - MyLonelyEnum.addEnum("ONE", 1) - MyLonelyEnum.addEnum("TWO", 2) - MyLonelyEnum.addEnum("THREE", 3) - MyLonelyEnum.addEnum("FOUR", 4) - - tri = MyLonelyEnum.THREE - - self.assertEqual(repr(tri), 'MyLonelyEnum(name = "THREE", value = 3)') - self.assertEqual(str(tri), 'THREE') - self.assertEqual(tri.name, 'THREE') - self.assertEqual(tri.value, 3) diff --git a/ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py b/ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py deleted file mode 100644 index 4066333221..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_basecvalue.py +++ /dev/null @@ -1,71 +0,0 @@ -import ecl -from ctypes import c_ubyte, c_double -from cwrap import BaseCValue, Prototype -from ecl.test import ExtendedTestCase - -class TestPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype): - super(TestPrototype, self).__init__(self.lib, prototype) - -class UnsignedByteValue(BaseCValue): - DATA_TYPE = c_ubyte - - -class MaxDouble(BaseCValue): - TYPE_NAME = "pow_double" - DATA_TYPE = c_double - - -class BaseCValueTest(ExtendedTestCase): - def setUp(self): - self.double_max = TestPrototype("pow_double util_double_max(double, double)") - - - def test_illegal_type(self): - class ExceptionValueTest(BaseCValue): - DATA_TYPE = str - def __init__(self, value): - super(ExceptionValueTest, self).__init__(value) - - with self.assertRaises(ValueError): - test = ExceptionValueTest("Failure") - - - class NoDataTypeTest(BaseCValue): - def __init__(self, value): - super(NoDataTypeTest, self).__init__(value) - - with self.assertRaises(ValueError): - test = ExceptionValueTest(0) - - - def test_creation(self): - test_value = UnsignedByteValue(255) - - self.assertEqual(test_value.value(), 255) - - test_value.setValue(256) - self.assertEqual(test_value.value(), 0) - - self.assertEqual(test_value.type(), c_ubyte) - - - def test_from_param(self): - test_value = UnsignedByteValue(127) - - self.assertEqual(UnsignedByteValue.from_param(test_value).value, 127) - - with self.assertRaises(AttributeError): - UnsignedByteValue.from_param(None) - - with self.assertRaises(ValueError): - UnsignedByteValue.from_param("exception") - - - def test_double_max(self): - double_max = self.double_max(2.97, 2.98) - - self.assertIsInstance(double_max, MaxDouble) - self.assertEqual(double_max.value(), 2.98) diff --git a/ThirdParty/Ert/python/tests/cwrap/test_cfile.py b/ThirdParty/Ert/python/tests/cwrap/test_cfile.py deleted file mode 100644 index 1df29bfe8c..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_cfile.py +++ /dev/null @@ -1,31 +0,0 @@ -import ecl -from cwrap import Prototype, CFILE -from ecl.test.extended_testcase import ExtendedTestCase -from ecl.test.test_area import TestAreaContext - - -# Local copies so that the real ones don't get changed -class TestUtilPrototype(Prototype): - lib = ecl.load("libecl") - def __init__(self, prototype, bind=False): - super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind) - -fileno = TestUtilPrototype("int fileno(FILE)") - - -class CFILETest(ExtendedTestCase): - - def test_cfile(self): - with TestAreaContext("cfile_tests") as test_area: - - with open("test", "w") as f: - f.write("some content") - - with open("test", "r") as f: - cfile = CFILE(f) - - self.assertEqual(fileno(cfile), f.fileno()) - - def test_cfile_error(self): - with self.assertRaises(TypeError): - cfile = CFILE("some text") diff --git a/ThirdParty/Ert/python/tests/cwrap/test_metawrap.py b/ThirdParty/Ert/python/tests/cwrap/test_metawrap.py deleted file mode 100644 index e82db53d6d..0000000000 --- a/ThirdParty/Ert/python/tests/cwrap/test_metawrap.py +++ /dev/null @@ -1,122 +0,0 @@ -from __future__ import absolute_import, division, print_function, unicode_literals -from six import string_types -import ctypes - -import ecl -from cwrap import BaseCClass, Prototype, PrototypeError -from ecl.test import ExtendedTestCase - - -# Local copies so that the real ones don't get changed -class TestUtilPrototype(Prototype): - lib = ecl.load("libecl") - def __init__(self, prototype, bind=False): - super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind) - -class BoundTestUtilPrototype(TestUtilPrototype): - def __init__(self, prototype): - super(BoundTestUtilPrototype, self).__init__(prototype, bind=True) - - -class StringList(BaseCClass): - TYPE_NAME = "test_stringlist" - - __len__ = BoundTestUtilPrototype("int stringlist_get_size(test_stringlist)") - free = BoundTestUtilPrototype("void stringlist_free(test_stringlist)") - - _alloc = TestUtilPrototype("void* stringlist_alloc_new()", bind = False) - _iget = TestUtilPrototype("char* stringlist_iget(test_stringlist, int)") - _append = TestUtilPrototype("void stringlist_append_copy(test_stringlist, char*)") - - def __init__(self, initial=None): - c_ptr = self._alloc() - super(StringList, self).__init__(c_ptr) - - if initial: - for s in initial: - if isinstance(s, bytes): - s.decode('ascii') - if isinstance(s, string_types): - self.append(s) - else: - raise TypeError("Item: %s not a string" % s) - - def __getitem__(self, index): - if isinstance(index, int): - length = len(self) - if index < 0: - index += length - if index < 0 or index >= length: - raise IndexError("index must be in range %d <= %d < %d" % (0, index, len(self))) - else: - return self._iget(self, index) - else: - raise TypeError("Index should be integer type") - - def append(self, string): - if isinstance(string, bytes): - s.decode('ascii') - if isinstance(string, string_types): - self._append(self, string) - else: - self._append(self, str(string)) - - - -class MetaWrapTest(ExtendedTestCase): - - def test_stringlist_wrap(self): - items = ["A", "C", "E"] - stringlist = StringList(items) - self.assertEqual(len(stringlist), len(items)) - - self.assertIn("free", StringList.__dict__) - self.assertEqual(StringList.free.__name__, "stringlist_free") - - for index, item in enumerate(items): - self.assertEqual(item, stringlist[index]) - - - def test_already_registered(self): - with self.assertRaises(PrototypeError): - Prototype.registerType("test_stringlist", None) - - def test_error_in_prototype_illegal_return_type(self): - func = TestUtilPrototype("test_stringlist util_alloc_date_stamp_utc()") - - with self.assertRaises(PrototypeError): - func() - - def test_prototype_known_return_type(self): - stringlist = StringList(["B", "D", "F"]) - func = TestUtilPrototype("test_stringlist_ref stringlist_alloc_shallow_copy(stringlist)") - result = func(stringlist) - self.assertIsInstance(result, StringList) - - for index, value in enumerate(stringlist): - self.assertEqual(result[index], value) - - - def test_invalid_function(self): - func = TestUtilPrototype("void stringlist_missing_function()") - with self.assertRaises(PrototypeError): - func() - - - def test_invalid_prototype(self): - func = TestUtilPrototype("void util_alloc_date_stamp_utc(") - with self.assertRaises(PrototypeError): - func() - - - def test_function_type(self): - def stringObj(c_ptr): - char_ptr = ctypes.c_char_p(c_ptr) - python_string = char_ptr.value - return python_string.decode('ascii') - - Prototype.registerType("string_obj", stringObj) - - dateStamp = TestUtilPrototype("string_obj util_alloc_date_stamp_utc()") - date_stamp = dateStamp() - self.assertIsInstance(date_stamp, string_types) diff --git a/ThirdParty/Ert/python/tests/ecl/CMakeLists.txt b/ThirdParty/Ert/python/tests/ecl/CMakeLists.txt deleted file mode 100644 index 5eb3c91721..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/CMakeLists.txt +++ /dev/null @@ -1,97 +0,0 @@ -set(NFS_RUNPATH "" CACHE STRING "Disk area which is shared among cluster nodes and can be used as CWD for LSF/RSH jobs.") -set(RSH_SERVERS "" CACHE STRING "List of nodes which will be used to test the RSH driver") - -set(TEST_SOURCES - __init__.py - test_deprecation.py - test_removed.py - test_ecl_3dkw.py - test_ecl_file_statoil.py - test_ecl_file.py - test_ecl_init_file.py - test_ecl_restart_file.py - test_debug.py - test_ecl_sum.py - test_ecl_sum_vector.py - test_fault_blocks.py - test_fault_blocks_statoil.py - test_faults.py - test_fortio.py - test_grdecl.py - test_grid.py - test_cell.py - test_grid_statoil.py - test_grid_generator.py - test_indexed_read.py - test_ecl_kw_statoil.py - test_ecl_kw.py - test_kw_function.py - test_layer.py - test_npv.py - test_region.py - test_region_statoil.py - test_restart.py - test_rft.py - test_rft_statoil.py - test_rft_cell.py - test_statoil_faults.py - test_sum_statoil.py - test_ecl_util.py - test_ecl_cmp.py - test_sum.py - test_grav.py - test_geertsma.py - test_ecl_type.py - test_restart_head.py - test_fk_user_data.py -) - -add_python_package("python.tests.ecl" ${PYTHON_INSTALL_PREFIX}/tests/ecl "${TEST_SOURCES}" False) - -addPythonTest(tests.ecl.test_fk_user_data.FKTest) -addPythonTest(tests.ecl.test_cell.CellTest) -addPythonTest(tests.ecl.test_grid.GridTest LABELS SLOW_1) -addPythonTest(tests.ecl.test_grid_generator.GridGeneratorTest LABELS SLOW_2) -addPythonTest(tests.ecl.test_ecl_kw.KWTest LABELS SLOW_2) -addPythonTest(tests.ecl.test_kw_function.KWFunctionTest) -addPythonTest(tests.ecl.test_ecl_3dkw.Ecl3DKWTest ) -addPythonTest(tests.ecl.test_rft.RFTTest) -addPythonTest(tests.ecl.test_rft_cell.RFTCellTest) -addPythonTest(tests.ecl.test_sum.SumTest) -addPythonTest(tests.ecl.test_layer.LayerTest ) -addPythonTest(tests.ecl.test_faults.FaultTest ) -addPythonTest(tests.ecl.test_fault_blocks.FaultBlockTest ) -addPythonTest(tests.ecl.test_deprecation.Deprecation_1_9_Test ) -addPythonTest(tests.ecl.test_deprecation.Deprecation_2_0_Test ) -addPythonTest(tests.ecl.test_deprecation.Deprecation_2_1_Test ) -addPythonTest(tests.ecl.test_removed.Removed_2_1_Test ) -addPythonTest(tests.ecl.test_ecl_util.EclUtilTest ) -addPythonTest(tests.ecl.test_fortio.FortIOTest) -addPythonTest(tests.ecl.test_ecl_file.EclFileTest) -addPythonTest(tests.ecl.test_grav.EclGravTest) -addPythonTest(tests.ecl.test_geertsma.GeertsmaTest) -addPythonTest(tests.ecl.test_ecl_type.EclDataTypeTest) -addPythonTest(tests.ecl.test_region.RegionTest) -addPythonTest(tests.ecl.test_debug.DebugTest) - - -if (STATOIL_TESTDATA_ROOT) - addPythonTest(tests.ecl.test_ecl_file_statoil.EclFileStatoilTest LABELS StatoilData) - addPythonTest(tests.ecl.test_grdecl.GRDECLTest LABELS StatoilData) - addPythonTest(tests.ecl.test_grid_statoil.GridTest LABELS StatoilData:Slow) - addPythonTest(tests.ecl.test_ecl_kw_statoil.KWTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_init_file.InitFileTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_restart_file.RestartFileTest LABELS StatoilData) - addPythonTest(tests.ecl.test_restart.RestartTest LABELS StatoilData ) - addPythonTest(tests.ecl.test_region_statoil.RegionTest LABELS StatoilData) - addPythonTest(tests.ecl.test_rft_statoil.RFTTest LABELS StatoilData) - addPythonTest(tests.ecl.test_sum_statoil.SumTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_sum_vector.EclSumVectorTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_sum.EclSumTest LABELS StatoilData) - addPythonTest(tests.ecl.test_statoil_faults.StatoilFaultTest LABELS StatoilData) - addPythonTest(tests.ecl.test_fault_blocks_statoil.FaultBlockTest LABELS StatoilData) - addPythonTest(tests.ecl.test_npv.NPVTest LABELS StatoilData) - addPythonTest(tests.ecl.test_indexed_read.EclIndexedReadTest LABELS StatoilData) - addPythonTest(tests.ecl.test_ecl_cmp.EclCmpTest LABELS StatoilData) - addPythonTest(tests.ecl.test_restart_head.RestartHeadTest LABELS StatoilData) -endif() diff --git a/ThirdParty/Ert/python/tests/ecl/test_sum.py b/ThirdParty/Ert/python/tests/ecl/test_sum.py deleted file mode 100644 index 2401a4c925..0000000000 --- a/ThirdParty/Ert/python/tests/ecl/test_sum.py +++ /dev/null @@ -1,315 +0,0 @@ -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -import os -import datetime -import csv -import shutil -from unittest import skipIf, skipUnless, skipIf - -from ecl.ecl import EclSum, EclSumVarType, FortIO, openFortIO, EclKW, EclDataType, EclSumKeyWordVector -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.test.ecl_mock import createEclSum - -def fopr(days): - return days - -def fopt(days): - return days - -def fgpt(days): - if days < 50: - return days - else: - return 100 - days - -class SumTest(ExtendedTestCase): - - - def test_mock(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) - self.assertTrue("FOPT" in case) - self.assertFalse("WWCT:OPX" in case) - - def test_TIME_special_case(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) - keys = case.keys() - self.assertEqual( len(keys) , 2 ) - self.assertIn( "FOPT" , keys ) - self.assertIn( "FOPR" , keys ) - - - keys = case.keys(pattern = "*") - self.assertEqual( len(keys) , 2 ) - self.assertIn( "FOPT" , keys ) - self.assertIn( "FOPR" , keys ) - - - def test_identify_var_type(self): - self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.h") - self.assertEqual( EclSum.varType( "WWCT:OP_X") , EclSumVarType.ECL_SMSPEC_WELL_VAR ) - self.assertEqual( EclSum.varType( "RPR") , EclSumVarType.ECL_SMSPEC_REGION_VAR ) - self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR ) - self.assertEqual( EclSum.varType( "AARQ:4") , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) - - case = createEclSum("CSV" , [("FOPT", None , 0) , - ("FOPR" , None , 0), - ("AARQ" , None , 10), - ("RGPT" , None ,1)]) - - node1 = case.smspec_node( "FOPT" ) - self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR ) - - node2 = case.smspec_node( "AARQ:10" ) - self.assertEqual( node2.varType( ) , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) - self.assertEqual( node2.getNum( ) , 10 ) - - node3 = case.smspec_node("RGPT:1") - self.assertEqual( node3.varType( ) , EclSumVarType.ECL_SMSPEC_REGION_VAR ) - self.assertEqual( node3.getNum( ) , 1 ) - self.assertTrue( node3.isTotal( )) - - self.assertLess( node1, node3 ) - self.assertGreater( node2, node3 ) - self.assertEqual( node1, node1 ) - self.assertNotEqual( node1, node2 ) - - with self.assertRaises(TypeError): - a = node1 < 1 - - def test_csv_export(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0)]) - sep = ";" - with TestAreaContext("ecl/csv"): - case.exportCSV( "file.csv" , sep = sep) - self.assertTrue( os.path.isfile( "file.csv" ) ) - input_file = csv.DictReader( open("file.csv") , delimiter = sep ) - for row in input_file: - self.assertIn("DAYS", row) - self.assertIn("DATE", row) - self.assertIn("FOPT", row) - self.assertIn("FOPR", row) - self.assertEqual( len(row) , 4 ) - break - - - - with TestAreaContext("ecl/csv"): - case.exportCSV( "file.csv" , keys = ["FOPT"] , sep = sep) - self.assertTrue( os.path.isfile( "file.csv" ) ) - input_file = csv.DictReader( open("file.csv") , delimiter=sep) - for row in input_file: - self.assertIn("DAYS", row) - self.assertIn("DATE", row) - self.assertIn("FOPT", row) - self.assertEqual( len(row) , 3 ) - break - - - - with TestAreaContext("ecl/csv"): - date_format = "%y-%m-%d" - sep = "," - case.exportCSV( "file.csv" , keys = ["F*"] , sep=sep , date_format = date_format) - self.assertTrue( os.path.isfile( "file.csv" ) ) - with open("file.csv") as f: - time_index = -1 - for line in f.readlines(): - tmp = line.split( sep ) - self.assertEqual( len(tmp) , 4) - - if time_index >= 0: - d = datetime.datetime.strptime( tmp[1] , date_format ) - self.assertEqual( case.iget_date( time_index ) , d ) - - time_index += 1 - - - def test_solve(self): - length = 100 - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = length, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - - self.assert_solve( case ) - - def assert_solve(self, case): - with self.assertRaises( KeyError ): - case.solveDays( "MISSING:KEY" , 0.56) - - sol = case.solveDays( "FOPT" , 150 ) - self.assertEqual( len(sol) , 0 ) - - sol = case.solveDays( "FOPT" , -10 ) - self.assertEqual( len(sol) , 0 ) - - sol = case.solveDays( "FOPT" , 50 ) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 50 ) - - sol = case.solveDays( "FOPT" , 50.50 ) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 50.50 ) - - sol = case.solveDays( "FOPR" , 50.90 ) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 50.00 + 1.0/86400 ) - - sol = case.solveDates("FOPR" , 50.90) - t = case.getDataStartTime( ) + datetime.timedelta( days = 50 ) + datetime.timedelta( seconds = 1 ) - self.assertEqual( sol[0] , t ) - - sol = case.solveDays( "FOPR" , 50.90 , rates_clamp_lower = False) - self.assertEqual( len(sol) , 1 ) - self.assertFloatEqual( sol[0] , 51.00 ) - - sol = case.solveDays( "FGPT" ,25.0) - self.assertEqual( len(sol) , 2 ) - self.assertFloatEqual( sol[0] , 25.00 ) - self.assertFloatEqual( sol[1] , 75.00 ) - - sol = case.solveDates( "FGPT" , 25 ) - self.assertEqual( len(sol) , 2 ) - t0 = case.getDataStartTime( ) - t1 = t0 + datetime.timedelta( days = 25 ) - t2 = t0 + datetime.timedelta( days = 75 ) - self.assertEqual( sol[0] , t1 ) - self.assertEqual( sol[1] , t2 ) - - - def test_ecl_sum_vector_algebra(self): - scalar = 0.78 - addend = 2.718281828459045 - - # setup - length = 100 - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = length, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - with self.assertRaises( KeyError ): - case.scaleVector( "MISSING:KEY" , scalar) - case.shiftVector( "MISSING:KEY" , addend) - - # scale all vectors with scalar - for key in case.keys(): - x = case.get_values(key) # get vector key - case.scaleVector(key , scalar) - y = case.get_values(key) - x = x * scalar # numpy vector scaling - for i in range(len(x)): - self.assertFloatEqual(x[i], y[i]) - - # shift all vectors with addend - for key in case.keys(): - x = case.get_values(key) # get vector key - case.shiftVector(key , addend) - y = case.get_values(key) - x = x + addend # numpy vector shifting - for i in range(len(x)): - self.assertFloatEqual(x[i], y[i]) - - - def test_different_names(self): - length = 100 - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = length, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - - with TestAreaContext("sum_different"): - case.fwrite( ) - shutil.move("CSV.SMSPEC" , "CSVX.SMSPEC") - with self.assertRaises(IOError): - case2 = EclSum.load( "Does/not/exist" , "CSV.UNSMRY") - - with self.assertRaises(IOError): - case2 = EclSum.load( "CSVX.SMSPEC" , "CSVX.UNSMRY") - - case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" ) - self.assert_solve( case2 ) - - def test_invalid(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = 100, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - - with TestAreaContext("sum_invalid"): - case.fwrite( ) - with open("CASE.txt", "w") as f: - f.write("No - this is not EclKW file ....") - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CSV.SMSPEC" , "CASE.txt" ) - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CASE.txt" , "CSV.UNSMRY" ) - - kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT) - kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT) - - with openFortIO( "CASE.KW" , FortIO.WRITE_MODE) as f: - kw1.fwrite( f ) - kw2.fwrite( f ) - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CSV.SMSPEC" , "CASE.KW") - - with self.assertRaises( IOError ): - case2 = EclSum.load( "CASE.KW" , "CSV.UNSMRY" ) - - - def test_kw_vector(self): - case = createEclSum("CSV" , [("FOPT", None , 0) , ("FOPR" , None , 0), ("FGPT" , None , 0)], - sim_length_days = 100, - num_report_step = 10, - num_mini_step = 10, - func_table = {"FOPT" : fopt, - "FOPR" : fopr , - "FGPT" : fgpt }) - kw_list = EclSumKeyWordVector( case ) - kw_list.add_keyword("FOPT") - kw_list.add_keyword("FOPR") - kw_list.add_keyword("FGPT") - - t = case.getDataStartTime( ) + datetime.timedelta( days = 43 ); - data = case.get_interp_row( kw_list , t ) - for d1,d2 in zip(data, [ case.get_interp("FOPT", date = t), - case.get_interp("FOPT", date = t), - case.get_interp("FOPT", date = t) ]): - - self.assertFloatEqual(d1,d2) - - tmp = [] - for key in kw_list: - tmp.append(key) - - for (k1,k2) in zip(kw_list,tmp): - self.assertEqual(k1,k2) diff --git a/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt new file mode 100644 index 0000000000..6444b8bfe3 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/CMakeLists.txt @@ -0,0 +1,92 @@ +set(TEST_SOURCES + __init__.py + test_deprecation.py + test_removed.py + test_ecl_3dkw.py + test_ecl_file_statoil.py + test_ecl_file.py + test_ecl_init_file.py + test_ecl_restart_file.py + test_debug.py + test_ecl_sum.py + test_ecl_sum_vector.py + test_fault_blocks.py + test_fault_blocks_statoil.py + test_faults.py + test_fortio.py + test_grdecl.py + test_grid.py + test_cell.py + test_grid_statoil.py + test_grid_generator.py + test_indexed_read.py + test_ecl_kw_statoil.py + test_ecl_kw.py + test_kw_function.py + test_layer.py + test_npv.py + test_region.py + test_region_statoil.py + test_restart.py + test_rft.py + test_rft_statoil.py + test_rft_cell.py + test_statoil_faults.py + test_sum_statoil.py + test_ecl_util.py + test_ecl_cmp.py + test_sum.py + test_grav.py + test_geertsma.py + test_ecl_type.py + test_restart_head.py + test_fk_user_data.py +) + +add_python_package("python.tests.ecl_tests" ${PYTHON_INSTALL_PREFIX}/tests/ecl_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.ecl_tests.test_fk_user_data.FKTest) +addPythonTest(tests.ecl_tests.test_cell.CellTest) +addPythonTest(tests.ecl_tests.test_grid.GridTest LABELS SLOW_1) +addPythonTest(tests.ecl_tests.test_grid_generator.GridGeneratorTest LABELS SLOW_2) +addPythonTest(tests.ecl_tests.test_ecl_kw.KWTest LABELS SLOW_2) +addPythonTest(tests.ecl_tests.test_kw_function.KWFunctionTest) +addPythonTest(tests.ecl_tests.test_ecl_3dkw.Ecl3DKWTest ) +addPythonTest(tests.ecl_tests.test_rft.RFTTest) +addPythonTest(tests.ecl_tests.test_rft_cell.RFTCellTest) +addPythonTest(tests.ecl_tests.test_sum.SumTest) +addPythonTest(tests.ecl_tests.test_layer.LayerTest ) +addPythonTest(tests.ecl_tests.test_faults.FaultTest ) +addPythonTest(tests.ecl_tests.test_fault_blocks.FaultBlockTest ) +addPythonTest(tests.ecl_tests.test_deprecation.Deprecation_1_9_Test ) +addPythonTest(tests.ecl_tests.test_deprecation.Deprecation_2_0_Test ) +addPythonTest(tests.ecl_tests.test_deprecation.Deprecation_2_1_Test ) +addPythonTest(tests.ecl_tests.test_removed.Removed_2_1_Test ) +addPythonTest(tests.ecl_tests.test_ecl_util.EclUtilTest ) +addPythonTest(tests.ecl_tests.test_fortio.FortIOTest) +addPythonTest(tests.ecl_tests.test_ecl_file.EclFileTest) +addPythonTest(tests.ecl_tests.test_grav.EclGravTest) +addPythonTest(tests.ecl_tests.test_geertsma.GeertsmaTest) +addPythonTest(tests.ecl_tests.test_ecl_type.EclDataTypeTest) +addPythonTest(tests.ecl_tests.test_region.RegionTest) +addPythonTest(tests.ecl_tests.test_debug.DebugTest) + + +addPythonTest(tests.ecl_tests.test_ecl_file_statoil.EclFileStatoilTest) +addPythonTest(tests.ecl_tests.test_grdecl.GRDECLTest) +addPythonTest(tests.ecl_tests.test_grid_statoil.GridTest) +addPythonTest(tests.ecl_tests.test_ecl_kw_statoil.KWTest) +addPythonTest(tests.ecl_tests.test_ecl_init_file.InitFileTest) +addPythonTest(tests.ecl_tests.test_ecl_restart_file.RestartFileTest) +addPythonTest(tests.ecl_tests.test_restart.RestartTest ) +addPythonTest(tests.ecl_tests.test_region_statoil.RegionTest) +addPythonTest(tests.ecl_tests.test_rft_statoil.RFTTest) +addPythonTest(tests.ecl_tests.test_sum_statoil.SumTest) +addPythonTest(tests.ecl_tests.test_ecl_sum_vector.EclSumVectorTest) +addPythonTest(tests.ecl_tests.test_ecl_sum.EclSumTest) +addPythonTest(tests.ecl_tests.test_statoil_faults.StatoilFaultTest) +addPythonTest(tests.ecl_tests.test_fault_blocks_statoil.FaultBlockTest) +addPythonTest(tests.ecl_tests.test_npv.NPVTest) +addPythonTest(tests.ecl_tests.test_indexed_read.EclIndexedReadTest) +addPythonTest(tests.ecl_tests.test_ecl_cmp.EclCmpTest) +addPythonTest(tests.ecl_tests.test_restart_head.RestartHeadTest) diff --git a/ThirdParty/Ert/python/tests/legacy/__init__.py b/ThirdParty/Ert/python/tests/ecl_tests/__init__.py similarity index 100% rename from ThirdParty/Ert/python/tests/legacy/__init__.py rename to ThirdParty/Ert/python/tests/ecl_tests/__init__.py diff --git a/ThirdParty/Ert/python/tests/ecl/test_cell.py b/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py similarity index 96% rename from ThirdParty/Ert/python/tests/ecl/test_cell.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_cell.py index 1764b7fe7c..5b8f41e52b 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_cell.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_cell.py @@ -15,10 +15,11 @@ # See the GNU General Public License at # for more details. -from ecl.ecl import Cell, EclGrid -from ecl.test import ExtendedTestCase +from ecl.grid import Cell, EclGrid +from tests import EclTest +from unittest import skipUnless -class CellTest(ExtendedTestCase): +class CellTest(EclTest): def setUp(self): fk = self.createTestPath('local/ECLIPSE/faarikaal/faarikaal1.EGRID') @@ -96,3 +97,4 @@ def test_repr(self): r = repr(c) self.assertTrue(r.startswith('Cell(4, 1, 82, active, ')) self.assertIn('faarikaal1.EGRID', r) + diff --git a/ThirdParty/Ert/python/tests/ecl/test_debug.py b/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py similarity index 90% rename from ThirdParty/Ert/python/tests/ecl/test_debug.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_debug.py index 344527d34a..49e4f997f1 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_debug.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_debug.py @@ -14,9 +14,10 @@ # See the GNU General Public License at # for more details. -from ecl.test import debug_msg, ExtendedTestCase +from ecl.util.test import debug_msg +from tests import EclTest -class DebugTest(ExtendedTestCase): +class DebugTest(EclTest): def test_create(self): msg = debug_msg( "DEBUG" ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_deprecation.py b/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py similarity index 75% rename from ThirdParty/Ert/python/tests/ecl/test_deprecation.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py index cd818abc5e..869b6a4168 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_deprecation.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_deprecation.py @@ -18,21 +18,24 @@ import time import datetime -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.ecl import EclFile, EclGrid, EclKW, EclDataType, EclGrid, EclRegion -from ecl.ecl import FortIO, openFortIO, EclRFT, EclGridGenerator -from ecl.test.ecl_mock import createEclSum -from ecl.util import BoolVector +from ecl.util.test import TestAreaContext +from ecl import EclDataType +from ecl.eclfile import EclFile, EclKW, FortIO, openFortIO +from ecl.grid import EclGrid, EclGrid, EclRegion, EclGridGenerator +from ecl.rft import EclRFT +from ecl.util.test.ecl_mock import createEclSum +from ecl.util.util import BoolVector +from tests import EclTest # The class Deprecation_1_9_Test contains methods which will be marked # as deprecated in the 1.9.x versions. warnings.simplefilter("error" , DeprecationWarning) -class Deprecation_2_1_Test(ExtendedTestCase): +class Deprecation_2_1_Test(EclTest): pass -class Deprecation_2_0_Test(ExtendedTestCase): +class Deprecation_2_0_Test(EclTest): def test_EclFile_name_property(self): with TestAreaContext("name") as t: @@ -43,7 +46,7 @@ def test_EclFile_name_property(self): t.sync() f = EclFile( "TEST" ) -class Deprecation_1_9_Test(ExtendedTestCase): +class Deprecation_1_9_Test(EclTest): def test_EclRegion_properties(self): grid = EclGridGenerator.createRectangular( (10,10,10) , (1,1,1)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py similarity index 95% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py index f6bdabb0c3..e6a8fed20a 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_3dkw.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_3dkw.py @@ -17,13 +17,15 @@ import os import random -from ecl.util import IntVector -from ecl.ecl import Ecl3DKW , EclKW, EclDataType, EclFile, FortIO, EclFileFlagEnum , EclGrid -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.util import IntVector +from ecl import EclDataType, EclFileFlagEnum +from ecl.eclfile import Ecl3DKW , EclKW, EclFile, FortIO +from ecl.grid import EclGrid +from ecl.util.test import TestAreaContext +from tests import EclTest - -class Ecl3DKWTest(ExtendedTestCase): +class Ecl3DKWTest(EclTest): def test_create( self ): actnum = IntVector(default_value = 1 , initial_size = 1000) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py similarity index 80% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py index 807c0b9ab0..39adb1fcb9 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_cmp.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_cmp.py @@ -1,29 +1,31 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'test_ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'test_ecl_cmp.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 # for more details. -from ecl.test import ExtendedTestCase , TestAreaContext -from ecl.test.ecl_mock import createEclSum -from ecl.ecl import EclCmp +from ecl.util.test import TestAreaContext +from ecl.util.test.ecl_mock import createEclSum +from ecl.summary import EclCmp +from tests import EclTest, statoil_test -class EclCmpTest(ExtendedTestCase): +@statoil_test() +class EclCmpTest(EclTest): def setUp(self): self.root1 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") self.root2 = self.createTestPath("Statoil/ECLIPSE/Oseberg/F8MLT/F8MLT-F4") - + def test_not_existing(self): with self.assertRaises(IOError): ecl_cmp = EclCmp( "missing/case1" , "missing/case2") @@ -37,17 +39,17 @@ def test_not_existing(self): ecl_cmp = EclCmp( self.root1 , self.root1) ecl_cmp = EclCmp( self.root2 , self.root2) - + def test_different_start(self): with self.assertRaises(ValueError): ecl_cmp = EclCmp(self.root1 , self.root2) - + def test_summary_cmp(self): ecl_cmp = EclCmp( self.root1 , self.root1) self.assertEqual( (False , False) , ecl_cmp.hasSummaryVector("MISSING")) self.assertEqual( (True , True) , ecl_cmp.hasSummaryVector("FOPT")) - + with self.assertRaises(KeyError): diff = ecl_cmp.cmpSummaryVector("MISSING") @@ -55,7 +57,7 @@ def test_summary_cmp(self): self.assertEqual( diff_sum , 0.0 ) self.assertTrue( ecl_cmp.endTimeEqual( ) ) - + def test_wells(self): ecl_cmp = EclCmp( self.root1 , self.root1) wells = ecl_cmp.testWells() @@ -64,5 +66,5 @@ def test_wells(self): self.assertEqual( len(wells) , len(well_set)) for well in wells: self.assertTrue( well in well_set ) - + diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py similarity index 96% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_file.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py index bd6ff62248..717012aed3 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_file.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file.py @@ -19,11 +19,11 @@ import gc from unittest import skipIf - -from ecl.ecl import EclFile, FortIO, EclKW , openFortIO , openEclFile -from ecl.ecl import EclFileFlagEnum, EclDataType, EclFileEnum -from ecl.util import CWDContext -from ecl.test import ExtendedTestCase , TestAreaContext, PathContext +from ecl import EclFileFlagEnum, EclDataType, EclFileEnum +from ecl.eclfile import EclFile, FortIO, EclKW , openFortIO , openEclFile +from ecl.util.util import CWDContext +from ecl.util.test import TestAreaContext, PathContext +from tests import EclTest def createFile( name , kw_list ): with openFortIO(name , mode = FortIO.WRITE_MODE) as f: @@ -42,7 +42,7 @@ def loadKeywords( name ): -class EclFileTest(ExtendedTestCase): +class EclFileTest(EclTest): def assertFileType(self , filename , expected): file_type , step , fmt_file = EclFile.getFileType(filename) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py similarity index 95% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py index 63b6a628da..8377b639f0 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_file_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_file_statoil.py @@ -18,15 +18,15 @@ import os.path from unittest import skipIf -from ecl.ecl import EclFile, FortIO, EclKW , openFortIO , openEclFile -from ecl.ecl import EclFileFlagEnum, EclFileEnum +from ecl import EclFileFlagEnum, EclFileEnum +from ecl.eclfile import EclFile, FortIO, EclKW , openFortIO , openEclFile -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test - - -class EclFileStatoilTest(ExtendedTestCase): +@statoil_test() +class EclFileStatoilTest(EclTest): def setUp(self): self.test_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") self.test_fmt_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.FUNRST") @@ -46,7 +46,6 @@ def test_fast_open(self): for kw0,kw1 in zip(f0,f1): self.assertEqual( kw0,kw1 ) - def test_restart_days(self): rst_file = EclFile( self.test_file ) self.assertAlmostEqual( 0.0 , rst_file.iget_restart_sim_days(0) ) @@ -60,7 +59,6 @@ def test_restart_days(self): rst_file.restart_get_kw("SWAT" , dtime = datetime.date( 1985 , 1 , 1)) - def test_iget_named(self): f = EclFile(self.test_file) N = f.num_named_kw( "SWAT" ) @@ -82,7 +80,7 @@ def test_fwrite( self ): - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow file test skipped!") + @skipIf(EclTest.slowTestShouldNotRun(), "Slow file test skipped!") def test_save(self): #work_area = TestArea("python/ecl_file/save") with TestAreaContext("python/ecl_file/save", store_area=False) as work_area: @@ -111,7 +109,7 @@ def test_save(self): - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow file test skipped!") + @skipIf(EclTest.slowTestShouldNotRun(), "Slow file test skipped!") def test_save_fmt(self): #work_area = TestArea("python/ecl_file/save_fmt") with TestAreaContext("python/ecl_file/save_fmt") as work_area: @@ -224,7 +222,7 @@ def test_ix_case(self): ] padd = lambda str_len : (lambda s : s + (" " * (max(0, str_len-len(s))))) - self.assertEqual(map(padd(8), keywords_from_file), keywords_loaded) + self.assertEqual( list(map(padd(8), keywords_from_file)), keywords_loaded) # Names self.assertTrue( "NAMES" in f ) @@ -274,4 +272,4 @@ def test_ix_case(self): ':+:+:+:+', ':+:+:+:+', ':+:+:+:+', ':+:+:+:+' ] - self.assertEqual(map(padd(10), names_from_file), names_loaded) + self.assertEqual( list(map(padd(10), names_from_file)), names_loaded) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py similarity index 86% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py index 3792354d54..9be2c65c72 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_init_file.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_init_file.py @@ -15,11 +15,13 @@ # for more details. -from ecl.test import ExtendedTestCase -from ecl.ecl import (Ecl3DKW, EclKW, EclInitFile, EclFile, FortIO, - EclFileFlagEnum, EclGrid) +from tests import EclTest, statoil_test +from ecl import EclFileFlagEnum +from ecl.eclfile import Ecl3DKW, EclKW, EclInitFile, EclFile, FortIO +from ecl.grid import EclGrid -class InitFileTest(ExtendedTestCase): +@statoil_test() +class InitFileTest(EclTest): def setUp(self): diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py similarity index 75% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py index f88f5e4c91..88d4fa9fb7 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw.py @@ -14,15 +14,17 @@ # # See the GNU General Public License at # for more details. -import os import random -import numpy import warnings +import cwrap +import random + +from ecl import EclDataType, EclTypeEnum, EclFileFlagEnum +from ecl.eclfile import EclKW, EclFile, FortIO, openFortIO -from ecl.ecl import (EclKW, EclDataType, EclTypeEnum, EclFile, FortIO, - EclFileFlagEnum, openFortIO) -from ecl.test import ExtendedTestCase, TestAreaContext +from ecl.util.test import TestAreaContext +from tests import EclTest def copy_long(): @@ -35,7 +37,7 @@ def copy_offset(): copy = src.sub_copy(200, 100) -class KWTest(ExtendedTestCase): +class KWTest(EclTest): def test_name(self): kw = EclKW('TEST', 3, EclDataType.ECL_INT) @@ -77,12 +79,10 @@ def kw_test(self, data_type, data, fmt): name1 = "file1.txt" name2 = "file2.txt" kw = EclKW("TEST", len(data), data_type) - i = 0 - for d in data: + for (i,d) in enumerate(data): kw[i] = d - i += 1 - file1 = open(name1, "w") + file1 = cwrap.open(name1, "w") kw.fprintf_data(file1, fmt) file1.close() @@ -193,7 +193,7 @@ def test_fprintf_data(self): for i in range(len(kw)): kw[i] = i - fileH = open("test", "w") + fileH = cwrap.open("test", "w") kw.fprintf_data(fileH) fileH.close() @@ -411,7 +411,7 @@ def test_resize(self): kw.resize(N/2) self.assertEqual(len(kw), N/2) - for i in range(N/2): + for i in range(int(N / 2)): self.assertEqual(kw[i], i) @@ -473,3 +473,140 @@ def test_string_padding(self): kw = EclKW("TEST_KW", 1, EclDataType.ECL_CHAR) kw[0] = "ABCD" self.assertEqual(kw[0], "ABCD ") + + + + def test_add_squared(self): + kw1 = EclKW("TEST_KW", 3, EclDataType.ECL_STRING(4)) + kw2 = EclKW("TEST_KW", 3, EclDataType.ECL_STRING(4)) + + with self.assertRaises(TypeError): + kw1.add_squared(kw2) + + + kw1 = EclKW("T1", 10, EclDataType.ECL_INT) + kw2 = EclKW("T2", 11, EclDataType.ECL_INT) + with self.assertRaises(ValueError): + kw1.add_squared(kw2) + + kw2 = EclKW("T", 10, EclDataType.ECL_FLOAT) + with self.assertRaises(ValueError): + kw1.add_squared(kw2) + + kw2 = EclKW("T2", 10, EclDataType.ECL_INT) + kw2.assign(2) + kw1.add_squared(kw2) + + for elm in kw1: + self.assertEqual(elm, 4) + + + def test_scatter_copy(self): + source = EclKW("SOURCE", 4 , EclDataType.ECL_INT) + with self.assertRaises(TypeError): + copy = source.scatter_copy([1,1,1,1]) + + actnum = EclKW("ACTNUM", 6 , EclDataType.ECL_FLOAT) + with self.assertRaises(ValueError): + copy = source.scatter_copy(actnum) + + + actnum = EclKW("ACTNUM", 8, EclDataType.ECL_INT) + actnum[0] = 1 + actnum[1] = 1 + with self.assertRaises(ValueError): + copy = source.scatter_copy(actnum) + + actnum.assign(1) + with self.assertRaises(ValueError): + copy = source.scatter_copy(actnum) + + + for i in range(4): + source[i] = i+1 + actnum[2*i] = 0 + + # src = [1,2,3,4] + # actnum = [0,1,0,1,0,1,0,1] + # copy = [0,1,0,2,0,3,0,4] + copy = source.scatter_copy(actnum) + for i in range(4): + self.assertEqual(copy[2*i + 1], i+1) + + def test_safe_div(self): + kw1 = EclKW("SOURCE", 10, EclDataType.ECL_INT) + kw2 = EclKW("XXX", 11, EclDataType.ECL_INT) + + with self.assertRaises(ValueError): + kw1.safe_div(kw2) + + kw1 = EclKW("SOURCE", 2, EclDataType.ECL_FLOAT) + kw1.assign(10) + + kw2 = EclKW("DIV", 2, EclDataType.ECL_INT) + kw2[0] = 0 + kw2[1] = 2 + + kw1.safe_div( kw2 ) + self.assertEqual(kw1[0], 10) + self.assertEqual(kw1[1], 5) + + + + def test_fmu_stat_workflow(self): + N = 100 + global_size = 100 + active_size = 50 + with TestAreaContext("FMU_FILES"): + for i in range(N): + permx = EclKW("PERMX", active_size, EclDataType.ECL_FLOAT) + poro = EclKW("PORO", active_size, EclDataType.ECL_FLOAT) + porv = EclKW("PORV", global_size, EclDataType.ECL_FLOAT) + + porv.assign(0) + for g in random.sample( range(global_size), active_size): + porv[g] = 1 + + permx.assign(random.random()) + poro.assign(random.random()) + + with openFortIO("TEST%d.INIT" % i, FortIO.WRITE_MODE) as f: + permx.fwrite(f) + poro.fwrite(f) + porv.fwrite(f) + + mean_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT) + std_permx = EclKW("PERMX", global_size, EclDataType.ECL_FLOAT) + mean_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT) + std_poro = EclKW("PORO", global_size, EclDataType.ECL_FLOAT) + + count = EclKW("COUNT", global_size, EclDataType.ECL_INT) + for i in range(N): + f = EclFile("TEST%d.INIT" % i) + + porv = f["PORV"][0] + permx = f["PERMX"][0] + poro = f["PORO"][0] + + actnum = porv.create_actnum() + + global_permx = permx.scatter_copy( actnum ) + mean_permx += global_permx + std_permx.add_squared( global_permx) + + global_poro = poro.scatter_copy( actnum ) + mean_poro += global_poro + std_poro.add_squared( global_poro) + + count += actnum + + + mean_permx.safe_div(count) + std_permx.safe_div(count) + std_permx -= mean_permx * mean_permx + std_permx.isqrt() + + mean_poro.safe_div(count) + std_poro.safe_div(count) + std_poro -= mean_poro * mean_poro + std_poro.isqrt() diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py similarity index 87% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py index 21d6b63c40..13b2d5d292 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_kw_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_kw_statoil.py @@ -1,25 +1,26 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# +# Copyright (C) 2011 Statoil ASA, Norway. +# # The file 'test_kw.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. import os import random -from ecl.ecl import EclKW, EclDataType, EclFile, FortIO, EclFileFlagEnum - -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl import EclDataType, EclFileFlagEnum +from ecl.eclfile import EclKW, EclFile, FortIO +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test def copy_long(): src = EclKW("NAME", 100, EclDataType.ECL_FLOAT) @@ -31,7 +32,8 @@ def copy_offset(): copy = src.sub_copy(200, 100) -class KWTest(ExtendedTestCase): +@statoil_test() +class KWTest(EclTest): def test_fortio_size( self ): unrst_file_path = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") unrst_file = EclFile(unrst_file_path) @@ -109,4 +111,4 @@ def test_equal(self): self.assertFalse(kw1.equal(kw2)) self.assertFalse(kw1.equal_numeric(kw2)) - + diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py similarity index 79% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py index e2779e6d5e..690ac7ba52 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_restart_file.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_restart_file.py @@ -1,31 +1,34 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# +# Copyright (C) 2015 Statoil ASA, Norway. +# # The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. import datetime -from ecl.test import ExtendedTestCase -from ecl.ecl import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO, EclFileFlagEnum , EclGrid +from tests import EclTest, statoil_test +from ecl import EclFileFlagEnum +from ecl.eclfile import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO +from ecl.grid import EclGrid -class RestartFileTest(ExtendedTestCase): +@statoil_test() +class RestartFileTest(EclTest): def setUp(self): self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") self.xrst_file0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") self.xrst_file10 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0010") self.xrst_file20 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0020") - + def test_load(self): g = EclGrid( self.grid_file ) @@ -33,10 +36,10 @@ def test_load(self): head = f["INTEHEAD"][0] self.assertTrue( isinstance( head , EclKW )) - + swat = f["SWAT"][0] self.assertTrue( isinstance( swat , Ecl3DKW )) - + pressure = f["PRESSURE"][0] self.assertTrue( isinstance( pressure , Ecl3DKW )) @@ -46,22 +49,22 @@ def test_type(self): with self.assertRaises(ValueError): f = EclRestartFile( g , "NOT_A_RESTART_FILE") - + def test_unified(self): g = EclGrid( self.grid_file ) f_unrst = EclRestartFile( g , self.unrst_file ) f_x0 = EclRestartFile( g , self.xrst_file0 ) f_x10 = EclRestartFile( g , self.xrst_file10 ) f_x20 = EclRestartFile( g , self.xrst_file20 ) - + self.assertTrue( f_unrst.unified() ) self.assertFalse( f_x0.unified() ) self.assertFalse( f_x10.unified() ) self.assertFalse( f_x20.unified() ) - + self.assertEqual( [(10 , datetime.datetime( 2000 , 10 , 1 , 0 , 0 , 0 ) , 274.0)] , f_x10.timeList()) unrst_timeList = f_unrst.timeList() - self.assertEqual( len(unrst_timeList) , 63 ) + self.assertEqual( len(unrst_timeList) , 63 ) self.assertEqual( (62 , datetime.datetime( 2004 , 12 , 31 , 0 , 0 , 0 ) , 1826.0) , unrst_timeList[62]); diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py similarity index 93% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py index f729589909..2177dbce95 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum.py @@ -19,12 +19,15 @@ import os.path from cwrap import CFILE -from ecl.ecl import EclSum, EclSumKeyWordVector, EclFile -from ecl.ecl import FortIO, openFortIO, openEclFile, EclKW -from ecl.test import ExtendedTestCase, TestAreaContext +from cwrap import Prototype, load, open as copen +from ecl.eclfile import EclFile, FortIO, openFortIO, openEclFile, EclKW +from ecl.summary import EclSum, EclSumKeyWordVector +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test -class EclSumTest(ExtendedTestCase): +@statoil_test() +class EclSumTest(EclTest): def setUp(self): @@ -60,7 +63,7 @@ def test_dump_csv_line(self): dtime = datetime.datetime(2002, 1, 1, 0, 0, 0) with TestAreaContext("EclSum/csv_dump"): test_file_name = self.createTestPath("dump.csv") - outputH = open(test_file_name, "w") + outputH = copen(test_file_name, "w") self.ecl_sum.dumpCSVLine(dtime, ecl_sum_vector, outputH) assert os.path.isfile(test_file_name) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py similarity index 94% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py index 8a15241a09..add1916a34 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_tstep.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_tstep.py @@ -1,10 +1,10 @@ from datetime import datetime import random from ecl.ecl import EclSumTStep, EclSum -from ecl.test import ExtendedTestCase +from tests import EclTest -class EclSumTStepTest(ExtendedTestCase): +class EclSumTStepTest(EclTest): def test_creation(self): ecl_sum = EclSum.writer("TEST", datetime(2010, 1, 1), 10, 10, 10) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py similarity index 87% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py index a5bfebf7fb..454fa9143a 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_sum_vector.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_sum_vector.py @@ -22,11 +22,11 @@ import warnings -from ecl.ecl import EclSumVector, EclSum -from ecl.test import ExtendedTestCase +from ecl.summary import EclSumVector, EclSum +from tests import EclTest, statoil_test - -class EclSumVectorTest(ExtendedTestCase): +@statoil_test() +class EclSumVectorTest(EclTest): def setUp(self): @@ -47,7 +47,8 @@ def test_basic(self): pfx = 'EclSum(name' self.assertEqual(pfx, repr(self.ecl_sum)[:len(pfx)]) it = iter(self.ecl_sum) - t = self.ecl_sum[it.next()] # EclSumVector + #t = self.ecl_sum[it.next()] # EclSumVector + t = self.ecl_sum[next(it)] # EclSumVector self.assertEqual(63, len(t)) self.assertEqual('BARSA', t.unit) pfx = 'EclSumVector(key = ' diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_type.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py similarity index 96% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_type.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py index 48da066718..537e7a61de 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_type.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_type.py @@ -1,11 +1,12 @@ -from ecl.test import TestAreaContext, ExtendedTestCase +from ecl.util.test import TestAreaContext +from tests import EclTest -from ecl.ecl import EclDataType, EclTypeEnum +from ecl import EclDataType, EclTypeEnum def get_const_size_types(): return EclTypeEnum.enums()[:-1:] -class EclDataTypeTest(ExtendedTestCase): +class EclDataTypeTest(EclTest): # All of the below should list their elements in the same order as # EclTypeEnum! @@ -124,7 +125,7 @@ def test_equals(self): def test_hash(self): all_types = set() - test_base = zip(self.TYPES, self.SIZES) + test_base = list(zip(self.TYPES, self.SIZES)) for index, (ecl_type, elem_size) in enumerate(test_base): all_types.add(EclDataType(ecl_type, elem_size)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_ecl_util.py b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py similarity index 73% rename from ThirdParty/Ert/python/tests/ecl/test_ecl_util.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py index 497f52769c..89003401c1 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_ecl_util.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_ecl_util.py @@ -1,24 +1,24 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# Copyright (C) 2015 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 # for more details. -from ecl.ecl import EclGrid , EclUtil, EclTypeEnum , EclFileEnum, EclPhaseEnum, EclUnitTypeEnum -from ecl.test import ExtendedTestCase +from ecl import EclTypeEnum , EclFileEnum, EclPhaseEnum, EclUnitTypeEnum, EclUtil +from ecl.grid import EclGrid +from tests import EclTest - -class EclUtilTest(ExtendedTestCase): +class EclUtilTest(EclTest): def test_enums(self): source_file_path = "lib/include/ert/ecl/ecl_util.h" @@ -28,15 +28,15 @@ def test_enums(self): source_file_path = "lib/include/ert/ecl/ecl_type.h" self.assertEnumIsFullyDefined(EclTypeEnum, "ecl_type_enum", source_file_path) - + def test_file_type(self): file_type , fmt , report = EclUtil.inspectExtension("CASE.X0078") self.assertEqual( file_type , EclFileEnum.ECL_RESTART_FILE ) - + def test_file_report_nr(self): report_nr = EclUtil.reportStep("CASE.X0080") self.assertEqual( report_nr , 80 ) with self.assertRaises(ValueError): EclUtil.reportStep("CASE.EGRID") - + diff --git a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py similarity index 90% rename from ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py index 9275c9a5dc..8e6ca732c4 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks.py @@ -1,30 +1,34 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# +# Copyright (C) 2014 Statoil ASA, Norway. +# # The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. from __future__ import print_function from unittest import skipIf import warnings +import cwrap -from ecl.ecl import EclGrid, EclKW , EclRegion, EclDataType -from ecl.ecl.faults import FaultBlock, FaultBlockLayer, FaultBlockCell,FaultCollection -from ecl.geo import Polyline , CPolylineCollection -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid, EclRegion +from ecl.grid.faults import FaultBlock, FaultBlockLayer, FaultBlockCell,FaultCollection +from ecl.util.geometry import Polyline , CPolylineCollection +from ecl.util.test import TestAreaContext +from tests import EclTest -class FaultBlockTest(ExtendedTestCase): +class FaultBlockTest(EclTest): def setUp(self): self.grid = EclGrid.createRectangular( (10,10,10) , (1,1,1) ) self.kw = EclKW( "FAULTBLK" , self.grid.getGlobalSize() , EclDataType.ECL_INT ) @@ -67,9 +71,10 @@ def test_get_ijk(self): fileH.write("4 4 4 0 0\n") fileH.write("4 4 4 0 5\n") fileH.write("/\n") + with cwrap.open("kw.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) - kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) layer = FaultBlockLayer( grid , 0 ) layer.loadKeyword( kw ) @@ -100,8 +105,10 @@ def test_neighbours(self): fileH.write("4 4 4 0 5\n") fileH.write("/\n") - kw = EclKW.read_grdecl(open("kw.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - + with cwrap.open("kw.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + grid = EclGrid.createRectangular( (5,5,1) , (1,1,1) ) layer = FaultBlockLayer( grid , 0 ) @@ -159,14 +166,17 @@ def test_neighbours2(self): fileH.write("3 3 3 3 2 2 2 2 \n") fileH.write("3 3 3 3 2 2 2 2 \n") fileH.write("/\n") - - kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - with open("faults.grdecl" , "w") as f: + + with cwrap.open("faultblock.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) + + with open("faults.grdecl", "w") as f: f.write("FAULTS\n") f.write("\'FY\' 1 4 4 4 1 1 'Y' /\n") f.write("\'FX\' 4 4 1 8 1 1 'X' /\n") f.write("/") - + faults = FaultCollection( grid , "faults.grdecl") layer.loadKeyword( kw ) b1 = layer.getBlock( 1 ) @@ -225,14 +235,16 @@ def test_neighbours3(self): fileH.write("1 1 1 1 1 2 2 2 \n") fileH.write("1 1 1 1 1 2 2 2 \n") fileH.write("/\n") - - kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) + + with cwrap.open("faultblock.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) with open("faults.grdecl" , "w") as f: f.write("FAULTS\n") f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") f.write("/") - + faults = FaultCollection( grid , "faults.grdecl") layer.loadKeyword( kw ) b1 = layer.getBlock( 1 ) @@ -435,15 +447,17 @@ def test_internal_blocks(self): fileH.write("1 1 1 1 1 2 2 2 \n") fileH.write("/\n") + with cwrap.open("faultblock.grdecl") as f: + kw = EclKW.read_grdecl( + f, "FAULTBLK", ecl_type=EclDataType.ECL_INT) - kw = EclKW.read_grdecl(open("faultblock.grdecl") , "FAULTBLK" , ecl_type = EclDataType.ECL_INT) - with open("faults.grdecl" , "w") as f: + with open("faults.grdecl", "w") as f: f.write("FAULTS\n") f.write("\'FX\' 4 4 1 4 1 1 'X' /\n") f.write("\'FX\' 5 5 4 4 1 1 'Y' /\n") f.write("\'FX\' 5 5 5 8 1 1 'X' /\n") f.write("/") - + faults = FaultCollection( grid , "faults.grdecl") layer.loadKeyword( kw ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py similarity index 62% rename from ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py index 8be7f2fc0a..4b72f27be6 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_fault_blocks_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fault_blocks_statoil.py @@ -1,40 +1,46 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# +# Copyright (C) 2014 Statoil ASA, Norway. +# # The file 'test_fault_blocks.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. try: from unittest2 import skipIf except ImportError: from unittest import skipIf -from ecl.ecl import EclGrid, EclDataType , EclKW -from ecl.test import ExtendedTestCase -from ecl.ecl.faults import FaultBlock, FaultBlockLayer +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from ecl.grid.faults import FaultBlock, FaultBlockLayer -class FaultBlockTest(ExtendedTestCase): +from cwrap import open as copen + + +@statoil_test() +class FaultBlockTest(EclTest): def setUp(self): self.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Mariner/MARINER.EGRID")) - fileH = open( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) + fileH = copen( self.createTestPath("Statoil/ECLIPSE/Mariner/faultblock.grdecl") ) self.kw = EclKW.read_grdecl( fileH , "FAULTBLK" , ecl_type = EclDataType.ECL_INT ) - + def test_load(self): for k in range(self.grid.getNZ()): faultBlocks = FaultBlockLayer(self.grid , k) faultBlocks.scanKeyword( self.kw ) for block in faultBlocks: centroid = block.getCentroid() - + diff --git a/ThirdParty/Ert/python/tests/ecl/test_faults.py b/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py similarity index 98% rename from ThirdParty/Ert/python/tests/ecl/test_faults.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_faults.py index aa73ceae9f..5a65e9a0b1 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_faults.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_faults.py @@ -19,13 +19,15 @@ import time from ecl import util -from ecl.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment,FaultBlockLayer -from ecl.ecl import EclGrid, EclKW, EclDataType -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.geo import Polyline , CPolyline - - -class FaultTest(ExtendedTestCase): +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from ecl.grid.faults import FaultCollection, Fault, FaultLine, FaultSegment,FaultBlockLayer +from ecl.util.test import TestAreaContext +from ecl.util.geometry import Polyline , CPolyline +from tests import EclTest + +class FaultTest(EclTest): @classmethod def setUpClass(cls): cls.grid = EclGrid.createRectangular( (151,100,50) , (1,1,1)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py similarity index 93% rename from ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py index b3d48befea..d01c981463 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_fk_user_data.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fk_user_data.py @@ -15,10 +15,11 @@ # See the GNU General Public License at # for more details. -from ecl.ecl import EclGrid -from ecl.test import ExtendedTestCase, TestAreaContext +from ecl.grid import EclGrid +from ecl.util.test import TestAreaContext +from tests import EclTest -class FKTest(ExtendedTestCase): +class FKTest(EclTest): def test_cell_containment(self): diff --git a/ThirdParty/Ert/python/tests/ecl/test_fortio.py b/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py similarity index 94% rename from ThirdParty/Ert/python/tests/ecl/test_fortio.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py index 01e51ff3d3..54a4b9fabe 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_fortio.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_fortio.py @@ -15,16 +15,19 @@ # See the GNU General Public License at # for more details. import os +import cwrap from random import randint -from ecl.ecl import FortIO, EclDataType, EclKW , openFortIO, EclFile -from ecl.test import ExtendedTestCase, TestAreaContext +from ecl import EclDataType +from ecl.eclfile import FortIO, EclKW , openFortIO, EclFile +from ecl.util.test import TestAreaContext +from tests import EclTest -class FortIOTest(ExtendedTestCase): +class FortIOTest(EclTest): + - def test_open_write(self): @@ -132,7 +135,7 @@ def test_is_fortran_file(self): with openFortIO("fortran_file" , mode = FortIO.WRITE_MODE) as f: kw1.fwrite( f ) - with open("text_file" , "w") as f: + with cwrap.open("text_file" , "w") as f: kw1.write_grdecl( f ) self.assertTrue( FortIO.isFortranFile( "fortran_file" )) diff --git a/ThirdParty/Ert/python/tests/ecl/test_geertsma.py b/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py similarity index 94% rename from ThirdParty/Ert/python/tests/ecl/test_geertsma.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py index 5ff2850716..f991e88704 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_geertsma.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_geertsma.py @@ -1,7 +1,11 @@ import datetime -from ecl.ecl import EclGrid, EclKW, EclDataType, openFortIO, FortIO, EclFile, EclSubsidence +from ecl import EclDataType +from ecl.eclfile import EclKW, openFortIO, FortIO, EclFile +from ecl.grid import EclGrid +from ecl.gravimetry import EclSubsidence -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.test import TestAreaContext +from tests import EclTest import numpy as np @@ -46,7 +50,7 @@ def create_restart(grid, case, p1, p2=None): p.fwrite(f) -class GeertsmaTest(ExtendedTestCase): +class GeertsmaTest(EclTest): @staticmethod def test_geertsma_kernel(): diff --git a/ThirdParty/Ert/python/tests/ecl/test_grav.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grav.py similarity index 73% rename from ThirdParty/Ert/python/tests/ecl/test_grav.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grav.py index 3772db8448..cec520ecee 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_grav.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grav.py @@ -1,9 +1,13 @@ import time -from ecl.ecl import EclGrav, EclKW, EclGrid, EclFile, EclDataType, openFortIO, FortIO -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl import EclDataType +from ecl.eclfile import EclKW, EclFile, openFortIO, FortIO +from ecl.grid import EclGrid +from ecl.gravimetry import EclGrav +from ecl.util.test import TestAreaContext +from tests import EclTest -class EclGravTest(ExtendedTestCase): +class EclGravTest(EclTest): def setUp(self): diff --git a/ThirdParty/Ert/python/tests/ecl/test_grdecl.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py similarity index 76% rename from ThirdParty/Ert/python/tests/ecl/test_grdecl.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py index 7c6b1b05c6..6063c109e0 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_grdecl.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grdecl.py @@ -1,29 +1,30 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. import os -from ecl.ecl import EclKW,EclGrid,Ecl3DKW -from ecl.test import ExtendedTestCase +from ecl.eclfile import EclKW, Ecl3DKW +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from cwrap import open as copen - - -class GRDECLTest(ExtendedTestCase): +@statoil_test() +class GRDECLTest(EclTest): def setUp(self): self.src_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/include/example_permx.GRDECL") self.file_list = [] @@ -38,29 +39,29 @@ def tearDown(self): def test_Load( self ): - kw = EclKW.read_grdecl(open(self.src_file, "r"), "PERMX") + kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") self.assertTrue(kw) grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE" )) - kw = Ecl3DKW.read_grdecl(grid , open(self.src_file, "r"), "PERMX") + kw = Ecl3DKW.read_grdecl(grid , copen(self.src_file, "r"), "PERMX") self.assertTrue( isinstance( kw , Ecl3DKW )) def test_reload( self ): - kw = EclKW.read_grdecl(open(self.src_file, "r"), "PERMX") + kw = EclKW.read_grdecl(copen(self.src_file, "r"), "PERMX") tmp_file1 = "/tmp/permx1.grdecl" tmp_file2 = "/tmp/permx2.grdecl" self.addFile(tmp_file1) self.addFile(tmp_file2) - fileH = open(tmp_file1, "w") + fileH = copen(tmp_file1, "w") kw.write_grdecl(fileH) fileH.close() - kw1 = EclKW.read_grdecl(open(tmp_file1, "r"), "PERMX") + kw1 = EclKW.read_grdecl(copen(tmp_file1, "r"), "PERMX") - fileH = open(tmp_file2, "w") + fileH = copen(tmp_file2, "w") kw1.write_grdecl(fileH) fileH.close() @@ -68,12 +69,12 @@ def test_reload( self ): def test_fseek( self ): - file = open(self.src_file, "r") + file = copen(self.src_file, "r") self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) self.assertFalse(EclKW.fseek_grdecl(file, "PERMY")) file.close() - file = open(self.src_file, "r") + file = copen(self.src_file, "r") kw1 = EclKW.read_grdecl(file, "PERMX") self.assertFalse(EclKW.fseek_grdecl(file, "PERMX")) self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) @@ -83,7 +84,7 @@ def test_fseek( self ): def test_fseek2(self): test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl") # Test kw at the the very start - file = open(test_src, "r") + file = copen(test_src, "r") self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) # Test commented out kw: @@ -94,7 +95,7 @@ def test_fseek2(self): self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) - # Test rewind + # Test rewind self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) @@ -105,7 +106,7 @@ def test_fseek2(self): def test_fseek_dos(self): test_src = self.createTestPath("local/ECLIPSE/grdecl-test/test.grdecl_dos") # File formatted with \r\n line endings. # Test kw at the the very start - file = open(test_src, "r") + file = copen(test_src, "r") self.assertTrue(EclKW.fseek_grdecl(file, "PERMX")) # Test commented out kw: @@ -116,7 +117,7 @@ def test_fseek_dos(self): self.assertTrue(EclKW.fseek_grdecl(file, "MARKER")) self.assertFalse(EclKW.fseek_grdecl(file, "PERMXYZ")) - # Test rewind + # Test rewind self.assertFalse(EclKW.fseek_grdecl(file, "PERMX", rewind=False)) self.assertTrue(EclKW.fseek_grdecl(file, "PERMX", rewind=True)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_grid.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py similarity index 97% rename from ThirdParty/Ert/python/tests/ecl/test_grid.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid.py index 0152414bb9..6c4be05924 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_grid.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid.py @@ -15,16 +15,20 @@ # See the GNU General Public License at # for more details. import os.path +import six from unittest import skipIf import time import itertools from numpy import linspace -from ecl.util import IntVector -from ecl.ecl import EclGrid, EclKW, EclDataType, EclUnitTypeEnum, EclFile -from ecl.ecl import EclGridGenerator as GridGen -from ecl.ecl.faults import Layer , FaultCollection -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.util import IntVector +from ecl import EclDataType, EclUnitTypeEnum +from ecl.eclfile import EclKW, EclFile +from ecl.grid import EclGrid +from ecl.grid import EclGridGenerator as GridGen +from ecl.grid.faults import Layer , FaultCollection +from ecl.util.test import TestAreaContext +from tests import EclTest # This dict is used to verify that corners are mapped to the correct # cell with respect to containment. @@ -113,13 +117,14 @@ def createWrapperGrid(grid): return GridGen.create_single_cell_grid(corners) def average(points): - p = reduce(lambda a,b: (a[0]+b[0], a[1]+b[1], a[2]+b[2]), points) + p = six.functools.reduce( + lambda a, b: (a[0] + b[0], a[1] + b[1], a[2] + b[2]), points) return [elem/float(len(points)) for elem in p] # This test class should only have test cases which do not require # external test data. Tests involving Statoil test data are in the # test_grid_statoil module. -class GridTest(ExtendedTestCase): +class GridTest(EclTest): def test_oom_grid(self): nx = 2000 @@ -457,7 +462,7 @@ def test_cell_face_containment(self): d = 10 grid = GridGen.createRectangular( (n, n, n), (d, d, d)) - for x, y, z in itertools.product(range(d/2, n*d, d), repeat=3): + for x, y, z in itertools.product(range(d//2, n*d, d), repeat=3): for axis, direction in itertools.product(range(3), [-1, 1]): p = [x, y, z] p[axis] = p[axis] + direction*d/2 diff --git a/ThirdParty/Ert/python/tests/ecl/test_grid_generator.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py similarity index 92% rename from ThirdParty/Ert/python/tests/ecl/test_grid_generator.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py index ff2d8f087d..9289003bc5 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_grid_generator.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_generator.py @@ -1,26 +1,32 @@ #!/usr/bin/env python -# Copyright (C) 2017 Statoil ASA, Norway. -# +# Copyright (C) 2017 Statoil ASA, Norway. +# # The file 'test_grid_generator.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. from itertools import product as prod -import operator, random, numpy +import operator +import random +import numpy +import six -from ecl.ecl import EclGrid, EclKW, EclDataType -from ecl.ecl import EclGridGenerator as GridGen -from ecl.test import ExtendedTestCase, TestAreaContext +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from ecl.grid import EclGridGenerator as GridGen +from ecl.util.test import TestAreaContext +from tests import EclTest def generate_ijk_bounds(dims): @@ -30,9 +36,9 @@ def generate_ijk_bounds(dims): return prod(ibounds, jbounds, kbounds) def decomposition_preserving(ijk_bound): - return sum(zip(*ijk_bound)[0])%2 is 0 + return sum(list(zip(*ijk_bound))[0]) % 2 is 0 -class GridGeneratorTest(ExtendedTestCase): +class GridGeneratorTest(EclTest): def setUp(self): self.test_base = [ @@ -86,7 +92,7 @@ def test_extract_grid_invalid_bounds(self): with self.assertRaises(ValueError): GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,6), (2,2), (2,2))) - + with self.assertRaises(ValueError): GridGen.extract_subgrid_data(dims, coord, zcorn, ((1,2), (2,0), (2,2))) @@ -110,7 +116,8 @@ def test_extract_grid_slice_spec(self): def assertSubgrid(self, grid, subgrid, ijk_bound): sijk_space = prod(*[range(d) for d in subgrid.getDims()[:-1:]]) for sijk in sijk_space: - gijk = tuple([a+b for a, b in zip(sijk, zip(*ijk_bound)[0])]) + gijk = tuple([a + b for a, b in + zip(sijk, list(zip(*ijk_bound))[0])]) self.assertEqual( [subgrid.getCellCorner(i, ijk=sijk) for i in range(8)], @@ -145,7 +152,8 @@ def test_actnum_extraction(self): coord = GridGen.create_coord(dims, (1,1,1)) zcorn = GridGen.create_zcorn(dims, (1,1,1), offset=0) - actnum = EclKW("ACTNUM", reduce(operator.mul, dims), EclDataType.ECL_INT) + actnum = EclKW("ACTNUM", six.functools.reduce(operator.mul, dims), + EclDataType.ECL_INT) random.seed(1337) for i in range(len(actnum)): actnum[i] = random.randint(0, 1) diff --git a/ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py similarity index 91% rename from ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py index 89129deadc..19f6be7295 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_grid_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_grid_statoil.py @@ -1,18 +1,18 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# +# Copyright (C) 2011 Statoil ASA, Norway. +# # The file 'test_grid.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. import math @@ -21,13 +21,20 @@ except ImportError: from unittest import skipIf +from cwrap import Prototype +from cwrap import open as copen + import time -from ecl.ecl import EclDataType, EclKW, EclGrid, EclFile, openEclFile -from ecl.util import DoubleVector, IntVector -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl import EclDataType +from ecl.eclfile import EclKW, EclFile, openEclFile +from ecl.grid import EclGrid +from ecl.util.util import DoubleVector, IntVector +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test -class GridTest(ExtendedTestCase): +@statoil_test() +class GridTest(EclTest): def egrid_file(self): return self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") @@ -45,14 +52,14 @@ def test_loadFromFile(self): self.assertTrue( isinstance( g1 , EclGrid ) ) self.assertTrue( isinstance( g2 , EclGrid ) ) - + def test_corner(self): grid = EclGrid(self.egrid_file()) nx = grid.getNX() ny = grid.getNY() nz = grid.getNZ() - + (x1,y1,z1) = grid.getCellCorner( 0 , ijk = (0,0,0)) (x2,y2,z2) = grid.getLayerXYZ( 0 , 0 ) self.assertEqual(x1,x2) @@ -84,7 +91,7 @@ def test_corner(self): self.assertEqual(z1,z2) - + with self.assertRaises(IndexError): grid.getLayerXYZ( -1 , 0 ) @@ -101,9 +108,9 @@ def test_corner(self): def test_GRID( self ): grid = EclGrid(self.grid_file()) self.assertTrue(grid) - - - + + + def test_EGRID( self ): grid = EclGrid(self.egrid_file()) self.assertTrue(grid) @@ -111,11 +118,11 @@ def test_EGRID( self ): self.assertEqual(dims[0] , grid.getNX()) self.assertEqual(dims[1] , grid.getNY()) self.assertEqual(dims[2] , grid.getNZ()) - - - + + + def create(self, filename, load_actnum=True): - fileH = open(filename, "r") + fileH = copen(filename, "r") specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) zcorn = EclKW.read_grdecl(fileH, "ZCORN") coord = EclKW.read_grdecl(fileH, "COORD") @@ -123,12 +130,12 @@ def create(self, filename, load_actnum=True): actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) else: actnum = None - + mapaxes = EclKW.read_grdecl(fileH, "MAPAXES") grid = EclGrid.create(specgrid, zcorn, coord, actnum, mapaxes=mapaxes) return grid - - + + def test_rect(self): with TestAreaContext("python/grid-test/testRect"): a1 = 1.0 @@ -139,32 +146,32 @@ def test_rect(self): grid2 = EclGrid("rect.EGRID") self.assertTrue(grid) self.assertTrue(grid2) - + (x, y, z) = grid.get_xyz(ijk=(4, 4, 4)) self.assertAlmostEqualList([x, y, z], [4.5 * a1, 4.5 * a2, 4.5 * a3]) - + v = grid.cell_volume(ijk=(4, 4, 4)) self.assertFloatEqual(v, a1 * a2 * a3) - + z = grid.depth(ijk=(4, 4, 4 )) self.assertFloatEqual(z, 4.5 * a3) - + g1 = grid.global_index(ijk=(2, 2, 2)) g2 = grid.global_index(ijk=(4, 4, 4)) (dx, dy, dz) = grid.distance(g2, g1) self.assertAlmostEqualList([dx, dy, dz], [2 * a1, 2 * a2, 2 * a3]) - + self.assertTrue(grid.cell_contains(2.5 * a1, 2.5 * a2, 2.5 * a3, ijk=(2, 2, 2))) - + #ijk = grid.find_cell(1.5 * a1 , 2.5 * a2 , 3.5 * a3) #self.assertAlmostEqualList(ijk, [1, 2, 3]) - - + + def test_create(self): grid = self.create(self.grdecl_file()) self.assertTrue(grid) - - + + def test_grdecl_load(self): with self.assertRaises(IOError): grid = EclGrid.loadFromGrdecl("/file/does/not/exists") @@ -172,86 +179,88 @@ def test_grdecl_load(self): with TestAreaContext("python/grid-test/grdeclLoad"): with open("grid.grdecl","w") as f: f.write("Hei ...") - + with self.assertRaises(ValueError): grid = EclGrid.loadFromGrdecl("grid.grdecl") - + actnum = IntVector(default_value = 1 , initial_size = 1000) actnum[0] = 0 g1 = EclGrid.createRectangular((10,10,10) , (1,1,1) , actnum = actnum ) self.assertEqual( g1.getNumActive() , actnum.elementSum() ) g1.save_EGRID("G.EGRID") + with open("grid.grdecl" , "w") as f2: + f2.write("SPECGRID\n") + f2.write(" 10 10 10 \'F\' /\n") + with openEclFile("G.EGRID") as f: - with open("grid.grdecl" , "w") as f2: - f2.write("SPECGRID\n") - f2.write(" 10 10 10 \'F\' /\n") + with copen("grid.grdecl" , "a") as f2: coord_kw = f["COORD"][0] coord_kw.write_grdecl( f2 ) - + zcorn_kw = f["ZCORN"][0] zcorn_kw.write_grdecl( f2 ) - + actnum_kw = f["ACTNUM"][0] actnum_kw.write_grdecl( f2 ) - + g2 = EclGrid.loadFromGrdecl("grid.grdecl") self.assertTrue( g1.equal( g2 )) - - + + def test_ACTNUM(self): g1 = self.create(self.grdecl_file()) g2 = self.create(self.grdecl_file(), load_actnum=False) self.assertTrue(g1.equal(g2)) - - + + def test_time(self): t0 = time.clock() g1 = EclGrid(self.egrid_file()) t1 = time.clock() t = t1 - t0 self.assertTrue(t < 1.0) - - + + def test_save(self): with TestAreaContext("python/grid-test/testSave"): g1 = EclGrid(self.egrid_file()) - + g1.save_EGRID("test.EGRID") g2 = EclGrid("test.EGRID") self.assertTrue(g1.equal(g2)) - + g1.save_GRID("test.GRID") g2 = EclGrid("test.GRID") self.assertTrue(g1.equal(g2)) - - fileH = open("test.grdecl", "w") + + fileH = copen("test.grdecl", "w") g1.save_grdecl(fileH) fileH.close() g2 = self.create("test.grdecl") self.assertTrue(g1.equal(g2)) - - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of coarse grid skipped!") + + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of coarse grid skipped!") def test_coarse(self): #work_area = TestArea("python/grid-test/testCoarse") with TestAreaContext("python/grid-test/testCoarse"): testGRID = True g1 = EclGrid(self.createTestPath("Statoil/ECLIPSE/LGCcase/LGC_TESTCASE2.EGRID")) - + g1.save_EGRID("LGC.EGRID") g2 = EclGrid("LGC.EGRID") self.assertTrue(g1.equal(g2, verbose=True)) - + if testGRID: g1.save_GRID("LGC.GRID") g3 = EclGrid("LGC.GRID") self.assertTrue(g1.equal(g3, verbose=True)) - + self.assertTrue(g1.coarse_groups() == 3384) - - + + def test_raise_IO_error(self): with self.assertRaises(IOError): g = EclGrid("/does/not/exist.EGRID") @@ -287,7 +296,7 @@ def test_boundingBox(self): - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of dual grid skipped!") + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of dual grid skipped!") def test_dual(self): with TestAreaContext("python/grid-test/testDual"): grid = EclGrid(self.egrid_file()) @@ -330,7 +339,7 @@ def test_dual(self): self.assertTrue(dgrid.equal(dgrid2 , verbose = True)) - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test of numActive large memory skipped!") + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test of numActive large memory skipped!") def test_num_active_large_memory(self): case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") vecList = [] @@ -381,12 +390,12 @@ def test_volume_kw(self): for global_index , volume in enumerate(vol): self.assertEqual( volume , grid.cell_volume( global_index = global_index )) - - + + def test_large_case(self): grdecl_file = self.createTestPath("Statoil/ECLIPSE/1.6.0_issueGrdecl/test_aug2016_gridOnly.grdecl") grid = EclGrid.loadFromGrdecl( grdecl_file ) - + def test_lgr_get(self): grid = EclGrid(self.createTestPath("Statoil/ECLIPSE/Troll/MSW_LGR/2BRANCHES-CCEWELLPATH-NEW-SCH-TUNED-AR3.EGRID")) diff --git a/ThirdParty/Ert/python/tests/ecl/test_indexed_read.py b/ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py similarity index 94% rename from ThirdParty/Ert/python/tests/ecl/test_indexed_read.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py index 8de919409a..a3cfee4ca7 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_indexed_read.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_indexed_read.py @@ -1,12 +1,14 @@ import ctypes import ecl -from ecl.ecl import EclPrototype -from ecl.ecl import EclKW, EclFile, EclDataType, FortIO -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.util import IntVector - -class EclIndexedReadTest(ExtendedTestCase): +from ecl import EclPrototype +from ecl import EclDataType +from ecl.eclfile import EclKW, EclFile, FortIO +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl.util.util import IntVector + +class EclIndexedReadTest(EclTest): _freadIndexedData = EclPrototype("void ecl_kw_fread_indexed_data_python(fortio, int, ecl_data_type, int, int_vector, char*)", bind = False) # fortio, offset, type, count, index_map, buffer _eclFileIndexedRead = EclPrototype("void ecl_file_indexed_read(ecl_file, char*, int, int_vector, char*)", bind = False) # ecl_file, kw, index, index_map, buffer diff --git a/ThirdParty/Ert/python/tests/ecl/test_kw_function.py b/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py similarity index 59% rename from ThirdParty/Ert/python/tests/ecl/test_kw_function.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py index 4f45f2f313..21f8452be8 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_kw_function.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_kw_function.py @@ -1,26 +1,28 @@ #!/usr/bin/env python -# Copyright (C) 2015 Statoil ASA, Norway. -# +# Copyright (C) 2015 Statoil ASA, Norway. +# # The file 'test_kw_function.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. import os import random -from ecl.ecl import EclKW, EclDataType, EclGrid , Ecl3DKW -from ecl.util import IntVector -from ecl.test import ExtendedTestCase +from ecl import EclDataType +from ecl.eclfile import EclKW, Ecl3DKW +from ecl.grid import EclGrid +from ecl.util.util import IntVector +from tests import EclTest -class KWFunctionTest(ExtendedTestCase): +class KWFunctionTest(EclTest): def test_region_filter(self): nx = 10 @@ -28,13 +30,13 @@ def test_region_filter(self): nz = 1 actnum = IntVector( initial_size = nx*ny*nz , default_value = 1 ) actnum[nx*ny - 1] = 0 - + grid = EclGrid.createRectangular( (nx,ny,nz) , (1,1,1) , actnum = actnum) self.assertEqual( grid.getNumActive() , nx*ny*nz - 1 ) - + kw = Ecl3DKW.create( "REGIONS" , grid , EclDataType.ECL_INT , global_active = True ) kw.assign( 0 ) - kw[0:nx*ny/2] = 1 + kw[0:int(nx*ny/2)] = 1 kw[5,2,0] = 0 kw[0,9,0] = 2 @@ -47,7 +49,7 @@ def test_region_filter(self): # Not assigned because it is inactive self.assertEqual( kw[nx - 1,ny - 1,0] , 0) - + self.assertEqual( kw[5,2,0] , 1 ) for j in range(5,10): self.assertEqual( kw[5,j,0] , 1 ) @@ -55,3 +57,23 @@ def test_region_filter(self): for i in range(10): self.assertEqual( kw[i,7,0] , 1 ) + + + def test_porv_kw(self): + porv_int = EclKW( "PORV", 100, EclDataType.ECL_INT) + with self.assertRaises(TypeError): + actnum = porv_int.create_actnum() + + + prv = EclKW("PRV", 100, EclDataType.ECL_FLOAT) + with self.assertRaises(ValueError): + actnum = prv.create_actnum() + + + porv = EclKW("PORV", 4, EclDataType.ECL_FLOAT) + porv[0] = 0 + porv[1] = 0.50 + porv[2] = 0.50 + porv[3] = 0 + actnum = porv.create_actnum() + self.assertEqual(tuple(actnum), (0,1,1,0)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_layer.py b/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py similarity index 97% rename from ThirdParty/Ert/python/tests/ecl/test_layer.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_layer.py index 370eb6ae8e..0c8aabf6f7 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_layer.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_layer.py @@ -18,14 +18,15 @@ from unittest import skipIf import time -from ecl.util import IntVector -from ecl.ecl import EclGrid -from ecl.geo import CPolyline -from ecl.ecl.faults import Layer , FaultCollection -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.util import IntVector +from ecl.grid import EclGrid +from ecl.util.geometry import CPolyline +from ecl.grid.faults import Layer , FaultCollection +from ecl.util.test import TestAreaContext +from tests import EclTest -class LayerTest(ExtendedTestCase): +class LayerTest(EclTest): def setUp(self): pass diff --git a/ThirdParty/Ert/python/tests/ecl/test_npv.py b/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py similarity index 95% rename from ThirdParty/Ert/python/tests/ecl/test_npv.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_npv.py index dceda077c1..43bd77493f 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_npv.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_npv.py @@ -24,11 +24,12 @@ except ImportError: from unittest import skipIf, skipUnless, skipIf -from ecl.ecl import EclSum -from ecl.ecl import EclNPV , NPVPriceVector +from ecl.summary import EclSum +from ecl.summary import EclNPV , NPVPriceVector -from ecl.util import StringList, TimeVector, DoubleVector , CTime -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.util import StringList, TimeVector, DoubleVector , CTime +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test base = "ECLIPSE" @@ -44,8 +45,8 @@ def linear1(x): def linear2(x): return 2*x - -class NPVTest(ExtendedTestCase): +@statoil_test() +class NPVTest(EclTest): def setUp(self): self.case = self.createTestPath(case) diff --git a/ThirdParty/Ert/python/tests/ecl/test_region.py b/ThirdParty/Ert/python/tests/ecl_tests/test_region.py similarity index 93% rename from ThirdParty/Ert/python/tests/ecl/test_region.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_region.py index b24b3d7969..6c38697115 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_region.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_region.py @@ -13,12 +13,14 @@ # # See the GNU General Public License at # for more details. -from ecl.ecl import EclGrid, EclKW, EclRegion, EclDataType -from ecl.ecl.faults import Layer -from ecl.test import ExtendedTestCase -from ecl.util import IntVector +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid, EclRegion +from ecl.grid.faults import Layer +from ecl.util.util import IntVector +from tests import EclTest -class RegionTest(ExtendedTestCase): +class RegionTest(EclTest): def test_equal(self): grid = EclGrid.createRectangular( (10,10,1) , (1,1,1)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_region_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py similarity index 92% rename from ThirdParty/Ert/python/tests/ecl/test_region_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py index fbe0c8035c..16fc04090a 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_region_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_region_statoil.py @@ -1,25 +1,27 @@ #!/usr/bin/env python -# Copyright (C) 2012 Statoil ASA, Norway. -# +# Copyright (C) 2012 Statoil ASA, Norway. +# # The file 'test_region.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. -from ecl.ecl import EclFile, EclGrid, EclRegion -from ecl.ecl.faults import Layer -from ecl.test import ExtendedTestCase +from ecl.eclfile import EclFile +from ecl.grid import EclGrid, EclRegion +from ecl.grid.faults import Layer +from tests import EclTest, statoil_test -class RegionTest(ExtendedTestCase): +@statoil_test() +class RegionTest(EclTest): def setUp(self): case = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE") self.grid = EclGrid(case) @@ -52,7 +54,7 @@ def test_equal(self): self.assertFalse( reg1 == reg2 ) reg1.select_islice(7,7) self.assertTrue( reg1 == reg2 ) - + def test_kw_idiv(self): P = self.rst_file["PRESSURE"][5] @@ -161,7 +163,7 @@ def test_polygon(self): dy = 0.1 reg.select_inside_polygon( [(x-dx,y-dy) , (x-dx,y+dy) , (x+dx,y+dy) , (x+dx,y-dy)] ) self.assertTrue( self.grid.getNZ() == len(reg.getGlobalList())) - + def test_heidrun(self): root = self.createTestPath("Statoil/ECLIPSE/Heidrun") @@ -178,7 +180,7 @@ def test_heidrun(self): reg.select_inside_polygon( polygon ) self.assertEqual( 0 , len(reg.getGlobalList()) % grid.getNZ()) - + def test_layer(self): region = EclRegion(self.grid, False) layer = Layer( self.grid.getNX() , self.grid.getNY() + 1) @@ -194,8 +196,8 @@ def test_layer(self): region.selectFromLayer( layer , -1 , 1 ) with self.assertRaises(ValueError): - region.selectFromLayer( layer , self.grid.getNZ() , 1 ) - + region.selectFromLayer( layer , self.grid.getNZ() , 1 ) + region.selectFromLayer( layer , 0 , 2 ) glist = region.getGlobalList() self.assertEqual(0 , len(glist)) diff --git a/ThirdParty/Ert/python/tests/ecl/test_removed.py b/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py similarity index 82% rename from ThirdParty/Ert/python/tests/ecl/test_removed.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_removed.py index fd41e1e434..db480ffe82 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_removed.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_removed.py @@ -1,12 +1,14 @@ import time import datetime -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.ecl import EclFile,EclKW,EclDataType,openFortIO, FortIO +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl import EclDataType +from ecl.eclfile import EclFile, EclKW, openFortIO, FortIO -class Removed_2_1_Test(ExtendedTestCase): +class Removed_2_1_Test(EclTest): def test_ecl_file_block(self): with TestAreaContext("name") as t: diff --git a/ThirdParty/Ert/python/tests/ecl/test_restart.py b/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py similarity index 90% rename from ThirdParty/Ert/python/tests/ecl/test_restart.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_restart.py index c9e91be399..32fa276aec 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_restart.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_restart.py @@ -1,30 +1,30 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# -# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 # for more details. from _ctypes import ArgumentError import os import datetime -from ecl.ecl import EclFile -from ecl.test import ExtendedTestCase +from ecl.eclfile import EclFile +from tests import EclTest, statoil_test - -class RestartTest(ExtendedTestCase): +@statoil_test() +class RestartTest(EclTest): def setUp(self): self.xfile0 = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.X0000") self.u_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") @@ -85,7 +85,7 @@ def report_list_file_test(self, fname, rlist0): def test_report_list(self): - rlist0 = range(63) + rlist0 = list(range(63)) self.report_list_file_test(self.u_file, rlist0) rlist0 = [0] @@ -123,7 +123,7 @@ def test_kw( self ): self.assertTrue(kw1.equal(kw2)) self.assertTrue(kw1.equal(kw3)) - + with self.assertRaises(IndexError): kw4 = f.restart_get_kw("SWAT", datetime.datetime(2009, 3, 17)) - + diff --git a/ThirdParty/Ert/python/tests/ecl/test_restart_head.py b/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py similarity index 71% rename from ThirdParty/Ert/python/tests/ecl/test_restart_head.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py index bd1468a73e..c1683f6d41 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_restart_head.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_restart_head.py @@ -1,24 +1,27 @@ -# Copyright (C) 2015 Statoil ASA, Norway. -# +# Copyright (C) 2015 Statoil ASA, Norway. +# # The file 'test_ecl_init_file.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. import datetime -from ecl.test import ExtendedTestCase -from ecl.ecl import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO, EclFileFlagEnum , EclGrid +from tests import EclTest, statoil_test +from ecl import EclFileFlagEnum +from ecl.eclfile import Ecl3DKW , EclKW, EclRestartFile , EclFile, FortIO +from ecl.grid import EclGrid -class RestartHeadTest(ExtendedTestCase): +@statoil_test() +class RestartHeadTest(EclTest): def setUp(self): self.grid_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.EGRID") self.unrst_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.UNRST") @@ -27,10 +30,10 @@ def setUp(self): def test_headers(self): g = EclGrid( self.grid_file ) f = EclRestartFile( g , self.unrst_file ) - + headers = f.headers( ) self.assertEqual( len(headers) , 63 ) - + with self.assertRaises(IndexError): f.get_header(1000) @@ -38,4 +41,4 @@ def test_headers(self): details = header.well_details( ) self.assertTrue( "NXCONZ" in details ) self.assertTrue( "NCWMAX" in details ) - + diff --git a/ThirdParty/Ert/python/tests/ecl/test_rft.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py similarity index 84% rename from ThirdParty/Ert/python/tests/ecl/test_rft.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_rft.py index 3ff440b42c..b903f3d78f 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_rft.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft.py @@ -17,13 +17,11 @@ import datetime -from ecl.util import CTime -from ecl.ecl import EclRFTFile, EclRFTCell, EclPLTCell -from ecl.ecl.rft import WellTrajectory -from ecl.test import ExtendedTestCase -from ecl.ecl import EclRFT +from ecl.util.util import CTime +from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, EclRFT, WellTrajectory +from tests import EclTest -class RFTTest(ExtendedTestCase): +class RFTTest(EclTest): def test_create(self): rft = EclRFT( "WELL" , "RFT" , datetime.date(2015 , 10 , 1 ) , 100 ) diff --git a/ThirdParty/Ert/python/tests/ecl/test_rft_cell.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py similarity index 96% rename from ThirdParty/Ert/python/tests/ecl/test_rft_cell.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py index 87276f6ad3..67fb0c0062 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_rft_cell.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_cell.py @@ -16,8 +16,8 @@ # for more details. -from ecl.ecl import EclRFTCell, EclPLTCell -from ecl.test import ExtendedTestCase +from ecl.rft import EclRFTCell, EclPLTCell +from tests import EclTest # def out_of_range(): @@ -25,7 +25,7 @@ # rft = rftFile[100] -class RFTCellTest(ExtendedTestCase): +class RFTCellTest(EclTest): def setUp(self): self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") diff --git a/ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py similarity index 96% rename from ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py index 22214e9f7f..e097551a44 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_rft_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_rft_statoil.py @@ -17,12 +17,12 @@ from __future__ import print_function import datetime -from ecl.ecl import EclRFTFile, EclRFTCell, EclPLTCell -from ecl.ecl.rft import WellTrajectory -from ecl.test import ExtendedTestCase +from ecl.rft import EclRFTFile, EclRFTCell, EclPLTCell, WellTrajectory +from tests import EclTest, statoil_test -class RFTTest(ExtendedTestCase): +@statoil_test() +class RFTTest(EclTest): def setUp(self): self.RFT_file = self.createTestPath("Statoil/ECLIPSE/Gurbat/ECLIPSE.RFT") self.PLT_file = self.createTestPath("Statoil/ECLIPSE/RFT/TEST1_1A.RFT") diff --git a/ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py b/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py similarity index 79% rename from ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py index 2d362b8713..03c5b3210a 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_statoil_faults.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_statoil_faults.py @@ -1,40 +1,44 @@ #!/usr/bin/env python -# Copyright (C) 2014 Statoil ASA, Norway. -# +# Copyright (C) 2014 Statoil ASA, Norway. +# # The file 'test_faults.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 +# +# ERT 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. +# +# ERT 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 # for more details. try: from unittest2 import skipIf except ImportError: from unittest import skipIf -import time -from ecl.ecl.faults import FaultCollection, Fault, FaultLine, FaultSegment -from ecl.ecl import EclGrid, EclKW, EclDataType -from ecl.test import ExtendedTestCase +from cwrap import open as copen +import time +from ecl import EclDataType +from ecl.eclfile import EclKW +from ecl.grid import EclGrid +from ecl.grid.faults import FaultCollection, Fault, FaultLine, FaultSegment +from tests import EclTest, statoil_test -class StatoilFaultTest(ExtendedTestCase): +@statoil_test() +class StatoilFaultTest(EclTest): def loadGrid(self): grid_file = self.createTestPath("Statoil/ECLIPSE/Faults/grid.grdecl") - fileH = open(grid_file, "r") + fileH = copen(grid_file, "r") specgrid = EclKW.read_grdecl(fileH, "SPECGRID", ecl_type=EclDataType.ECL_INT, strict=False) zcorn = EclKW.read_grdecl(fileH, "ZCORN") coord = EclKW.read_grdecl(fileH, "COORD") actnum = EclKW.read_grdecl(fileH, "ACTNUM", ecl_type=EclDataType.ECL_INT) - + return EclGrid.create(specgrid, zcorn, coord, actnum) @@ -48,7 +52,7 @@ def test_load(self): for layer in fault: for fl in layer: fl.verify() - + def test_splitLine2(self): @@ -57,29 +61,29 @@ def test_splitLine2(self): # 179 180 181 # o o o o o o o o o o o o o o -# | -# 78 | +# | +# 78 | # o o o o o o o o o o o o o o -# | +# | # 77 | # o o o o o o o o o o o o o o -# | +# | # 76 | # o o o o o o o o o o o o o o # | # 75 | # o o o o o o o o o o o o o o -# -# 74 +# +# 74 # o o o o o o o o o o o o o o -# -# 73 +# +# 73 # o o o o-----o o o o o o o o o o # | # 72 | # o o o o-----o o o o o o o o o o -# -# 71 +# +# 71 # o o o o-----o o o o o o o o o o # | # 70 | @@ -87,16 +91,16 @@ def test_splitLine2(self): # | # 69 | # o o o o o o o o o o o o o o -# -# 68 +# +# 68 # o o o o o o o o o o o o o o -# -# 67 +# +# 67 # o o o o o o o o o o o o o o -# -# 66 +# +# 66 # o o o o o o o o o o o o o o -# | +# | # 65 | # o o o o-----o o o o o o o o o o @@ -106,13 +110,13 @@ def test_splitLine2(self): f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'X' ) f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y' ) f.addRecord( 180, 180 , 72 , 72 , 0 , 41 , 'Y-' ) - + f.addRecord( 180, 180 , 70 , 70 , 0 , 42 , 'Y' ) f.addRecord( 180, 180 , 69 , 70 , 0 , 42 , 'X' ) f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'X' ) f.addRecord( 180, 180 , 65 , 65 , 0 , 42 , 'Y-' ) - - + + ij_polyline = f.getIJPolyline( 19 ) ij_list = [(180, 79), (180, 77), (180, 75), (180, 73), (181, 73), (181, 72), (180, 72), @@ -120,9 +124,9 @@ def test_splitLine2(self): (181, 66), (181, 65), (180, 65)] self.assertEqual(ij_polyline , ij_list) - - - + + + diff --git a/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py new file mode 100644 index 0000000000..c4dc3f46a5 --- /dev/null +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum.py @@ -0,0 +1,562 @@ +# Copyright (C) 2011 Statoil ASA, Norway. +# +# The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. +# +# ERT 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. +# +# ERT 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 +# for more details. + +import os.path +import os +import inspect +import datetime +import csv +import shutil +import cwrap +import stat +from contextlib import contextmanager +from unittest import skipIf, skipUnless, skipIf + +from ecl import EclUnitTypeEnum +from ecl import EclDataType +from ecl.eclfile import FortIO, openFortIO, EclKW, EclFile +from ecl.summary import EclSum, EclSumVarType, EclSumKeyWordVector +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl.util.test.ecl_mock import createEclSum + + +@contextmanager +def pushd(path): + if not os.path.isdir(path): + os.makedirs(path) + cwd = os.getcwd() + os.chdir(path) + + yield + + os.chdir(cwd) + +def create_prediction(history, pred_path): + restart_case = os.path.join( os.getcwd(), history.base) + restart_step = history.last_report + with pushd(pred_path): + prediction = create_case( case = "PREDICTION", restart_case = restart_case, restart_step = restart_step, data_start = history.end_date) + prediction.fwrite() + + +def fopr(days): + return days + +def fopt(days): + return days + +def fgpt(days): + if days < 50: + return days + else: + return 100 - days + +def create_case(case = "CSV", restart_case = None, restart_step = -1, data_start = None): + length = 100 + return createEclSum(case , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY"), ("FGPT" , None , 0, "SM3")], + sim_length_days = length, + num_report_step = 10, + num_mini_step = 10, + data_start = data_start, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FGPT" : fgpt }, + restart_case = restart_case, + restart_step = restart_step) + +class SumTest(EclTest): + + + def test_mock(self): + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY")]) + self.assertTrue("FOPT" in case) + self.assertFalse("WWCT:OPX" in case) + + def test_TIME_special_case(self): + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY")]) + keys = case.keys() + self.assertEqual( len(keys) , 2 ) + self.assertIn( "FOPT" , keys ) + self.assertIn( "FOPR" , keys ) + + + keys = case.keys(pattern = "*") + self.assertEqual( len(keys) , 2 ) + self.assertIn( "FOPT" , keys ) + self.assertIn( "FOPR" , keys ) + + + def test_identify_var_type(self): + self.assertEnumIsFullyDefined( EclSumVarType , "ecl_smspec_var_type" , "lib/include/ert/ecl/smspec_node.h") + self.assertEqual( EclSum.varType( "WWCT:OP_X") , EclSumVarType.ECL_SMSPEC_WELL_VAR ) + self.assertEqual( EclSum.varType( "RPR") , EclSumVarType.ECL_SMSPEC_REGION_VAR ) + self.assertEqual( EclSum.varType( "WNEWTON") , EclSumVarType.ECL_SMSPEC_MISC_VAR ) + self.assertEqual( EclSum.varType( "AARQ:4") , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) + + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , + ("FOPR" , None , 0, "SM3/DAY"), + ("AARQ" , None , 10, "???"), + ("RGPT" , None ,1, "SM3")]) + + node1 = case.smspec_node( "FOPT" ) + self.assertEqual( node1.varType( ) , EclSumVarType.ECL_SMSPEC_FIELD_VAR ) + + node2 = case.smspec_node( "AARQ:10" ) + self.assertEqual( node2.varType( ) , EclSumVarType.ECL_SMSPEC_AQUIFER_VAR ) + self.assertEqual( node2.getNum( ) , 10 ) + + node3 = case.smspec_node("RGPT:1") + self.assertEqual( node3.varType( ) , EclSumVarType.ECL_SMSPEC_REGION_VAR ) + self.assertEqual( node3.getNum( ) , 1 ) + self.assertTrue( node3.isTotal( )) + + self.assertLess( node1, node3 ) + self.assertGreater( node2, node3 ) + self.assertEqual( node1, node1 ) + self.assertNotEqual( node1, node2 ) + + with self.assertRaises(TypeError): + a = node1 < 1 + + def test_csv_export(self): + case = createEclSum("CSV" , [("FOPT", None , 0, "SM3") , ("FOPR" , None , 0, "SM3/DAY")]) + sep = ";" + with TestAreaContext("ecl/csv"): + case.exportCSV( "file.csv" , sep = sep) + self.assertTrue( os.path.isfile( "file.csv" ) ) + input_file = csv.DictReader( open("file.csv") , delimiter = sep ) + for row in input_file: + self.assertIn("DAYS", row) + self.assertIn("DATE", row) + self.assertIn("FOPT", row) + self.assertIn("FOPR", row) + self.assertEqual( len(row) , 4 ) + break + + self.assertEqual(case.unit("FOPT"), "SM3") + + with TestAreaContext("ecl/csv"): + case.exportCSV( "file.csv" , keys = ["FOPT"] , sep = sep) + self.assertTrue( os.path.isfile( "file.csv" ) ) + input_file = csv.DictReader( open("file.csv") , delimiter=sep) + for row in input_file: + self.assertIn("DAYS", row) + self.assertIn("DATE", row) + self.assertIn("FOPT", row) + self.assertEqual( len(row) , 3 ) + break + + + + with TestAreaContext("ecl/csv"): + date_format = "%y-%m-%d" + sep = "," + case.exportCSV( "file.csv" , keys = ["F*"] , sep=sep , date_format = date_format) + self.assertTrue( os.path.isfile( "file.csv" ) ) + with open("file.csv") as f: + time_index = -1 + for line in f.readlines(): + tmp = line.split( sep ) + self.assertEqual( len(tmp) , 4) + + if time_index >= 0: + d = datetime.datetime.strptime( tmp[1] , date_format ) + self.assertEqual( case.iget_date( time_index ) , d ) + + time_index += 1 + + + def test_solve(self): + length = 100 + case = create_case() + self.assert_solve( case ) + + def assert_solve(self, case): + with self.assertRaises( KeyError ): + case.solveDays( "MISSING:KEY" , 0.56) + + sol = case.solveDays( "FOPT" , 150 ) + self.assertEqual( len(sol) , 0 ) + + sol = case.solveDays( "FOPT" , -10 ) + self.assertEqual( len(sol) , 0 ) + + sol = case.solveDays( "FOPT" , 50 ) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 50 ) + + sol = case.solveDays( "FOPT" , 50.50 ) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 50.50 ) + + sol = case.solveDays( "FOPR" , 50.90 ) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 50.00 + 1.0/86400 ) + + sol = case.solveDates("FOPR" , 50.90) + t = case.getDataStartTime( ) + datetime.timedelta( days = 50 ) + datetime.timedelta( seconds = 1 ) + self.assertEqual( sol[0] , t ) + + sol = case.solveDays( "FOPR" , 50.90 , rates_clamp_lower = False) + self.assertEqual( len(sol) , 1 ) + self.assertFloatEqual( sol[0] , 51.00 ) + + sol = case.solveDays( "FGPT" ,25.0) + self.assertEqual( len(sol) , 2 ) + self.assertFloatEqual( sol[0] , 25.00 ) + self.assertFloatEqual( sol[1] , 75.00 ) + + sol = case.solveDates( "FGPT" , 25 ) + self.assertEqual( len(sol) , 2 ) + t0 = case.getDataStartTime( ) + t1 = t0 + datetime.timedelta( days = 25 ) + t2 = t0 + datetime.timedelta( days = 75 ) + self.assertEqual( sol[0] , t1 ) + self.assertEqual( sol[1] , t2 ) + + + def test_ecl_sum_vector_algebra(self): + scalar = 0.78 + addend = 2.718281828459045 + + case = create_case() + with self.assertRaises( KeyError ): + case.scaleVector( "MISSING:KEY" , scalar) + case.shiftVector( "MISSING:KEY" , addend) + + # scale all vectors with scalar + for key in case.keys(): + x = case.get_values(key) # get vector key + case.scaleVector(key , scalar) + y = case.get_values(key) + x = x * scalar # numpy vector scaling + for i in range(len(x)): + self.assertFloatEqual(x[i], y[i]) + + # shift all vectors with addend + for key in case.keys(): + x = case.get_values(key) # get vector key + case.shiftVector(key , addend) + y = case.get_values(key) + x = x + addend # numpy vector shifting + for i in range(len(x)): + self.assertFloatEqual(x[i], y[i]) + + + def test_different_names(self): + case = create_case() + with TestAreaContext("sum_different"): + case.fwrite( ) + shutil.move("CSV.SMSPEC" , "CSVX.SMSPEC") + with self.assertRaises(IOError): + case2 = EclSum.load( "Does/not/exist" , "CSV.UNSMRY") + + with self.assertRaises(IOError): + case2 = EclSum.load( "CSVX.SMSPEC" , "CSVX.UNSMRY") + + case2 = EclSum.load( "CSVX.SMSPEC" , "CSV.UNSMRY" ) + self.assert_solve( case2 ) + self.assertEqual(case.unit("FOPR"), "SM3/DAY") + + def test_invalid(self): + case = create_case() + with TestAreaContext("sum_invalid"): + case.fwrite( ) + with open("CASE.txt", "w") as f: + f.write("No - this is not EclKW file ....") + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CSV.SMSPEC" , "CASE.txt" ) + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CASE.txt" , "CSV.UNSMRY" ) + + kw1 = EclKW("TEST1", 30, EclDataType.ECL_INT) + kw2 = EclKW("TEST2", 30, EclDataType.ECL_INT) + + with openFortIO( "CASE.KW" , FortIO.WRITE_MODE) as f: + kw1.fwrite( f ) + kw2.fwrite( f ) + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CSV.SMSPEC" , "CASE.KW") + + with self.assertRaises( IOError ): + case2 = EclSum.load( "CASE.KW" , "CSV.UNSMRY" ) + + + def test_kw_vector(self): + case1 = create_case() + case2 = createEclSum("CSV" , [("FOPR", None , 0, "SM3/DAY") , ("FOPT" , None , 0, "SM3"), ("FWPT" , None , 0, "SM3")], + sim_length_days = 100, + num_report_step = 10, + num_mini_step = 10, + func_table = {"FOPT" : fopt, + "FOPR" : fopr , + "FWPT" : fgpt }) + + kw_list = EclSumKeyWordVector( case1 ) + kw_list.add_keyword("FOPT") + kw_list.add_keyword("FGPT") + kw_list.add_keyword("FOPR") + + t = case1.getDataStartTime( ) + datetime.timedelta( days = 43 ); + data = case1.get_interp_row( kw_list , t ) + for d1,d2 in zip(data, [ case1.get_interp("FOPT", date = t), + case1.get_interp("FOPT", date = t), + case1.get_interp("FOPT", date = t) ]): + + self.assertFloatEqual(d1,d2) + + tmp = [] + for key in kw_list: + tmp.append(key) + + for (k1,k2) in zip(kw_list,tmp): + self.assertEqual(k1,k2) + + kw_list2 = kw_list.copy(case2) + self.assertIn("FOPT", kw_list2) + self.assertIn("FOPR", kw_list2) + self.assertIn("FGPT", kw_list2) + data2 = case2.get_interp_row( kw_list2 , t ) + + self.assertEqual(len(data2), 3) + self.assertEqual(data[0], data2[0]) + self.assertEqual(data[2], data2[2]) + + with TestAreaContext("sum_vector"): + with cwrap.open("f1.txt","w") as f: + case1.dumpCSVLine(t, kw_list, f) + + with cwrap.open("f2.txt", "w") as f: + case2.dumpCSVLine(t,kw_list2,f) + + with open("f1.txt") as f: + d1 = f.readline().split(",") + + with open("f2.txt") as f: + d2 = f.readline().split(",") + + self.assertEqual(d1[0],d2[0]) + self.assertEqual(d1[2],d2[2]) + self.assertEqual(d2[1],"") + + + + def test_vector_select_all(self): + case = create_case() + ecl_sum_vector = EclSumKeyWordVector(case, True) + keys = case.keys() + self.assertEqual( len(keys), len(ecl_sum_vector)) + for key in keys: + self.assertIn(key, ecl_sum_vector) + + + def test_first_last(self): + case = create_case() + with self.assertRaises(KeyError): + case.last_value("NO_SUCH_KEY") + last_fopt = case.last_value("FOPT") + values = case.get_values("FOPT") + self.assertEqual( last_fopt, values[-1]) + + with self.assertRaises(KeyError): + case.first_value("NO_SUCH_KEY") + + first_fopt = case.first_value("FOPT") + self.assertEqual(first_fopt, values[0]) + + + def test_time_range(self): + case = create_case() + with self.assertRaises(ValueError): + case.time_range(num_timestep = 1) + + time_range = case.time_range( num_timestep = 10) + self.assertEqual( len(time_range), 10) + self.assertEqual( time_range[0], case.get_data_start_time()) + self.assertEqual( time_range[-1], case.get_end_time()) + + + def test_resample(self): + case = create_case() + time_vector = case.alloc_time_vector( False ) + case2 = case.resample( "RS", time_vector) + time_vector_resample = case2.alloc_time_vector(False) + first_diff = time_vector_resample.first_neq( time_vector) + self.assertEqual( time_vector_resample, time_vector) + + + + # The purpose of this test is to reproduce a slightly contrived error situation. + # + # 1. A history simulation is created and stored somewhere in the + # filesystem. + # + # 2. We create a prediction, which has 'RESTART' reference to + # the history case. + # + # 3. The prediction case is loaded from disk, with a cwd different from the + # location of the predition case. + # + # This configuration would previously lead to a bug in the path used to + # resolve the history case, and the history would silently be ignored. + + def test_restart_abs_path(self): + with TestAreaContext("restart_test"): + history = create_case(case = "HISTORY") + history.fwrite() + + pred_path = "prediction" + create_prediction(history, pred_path) + + pred = EclSum(os.path.join(pred_path, "PREDICTION")) + # The restart case has a maximum length of 72 characters, depending + # on the path used for $TMP and so on we do not really know here if + # the restart_case has been set or not. + if pred.restart_case: + self.assertTrue(isinstance(pred.restart_case, EclSum)) + self.assertEqual(pred.restart_case.case, os.path.join(os.getcwd(), history.case)) + self.assertEqual(pred.restart_step, history.last_report) + + length = pred.sim_length + pred_times = pred.alloc_time_vector(False) + hist_times = history.alloc_time_vector(False) + + for index in range(len(hist_times)): + self.assertEqual(hist_times[index], pred_times[index]) + + + + + def test_restart_too_long_history_path(self): + with TestAreaContext("restart_test_too_fucking_long_path_for_the_eclipse_restart_keyword_1234567890123456789012345678901234567890"): + history = create_case(case = "HISTORY") + history.fwrite() + + pred_path = "prediction" + create_prediction(history, pred_path) + + pred = EclSum(os.path.join(pred_path, "PREDICTION")) + self.assertIsNone(pred.restart_case) + + + def test_restart_perm_denied(self): + with TestAreaContext("restart_test"): + with pushd("history/case1"): + history = create_case(case = "HISTORY") + history.fwrite() + + prediction = create_case( case = "PREDICTION", restart_case = "history/case1/HISTORY", data_start = history.end_date) + prediction.fwrite() + + os.chmod("history", 0) + + # This just tests that we can create a summary instance even if we do not + # have access to load the history case. + pred = EclSum("PREDICTION") + + os.chmod("history", stat.S_IRWXU) + + + def test_units(self): + case = create_case() + self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) + + + # We do not really have support for writing anything else than the + # default MERIC unit system. To be able to test the read functionality + # we therefor monkey-patch the summary files in place. + with TestAreaContext("unit_test"): + case = create_case("UNITS") + case.fwrite() + case2 = EclSum("UNITS") + + kw_list = [] + f = EclFile("UNITS.SMSPEC") + for kw in f: + if kw.name == "INTEHEAD": + kw[0] = 3 + kw_list.append(kw.copy()) + + f.close() + with openFortIO("UNITS.SMSPEC", mode = FortIO.WRITE_MODE) as f: + for kw in kw_list: + kw.fwrite(f) + + + case = EclSum("UNITS") + self.assertEqual(case.unit_system, EclUnitTypeEnum.ECL_LAB_UNITS) + + + def test_numpy_vector(self): + case = create_case() + + with self.assertRaises(KeyError): + case.numpy_vector("NO_SUCH_KEY") + + numpy_vector = case.numpy_vector("FOPT") + self.assertEqual(len(numpy_vector), len(case)) + numpy_dates = case.numpy_dates + self.assertEqual( numpy_dates[0].tolist(), case.getDataStartTime()) + self.assertEqual( numpy_dates[-1].tolist(), case.getEndTime()) + + dates = case.dates + self.assertEqual( dates[0], case.getDataStartTime()) + self.assertEqual( dates[-1], case.getEndTime()) + + dates = [datetime.datetime(2000,1,1)] + case.dates + [datetime.datetime(2020,1,1)] + fopr = case.numpy_vector("FOPR", time_index = dates) + fopt = case.numpy_vector("FOPT", time_index = dates) + + + self.assertEqual(fopr[0], 0) + self.assertEqual(fopr[-1], 0) + + self.assertEqual(fopt[0], 0) + self.assertEqual(fopt[0], case.first_value("FOPT")) + self.assertEqual(fopt[-1], case.last_value("FOPT")) + + + + def test_pandas(self): + case = create_case() + dates = [datetime.datetime(2000,1,1)] + case.dates + [datetime.datetime(2020,1,1)] + frame = case.pandas_frame(column_keys=["FOPT", "FOPR"], time_index = dates) + + fopr = frame["FOPR"] + fopt = frame["FOPT"] + + self.assertEqual(fopr[0], 0) + self.assertEqual(fopr[-1], 0) + + self.assertEqual(fopt[0], 0) + self.assertEqual(fopt[0], case.first_value("FOPT")) + self.assertEqual(fopt[-1], case.last_value("FOPT")) + + + with self.assertRaises(ValueError): + frame = case.pandas_frame(column_keys=[]) + + with self.assertRaises(ValueError): + frame = case.pandas_frame(column_keys=["NO_KEY"]) + + frame = case.pandas_frame( ) + rows, columns = frame.shape + self.assertEqual(len(case.keys()), columns) + self.assertEqual(len(case), rows) diff --git a/ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py b/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py similarity index 91% rename from ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py rename to ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py index aa543b250e..2ab3a5fa31 100644 --- a/ThirdParty/Ert/python/tests/ecl/test_sum_statoil.py +++ b/ThirdParty/Ert/python/tests/ecl_tests/test_sum_statoil.py @@ -1,4 +1,3 @@ -#!/usr/bin/env python # Copyright (C) 2011 Statoil ASA, Norway. # # The file 'sum_test.py' is part of ERT - Ensemble based Reservoir Tool. @@ -20,11 +19,14 @@ from unittest import skipIf, skipUnless, skipIf -from ecl.ecl import EclSum, EclFile +from ecl.eclfile import EclFile +from ecl.summary import EclSum +from ecl import EclUnitTypeEnum -from ecl.util import StringList, TimeVector, DoubleVector +from ecl.util.util import StringList, TimeVector, DoubleVector, CTime -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.test import TestAreaContext +from tests import EclTest, statoil_test import csv base = "ECLIPSE" @@ -40,7 +42,8 @@ def sum_get(*args): vec = sum[key] -class SumTest(ExtendedTestCase): +@statoil_test() +class SumTest(EclTest): def setUp(self): self.case = self.createTestPath(case) self.ecl_sum = EclSum(self.case) @@ -199,7 +202,7 @@ def test_report(self): self.assertFloatEqual(sum.get_from_report("FOPT", 10), 6.67447e+06) - @skipIf(ExtendedTestCase.slowTestShouldNotRun(), "Slow test skipped") + @skipIf(EclTest.slowTestShouldNotRun(), "Slow test skipped") def test_fwrite(self): # todo: What is tested here? # work_area = TestArea("python/sum-test/fwrite", True) @@ -458,7 +461,7 @@ def test_write(self): self.assertEqual(intersect_summary.keys(), reloaded_summary.keys()) def test_ix_case(self): - intersect_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well")) + intersect_summary = EclSum(self.createTestPath("Statoil/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL")) self.assertIsNotNone(intersect_summary) self.assertTrue( @@ -472,13 +475,13 @@ def test_ix_case(self): hwell_padder = lambda key : key if key.split(":")[-1] != "HWELL_PR" else key + "OD" self.assertEqual( intersect_summary.keys("WWCT*"), - map(hwell_padder, eclipse_summary.keys("WWCT*")) + list(map(hwell_padder, eclipse_summary.keys("WWCT*"))) ) def test_ix_write(self): for data_set in [ - "Statoil/ECLIPSE/ix/summary/Create_Region_Around_Well", - "Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_grid2.SMSPEC" + "Statoil/ECLIPSE/ix/summary/CREATE_REGION_AROUND_WELL", + "Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC" ]: with TestAreaContext("my_space" + data_set.split("/")[-1]) as area: @@ -495,6 +498,35 @@ def test_ix_write(self): ) def test_ix_caseII(self): - troll_summary = EclSum( self.createTestPath("Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_grid2.SMSPEC")) + troll_summary = EclSum( self.createTestPath("Statoil/ECLIPSE/ix/troll/IX_NOPH3_R04_75X75X1_GRID2.SMSPEC")) self.assertIsNotNone(troll_summary) self.assertTrue("WMCTL:Q21BH1" in list(troll_summary.keys())) + + + def test_resample(self): + time_points = TimeVector() + start_time = self.ecl_sum.get_data_start_time() + end_time = self.ecl_sum.get_end_time() + delta = end_time - start_time + N = 25 + time_points.initRange( CTime(start_time), + CTime(end_time), + CTime(int(delta.total_seconds()/(N - 1)))) + time_points.append(CTime(end_time)) + resampled = self.ecl_sum.resample( "OUTPUT_CASE", time_points ) + + for key in self.ecl_sum.keys(): + self.assertIn( key, resampled ) + + self.assertEqual(self.ecl_sum.get_data_start_time(), resampled.get_data_start_time()) + delta = self.ecl_sum.get_end_time() - resampled.get_end_time() + self.assertTrue( delta.total_seconds() <= 1 ) + + keys = ["FOPT", "FOPR", "BPR:15,28,1", "WGOR:OP_1"] + for key in keys: + for time_index,t in enumerate(time_points): + self.assertFloatEqual(resampled.iget( key, time_index), self.ecl_sum.get_interp_direct( key, t)) + + + def test_summary_units(self): + self.assertEqual(self.ecl_sum.unit_system, EclUnitTypeEnum.ECL_METRIC_UNITS) diff --git a/ThirdParty/Ert/python/tests/geometry/CMakeLists.txt b/ThirdParty/Ert/python/tests/geometry/CMakeLists.txt deleted file mode 100644 index 1795decd10..0000000000 --- a/ThirdParty/Ert/python/tests/geometry/CMakeLists.txt +++ /dev/null @@ -1,28 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_convex_hull.py - test_cpolyline.py - test_cpolyline_collection.py - test_geometry_tools.py - test_intersection.py - test_point_in_polygon.py - test_polygon_slicing.py - test_polyline.py - test_surface.py - test_geo_pointset.py - test_geo_region.py -) - -add_python_package("python.tests.geometry" ${PYTHON_INSTALL_PREFIX}/tests/geometry "${TEST_SOURCES}" False) - -addPythonTest(tests.geometry.test_geo_pointset.GeoPointsetTest) -addPythonTest(tests.geometry.test_geo_region.GeoRegionTest) -addPythonTest(tests.geometry.test_surface.SurfaceTest) -addPythonTest(tests.geometry.test_polyline.PolylineTest) -addPythonTest(tests.geometry.test_intersection.IntersectionTest) -addPythonTest(tests.geometry.test_convex_hull.ConvexHullTest) -addPythonTest(tests.geometry.test_point_in_polygon.PointInPolygonTest) -addPythonTest(tests.geometry.test_polygon_slicing.PolygonSlicingTest) -addPythonTest(tests.geometry.test_cpolyline.CPolylineTest) -addPythonTest(tests.geometry.test_cpolyline_collection.CPolylineCollectionTest) -addPythonTest(tests.geometry.test_geometry_tools.GeometryToolsTest ) diff --git a/ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt new file mode 100644 index 0000000000..42aa148046 --- /dev/null +++ b/ThirdParty/Ert/python/tests/geometry_tests/CMakeLists.txt @@ -0,0 +1,28 @@ +set(TEST_SOURCES + __init__.py + test_convex_hull.py + test_cpolyline.py + test_cpolyline_collection.py + test_geometry_tools.py + test_intersection.py + test_point_in_polygon.py + test_polygon_slicing.py + test_polyline.py + test_surface.py + test_geo_pointset.py + test_geo_region.py +) + +add_python_package("python.tests.geometry_tests" ${PYTHON_INSTALL_PREFIX}/tests/geometry_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.geometry_tests.test_geo_pointset.GeoPointsetTest) +addPythonTest(tests.geometry_tests.test_geo_region.GeoRegionTest) +addPythonTest(tests.geometry_tests.test_surface.SurfaceTest) +addPythonTest(tests.geometry_tests.test_polyline.PolylineTest) +addPythonTest(tests.geometry_tests.test_intersection.IntersectionTest) +addPythonTest(tests.geometry_tests.test_convex_hull.ConvexHullTest) +addPythonTest(tests.geometry_tests.test_point_in_polygon.PointInPolygonTest) +addPythonTest(tests.geometry_tests.test_polygon_slicing.PolygonSlicingTest) +addPythonTest(tests.geometry_tests.test_cpolyline.CPolylineTest) +addPythonTest(tests.geometry_tests.test_cpolyline_collection.CPolylineCollectionTest) +addPythonTest(tests.geometry_tests.test_geometry_tools.GeometryToolsTest ) diff --git a/ThirdParty/Ert/python/tests/share/__init__.py b/ThirdParty/Ert/python/tests/geometry_tests/__init__.py similarity index 100% rename from ThirdParty/Ert/python/tests/share/__init__.py rename to ThirdParty/Ert/python/tests/geometry_tests/__init__.py diff --git a/ThirdParty/Ert/python/tests/geometry/test_convex_hull.py b/ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py similarity index 82% rename from ThirdParty/Ert/python/tests/geometry/test_convex_hull.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py index e0c27305f6..352d830f40 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_convex_hull.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_convex_hull.py @@ -1,8 +1,8 @@ -from ecl.geo.geometry_tools import GeometryTools -from ecl.test.extended_testcase import ExtendedTestCase +from ecl.util.geometry.geometry_tools import GeometryTools +from tests import EclTest -class ConvexHullTest(ExtendedTestCase): +class ConvexHullTest(EclTest): def test_ccw(self): p1 = (0, 0) @@ -24,4 +24,4 @@ def test_convex_hull(self): points = [(0, -0.5), (0, 0.5), (-0.5, 0), (0.5, 0), (0, 0), (0.5, 0.5)] result = GeometryTools.convexHull(points) - self.assertEqual(result, [(-0.5, 0), (0, 0.5), (0.5, 0.5), (0.5, 0), (0, -0.5)]) \ No newline at end of file + self.assertEqual(result, [(-0.5, 0), (0, 0.5), (0.5, 0.5), (0.5, 0), (0, -0.5)]) diff --git a/ThirdParty/Ert/python/tests/geometry/test_cpolyline.py b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py similarity index 96% rename from ThirdParty/Ert/python/tests/geometry/test_cpolyline.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py index 6439f15923..39708f2cc1 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_cpolyline.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline.py @@ -1,11 +1,12 @@ import math -from ecl.geo import CPolyline , Polyline -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.geometry import CPolyline , Polyline +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest -class CPolylineTest(ExtendedTestCase): +class CPolylineTest(EclTest): def setUp(self): self.polyline1 = self.createTestPath("local/geometry/pol11.xyz") self.polyline2 = self.createTestPath("local/geometry/pol8.xyz") diff --git a/ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py similarity index 93% rename from ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py index 11ab6a63cd..52819ce6a0 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_cpolyline_collection.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_cpolyline_collection.py @@ -1,11 +1,12 @@ import gc -from ecl.geo import CPolylineCollection , CPolyline -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext -from ecl.util import DoubleVector +from ecl.util.geometry import CPolylineCollection , CPolyline +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest +from ecl.util.util import DoubleVector -class CPolylineCollectionTest(ExtendedTestCase): +class CPolylineCollectionTest(EclTest): def test_construction(self): pc = CPolylineCollection() diff --git a/ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py similarity index 83% rename from ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py index 1d1c423f17..4f43df59da 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_geo_pointset.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_pointset.py @@ -1,8 +1,9 @@ -from ecl.geo import GeoPointset, Surface -from ecl.test import ExtendedTestCase, TestAreaContext +from ecl.util.geometry import GeoPointset, Surface +from ecl.util.test import TestAreaContext +from tests import EclTest -class GeoPointsetTest(ExtendedTestCase): +class GeoPointsetTest(EclTest): def test_init(self): gp = GeoPointset() diff --git a/ThirdParty/Ert/python/tests/geometry/test_geo_region.py b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py similarity index 94% rename from ThirdParty/Ert/python/tests/geometry/test_geo_region.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py index 949ced3128..c1d6533489 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_geo_region.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_geo_region.py @@ -1,8 +1,9 @@ -from ecl.geo import GeoRegion, GeoPointset, CPolyline, Surface -from ecl.test import ExtendedTestCase, TestAreaContext +from ecl.util.geometry import GeoRegion, GeoPointset, CPolyline, Surface +from ecl.util.test import TestAreaContext +from tests import EclTest -class GeoRegionTest(ExtendedTestCase): +class GeoRegionTest(EclTest): def test_init(self): pointset = GeoPointset() diff --git a/ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py b/ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py similarity index 92% rename from ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py index 0656677ad6..8e2d7587ff 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_geometry_tools.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_geometry_tools.py @@ -1,11 +1,12 @@ import math -from ecl.geo import Polyline, GeometryTools , CPolyline -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.geometry import Polyline, GeometryTools , CPolyline +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest -class GeometryToolsTest(ExtendedTestCase): +class GeometryToolsTest(EclTest): def test_distance(self): p1 = (1,1) diff --git a/ThirdParty/Ert/python/tests/geometry/test_intersection.py b/ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py similarity index 88% rename from ThirdParty/Ert/python/tests/geometry/test_intersection.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py index af78512e84..189ad14614 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_intersection.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_intersection.py @@ -1,8 +1,8 @@ -from ecl.geo import GeometryTools -from ecl.test.extended_testcase import ExtendedTestCase +from ecl.util.geometry import GeometryTools +from tests import EclTest -class IntersectionTest(ExtendedTestCase): +class IntersectionTest(EclTest): def test_intersection(self): diff --git a/ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py b/ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py similarity index 86% rename from ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py index 8faeb9ca5f..469a58127d 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_point_in_polygon.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_point_in_polygon.py @@ -1,9 +1,9 @@ -from ecl.geo.geometry_tools import GeometryTools -from ecl.geo.polyline import Polyline -from ecl.test.extended_testcase import ExtendedTestCase +from ecl.util.geometry.geometry_tools import GeometryTools +from ecl.util.geometry.polyline import Polyline +from tests import EclTest -class PointInPolygonTest(ExtendedTestCase): +class PointInPolygonTest(EclTest): def test_point_in_polygon(self): p1 = (0.5, 0.5) @@ -57,4 +57,4 @@ def test_point_in_polygon_with_3_element_points(self): poly = [(0,0,9), (0,1,9), (0.6,0.5), (0.4,0.5,9), (1,1), (1,0,9)] self.assertFalse(GeometryTools.pointInPolygon(p1, poly)) - self.assertTrue(GeometryTools.pointInPolygon(p2, poly)) \ No newline at end of file + self.assertTrue(GeometryTools.pointInPolygon(p2, poly)) diff --git a/ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py b/ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py similarity index 96% rename from ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py index e2493e6822..5d6e0f06ec 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_polygon_slicing.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_polygon_slicing.py @@ -1,9 +1,9 @@ from math import sqrt -from ecl.geo.geometry_tools import GeometryTools -from ecl.test import ExtendedTestCase +from ecl.util.geometry.geometry_tools import GeometryTools +from tests import EclTest -class PolygonSlicingTest(ExtendedTestCase): +class PolygonSlicingTest(EclTest): def test_slicing_internal_hull(self): polygon = [(2,2),(2,1),(1,1),(1,5),(5,5),(5,4),(4,4)] diff --git a/ThirdParty/Ert/python/tests/geometry/test_polyline.py b/ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py similarity index 96% rename from ThirdParty/Ert/python/tests/geometry/test_polyline.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py index bd9e262cff..04c538c84f 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_polyline.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_polyline.py @@ -1,10 +1,11 @@ -from ecl.geo import Polyline, GeometryTools -from ecl.geo.xyz_io import XYZIo -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.geometry import Polyline, GeometryTools +from ecl.util.geometry.xyz_io import XYZIo +from ecl.util.test import TestAreaContext +from tests import EclTest -class PolylineTest(ExtendedTestCase): +class PolylineTest(EclTest): def setUp(self): self.polyline = self.createTestPath("local/geometry/pol11.xyz") self.closed_polyline = self.createTestPath("local/geometry/pol8.xyz") diff --git a/ThirdParty/Ert/python/tests/geometry/test_surface.py b/ThirdParty/Ert/python/tests/geometry_tests/test_surface.py similarity index 97% rename from ThirdParty/Ert/python/tests/geometry/test_surface.py rename to ThirdParty/Ert/python/tests/geometry_tests/test_surface.py index 995c34bcdb..631305b30d 100644 --- a/ThirdParty/Ert/python/tests/geometry/test_surface.py +++ b/ThirdParty/Ert/python/tests/geometry_tests/test_surface.py @@ -1,9 +1,10 @@ import random -from ecl.geo import Surface -from ecl.test import ExtendedTestCase , TestAreaContext +from ecl.util.geometry import Surface +from ecl.util.test import TestAreaContext +from tests import EclTest -class SurfaceTest(ExtendedTestCase): +class SurfaceTest(EclTest): def setUp(self): self.surface_valid = self.createTestPath("local/geometry/surface/valid_ascii.irap") self.surface_short = self.createTestPath("local/geometry/surface/short_ascii.irap") diff --git a/ThirdParty/Ert/python/tests/global/CMakeLists.txt b/ThirdParty/Ert/python/tests/global/CMakeLists.txt deleted file mode 100644 index 957c12c570..0000000000 --- a/ThirdParty/Ert/python/tests/global/CMakeLists.txt +++ /dev/null @@ -1,12 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_import.py - test_pylint.py -) - -add_python_package("python.tests.global" "${PYTHON_INSTALL_PREFIX}/tests/global" "${TEST_SOURCES}" False) - -addPythonTest(tests.global.test_import.ImportEcl) -addPythonTest(tests.global.test_pylint.LintErt) - - diff --git a/ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt new file mode 100644 index 0000000000..25fb9e4263 --- /dev/null +++ b/ThirdParty/Ert/python/tests/global_tests/CMakeLists.txt @@ -0,0 +1,12 @@ +set(TEST_SOURCES + __init__.py + test_import.py + test_pylint.py +) + +add_python_package("python.tests.global_tests" "${PYTHON_INSTALL_PREFIX}/tests/global_tests" "${TEST_SOURCES}" False) + +addPythonTest(tests.global_tests.test_import.ImportEcl) +addPythonTest(tests.global_tests.test_pylint.LintErt) + + diff --git a/ThirdParty/Ert/python/tests/util/__init__.py b/ThirdParty/Ert/python/tests/global_tests/__init__.py similarity index 100% rename from ThirdParty/Ert/python/tests/util/__init__.py rename to ThirdParty/Ert/python/tests/global_tests/__init__.py diff --git a/ThirdParty/Ert/python/tests/global/test_import.py b/ThirdParty/Ert/python/tests/global_tests/test_import.py similarity index 94% rename from ThirdParty/Ert/python/tests/global/test_import.py rename to ThirdParty/Ert/python/tests/global_tests/test_import.py index fe0835809a..6681589a8d 100644 --- a/ThirdParty/Ert/python/tests/global/test_import.py +++ b/ThirdParty/Ert/python/tests/global_tests/test_import.py @@ -18,9 +18,9 @@ import sys -from ecl.test import ImportTestCase +from ecl.util.test import ImportTestCase class ImportEcl(ImportTestCase): - + def test_import_ecl(self): self.assertTrue( self.import_package( "ecl" )) diff --git a/ThirdParty/Ert/python/tests/global/test_pylint.py b/ThirdParty/Ert/python/tests/global_tests/test_pylint.py similarity index 56% rename from ThirdParty/Ert/python/tests/global/test_pylint.py rename to ThirdParty/Ert/python/tests/global_tests/test_pylint.py index bebe2f5f48..1dac7dafaf 100644 --- a/ThirdParty/Ert/python/tests/global/test_pylint.py +++ b/ThirdParty/Ert/python/tests/global_tests/test_pylint.py @@ -14,7 +14,7 @@ # See the GNU General Public License at # for more details. -from ecl.test import LintTestCase +from ecl.util.test import LintTestCase class LintErt(LintTestCase): """Tests that no file in ert needs linting""" @@ -28,7 +28,18 @@ def test_lint_geo(self): self.assertLinted('ecl/geo') def test_lint_util(self): - self.assertLinted('ecl/util') + self.assertLinted('ecl/util', whitelist = ["vector_template.py", + "test_area.py", + "extended_testcase.py", + "ert_test_context.py", + "ert_test_runnet.py", + "import_test_case.py", + "lint_test_case.py", + "path_context.py" + "source_enumerator.py", + "temp_area.py", + "test_run.py" + ]) def test_lint_well(self): self.assertLinted('ecl/well') diff --git a/ThirdParty/Ert/python/tests/install/test_install.py b/ThirdParty/Ert/python/tests/install_tests/test_install.py similarity index 85% rename from ThirdParty/Ert/python/tests/install/test_install.py rename to ThirdParty/Ert/python/tests/install_tests/test_install.py index b43ab9b903..a0696599c8 100644 --- a/ThirdParty/Ert/python/tests/install/test_install.py +++ b/ThirdParty/Ert/python/tests/install_tests/test_install.py @@ -7,7 +7,8 @@ # typically be achieved with the bash script bin/test_install which is # generated during the configure process. -from ecl.ecl import EclSum, EclGrid +from ecl.grid import EclGrid +from ecl.summary import EclSum diff --git a/ThirdParty/Ert/python/tests/legacy/CMakeLists.txt b/ThirdParty/Ert/python/tests/legacy/CMakeLists.txt deleted file mode 100644 index 1ccd83497b..0000000000 --- a/ThirdParty/Ert/python/tests/legacy/CMakeLists.txt +++ /dev/null @@ -1,16 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_ecl.py - test_geo.py - test_well.py - test_util.py - test_test.py -) - -add_python_package("python.tests.legacy.ert" ${PYTHON_INSTALL_PREFIX}/tests/legacy "${TEST_SOURCES}" False) - -addPythonTest(tests.legacy.test_ecl.ErtLegacyEclTest) -addPythonTest(tests.legacy.test_geo.ErtLegacyGeoTest) -addPythonTest(tests.legacy.test_well.ErtLegacyWellTest) -addPythonTest(tests.legacy.test_util.ErtLegacyUtilTest) -addPythonTest(tests.legacy.test_test.ErtLegacyTestTest) diff --git a/ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt new file mode 100644 index 0000000000..74fd4fcd47 --- /dev/null +++ b/ThirdParty/Ert/python/tests/legacy_tests/CMakeLists.txt @@ -0,0 +1,16 @@ +set(TEST_SOURCES + __init__.py + test_ecl.py + test_geo.py + test_well.py + test_util.py + test_test.py +) + +add_python_package("python.tests.legacy_tests.ert" ${PYTHON_INSTALL_PREFIX}/tests/legacy_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.legacy_tests.test_ecl.ErtLegacyEclTest) +addPythonTest(tests.legacy_tests.test_geo.ErtLegacyGeoTest) +addPythonTest(tests.legacy_tests.test_well.ErtLegacyWellTest) +addPythonTest(tests.legacy_tests.test_util.ErtLegacyUtilTest) +addPythonTest(tests.legacy_tests.test_test.ErtLegacyTestTest) diff --git a/ThirdParty/Ert/python/tests/well/__init__.py b/ThirdParty/Ert/python/tests/legacy_tests/__init__.py similarity index 100% rename from ThirdParty/Ert/python/tests/well/__init__.py rename to ThirdParty/Ert/python/tests/legacy_tests/__init__.py diff --git a/ThirdParty/Ert/python/tests/legacy/test_ecl.py b/ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py similarity index 94% rename from ThirdParty/Ert/python/tests/legacy/test_ecl.py rename to ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py index f90d3fd628..c51a55eabc 100644 --- a/ThirdParty/Ert/python/tests/legacy/test_ecl.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_ecl.py @@ -34,8 +34,9 @@ from ert.ecl.faults import FaultBlockLayer -from ecl.test import ExtendedTestCase +from tests import EclTest -class ErtLegacyEclTest(ExtendedTestCase): + +class ErtLegacyEclTest(EclTest): pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_geo.py b/ThirdParty/Ert/python/tests/legacy_tests/test_geo.py similarity index 76% rename from ThirdParty/Ert/python/tests/legacy/test_geo.py rename to ThirdParty/Ert/python/tests/legacy_tests/test_geo.py index 669b5ab9d6..b0e5cb0126 100644 --- a/ThirdParty/Ert/python/tests/legacy/test_geo.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_geo.py @@ -7,8 +7,8 @@ from ert.geo import GeometryTools from ert.geo import Surface -from ecl.test import ExtendedTestCase +from tests import EclTest -class ErtLegacyGeoTest(ExtendedTestCase): +class ErtLegacyGeoTest(EclTest): pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_test.py b/ThirdParty/Ert/python/tests/legacy_tests/test_test.py similarity index 74% rename from ThirdParty/Ert/python/tests/legacy/test_test.py rename to ThirdParty/Ert/python/tests/legacy_tests/test_test.py index 40d0ef2b73..1b75b2941f 100644 --- a/ThirdParty/Ert/python/tests/legacy/test_test.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_test.py @@ -1,6 +1,5 @@ from ert.test import TestRun from ert.test import path_exists -from ert.test import ExtendedTestCase from ert.test import SourceEnumerator from ert.test import TestArea , TestAreaContext from ert.test import TempArea , TempAreaContext @@ -9,8 +8,8 @@ from ert.test import LintTestCase from ert.test import ImportTestCase -from ecl.test import ExtendedTestCase +from tests import EclTest -class ErtLegacyTestTest(ExtendedTestCase): +class ErtLegacyTestTest(EclTest): pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_util.py b/ThirdParty/Ert/python/tests/legacy_tests/test_util.py similarity index 59% rename from ThirdParty/Ert/python/tests/legacy/test_util.py rename to ThirdParty/Ert/python/tests/legacy_tests/test_util.py index 712f12f00a..a52dd8f442 100644 --- a/ThirdParty/Ert/python/tests/legacy/test_util.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_util.py @@ -1,5 +1,5 @@ from ert.util import Version -from ert.util import RngAlgTypeEnum, RngInitModeEnum, LLSQResultEnum +from ert.util import RngAlgTypeEnum, RngInitModeEnum from ert.util import CTime from ert.util import PermutationVector from ert.util import VectorTemplate @@ -9,26 +9,23 @@ from ert.util import TimeVector from ert.util import StringList from ert.util import RandomNumberGenerator -from ert.util import Matrix -from ert.util import quantile, quantile_sorted, polyfit -from ert.util import Log from ert.util import LookupTable -from ert.util import Buffer from ert.util import Hash, StringHash, DoubleHash, IntegerHash -from ert.util import UIReturn from ert.util import ThreadPool -from ert.util import CThreadPool, startCThreadPool from ert.util import installAbortSignals, updateAbortSignals -from ert.util import Profiler from ert.util import ArgPack -from ert.util import PathFormat -from ecl.test import ExtendedTestCase +from tests import EclTest try: from res.util import SubstitutionList except ImportError: pass -class ErtLegacyUtilTest(ExtendedTestCase): +try: + from res.util import CThreadPool, startCThreadPool +except ImportError: + pass + +class ErtLegacyUtilTest(EclTest): pass diff --git a/ThirdParty/Ert/python/tests/legacy/test_well.py b/ThirdParty/Ert/python/tests/legacy_tests/test_well.py similarity index 76% rename from ThirdParty/Ert/python/tests/legacy/test_well.py rename to ThirdParty/Ert/python/tests/legacy_tests/test_well.py index 102b049739..b622ec965a 100644 --- a/ThirdParty/Ert/python/tests/legacy/test_well.py +++ b/ThirdParty/Ert/python/tests/legacy_tests/test_well.py @@ -6,8 +6,8 @@ from ert.well import WellTimeLine from ert.well import WellInfo -from ecl.test import ExtendedTestCase +from tests import EclTest -class ErtLegacyWellTest(ExtendedTestCase): +class ErtLegacyWellTest(EclTest): pass diff --git a/ThirdParty/Ert/python/tests/share/CMakeLists.txt b/ThirdParty/Ert/python/tests/share/CMakeLists.txt deleted file mode 100644 index ef80c2d77d..0000000000 --- a/ThirdParty/Ert/python/tests/share/CMakeLists.txt +++ /dev/null @@ -1,8 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_synthesizer.py -) - -add_python_package("python.tests.share" ${PYTHON_INSTALL_PREFIX}/tests/share "${TEST_SOURCES}" False) - -addPythonTest(share.test_synthesizer.SynthesizerTest) diff --git a/ThirdParty/Ert/python/tests/share/test_synthesizer.py b/ThirdParty/Ert/python/tests/share/test_synthesizer.py deleted file mode 100644 index f5863f5e91..0000000000 --- a/ThirdParty/Ert/python/tests/share/test_synthesizer.py +++ /dev/null @@ -1,50 +0,0 @@ -import sys -import os -from ecl.test import ExtendedTestCase - -try: - from synthesizer import OilSimulator -except ImportError as e: - share_lib_path = os.path.join(ExtendedTestCase.createSharePath("lib")) - - sys.path.insert(0, share_lib_path) - synthesizer_module = __import__("synthesizer") - OilSimulator = synthesizer_module.OilSimulator - sys.path.pop(0) - - -class SynthesizerTest(ExtendedTestCase): - - def test_oil_simulator(self): - sim = OilSimulator() - sim.addWell("OP1", seed=1) - sim.addBlock("6,6,6", seed=2) - - expected_values = [ - [0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 1.0], - [0.3359771423145687, 0.3359771423145687, 0.25672494192349865, 0.25672494192349865, 0.010039005455891323, 0.010039005455891323, 0.029013112597713192, 0.7641143089523995, 0.3359771423145687, 0.25672494192349865, 0.010039005455891323, 0.7641143089523995, 0.029013112597713192, 0.8462347957619747], - [0.7252470407619624, 1.0612241830765312, 0.5175173529594699, 0.7742422948829686, 0.017973831236885583, 0.028012836692776905, 0.02418370085402209, 0.7135738912023045, 0.7252470407619624, 0.5175173529594699, 0.017973831236885583, 0.7135738912023045, 0.02418370085402209, 0.6888364145396828], - [0.7723163496234255, 1.8335405326999568, 0.5742386073607806, 1.3484809022437492, 0.11041673583737899, 0.1384295725301559, 0.12508507685507134, 0.7435277106858791, 0.7723163496234255, 0.5742386073607806, 0.11041673583737899, 0.7435277106858791, 0.12508507685507134, 0.6403046565762696], - [0.6038799675664164, 2.437420500266373, 0.6888868738548185, 2.037367776098568, 0.267892132439122, 0.4063217049692779, 0.3072960610203287, 1.140767885762087, 0.6038799675664164, 0.6888868738548185, 0.267892132439122, 1.140767885762087, 0.3072960610203287, 0.5205364945011657], - [0.23016535126253962, 2.6675858515289126, 0.721655666522216, 2.7590234426207836, 0.35552466124555465, 0.7618463662148325, 0.6070184801736589, 3.135379250454838, 0.23016535126253962, 0.721655666522216, 0.35552466124555465, 3.135379250454838, 0.6070184801736589, 0.4800677649914682], - [0.026293782934652718, 2.693879634463565, 0.7131990780527108, 3.4722225206734945, 0.6392372725163122, 1.4010836387311447, 0.8647254356377257, 7.131990780527107, 0.026293782934652718, 0.7131990780527108, 0.6392372725163122, 7.131990780527107, 0.8647254356377257, 0.3872974839053025], - [0.0, 2.693879634463565, 0.8676997908824122, 4.339922311555907, 0.8580356376693129, 2.2591192764004577, 0.8956197493411856, 8.676997908824122, 0.0, 0.8676997908824122, 0.8580356376693129, 8.676997908824122, 0.8956197493411856, 0.22557165737149715], - [0.10560669451549878, 2.799486328979064, 0.869082212788759, 5.209004524344666, 0.8903674796589355, 3.1494867560593933, 0.8939664328113363, 8.229423492288294, 0.10560669451549878, 0.869082212788759, 0.8903674796589355, 8.229423492288294, 0.8939664328113363, 0.1340241573819292], - [0.08615885630000791, 2.885645185279072, 0.44074890315982446, 5.64975342750449, 0.9425699260811738, 4.0920566821405675, 0.9040831722665535, 4.407489031598244, 0.08615885630000791, 0.44074890315982446, 0.9425699260811738, 4.407489031598244, 0.9040831722665535, 0.13404047971467026] - ] - - for report_step in range(10): - sim.step(scale=1.0 / 10.0) - - values = [sim.fopr(), sim.fopt(), sim.fgpr(), sim.fgpt(), sim.fwpr(), sim.fwpt(), sim.fwct(), sim.fgor(), - sim.opr("OP1"), sim.gpr("OP1"), sim.wpr("OP1"), sim.gor("OP1"), sim.wct("OP1"), sim.bpr("6,6,6")] - - self.assertAlmostEqual(values[0], values[8]) # fopr = opr:op1 - self.assertAlmostEqual(values[2], values[9]) # fgpr = gpr:op1 - self.assertAlmostEqual(values[4], values[10]) # fwpr = wpr:op1 - - self.assertAlmostEqual(sim.foip(), sim.ooip - sim.fopt()) - self.assertAlmostEqual(sim.fgip(), sim.goip - sim.fgpt()) - self.assertAlmostEqual(sim.fwip(), sim.woip - sim.fwpt()) - - self.assertAlmostEqualList(values, expected_values[report_step]) diff --git a/ThirdParty/Ert/python/tests/test_install.in b/ThirdParty/Ert/python/tests/test_install.in index 0831127069..e7e154739a 100644 --- a/ThirdParty/Ert/python/tests/test_install.in +++ b/ThirdParty/Ert/python/tests/test_install.in @@ -2,5 +2,5 @@ export PYTHONPATH=@CMAKE_INSTALL_PREFIX@/@PYTHON_INSTALL_PREFIX@:@CTEST_PYTHONPATH@:$PYTHONPATH -@PROJECT_SOURCE_DIR@/python/tests/install/test_install.py $@ +@PROJECT_SOURCE_DIR@/python/tests/install_tests/test_install.py $@ diff --git a/ThirdParty/Ert/python/tests/test_pylint.py b/ThirdParty/Ert/python/tests/test_pylint.py deleted file mode 100644 index 84e8ff6a63..0000000000 --- a/ThirdParty/Ert/python/tests/test_pylint.py +++ /dev/null @@ -1,34 +0,0 @@ -# Copyright (C) 2017 Statoil ASA, Norway. -# -# This file is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. - -from ecl.test import LintTestCase - -class LintErt(LintTestCase): - """Tests that no file in ert needs linting""" - - # Temporarily disabled due to monkey patching camel case - # def test_lint_ecl(self): - # white = ['ecl_kw.py', 'ecl_type.py', 'ecl_sum.py', 'ecl_grid.py', 'ecl_npv.py'] # TODO fix issues and remove - # self.assertLinted('ecl/ecl', whitelist=white) - - def test_lint_geo(self): - self.assertLinted('ecl/geo') - - def test_lint_util(self): - self.assertLinted('ecl/util') - - def test_lint_well(self): - self.assertLinted('ecl/well') diff --git a/ThirdParty/Ert/python/tests/util/CMakeLists.txt b/ThirdParty/Ert/python/tests/util/CMakeLists.txt deleted file mode 100644 index e2b75c8024..0000000000 --- a/ThirdParty/Ert/python/tests/util/CMakeLists.txt +++ /dev/null @@ -1,46 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_ctime.py - test_cstring.py - test_hash.py - test_lookup_table.py - test_matrix.py - test_rng.py - test_stat.py - test_string_list.py - #test_substitution_list.py - test_thread_pool.py - test_cthread_pool.py - test_ui_return.py - test_vectors.py - test_version.py - test_work_area.py - test_path_context.py - test_path_fmt.py - test_arg_pack.py - test_spawn.py - test_log.py -) - -add_python_package("python.tests.util" ${PYTHON_INSTALL_PREFIX}/tests/util "${TEST_SOURCES}" False) - -addPythonTest(tests.util.test_ctime.CTimeTest) -addPythonTest(tests.util.test_cstring.CStringTest) -addPythonTest(tests.util.test_hash.HashTest) -addPythonTest(tests.util.test_lookup_table.LookupTableTest ) -addPythonTest(tests.util.test_matrix.MatrixTest ) -addPythonTest(tests.util.test_rng.RngTest ) -addPythonTest(tests.util.test_stat.StatTest ) -addPythonTest(tests.util.test_string_list.StringListTest) -addPythonTest(tests.util.test_vectors.UtilTest) -addPythonTest(tests.util.test_ui_return.UIReturnTest) -addPythonTest(tests.util.test_path_fmt.PathFmtTest) -addPythonTest(tests.util.test_work_area.WorkAreaTest) -addPythonTest(tests.util.test_version.VersionTest) -addPythonTest(tests.util.test_path_context.PathContextTest) -addPythonTest(tests.util.test_thread_pool.ThreadPoolTest) -addPythonTest(tests.util.test_cthread_pool.CThreadPoolTest) -addPythonTest(tests.util.test_arg_pack.ArgPackTest) -addPythonTest(tests.util.test_spawn.SpawnTest) -#addPythonTest(tests.util.test_substitution_list.SubstitutionListTest) -addPythonTest(tests.util.test_log.LogTest) diff --git a/ThirdParty/Ert/python/tests/util/test_cstring.py b/ThirdParty/Ert/python/tests/util/test_cstring.py deleted file mode 100644 index 12f8a58c50..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_cstring.py +++ /dev/null @@ -1,24 +0,0 @@ -import ecl -from cwrap import Prototype -from ecl.test.extended_testcase import ExtendedTestCase - -# Local copies so that the real ones don't get changed -class TestUtilPrototype(Prototype): - lib = ecl.load("libecl") - - def __init__(self, prototype, bind=False): - super(TestUtilPrototype, self).__init__(TestUtilPrototype.lib, prototype, bind=bind) - -alloc_string_copy = TestUtilPrototype("char* util_alloc_string_copy(char*)") - -class CStringTest(ExtendedTestCase): - - def test_get(self): - # this test can safely be deleted, as the type it used to test, - # cstring_obj, has been replaced with char* - s1 = "String123" - print('test_get.s1=' + s1) - s2 = alloc_string_copy(s1) - print('test_get.s2=' + s2) - self.assertEqual(s1, s2) - print('test_get.s1==s2: %s' % (s1 == s2)) diff --git a/ThirdParty/Ert/python/tests/util/test_cthread_pool.py b/ThirdParty/Ert/python/tests/util/test_cthread_pool.py deleted file mode 100644 index dd6b32b952..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_cthread_pool.py +++ /dev/null @@ -1,47 +0,0 @@ -import ctypes -import ecl -from ecl.test import ExtendedTestCase -from ecl.util import CThreadPool, startCThreadPool - -TEST_LIB = ecl.load("libecl") - - -class CThreadPoolTest(ExtendedTestCase): - def test_cfunc(self): - with self.assertRaises(TypeError): - func = CThreadPool.lookupCFunction("WRONG-TYPE", "no-this-does-not-exist") - - with self.assertRaises(AttributeError): - func = CThreadPool.lookupCFunction(TEST_LIB, "no-this-does-not-exist") - - def test_create(self): - pool = CThreadPool(32, start=True) - job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1") - arg = ctypes.c_int(0) - - N = 256 - for i in range(N): - pool.addTask(job, ctypes.byref(arg)) - pool.join() - self.assertEqual(arg.value, N) - - def test_context(self): - N = 256 - arg = ctypes.c_int(0) - job = CThreadPool.lookupCFunction(TEST_LIB, "thread_pool_test_func1") - with startCThreadPool(16) as tp: - for i in range(N): - tp.addTask(job, ctypes.byref(arg)) - self.assertEqual(arg.value, N) - - def test_add_task_function(self): - pool = CThreadPool(32, start=True) - pool.addTaskFunction("testFunction", TEST_LIB, "thread_pool_test_func1") - - arg = ctypes.c_int(0) - task_count = 256 - for i in range(task_count): - pool.testFunction(ctypes.byref(arg)) - - pool.join() - self.assertEqual(arg.value, task_count) diff --git a/ThirdParty/Ert/python/tests/util/test_log.py b/ThirdParty/Ert/python/tests/util/test_log.py deleted file mode 100644 index dba143dad9..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_log.py +++ /dev/null @@ -1,8 +0,0 @@ -from ecl.util.enums import MessageLevelEnum - -from ecl.test import ExtendedTestCase - -class LogTest(ExtendedTestCase): - - def test_enums(self): - self.assertEnumIsFullyDefined(MessageLevelEnum, "message_level_type", "lib/include/ert/util/log.h") diff --git a/ThirdParty/Ert/python/tests/util/test_matrix.py b/ThirdParty/Ert/python/tests/util/test_matrix.py deleted file mode 100644 index d5d5205890..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_matrix.py +++ /dev/null @@ -1,247 +0,0 @@ -from ecl.util import Matrix , RandomNumberGenerator -from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum -from ecl.test import ExtendedTestCase, TestAreaContext - -class MatrixTest(ExtendedTestCase): - def test_matrix(self): - m = Matrix(2, 3) - - self.assertEqual(m.rows(), 2) - self.assertEqual(m.columns(), 3) - - self.assertEqual(m[(0, 0)], 0) - - m[(1, 1)] = 1.5 - self.assertEqual(m[(1, 1)], 1.5) - - m[1,0] = 5 - self.assertEqual(m[1, 0], 5) - - with self.assertRaises(TypeError): - m[5] = 5 - - with self.assertRaises(IndexError): - m[2, 0] = 0 - - with self.assertRaises(IndexError): - m[0, 3] = 0 - - def test_matrix_set(self): - m1 = Matrix(2,2) - m1.setAll(99) - self.assertEqual( 99 , m1[0,0] ) - self.assertEqual( 99 , m1[1,1] ) - m2 = Matrix(2,2 , value = 99) - self.assertEqual(m1,m2) - - - def test_matrix_random_init(self): - m = Matrix(10,10) - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) - m.randomInit( rng ) - - def test_matrix_copy_column(self): - m = Matrix(10,2) - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) - m.randomInit( rng ) - - with self.assertRaises(ValueError): - m.copyColumn(0,2) - - with self.assertRaises(ValueError): - m.copyColumn(2,0) - - with self.assertRaises(ValueError): - m.copyColumn(-2,0) - - m.copyColumn(1, 0) - for i in range(m.rows()): - self.assertEqual( m[i,0] , m[i,1] ) - - - def test_matrix_scale(self): - m = Matrix(2,2 , value = 1) - m.scaleColumn(0 , 2) - self.assertEqual(2 , m[0,0]) - self.assertEqual(2 , m[1,0]) - - m.setAll(1) - m.scaleRow(1 , 2 ) - self.assertEqual(2 , m[1,0]) - self.assertEqual(2 , m[1,1]) - - with self.assertRaises(IndexError): - m.scaleColumn(10 , 99) - - with self.assertRaises(IndexError): - m.scaleRow(10 , 99) - - - - - def test_matrix_equality(self): - m = Matrix(2, 2) - m[0, 0] = 2 - m[1, 1] = 4 - - s = Matrix(2, 3) - s[0, 0] = 2 - s[1, 1] = 4 - - self.assertNotEqual(m, s) - - r = Matrix(2, 2) - r[0, 0] = 2 - r[1, 1] = 3 - - self.assertNotEqual(m, r) - - r[1, 1] = 4 - - self.assertEqual(m, r) - - def test_str(self): - m = Matrix(2, 2) - s = "%s" % m - - m[0,0] = 0 - m[0,1] = 1 - m[1,0] = 2 - m[1,1] = 3 - - with TestAreaContext("matrix_fprint"): - with open("matrix.txt", "w") as f: - m.fprint( f ) - - with open("matrix.txt") as f: - l1 = [ float(x) for x in f.readline().split()] - l2 = [ float(x) for x in f.readline().split()] - - self.assertEqual( l1[0] , m[0,0]) - self.assertEqual( l1[1] , m[0,1]) - self.assertEqual( l2[0] , m[1,0]) - self.assertEqual( l2[1] , m[1,1]) - - - def test_copy_equal(self): - m1 = Matrix(2, 2) - m1[0,0] = 0 - m1[0,1] = 1 - m1[1,0] = 2 - m1[1,1] = 3 - - m2 = m1.copy( ) - self.assertTrue( m1 == m2 ) - - def test_sub_copy(self): - m1 = Matrix(3,3) - rng = RandomNumberGenerator(RngAlgTypeEnum.MZRAN, RngInitModeEnum.INIT_DEFAULT) - m1.randomInit( rng ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 0,0,4,2 ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 0,0,2,4 ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 4,0,1,1 ) - - with self.assertRaises(ValueError): - m2 = m1.subCopy( 0,2,1,2 ) - - - m2 = m1.subCopy( 0,0,2,2 ) - for i in range(2): - for j in range(2): - self.assertEqual( m1[i,j] , m2[i,j]) - - - def test_transpose(self): - m = Matrix(3,2) - m[0,0] = 0 - m[1,0] = 2 - m[2,0] = 4 - - m[0,1] = 1 - m[1,1] = 3 - m[2,1] = 5 - - mt = m.transpose( ) - - self.assertEqual(m[0,0] , 0) - self.assertEqual(m[1,0] , 2) - self.assertEqual(m[2,0] , 4) - - self.assertEqual(m[0,1] , 1) - self.assertEqual(m[1,1] , 3) - self.assertEqual(m[2,1] , 5) - - self.assertEqual( mt.rows() , m.columns()) - self.assertEqual( mt.columns() , m.rows()) - self.assertEqual(mt[0,0] , 0) - self.assertEqual(mt[1,0] , 1) - - self.assertEqual(mt[0,1] , 2) - self.assertEqual(mt[1,1] , 3) - - self.assertEqual(mt[0,2] , 4) - self.assertEqual(mt[1,2] , 5) - - m.transpose( inplace = True ) - self.assertEqual( m , mt ) - - - def test_matmul(self): - m1 = Matrix(3,3) - m2 = Matrix(2,2) - - with self.assertRaises(ValueError): - Matrix.matmul( m1 , m2 ) - - m = Matrix(3,2) - m[0,0] = 0 - m[1,0] = 2 - m[2,0] = 4 - - m[0,1] = 1 - m[1,1] = 3 - m[2,1] = 5 - - mt = m.transpose( ) - - m2 = Matrix.matmul( m , mt ) - - self.assertEqual( m2[0,0] , 1 ) - self.assertEqual( m2[1,1] , 13 ) - self.assertEqual( m2[2,2] , 41 ) - - - def test_csv(self): - m = Matrix(2, 2) - m[0, 0] = 2 - m[1, 1] = 4 - with TestAreaContext("matrix_csv"): - m.dumpCSV("matrix.csv") - - def test_identity(self): - m1 = Matrix.identity(1) - self.assertEqual(m1.rows(), 1) - self.assertEqual(m1.columns(), 1) - self.assertEqual(m1[0,0], 1) - - with self.assertRaises(ValueError): - Matrix.identity(0) - with self.assertRaises(ValueError): - Matrix.identity(-3) - - m = Matrix.identity(17) - self.assertEqual(m.rows(), 17) - self.assertEqual(m.columns(), 17) - for i in range(17): - for j in range(17): - elt = m[i, j] - if i == j: - self.assertEqual(elt, 1) - else: - self.assertEqual(elt, 0) diff --git a/ThirdParty/Ert/python/tests/util/test_path_fmt.py b/ThirdParty/Ert/python/tests/util/test_path_fmt.py deleted file mode 100644 index 30adf3be51..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_path_fmt.py +++ /dev/null @@ -1,10 +0,0 @@ -import os -from ecl.test import ExtendedTestCase, TestAreaContext -from ecl.util import PathFormat - -class PathFmtTest(ExtendedTestCase): - - def test_create(self): - path_fmt = PathFormat("random/path/%d-%d") - self.assertIn('random/path', repr(path_fmt)) - self.assertTrue(str(path_fmt).startswith('PathFormat(')) diff --git a/ThirdParty/Ert/python/tests/util/test_stat.py b/ThirdParty/Ert/python/tests/util/test_stat.py deleted file mode 100644 index f1a79e9701..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_stat.py +++ /dev/null @@ -1,43 +0,0 @@ -from ecl.test import ExtendedTestCase -from ecl.util import DoubleVector, quantile, quantile_sorted, polyfit -from ecl.util.rng import RandomNumberGenerator - - -class StatTest(ExtendedTestCase): - def test_stat_quantiles(self): - rng = RandomNumberGenerator() - rng.setState("0123456789ABCDEF") - v = DoubleVector() - for i in range(100000): - v.append(rng.getDouble( )) - - self.assertAlmostEqual(quantile(v, 0.1), 0.1, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.2), 0.2, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.3), 0.3, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.4), 0.4, 2) - self.assertAlmostEqual(quantile_sorted(v, 0.5), 0.5, 2) - - def test_polyfit(self): - x_list = DoubleVector() - y_list = DoubleVector() - S = DoubleVector() - - A = 7.25 - B = -4 - C = 0.025 - - x = 0 - dx = 0.1 - for i in range(100): - y = A + B * x + C * x * x - x_list.append(x) - y_list.append(y) - - x += dx - S.append(1.0) - - beta = polyfit(3, x_list, y_list, None) - - self.assertAlmostEqual(A, beta[0]) - self.assertAlmostEqual(B, beta[1]) - self.assertAlmostEqual(C, beta[2]) diff --git a/ThirdParty/Ert/python/tests/util/test_ui_return.py b/ThirdParty/Ert/python/tests/util/test_ui_return.py deleted file mode 100644 index 8b8da46025..0000000000 --- a/ThirdParty/Ert/python/tests/util/test_ui_return.py +++ /dev/null @@ -1,69 +0,0 @@ -from ecl.test import ExtendedTestCase -from ecl.util import UIReturn -from ecl.util.enums import UIReturnStatusEnum - - -class UIReturnTest(ExtendedTestCase): - def test_create(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - self.assertTrue(ui_return) - - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_FAIL) - self.assertFalse(ui_return) - - self.assertEqual(0, len(ui_return)) - - def test_help(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - self.assertEqual("", ui_return.help_text()) - - ui_return.add_help("Help1") - self.assertEqual("Help1", ui_return.help_text()) - - ui_return.add_help("Help2") - self.assertEqual("Help1 Help2", ui_return.help_text()) - - def test_error_raises_OK(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - with self.assertRaises(ValueError): - ui_return.add_error("Error1") - - with self.assertRaises(ValueError): - ui_return.last_error() - - with self.assertRaises(ValueError): - ui_return.first_error() - - def test_add_error(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_FAIL) - ui_return.add_error("Error1") - ui_return.add_error("Error2") - ui_return.add_error("Error3") - self.assertEqual(3, len(ui_return)) - - self.assertEqual("Error1", ui_return.first_error()) - self.assertEqual("Error3", ui_return.last_error()) - - def test_iget_error(self): - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_FAIL) - ui_return.add_error("Error1") - ui_return.add_error("Error2") - ui_return.add_error("Error3") - - errorList = [] - for index in range(len(ui_return)): - errorList.append(ui_return.iget_error(index)) - self.assertEqual(errorList, ["Error1", "Error2", "Error3"]) - - with self.assertRaises(TypeError): - ui_return.iget_error("XX") - - ui_return = UIReturn(UIReturnStatusEnum.UI_RETURN_OK) - errorList = [] - for index in range(len(ui_return)): - errorList.append(ui_return.iget_error(index)) - self.assertEqual(errorList, []) - - def test_status_enum(self): - source_file_path = "lib/include/ert/util/ui_return.h" - self.assertEnumIsFullyDefined(UIReturnStatusEnum, "ui_return_status_enum", source_file_path) diff --git a/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt new file mode 100644 index 0000000000..a14e586e39 --- /dev/null +++ b/ThirdParty/Ert/python/tests/util_tests/CMakeLists.txt @@ -0,0 +1,32 @@ +set(TEST_SOURCES + __init__.py + test_ctime.py + test_hash.py + test_lookup_table.py + test_rng.py + test_string_list.py + #test_substitution_list.py + test_thread_pool.py + test_vectors.py + test_version.py + test_work_area.py + test_path_context.py + test_arg_pack.py + test_spawn.py +) + +add_python_package("python.tests.util_tests" ${PYTHON_INSTALL_PREFIX}/tests/util_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.util_tests.test_ctime.CTimeTest) +addPythonTest(tests.util_tests.test_hash.HashTest) +addPythonTest(tests.util_tests.test_lookup_table.LookupTableTest ) +addPythonTest(tests.util_tests.test_rng.RngTest ) +addPythonTest(tests.util_tests.test_string_list.StringListTest) +addPythonTest(tests.util_tests.test_vectors.UtilTest) +addPythonTest(tests.util_tests.test_work_area.WorkAreaTest) +addPythonTest(tests.util_tests.test_version.VersionTest) +addPythonTest(tests.util_tests.test_path_context.PathContextTest) +addPythonTest(tests.util_tests.test_thread_pool.ThreadPoolTest) +addPythonTest(tests.util_tests.test_arg_pack.ArgPackTest) +addPythonTest(tests.util_tests.test_spawn.SpawnTest) +#addPythonTest(tests.util.test_substitution_list.SubstitutionListTest) diff --git a/ThirdParty/Ert/python/tests/util_tests/__init__.py b/ThirdParty/Ert/python/tests/util_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/util/test_arg_pack.py b/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py similarity index 81% rename from ThirdParty/Ert/python/tests/util/test_arg_pack.py rename to ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py index 2a73c39112..69f77c68b5 100644 --- a/ThirdParty/Ert/python/tests/util/test_arg_pack.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_arg_pack.py @@ -1,11 +1,12 @@ import ecl -from ecl.test import ExtendedTestCase -from ecl.util import ArgPack, StringList +from ecl import EclPrototype +from tests import EclTest +from ecl.util.util import ArgPack, StringList -TEST_LIB = ecl.load("libecl") +TEST_LIB = EclPrototype.lib -class ArgPackTest(ExtendedTestCase): +class ArgPackTest(EclTest): def test_create(self): arg = ArgPack() self.assertEqual(len(arg), 0) diff --git a/ThirdParty/Ert/python/tests/util/test_ctime.py b/ThirdParty/Ert/python/tests/util_tests/test_ctime.py similarity index 99% rename from ThirdParty/Ert/python/tests/util/test_ctime.py rename to ThirdParty/Ert/python/tests/util_tests/test_ctime.py index 292a13153a..18ca924804 100644 --- a/ThirdParty/Ert/python/tests/util/test_ctime.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_ctime.py @@ -1,7 +1,7 @@ import time from datetime import datetime, date -from ecl.util import CTime +from ecl.util.util import CTime try: diff --git a/ThirdParty/Ert/python/tests/util/test_hash.py b/ThirdParty/Ert/python/tests/util_tests/test_hash.py similarity index 91% rename from ThirdParty/Ert/python/tests/util/test_hash.py rename to ThirdParty/Ert/python/tests/util_tests/test_hash.py index 528d123ee4..a8111a164f 100644 --- a/ThirdParty/Ert/python/tests/util/test_hash.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_hash.py @@ -1,10 +1,10 @@ from ctypes import c_void_p -from ecl.test import ExtendedTestCase -from ecl.util import Hash, StringHash, DoubleHash, IntegerHash +from tests import EclTest +from ecl.util.util import Hash, StringHash, DoubleHash, IntegerHash -class HashTest(ExtendedTestCase): +class HashTest(EclTest): def test_string_hash(self): hash = StringHash() diff --git a/ThirdParty/Ert/python/tests/util/test_lookup_table.py b/ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py similarity index 98% rename from ThirdParty/Ert/python/tests/util/test_lookup_table.py rename to ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py index 9a0fdccdfe..48d7c827f7 100644 --- a/ThirdParty/Ert/python/tests/util/test_lookup_table.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_lookup_table.py @@ -3,7 +3,7 @@ except ImportError: from unittest import TestCase -from ecl.util import LookupTable +from ecl.util.util import LookupTable class LookupTableTest(TestCase): diff --git a/ThirdParty/Ert/python/tests/util/test_path_context.py b/ThirdParty/Ert/python/tests/util_tests/test_path_context.py similarity index 93% rename from ThirdParty/Ert/python/tests/util/test_path_context.py rename to ThirdParty/Ert/python/tests/util_tests/test_path_context.py index 8497e9d193..1690d04ae9 100644 --- a/ThirdParty/Ert/python/tests/util/test_path_context.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_path_context.py @@ -1,8 +1,9 @@ import os -from ecl.test import ExtendedTestCase, PathContext,TestAreaContext +from ecl.util.test import PathContext,TestAreaContext +from tests import EclTest -class PathContextTest(ExtendedTestCase): +class PathContextTest(EclTest): def test_error(self): with TestAreaContext("pathcontext"): diff --git a/ThirdParty/Ert/python/tests/util/test_rng.py b/ThirdParty/Ert/python/tests/util_tests/test_rng.py similarity index 90% rename from ThirdParty/Ert/python/tests/util/test_rng.py rename to ThirdParty/Ert/python/tests/util_tests/test_rng.py index fdf0c2d60c..aba91bfed4 100644 --- a/ThirdParty/Ert/python/tests/util/test_rng.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_rng.py @@ -1,9 +1,10 @@ from ecl.util.enums import RngAlgTypeEnum, RngInitModeEnum -from ecl.util.rng import RandomNumberGenerator -from ecl.test import ExtendedTestCase,TestAreaContext +from ecl.util.util import RandomNumberGenerator +from ecl.util.test import TestAreaContext +from tests import EclTest -class RngTest(ExtendedTestCase): +class RngTest(EclTest): def test_enums(self): self.assertEnumIsFullyDefined(RngAlgTypeEnum, "rng_alg_type", "lib/include/ert/util/rng.h") diff --git a/ThirdParty/Ert/python/tests/util/test_spawn.py b/ThirdParty/Ert/python/tests/util_tests/test_spawn.py similarity index 92% rename from ThirdParty/Ert/python/tests/util/test_spawn.py rename to ThirdParty/Ert/python/tests/util_tests/test_spawn.py index c624ea3d6a..80809fcfff 100644 --- a/ThirdParty/Ert/python/tests/util/test_spawn.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_spawn.py @@ -3,19 +3,20 @@ import sys import ecl -from ecl.test.extended_testcase import ExtendedTestCase -from ecl.test.test_area import TestAreaContext +from ecl import EclPrototype +from tests import EclTest +from ecl.util.test.test_area import TestAreaContext from cwrap import Prototype class _TestSpawnPrototype(Prototype): - lib = ecl.load('libecl') + lib = EclPrototype.lib def __init__(self, prototype, bind=True): super(_TestSpawnPrototype, self).__init__(_TestSpawnPrototype.lib, prototype, bind=bind) -class SpawnTest(ExtendedTestCase): +class SpawnTest(EclTest): _spawn = _TestSpawnPrototype("int util_spawn_blocking(char*, int, void*, char*, char*)", bind = False) def createScript(self, name, stdout_string , stderr_string): with open(name, "w") as f: diff --git a/ThirdParty/Ert/python/tests/util/test_string_list.py b/ThirdParty/Ert/python/tests/util_tests/test_string_list.py similarity index 99% rename from ThirdParty/Ert/python/tests/util/test_string_list.py rename to ThirdParty/Ert/python/tests/util_tests/test_string_list.py index a4076fe2c8..6d0a809836 100644 --- a/ThirdParty/Ert/python/tests/util/test_string_list.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_string_list.py @@ -5,7 +5,7 @@ except ImportError: from unittest import TestCase -from ecl.util import StringList +from ecl.util.util import StringList class StringListTest(TestCase): diff --git a/ThirdParty/Ert/python/tests/util/test_thread_pool.py b/ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py similarity index 93% rename from ThirdParty/Ert/python/tests/util/test_thread_pool.py rename to ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py index ffe620dcd6..a7cb895924 100644 --- a/ThirdParty/Ert/python/tests/util/test_thread_pool.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_thread_pool.py @@ -1,10 +1,10 @@ import time -from ecl.util import ThreadPool -from ecl.util.thread_pool import Task -from ecl.test import ExtendedTestCase +from ecl.util.util import ThreadPool +from ecl.util.util.thread_pool import Task +from tests import EclTest -class ThreadPoolTest(ExtendedTestCase): +class ThreadPoolTest(EclTest): def sleepTask(self, *args, **kwargs): diff --git a/ThirdParty/Ert/python/tests/util/test_vectors.py b/ThirdParty/Ert/python/tests/util_tests/test_vectors.py similarity index 93% rename from ThirdParty/Ert/python/tests/util/test_vectors.py rename to ThirdParty/Ert/python/tests/util_tests/test_vectors.py index 9b710567eb..47d306aacd 100644 --- a/ThirdParty/Ert/python/tests/util/test_vectors.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_vectors.py @@ -1,30 +1,31 @@ #!/usr/bin/env python -# Copyright (C) 2011 Statoil ASA, Norway. -# +# Copyright (C) 2011 Statoil ASA, Norway. +# # The file 'test_vectors.py' is part of ERT - Ensemble based Reservoir Tool. -# -# ERT 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. -# -# ERT 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 -# for more details. +# +# ERT 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. +# +# ERT 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 +# for more details. import copy import datetime +import six try: from unittest2 import TestCase except ImportError: from unittest import TestCase -from ecl.util import DoubleVector, IntVector, BoolVector, TimeVector, CTime, PermutationVector +from ecl.util.util import DoubleVector, IntVector, BoolVector, TimeVector, CTime, PermutationVector class UtilTest(TestCase): def setUp(self): @@ -155,11 +156,9 @@ def test_repr(self): for i in primes: b[i] = True pfx = 'BoolVector(size = 20, content = "00110101000101000101")' - print(repr(b)) self.assertEqual(pfx, repr(b)[:len(pfx)]) b[30] = True pfx = 'BoolVector(size = 31, content = "001101010...00000001")' - print(repr(b)) self.assertEqual(pfx, repr(b)[:len(pfx)]) @@ -184,7 +183,7 @@ def test_activeList(self): active_list = IntVector.active_list("1,10,100-105X") self.assertFalse(active_list) - + def test_value_list(self): list2 = IntVector.valueList("3,10-12,0,1") self.assertTrue(len(list2) == 6) @@ -261,7 +260,7 @@ def test_pop(self): a.pop() #---- - + def test_shift(self): a = IntVector() a.append(1) @@ -282,9 +281,7 @@ def test_shift(self): b = a << 2 self.assertEqual(list(b), [3, 4, 5]) - print(a) a <<= 2 - print(a) self.assertEqual(list(a), [3, 4, 5]) b = a >> 2 @@ -309,25 +306,25 @@ def test_int_vector(self): self.assertTrue(a.max(), 5) self.assertTrue(a.min(), 1) self.assertTrue(a.minIndex(), 4) - + self.assertEqual(a.maxIndex(reverse=True), 0) self.assertEqual(a.maxIndex(reverse=False), 0) - + a[4] = 5 self.assertTrue(a[4] == 5) - + a_plus_one = a + 1 self.assertEqual(list(a_plus_one), [6, 5, 4, 3, 6]) sliced = a[0:3] self.assertEqual(list(sliced), [5, 4, 3]) - + with self.assertRaises(IndexError): item = a[6] - + copy_of_a = a.copy() self.assertEqual(list(a), list(copy_of_a)) - + another_copy_of_a = copy_of_a.copy( ) self.assertEqual(list(a), list(another_copy_of_a)) @@ -368,7 +365,6 @@ def test_time_vector(self): tv2 = TimeVector() tv2.append(time2) - print(tv2) def test_permutation_vector(self): vector = DoubleVector() @@ -473,7 +469,7 @@ def test_time_vector_regular(self): start = datetime.datetime(1980, 1, 1, 0, 0, 0) end = datetime.datetime(2020, 1, 1, 0, 0, 0) trange = TimeVector.createRegular(start, end, "2Y") - for (y, t) in zip(xrange(1980, 2022, 2), trange): + for (y, t) in zip(six.moves.xrange(1980, 2022, 2), trange): self.assertTrue(t == datetime.datetime(y, 1, 1, 0, 0, 0)) trange = TimeVector.createRegular(start, datetime.date(2050, 1, 1), "1Y") @@ -543,10 +539,38 @@ def test_range(self): self.create_range_test(v, 0, 100, -3) - + def test_perm_vector(self): v = IntVector.createRange( 11 , 0 , -1 ) perm = v.permutationSort( ) self.assertEqual( perm[0] , 10 ) self.assertEqual( perm[5] , 5 ) self.assertEqual( perm[10] , 0 ) + + + def test_init_linear(self): + with self.assertRaises(ValueError): + v = IntVector.create_linear(0, 10, 1) + + v = IntVector.create_linear(0,10,11) + for i in range(len(v)): + self.assertEqual(v[i], i) + + + v = IntVector.create_linear(10,0,11) + for i in range(len(v)): + self.assertEqual(v[i], 10 - i) + + + d = DoubleVector.create_linear(0,1,11) + for i in range(len(d)): + self.assertEqual( d[i] , i*0.10) + + def test_equal(self): + v1 = IntVector() + v1[3] = 99 + + v2 = IntVector() + self.assertNotEqual( v1,v2 ) + v2[3] = 99 + self.assertEqual(v1,v2) diff --git a/ThirdParty/Ert/python/tests/util/test_version.py b/ThirdParty/Ert/python/tests/util_tests/test_version.py similarity index 96% rename from ThirdParty/Ert/python/tests/util/test_version.py rename to ThirdParty/Ert/python/tests/util_tests/test_version.py index fc8de22f6d..c0864b4a20 100644 --- a/ThirdParty/Ert/python/tests/util/test_version.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_version.py @@ -16,11 +16,11 @@ import os.path import ecl -from ecl.test import ExtendedTestCase -from ecl.util import Version,EclVersion +from tests import EclTest +from ecl.util.util import Version,EclVersion -class VersionTest(ExtendedTestCase): +class VersionTest(EclTest): def setUp(self): pass diff --git a/ThirdParty/Ert/python/tests/util/test_work_area.py b/ThirdParty/Ert/python/tests/util_tests/test_work_area.py similarity index 68% rename from ThirdParty/Ert/python/tests/util/test_work_area.py rename to ThirdParty/Ert/python/tests/util_tests/test_work_area.py index 51403f817d..0d7a69bae5 100644 --- a/ThirdParty/Ert/python/tests/util/test_work_area.py +++ b/ThirdParty/Ert/python/tests/util_tests/test_work_area.py @@ -23,10 +23,11 @@ except ImportError: from unittest import skipIf -from ecl.test import ExtendedTestCase , TestAreaContext, TempAreaContext +from ecl.util.test import TestAreaContext, TempAreaContext +from tests import EclTest -class WorkAreaTest(ExtendedTestCase): +class WorkAreaTest(EclTest): def test_full_path(self): with TestAreaContext("TestArea") as test_area: @@ -93,3 +94,32 @@ def test_sync(self): t.sync() self.assertTrue( os.path.isfile( "file.txt")) + + def test_multiple_areas(self): + original_dir = os.getcwd() + context_dirs = [] + for i in range(3): + loop_dir = os.getcwd() + self.assertEqual(loop_dir, original_dir, + 'Wrong folder before creating TestAreaContext. Loop: {} -- CWD: {} ' + .format(i, loop_dir)) + + with TestAreaContext("test_multiple_areas") as t: + t_dir = t.get_cwd() + + self.assertNotIn(t_dir, context_dirs, + 'Multiple TestAreaContext objects in the same folder. Loop {} -- CWD: {}' + .format(i, loop_dir)) + context_dirs.append(t_dir) + + # It is possible to make the following assert fail, but whoever run the tests should + # try really really hard to make that happen + self.assertNotEqual(t_dir, original_dir, + 'TestAreaContext in the current working directory. Loop: {} -- CWD: {}' + .format(i, loop_dir)) + + loop_dir = os.getcwd() + self.assertEqual(loop_dir, original_dir, + 'Wrong folder after creating TestAreaContext. Loop: {} -- CWD: {} ' + .format(i, loop_dir)) + diff --git a/ThirdParty/Ert/python/tests/well/CMakeLists.txt b/ThirdParty/Ert/python/tests/well/CMakeLists.txt deleted file mode 100644 index b9efe79dca..0000000000 --- a/ThirdParty/Ert/python/tests/well/CMakeLists.txt +++ /dev/null @@ -1,14 +0,0 @@ -set(TEST_SOURCES - __init__.py - test_ecl_well.py - test_ecl_well2.py - test_ecl_well3.py -) - -add_python_package("python.tests.well" ${PYTHON_INSTALL_PREFIX}/tests/well "${TEST_SOURCES}" False) - -if (STATOIL_TESTDATA_ROOT) - addPythonTest(tests.well.test_ecl_well.EclWellTest LABELS StatoilData) - addPythonTest(tests.well.test_ecl_well2.EclWellTest2 LABELS StatoilData) - addPythonTest(tests.well.test_ecl_well3.EclWellTest3 LABELS StatoilData) -endif() diff --git a/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt b/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt new file mode 100644 index 0000000000..00d362918c --- /dev/null +++ b/ThirdParty/Ert/python/tests/well_tests/CMakeLists.txt @@ -0,0 +1,12 @@ +set(TEST_SOURCES + __init__.py + test_ecl_well.py + test_ecl_well2.py + test_ecl_well3.py +) + +add_python_package("python.tests.well_tests" ${PYTHON_INSTALL_PREFIX}/tests/well_tests "${TEST_SOURCES}" False) + +addPythonTest(tests.well_tests.test_ecl_well.EclWellTest) +addPythonTest(tests.well_tests.test_ecl_well2.EclWellTest2) +addPythonTest(tests.well_tests.test_ecl_well3.EclWellTest3) diff --git a/ThirdParty/Ert/python/tests/well_tests/__init__.py b/ThirdParty/Ert/python/tests/well_tests/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/ThirdParty/Ert/python/tests/well/test_ecl_well.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py similarity index 97% rename from ThirdParty/Ert/python/tests/well/test_ecl_well.py rename to ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py index ed3aad2c47..1d7d2ee32f 100644 --- a/ThirdParty/Ert/python/tests/well/test_ecl_well.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well.py @@ -1,11 +1,13 @@ import datetime -from ecl.ecl import EclGrid, EclFile, EclFileFlagEnum -from ecl.test import ExtendedTestCase -from ecl.util.ctime import CTime +from ecl import EclFileFlagEnum +from ecl.eclfile import EclFile +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from ecl.util.util.ctime import CTime from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment - -class EclWellTest(ExtendedTestCase): +@statoil_test() +class EclWellTest(EclTest): ALL_WELLS = ['E5H', 'G1H', 'M41', 'J41', 'D10H', 'P41', 'L41', 'M42', 'S41', 'S13H', 'Q12HT2', 'O41', 'L11H', 'Q21H', 'E6CH', 'D4Y1H', 'D4Y2H', 'I13Y1H', 'Q21AY1H', 'F5AH', 'O14Y4HT2', 'K24Y1H', 'K24Y3H', 'S21H', 'N11H', 'L23Y1H', 'D7AY1H', 'S21AHT2', 'H2AH', 'S21AHT3', 'L23Y6H', 'N11AH', 'N11BY1H', 'X23Y2H', 'N22Y3HT3', @@ -444,3 +446,10 @@ def test_well_connections_msw_do_not_load_segments(self): self.assertFalse(connection.isFractureConnection()) self.assertTrue(connection.isMatrixConnection()) self.assertEqual(connection.direction(), WellConnectionDirectionEnum.well_conn_dirY) + + + def test_load_broken_direction(self): + grid_path = self.createTestPath("Statoil/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.EGRID") + rst_path = self.createTestPath("Statoil/ECLIPSE/icon-invalid-value/R6_HM2016B_FFP_BASE.UNRST") + grid = EclGrid(grid_path) + well_info = WellInfo(grid, rst_path) diff --git a/ThirdParty/Ert/python/tests/well/test_ecl_well2.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py similarity index 81% rename from ThirdParty/Ert/python/tests/well/test_ecl_well2.py rename to ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py index 52797e2bfa..554e18bda2 100644 --- a/ThirdParty/Ert/python/tests/well/test_ecl_well2.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well2.py @@ -1,26 +1,28 @@ import datetime import os.path -from ecl.ecl import EclGrid, EclFile, EclFileFlagEnum -from ecl.test import ExtendedTestCase -from ecl.util.ctime import CTime +from ecl import EclFileFlagEnum +from ecl.eclfile import EclFile +from ecl.grid import EclGrid +from tests import EclTest, statoil_test +from ecl.util.util.ctime import CTime from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment - -class EclWellTest2(ExtendedTestCase): +@statoil_test() +class EclWellTest2(EclTest): grid = None def getGrid(self): if EclWellTest2.grid is None: EclWellTest2.grid = EclGrid( self.createTestPath("Statoil/ECLIPSE/Troll/Ref2014/T07-4A-W2014-06.EGRID")) - + return EclWellTest2.grid - + def checkWell(self , rst_file): - segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529, + segment_length = [2660 , 20 , 121 , 1347.916 , 20.585 , 56.249 , 115.503 , 106.978 , 47.124 , 279.529, 128.534 , 165.33 , 59.97 , 936.719 ] well_info = WellInfo( self.getGrid() , self.createTestPath( os.path.join("Statoil/ECLIPSE/Troll/Ref2014" , rst_file ))) @@ -28,16 +30,16 @@ def checkWell(self , rst_file): for well_state in well_time_line: self.assertTrue( well_state.isMultiSegmentWell() ) self.assertTrue( well_state.hasSegmentData() ) - + for index,length in enumerate(segment_length): segment = well_state.igetSegment(index) self.assertFloatEqual( segment.length() , length ) - + def testWell(self): self.checkWell("T07-4A-W2014-06.X0695") self.checkWell("T07-4A-W2014-06.X0709") self.checkWell("T07-4A-W2014-06.UNRST") - + diff --git a/ThirdParty/Ert/python/tests/well/test_ecl_well3.py b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py similarity index 92% rename from ThirdParty/Ert/python/tests/well/test_ecl_well3.py rename to ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py index 66283d261e..9252f111d6 100644 --- a/ThirdParty/Ert/python/tests/well/test_ecl_well3.py +++ b/ThirdParty/Ert/python/tests/well_tests/test_ecl_well3.py @@ -1,13 +1,15 @@ import datetime import os.path -from ecl.ecl import EclGrid, EclFile, EclSum -from ecl.test import ExtendedTestCase -from ecl.util.ctime import CTime +from ecl.eclfile import EclFile +from ecl.grid import EclGrid +from ecl.summary import EclSum +from tests import EclTest, statoil_test +from ecl.util.util.ctime import CTime from ecl.well import WellInfo, WellConnection, WellTypeEnum, WellConnectionDirectionEnum, WellSegment - -class EclWellTest3(ExtendedTestCase): +@statoil_test() +class EclWellTest3(EclTest): grid = None def test_rates(self): diff --git a/ThirdParty/Ert/redhat/ecl.spec b/ThirdParty/Ert/redhat/ecl.spec new file mode 100644 index 0000000000..47b7a85513 --- /dev/null +++ b/ThirdParty/Ert/redhat/ecl.spec @@ -0,0 +1,101 @@ +# +# spec file for package ecl +# + +%define tag rc1 + +Name: ecl +Version: 2017.10 +Release: 0 +Summary: ECL library +License: GPL-3+ +Group: Development/Libraries/C and C++ +Url: http://ert.nr.no +Source0: https://github.com/Statoil/libecl/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz +BuildRequires: lapack-devel zlib-devel iputils +BuildRequires: devtoolset-6-toolchain +%{?!el6:BuildRequires: python-devel numpy} +%{?el6:BuildRequires: cmake3} +%{?!el6:BuildRequires: cmake} +BuildRoot: %{_tmppath}/%{name}-%{version}-build +Requires: libecl1 = %{version} + +%description +libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. + +%package -n libecl1 +Summary: ECL library +Group: System/Libraries + +%{?!el6: +%package -n python-ecl +Summary: ECL - Python bindings +Group: Python/Libraries +Requires: libecl1 + +%description -n python-ecl +libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. This package contains the Python bindings. + +%package -n python-cwrap +Summary: Simplify ctypes based wrapping of C code. +Group: Python/Libraries + +%description -n python-cwrap +Package to simplify ctypes based wrapping of C code. +} + +%description -n libecl1 +libecl is a package for reading and writing the result files from the Eclipse reservoir simulator. + +%package devel +Summary: Development and header files for libecl +Group: Development/Libraries/C and C++ +Requires: %{name} = %{version} +Requires: lapack-devel +Requires: libecl1 = %{version} + +%description devel +This package contains the development and header files for ecl + +%prep +%setup -q -n libecl-release-%{version}-%{tag} + +%build +scl enable devtoolset-6 bash +DESTDIR=${RPM_BUILD_ROOT} %{?el6:cmake3} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 %{?el6:-DENABLE_PYTHON=0} %{?!el6:-DENABLE_PYTHON=1}-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-6/root/usr/bin/gfortran +make + +%install +make install DESTDIR=${RPM_BUILD_ROOT} + +%clean +rm -rf %{buildroot} + +%post -n libecl1 -p /sbin/ldconfig + +%postun -n libecl1 -p /sbin/ldconfig + +%files +%doc README.md + +%files -n libecl1 +%defattr(-,root,root,-) +%{_libdir}/*.so.* +%{_bindir}/* + +%files devel +%defattr(-,root,root,-) +%{_libdir}/*.so +%{_includedir}/* +%{_datadir}/cmake/* +%{_datadir}/man/* + +%{?!el6: +%files -n python-ecl +%defattr(-,root,root,-) +/usr/lib/python2.7/site-packages/ecl/* + +%files -n python-cwrap +%defattr(-,root,root,-) +/usr/lib/python2.7/site-packages/cwrap/* +} diff --git a/ThirdParty/Ert/redhat/ert.ecl.spec b/ThirdParty/Ert/redhat/ert.ecl.spec deleted file mode 100644 index 9aabf2ff86..0000000000 --- a/ThirdParty/Ert/redhat/ert.ecl.spec +++ /dev/null @@ -1,108 +0,0 @@ -# -# spec file for package ert.ecl -# - -%define tag final2 - -Name: ert.ecl -Version: 2015.10 -Release: 0 -Summary: ERT - Ensemble based Reservoir Tool - ECL library -License: GPL-3+ -Group: Development/Libraries/C and C++ -Url: http://ert.nr.no -Source0: https://github.com/OPM/%{name}/archive/release/%{version}/%{tag}.tar.gz#/%{name}-%{version}.tar.gz -BuildRequires: lapack-devel zlib-devel iputils -BuildRequires: gcc -%{?!el6:BuildRequires: python-devel numpy} -%{?el6:BuildRequires: cmake28 devtoolset-3-toolchain} -%{?!el6:BuildRequires: cmake} -BuildRoot: %{_tmppath}/%{name}-%{version}-build -Requires: libert.ecl1 = %{version} - -%description -ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble -of reservoir models. The initial motivation for creating ERT was a as -tool to do assisted history matching with Ensemble Kalman Filter -(EnKF). - -%package -n libert.ecl1 -Summary: ERT - Ensemble based Reservoir Tool - ECL library -Group: System/Libraries - -%{?!el6: -%package -n python-ert.ecl -Summary: ERT - Ensemble based Reservoir Tool - Python bindings -Group: Python/Libraries -Requires: libert.ecl1 python-cwrap - -%description -n python-ert.ecl -ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble -of reservoir models. The initial motivation for creating ERT was a as -tool to do assisted history matching with Ensemble Kalman Filter -(EnKF). This package contains the Python bindings. - -%package -n python-cwrap -Summary: Simplify ctypes based wrapping of C code. -Group: Python/Libraries - -%description -n python-cwrap -Package to simplify ctypes based wrapping of C code. -} - -%description -n libert.ecl1 -ERT - Ensemble based Reservoir Tool is a tool for managing en ensemble -of reservoir models. The initial motivation for creating ERT was a as -tool to do assisted history matching with Ensemble Kalman Filter -(EnKF). - -%package devel -Summary: Development and header files for libert.ecl -Group: Development/Libraries/C and C++ -Requires: %{name} = %{version} -Requires: lapack-devel -Requires: libert.ecl1 = %{version} - -%description devel -This package contains the development and header files for ert.ecl - -%prep -%setup -q -n ert-release-%{version}-%{tag} - -%build -%{?el6:scl enable devtoolset-3 bash} -DESTDIR=${RPM_BUILD_ROOT} %{?el6:cmake28} %{?!el6:cmake} -DBUILD_SHARED_LIBS=1 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%{_prefix} -DBUILD_ECL_SUMMARY=1 %{?el6:-DBUILD_PYTHON=0} %{?el6:-DCMAKE_CXX_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/g++ -DCMAKE_C_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gcc -DCMAKE_Fortran_COMPILER=/opt/rh/devtoolset-3/root/usr/bin/gfortran} -make - -%install -make install DESTDIR=${RPM_BUILD_ROOT} - -%clean -rm -rf %{buildroot} - -%post -n libert.ecl1 -p /sbin/ldconfig - -%postun -n libert.ecl1 -p /sbin/ldconfig - -%files -%doc README - -%files -n libert.ecl1 -%defattr(-,root,root,-) -%{_libdir}/*.so.* -%{_bindir}/* - -%files devel -%defattr(-,root,root,-) -%{_libdir}/*.so -%{_includedir}/* - -%{?!el6: -%files -n python-ert.ecl -%defattr(-,root,root,-) -/usr/lib/python2.7/site-packages/ert/* - -%files -n python-cwrap -%defattr(-,root,root,-) -/usr/lib/python2.7/site-packages/cwrap/* -} diff --git a/ThirdParty/Ert/requirements.txt b/ThirdParty/Ert/requirements.txt new file mode 100644 index 0000000000..4d44c49dca --- /dev/null +++ b/ThirdParty/Ert/requirements.txt @@ -0,0 +1,3 @@ +cwrap +numpy +pandas diff --git a/ThirdParty/Ert/test-data/local/nexus/SPE1.plt b/ThirdParty/Ert/test-data/local/nexus/SPE1.plt index cf144f845b..e8226ce9b0 100644 Binary files a/ThirdParty/Ert/test-data/local/nexus/SPE1.plt and b/ThirdParty/Ert/test-data/local/nexus/SPE1.plt differ diff --git a/ThirdParty/Ert/test-data/local/nexus/SPE1_delayedWell.plt b/ThirdParty/Ert/test-data/local/nexus/SPE1_delayedWell.plt new file mode 100644 index 0000000000..addb3c981c Binary files /dev/null and b/ThirdParty/Ert/test-data/local/nexus/SPE1_delayedWell.plt differ diff --git a/ThirdParty/NRLib/CMakeLists.txt b/ThirdParty/NRLib/CMakeLists.txt index 215aba8f7c..0b865c0cf2 100644 --- a/ThirdParty/NRLib/CMakeLists.txt +++ b/ThirdParty/NRLib/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (NRLib) @@ -6,8 +6,6 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/nrlib ${CMAKE_CURRENT_SOURCE_DIR}/nrlib/well - - ${boost-Subset_SOURCE_DIR} ) file ( GLOB NRLIB_IOTOOLS_SRC @@ -32,3 +30,11 @@ endif() add_subdirectory(well_UnitTests) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/nrlib/well +) + +target_link_libraries ( ${PROJECT_NAME} + boost-Subset +) diff --git a/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt b/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt index f8ff33b636..7938ccdb9a 100644 --- a/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt +++ b/ThirdParty/NRLib/well_UnitTests/CMakeLists.txt @@ -4,11 +4,7 @@ project ( well_UnitTests ) include_directories ( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/.. ${CMAKE_CURRENT_SOURCE_DIR}/../.. - - ${NR_well_SOURCE_DIR} ) set( PROJECT_FILES @@ -28,6 +24,5 @@ source_group("" FILES ${PROJECT_FILES}) target_link_libraries ( ${PROJECT_NAME} NRLib - boost-Subset ) diff --git a/ThirdParty/Qwt/src/CMakeLists.txt b/ThirdParty/Qwt/src/CMakeLists.txt index 8844512282..46b51e9d7c 100644 --- a/ThirdParty/Qwt/src/CMakeLists.txt +++ b/ThirdParty/Qwt/src/CMakeLists.txt @@ -280,3 +280,8 @@ qt4_wrap_cpp(MOC_SOURCE_FILES ${MOC_HEADER_FILES} ) add_library(${PROJECT_NAME} ${HEADER_FILES} ${SOURCE_FILES} ${MOC_SOURCE_FILES}) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + diff --git a/ThirdParty/boost-Subset/CMakeLists.txt b/ThirdParty/boost-Subset/CMakeLists.txt index 2fe351529e..5a94a45d8c 100644 --- a/ThirdParty/boost-Subset/CMakeLists.txt +++ b/ThirdParty/boost-Subset/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) # Procedure used to extract subset from complete Boost installation # @@ -36,3 +36,8 @@ add_library( ${PROJECT_NAME} if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4244") endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) diff --git a/ThirdParty/clipper/CMakeLists.txt b/ThirdParty/clipper/CMakeLists.txt index 0a17507090..300964eeb3 100644 --- a/ThirdParty/clipper/CMakeLists.txt +++ b/ThirdParty/clipper/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (clipper) @@ -11,3 +11,9 @@ add_library(${PROJECT_NAME} ${project_source_files} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt index e0f850276e..c37bd33e02 100644 --- a/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (custom-opm-flowdiag-app) @@ -6,7 +6,6 @@ include_directories( ../custom-opm-flowdiagnostics/opm-flowdiagnostics opm-flowdiagnostics-applications opmCore - ${boost-Subset_SOURCE_DIR} ) include (opm-flowdiagnostics-applications/CMakeLists_files.cmake) @@ -26,8 +25,16 @@ add_library(custom-opm-flowdiag-app ${project_source_files_complete_path1} ) -target_link_libraries(custom-opm-flowdiag-app ecl) +target_link_libraries(custom-opm-flowdiag-app + ecl + boost-Subset +) if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4190 /wd4267") endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/opm-flowdiagnostics-applications +) diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt index 565b1aafce..3d166e14e7 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/CMakeLists.txt @@ -56,9 +56,9 @@ include(OpmInit) macro (dir_hook) endmacro (dir_hook) -# Look for the opm-data repository; if found the variable -# HAVE_OPM_DATA will be set to true. -include (Findopm-data) +# Look for the "opm-tests" repository (OPM's Regression Test data +# repository)--HAVE_OPM_TESTS true if found. +include (Findopm-tests) # list of prerequisites for this particular project; this is in a # separate file (in cmake/Modules sub-directory) because it is shared @@ -93,6 +93,7 @@ endmacro (install_hook) # all setup common to the OPM library modules is done here include (OpmLibMain) -if (HAVE_OPM_DATA) +if (HAVE_OPM_TESTS) + # Regression test data available. Enable additional tests. include (${CMAKE_CURRENT_SOURCE_DIR}/AcceptanceTests.cmake) endif() diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module index b55f213284..1d257c47cc 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/dune.module @@ -5,9 +5,9 @@ Module: opm-flowdiagnostics-applications Description: flow diagnostics applications and examples -Version: 2018.04-pre -Label: 2018.04-pre +Version: 2018.10-pre +Label: 2018.10-pre Maintainer: bard.skaflestad@sintef.no MaintainerName: BÃ¥rd Skaflestad Url: http://opm-project.org -Depends: opm-common opm-flowdiagnostics opm-core +Depends: opm-common opm-flowdiagnostics diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp index bd4fe47f1a..8c8b67f53e 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/exampleSetup.hpp @@ -23,7 +23,7 @@ -#include +#include #include #include diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp index 060fba34f7..4a177f5e95 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractFromRestart.cpp @@ -22,7 +22,7 @@ #include #endif -#include +#include #include #include diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp index 8ca6f823d4..cbfbfed881 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/examples/extractPropCurves.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include @@ -98,9 +99,9 @@ namespace { // ----------------------------------------------------------------- // Relative permeability - void krg(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krg(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -115,14 +116,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krg", graph); } - void krog(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krog(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -137,14 +138,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krog", graph); } - void krow(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krow(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -159,14 +160,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krow", graph); } - void krw(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void krw(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -181,7 +182,7 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "krw", graph); } @@ -189,9 +190,9 @@ namespace { // ----------------------------------------------------------------- // Capillary pressure - void pcgo(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void pcgo(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -206,14 +207,14 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "pcgo", graph); } - void pcow(const Opm::ECLSaturationFunc& sfunc, - const int activeCell, - const bool useEPS) + void pcow(const Opm::ECLSaturationFunc& sfunc, + const int activeCell, + const Opm::ECLSaturationFunc::SatFuncScaling& scaling) { using RC = Opm::ECLSaturationFunc::RawCurve; @@ -228,7 +229,7 @@ namespace { }); const auto graph = - sfunc.getSatFuncCurve(func, activeCell, useEPS); + sfunc.getSatFuncCurve(func, activeCell, scaling); printGraph(std::cout, "pcow", graph); } @@ -407,13 +408,41 @@ namespace { return acell; } + + Opm::ECLSaturationFunc::SatFuncScaling + saturationFuncScaling(const Opm::ParameterGroup& prm) + { + using T = Opm::ECLSaturationFunc::SatFuncScaling::Type; + + const auto opt = + std::regex_constants::icase | + std::regex_constants::ECMAScript; + + const auto horiz = std::regex { "horizontal", opt }; + const auto vert = std::regex { "vertical" , opt }; + const auto useEPS = + prm.getDefault("useEPS", std::string{"off"}); + + auto scaling = Opm::ECLSaturationFunc::SatFuncScaling{}; + scaling.enable = static_cast(0); + scaling.invalid = handleInvalid(prm); + + if (std::regex_search(useEPS, horiz)) { + scaling.enable |= T::Horizontal; + } + + if (std::regex_search(useEPS, vert)) { + scaling.enable |= T::Vertical; + } + + return scaling; + } } // namespace Anonymous int main(int argc, char* argv[]) try { - const auto prm = example::initParam(argc, argv); - const auto useEPS = prm.getDefault("useEPS", false); - const auto h_inv = handleInvalid(prm); + const auto prm = example::initParam(argc, argv); + const auto scaling = saturationFuncScaling(prm); const auto rset = example::identifyResultSet(prm); const auto init = Opm::ECLInitFileData(rset.initFile()); @@ -421,7 +450,7 @@ try { const auto cellID = getActiveCell(graph, prm); - auto sfunc = Opm::ECLSaturationFunc(graph, init, useEPS, h_inv); + auto sfunc = Opm::ECLSaturationFunc(graph, init); auto pvtCC = Opm::ECLPVT::ECLPvtCurveCollection(graph, init); if (prm.has("unit")) { @@ -434,15 +463,15 @@ try { // ----------------------------------------------------------------- // Relative permeability - if (prm.getDefault("krg" , false)) { krg (sfunc, cellID, useEPS); } - if (prm.getDefault("krog", false)) { krog(sfunc, cellID, useEPS); } - if (prm.getDefault("krow", false)) { krow(sfunc, cellID, useEPS); } - if (prm.getDefault("krw" , false)) { krw (sfunc, cellID, useEPS); } + if (prm.getDefault("krg" , false)) { krg (sfunc, cellID, scaling); } + if (prm.getDefault("krog", false)) { krog(sfunc, cellID, scaling); } + if (prm.getDefault("krow", false)) { krow(sfunc, cellID, scaling); } + if (prm.getDefault("krw" , false)) { krw (sfunc, cellID, scaling); } // ----------------------------------------------------------------- // Capillary pressure - if (prm.getDefault("pcgo", false)) { pcgo(sfunc, cellID, useEPS); } - if (prm.getDefault("pcow", false)) { pcow(sfunc, cellID, useEPS); } + if (prm.getDefault("pcgo", false)) { pcgo(sfunc, cellID, scaling); } + if (prm.getDefault("pcow", false)) { pcow(sfunc, cellID, scaling); } // ----------------------------------------------------------------- // PVT Curves diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake index 5461c566c8..180114cb46 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm-flowdiagnostics-applications-prereqs.cmake @@ -17,10 +17,8 @@ set (opm-flowdiagnostics-applications_DEPS # Prerequisite OPM modules # common -> Parameter System # fdiag -> Solver - # parser -> Unit Conversions "opm-common REQUIRED" "opm-flowdiagnostics REQUIRED" - "opm-parser REQUIRED" ) find_package_deps(opm-flowdiagnostics-applications) diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp index 0c9a99bc65..5bd31f9949 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.cpp @@ -27,6 +27,10 @@ #include #include +#include +#include + +#include #include #include #include @@ -37,6 +41,8 @@ #include #include +#include + namespace { std::vector unscaledTwoPt(const std::vector& min, @@ -81,6 +87,39 @@ namespace { return tep; } + template + std::vector + gridDefaultedVector(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::string& vector, + const std::vector& dflt, + CvrtVal&& cvrt) + { + auto ret = std::vector(G.numCells()); + + assert (! dflt.empty() && "Internal Error"); + + auto cellID = std::vector::size_type{0}; + for (const auto& gridID : G.activeGrids()) { + const auto nc = G.numCells(gridID); + + const auto& snum = init.haveKeywordData("SATNUM", gridID) + ? G.rawLinearisedCellData(init, "SATNUM", gridID) + : std::vector(nc, 1); + + const auto& val = init.haveKeywordData(vector, gridID) + ? G.rawLinearisedCellData(init, vector, gridID) + : std::vector(nc, -1.0e21); + + for (auto c = 0*nc; c < nc; ++c, ++cellID) { + ret[cellID] = (std::abs(val[c]) < 1.0e20) + ? cvrt(val[c]) : dflt[snum[c] - 1]; + } + } + + return ret; + } + double defaultedScaledSaturation(const double s, const double dflt) { // Use input scaled saturation ('s') if not defaulted (|s| < 1e20), @@ -114,12 +153,11 @@ namespace { class Opm::SatFunc::TwoPointScaling::Impl { public: - Impl(std::vector smin, - std::vector smax, - InvalidEndpointBehaviour handle_invalid) + Impl(std::vector smin, + std::vector smax) : smin_ (std::move(smin)) , smax_ (std::move(smax)) - , handle_invalid_(handle_invalid) + , handle_invalid_(InvalidEndpointBehaviour::UseUnscaled) { if (this->smin_.size() != this->smax_.size()) { throw std::invalid_argument { @@ -278,6 +316,122 @@ handleInvalidEndpoint(const SaturationAssoc& sp, } } +// --------------------------------------------------------------------- +// Class Opm::SatFunc::PureVerticalScaling::Impl +// --------------------------------------------------------------------- + +class Opm::SatFunc::PureVerticalScaling::Impl +{ +public: + explicit Impl(std::vector fmax) + : fmax_(std::move(fmax)) + {} + + std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const; + +private: + std::vector fmax_; +}; + +std::vector +Opm::SatFunc::PureVerticalScaling::Impl:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const +{ + assert (sp.size() == val.size() && "Internal Error in Vertical Scaling"); + + auto ret = std::move(val); + + const auto maxVal = f.max.val; + + for (auto n = sp.size(), i = 0*n; i < n; ++i) { + ret[i] *= this->fmax_[ sp[i].cell ] / maxVal; + } + + return ret; +} + +// --------------------------------------------------------------------- +// Class Opm::SatFunc::CritSatVerticalScaling::Impl +// --------------------------------------------------------------------- + +class Opm::SatFunc::CritSatVerticalScaling::Impl +{ +public: + explicit Impl(std::vector sdisp, + std::vector fdisp, + std::vector fmax) + : sdisp_(std::move(sdisp)) + , fdisp_(std::move(fdisp)) + , fmax_ (std::move(fmax)) + {} + + std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const; + +private: + std::vector sdisp_; + std::vector fdisp_; + std::vector fmax_; +}; + +std::vector +Opm::SatFunc::CritSatVerticalScaling::Impl:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + std::vector val) const +{ + assert ((sp.size() == val.size()) && "Internal Error in Vertical Scaling"); + assert (! (f.max.val < f.disp.val) && "Internal Error in Table Extraction"); + assert (! (f.max.sat < f.disp.sat) && "Internal Error in Table Extraction"); + + auto ret = std::move(val); + + const auto fdisp = f.disp.val; const auto sdisp = f.disp.sat; + const auto fmax = f.max .val; const auto smax = f.max .sat; + const auto sepfv = fmax > fdisp; const auto sep_s = sdisp > smax; + + for (auto n = sp.size(), i = 0*n; i < n; ++i) { + auto& y = ret[i]; + + const auto c = sp[i].cell; + const auto s = sp[i].sat; + const auto sr = this->sdisp_[c]; + const auto fr = this->fdisp_[c]; + const auto fm = this->fmax_ [c]; + + if (! (s > sr)) { + // s <= sr: Pure vertical scaling in left interval. + y *= fr / fdisp; + } + else if (sepfv) { + // Normal case: Kr(Smax) > Kr(Sr) + const auto t = (y - fdisp) / (fmax - fdisp); + + y = fr + t*(fm - fr); + } + else if (sep_s) { + // Special case: Kr(Smax) == Kr(Sr). Use linear function from + // saturations. + const auto t = (s - sdisp) / (smax - sdisp); + + y = fr + t*(fm - fr); + } + else { + // Smax == Sr; Almost arbitrarily pick fmax_[c]. + y = fm; + } + } + + return ret; +} + // --------------------------------------------------------------------- // Class Opm::ThreePointScaling::Impl // --------------------------------------------------------------------- @@ -285,14 +439,13 @@ handleInvalidEndpoint(const SaturationAssoc& sp, class Opm::SatFunc::ThreePointScaling::Impl { public: - Impl(std::vector smin , - std::vector sdisp, - std::vector smax , - InvalidEndpointBehaviour handle_invalid) + Impl(std::vector smin , + std::vector sdisp, + std::vector smax ) : smin_ (std::move(smin )) , sdisp_ (std::move(sdisp)) , smax_ (std::move(smax )) - , handle_invalid_(handle_invalid) + , handle_invalid_(InvalidEndpointBehaviour::UseUnscaled) { if ((this->sdisp_.size() != this->smin_.size()) || (this->sdisp_.size() != this->smax_.size())) @@ -480,6 +633,42 @@ handleInvalidEndpoint(const SaturationAssoc& sp, // EPS factory functions for two-point and three-point scaling options // --------------------------------------------------------------------- +namespace { + bool haveScaledRelPermAtCritSatKeyword(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::string& kw) + { + auto haveKW = false; + + for (const auto& grid : G.activeGrids()) { + haveKW = haveKW || init.haveKeywordData(kw, grid); + } + + return haveKW; + } + + bool haveScaledRelPermAtCritSat(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const ::Opm::ECLPhaseIndex phase, + const ::Opm::SatFunc::CreateEPS::SubSystem subSys) + { + switch (phase) { + case ::Opm::ECLPhaseIndex::Aqua: + return haveScaledRelPermAtCritSatKeyword(G, init, "KRWR"); + + case ::Opm::ECLPhaseIndex::Liquid: + return (subSys == ::Opm::SatFunc::CreateEPS::SubSystem::OilGas) + ? haveScaledRelPermAtCritSatKeyword(G, init, "KROGR") + : haveScaledRelPermAtCritSatKeyword(G, init, "KROWR"); + + case ::Opm::ECLPhaseIndex::Vapour: + return haveScaledRelPermAtCritSatKeyword(G, init, "KRGR"); + } + + return false; + } +} // namespace Anonymous + namespace Create { using EPSOpt = ::Opm::SatFunc::CreateEPS::EPSOptions; using RTEP = ::Opm::SatFunc::CreateEPS::RawTableEndPoints; @@ -493,35 +682,29 @@ namespace Create { struct Kr { static EPSPtr G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); }; struct Pc { static EPSPtr GO(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); }; static EPSPtr @@ -540,23 +723,19 @@ namespace Create { struct Kr { static EPSPtr G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); static EPSPtr W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid); + const ::Opm::ECLInitFileData& init); }; static EPSPtr @@ -567,14 +746,95 @@ namespace Create { static std::vector unscaledEndPoints(const RTEP& ep, const EPSOpt& opt); } // namespace ThreePoint + + namespace PureVertical { + using Scaling = ::Opm::SatFunc::PureVerticalScaling; + using EPSOpt = ::Opm::SatFunc::CreateEPS::EPSOptions; + using FValVec = ::Opm::SatFunc::CreateEPS::Vertical::FuncValVector; + using ScalPtr = std::unique_ptr; + + struct Kr { + static ScalPtr + G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + + static ScalPtr + O(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + + static ScalPtr + W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + }; + + struct Pc { + static ScalPtr + GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + + static ScalPtr + OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt); + }; + + static ScalPtr + scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const FValVec& fvals); + } // namespace PureVertical + + namespace CritSatVertical { + using Scaling = ::Opm::SatFunc::CritSatVerticalScaling; + using EPSOpt = ::Opm::SatFunc::CreateEPS::EPSOptions; + using FValVec = ::Opm::SatFunc::CreateEPS::Vertical::FuncValVector; + using ScalPtr = std::unique_ptr; + + struct Kr { + static ScalPtr + G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + + static ScalPtr + GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + + static ScalPtr + OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + + static ScalPtr + W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval); + }; + + static ScalPtr + scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const RTEP& tep, + const FValVec& fvals); + } // namespace CritSatVertical } // namespace Create // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // Implementation of Create::TwoPoint::scalingFunction() Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sgcr = G.rawLinearisedCellData(init, "SGCR"); auto sgu = G.rawLinearisedCellData(init, "SGU"); @@ -589,16 +849,13 @@ Create::TwoPoint::Kr::G(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sgcr), std::move(sgu), handle_invalid - } + new EPS { std::move(sgcr), std::move(sgu) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sogcr = G.rawLinearisedCellData(init, "SOGCR"); @@ -645,16 +902,13 @@ Create::TwoPoint::Kr::OG(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sogcr), std::move(smax), handle_invalid - } + new EPS { std::move(sogcr), std::move(smax) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sowcr = G.rawLinearisedCellData(init, "SOWCR"); @@ -701,16 +955,13 @@ Create::TwoPoint::Kr::OW(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sowcr), std::move(smax), handle_invalid - } + new EPS { std::move(sowcr), std::move(smax) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Kr::W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto swcr = G.rawLinearisedCellData(init, "SWCR"); auto swu = G.rawLinearisedCellData(init, "SWU"); @@ -722,16 +973,13 @@ Create::TwoPoint::Kr::W(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(swcr), std::move(swu), handle_invalid - } + new EPS { std::move(swcr), std::move(swu) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Pc::GO(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { // Try dedicated scaled Sg_conn for Pc first auto sgl = G.rawLinearisedCellData(init, "SGLPC"); @@ -752,16 +1000,13 @@ Create::TwoPoint::Pc::GO(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(sgl), std::move(sgu), handle_invalid - } + new EPS { std::move(sgl), std::move(sgu) } }; } Create::TwoPoint::EPSPtr Create::TwoPoint::Pc::OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { // Try dedicated scaled Sw_conn for Pc first auto swl = G.rawLinearisedCellData(init, "SWLPC"); @@ -782,9 +1027,7 @@ Create::TwoPoint::Pc::OW(const ::Opm::ECLGraph& G, } return EPSPtr { - new EPS { - std::move(swl), std::move(swu), handle_invalid - } + new EPS { std::move(swl), std::move(swu) } }; } @@ -811,10 +1054,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Aqua) { - return Create::TwoPoint::Kr::W(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::W(G, init); } - return Create::TwoPoint::Kr::OW(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::OW(G, init); } if (opt.subSys == SSys::OilGas) { @@ -826,10 +1069,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Vapour) { - return Create::TwoPoint::Kr::G(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::G(G, init); } - return Create::TwoPoint::Kr::OG(G, init, opt.handle_invalid); + return Create::TwoPoint::Kr::OG(G, init); } } @@ -842,11 +1085,11 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Vapour) { - return Create::TwoPoint::Pc::GO(G, init, opt.handle_invalid); + return Create::TwoPoint::Pc::GO(G, init); } if (opt.thisPh == PhIdx::Aqua) { - return Create::TwoPoint::Pc::OW(G, init, opt.handle_invalid); + return Create::TwoPoint::Pc::OW(G, init); } } @@ -931,8 +1174,7 @@ Create::TwoPoint::unscaledEndPoints(const RTEP& ep, const EPSOpt& opt) Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::G(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sgcr = G.rawLinearisedCellData(init, "SGCR"); auto sgu = G.rawLinearisedCellData(init, "SGU"); @@ -984,15 +1226,14 @@ Create::ThreePoint::Kr::G(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(sgcr), std::move(sr), std::move(sgu), handle_invalid + std::move(sgcr), std::move(sr), std::move(sgu) } }; } Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::OG(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sogcr = G.rawLinearisedCellData(init, "SOGCR"); @@ -1060,15 +1301,14 @@ Create::ThreePoint::Kr::OG(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(sogcr), std::move(sdisp), std::move(smax), handle_invalid + std::move(sogcr), std::move(sdisp), std::move(smax) } }; } Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::OW(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto sowcr = G.rawLinearisedCellData(init, "SOWCR"); @@ -1136,15 +1376,14 @@ Create::ThreePoint::Kr::OW(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(sowcr), std::move(sdisp), std::move(smax), handle_invalid + std::move(sowcr), std::move(sdisp), std::move(smax) } }; } Create::ThreePoint::EPSPtr Create::ThreePoint::Kr::W(const ::Opm::ECLGraph& G, - const ::Opm::ECLInitFileData& init, - const InvBeh handle_invalid) + const ::Opm::ECLInitFileData& init) { auto swcr = G.rawLinearisedCellData(init, "SWCR"); auto swu = G.rawLinearisedCellData(init, "SWU"); @@ -1195,7 +1434,7 @@ Create::ThreePoint::Kr::W(const ::Opm::ECLGraph& G, return EPSPtr { new EPS { - std::move(swcr), std::move(sdisp), std::move(swu), handle_invalid + std::move(swcr), std::move(sdisp), std::move(swu) } }; } @@ -1225,10 +1464,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Aqua) { - return Create::ThreePoint::Kr::W(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::W(G, init); } - return Create::ThreePoint::Kr::OW(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::OW(G, init); } if (opt.subSys == SSys::OilGas) { @@ -1240,10 +1479,10 @@ scalingFunction(const ::Opm::ECLGraph& G, } if (opt.thisPh == PhIdx::Vapour) { - return Create::ThreePoint::Kr::G(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::G(G, init); } - return Create::ThreePoint::Kr::OG(G, init, opt.handle_invalid); + return Create::ThreePoint::Kr::OG(G, init); } // Invalid. @@ -1327,6 +1566,458 @@ Create::ThreePoint::unscaledEndPoints(const RTEP& ep, const EPSOpt& opt) return {}; } +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Implementation of Create::PureVertical::scalingFunction() + +namespace { + Create::PureVertical::ScalPtr + pureVerticalRelpermScaling(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt, + const std::string& vector) + { + auto scaledMaxKr = + gridDefaultedVector(G, init, vector, dflt, + [](const double kr) { return kr; }); + + return Create::PureVertical::ScalPtr { + new ::Opm::SatFunc::PureVerticalScaling(std::move(scaledMaxKr)) + }; + } + + Create::PureVertical::ScalPtr + pureVerticalCapPressScaling(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt, + const std::string& vector) + { + const auto& ih = init.keywordData(INTEHEAD_KW); + + const auto pscale = ::Opm::ECLUnits:: + createUnitSystem(ih[ INTEHEAD_UNIT_INDEX ])->pressure(); + + auto scaledMaxPc = + gridDefaultedVector(G, init, vector, dflt, + [pscale](const double pc) + { + return ::ImportedOpm::unit::convert::from(pc, pscale); + }); + + return Create::PureVertical::ScalPtr { + new ::Opm::SatFunc::PureVerticalScaling(std::move(scaledMaxPc)) + }; + } + +} // Anonymous + +Create::PureVertical::ScalPtr +Create::PureVertical::Kr::G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalRelpermScaling(G, init, dflt, "KRG"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Kr::O(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalRelpermScaling(G, init, dflt, "KRO"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Kr::W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalRelpermScaling(G, init, dflt, "KRW"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Pc::GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalCapPressScaling(G, init, dflt, "PCG"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical::Pc::OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const std::vector& dflt) +{ + return pureVerticalCapPressScaling(G, init, dflt, "PCW"); +} + +Create::PureVertical::ScalPtr +Create::PureVertical:: +scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const FValVec& fvals) +{ + using FCat = ::Opm::SatFunc::CreateEPS::FunctionCategory; + using SSys = ::Opm::SatFunc::CreateEPS::SubSystem; + using PhIdx = ::Opm::ECLPhaseIndex; + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + auto dfltVals = std::vector(fvals.size(), 0.0); + std::transform(std::begin(fvals), std::end(fvals), + std::begin(dfltVals), + [](const FVal& fv) + { + return fv.max.val; + }); + + if (opt.curve == FCat::Relperm) { + if (opt.subSys == SSys::OilGas) { + if (opt.thisPh == PhIdx::Aqua) { + throw std::invalid_argument { + "Cannot Create Vertical Scaling for " + "Water Relperm in an Oil/Gas System" + }; + } + + if (opt.thisPh == PhIdx::Vapour) { + return Create::PureVertical::Kr::G(G, init, dfltVals); + } + + return Create::PureVertical::Kr::O(G, init, dfltVals); + } + + if (opt.subSys == SSys::OilWater) { + if (opt.thisPh == PhIdx::Vapour) { + throw std::invalid_argument { + "Cannot Create Vertical Scaling for " + "Gas Relperm in an Oil/Water System" + }; + } + + if (opt.thisPh == PhIdx::Aqua) { + return Create::PureVertical::Kr::W(G, init, dfltVals); + } + + return Create::PureVertical::Kr::O(G, init, dfltVals); + } + } + + if (opt.curve == FCat::CapPress) { + if (opt.thisPh == PhIdx::Liquid) { + throw std::invalid_argument { + "Creating Capillary Pressure Vertical Scaling " + "as a Function of Oil Saturation is not Supported" + }; + } + + if (opt.thisPh == PhIdx::Vapour) { + return Create::PureVertical::Pc::GO(G, init, dfltVals); + } + + if (opt.thisPh == PhIdx::Aqua) { + return Create::PureVertical::Pc::OW(G, init, dfltVals); + } + } + + // Invalid. + return {}; +} + +// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - +// Implementation of Create::CritSatVertical::scalingFunction() + +namespace { + template + std::vector + extractCritSat(const std::vector& tep, + Extract&& extract) + { + auto scr = std::vector(tep.size(), 0.0); + + std::transform(std::begin(tep), std::end(tep), std::begin(scr), + std::forward(extract)); + + return scr; + } +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::G(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& rtep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto& ih = init.keywordData(INTEHEAD_KW); + const auto iphs = static_cast(ih[INTEHEAD_PHASE_INDEX]); + + auto sdisp = std::vector(G.numCells()); + + if ((iphs & (1u << 0)) != 0) { // Oil active + auto sogcr = + gridDefaultedVector(G, init, "SOGCR", rtep.crit.oil_in_gas, + [](const double s) { return s; }); + + auto swl = + gridDefaultedVector(G, init, "SWL", rtep.conn.water, + [](const double s) { return s; }); + + std::transform(std::begin(sogcr), std::end(sogcr), + std::begin(swl), std::begin(sdisp), + [](const double so, const double sw) + { + return 1.0 - (so + sw); + }); + } + else { // Oil not active (G/W?) + auto swcr = + gridDefaultedVector(G, init, "SWCR", rtep.crit.water, + [](const double s) { return s; }); + + std::transform(std::begin(swcr), std::end(swcr), + std::begin(sdisp), + [](const double sw) + { + return 1.0 - sw; + }); + } + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRGR", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRG", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::GO(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + auto sdisp = std::vector(G.numCells()); + + auto sgcr = + gridDefaultedVector(G, init, "SGCR", tep.crit.gas, + [](const double s) { return s; }); + + auto swl = + gridDefaultedVector(G, init, "SWL", tep.conn.water, + [](const double s) { return s; }); + + std::transform(std::begin(sgcr), std::end(sgcr), + std::begin(swl), std::begin(sdisp), + [](const double sg, const double sw) + { + return 1.0 - (sg + sw); + }); + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRORG", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRO", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::OW(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + auto sdisp = std::vector(G.numCells()); + + auto swcr = + gridDefaultedVector(G, init, "SWCR", tep.crit.water, + [](const double s) { return s; }); + + auto sgl = + gridDefaultedVector(G, init, "SGL", tep.conn.gas, + [](const double s) { return s; }); + + std::transform(std::begin(swcr), std::end(swcr), + std::begin(sgl), std::begin(sdisp), + [](const double sw, const double sg) + { + return 1.0 - (sg + sw); + }); + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRORW", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRO", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical::Kr::W(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const RTEP& tep, + const FValVec& fval) +{ + using FVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto& ih = init.keywordData(INTEHEAD_KW); + const auto iphs = static_cast(ih[INTEHEAD_PHASE_INDEX]); + + auto sdisp = std::vector(G.numCells()); + + if ((iphs & (1u << 0)) != 0) { // Oil active + auto sowcr = + gridDefaultedVector(G, init, "SOWCR", tep.crit.oil_in_water, + [](const double s) { return s; }); + + auto sgl = + gridDefaultedVector(G, init, "SGL", tep.conn.gas, + [](const double s) { return s; }); + + std::transform(std::begin(sowcr), std::end(sowcr), + std::begin(sgl), std::begin(sdisp), + [](const double so, const double sg) + { + return 1.0 - (so + sg); + }); + } + else { // Oil not active (G/W?) + auto sgcr = + gridDefaultedVector(G, init, "SGCR", tep.crit.gas, + [](const double s) { return s; }); + + std::transform(std::begin(sgcr), std::end(sgcr), + std::begin(sdisp), + [](const double sg) + { + return 1.0 - sg; + }); + } + + auto dflt_fdisp = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fdisp), + [](const FVal& fv) { return fv.disp.val;}); + + auto fdisp = + gridDefaultedVector(G, init, "KRWR", dflt_fdisp, + [](const double kr) { return kr; }); + + auto dflt_fmax = std::vector(fval.size(), 0.0); + std::transform(std::begin(fval), std::end(fval), + std::begin(dflt_fmax), + [](const FVal& fv) { return fv.max.val; }); + + auto fmax = + gridDefaultedVector(G, init, "KRW", dflt_fmax, + [](const double kr) { return kr; }); + + return ScalPtr { + new ::Opm::SatFunc::CritSatVerticalScaling { + std::move(sdisp), std::move(fdisp), std::move(fmax) + } + }; +} + +Create::CritSatVertical::ScalPtr +Create::CritSatVertical:: +scalingFunction(const ::Opm::ECLGraph& G, + const ::Opm::ECLInitFileData& init, + const EPSOpt& opt, + const RTEP& tep, + const FValVec& fvals) +{ + using SSys = ::Opm::SatFunc::CreateEPS::SubSystem; + using PhIdx = ::Opm::ECLPhaseIndex; + + if (opt.subSys == SSys::OilWater) { + if (opt.thisPh == PhIdx::Vapour) { + throw std::invalid_argument { + "Cannot Create Critical Saturation Vertical " + "Scaling for Gas Relperm in an Oil/Water System" + }; + } + + if (opt.thisPh == PhIdx::Aqua) { + return Create::CritSatVertical::Kr::W(G, init, tep, fvals); + } + + return Create::CritSatVertical::Kr::OW(G, init, tep, fvals); + } + + if (opt.subSys == SSys::OilGas) { + if (opt.thisPh == PhIdx::Aqua) { + throw std::invalid_argument { + "Cannot Create Critical Saturation Vertical " + "Scaling for Water Relperm in an Oil/Gas System" + }; + } + + if (opt.thisPh == PhIdx::Vapour) { + return Create::CritSatVertical::Kr::G(G, init, tep, fvals); + } + + return Create::CritSatVertical::Kr::GO(G, init, tep, fvals); + } + + // Invalid. + return {}; +} + // ##################################################################### // ===================================================================== // Public Interface Below Separator @@ -1339,12 +2030,17 @@ Opm::SatFunc::EPSEvalInterface::~EPSEvalInterface() // --------------------------------------------------------------------- +// Class Opm::SatFunc::VerticalScalingInterface +Opm::SatFunc::VerticalScalingInterface::~VerticalScalingInterface() +{} + +// --------------------------------------------------------------------- + // Class Opm::SatFunc::TwoPointScaling Opm::SatFunc::TwoPointScaling:: -TwoPointScaling(std::vector smin, - std::vector smax, - InvalidEndpointBehaviour handle_invalid) - : pImpl_(new Impl(std::move(smin), std::move(smax), handle_invalid)) +TwoPointScaling(std::vector smin, + std::vector smax) + : pImpl_(new Impl(std::move(smin), std::move(smax))) {} Opm::SatFunc::TwoPointScaling::~TwoPointScaling() @@ -1398,16 +2094,65 @@ Opm::SatFunc::TwoPointScaling::clone() const // --------------------------------------------------------------------- +// Class Opm::SatFunc::PureVerticalScaling + +Opm::SatFunc::PureVerticalScaling:: +PureVerticalScaling(std::vector fmax) + : pImpl_(new Impl(std::move(fmax))) +{} + +Opm::SatFunc::PureVerticalScaling::~PureVerticalScaling() +{} + +Opm::SatFunc::PureVerticalScaling:: +PureVerticalScaling(const PureVerticalScaling& rhs) + : pImpl_(new Impl(*rhs.pImpl_)) +{} + +Opm::SatFunc::PureVerticalScaling:: +PureVerticalScaling(PureVerticalScaling&& rhs) + : pImpl_(std::move(rhs.pImpl_)) +{} + +Opm::SatFunc::PureVerticalScaling& +Opm::SatFunc::PureVerticalScaling::operator=(const PureVerticalScaling& rhs) +{ + this->pImpl_.reset(new Impl(*rhs.pImpl_)); + + return *this; +} + +Opm::SatFunc::PureVerticalScaling& +Opm::SatFunc::PureVerticalScaling::operator=(PureVerticalScaling&& rhs) +{ + this->pImpl_ = std::move(rhs.pImpl_); + + return *this; +} + +std::vector +Opm::SatFunc::PureVerticalScaling:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const +{ + return this->pImpl_->vertScale(f, sp, val); +} + +std::unique_ptr +Opm::SatFunc::PureVerticalScaling::clone() const +{ + return std::unique_ptr(new PureVerticalScaling(*this)); +} + +// --------------------------------------------------------------------- + // Class Opm::SatFunc::ThreePointScaling Opm::SatFunc::ThreePointScaling:: -ThreePointScaling(std::vector smin, - std::vector sdisp, - std::vector smax, - InvalidEndpointBehaviour handle_invalid) - : pImpl_(new Impl(std::move(smin) , - std::move(sdisp), - std::move(smax) , - handle_invalid)) +ThreePointScaling(std::vector smin, + std::vector sdisp, + std::vector smax) + : pImpl_(new Impl(std::move(smin), std::move(sdisp), std::move(smax))) {} Opm::SatFunc::ThreePointScaling::~ThreePointScaling() @@ -1459,10 +2204,68 @@ Opm::SatFunc::ThreePointScaling::clone() const } // --------------------------------------------------------------------- -// Factory function Opm::SatFunc::CreateEPS::fromECLOutput() + +// Class Opm::SatFunc::CritSatVerticalScaling +Opm::SatFunc::CritSatVerticalScaling:: +CritSatVerticalScaling(std::vector sdisp, + std::vector fdisp, + std::vector fmax) + : pImpl_(new Impl(std::move(sdisp), std::move(fdisp), std::move(fmax))) +{} + +Opm::SatFunc::CritSatVerticalScaling::~CritSatVerticalScaling() +{} + +Opm::SatFunc::CritSatVerticalScaling:: +CritSatVerticalScaling(const CritSatVerticalScaling& rhs) + : pImpl_(new Impl(*rhs.pImpl_)) +{} + +Opm::SatFunc::CritSatVerticalScaling:: +CritSatVerticalScaling(CritSatVerticalScaling&& rhs) + : pImpl_(std::move(rhs.pImpl_)) +{} + +Opm::SatFunc::CritSatVerticalScaling& +Opm::SatFunc::CritSatVerticalScaling:: +operator=(const CritSatVerticalScaling& rhs) +{ + this->pImpl_.reset(new Impl(*rhs.pImpl_)); + + return *this; +} + +Opm::SatFunc::CritSatVerticalScaling& +Opm::SatFunc::CritSatVerticalScaling:: +operator=(CritSatVerticalScaling&& rhs) +{ + this->pImpl_ = std::move(rhs.pImpl_); + + return *this; +} + +std::vector +Opm::SatFunc::CritSatVerticalScaling:: +vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const +{ + return this->pImpl_->vertScale(f, sp, val); +} + +std::unique_ptr +Opm::SatFunc::CritSatVerticalScaling::clone() const +{ + return std::unique_ptr { + new CritSatVerticalScaling(*this) + }; +} + +// --------------------------------------------------------------------- +// Factory function Opm::SatFunc::CreateEPS::Horizontal::fromECLOutput() std::unique_ptr -Opm::SatFunc::CreateEPS:: +Opm::SatFunc::CreateEPS::Horizontal:: fromECLOutput(const ECLGraph& G, const ECLInitFileData& init, const EPSOptions& opt) @@ -1483,10 +2286,10 @@ fromECLOutput(const ECLGraph& G, } // --------------------------------------------------------------------- -// Factory function Opm::SatFunc::CreateEPS::unscaledEndPoints() +// Factory function Opm::SatFunc::CreateEPS::Horizontal::unscaledEndPoints() std::vector -Opm::SatFunc::CreateEPS:: +Opm::SatFunc::CreateEPS::Horizontal:: unscaledEndPoints(const RawTableEndPoints& ep, const EPSOptions& opt) { @@ -1504,3 +2307,84 @@ unscaledEndPoints(const RawTableEndPoints& ep, // Invalid return {}; } + +// --------------------------------------------------------------------- +// Factory function Opm::SatFunc::CreateEPS::Vertical::fromECLOutput() + +std::unique_ptr +Opm::SatFunc::CreateEPS::Vertical:: +fromECLOutput(const ECLGraph& G, + const ECLInitFileData& init, + const EPSOptions& opt, + const RawTableEndPoints& tep, + const FuncValVector& fvals) +{ + const auto haveScaleCRS = + haveScaledRelPermAtCritSat(G, init, opt.thisPh, opt.subSys); + + if ((opt.curve == FunctionCategory::CapPress) || (! haveScaleCRS)) + { + return Create::PureVertical:: + scalingFunction(G, init, opt, fvals); + } + + if ((opt.curve == FunctionCategory::Relperm) && haveScaleCRS) + { + return Create::CritSatVertical:: + scalingFunction(G, init, opt, tep, fvals); + } + + // Invalid + return {}; +} + +// --------------------------------------------------------------------- +// Factory function Opm::SatFunc::CreateEPS::Vertical::unscaledFunctionValues() + +std::vector +Opm::SatFunc::CreateEPS::Vertical:: +unscaledFunctionValues(const ECLGraph& G, + const ECLInitFileData& init, + const RawTableEndPoints& ep, + const EPSOptions& opt, + const SatFuncEvaluator& evalSF) +{ + auto ret = std::vector{}; + + const auto haveScaleCRS = + haveScaledRelPermAtCritSat(G, init, opt.thisPh, opt.subSys); + + if ((opt.curve == FunctionCategory::CapPress) || (! haveScaleCRS)) { + auto opt_cpy = opt; + opt_cpy.use3PtScaling = false; + + const auto uep = + Create::TwoPoint::unscaledEndPoints(ep, opt_cpy); + + ret.resize(uep.size()); + + for (auto n = uep.size(), i = 0*n; i < n; ++i) { + ret[i].max.sat = uep[i].high; + ret[i].max.val = evalSF(static_cast(i), ret[i].max.sat); + } + } + else { + auto opt_cpy = opt; + opt_cpy.use3PtScaling = true; + + const auto uep = + Create::ThreePoint::unscaledEndPoints(ep, opt_cpy); + + ret.resize(uep.size()); + + for (auto n = uep.size(), i = 0*n; i < n; ++i) { + ret[i].disp.sat = uep[i].disp; + ret[i].disp.val = evalSF(static_cast(i), ret[i].disp.sat); + + ret[i].max.sat = uep[i].high; + ret[i].max.val = evalSF(static_cast(i), ret[i].max.sat); + } + } + + return ret; +} diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp index acdb9e3cc4..42cc2aa679 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLEndPointScaling.hpp @@ -127,6 +127,52 @@ namespace Opm { namespace SatFunc { virtual ~EPSEvalInterface(); }; + /// Protocol for computing vertically scaled relative permeability and + /// capillary pressure values. + class VerticalScalingInterface + { + public: + struct FunctionValues { + struct Point { + double sat; + double val; + }; + + Point disp; + Point max; + }; + + /// Associate a saturation value to a specific cell. + using SaturationAssoc = EPSEvalInterface::SaturationAssoc; + + /// Convenience type alias. + using SaturationPoints = EPSEvalInterface::SaturationPoints; + + /// Compute vertically scaled saturation function values. + /// + /// \param[in] f Unscaled function values extracted from input's + /// saturation function table. + /// + /// \param[in] sp Sequence of saturation points. + /// + /// \param[in] val Sequence of saturation function values. + /// + /// \return Sequence of vertically scaled saturation function values + /// in order of the input sequence. In particular the \c i-th + /// element of this result is the scaled version of \code val[i] + /// \endcode. + virtual std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const = 0; + + /// Virtual copy constructor. + virtual std::unique_ptr clone() const = 0; + + /// Destructor. Must be virtual. + virtual ~VerticalScalingInterface(); + }; + /// Implementation of ECLIPSE's standard, two-point, saturation scaling /// option. class TwoPointScaling : public EPSEvalInterface @@ -141,19 +187,8 @@ namespace Opm { namespace SatFunc { /// \param[in] smin Left end points for a set of cells. /// /// \param[in] smax Right end points for a set of cells. - /// - /// \param[in] handle_invalid How to treat scaling requests with - /// invalid scaled saturations. This can, for instance, happen - /// if the scaled saturations are present in the result set but - /// some (or all) cells have irreconcilable values (e.g., minimum - /// saturation greater than maximum saturation, smin < -1E+20, - /// smax < -1E+20). - /// - /// Default behaviour: Use unscaled saturation if this happens. - TwoPointScaling(std::vector smin, - std::vector smax, - const InvalidEndpointBehaviour handle_invalid - = InvalidEndpointBehaviour::UseUnscaled); + TwoPointScaling(std::vector smin, + std::vector smax); /// Destructor. ~TwoPointScaling(); @@ -244,6 +279,74 @@ namespace Opm { namespace SatFunc { std::unique_ptr pImpl_; }; + /// Implementation of ECLIPSE's standard, pure vertical saturation + /// function scaling option. + /// + /// Multiplies function values with a location (cell ID) dependent + /// factor. Applies to both relative permeability and capillary + /// pressure functions. + class PureVerticalScaling : public VerticalScalingInterface + { + public: + /// Constructor. + /// + /// Typically set up to define vertical scaling of saturation + /// function values in all active cells in a model, but could + /// alternatively be used as a means to computing the effective + /// saturation function value of a single cell. + /// + /// \param[in] fmax Scaled maximum saturation function (Kr or Pc) + /// value in collection of cells. Typically an input vector like + /// PCG or KROW from an ECL result set. + explicit PureVerticalScaling(std::vector fmax); + + /// Destructor. + virtual ~PureVerticalScaling(); + + /// Copy constructor. + PureVerticalScaling(const PureVerticalScaling& rhs); + + /// Move constructor. + PureVerticalScaling(PureVerticalScaling&& rhs); + + /// Assignment operator. + PureVerticalScaling& operator=(const PureVerticalScaling& rhs); + + /// Move assignment operator. + PureVerticalScaling& operator=(PureVerticalScaling&& rhs); + + /// Compute vertically scaled saturation function values. + /// + /// \param[in] f Unscaled function values extracted from input's + /// saturation function table. Method \c PureVerticalScaling + /// uses the maximum value/point only. + /// + /// \param[in] sp Sequence of saturation points. + /// + /// \param[in] val Sequence of saturation function values. + /// + /// \return Sequence of vertically scaled saturation function values + /// in order of the input sequence. In particular the \c i-th + /// element of this result is the scaled version of \code val[i] + /// \endcode. Multiplies entries in \p val with an appropriate + /// location dependent factor. + virtual std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const override; + + /// Virtual copy constructor. + virtual std::unique_ptr + clone() const override; + + private: + /// Implementation class. + class Impl; + + /// Pimpl idiom. + std::unique_ptr pImpl_; + }; + /// Implementation of ECLIPSE's alternative, three-point, saturation /// scaling option. class ThreePointScaling : public EPSEvalInterface @@ -261,20 +364,9 @@ namespace Opm { namespace SatFunc { /// for a set of cells. /// /// \param[in] smax Right end points for a set of cells. - /// - /// \param[in] handle_invalid How to treat scaling requests with - /// invalid scaled saturations. This can, for instance, happen - /// if the scaled saturations are present in the result set but - /// some (or all) cells have irreconcilable values (e.g., minimum - /// saturation greater than maximum saturation, smin < -1E+20, - /// smax < -1E+20). - /// - /// Default behaviour: Use unscaled saturation if this happens. - ThreePointScaling(std::vector smin, - std::vector sdisp, - std::vector smax, - const InvalidEndpointBehaviour handle_invalid - = InvalidEndpointBehaviour::UseUnscaled); + ThreePointScaling(std::vector smin, + std::vector sdisp, + std::vector smax); /// Destructor. ~ThreePointScaling(); @@ -365,6 +457,67 @@ namespace Opm { namespace SatFunc { std::unique_ptr pImpl_; }; + /// Implementation of ECLIPSE's option for vertical scaling of relative + /// permeability functions honouring critical/residual saturation of + /// displacing phase. + /// + /// Multiplies function values with a location (cell ID) and saturation + /// dependent factor. Not intended for capillary pressure functions. + class CritSatVerticalScaling : public VerticalScalingInterface + { + public: + /// Constructor. + explicit CritSatVerticalScaling(std::vector sdisp, + std::vector fdisp, + std::vector fmax); + + /// Destructor. + virtual ~CritSatVerticalScaling(); + + /// Copy constructor. + CritSatVerticalScaling(const CritSatVerticalScaling& rhs); + + /// Move constructor. + CritSatVerticalScaling(CritSatVerticalScaling&& rhs); + + /// Assignment operator. + CritSatVerticalScaling& operator=(const CritSatVerticalScaling& rhs); + + /// Move assignment operator. + CritSatVerticalScaling& operator=(CritSatVerticalScaling&& rhs); + + /// Compute vertically scaled saturation function values. + /// + /// \param[in] f Unscaled function values extracted from input's + /// saturation function table. The critical saturation vertical + /// scaling method uses both the displacement and the maximum + /// points. + /// + /// \param[in] sp Sequence of saturation points. + /// + /// \param[in] val Sequence of saturation function values. + /// + /// \return Sequence of vertically scaled saturation function values + /// in order of the input sequence. In particular the \c i-th + /// element of this result is the scaled version of \code val[i] + /// \endcode. + virtual std::vector + vertScale(const FunctionValues& f, + const SaturationPoints& sp, + const std::vector& val) const override; + + /// Virtual copy constructor. + virtual std::unique_ptr + clone() const override; + + private: + /// Implementation class. + class Impl; + + /// Pimpl idiom. + std::unique_ptr pImpl_; + }; + /// Named constructors for enabling saturation end-point scaling from an /// ECL result set (see class \c ECLInitFileData). struct CreateEPS @@ -494,46 +647,120 @@ namespace Opm { namespace SatFunc { Maximum smax; }; - /// Construct an EPS evaluator from a particular ECL result set. - /// - /// \param[in] G Connected topology of current model's active cells. - /// Needed to linearise table end-points that may be distributed - /// on local grids to all of the model's active cells (\code - /// member function G.rawLinearisedCellData() \endcode). - /// - /// \param[in] init Container of tabulated saturation functions and - /// saturation table end points for all active cells. - /// - /// \param[in] opt Options that identify a particular end-point - /// scaling behaviour of a particular saturation function curve. - /// - /// \return EPS evaluator for the particular curve defined by the - /// input options. - static std::unique_ptr - fromECLOutput(const ECLGraph& G, - const ECLInitFileData& init, - const EPSOptions& opt); - - /// Extract table end points relevant to a particular EPS evaluator - /// from raw tabulated saturation functions. - /// - /// \param[in] ep Collection of all raw table saturation end points - /// for all tabulated saturation functions. Typically computed - /// by direct calls to the \code connateSat() \endcode, \code - /// criticalSat() \endcode, and \code maximumSat() \endcode of - /// the currently active \code Opm::SatFuncInterpolant \code - /// objects. - /// - /// \param[in] opt Options that identify a particular end-point - /// scaling behaviour of a particular saturation function curve. - /// - /// \return Subset of the input end points in a format intended for - /// passing as the first argument of member function \code eval() - /// \endcode of the \code EPSEvalInterface \endcode that - /// corresponds to the input options. - static std::vector - unscaledEndPoints(const RawTableEndPoints& ep, - const EPSOptions& opt); + /// Named constructors for horizontal (saturation) end-point scaling + /// of saturation functions. + struct Horizontal { + /// Construct a horizontal EPS evaluator from a particular ECL + /// result set. + /// + /// \param[in] G Connected topology of current model's active + /// cells. Needed to linearise table end-points that may be + /// distributed on local grids to all of the model's active + /// cells (\code member function G.rawLinearisedCellData() + /// \endcode). + /// + /// \param[in] init Container of tabulated saturation functions + /// and saturation table end points for all active cells. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \return EPS evaluator for the particular curve defined by + /// the input options. + static std::unique_ptr + fromECLOutput(const ECLGraph& G, + const ECLInitFileData& init, + const EPSOptions& opt); + + /// Extract table end points relevant to a particular horizontal + /// EPS evaluator from raw tabulated saturation functions. + /// + /// \param[in] ep Collection of all raw table saturation end + /// points for all tabulated saturation functions. Typically + /// computed by direct calls to the \code connateSat() + /// \endcode, \code criticalSat() \endcode, and \code + /// maximumSat() \endcode of the currently active \code + /// Opm::SatFuncInterpolant \code objects. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \return Subset of the input end points in a format intended + /// for passing as the first argument of member function + /// \code eval() \endcode of the \code EPSEvalInterface + /// \endcode that corresponds to the input options. + static std::vector + unscaledEndPoints(const RawTableEndPoints& ep, + const EPSOptions& opt); + }; + + /// Named constructors for vertical (value) scaling of saturation + /// functions. + struct Vertical { + using SatFuncEvaluator = std::function; + using FuncValVector = std::vector< + VerticalScalingInterface::FunctionValues>; + + /// Construct a vertical saturation function value scaling from + /// a particular ECL result set. + /// + /// \param[in] G Connected topology of current model's active + /// cells. Needed to linearise table end-points that may be + /// distributed on local grids to all of the model's active + /// cells (member functions \code G.rawLinearisedCellData() + /// \endcode and \code G.linearisedCellData() \endcode). + /// + /// \param[in] init Container of tabulated saturation functions + /// and saturation table end points for all active cells. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \param[in] tep Table end-points. Used to define critical + /// saturations of displacing phase for vertical scaling at + /// displacing saturation. Otherwise unused. + /// + /// \param[in] fvals Function values at selected saturation + /// points. Typically constructed by means of function + /// unscaledFunctionValues(). + /// + /// \return Vertical scaling operator for the particular curve + /// defined by the input options. + static std::unique_ptr + fromECLOutput(const ECLGraph& G, + const ECLInitFileData& init, + const EPSOptions& opt, + const RawTableEndPoints& tep, + const FuncValVector& fvals); + + /// Extract table end points relevant to a particular vertical + /// scaling evaluator from raw tabulated saturation functions. + /// + /// \param[in] ep Collection of all raw table saturation end + /// points for all tabulated saturation functions. Typically + /// computed by direct calls to the \code connateSat() + /// \endcode, \code criticalSat() \endcode, and \code + /// maximumSat() \endcode of the currently active \code + /// Opm::SatFuncInterpolant \code objects. + /// + /// \param[in] opt Options that identify a particular end-point + /// scaling behaviour of a particular saturation function + /// curve. + /// + /// \return Subset of the input end points in a format intended + /// for passing as the first argument of member function + /// \code eval() \endcode of the \code EPSEvalInterface + /// \endcode that corresponds to the input options. + static std::vector + unscaledFunctionValues(const ECLGraph& G, + const ECLInitFileData& init, + const RawTableEndPoints& ep, + const EPSOptions& opt, + const SatFuncEvaluator& evalSF); + }; }; }} // namespace Opm::SatFunc diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp index 5550d376c3..c4f9429d4f 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLFluxCalc.cpp @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include @@ -90,7 +90,7 @@ namespace { const auto depthscale = usys->depth(); for (auto& zi : depth) { - zi = ::Opm::unit::convert::from(zi, depthscale); + zi = ::ImportedOpm::unit::convert::from(zi, depthscale); } return depth; @@ -183,9 +183,9 @@ namespace Opm ECLFluxCalc::ECLFluxCalc(const ECLGraph& graph, const ECLInitFileData& init, const double grav, - const bool useEPS) + const bool /* useEPS */) : graph_(graph) - , satfunc_(graph, init, useEPS) + , satfunc_(graph, init) , rmap_(pvtnumVector(graph, init)) , neighbours_(graph.neighbours()) , transmissibility_(graph.transmissibility()) diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp index 8783275b98..32b6739d32 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include @@ -604,7 +604,7 @@ ECL::getPVolVector(const ecl_grid_type* G, getUnitSystem(init, gridID)->reservoirVolume(); for (auto& pv : pvol) { - pv = ::Opm::unit::convert::from(pv, pvol_unit); + pv = ::ImportedOpm::unit::convert::from(pv, pvol_unit); } } @@ -1157,7 +1157,7 @@ connectionData(const ::Opm::ECLRestartData& rstrt, "Direction must be I, J, or K"); for (const auto& cell : cells->second) { - x.push_back(::Opm::unit::convert::from(v[cell], unit)); + x.push_back(::ImportedOpm::unit::convert::from(v[cell], unit)); } } @@ -1208,7 +1208,7 @@ deriveNeighbours(const std::vector& gcells, auto SI_trans = [trans_unit](const double trans) { - return ::Opm::unit::convert::from(trans, trans_unit); + return ::ImportedOpm::unit::convert::from(trans, trans_unit); }; auto& ocell = this->outCell_[d]; @@ -1288,6 +1288,9 @@ class Opm::ECLGraph::Impl /// Retrieve number of active cells in graph. std::size_t numCells() const; + /// Retrieve number of active cells in particular subgrid. + std::size_t numCells(const std::string& gridID) const; + /// Retrieve number of connections in graph. std::size_t numConnections() const; @@ -1364,6 +1367,24 @@ class Opm::ECLGraph::Impl rawLinearisedCellData(const ResultSet& rset, const std::string& vector) const; + /// Retrieve result set vector from current view (e.g., particular + /// report step) linearised on active cells of a particular sub-grid. + /// + /// \tparam T Element type of result set vector. + /// + /// \param[in] vector Name of result set vector. + /// + /// \param[in] gridID Identity of specific grid to which to relate the + /// requested vector. Use empty for main grid and names for any + /// LGRs. + /// + /// \return Result set vector linearised on active cells of sub-grid. + template + std::vector + rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const; + /// Retrieve floating-point result set vector from current view /// (e.g., particular report step) linearised on active cells and /// converted to strict SI unit conventions. @@ -1776,7 +1797,7 @@ NNC::add(const std::vector& grid, // Capture transmissibility field to support on-demand flux calculations // if flux fields are not output to the on-disk result set. - this->trans_.push_back(unit::convert::from(nnc.trans, trans_unit)); + this->trans_.push_back(ImportedOpm::unit::convert::from(nnc.trans, trans_unit)); const auto cat = this->classifyConnection(nnc.grid_nr1, nnc.grid_nr2); @@ -1997,6 +2018,15 @@ Opm::ECLGraph::Impl::numCells() const return this->activeOffset_.back(); } +std::size_t +Opm::ECLGraph::Impl::numCells(const std::string& gridID) const +{ + auto i = this->gridID_.find(gridID); + + return (i == std::end(this->gridID_)) + ? 0 : this->grid_[i->second].numCells(); +} + std::size_t Opm::ECLGraph::Impl::numConnections() const { @@ -2185,6 +2215,21 @@ namespace Opm { return x; } + + template + std::vector + ECLGraph::Impl::rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const + { + auto i = this->gridID_.find(gridID); + + if (i == std::end(this->gridID_)) { + return {}; + } + + return this->grid_[i->second].activeCellData(rset, vector); + } } // namespace Opm std::vector @@ -2211,7 +2256,7 @@ Opm::ECLGraph::Impl::linearisedCellData(const ECLRestartData& rstrt, std::back_inserter(x), [vector_unit](const double value) { - return ::Opm::unit::convert::from(value, vector_unit); + return ::ImportedOpm::unit::convert::from(value, vector_unit); }); } @@ -2285,7 +2330,7 @@ Opm::ECLGraph::Impl::fluxNNC(const ECLRestartData& rstrt, assert (ix.kwIdx < q.size()); v[ix.neighIdx] = - unit::convert::from(q[ix.kwIdx], flux_unit); + ImportedOpm::unit::convert::from(q[ix.kwIdx], flux_unit); assigned[ix.neighIdx] = true; } @@ -2408,6 +2453,11 @@ std::size_t Opm::ECLGraph::numCells() const return this->pImpl_->numCells(); } +std::size_t Opm::ECLGraph::numCells(const std::string& gridID) const +{ + return this->pImpl_->numCells(gridID); +} + std::size_t Opm::ECLGraph::numConnections() const { return this->pImpl_->numConnections(); @@ -2462,6 +2512,15 @@ namespace Opm { return this->pImpl_->rawLinearisedCellData(rset, vector); } + template + std::vector + ECLGraph::rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const + { + return this->pImpl_->rawLinearisedCellData(rset, vector, gridID); + } + // Explicit instantiations of method rawLinearisedCellData() for the // element and result set types we care about. template std::vector @@ -2480,6 +2539,26 @@ namespace Opm { ECLGraph::rawLinearisedCellData(const ECLRestartData& rset, const std::string& vector) const; + template std::vector + ECLGraph::rawLinearisedCellData(const ECLInitFileData& rset, + const std::string& vector, + const std::string& gridID) const; + + template std::vector + ECLGraph::rawLinearisedCellData(const ECLRestartData& rset, + const std::string& vector, + const std::string& gridID) const; + + template std::vector + ECLGraph::rawLinearisedCellData(const ECLInitFileData& rset, + const std::string& vector, + const std::string& gridID) const; + + template std::vector + ECLGraph::rawLinearisedCellData(const ECLRestartData& rset, + const std::string& vector, + const std::string& gridID) const; + } // namespace Opm std::vector diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp index e8114d7127..bd12218ea3 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLGraph.hpp @@ -111,11 +111,14 @@ namespace Opm { /// outside valid range or if the specific cell identified by \p /// ijk and \p gridID is not actually active. int activeCell(const std::array& ijk, - const std::string& gridID = 0) const; + const std::string& gridID = "") const; /// Retrieve number of active cells in graph. std::size_t numCells() const; + /// Retrieve number of active cells in particular subgrid. + std::size_t numCells(const std::string& gridID) const; + /// Retrieve number of connections in graph. std::size_t numConnections() const; @@ -183,6 +186,24 @@ namespace Opm { rawLinearisedCellData(const ResultSet& rset, const std::string& vector) const; + /// Retrieve result set vector from current view (e.g., particular + /// report step) linearised on active cells of a particular sub-grid. + /// + /// \tparam T Element type of result set vector. + /// + /// \param[in] vector Name of result set vector. + /// + /// \param[in] gridID Identity of specific grid to which to relate + /// the requested vector. Use empty for main grid and names for + /// any LGRs. + /// + /// \return Result set vector linearised on active cells of sub-grid. + template + std::vector + rawLinearisedCellData(const ResultSet& rset, + const std::string& vector, + const std::string& gridID) const; + /// Convenience type alias for \c UnitSystem PMFs (pointer to member /// function). typedef double (ECLUnits::UnitSystem::*UnitConvention)() const; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp index 07a6b05e7c..65f2a18c48 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPropertyUnitConversion.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include @@ -315,7 +315,7 @@ namespace { double calculateScaleFactor(const double from, const double to) { - using namespace ::Opm::unit; + using namespace ::ImportedOpm::unit; // "return from / to", essentially. return convert::to(convert::from(1.0, from), to); diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp index 56bb6d075f..f55b771164 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtCommon.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include #include #include @@ -64,7 +64,7 @@ namespace { return ::Opm::ECLPVT::ConvertUnits::Converter { [uscale](const double q) -> double { - return ::Opm::unit::convert::from(q, uscale); + return ::ImportedOpm::unit::convert::from(q, uscale); } }; } @@ -326,7 +326,7 @@ Opm::ECLPVT::surfaceMassDensity(const ECLInitFileData& init, const auto dens_scale = u->density(); for (auto& rho_i : rho) { - rho_i = unit::convert::from(rho_i, dens_scale); + rho_i = ImportedOpm::unit::convert::from(rho_i, dens_scale); } return rho; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp index e84cba83b9..fef7dd5140 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtGas.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp index b572ccb35a..362ae167f8 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLPvtOil.cpp @@ -24,7 +24,7 @@ #include #include -#include +#include #include #include @@ -48,7 +48,7 @@ namespace { return [scale](const double x) -> double { - return Opm::unit::convert::from(x, scale); + return ImportedOpm::unit::convert::from(x, scale); }; } @@ -59,7 +59,7 @@ namespace { return [scale](const double x) -> double { - return Opm::unit::convert::from(x, scale); + return ImportedOpm::unit::convert::from(x, scale); }; } diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp index ec71e996f2..522def78e6 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include @@ -121,6 +121,20 @@ namespace { return { std::move(Sx), std::move(y) }; } + + bool enableHorizontalEPS(const Opm::ECLSaturationFunc::SatFuncScaling& scaling) + { + using T = Opm::ECLSaturationFunc::SatFuncScaling::Type; + + return (scaling.enable & T::Horizontal) != 0; + } + + bool enableVerticalSFScaling(const Opm::ECLSaturationFunc::SatFuncScaling& scaling) + { + using T = Opm::ECLSaturationFunc::SatFuncScaling::Type; + + return (scaling.enable & T::Vertical) != 0; + } } // Anonymous // ===================================================================== @@ -589,7 +603,7 @@ Gas::Details::unitConverter(const int usys) const auto pscale = u->pressure(); auto cvrt_press = [pscale](const double p) { - return ::Opm::unit::convert::from(p, pscale); + return ::ImportedOpm::unit::convert::from(p, pscale); }; return CU { @@ -680,7 +694,7 @@ Water::Details::unitConverter(const int usys) const auto pscale = u->pressure(); auto cvrt_press = [pscale](const double p) { - return ::Opm::unit::convert::from(p, pscale); + return ::ImportedOpm::unit::convert::from(p, pscale); }; return CU { @@ -701,10 +715,8 @@ class Opm::ECLSaturationFunc::Impl Impl(Impl&& rhs); Impl(const Impl& rhs); - void init(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS, - const InvalidEPBehaviour handle_invalid); + void init(const ECLGraph& G, + const ECLInitFileData& init); void setOutputUnits(std::unique_ptr usys); @@ -716,7 +728,7 @@ class Opm::ECLSaturationFunc::Impl std::vector getSatFuncCurve(const std::vector& func, const int activeCell, - const bool useEPS) const; + const SatFuncScaling& scaling) const; private: class EPSEvaluator @@ -738,30 +750,33 @@ class Opm::ECLSaturationFunc::Impl bool wat; }; - void define(const ECLGraph& G, - const ECLInitFileData& init, - const RawTEP& ep, - const bool use3PtScaling, - const ActPh& active, - const InvalidEPBehaviour handle_invalid) + void define(const Impl& host, + const ECLGraph& G, + const ECLInitFileData& init, + const RawTEP& ep, + const bool use3PtScaling, + const ActPh& active) { auto opt = Create::EPSOptions{}; opt.use3PtScaling = use3PtScaling; - opt.handle_invalid = handle_invalid; + opt.handle_invalid = SatFuncScaling::IEB::UseUnscaled; if (active.oil) { - this->create_oil_eps(G, init, ep, active, opt); + this->create_oil_eps(host, G, init, ep, active, opt); } if (active.gas) { - this->create_gas_eps(G, init, ep, opt); + this->create_gas_eps(host, G, init, ep, opt); } if (active.wat) { - this->create_wat_eps(G, init, ep, opt); + this->create_wat_eps(host, G, init, ep, opt); } } + // --------------------------------------------- + // ---------- End-point scaling ---------------- + void scaleKrOG(const ECLRegionMapping& rmap, std::vector& so) const { @@ -798,6 +813,9 @@ class Opm::ECLSaturationFunc::Impl this->scale(this->wat_.pc, rmap, sw); } + // --------------------------------------------- + // ---------- Reverse scaling ------------------ + void reverseScaleKrOG(const ECLRegionMapping& rmap, std::vector& so) const { @@ -834,6 +852,51 @@ class Opm::ECLSaturationFunc::Impl this->reverseScale(this->wat_.pc, rmap, sw); } + // --------------------------------------------- + // ---------- Vertical scaling ----------------- + + void vertScaleKrOG(const ECLRegionMapping& rmap, + const std::vector& so, + std::vector& kr) const + { + this->vertScale(this->oil_in_og_, rmap, so, kr); + } + + void vertScaleKrOW(const ECLRegionMapping& rmap, + const std::vector& so, + std::vector& kr) const + { + this->vertScale(this->oil_in_ow_, rmap, so, kr); + } + + void vertScaleKrGas(const ECLRegionMapping& rmap, + const std::vector& sg, + std::vector& kr) const + { + this->vertScale(this->gas_.kr, rmap, sg, kr); + } + + void vertScaleKrWat(const ECLRegionMapping& rmap, + const std::vector& sw, + std::vector& kr) const + { + this->vertScale(this->wat_.kr, rmap, sw,kr); + } + + void vertScalePcGO(const ECLRegionMapping& rmap, + const std::vector& sg, + std::vector& pc) const + { + this->vertScale(this->gas_.pc, rmap, sg, pc); + } + + void vertScalePcOW(const ECLRegionMapping& rmap, + const std::vector& sw, + std::vector& pc) const + { + this->vertScale(this->wat_.pc, rmap, sw, pc); + } + private: using Create = ::Opm::SatFunc::CreateEPS; using FCat = ::Opm::SatFunc::CreateEPS::FunctionCategory; @@ -844,9 +907,16 @@ class Opm::ECLSaturationFunc::Impl using EPSEndPts = ::Opm::SatFunc::EPSEvalInterface::TableEndPoints; using EPSEndPtVec = std::vector; + using VSInterface = ::Opm::SatFunc::VerticalScalingInterface; + using VSFuncVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + using VSFValVec = std::vector; + using EPSPtr = std::unique_ptr; using EndPtsPtr = std::unique_ptr; + using VScalPtr = std::unique_ptr; + using VScalFVVecPtr = std::unique_ptr; + struct EPS { EPS() {} @@ -859,11 +929,23 @@ class Opm::ECLSaturationFunc::Impl if (rhs.tep) { this->tep = EndPtsPtr(new EPSEndPtVec(*rhs.tep)); } + + if (rhs.vertscaling) { + this->vertscaling = rhs.vertscaling->clone(); + } + + if (rhs.vertfuncval) { + this->vertfuncval = VScalFVVecPtr { + new VSFValVec(*rhs.vertfuncval) + }; + } } EPS(EPS&& rhs) - : scaling(std::move(rhs.scaling)) - , tep (std::move(rhs.tep)) + : scaling (std::move(rhs.scaling)) + , tep (std::move(rhs.tep)) + , vertscaling(std::move(rhs.vertscaling)) + , vertfuncval(std::move(rhs.vertfuncval)) {} EPS& operator=(const EPS& rhs) @@ -876,6 +958,16 @@ class Opm::ECLSaturationFunc::Impl this->tep = EndPtsPtr(new EPSEndPtVec(*rhs.tep)); } + if (rhs.vertscaling) { + this->vertscaling = rhs.vertscaling->clone(); + } + + if (rhs.vertfuncval) { + this->vertfuncval = VScalFVVecPtr { + new VSFValVec(*rhs.vertfuncval) + }; + } + return *this; } @@ -884,11 +976,17 @@ class Opm::ECLSaturationFunc::Impl this->scaling = std::move(rhs.scaling); this->tep = std::move(rhs.tep); + this->vertscaling = std::move(rhs.vertscaling); + this->vertfuncval = std::move(rhs.vertfuncval); + return *this; } EPSPtr scaling; EndPtsPtr tep; + + VScalPtr vertscaling; + VScalFVVecPtr vertfuncval; }; struct FullEPS { @@ -901,6 +999,9 @@ class Opm::ECLSaturationFunc::Impl FullEPS gas_; FullEPS wat_; + // ---------------------------------------------- + // ------- End-point scaling (engine) ----------- + void scale(const EPS& eps, const ECLRegionMapping& rmap, std::vector& s) const @@ -929,10 +1030,13 @@ class Opm::ECLSaturationFunc::Impl const auto sr = eps.scaling->eval((*eps.tep)[regID - 1], sp); - this->assignScaledSaturations(rmap, regID, sr, s); + this->assignScaledResult(rmap, regID, sr, s); } } + // ---------------------------------------------- + // ------- Reverse end-point scaling (engine) --- + void reverseScale(const EPS& eps, const ECLRegionMapping& rmap, std::vector& s) const @@ -961,10 +1065,54 @@ class Opm::ECLSaturationFunc::Impl const auto sr = eps.scaling->reverse((*eps.tep)[regID - 1], sp); - this->assignScaledSaturations(rmap, regID, sr, s); + this->assignScaledResult(rmap, regID, sr, s); } } + // ---------------------------------------------- + // ------- Vertical scaling (engine) ------------ + + void vertScale(const EPS& scalop, + const ECLRegionMapping& rmap, + const std::vector& s, + std::vector& sfval) const + { + assert (rmap.regionSubset().size() == s.size()); + assert (sfval.size() == s.size()); + + if (! scalop.vertscaling) { + // No vertical scaling defined for this curve. Return + // unchanged. + return; + } + + if (! scalop.vertfuncval) { + throw std::logic_error { + "Cannot Perform Vertical Scaling in " + "Absence of Function Value Data" + }; + } + + const auto& fval_table = *scalop.vertfuncval; + + for (const auto& regID : rmap.activeRegions()) { + const auto sp = + this->getSaturationPoints(rmap, regID, s); + + // Assume 'regID' is a traditional ECL-style, one-based + // region ID (e.g., SATNUM entry). + const auto& f = fval_table[regID - 1]; + + const auto scaled_fval = + scalop.vertscaling->vertScale(f, sp, sfval); + + this->assignScaledResult(rmap, regID, scaled_fval, sfval); + } + } + + // ---------------------------------------------- + // ------- Helpers for engine functions --------- + EPSInterface::SaturationPoints getSaturationPoints(const ECLRegionMapping& rmap, const int regID, @@ -988,52 +1136,94 @@ class Opm::ECLSaturationFunc::Impl return sp; } - void - assignScaledSaturations(const ECLRegionMapping& rmap, + void assignScaledResult(const ECLRegionMapping& rmap, const int regID, - const std::vector& sr, - std::vector& s) const + const std::vector& result, + std::vector& output) const { - auto i = static_cast(0); + auto i = static_cast(0); for (const auto& ix : rmap.getRegionIndices(regID)) { - s[ix] = sr[i++]; + output[ix] = result[i++]; } } - void create_oil_eps(const ECLGraph& G, + // ---------------------------------------------- + // ---- Constructor functions for scaling ops --- + + void create_oil_eps(const Impl& host, + const ECLGraph& G, const ECLInitFileData& init, const RawTEP& ep, const ActPh& active, Create::EPSOptions& opt) { + assert (host.oil_ != nullptr); + opt.thisPh = PhIdx::Liquid; opt.curve = FCat::Relperm; // Oil EPS only applies to Kr + using SOil = Oil::KrFunction::SOil; + if (active.gas) { opt.subSys = SSys::OilGas; - this->oil_in_og_.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->oil_in_og_; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->oil_in_og_.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + const auto ssys = RawCurve::SubSystem::OilGas; + + return host.oil_-> + kro(regID, SOil{ { sat } }, ssys)[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } if (active.wat) { opt.subSys = SSys::OilWater; - this->oil_in_ow_.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->oil_in_ow_; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->oil_in_ow_.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + const auto ssys = RawCurve::SubSystem::OilWater; + + return host.oil_-> + kro(regID, SOil{ { sat } }, ssys)[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } } - void create_gas_eps(const ECLGraph& G, + void create_gas_eps(const Impl& host, + const ECLGraph& G, const ECLInitFileData& init, const RawTEP& ep, Create::EPSOptions& opt) { + assert (host.gas_ != nullptr); + opt.thisPh = PhIdx::Vapour; opt.subSys = SSys::OilGas; @@ -1041,10 +1231,23 @@ class Opm::ECLSaturationFunc::Impl { opt.curve = FCat::Relperm; - this->gas_.kr.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->gas_.kr; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); - this->gas_.kr.tep = this->endPoints(ep, opt); + eps.tep = this->endPoints(ep, opt); + + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.gas_->krg(regID, { sat })[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } // Scaling for Gas/Oil capillary pressure @@ -1056,21 +1259,37 @@ class Opm::ECLSaturationFunc::Impl opt.curve = FCat::CapPress; - this->gas_.pc.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->gas_.pc; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->gas_.pc.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.gas_->pcgo(regID, { sat })[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); // Restore original setting for Alternative scaling option. opt.use3PtScaling = use3Pt; } } - void create_wat_eps(const ECLGraph& G, + void create_wat_eps(const Impl& host, + const ECLGraph& G, const ECLInitFileData& init, const RawTEP& ep, Create::EPSOptions& opt) { + assert (host.wat_ != nullptr); + opt.thisPh = PhIdx::Aqua; opt.subSys = SSys::OilWater; @@ -1078,10 +1297,23 @@ class Opm::ECLSaturationFunc::Impl { opt.curve = FCat::Relperm; - this->wat_.kr.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->wat_.kr; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); - this->wat_.kr.tep = this->endPoints(ep, opt); + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.wat_->krw(regID, { sat })[0]; + }); + + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); } // Scaling for Oil/Water capillary pressure @@ -1093,24 +1325,49 @@ class Opm::ECLSaturationFunc::Impl opt.curve = FCat::CapPress; - this->wat_.pc.scaling = - Create::fromECLOutput(G, init, opt); + auto& eps = this->wat_.pc; + + eps.scaling = Create::Horizontal:: + fromECLOutput(G, init, opt); + + eps.tep = this->endPoints(ep, opt); + + eps.vertfuncval = this-> + vertFuncVal(G, init, ep, opt, [&host] + (const int regID, const double sat) -> double + { + return host.wat_->pcow(regID, { sat })[0]; + }); - this->wat_.pc.tep = this->endPoints(ep, opt); + eps.vertscaling = Create::Vertical:: + fromECLOutput(G, init, opt, ep, + *eps.vertfuncval); // Restore original setting for Alternative scaling option. opt.use3PtScaling = use3Pt; } - } EndPtsPtr endPoints(const RawTEP& ep, const Create::EPSOptions& opt) { return EndPtsPtr { - new EPSEndPtVec(Create::unscaledEndPoints(ep, opt)) + new EPSEndPtVec(Create::Horizontal::unscaledEndPoints(ep, opt)) }; } + + VScalFVVecPtr + vertFuncVal(const ECLGraph& G, + const ECLInitFileData& init, + const RawTEP& ep, + const Create::EPSOptions& opt, + std::function f) + { + auto val = Create::Vertical:: + unscaledFunctionValues(G, init, ep, opt, std::move(f)); + + return VScalFVVecPtr { new VSFValVec(std::move(val)) }; + } }; std::vector satnum_; @@ -1136,76 +1393,75 @@ class Opm::ECLSaturationFunc::Impl void initEPS(const EPSEvaluator::ActPh& active, const bool use3PtScaling, const ECLGraph& G, - const ECLInitFileData& init, - const InvalidEPBehaviour handle_invalid); + const ECLInitFileData& init); void setNumTables(const ECLPropTableRawData::SizeType ntab); std::vector kro(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS = true) const; + const SatFuncScaling& scaling = SatFuncScaling{}) const; FlowDiagnostics::Graph kroCurve(const ECLRegionMapping& rmap, const std::size_t regID, const RawCurve::SubSystem subsys, const std::vector& so, - const bool useEPS) const; + const SatFuncScaling& scaling) const; std::vector krg(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS = true) const; + const SatFuncScaling& scaling = SatFuncScaling{}) const; FlowDiagnostics::Graph krgCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const; + const SatFuncScaling& scaling) const; FlowDiagnostics::Graph pcgoCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const; + const SatFuncScaling& scaling) const; std::vector krw(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS = true) const; + const SatFuncScaling& scaling = SatFuncScaling{}) const; FlowDiagnostics::Graph krwCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const; + const SatFuncScaling& scaling) const; FlowDiagnostics::Graph pcowCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const; + const SatFuncScaling& scaling) const; void scaleKrGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const; void scalePcGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const; void scaleKrOilSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& so_g, std::vector& so_w) const; void scaleKrWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sw) const; void scalePcWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sw) const; void uniqueReverseScaleSat(std::vector& s) const; @@ -1303,10 +1559,8 @@ Opm::ECLSaturationFunc::Impl::Impl(const Impl& rhs) // --------------------------------------------------------------------- void -Opm::ECLSaturationFunc::Impl::init(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS, - const InvalidEPBehaviour handle_invalid) +Opm::ECLSaturationFunc::Impl::init(const ECLGraph& G, + const ECLInitFileData& init) { // Extract INTEHEAD from main grid const auto& ih = init.keywordData(INTEHEAD_KW); @@ -1316,19 +1570,18 @@ Opm::ECLSaturationFunc::Impl::init(const ECLGraph& G, this->initRelPermInterp(active, init, ih[INTEHEAD_UNIT_INDEX]); - if (useEPS) { - const auto& lh = init.keywordData(LOGIHEAD_KW); + // Activate saturation function scaling if present in result set. + const auto& lh = init.keywordData(LOGIHEAD_KW); - const auto haveEPS = static_cast( - lh[LOGIHEAD_ENDPOINT_SCALING_INDEX]); + const auto haveEPS = static_cast( + lh[LOGIHEAD_ENDPOINT_SCALING_INDEX]); - if (haveEPS) { - const auto use3PtScaling = static_cast( - lh[LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX]); + if (haveEPS) { + const auto use3PtScaling = static_cast( + lh[LOGIHEAD_ALT_ENDPOINT_SCALING_INDEX]); - // Must be called *after* initRelPermInterp(). - this->initEPS(active, use3PtScaling, G, init, handle_invalid); - } + // Must be called *after* initRelPermInterp(). + this->initEPS(active, use3PtScaling, G, init); } } @@ -1394,14 +1647,15 @@ void Opm::ECLSaturationFunc:: Impl::initEPS(const EPSEvaluator::ActPh& active, const bool use3PtScaling, const ECLGraph& G, - const ECLInitFileData& init, - const InvalidEPBehaviour handle_invalid) + const ECLInitFileData& init) { const auto ep = this->extractRawTableEndPoints(active); this->eps_.reset(new EPSEvaluator()); - this->eps_->define(G, init, ep, use3PtScaling, active, handle_invalid); + if (this->eps_ != nullptr) { + this->eps_->define(*this, G, init, ep, use3PtScaling, active); + } } void Opm::ECLSaturationFunc:: @@ -1457,7 +1711,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: getSatFuncCurve(const std::vector& func, const int activeCell, - const bool useEPS) const + const SatFuncScaling& scaling) const { using SatPointAssoc = std::pair< std::vector, @@ -1501,9 +1755,9 @@ getSatFuncCurve(const std::vector& func, auto crv = (fi.curve == RawCurve::Function::RelPerm) ? this->krwCurve (*wat_assoc.second, regID, - wat_assoc.first, useEPS) + wat_assoc.first, scaling) : this->pcowCurve(*wat_assoc.second, regID, - wat_assoc.first, useEPS); + wat_assoc.first, scaling); graph.push_back(std::move(crv)); } @@ -1532,7 +1786,7 @@ getSatFuncCurve(const std::vector& func, const auto kro = this->kroCurve(*oil_assoc.second, regID, - fi.subsys, oil_assoc.first, useEPS); + fi.subsys, oil_assoc.first, scaling); const auto So_off = (fi.subsys == RawCurve::SubSystem::OilGas) ? oil_assoc.first.back() // Sg = Max{So} - So in G/O system @@ -1568,9 +1822,9 @@ getSatFuncCurve(const std::vector& func, auto crv = (fi.curve == RawCurve::Function::RelPerm) ? this->krgCurve (*gas_assoc.second, regID, - gas_assoc.first, useEPS) + gas_assoc.first, scaling) : this->pcgoCurve(*gas_assoc.second, regID, - gas_assoc.first, useEPS); + gas_assoc.first, scaling); graph.push_back(std::move(crv)); } @@ -1588,7 +1842,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: kro(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS) const + const SatFuncScaling& scaling) const { auto kr = std::vector{}; @@ -1602,7 +1856,7 @@ kro(const ECLGraph& G, auto so_g = oil_saturation(sg, sw, G, rstrt); auto so_w = so_g; - this->scaleKrOilSat(this->rmap_, useEPS, so_g, so_w); + this->scaleKrOilSat(this->rmap_, scaling, so_g, so_w); // Allocate result. Member function scatterRegionResult() depends on // having an allocated result vector into which to write the values from @@ -1650,7 +1904,7 @@ kroCurve(const ECLRegionMapping& rmap, const std::size_t regID, const RawCurve::SubSystem subsys, const std::vector& so, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->oil_) { return FlowDiagnostics::Graph{}; @@ -1658,7 +1912,7 @@ kroCurve(const ECLRegionMapping& rmap, auto so_g = so; auto so_w = so_g; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScaleKrOG(rmap, so_g); this->eps_->reverseScaleKrOW(rmap, so_w); @@ -1681,7 +1935,7 @@ kroCurve(const ECLRegionMapping& rmap, so_g.resize(so.size(), 1.0); so_w.resize(so.size(), 1.0); - this->scaleKrOilSat(rmap, useEPS, so_g, so_w); + this->scaleKrOilSat(rmap, scaling, so_g, so_w); const auto so_inp = Oil::KrFunction::SOil { (subsys == RawCurve::SubSystem::OilGas) ? so_g : so_w @@ -1689,7 +1943,19 @@ kroCurve(const ECLRegionMapping& rmap, // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. - const auto kr = this->oil_->kro(regID - 1, so_inp, subsys); + auto kr = this->oil_->kro(regID - 1, so_inp, subsys); + + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + if (subsys == RawCurve::SubSystem::OilGas) { + this->eps_->vertScaleKrOG(rmap, so, kr); + } + else { + this->eps_->vertScaleKrOW(rmap, so, kr); + } + } // FD::Graph == pair, vector> return FlowDiagnostics::Graph { @@ -1702,7 +1968,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: krg(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS) const + const SatFuncScaling& scaling) const { auto kr = std::vector{}; @@ -1712,7 +1978,7 @@ krg(const ECLGraph& G, auto sg = G.rawLinearisedCellData(rstrt, "SGAS"); - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrGas(this->rmap_, sg); } @@ -1745,14 +2011,14 @@ Opm::ECLSaturationFunc::Impl:: krgCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->gas_) { return FlowDiagnostics::Graph{}; } auto sg_inp = sg; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScaleKrGas(rmap, sg_inp); this->uniqueReverseScaleSat(sg_inp); } @@ -1769,11 +2035,18 @@ krgCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sg_inp.resize(sg.size(), 1.0); - this->scaleKrGasSat(rmap, useEPS, sg_inp); + this->scaleKrGasSat(rmap, scaling, sg_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. - const auto kr = this->gas_->krg(regID - 1, sg_inp); + auto kr = this->gas_->krg(regID - 1, sg_inp); + + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScaleKrGas(rmap, sg, kr); + } // FD::Graph == pair, vector> return FlowDiagnostics::Graph { @@ -1787,14 +2060,14 @@ Opm::ECLSaturationFunc::Impl:: pcgoCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sg, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->gas_) { return FlowDiagnostics::Graph{}; } auto sg_inp = sg; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScalePcGO(rmap, sg_inp); this->uniqueReverseScaleSat(sg_inp); } @@ -1811,12 +2084,19 @@ pcgoCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sg_inp.resize(sg.size(), 1.0); - this->scalePcGasSat(rmap, useEPS, sg_inp); + this->scalePcGasSat(rmap, scaling, sg_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. auto pc = this->gas_->pcgo(regID - 1, sg_inp); + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScalePcGO(rmap, sg, pc); + } + if (this->usys_output_ != nullptr) { ::Opm::ECLUnits::Convert::Pressure() .from(*this->usys_internal_) @@ -1834,7 +2114,7 @@ std::vector Opm::ECLSaturationFunc::Impl:: krw(const ECLGraph& G, const ECLRestartData& rstrt, - const bool useEPS) const + const SatFuncScaling& scaling) const { auto kr = std::vector{}; @@ -1844,7 +2124,7 @@ krw(const ECLGraph& G, auto sw = G.rawLinearisedCellData(rstrt, "SWAT"); - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrWat(this->rmap_, sw); } @@ -1877,14 +2157,14 @@ Opm::ECLSaturationFunc::Impl:: krwCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->wat_) { return FlowDiagnostics::Graph{}; } auto sw_inp = sw; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScaleKrWat(rmap, sw_inp); this->uniqueReverseScaleSat(sw_inp); } @@ -1901,11 +2181,18 @@ krwCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sw_inp.resize(sw.size(), 1.0); - this->scaleKrWaterSat(rmap, useEPS, sw_inp); + this->scaleKrWaterSat(rmap, scaling, sw_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. - const auto kr = this->wat_->krw(regID - 1, sw_inp); + auto kr = this->wat_->krw(regID - 1, sw_inp); + + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScaleKrWat(rmap, sw, kr); + } // FD::Graph == pair, vector> return FlowDiagnostics::Graph { @@ -1919,14 +2206,14 @@ Opm::ECLSaturationFunc::Impl:: pcowCurve(const ECLRegionMapping& rmap, const std::size_t regID, const std::vector& sw, - const bool useEPS) const + const SatFuncScaling& scaling) const { if (! this->wat_) { return FlowDiagnostics::Graph{}; } auto sw_inp = sw; - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->reverseScalePcOW(rmap, sw_inp); this->uniqueReverseScaleSat(sw_inp); } @@ -1943,12 +2230,19 @@ pcowCurve(const ECLRegionMapping& rmap, // Re-expand input arrays to match size requirements of EPS evaluator. sw_inp.resize(sw.size(), 1.0); - this->scalePcWaterSat(rmap, useEPS, sw_inp); + this->scalePcWaterSat(rmap, scaling, sw_inp); // Region ID 'reg' is traditional, ECL-style one-based region ID // (SATNUM). Subtract one to create valid table index. auto pc = this->wat_->pcow(regID - 1, sw_inp); + if (enableVerticalSFScaling(scaling) && + (this->eps_ != nullptr)) + { + // Evaluate vertical scaling in input saturations. + this->eps_->vertScalePcOW(rmap, sw, pc); + } + if (this->usys_output_ != nullptr) { ::Opm::ECLUnits::Convert::Pressure() .from(*this->usys_internal_) @@ -1965,10 +2259,10 @@ pcowCurve(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scaleKrGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrGas(rmap, sg); } } @@ -1976,10 +2270,10 @@ scaleKrGasSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scalePcGasSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scalePcGO(rmap, sg); } } @@ -1987,11 +2281,11 @@ scalePcGasSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scaleKrOilSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& so_g, std::vector& so_w) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { // Independent scaling of So in O/G and O/W sub-systems of an O/G/W // run. Performs duplicate work in a two-phase case. Need to take // action if this becomes a bottleneck. @@ -2003,10 +2297,10 @@ scaleKrOilSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scaleKrWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scaleKrWat(rmap, sg); } } @@ -2014,10 +2308,10 @@ scaleKrWaterSat(const ECLRegionMapping& rmap, void Opm::ECLSaturationFunc::Impl:: scalePcWaterSat(const ECLRegionMapping& rmap, - const bool useEPS, + const SatFuncScaling& scaling, std::vector& sg) const { - if (useEPS && this->eps_) { + if (enableHorizontalEPS(scaling) && this->eps_) { this->eps_->scalePcOW(rmap, sg); } } @@ -2087,13 +2381,11 @@ extractRawTableEndPoints(const EPSEvaluator::ActPh& active) const // ===================================================================== Opm::ECLSaturationFunc:: -ECLSaturationFunc(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS, - const InvalidEPBehaviour handle_invalid) +ECLSaturationFunc(const ECLGraph& G, + const ECLInitFileData& init) : pImpl_(new Impl(G, init)) { - this->pImpl_->init(G, init, useEPS, handle_invalid); + this->pImpl_->init(G, init); } Opm::ECLSaturationFunc::~ECLSaturationFunc() @@ -2145,5 +2437,20 @@ getSatFuncCurve(const std::vector& func, const int activeCell, const bool useEPS) const { - return this->pImpl_->getSatFuncCurve(func, activeCell, useEPS); + auto scaling = SatFuncScaling{}; + + if (! useEPS) { + scaling.enable = static_cast(0); + } + + return this->getSatFuncCurve(func, activeCell, scaling); +} + +std::vector +Opm::ECLSaturationFunc:: +getSatFuncCurve(const std::vector& func, + const int activeCell, + const SatFuncScaling& scaling) const +{ + return this->pImpl_->getSatFuncCurve(func, activeCell, scaling); } diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp index 52da556bcc..ff9926d0aa 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLSaturationFunc.hpp @@ -79,8 +79,26 @@ namespace Opm { ECLPhaseIndex thisPh; }; - using InvalidEPBehaviour = ::Opm::SatFunc:: - EPSEvalInterface::InvalidEndpointBehaviour; + struct SatFuncScaling { + enum Type : unsigned char { + Horizontal = 1 << 0u, + Vertical = 1 << 1u, + }; + + using IEB = SatFunc::EPSEvalInterface::InvalidEndpointBehaviour; + + SatFuncScaling() + : enable (Type::Horizontal | Type::Vertical) + , invalid(IEB::UseUnscaled) + {} + + // Default: Use both Horizontal and Vertical if specified. + unsigned char enable; + + // Default: Use unscaled values in case of invalid scaled + // saturations occurring in the result set. + IEB invalid; + }; /// Constructor /// @@ -92,27 +110,8 @@ namespace Opm { /// \param[in] init Container of tabulated saturation functions and /// saturation table end points, if applicable, for all active /// cells in the model \p G. - /// - /// \param[in] useEPS Whether or not to include effects of - /// saturation end-point scaling. No effect if the INIT result - /// set does not actually include saturation end-point scaling - /// data. Otherwise, enables turning EPS off even if associate - /// data is present in the INIT result set. - /// - /// Default value (\c true) means that effects of EPS are - /// included if requisite data is present in the INIT result. - /// - /// \param[in] handle_invalid Run-time policy for how to handle - /// scaling requests relative to invalid scaled saturations - /// (e.g., SWL = -1.0E+20). - /// - /// Default value (\c UseUnscaled) means that invalid scalings - /// are treated as unscaled. - ECLSaturationFunc(const ECLGraph& G, - const ECLInitFileData& init, - const bool useEPS = true, - const InvalidEPBehaviour handle_invalid - = InvalidEPBehaviour::UseUnscaled); + ECLSaturationFunc(const ECLGraph& G, + const ECLInitFileData& init); /// Destructor. ~ECLSaturationFunc(); @@ -253,6 +252,69 @@ namespace Opm { const int activeCell, const bool useEPS = true) const; + /// Retrieve 2D graph representations of sequence of effective + /// saturation functions in a single cell. + /// + /// \param[in] func Sequence of saturation function descriptions. + /// + /// \param[in] activeCell Index of active cell from which to derive + /// the effective saturation function. Use member function \code + /// ECLGraph::activeCell() \endcode to translate a global cell + /// (I,J,K) tuple--relative to a model grid--to a linear active + /// cell ID. + /// + /// \param[in] scaling Which type of saturation function scaling to + /// apply. No effect if the INIT result set from which the + /// object was constructed does not actually include saturation + /// end-point scaling or function value scaling data. Otherwise, + /// enables turning various scaling effects on or off even if + /// associate data is present in the INIT result set. + /// + /// \return Sequence of 2D graphs for all saturation function + /// requests represented by \p func. In particular, the \c i-th + /// element of the result corresponds to input request \code + /// func[i] \endcode. Abscissas are stored in \code + /// graph[i].first \endcode and ordinates are stored in \code + /// graph[i].second \endcode. If a particular request is + /// semantically invalid, such as when requesting the water + /// relative permeability in the oil-gas system, then the + /// corresponding graph in the result is empty. + /// + /// Example: Retrieve relative permeability curves for oil in active + /// cell 2718 in both the oil-gas and oil-water sub-systems + /// including effects of vertical scaling only. + /// + /// \code + /// using RC = ECLSaturationFunc::RawCurve; + /// auto func = std::vector{}; + /// func.reserve(2); + /// + /// // Request krog (oil rel-perm in oil-gas system) + /// func.push_back(RC{ + /// RC::Function::RelPerm, + /// RC::SubSystem::OilGas, + /// ECLPhaseIndex::Liquid + /// }); + /// + /// // Request krow (oil rel-perm in oil-water system) + /// func.push_back(RC{ + /// RC::Function::RelPerm, + /// RC::SubSystem::OilWater, + /// ECLPhaseIndex::Liquid + /// }); + /// + /// auto scaling = SatFuncScaling{}; + /// scaling.enable = static_cast(0); + /// scaling.enable |= SatFuncScaling::Type::Vertical; + /// + /// const auto graph = + /// sfunc.getSatFuncCurve(func, 2718, scaling); + /// \endcode + std::vector + getSatFuncCurve(const std::vector& func, + const int activeCell, + const SatFuncScaling& scaling) const; + private: /// Implementation backend. class Impl; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp index 3d2815d5c9..7cd052ec8c 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLUnitHandling.cpp @@ -23,7 +23,7 @@ #include -#include +#include #include #include @@ -38,6 +38,8 @@ namespace Opm { namespace ECLUnits { template class USys; + using namespace ImportedOpm; + template <> class USys : public ::Opm::ECLUnits::UnitSystem { diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp index 78a477fddd..673ecc8546 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/ECLWellSolution.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -217,6 +217,7 @@ namespace Opm for (int well = 0; well < ih.nwell; ++well) { // Skip if total rate below threshold (for wells that are // shut or stopped for example). + using namespace ImportedOpm; const double well_reservoir_inflow_rate = -unit::convert::from(xwel[well * ih.nxwel + XWEL_RESV_INDEX], qr_unit); if (std::fabs(well_reservoir_inflow_rate) < rate_threshold_) { continue; diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp new file mode 100644 index 0000000000..3c3f74deb1 --- /dev/null +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/opm/utility/imported/Units.hpp @@ -0,0 +1,367 @@ +//=========================================================================== +// +// File: Units.hpp +// +// Created: Thu Jul 2 09:19:08 2009 +// +// Author(s): Halvor M Nilsen +// +// $Date$ +// +// $Revision$ +// +//=========================================================================== + +/* + Copyright 2009, 2010, 2011, 2012 SINTEF ICT, Applied Mathematics. + Copyright 2009, 2010, 2011, 2012 Statoil ASA. + + This file is part of the Open Porous Media project (OPM). + + OPM 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. + + OPM 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 for more details. + + You should have received a copy of the GNU General Public License + along with OPM. If not, see . +*/ + +#ifndef IMPORTED_OPM_UNITS_HEADER +#define IMPORTED_OPM_UNITS_HEADER + + +// WARNING! +// This file is a modified duplicate, imported to make this module independent. +// Modifications include file location, the header guard, and using the ImportedOpm namespace. + + +/** + The unit sets emplyed in ECLIPSE, in particular the FIELD units, + are quite inconsistent. Ideally one should choose units for a set + of base quantities like Mass,Time and Length and then derive the + units for e.g. pressure and flowrate in a consisten manner. However + that is not the case; for instance in the metric system we have: + + [Length] = meters + [time] = days + [mass] = kg + + This should give: + + [Pressure] = [mass] / ([length] * [time]^2) = kg / (m * days * days) + + Instead pressure is given in Bars. When it comes to FIELD units the + number of such examples is long. +*/ +namespace ImportedOpm { + namespace prefix + /// Conversion prefix for units. + { + constexpr const double micro = 1.0e-6; /**< Unit prefix [\f$\mu\f$] */ + constexpr const double milli = 1.0e-3; /**< Unit prefix [m] */ + constexpr const double centi = 1.0e-2; /**< Non-standard unit prefix [c] */ + constexpr const double deci = 1.0e-1; /**< Non-standard unit prefix [d] */ + constexpr const double kilo = 1.0e3; /**< Unit prefix [k] */ + constexpr const double mega = 1.0e6; /**< Unit prefix [M] */ + constexpr const double giga = 1.0e9; /**< Unit prefix [G] */ + } // namespace prefix + + namespace unit + /// Definition of various units. + /// All the units are defined in terms of international standard + /// units (SI). Example of use: We define a variable \c k which + /// gives a permeability. We want to set \c k to \f$1\,mD\f$. + /// \code + /// using namespace Opm::unit + /// double k = 0.001*darcy; + /// \endcode + /// We can also use one of the prefixes defined in Opm::prefix + /// \code + /// using namespace Opm::unit + /// using namespace Opm::prefix + /// double k = 1.0*milli*darcy; + /// \endcode + { + ///\name Common powers + /// @{ + constexpr double square(double v) { return v * v; } + constexpr double cubic (double v) { return v * v * v; } + /// @} + + // -------------------------------------------------------------- + // Basic (fundamental) units and conversions + // -------------------------------------------------------------- + + /// \name Length + /// @{ + constexpr const double meter = 1; + constexpr const double inch = 2.54 * prefix::centi*meter; + constexpr const double feet = 12 * inch; + /// @} + + /// \name Time + /// @{ + constexpr const double second = 1; + constexpr const double minute = 60 * second; + constexpr const double hour = 60 * minute; + constexpr const double day = 24 * hour; + constexpr const double year = 365 * day; + /// @} + + /// \name Volume + /// @{ + constexpr const double gallon = 231 * cubic(inch); + constexpr const double stb = 42 * gallon; + constexpr const double liter = 1 * cubic(prefix::deci*meter); + /// @} + + /// \name Mass + /// @{ + constexpr const double kilogram = 1; + constexpr const double gram = 1.0e-3 * kilogram; + // http://en.wikipedia.org/wiki/Pound_(mass)#Avoirdupois_pound + constexpr const double pound = 0.45359237 * kilogram; + /// @} + + /// \name Energy + /// @{ + constexpr const double joule = 1; + constexpr const double btu = 1054.3503*joule; // "british thermal units" + /// @} + + // -------------------------------------------------------------- + // Standardised constants + // -------------------------------------------------------------- + + /// \name Standardised constant + /// @{ + constexpr const double gravity = 9.80665 * meter/square(second); + /// @} + + // -------------------------------------------------------------- + // Derived units and conversions + // -------------------------------------------------------------- + + /// \name Force + /// @{ + constexpr const double Newton = kilogram*meter / square(second); // == 1 + constexpr const double dyne = 1e-5*Newton; + constexpr const double lbf = pound * gravity; // Pound-force + /// @} + + /// \name Pressure + /// @{ + constexpr const double Pascal = Newton / square(meter); // == 1 + constexpr const double barsa = 100000 * Pascal; + constexpr const double atm = 101325 * Pascal; + constexpr const double psia = lbf / square(inch); + /// @} + + /// \name Temperature. This one is more complicated + /// because the unit systems used by Eclipse (i.e. degrees + /// Celsius and degrees Fahrenheit require to add or + /// subtract an offset for the conversion between from/to + /// Kelvin + /// @{ + constexpr const double degCelsius = 1.0; // scaling factor °C -> K + constexpr const double degCelsiusOffset = 273.15; // offset for the °C -> K conversion + + constexpr const double degFahrenheit = 5.0/9; // scaling factor °F -> K + constexpr const double degFahrenheitOffset = 255.37; // offset for the °C -> K conversion + /// @} + + /// \name Viscosity + /// @{ + constexpr const double Pas = Pascal * second; // == 1 + constexpr const double Poise = prefix::deci*Pas; + /// @} + + namespace perm_details { + constexpr const double p_grad = atm / (prefix::centi*meter); + constexpr const double area = square(prefix::centi*meter); + constexpr const double flux = cubic (prefix::centi*meter) / second; + constexpr const double velocity = flux / area; + constexpr const double visc = prefix::centi*Poise; + constexpr const double darcy = (velocity * visc) / p_grad; + // == 1e-7 [m^2] / 101325 + // == 9.869232667160130e-13 [m^2] + } + /// \name Permeability + /// @{ + /// + /// A porous medium with a permeability of 1 darcy permits a flow (flux) + /// of \f$1\,\mathit{cm}^3/s\f$ of a fluid with viscosity + /// \f$1\,\mathit{cP}\f$ (\f$1\,mPa\cdot s\f$) under a pressure gradient + /// of \f$1\,\mathit{atm}/\mathit{cm}\f$ acting across an area of + /// \f$1\,\mathit{cm}^2\f$. + /// + constexpr const double darcy = perm_details::darcy; + /// @} + + /** + * Unit conversion routines. + */ + namespace convert { + /** + * Convert from external units of measurements to equivalent + * internal units of measurements. Note: The internal units of + * measurements are *ALWAYS*, and exclusively, SI. + * + * Example: Convert a double @c kx, containing a permeability value + * in units of milli-darcy (mD) to the equivalent value in SI units + * (i.e., \f$m^2\f$). + * \code + * using namespace Opm::unit; + * using namespace Opm::prefix; + * convert::from(kx, milli*darcy); + * \endcode + * + * @param[in] q Physical quantity. + * @param[in] unit Physical unit of measurement. + * @return Value of @c q in equivalent SI units of measurements. + */ + constexpr double from(const double q, const double unit) + { + return q * unit; + } + + /** + * Convert from internal units of measurements to equivalent + * external units of measurements. Note: The internal units of + * measurements are *ALWAYS*, and exclusively, SI. + * + * Example: Convert a std::vector p, containing + * pressure values in the SI unit Pascal (i.e., unit::Pascal) to the + * equivalent values in Psi (unit::psia). + * \code + * using namespace Opm::unit; + * std::transform(p.begin(), p.end(), p.begin(), + * boost::bind(convert::to, _1, psia)); + * \endcode + * + * @param[in] q Physical quantity, measured in SI units. + * @param[in] unit Physical unit of measurement. + * @return Value of @c q in unit unit. + */ + constexpr double to(const double q, const double unit) + { + return q / unit; + } + } // namespace convert + } + + namespace Metric { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = barsa; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = meter; + constexpr const double Time = day; + constexpr const double Mass = kilogram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*barsa); + constexpr const double LiquidSurfaceVolume = cubic(meter); + constexpr const double GasSurfaceVolume = cubic(meter); + constexpr const double ReservoirVolume = cubic(meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = kilogram/cubic(meter); + constexpr const double PolymerDensity = kilogram/cubic(meter); + constexpr const double Salinity = kilogram/cubic(meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = kilo*joule; + } + + + namespace Field { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = psia; + constexpr const double Temperature = degFahrenheit; + constexpr const double TemperatureOffset = degFahrenheitOffset; + constexpr const double AbsoluteTemperature = degFahrenheit; // actually [°R], but the these two are identical + constexpr const double Length = feet; + constexpr const double Time = day; + constexpr const double Mass = pound; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*stb/(day*psia); + constexpr const double LiquidSurfaceVolume = stb; + constexpr const double GasSurfaceVolume = 1000*cubic(feet); + constexpr const double ReservoirVolume = stb; + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = pound/cubic(feet); + constexpr const double PolymerDensity = pound/stb; + constexpr const double Salinity = pound/stb; + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = btu; + } + + + namespace Lab { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = atm; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = centi*meter; + constexpr const double Time = hour; + constexpr const double Mass = gram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(centi*meter)/(hour*atm); + constexpr const double LiquidSurfaceVolume = cubic(centi*meter); + constexpr const double GasSurfaceVolume = cubic(centi*meter); + constexpr const double ReservoirVolume = cubic(centi*meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = gram/cubic(centi*meter); + constexpr const double PolymerDensity = gram/cubic(centi*meter); + constexpr const double Salinity = gram/cubic(centi*meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = hour; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = joule; + } + + + namespace PVT_M { + using namespace prefix; + using namespace unit; + constexpr const double Pressure = atm; + constexpr const double Temperature = degCelsius; + constexpr const double TemperatureOffset = degCelsiusOffset; + constexpr const double AbsoluteTemperature = degCelsius; // actually [K], but the these two are identical + constexpr const double Length = meter; + constexpr const double Time = day; + constexpr const double Mass = kilogram; + constexpr const double Permeability = milli*darcy; + constexpr const double Transmissibility = centi*Poise*cubic(meter)/(day*atm); + constexpr const double LiquidSurfaceVolume = cubic(meter); + constexpr const double GasSurfaceVolume = cubic(meter); + constexpr const double ReservoirVolume = cubic(meter); + constexpr const double GasDissolutionFactor = GasSurfaceVolume/LiquidSurfaceVolume; + constexpr const double OilDissolutionFactor = LiquidSurfaceVolume/GasSurfaceVolume; + constexpr const double Density = kilogram/cubic(meter); + constexpr const double PolymerDensity = kilogram/cubic(meter); + constexpr const double Salinity = kilogram/cubic(meter); + constexpr const double Viscosity = centi*Poise; + constexpr const double Timestep = day; + constexpr const double SurfaceTension = dyne/(centi*meter); + constexpr const double Energy = kilo*joule; + } +} + +#endif // IMPORTED_OPM_UNITS_HEADER diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp index cca335b6e2..6c00681263 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/runLinearisedCellDataTest.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include #include #include @@ -58,11 +58,11 @@ namespace StringUtils { std::string trim(const std::string& s) { const auto anchor_ws = - boost::regex(R"~~(^\s+([^\s]+)\s+$)~~"); + std::regex(R"~~(^\s+([^\s]+)\s+$)~~"); - auto m = boost::smatch{}; + auto m = std::smatch{}; - if (boost::regex_match(s, m, anchor_ws)) { + if (std::regex_match(s, m, anchor_ws)) { return m[1]; } @@ -77,9 +77,9 @@ namespace StringUtils { return { "" }; } - const auto sep = boost::regex(R"~~([\s,;.|]+)~~"); + const auto sep = std::regex(R"~~([\s,;.|]+)~~"); - using TI = boost::sregex_token_iterator; + using TI = std::sregex_token_iterator; // vector(begin, end) // diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp index 7bef5298bc..b666f08109 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclendpointscaling.cpp @@ -21,10 +21,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLENDPOINTSCALING @@ -36,6 +32,7 @@ #include #include +#include #include #include @@ -72,6 +69,116 @@ namespace { return sp; } + + std::vector sw_core1d_example() + { + return { + 1.700000000000000e-01, + 1.861700000000000e-01, + 2.023400000000000e-01, + 2.185110000000000e-01, + 2.346810000000000e-01, + 2.508510000000000e-01, + 2.670210000000000e-01, + 2.831910000000000e-01, + 2.993620000000000e-01, + 3.155320000000000e-01, + 3.317020000000000e-01, + 3.478720000000000e-01, + 3.640430000000000e-01, + 3.802130000000000e-01, + 3.963830000000000e-01, + 4.125530000000000e-01, + 4.287230000000000e-01, + 4.448940000000000e-01, + 4.610640000000000e-01, + 4.772340000000000e-01, + 4.934040000000000e-01, + 5.095740000000000e-01, + 5.257450000000000e-01, + 5.419150000000000e-01, + 5.580850000000001e-01, + 5.742550000000000e-01, + 5.904260000000000e-01, + 6.065960000000000e-01, + 6.227660000000000e-01, + 6.389359999999999e-01, + 6.551060000000000e-01, + 6.712770000000000e-01, + 6.874470000000000e-01, + 7.036170000000000e-01, + 7.197870000000000e-01, + 7.359570000000000e-01, + 7.521280000000000e-01, + 7.682980000000000e-01, + 7.844680000000001e-01, + 8.006380000000000e-01, + 8.168090000000000e-01, + 8.329790000000000e-01, + 8.491490000000000e-01, + 8.653189999999999e-01, + 8.814890000000000e-01, + 8.976600000000000e-01, + 9.138300000000000e-01, + 9.300000000000000e-01, + 1.000000000000000e+00, + }; + } + + std::vector krw_core1d_example() + { + return { + 0, + 4.526940000000000e-04, + 1.810770000000000e-03, + 4.074240000000000e-03, + 7.243100000000000e-03, + 1.131730000000000e-02, + 1.629700000000000e-02, + 2.218200000000000e-02, + 2.897240000000000e-02, + 3.666820000000000e-02, + 4.526940000000000e-02, + 5.477590000000000e-02, + 6.518789999999999e-02, + 7.650520000000000e-02, + 8.872790000000000e-02, + 1.018560000000000e-01, + 1.158900000000000e-01, + 1.308280000000000e-01, + 1.466730000000000e-01, + 1.634220000000000e-01, + 1.810770000000000e-01, + 1.996380000000000e-01, + 2.191040000000000e-01, + 2.394750000000000e-01, + 2.607510000000000e-01, + 2.829330000000000e-01, + 3.060210000000000e-01, + 3.300140000000000e-01, + 3.549120000000000e-01, + 3.807150000000000e-01, + 4.074240000000000e-01, + 4.350380000000000e-01, + 4.635580000000000e-01, + 4.929830000000000e-01, + 5.233139999999999e-01, + 5.545500000000000e-01, + 5.866910000000000e-01, + 6.197370000000000e-01, + 6.536890000000000e-01, + 6.885470000000000e-01, + 7.243100000000000e-01, + 7.609780000000000e-01, + 7.985510000000000e-01, + 8.370300000000001e-01, + 8.764150000000001e-01, + 9.167040000000000e-01, + 9.579000000000000e-01, + 1.000000000000000e+00, + 1.000000000000000e+00, + }; + } } // Namespace Anonymous // ===================================================================== @@ -631,3 +738,330 @@ BOOST_AUTO_TEST_CASE (ScaledConnate) } BOOST_AUTO_TEST_SUITE_END () + +// ===================================================================== +// Pure vertical scaling of SF values. +// --------------------------------------------------------------------- + +BOOST_AUTO_TEST_SUITE (PureVerticalScaling_SFValues) + +BOOST_AUTO_TEST_CASE (Parabola_ScaledCell) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + // val = linspace(0, 1, 11) .^ 2 + const auto val = std::vector { + 0, + 1.0e-02, + 4.0e-02, + 9.0e-02, + 1.6e-01, + 2.5e-01, + 3.6e-01, + 4.9e-01, + 6.4e-01, + 8.1e-01, + 1.0e+00, + }; + + // Maximum value in cell is 0.5. + const auto scaler = Opm::SatFunc::PureVerticalScaling({ 0.5 }); + + // This is a lie. We do however not actually use the sp[i].sat values + // in *this particular application (pure v-scaling)* though--we only + // care about sp[i].cell--so we can get away with pretending that the + // function values (val) are saturations. + const auto sp = associate(val); + + const auto f = SFVal{ + SFPt{ 0.0, 0.0 }, // Displacement + SFPt{ 1.0, 1.0 }, // Maximum + }; + + const auto y = scaler.vertScale(f, sp, val); + + // expect = 0.5 * val + const auto expect = std::vector { + 0, + 5.00e-03, + 2.00e-02, + 4.50e-02, + 8.00e-02, + 1.25e-01, + 1.80e-01, + 2.45e-01, + 3.20e-01, + 4.05e-01, + 5.00e-01, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_CASE (Parabola_ScaledFunc) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + // val = linspace(0, 1, 11) .^ 2 + const auto val = std::vector { + 0, + 1.0e-02, + 4.0e-02, + 9.0e-02, + 1.6e-01, + 2.5e-01, + 3.6e-01, + 4.9e-01, + 6.4e-01, + 8.1e-01, + 1.0e+00, + }; + + // Maximum value in cell is 1. + const auto scaler = Opm::SatFunc::PureVerticalScaling({ 1.0 }); + + // This is a lie. We do however not actually use the sp[i].sat values + // in *this particular application (pure v-scaling)* though--we only + // care about sp[i].cell--so we can get away with pretending that the + // function values (val) are saturations. + const auto sp = associate(val); + + const auto f = SFVal{ + SFPt{ 0.0, 0.0 }, // Displacement + SFPt{ 1.0, 2.0 }, // Maximum + }; + + const auto y = scaler.vertScale(f, sp, val); + + // expect = val / 2 + const auto expect = std::vector { + 0, + 5.00e-03, + 2.00e-02, + 4.50e-02, + 8.00e-02, + 1.25e-01, + 1.80e-01, + 2.45e-01, + 3.20e-01, + 4.05e-01, + 5.00e-01, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_CASE (Parabola_ScaledBoth) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + // val = linspace(0, 1, 11) .^ 2 + const auto val = std::vector { + 0, + 1.0e-02, + 4.0e-02, + 9.0e-02, + 1.6e-01, + 2.5e-01, + 3.6e-01, + 4.9e-01, + 6.4e-01, + 8.1e-01, + 1.0e+00, + }; + + // Maximum value in cell is 1.5. + const auto scaler = Opm::SatFunc::PureVerticalScaling({ 1.5 }); + + // This is a lie. We do however not actually use the sp[i].sat values + // in *this particular application (pure v-scaling)* though--we only + // care about sp[i].cell--so we can get away with pretending that the + // function values (val) are saturations. + const auto sp = associate(val); + + const auto f = SFVal{ + SFPt{ 0.0, 0.0 }, // Displacement + SFPt{ 1.0, 2.0 }, // Maximum + }; + + const auto y = scaler.vertScale(f, sp, val); + + // expect = val * 0.75 + const auto expect = std::vector { + 0, + 7.500e-03, + 3.000e-02, + 6.750e-02, + 1.200e-01, + 1.875e-01, + 2.700e-01, + 3.675e-01, + 4.800e-01, + 6.075e-01, + 7.500e-01, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_SUITE_END () + +// ===================================================================== +// Critical saturation vertical scaling of SF values. +// --------------------------------------------------------------------- + +BOOST_AUTO_TEST_SUITE (CritSatVScale_SFValues) + +/* + sw = 0.1 : 0.05 : 0.9; + kr = sw .^ 2; + + [sdisp, fdisp, fmax] = deal(0.7, 0.6, 0.7); + + i = ~ (sw > sdisp); + y = 0 * kr; + y( i) = kr(i) .* fdisp./sdisp^2; + y(~i) = fdisp + (kr(~i) - sdisp^2)./(kr(end) - sdisp^2) .* (fmax - fdisp); + + figure, plot(sw, [kr; y], '.-') + legend('Unscaled', 'Vert. Scaled', 'Location', 'Best') +*/ +BOOST_AUTO_TEST_CASE (Sw2_Regular) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto sw = associate({ + 1.0e-01, 1.5e-01, 2.0e-01, 2.5e-01, + 3.0e-01, 3.5e-01, 4.0e-01, 4.5e-01, + 5.0e-01, 5.5e-01, 6.0e-01, 6.5e-01, + 7.0e-01, 7.5e-01, 8.0e-01, 8.5e-01, + 9.0e-01, + }); + + const auto kr = std::vector { // sw^2 + 1.000e-02, 2.250e-02, 4.000e-02, 6.250e-02, // 0 .. 3 + 9.000e-02, 1.225e-01, 1.600e-01, 2.025e-01, // 4 .. 7 + 2.500e-01, 3.025e-01, 3.600e-01, 4.225e-01, // 8 .. 11 + 4.900e-01, 5.625e-01, 6.400e-01, 7.225e-01, // 12 .. 15 + 8.100e-01, // 16 + }; + + const auto f = SFVal{ + SFPt{ 0.7, 0.49 }, // Displacement + SFPt{ 0.9, 0.81 }, // Maximum + }; + + // Scaled residual displacement sat: 0.7 + // Scaled Kr at Scaled Sr (KRxR): 0.6 + // Scaled Kr at Smax: (KRx) 0.7 + const auto scaler = Opm::SatFunc:: + CritSatVerticalScaling({ 0.71 }, { 0.6 }, { 0.7 }); + + const auto y = scaler.vertScale(f, sw, kr); + + // expect = kr .* (KRxR/0.49), S \le Sr + // KRxR + (kr - 0.49)/(0.81 - 0.49)*(KRx - KRxR), Sr < S + const auto expect = std::vector { + 1.224489795918368e-02, // 0 + 2.755102040816328e-02, // 1 + 4.897959183673471e-02, // 2 + 7.653061224489796e-02, // 3 + 1.102040816326531e-01, // 4 + 1.500000000000000e-01, // 5 + 1.959183673469388e-01, // 6 + 2.479591836734695e-01, // 7 + 3.061224489795918e-01, // 8 + 3.704081632653062e-01, // 9 + 4.408163265306123e-01, // 10 + 5.173469387755103e-01, // 11 + + // ------- Sr ------- + + 6.000000000000000e-01, // 12 + 6.226562500000000e-01, // 13 + 6.468750000000000e-01, // 14 + 6.726562500000000e-01, // 15 + 7.000000000000000e-01, // 16 + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_CASE (Core1D_Coincident_FVal) +{ + using SFPt = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues::Point; + using SFVal = ::Opm::SatFunc::VerticalScalingInterface::FunctionValues; + + const auto s = associate(sw_core1d_example()); + const auto kr = krw_core1d_example(); + + const auto f = SFVal{ + SFPt{ 0.93, 1.0 }, // Displacement + SFPt{ 1.0 , 1.0 }, // Maximum + }; + + const auto scaler = Opm::SatFunc:: + CritSatVerticalScaling({ 0.93 }, { 0.9 }, { 1.0 }); + + const auto y = scaler.vertScale(f, s, kr); + + const auto expect = std::vector { + 0, + 4.074246000000000e-04, + 1.629693000000000e-03, + 3.666816000000000e-03, + 6.518790000000000e-03, + 1.018557000000000e-02, + 1.466730000000000e-02, + 1.996380000000000e-02, + 2.607516000000000e-02, + 3.300138000000000e-02, + 4.074246000000000e-02, + 4.929831000000000e-02, + 5.866911000000000e-02, + 6.885468000000000e-02, + 7.985511000000001e-02, + 9.167040000000000e-02, + 1.043010000000000e-01, + 1.177452000000000e-01, + 1.320057000000000e-01, + 1.470798000000000e-01, + 1.629693000000000e-01, + 1.796742000000000e-01, + 1.971936000000000e-01, + 2.155275000000000e-01, + 2.346759000000000e-01, + 2.546397000000000e-01, + 2.754189000000000e-01, + 2.970126000000000e-01, + 3.194208000000000e-01, + 3.426435000000000e-01, + 3.666816000000000e-01, + 3.915342000000000e-01, + 4.172022000000000e-01, + 4.436847000000000e-01, + 4.709826000000000e-01, + 4.990950000000000e-01, + 5.280218999999999e-01, + 5.577633000000000e-01, + 5.883201000000000e-01, + 6.196923000000001e-01, + 6.518790000000000e-01, + 6.848802000000001e-01, + 7.186959000000001e-01, + 7.533270000000001e-01, + 7.887735000000000e-01, + 8.250336000000000e-01, + 8.621100000000000e-01, + 9.000000000000000e-01, + 1.000000000000000e+00, + }; + + check_is_close(y, expect); +} + +BOOST_AUTO_TEST_SUITE_END () diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp index b6c2ae5110..1782ecede2 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpropertyunitconversion.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLPROPERTYUNITCONVERSION diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp index e31a4e0d03..a6ddbedcd8 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclproptable.cpp @@ -21,10 +21,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLPROPTABLE diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp index 17588f26a1..2c9b5f60e1 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclpvtcommon.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECLPVTCOMMON_UNITCONV diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp index fd3c8ca9bc..ae982d07d5 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclregionmapping.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_REGION_MAPPING diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp index b6ba1959b4..d43df46ab8 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclsimple1dinterpolant.cpp @@ -21,10 +21,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_ECL1DINTERPOLATION diff --git a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp index 02d45a51e8..0d3888a1b9 100644 --- a/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp +++ b/ThirdParty/custom-opm-flowdiag-app/opm-flowdiagnostics-applications/tests/test_eclunithandling.cpp @@ -22,10 +22,6 @@ #include #endif // HAVE_CONFIG_H -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_UNIT_HANDLING diff --git a/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt b/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt index 3e072c7c1e..447ed4e265 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiagnostics/CMakeLists.txt @@ -24,3 +24,8 @@ add_library(${PROJECT_NAME} if (MSVC) set_target_properties(${PROJECT_NAME} PROPERTIES COMPILE_FLAGS "/wd4267") endif() + +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/opm-flowdiagnostics +) diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt index 8682cb6afe..5dff972ec4 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/CMakeLists.txt @@ -15,7 +15,7 @@ ########################################################################### # Mandatory call to project -project(opm-flowdiagnostics CXX) +project(opm-flowdiagnostics C CXX) cmake_minimum_required (VERSION 2.8) diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module index 64b59849aa..18e86045a3 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/dune.module @@ -5,8 +5,8 @@ Module: opm-flowdiagnostics Description: Open Porous Media Initiative flow diagnostics -Version: 2016.10-pre -Label: 2016.10-pre +Version: 2018.10-pre +Label: 2018.10-pre Maintainer: opm@opm-project.org MaintainerName: OPM community Url: http://opm-project.org diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake new file mode 100644 index 0000000000..94fecbdc17 --- /dev/null +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/opm-flowdiagnostics-prereqs.cmake @@ -0,0 +1,19 @@ +# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*- +# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap: + +# defines that must be present in config.h for our headers +set (opm-flowdiagnostics_CONFIG_VAR + ) + +# dependencies +set (opm-flowdiagnostics_DEPS + # compile with C99 support if available + "C99" + # compile with C++0x/11 support if available + "CXX11Features REQUIRED" + "Boost 1.44.0 + COMPONENTS unit_test_framework REQUIRED" + "opm-common REQUIRED" + ) + +find_package_deps(opm-flowdiagnostics) diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp index b0feae8d85..f563375121 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_assembledconnections.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp index 53c2036fc4..15764916dc 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_cellset.cpp @@ -20,10 +20,6 @@ #include -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TEST_CELLSET diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp index 647984c96c..907c869633 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectionvalues.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp index 8a9672cce9..fe15a2c0f5 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_connectivitygraph.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp index 4cd2036712..6a0e6b0ec6 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_derivedquantities.cpp @@ -17,13 +17,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif // HAVE_DYNAMIC_BOOST_TEST #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp index b5d34bb030..ee1f92b815 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_flowdiagnosticstool.cpp @@ -18,13 +18,7 @@ along with OPM. If not, see . */ -#if HAVE_CONFIG_H #include -#endif // HAVE_CONFIG_H - -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif // HAVE_DYNAMIC_BOOST_TEST #define NVERBOSE diff --git a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp index c07507c64b..784e170af3 100644 --- a/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp +++ b/ThirdParty/custom-opm-flowdiagnostics/opm-flowdiagnostics/tests/test_tarjan.cpp @@ -20,10 +20,6 @@ #include -#if HAVE_DYNAMIC_BOOST_TEST -#define BOOST_TEST_DYN_LINK -#endif - #define NVERBOSE #define BOOST_TEST_MODULE TarjanImplementationTest diff --git a/ThirdParty/expressionparser/CMakeLists.txt b/ThirdParty/expressionparser/CMakeLists.txt index e2e72d8383..4de3ad10bf 100644 --- a/ThirdParty/expressionparser/CMakeLists.txt +++ b/ThirdParty/expressionparser/CMakeLists.txt @@ -22,3 +22,10 @@ add_library( ${PROJECT_NAME} if(MSVC) set_target_properties(expressionparser PROPERTIES COMPILE_FLAGS "/wd4267") endif() + + target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/ThirdParty/nightcharts/CMakeLists.txt b/ThirdParty/nightcharts/CMakeLists.txt index 287617a83d..3169a76e4c 100644 --- a/ThirdParty/nightcharts/CMakeLists.txt +++ b/ThirdParty/nightcharts/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 2.8) +cmake_minimum_required (VERSION 2.8.12) project (nightcharts) @@ -14,3 +14,9 @@ add_library( ${PROJECT_NAME} ${MAIN_SOURCE_FILES} ) +target_include_directories(${PROJECT_NAME} + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR} +) + +source_group("" FILES ${PROJECT_FILES}) diff --git a/doc/case_collections.plantuml b/doc/case_collections.plantuml new file mode 100644 index 0000000000..9c4f823606 --- /dev/null +++ b/doc/case_collections.plantuml @@ -0,0 +1,50 @@ +@startuml + +package "Summary case ensamble" { + + skinparam class { + BackgroundColor<> LightGray + } + + package Cases { + RimSummaryCaseMainCollection --> "*" RimSummaryCaseCollection + RimSummaryCaseMainCollection --> "*" RimSummaryCase + RimSummaryCaseCollection --> "*" RimSummaryCase + + RimSummaryCase -> RigCaseRealizationParameters + + RimSummaryCaseMainCollection ..> RifCaseRealizationParametersReader : create + RifCaseRealizationParametersReader ..> RimSummaryCase : set parameters + + class RifSummaryReaderInterface { + allResultAddresses() + } + RimSummaryCase <|-- RimGridSummaryCase + RimSummaryCase --> RifSummaryReaderInterface + RifSummaryReaderInterface <|-- RifReaderEclipseSummary + RimGridSummaryCase ..> RifReaderEclipseSummary + } + + package Curves { + RimMainPlotCollection --> RimSummaryPlotCollection + RimSummaryPlotCollection --> "*" RimSummaryPlot + + RimSummaryPlot --> RimSummaryCurveCollection + RimSummaryPlot -> RimEnsambleCurveSetCollection + RimSummaryCurveCollection --> "*" RimSummaryCurve + RimSummaryCurveCollection -> "3" RimSummaryPlotSourceStepping + RimEnsambleCurveSetCollection --> RimEnsambleCurveSet + RimEnsambleCurveSet --> "*" RimSummaryCurve + } + + RimProject -> RimMainPlotCollection + RimProject --> "*" RimOilField + RimOilField --> RimSummaryCaseMainCollection + + RimSummaryCurve -> RimSummaryCase + RimSummaryCurve --> RifEclipseSummaryAddress + + RifSummaryReaderInterface --> "*" RifEclipseSummaryAddress +} + +@enduml diff --git a/doc/curve_creator.plantuml b/doc/curve_creator.plantuml new file mode 100644 index 0000000000..4725b2f8e2 --- /dev/null +++ b/doc/curve_creator.plantuml @@ -0,0 +1,50 @@ +@startuml + +package "Curve creator (Plot editor)" { + +' +' Class definitions +' +class RicSummaryCurveCreatorSplitterUi { + Qt layouts +} + +class RicSummaryCurveCreator { + Appearance types + OK/Apply/Cancel buttons +} + +class RiuSummaryCurveDefSelectionEditor { + m_firstRowLeftLayout + m_firstRowRightLayout +} + +class RiuSummaryCurveDefSelection { + Cases + Summary categories + Identifier fields +} + +' +' Class Hierarchy +' +PdmUiWidgetBasedObjectEditor <|-- RicSummaryCurveCreatorSplitterUi +PdmUiWidgetBasedObjectEditor <|-- RiuSummaryCurveDefSelectionEditor + +' +' Class references +' +RicSummaryCurveCreatorDialog --> RicSummaryCurveCreatorSplitterUi + +RicSummaryCurveCreatorSplitterUi ->RicSummaryCurveCreator + +RicSummaryCurveCreator --> RiuSummaryCurveDefSelectionEditor + +RicSummaryCurveCreator --> RimSummaryPlot : Target plot +RicSummaryCurveCreator --> RimSummaryPlot : Preview plot + +RiuSummaryCurveDefSelectionEditor --> RiuSummaryCurveDefSelection + +} + +@enduml diff --git a/doc/fracture_clases.plantuml b/doc/fracture_clases.plantuml index f6fd1ddedc..087952b33b 100644 --- a/doc/fracture_clases.plantuml +++ b/doc/fracture_clases.plantuml @@ -3,7 +3,7 @@ Title Classes related to fractures note as N1 - Updated 2017-06-09 + Updated 2018-03-07 end note class RimFracture { @@ -19,6 +19,10 @@ class RimWellPathFracture { RimFracture <|-- RimSimWellFracture RimFracture <|-- RimWellPathFracture +RimFracture -> RimStimPlanFractureTemplate + +RimFracture -> RivWellFracturePartMgr +RivWellFracturePartMgr ->RimFracture class RimFractureTemplate { RimDefines::UnitSystemType fractureTemplateUnit; @@ -29,6 +33,9 @@ class RimEllipseFractureTemplate { class RimStimPlanFractureTemplate { } +class RifStimPlanXmlReader { + <> readStimPlanXMLFile() +} RimFractureTemplate <|-- RimEllipseFractureTemplate RimFractureTemplate <|-- RimStimPlanFractureTemplate @@ -80,9 +87,7 @@ class RicExportFractureCompletionsImpl{ generateFracturesCompdatValues() } - - - - +RimStimPlanFractureTemplate ---> RifStimPlanXmlReader +RifStimPlanXmlReader ...> "create" RigStimPlanFractureDefinition @enduml diff --git a/doc/legends.plantuml b/doc/legends.plantuml new file mode 100644 index 0000000000..8ca560617b --- /dev/null +++ b/doc/legends.plantuml @@ -0,0 +1,21 @@ +@startuml + +package Legends { + + OverlayItem <|-- OverlayScalarMapperLegend + + ScalarMapper <|-- ScalarMapperRangeBased + ScalarMapperRangeBased <|-- ScalarMapperContinuousLinear + ScalarMapperRangeBased <|-- ScalarMapperDiscreteLinear + + RimStimPlanColors --> RimLegendConfig + Rim2dIntersectionView --> RimLegendConfig + RimEclipseCellColors --> RimLegendConfig + + RimLegendConfig --> ScalarMapper + RimLegendConfig --> OverlayScalarMapperLegend + + OverlayScalarMapperLegend --> ScalarMapper +} + +@enduml diff --git a/doc/view_classes.plantuml b/doc/view_classes.plantuml index 7494fc2ac9..f553c317b9 100644 --- a/doc/view_classes.plantuml +++ b/doc/view_classes.plantuml @@ -4,12 +4,12 @@ class RimViewWindow { RimMdiWindowController mdiWindowGeometry() } -note top of RimViewWindow : Updated 2017-02-24 +note top of RimViewWindow : Updated 2018-04-18 (NOTE : sub classes of RimViewWindow is not complete, consider Doxygen for this info class RimView { } -RimViewWindow <|-- RimView +RimViewWindow <|-- Rim3dView package plots { RimViewWindow <|-- RimSummaryPlot @@ -20,8 +20,12 @@ RimViewWindow <|-- RimWellLogPlot RimViewWindow *-- RimMdiWindowController -RimView <|-- RimEclipseView -RimView <|-- RimGeoMechView +Rim3dView <|-- Rim2dIntersectionView + +Rim3dView <|-- RimGridView + +RimGridView <|-- RimEclipseView +RimGridView <|-- RimGeoMechView diff --git a/patches/fix-synthetic-odb-cases.patch b/patches/fix-synthetic-odb-cases.patch index 050a7e882d..368fb05bd5 100644 --- a/patches/fix-synthetic-odb-cases.patch +++ b/patches/fix-synthetic-odb-cases.patch @@ -4,13 +4,13 @@ Date: Thu, 4 Jan 2018 20:29:09 +0100 Subject: [PATCH] #2317 Apply fix for synthetic odb files --- - ThirdParty/Ert/lib/ecl/ecl_rsthead.c | 10 ++++++++-- + ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) -diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +diff --git a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp index e8d9cef..2993b1e 100644 ---- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.c -+++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.c +--- a/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp ++++ b/ThirdParty/Ert/lib/ecl/ecl_rsthead.cpp @@ -88,7 +88,10 @@ ecl_rsthead_type * ecl_rsthead_alloc_from_kw( int report_step , const ecl_kw_typ // The only derived quantity rsthead->sim_time = rsthead_date( rsthead->day , rsthead->month , rsthead->year ); diff --git a/patches/install-ert.patch b/patches/install-ert.patch new file mode 100644 index 0000000000..c874f27eab --- /dev/null +++ b/patches/install-ert.patch @@ -0,0 +1,49 @@ +From 57a5f7fc667d42a5405021c975dabc2db53079a4 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Jacob=20St=C3=B8ren?= +Date: Thu, 26 Oct 2017 17:16:42 +0200 +Subject: [PATCH] #2011 libecl: Add INSTALL_ERT to control install targets + +--- + ThirdParty/Ert/CMakeLists.txt | 5 ++++- + ThirdParty/Ert/lib/CMakeLists.txt | 3 ++- + 2 files changed, 6 insertions(+), 2 deletions(-) + +diff --git a/ThirdParty/Ert/CMakeLists.txt b/ThirdParty/Ert/CMakeLists.txt +index ffb2de0f9..73fb3b30d 100644 +--- a/ThirdParty/Ert/CMakeLists.txt ++++ b/ThirdParty/Ert/CMakeLists.txt +@@ -363,6 +363,9 @@ if (BUILD_PYTHON) + endif() + endif() + +-install(EXPORT ecl-config DESTINATION share/cmake/ecl) ++if (INSTALL_ERT) ++ install(EXPORT ecl-config DESTINATION share/cmake/ecl) ++endif() ++ + export(TARGETS ecl FILE eclConfig.cmake) + export(PACKAGE ecl) +diff --git a/ThirdParty/Ert/lib/CMakeLists.txt b/ThirdParty/Ert/lib/CMakeLists.txt +index 477f95530..2b91ee17f 100644 +--- a/ThirdParty/Ert/lib/CMakeLists.txt ++++ b/ThirdParty/Ert/lib/CMakeLists.txt +@@ -220,7 +220,7 @@ endif () + set_target_properties(ecl PROPERTIES + VERSION ${ECL_VERSION_MAJOR}.${ECL_VERSION_MINOR} + SOVERSION ${ECL_VERSION_MAJOR}) +- ++if (INSTALL_ERT) + install(TARGETS ecl + EXPORT ecl-config + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} +@@ -245,6 +245,7 @@ if (ERT_BUILD_CXX) + PATTERN *.hpp + ) + endif () ++endif() + + if (NOT BUILD_TESTS) + return () +-- +2.16.2.windows.1 + diff --git a/patches/readme.txt b/patches/readme.txt index 34f195f307..0a0d7ecc9a 100644 --- a/patches/readme.txt +++ b/patches/readme.txt @@ -6,4 +6,4 @@ Description: Will fix reading of special Eclipse cases related to synthetic ODB test cases. Required for regression testing. Patch is created by : -git format-patch -1 +git format-patch -1 --stdout > patch-file diff --git a/scripts/ceesol-sample-clang-build.ps1 b/scripts/ceesol-sample-clang-build.ps1 new file mode 100644 index 0000000000..d1ba3e1a79 --- /dev/null +++ b/scripts/ceesol-sample-clang-build.ps1 @@ -0,0 +1,231 @@ +<# +.SYNOPSIS + Compiles or tidies up code from Visual Studio .vcxproj project files. + It sets up the scene required for clang-build.ps1 to do its job, and makes + command-line usage for projects and files quicker. + + Before calling sample-clang-build.ps1 you need to set the current directory + to the root source directory. + +.PARAMETER aVcxprojToCompile + Alias 'proj'. Array of project(s) to compile. If empty, all projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojToIgnore + Alias 'proj-ignore'. Array of project(s) to ignore, from the matched ones. + If empty, all already matched projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojConfigPlatform + Alias 'active-config'. The configuration-platform pair, separated by |, + to be used when processing project files. + + E.g. 'Debug|Win32'. + If not specified, the first configuration-plaform found in the current project is used. + +.PARAMETER aCppToCompile + Alias 'file'. What cpp(s) to compile from the found project(s). If empty, all CPPs are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" compiles all CPPs containing 'table'. + +.PARAMETER aCppToIgnore + Alias 'file-ignore'. Array of file(s) to ignore, from the matched ones. + If empty, all already matched files are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" ignores all CPPs containing 'table'. + + Can be passed as comma separated values. + + +.PARAMETER aContinueOnError + Alias 'continue'. Switch to continue project compilation even when errors occur. + +.PARAMETER aClangCompileFlags + Alias 'clang-flags'. Flags given to clang++ when compiling project, + alongside project-specific defines. + +.PARAMETER aDisableNameRegexMatching + Alias 'literal'. Switch to take project and cpp name filters literally, not by regex matching. + +.PARAMETER aTidyFlags + Alias 'tidy'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will not be applied, only simulated. + + If aTidyFixFlags is present, it takes precedence over this parameter. + +.PARAMETER aTidyFixFlags + Alias 'tidy-fix'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will be applied to the file(s). + + If present, this parameter takes precedence over aTidyFlags. + +.PARAMETER aAfterTidyFixFormatStyle + Alias 'format-style'. Used in combination with 'tidy-fix'. If present, clang-tidy will + also format the fixed file(s), using the specified style. + Possible values: - not present, no formatting will be done + - 'file' + Literally 'file', not a placeholder. + Uses .clang-format file in the closest parent directory. + - 'llvm' + - 'google' + - 'webkit' + - 'mozilla' + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + Doesn't actually apply the clang-tidy module changes to CPPs. + It will only print the tidy module output. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy-fix "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + It will apply all tidy module changes to CPPs. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo -proj-ignore foobar + + Runs clang++ on all CPPs in foo... projects, except foobar + +.OUTPUTS + Will output Clang warnings and errors to screen. The return code will be 0 for success, >0 for failure. + +.NOTES + Author: Gabriel Diaconita +#> +param( [alias("proj")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToCompile + , [alias("proj-ignore")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToIgnore + , [alias("active-config")][Parameter(Mandatory=$false)][string] $aVcxprojConfigPlatform + , [alias("file")] [Parameter(Mandatory=$false)][string] $aCppToCompile + , [alias("file-ignore")] [Parameter(Mandatory=$false)][string[]] $aCppToIgnore + , [alias("continue")] [Parameter(Mandatory=$false)][switch] $aContinueOnError + , [alias("literal")] [Parameter(Mandatory=$false)][switch] $aDisableNameRegexMatching + , [alias("tidy")] [Parameter(Mandatory=$false)][string] $aTidyFlags + , [alias("tidy-fix")] [Parameter(Mandatory=$false)][string] $aTidyFixFlags + , [alias("format-style")] [Parameter(Mandatory=$false)][string] $aAfterTidyFixFormatStyle + ) + +# ------------------------------------------------------------------------------------------------ + +Set-Variable -name kClangCompileFlags -Option Constant ` + -value @( "-Wall" + , "-fms-compatibility-version=19.10" + , "-Wmicrosoft" + , "-Wno-invalid-token-paste" + , "-Wno-unknown-pragmas" + , "-Wno-unused-variable" + , "-Wno-unused-value" + , "-Wno-undefined-var-template" + , "-Wno-microsoft-enum-value" + , "-Wno-inconsistent-missing-override" + , "-Wno-extra-tokens" + , "-Wno-c99-extensions" + , "-Wno-logical-op-parentheses" + , "-Wno-invalid-source-encoding" + ) + +Set-Variable -name kVisualStudioVersion -value "2017" -Option Constant +Set-Variable -name kVisualStudioSku -value "Professional" -Option Constant +Set-Variable -name localVarUseParallelCompile -value $True -Option Constant +Set-Variable -name localVarCppToIgnore -Option Constant ` + -value @( "gtest" + , "moc_" + ) + + +# ------------------------------------------------------------------------------------------------ + +Function Merge-Array([string[]] $aArray) +{ + # we need to individually wrap items into quotes as values + # can contain PS control characters (e.g. - in -std=c++14) + $quotedArray = ($aArray | ForEach-Object { """$_"""}) + return ($quotedArray -join ",") +} + +[string] $scriptDirectory = (Split-Path -parent $PSCommandPath) + +[string] $clangScript = "$scriptDirectory\clang-build.ps1" +[string[]] $scriptParams = @("-aSolutionsPath", "'$(Get-Location)'") + +if (![string]::IsNullOrEmpty($aVcxprojToCompile)) +{ + $scriptParams += ("-aVcxprojToCompile", (Merge-Array $aVcxprojToCompile)) +} + +if (![string]::IsNullOrEmpty($aVcxprojToIgnore)) +{ + $scriptParams += ("-aVcxprojToIgnore", (Merge-Array $aVcxprojToIgnore)) +} + +if (![string]::IsNullOrEmpty($aVcxprojConfigPlatform)) +{ + $scriptParams += ("-aVcxprojConfigPlatform", (Merge-Array $aVcxprojConfigPlatform)) +} + +if (![string]::IsNullOrEmpty($aCppToCompile)) +{ + $scriptParams += ("-aCppToCompile", (Merge-Array $aCppToCompile)) +} + +if (![string]::IsNullOrEmpty($localVarCppToIgnore)) +{ + $scriptParams += ("-aCppToIgnore", (Merge-Array $localVarCppToIgnore)) +} + +$scriptParams += ("-aClangCompileFlags", (Merge-Array $kClangCompileFlags)) + +if (![string]::IsNullOrEmpty($aTidyFlags)) +{ + $scriptParams += ("-aTidyFlags", (Merge-Array (@($aTidyFlags)))) +} + +if (![string]::IsNullOrEmpty($aTidyFixFlags)) +{ + $scriptParams += ("-aTidyFixFlags", (Merge-Array (@($aTidyFixFlags)))) +} + +if (![string]::IsNullOrEmpty($aAfterTidyFixFormatStyle)) +{ + $scriptParams += ("-aAfterTidyFixFormatStyle", $aAfterTidyFixFormatStyle) +} + +if ($localVarUseParallelCompile) +{ + $scriptParams += ("-aUseParallelCompile") +} + +if ($aContinueOnError) +{ + $scriptParams += ("-aContinueOnError") +} + +if ($True) +{ + $scriptParams += ("-aTreatAdditionalIncludesAsSystemIncludes") +} + +if ($aDisableNameRegexMatching) +{ + $scriptParams += ("-aDisableNameRegexMatching") +} + +$scriptParams += ("-aVisualStudioVersion", $kVisualStudioVersion) +$scriptParams += ("-aVisualStudioSku", $kVisualStudioSku) +$scriptParams += ("-aTidyHeaderFilter", ".*") + +Invoke-Expression "&'$clangScript' $scriptParams" diff --git a/scripts/clang-build.ps1 b/scripts/clang-build.ps1 new file mode 100644 index 0000000000..8c8c37c8b8 --- /dev/null +++ b/scripts/clang-build.ps1 @@ -0,0 +1,2229 @@ +#Requires -Version 3 +<# +.SYNOPSIS + Compiles or tidies up code from Visual Studio .vcxproj project files. + +.DESCRIPTION + This PowerShell script scans for all .vcxproj Visual Studio projects inside a source directory. + One or more of these projects will be compiled or tidied up (modernized), using Clang. + +.PARAMETER aSolutionsPath + Alias 'dir'. Source directory to find sln files. + Projects will be extracted from each sln. + + Important: You can pass an absolute path to a sln. This way, no file searching will be done, and + only the projects from this solution file will be taken into acount. + +.PARAMETER aVcxprojToCompile + Alias 'proj'. Array of project(s) to compile. If empty, all projects found in solutions are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all projects containing 'msicomp'. + + Absolute disk paths to vcxproj files are accepted. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojToIgnore + Alias 'proj-ignore'. Array of project(s) to ignore, from the matched ones. + If empty, all already matched projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" ignores projects containing 'msicomp'. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojConfigPlatform + Alias 'active-config'. The configuration-platform pair, separated by |, + to be used when processing project files. + + E.g. 'Debug|Win32'. + If not specified, the first configuration-plaform found in the current project is used. + +.PARAMETER aCppToCompile + Alias 'file'. What cpp(s) to compile from the found project(s). If empty, all CPPs are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" compiles all CPPs containing 'table'. + +.PARAMETER aCppToIgnore + Alias 'file-ignore'. Array of file(s) to ignore, from the matched ones. + If empty, all already matched files are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" ignores all CPPs containing 'table'. + + Can be passed as comma separated values. + +.PARAMETER aUseParallelCompile + Alias 'parallel'. Switch to run in parallel mode, on all logical CPU cores. + +.PARAMETER aContinueOnError + Alias 'continue'. Switch to continue project compilation even when errors occur. + +.PARAMETER aTreatAdditionalIncludesAsSystemIncludes + Alias 'treat-sai'. Switch to treat project additional include directories as system includes. + +.PARAMETER aClangCompileFlags + Alias 'clang-flags'. Flags given to clang++ when compiling project, + alongside project-specific defines. + +.PARAMETER aDisableNameRegexMatching + Alias 'literal'. Switch to take project and cpp name filters literally, not by regex matching. + +.PARAMETER aTidyFlags + Alias 'tidy'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will not be applied, only simulated. + + If aTidyFixFlags is present, it takes precedence over this parameter. + + If '.clang-tidy' value is given, configuration will be read from .clang-tidy file + in the closest parent directory. + +.PARAMETER aTidyFixFlags + Alias 'tidy-fix'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will be applied to the file(s). + + If present, this parameter takes precedence over aTidyFlags. + + If '.clang-tidy' value is given, configuration will be read from .clang-tidy file + in the closest parent directory. + +.PARAMETER aAfterTidyFixFormatStyle + Alias 'format-style'. Used in combination with 'tidy-fix'. If present, clang-tidy will + also format the fixed file(s), using the specified style. + Possible values: - not present, no formatting will be done + - 'file' + Literally 'file', not a placeholder. + Uses .clang-format file in the closest parent directory. + - 'llvm' + - 'google' + - 'webkit' + - 'mozilla' + +.PARAMETER aVisualStudioVersion + Alias 'vs-ver'. Version of Visual Studio (VC++) installed and that'll be used for + standard library include directories. E.g. 2017. + +.PARAMETER aVisualStudioSku + Alias 'vs-sku'. Sku of Visual Studio (VC++) installed and that'll be used for + standard library include directories. E.g. Professional. + +.NOTES + Author: Gabriel Diaconita +#> +param( [alias("dir")] [Parameter(Mandatory=$true)] [string] $aSolutionsPath + , [alias("proj")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToCompile + , [alias("proj-ignore")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToIgnore + , [alias("active-config")][Parameter(Mandatory=$false)][string] $aVcxprojConfigPlatform + , [alias("file")] [Parameter(Mandatory=$false)][string] $aCppToCompile + , [alias("file-ignore")] [Parameter(Mandatory=$false)][string[]] $aCppToIgnore + , [alias("parallel")] [Parameter(Mandatory=$false)][switch] $aUseParallelCompile + , [alias("continue")] [Parameter(Mandatory=$false)][switch] $aContinueOnError + , [alias("treat-sai")] [Parameter(Mandatory=$false)][switch] $aTreatAdditionalIncludesAsSystemIncludes + , [alias("clang-flags")] [Parameter(Mandatory=$true)] [string[]] $aClangCompileFlags + , [alias("literal")] [Parameter(Mandatory=$false)][switch] $aDisableNameRegexMatching + , [alias("tidy")] [Parameter(Mandatory=$false)][string] $aTidyFlags + , [alias("tidy-fix")] [Parameter(Mandatory=$false)][string] $aTidyFixFlags + , [alias("header-filter")][Parameter(Mandatory=$false)][string] $aTidyHeaderFilter + , [alias("format-style")] [Parameter(Mandatory=$false)][string] $aAfterTidyFixFormatStyle + , [alias("vs-ver")] [Parameter(Mandatory=$true)] [string] $aVisualStudioVersion + , [alias("vs-sku")] [Parameter(Mandatory=$true)] [string] $aVisualStudioSku + ) + +# System Architecture Constants +# ------------------------------------------------------------------------------------------------ + +Set-Variable -name kLogicalCoreCount -value ` + (@(Get-WmiObject -class Win32_processor) | ` + ForEach-Object -Begin { $coreCount = 0 } ` + -Process { $coreCount += ($_ | Select-Object -property NumberOfLogicalProcessors ` + -ExpandProperty NumberOfLogicalProcessors) } ` + -End { $coreCount }) -option Constant +# ------------------------------------------------------------------------------------------------ +# Return Value Constants + +Set-Variable -name kScriptFailsExitCode -value 47 -option Constant + +# ------------------------------------------------------------------------------------------------ +# File System Constants + +Set-Variable -name kExtensionVcxproj -value ".vcxproj" -option Constant +Set-Variable -name kExtensionSolution -value ".sln" -option Constant +Set-Variable -name kExtensionClangPch -value ".clang.pch" -option Constant + +# ------------------------------------------------------------------------------------------------ +# Vcxproj Related Constants + +Set-Variable -name kVcxprojXpathPreprocessorDefs ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:PreprocessorDefinitions" ` + -option Constant + +Set-Variable -name kVcxprojXpathAdditionalIncludes ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:AdditionalIncludeDirectories" ` + -option Constant + +Set-Variable -name kVcxprojXpathHeaders ` + -value "ns:Project/ns:ItemGroup/ns:ClInclude" ` + -option Constant + +Set-Variable -name kVcxprojXpathCompileFiles ` + -value "ns:Project/ns:ItemGroup/ns:ClCompile" ` + -option Constant + +Set-Variable -name kVcxprojXpathWinPlatformVer ` + -value "ns:Project/ns:PropertyGroup/ns:WindowsTargetPlatformVersion" ` + -option Constant + +Set-Variable -name kVcxprojXpathForceIncludes ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:ForcedIncludeFiles" ` + -option Constant + +Set-Variable -name kVcxprojXpathPCH ` + -value "ns:Project/ns:ItemGroup/ns:ClCompile/ns:PrecompiledHeader[text()='Create']" ` + -option Constant + +Set-Variable -name kVcxprojXpathToolset ` + -value "ns:Project/ns:PropertyGroup[@Label='Configuration']/ns:PlatformToolset" ` + -option Constant + +Set-Variable -name kVcxprojXpathDefaultConfigPlatform ` + -value "ns:Project/ns:ItemGroup[@Label='ProjectConfigurations']/ns:ProjectConfiguration[1]" ` + -option Constant + +Set-Variable -name kVcxprojXpathConditionedElements ` + -value "//*[@Condition]" ` + -option Constant + +Set-Variable -name kVcxprojXpathChooseElements ` + -value "ns:Project//ns:Choose" ` + -option Constant + +Set-Variable -name kVcxprojXpathPropGroupElements ` + -value "ns:Project//ns:PropertyGroup/*" ` + -option Constant + +Set-Variable -name kVcxprojXpathCppStandard ` + -value "ns:Project/ns:ItemDefinitionGroup/ns:ClCompile/ns:LanguageStandard" ` + -option Constant + +Set-Variable -name kVSDefaultWinSDK -value '8.1' -option Constant +Set-Variable -name kVSDefaultWinSDK_XP -value '7.0' -option Constant + +# ------------------------------------------------------------------------------------------------ +# Clang-Related Constants + +Set-Variable -name kDefaultCppStd -value "stdcpp14" -option Constant +Set-Variable -name kClangFlagSupressLINK -value @("-fsyntax-only") -option Constant +Set-Variable -name kClangFlagWarningIsError -value @("-Werror") -option Constant +Set-Variable -name kClangFlagIncludePch -value "-include-pch" -option Constant +Set-Variable -name kClangFlagEmitPch -value "-emit-pch" -option Constant +Set-Variable -name kClangFlagMinusO -value "-o" -option Constant + +Set-Variable -name kClangDefinePrefix -value "-D" -option Constant +Set-Variable -name kClangFlagNoUnusedArg -value "-Wno-unused-command-line-argument" ` + -option Constant +Set-Variable -name kClangFlagNoMsInclude -value "-Wno-microsoft-include" ` + -Option Constant +Set-Variable -name kClangFlagFileIsCPP -value "-x c++" -option Constant +Set-Variable -name kClangFlagForceInclude -value "-include" -option Constant + +Set-Variable -name kClangCompiler -value "clang++.exe" -option Constant +Set-Variable -name kClangTidy -value "clang-tidy.exe" -option Constant +Set-Variable -name kClangTidyFlags -value @("-quiet" + ,"--") -option Constant +Set-Variable -name kClangTidyFixFlags -value @("-quiet" + ,"-fix-errors" + , "--") -option Constant +Set-Variable -name kClangTidyFlagHeaderFilter -value "-header-filter=" -option Constant +Set-Variable -name kClangTidyFlagChecks -value "-checks=" -option Constant +Set-Variable -name kClangTidyUseFile -value ".clang-tidy" -option Constant +Set-Variable -name kClangTidyFormatStyle -value "-format-style=" -option Constant + +# ------------------------------------------------------------------------------------------------ +# Default install locations of LLVM. If present there, we automatically use it + +Set-Variable -name kLLVMInstallLocations -value @("${Env:ProgramW6432}\LLVM\bin" + ,"${Env:ProgramFiles(x86)}\LLVM\bin" + ) -option Constant + +# ------------------------------------------------------------------------------------------------ +# Helpers for locating Visual Studio on the computer + +# VsWhere is available starting with Visual Studio 2017 version 15.2. +Set-Variable -name kVsWhereLocation ` + -value "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" ` + -option Constant + +# Default installation path of Visual Studio 2017. We'll use when VsWhere isn't available. +Set-Variable -name kVs15DefaultLocation ` + -value "${Env:ProgramFiles(x86)}\Microsoft Visual Studio\$aVisualStudioVersion\$aVisualStudioSku" ` + -option Constant + +# Registry key containing information about Visual Studio 2015 installation path. +Set-Variable -name kVs2015RegistryKey ` + -value "HKLM:SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0" ` + -option Constant + +#------------------------------------------------------------------------------------------------- +# PlatformToolset-Related Constants + +Set-Variable -name kDefinesUnicode -value @("-DUNICODE" + ,"-D_UNICODE" + ) ` + -option Constant + +Set-Variable -name kDefinesClangXpTargeting ` + -value @("-D_USING_V110_SDK71_") ` + -option Constant + + +Set-Variable -name kIncludePathsXPTargetingSDK ` + -value "${Env:ProgramFiles(x86)}\Microsoft SDKs\Windows\v7.1A\Include" ` + -option Constant + +#------------------------------------------------------------------------------------------------- +# Custom Types + +Add-Type -TypeDefinition @" + public enum WorkloadType + { + Compile, + Tidy, + TidyFix + } +"@ + +Set-Variable -name kVStudioDefaultPlatformToolset -Value "v141" -option Constant + +Set-Variable -name "kMsbuildExpressionToPsRules" -option Constant ` + -value @(<# backticks are control characters in PS, replace them #> + ('`' , '''' )` + <# Temporarily replace $( #> ` + , ('\$\s*\(' , '!@#' )` + <# Escape $ #> ` + , ('\$' , '`$' )` + <# Put back $( #> ` + , ('!@#' , '$(' )` + <# Various operators #> ` + , ("([\s\)\'""])!=" , '$1 -ne ' )` + , ("([\s\)\'""])<=" , '$1 -le ' )` + , ("([\s\)\'""])>=" , '$1 -ge ' )` + , ("([\s\)\'""])==" , '$1 -eq ' )` + , ("([\s\)\'""])<" , '$1 -lt ' )` + , ("([\s\)\'""])>" , '$1 -gt ' )` + , ("([\s\)\'""])or" , '$1 -or ' )` + , ("([\s\)\'""])and" , '$1 -and ' )` + <# Use only double quotes #> ` + , ("\'" , '"' )` + , ("Exists\((.*?)\)(\s|$)" , '(Exists($1))$2' )` + , ("HasTrailingSlash\((.*?)\)(\s|$)" , '(HasTrailingSlash($1))$2' )` + , ("(\`$\()(Registry:)(.*?)(\))" , '$$(GetRegValue("$3"))' )` + ) + +Set-Variable -name "kMsbuildConditionToPsRules" -option Constant ` + -value @(<# Use only double quotes #> ` + ("\'" , '"' )` + <# We need to escape double quotes since we will eval() the condition #> ` + , ('"' , '""' )` + ) + +Set-Variable -name "kRedundantSeparatorsReplaceRules" -option Constant ` + -value @( <# handle multiple consecutive separators #> ` + (";+" , ";") ` + <# handle separator at end #> ` + , (";$" , "") ` + <# handle separator at beginning #> ` + , ("^;" , "") ` + ) + +#------------------------------------------------------------------------------------------------- +# Global variables + +# temporary files created during project processing (e.g. PCH files) +[System.Collections.ArrayList] $global:FilesToDeleteWhenScriptQuits = @() + +# vcxproj and property sheet files declare MsBuild properties (e.g. $(MYPROP)). +# they are used in project xml nodes expressions. we have a +# translation engine (MSBUILD-POWERSHELL) for these. it relies on +# PowerShell to evaluate these expressions. We have to inject project +# properties in the Powershell runtime context. We keep track of them in +# this list, to be cleaned before the next project begins processing +[System.Collections.ArrayList] $global:ProjectSpecificVariables = @() + +# flag to signal when errors are encounteres during project processing +[Boolean] $global:FoundErrors = $false + +# current vcxproj and property sheets +[xml[]] $global:projectFiles = @(); + +# path of current project +[string] $global:vcxprojPath = ""; + +# namespace of current project vcxproj XML +[System.Xml.XmlNamespaceManager] $global:xpathNS = $null; + +# filePath-fileData for SLN files located in source directory +[System.Collections.Generic.Dictionary[String,String]] $global:slnFiles = @{} + +#------------------------------------------------------------------------------------------------- +# Global functions + +Function Exit-Script([Parameter(Mandatory=$false)][int] $code = 0) +{ + Write-Verbose-Array -array $global:FilesToDeleteWhenScriptQuits ` + -name "Cleaning up PCH temporaries" + # Clean-up + foreach ($file in $global:FilesToDeleteWhenScriptQuits) + { + Remove-Item $file -ErrorAction SilentlyContinue | Out-Null + } + + # Restore working directory + Pop-Location + + exit $code +} + +Function Fail-Script([parameter(Mandatory=$false)][string] $msg = "Got errors.") +{ + if (![string]::IsNullOrEmpty($msg)) + { + Write-Err $msg + } + Exit-Script($kScriptFailsExitCode) +} + +Function Set-Var([parameter(Mandatory=$false)][string] $name, + [parameter(Mandatory=$false)][string] $value) +{ + Write-Verbose "SET_VAR $($name): $value" + Set-Variable -name $name -Value $value -Scope Global + + if (!$global:ProjectSpecificVariables.Contains($name)) + { + $global:ProjectSpecificVariables.Add($name) | Out-Null + } +} + +Function Clear-Vars() +{ + Write-Verbose-Array -array $global:ProjectSpecificVariables ` + -name "Deleting project specific variables" + + foreach ($var in $global:ProjectSpecificVariables) + { + Remove-Variable -name $var -scope Global -ErrorAction SilentlyContinue + } + + $global:ProjectSpecificVariables.Clear() +} + +Function Write-Message([parameter(Mandatory=$true)][string] $msg + ,[Parameter(Mandatory=$true)][System.ConsoleColor] $color) +{ + $foregroundColor = $host.ui.RawUI.ForegroundColor + $host.ui.RawUI.ForegroundColor = $color + Write-Output $msg + $host.ui.RawUI.ForegroundColor = $foregroundColor +} + +# Writes an error without the verbose powershell extra-info (script line location, etc.) +Function Write-Err([parameter(ValueFromPipeline, Mandatory=$true)][string] $msg) +{ + Write-Message -msg $msg -color Red +} + +Function Write-Success([parameter(ValueFromPipeline, Mandatory=$true)][string] $msg) +{ + Write-Message -msg $msg -color Green +} + +Function Write-Verbose-Array($array, $name) +{ + Write-Verbose "$($name):" + $array | ForEach-Object { Write-Verbose " $_" } +} + +Function Exists-Command([Parameter(Mandatory=$true)][string] $command) +{ + try + { + Get-Command -name $command -ErrorAction Stop + return $true + } + catch + { + return $false + } +} + +Function Get-FileDirectory([Parameter(Mandatory=$true)][string] $filePath) +{ + return ([System.IO.Path]::GetDirectoryName($filePath) + "\") +} + +Function Get-FileName( [Parameter(Mandatory=$true)][string] $path + , [Parameter(Mandatory=$false)][switch] $noext) +{ + if ($noext) + { + return ([System.IO.Path]::GetFileNameWithoutExtension($path)) + } + else + { + return ([System.IO.Path]::GetFileName($path)) + } +} + +Function IsFileMatchingName( [Parameter(Mandatory=$true)][string] $filePath + , [Parameter(Mandatory=$true)][string] $matchName) +{ + if ([System.IO.Path]::IsPathRooted($matchName)) + { + return $filePath -ieq $matchName + } + + [string] $fileName = (Get-FileName -path $filePath) + [string] $fileNameNoExt = (Get-FileName -path $filePath -noext) + if ($aDisableNameRegexMatching) + { + return (($fileName -eq $matchName) -or ($fileNameNoExt -eq $matchName)) + } + else + { + return (($fileName -match $matchName) -or ($fileNameNoExt -match $matchName)) + } +} + + <# + .DESCRIPTION + Merges an absolute and a relative file path. + .EXAMPLE + Havin base = C:\Windows\System32 and child = .. we get C:\Windows + .EXAMPLE + Havin base = C:\Windows\System32 and child = ..\..\..\.. we get C:\ (cannot go further up) + .PARAMETER base + The absolute path from which we start. + .PARAMETER child + The relative path to be merged into base. + .PARAMETER ignoreErrors + If this switch is not present, an error will be triggered if the resulting path + is not present on disk (e.g. c:\Windows\System33). + + If present and the resulting path does not exist, the function returns an empty string. + #> +Function Canonize-Path( [Parameter(Mandatory=$true)][string] $base + , [Parameter(Mandatory=$true)][string] $child + , [switch] $ignoreErrors) +{ + [string] $errorAction = If ($ignoreErrors) {"SilentlyContinue"} Else {"Stop"} + + if ([System.IO.Path]::IsPathRooted($child)) + { + if (!(Test-Path $child)) + { + return "" + } + return $child + } + else + { + [string[]] $paths = Join-Path -Path "$base" -ChildPath "$child" -Resolve -ErrorAction $errorAction + return $paths + } +} + +Function Get-SourceDirectory() +{ + [bool] $isDirectory = ($(Get-Item $aSolutionsPath) -is [System.IO.DirectoryInfo]) + if ($isDirectory) + { + return $aSolutionsPath + } + else + { + return (Get-FileDirectory -filePath $aSolutionsPath) + } +} + +function Load-Solutions() +{ + Write-Verbose "Scanning for solution files" + $slns = Get-ChildItem -recurse -LiteralPath "$aSolutionsPath" ` + | Where-Object { $_.Extension -eq $kExtensionSolution } + foreach ($sln in $slns) + { + $slnPath = $sln.FullName + $global:slnFiles[$slnPath] = (Get-Content $slnPath) + } + + Write-Verbose-Array -array $global:slnFiles.Keys -name "Solution file paths" +} + +function Get-SolutionProjects([Parameter(Mandatory=$true)][string] $slnPath) +{ + [string] $slnDirectory = Get-FileDirectory -file $slnPath + $matches = [regex]::Matches($global:slnFiles[$slnPath], 'Project\([{}\"A-Z0-9\-]+\) = \S+,\s(\S+),') + $projectAbsolutePaths = $matches ` + | ForEach-Object { Canonize-Path -base $slnDirectory ` + -child $_.Groups[1].Value.Replace('"','') -ignoreErrors } ` + | Where-Object { ! [string]::IsNullOrEmpty($_) -and $_.EndsWith($kExtensionVcxproj) } + return $projectAbsolutePaths +} + +function Get-ProjectSolution() +{ + foreach ($slnPath in $global:slnFiles.Keys) + { + [string[]] $solutionProjectPaths = Get-SolutionProjects $slnPath + if ($solutionProjectPaths -and $solutionProjectPaths -contains $global:vcxprojPath) + { + return $slnPath + } + } + return "" +} + +Function Get-MscVer() +{ + return ((Get-Item "$(Get-VisualStudio-Path)\VC\Tools\MSVC\" | Get-ChildItem) | select -last 1).Name +} + +Function InitializeMsBuildCurrentFileProperties([Parameter(Mandatory=$true)][string] $filePath) +{ + Set-Var -name "MSBuildThisFileFullPath" -value $filePath + Set-Var -name "MSBuildThisFileExtension" -value ([IO.Path]::GetExtension($filePath)) + Set-Var -name "MSBuildThisFile" -value (Get-FileName -path $filePath) + Set-Var -name "MSBuildThisFileName" -value (Get-FileName -path $filePath -noext) + Set-Var -name "MSBuildThisFileDirectory" -value (Get-FileDirectory -filePath $filePath) +} + +Function InitializeMsBuildProjectProperties() +{ + Write-Verbose "Importing environment variables into current scope" + foreach ($var in (Get-ChildItem Env:)) + { + Set-Var -name $var.Name -value $var.Value + } + + Set-Var -name "MSBuildProjectFullPath" -value $global:vcxprojPath + Set-Var -name "ProjectDir" -value (Get-FileDirectory -filePath $global:vcxprojPath) + Set-Var -name "MSBuildProjectExtension" -value ([IO.Path]::GetExtension($global:vcxprojPath)) + Set-Var -name "MSBuildProjectFile" -value (Get-FileName -path $global:vcxprojPath) + Set-Var -name "MSBuildProjectName" -value (Get-FileName -path $global:vcxprojPath -noext) + Set-Var -name "MSBuildProjectDirectory" -value (Get-FileDirectory -filePath $global:vcxprojPath) + Set-Var -name "MSBuildProgramFiles32" -value "${Env:ProgramFiles(x86)}" + # defaults for projectname and targetname, may be overriden by project settings + Set-Var -name "ProjectName" -value $MSBuildProjectName + Set-Var -name "TargetName" -value $MSBuildProjectName + + # These would enable full project platform references parsing, experimental right now + if ($env:CPT_LOAD_ALL -eq '1') + { + Set-Var -name "ConfigurationType" -value "Application" + Set-Var -name "VCTargetsPath" -value "$(Get-VisualStudio-Path)\Common7\IDE\VC\VCTargets\" + Set-Var -name "VsInstallRoot" -value (Get-VisualStudio-Path) + Set-Var -name "MSBuildExtensionsPath" -value "$(Get-VisualStudio-Path)\MSBuild" + Set-Var -name "LocalAppData" -value $env:LOCALAPPDATA + Set-Var -name "UserRootDir" -value "$LocalAppData\Microsoft\MSBuild\v4.0" + Set-Var -name "UniversalCRT_IncludePath" -value "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.10240.0\ucrt" + } + + [string] $vsVer = "15.0" + if ($aVisualStudioVersion -eq "2015") + { + $vsVer = "14.0" + } + Set-Var -name "VisualStudioVersion" -value $vsVer + Set-Var -name "MSBuildToolsVersion" -value $vsVer + + [string] $projectSlnPath = Get-ProjectSolution + [string] $projectSlnDir = Get-FileDirectory -filePath $projectSlnPath + Set-Var -name "SolutionDir" -value $projectSlnDir +} + +Function Should-CompileProject([Parameter(Mandatory=$true)][string] $vcxprojPath) +{ + if ($aVcxprojToCompile -eq $null) + { + return $true + } + + foreach ($projMatch in $aVcxprojToCompile) + { + if (IsFileMatchingName -filePath $vcxprojPath -matchName $projMatch) + { + return $true + } + } + + return $false +} + +Function Should-IgnoreProject([Parameter(Mandatory=$true)][string] $vcxprojPath) +{ + if ($aVcxprojToIgnore -eq $null) + { + return $false + } + + foreach ($projIgnoreMatch in $aVcxprojToIgnore) + { + if (IsFileMatchingName -filePath $vcxprojPath -matchName $projIgnoreMatch) + { + return $true + } + } + + return $false +} + +Function Should-IgnoreFile([Parameter(Mandatory=$true)][string] $file) +{ + if ($aCppToIgnore -eq $null) + { + return $false + } + + foreach ($projIgnoreMatch in $aCppToIgnore) + { + if (IsFileMatchingName -filePath $file -matchName $projIgnoreMatch) + { + return $true + } + } + + return $false +} + +Function Get-ProjectFilesToCompile([Parameter(Mandatory=$false)][string] $pchCppName) +{ + [Boolean] $pchDisabled = [string]::IsNullOrEmpty($pchCppName) + + [string[]] $projectEntries = Select-ProjectNodes($kVcxprojXpathCompileFiles) | ` + Where-Object { ($_.Include -ne $null) -and + ($pchDisabled -or ($_.Include -ne $pchCppName)) + } | ` + Select-Object -Property "Include" -ExpandProperty "Include" + [string[]] $files = @() + foreach ($entry in $projectEntries) + { + [string[]] $matchedFiles = Canonize-Path -base $ProjectDir -child $entry + if ($matchedFiles.Count -gt 0) + { + $files += $matchedFiles + } + } + + if ($files.Count -gt 0) + { + $files = $files | Where-Object { ! (Should-IgnoreFile -file $_) } + } + + return $files +} + +Function Get-ProjectHeaders() +{ + [string[]] $headers = Select-ProjectNodes($kVcxprojXpathHeaders) | ForEach-Object {$_.Include } + + [string[]] $headerPaths = @() + + foreach ($headerEntry in $headers) + { + [string[]] $paths = Canonize-Path -base $ProjectDir -child $headerEntry -ignoreErrors + if ($paths.Count -gt 0) + { + $headerPaths += $paths + } + } + return $headerPaths +} + +Function Get-Project-SDKVer() +{ + [string] $sdkVer = (Select-ProjectNodes($kVcxprojXpathWinPlatformVer)).InnerText + + If ([string]::IsNullOrEmpty($sdkVer)) { "" } Else { $sdkVer.Trim() } +} + +Function Is-Project-Unicode() +{ + $propGroup = Select-ProjectNodes("ns:Project/ns:PropertyGroup[@Label='Configuration']") + + return ($propGroup.CharacterSet -eq "Unicode") +} + +Function Get-Project-CppStandard() +{ + [string] $cachedValueVarName = "ClangPowerTools:CppStd" + + [string] $cachedVar = (Get-Variable $cachedValueVarName -ErrorAction SilentlyContinue -ValueOnly) + if (![string]::IsNullOrEmpty($cachedVar)) + { + return $cachedVar + } + + [string] $cppStd = "" + + $cppStdNode = Select-ProjectNodes($kVcxprojXpathCppStandard) + if ($cppStdNode) + { + $cppStd = $cppStdNode.InnerText + } + else + { + $cppStd = $kDefaultCppStd + } + + $cppStdMap = @{ 'stdcpplatest' = 'c++1z' + ; 'stdcpp14' = 'c++14' + ; 'stdcpp17' = 'c++17' + } + + [string] $cppStdClangValue = $cppStdMap[$cppStd] + Set-Var -name $cachedValueVarName -value $cppStdClangValue + + return $cppStdClangValue +} + +Function Get-ClangCompileFlags() +{ + [string[]] $flags = $aClangCompileFlags + if (!($flags -match "-std=.*")) + { + [string] $cppStandard = Get-Project-CppStandard + + $flags = @("-std=$cppStandard") + $flags + } + + return $flags +} + +Function Get-ProjectPlatformToolset() +{ + $propGroup = Select-ProjectNodes($kVcxprojXpathToolset) + + $toolset = $propGroup.InnerText + + if ($toolset) + { + return $toolset + } + else + { + return $kVStudioDefaultPlatformToolset + } +} + +Function Get-VisualStudio-Includes([Parameter(Mandatory=$true)][string] $vsPath, + [Parameter(Mandatory=$false)][string] $mscVer) +{ + [string] $mscVerToken = "" + If (![string]::IsNullOrEmpty($mscVer)) + { + $mscVerToken = "Tools\MSVC\$mscVer\" + } + + return @( "$vsPath\VC\$($mscVerToken)include" + , "$vsPath\VC\$($mscVerToken)atlmfc\include" + ) +} + +Function Get-VisualStudio-Path() +{ + if ($aVisualStudioVersion -eq "2015") + { + $installLocation = (Get-Item $kVs2015RegistryKey).GetValue("InstallDir") + return Canonize-Path -base $installLocation -child "..\.." + } + else + { + if (Test-Path $kVsWhereLocation) + { + [string] $product = "Microsoft.VisualStudio.Product.$aVisualStudioSku" + return (& "$kVsWhereLocation" -nologo ` + -property installationPath ` + -products $product ` + -prerelease) + } + + if (Test-Path -Path $kVs15DefaultLocation) + { + return $kVs15DefaultLocation + } + + throw "Cannot locate Visual Studio location" + } +} + +Function Get-ProjectIncludeDirectories([Parameter(Mandatory=$false)][string] $stdafxDir) +{ + [string[]] $returnArray = ($IncludePath -split ";") | ` + Where-Object { ![string]::IsNullOrEmpty($_) } | ` + ForEach-Object { Canonize-Path -base $ProjectDir -child $_ -ignoreErrors } | ` + Where-Object { ![string]::IsNullOrEmpty($_) } | ` + ForEach-Object { $_ -replace '\\$', '' } + if ($env:CPT_LOAD_ALL -eq '1') + { + return $returnArray + } + + [string] $vsPath = Get-VisualStudio-Path + Write-Verbose "Visual Studio location: $vsPath" + + [string] $platformToolset = Get-ProjectPlatformToolset + + if ($aVisualStudioVersion -eq "2015") + { + $returnArray += Get-VisualStudio-Includes -vsPath $vsPath + } + else + { + $mscVer = Get-MscVer -visualStudioPath $vsPath + Write-Verbose "MSCVER: $mscVer" + + $returnArray += Get-VisualStudio-Includes -vsPath $vsPath -mscVer $mscVer + } + + $sdkVer = Get-Project-SDKVer + + # We did not find a WinSDK version in the vcxproj. We use Visual Studio's defaults + if ([string]::IsNullOrEmpty($sdkVer)) + { + if ($platformToolset.EndsWith("xp")) + { + $sdkVer = $kVSDefaultWinSDK_XP + } + else + { + $sdkVer = $kVSDefaultWinSDK + } + } + + Write-Verbose "WinSDK version: $sdkVer" + + # ---------------------------------------------------------------------------------------------- + # Windows 10 + + if ((![string]::IsNullOrEmpty($sdkVer)) -and ($sdkVer.StartsWith("10"))) + { + $returnArray += @("${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\ucrt") + + if ($platformToolset.EndsWith("xp")) + { + $returnArray += @($kIncludePathsXPTargetingSDK) + } + else + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\um" + , "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\shared" + , "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\$sdkVer\winrt" + ) + } + } + + # ---------------------------------------------------------------------------------------------- + # Windows 8 / 8.1 + + if ((![string]::IsNullOrEmpty($sdkVer)) -and ($sdkVer.StartsWith("8."))) + { + $returnArray += @("${Env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.10240.0\ucrt") + + if ($platformToolset.EndsWith("xp")) + { + $returnArray += @($kIncludePathsXPTargetingSDK) + } + else + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\$sdkVer\Include\um" + , "${Env:ProgramFiles(x86)}\Windows Kits\$sdkVer\Include\shared" + , "${Env:ProgramFiles(x86)}\Windows Kits\$sdkVer\Include\winrt" + ) + } + } + + # ---------------------------------------------------------------------------------------------- + # Windows 7 + + if ((![string]::IsNullOrEmpty($sdkVer)) -and ($sdkVer.StartsWith("7.0"))) + { + $returnArray += @("$vsPath\VC\Auxiliary\VS\include") + + if ($platformToolset.EndsWith("xp")) + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\10.0.10240.0\ucrt" + , $kIncludePathsXPTargetingSDK + ) + } + else + { + $returnArray += @( "${Env:ProgramFiles(x86)}\Windows Kits\10\Include\7.0\ucrt") + } + } + + if (![string]::IsNullOrEmpty($stdafxDir)) + { + $returnArray = @($stdafxDir) + $returnArray + } + + return ( $returnArray | ForEach-Object { $_ -replace '\\$', '' } ) +} + +Function Get-Projects() +{ + [string[]] $projects = @() + + foreach ($slnPath in $global:slnFiles.Keys) + { + [string[]] $solutionProjects = Get-SolutionProjects -slnPath $slnPath + if ($solutionProjects.Count -gt 0) + { + $projects += $solutionProjects + } + } + + return ($projects | Select -Unique); +} + +Function Get-PchCppIncludeHeader([Parameter(Mandatory=$true)][string] $pchCppFile) +{ + [string] $cppPath = Canonize-Path -base $ProjectDir -child $pchCppFile + [string] $fileContent = Get-Content -path $cppPath + + return [regex]::match($fileContent,'#include "(\S+)"').Groups[1].Value +} + +<# +.DESCRIPTION + Retrieve directory in which stdafx.h resides +#> +Function Get-ProjectStdafxDir([Parameter(Mandatory=$true)][string] $pchHeaderName) +{ + [string[]] $projectHeaders = Get-ProjectHeaders + [string] $stdafxPath = $projectHeaders | Where-Object { (Get-FileName -path $_) -cmatch $pchHeaderName } + if ([string]::IsNullOrEmpty($stdafxPath)) + { + $stdafxPath = Canonize-Path -base $ProjectDir ` + -child $pchHeaderName + } + + [string] $stdafxDir = Get-FileDirectory($stdafxPath) + + return $stdafxDir +} + +<# +.DESCRIPTION + Retrieve directory in which the PCH CPP resides (e.g. stdafx.cpp, stdafxA.cpp) +#> +Function Get-Project-PchCpp() +{ + $pchCppRelativePath = Select-ProjectNodes($kVcxprojXpathPCH) | + Select-Object -ExpandProperty ParentNode | + Select-Object -first 1 | + Select-Object -ExpandProperty Include + + return $pchCppRelativePath +} + +Function Get-ClangIncludeDirectories( [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + ) +{ + [string[]] $returnDirs = @() + + foreach ($includeDir in $includeDirectories) + { + $returnDirs += "-isystem""$includeDir""" + } + foreach ($includeDir in $additionalIncludeDirectories) + { + if ($aTreatAdditionalIncludesAsSystemIncludes) + { + $returnDirs += "-isystem""$includeDir""" + } + else + { + $returnDirs += "-I""$includeDir""" + } + } + + return $returnDirs +} + +Function Generate-Pch( [Parameter(Mandatory=$true)] [string] $stdafxDir + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$true)] [string] $stdafxHeaderName + , [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions) +{ + [string] $stdafx = (Canonize-Path -base $stdafxDir -child $stdafxHeaderName) + [string] $vcxprojShortName = [System.IO.Path]::GetFileNameWithoutExtension($global:vcxprojPath); + [string] $stdafxPch = (Join-Path -path (Get-SourceDirectory) ` + -ChildPath "$vcxprojShortName$kExtensionClangPch") + Remove-Item -Path "$stdafxPch" -ErrorAction SilentlyContinue | Out-Null + + $global:FilesToDeleteWhenScriptQuits.Add($stdafxPch) | Out-Null + + # Supress -Werror for PCH generation as it throws warnings quite often in code we cannot control + [string[]] $clangFlags = Get-ClangCompileFlags | Where-Object { $_ -ne $kClangFlagWarningIsError } + + [string[]] $compilationFlags = @("""$stdafx""" + ,$kClangFlagEmitPch + ,$kClangFlagMinusO + ,"""$stdafxPch""" + ,$clangFlags + ,$kClangFlagNoUnusedArg + ,$preprocessorDefinitions + ) + + $compilationFlags += Get-ClangIncludeDirectories -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + Write-Verbose "INVOKE: ""$($global:llvmLocation)\$kClangCompiler"" $compilationFlags" + + [System.Diagnostics.Process] $processInfo = Start-Process -FilePath $kClangCompiler ` + -ArgumentList $compilationFlags ` + -WorkingDirectory "$(Get-SourceDirectory)" ` + -NoNewWindow ` + -Wait ` + -PassThru + if ($processInfo.ExitCode -ne 0) + { + Fail-Script "Errors encountered during PCH creation" + } + + return $stdafxPch +} + +function HasTrailingSlash([Parameter(Mandatory=$true)][string] $str) +{ + return $str.EndsWith('\') -or $str.EndsWith('/') +} + +function Exists([Parameter(Mandatory=$false)][string] $path) +{ + if ([string]::IsNullOrEmpty($path)) + { + return $false + } + + return Test-Path $path +} + +function GetRegValue([Parameter(Mandatory=$true)][string] $regPath) +{ + Write-Debug "REG_READ $regPath" + + [int] $separatorIndex = $regPath.IndexOf('@') + [string] $valueName = "" + if ($separatorIndex -gt 0) + { + [string] $valueName = $regPath.Substring($separatorIndex + 1) + $regPath = $regPath.Substring(0, $separatorIndex) + } + if ([string]::IsNullOrEmpty($valueName)) + { + throw "Cannot retrieve an empty registry value" + } + $regPath = $regPath -replace "HKEY_LOCAL_MACHINE\\", "HKLM:\" + + if (Test-Path $regPath) + { + return (Get-Item $regPath).GetValue($valueName) + } + else + { + return "" + } +} + +function Evaluate-MSBuildExpression([string] $expression, [switch] $isCondition) +{ + Write-Debug "Start evaluate MSBuild expression $expression" + + foreach ($rule in $kMsbuildExpressionToPsRules) + { + $expression = $expression -replace $rule[0], $rule[1] + } + + if ( !$isCondition -and ($expression.IndexOf('$') -lt 0)) + { + # we can stop here, further processing is not required + return $expression + } + + [int] $expressionStartIndex = -1 + [int] $openParantheses = 0 + for ([int] $i = 0; $i -lt $expression.Length; $i += 1) + { + if ($expression.Substring($i, 1) -eq '(') + { + if ($i -gt 0 -and $expressionStartIndex -lt 0 -and $expression.Substring($i - 1, 1) -eq '$') + { + $expressionStartIndex = $i - 1 + } + + if ($expressionStartIndex -ge 0) + { + $openParantheses += 1 + } + } + + if ($expression.Substring($i, 1) -eq ')' -and $expressionStartIndex -ge 0) + { + $openParantheses -= 1 + if ($openParantheses -lt 0) + { + throw "Parse error" + } + if ($openParantheses -eq 0) + { + [string] $content = $expression.Substring($expressionStartIndex + 2, + $i - $expressionStartIndex - 2) + [int] $initialLength = $content.Length + + if ([regex]::Match($content, "[a-zA-Z_][a-zA-Z0-9_\-]+").Value -eq $content) + { + # we have a plain property retrieval + $content = "`${$content}" + } + else + { + # dealing with a more complex expression + $content = $content -replace '(^|\s+|\$\()([a-zA-Z_][a-zA-Z0-9_]+)(\.|\)|$)', '$1$$$2$3' + } + + $newCond = $expression.Substring(0, $expressionStartIndex + 2) + + $content + $expression.Substring($i) + $expression = $newCond + + $i += ($content.Length - $initialLength) + $expressionStartIndex = -1 + } + } + } + + Write-Debug "Intermediate PS expression: $expression" + + try + { + [string] $toInvoke = "(`$s = ""$expression"")" + if ($isCondition) + { + $toInvoke = "(`$s = ""`$($expression)"")" + } + + $res = Invoke-Expression $toInvoke + } + catch + { + write-debug $_.Exception.Message + } + + Write-Debug "Evaluated expression to: $res" + + return $res +} +function Evaluate-MSBuildCondition([Parameter(Mandatory=$true)][string] $condition) +{ + Write-Debug "Evaluating condition $condition" + foreach ($rule in $kMsbuildConditionToPsRules) + { + $condition = $condition -replace $rule[0], $rule[1] + } + $expression = Evaluate-MSBuildExpression -expression $condition -isCondition + + if ($expression -ieq "true") + { + return $true + } + + if ($expression -ieq "false") + { + return $false + } + + [bool] $res = $false + try + { + $res = (Invoke-Expression $expression) -eq $true + } + catch + { + Write-Debug $_.Exception.Message + } + Write-Debug "Evaluated condition to $res" + + return $res +} + +<# +.DESCRIPTION +A wrapper over the XmlDOcument.SelectNodes function. For convenience. +Not to be used directly. Please use Select-ProjectNodes instead. +#> +function Help:Get-ProjectFileNodes([xml] $projectFile, [string] $xpath) +{ + [System.Xml.XmlElement[]] $nodes = $projectFile.SelectNodes($xpath, $global:xpathNS) + return $nodes +} + +function GetNodeInheritanceToken([System.Xml.XmlNode] $node) +{ + [string] $inheritanceToken = "%($($node.Name))"; + if ($node.InnerText.Contains($inheritanceToken)) + { + return $inheritanceToken + } + + return "" +} + +function ReplaceInheritedNodeValue([System.Xml.XmlNode] $currentNode + ,[System.Xml.XmlNode] $nodeToInheritFrom + ) +{ + [string] $inheritanceToken = GetNodeInheritanceToken($currentNode) + if ([string]::IsNullOrEmpty($inheritanceToken)) + { + # no need to inherit + return $false + } + + [string] $replaceWith = "" + if ($nodeToInheritFrom) + { + $replaceWith = $nodeToInheritFrom.InnerText + } + + [string] $whatToReplace = [regex]::Escape($inheritanceToken); + if ([string]::IsNullOrEmpty($replaceWith)) + { + # handle semicolon separators + [string] $escTok = [regex]::Escape($inheritanceToken) + $whatToReplace = "(;$escTok)|($escTok;)|($escTok)" + } + + # replace inherited token and redundant separators + $replacementRules = @(,($whatToReplace, $replaceWith)) + $kRedundantSeparatorsReplaceRules + foreach ($rule in $replacementRules) + { + $currentNode.InnerText = $currentNode.InnerText -replace $rule[0], $rule[1] + } + + return $currentNode.InnerText.Contains($inheritanceToken) +} + +<# +.SYNOPSIS +Selects one or more nodes from the project. +.DESCRIPTION +We often need to access data from the project, e.g. additional includes, Win SDK version. +A naive implementation would be to simply look inside the vcxproj, but that leaves out +property sheets. + +This function takes care to retrieve the nodes we're searching by looking in both the .vcxproj +and property sheets, taking care to inherit values accordingly. +.EXAMPLE +Give an example of how to use it +.EXAMPLE +Give another example of how to use it. +.PARAMETER xpath +XPath we want to use for searching nodes. +.PARAMETER fileIndex +Optional. Index of the project xml file we want to start our search in. +0 = .vcxproj and then, recursively, all property sheets +1 = first property sheet and then, recursively, all other property sheets +etc. +#> +function Select-ProjectNodes([Parameter(Mandatory=$true)] [string][string] $xpath + ,[Parameter(Mandatory=$false)] [int] $fileIndex = 0) +{ + [System.Xml.XmlElement[]] $nodes = @() + + if ($fileIndex -ge $global:projectFiles.Count) + { + return $nodes + } + + $nodes = Help:Get-ProjectFileNodes -projectFile $global:projectFiles[$fileIndex] ` + -xpath $xpath + + # nothing on this level or we're dealing with an ItemGroup, go above + if ($nodes.Count -eq 0 -or $xpath.Contains("ItemGroup")) + { + [System.Xml.XmlElement[]] $upperNodes = Select-ProjectNodes -xpath $xpath -fileIndex ($fileIndex + 1) + if ($upperNodes.Count -gt 0) + { + $nodes += $upperNodes + } + return $nodes + } + + if ($nodes[$nodes.Count -1]."#text") + { + # we found textual settings that can be inherited. see if we should inherit + + [System.Xml.XmlNode] $nodeToReturn = $nodes[$nodes.Count -1] + if ($nodeToReturn.Attributes.Count -gt 0) + { + throw "Did not expect node to have attributes" + } + + [bool] $shouldInheritMore = ![string]::IsNullOrEmpty((GetNodeInheritanceToken -node $nodeToReturn)) + for ([int] $i = $nodes.Count - 2; ($i -ge 0) -and $shouldInheritMore; $i -= 1) + { + $shouldInheritMore = ReplaceInheritedNodeValue -currentNode $nodeToReturn -nodeToInheritFrom $nodes[$i] + } + + if ($shouldInheritMore) + { + [System.Xml.XmlElement[]] $inheritedNodes = Select-ProjectNodes -xpath $xpath -fileIndex ($fileIndex + 1) + if ($inheritedNodes.Count -gt 1) + { + throw "Did not expect to inherit more than one node" + } + if ($inheritedNodes.Count -eq 1) + { + $shouldInheritMore = ReplaceInheritedNodeValue -currentNode $nodeToReturn -nodeToInheritFrom $inheritedNodes[0] + } + } + + # we still could have to inherit from parents but when not loading + # all MS prop sheets we have nothing to inherit from, delete inheritance token + ReplaceInheritedNodeValue -currentNode $nodeToReturn -nodeToInheritFrom $null | Out-Null + + return @($nodeToReturn) + } + else + { + # return what we found + return $nodes + } +} + +<# +.DESCRIPTION + Finds the first config-platform pair in the vcxproj. + We'll use it for all project data retrievals. + + Items for other config-platform pairs will be removed from the DOM. + This is needed so that our XPath selectors don't get confused when looking for data. +#> +function Detect-ProjectDefaultConfigPlatform([string] $projectValue) +{ + [string]$configPlatformName = "" + + if (![string]::IsNullOrEmpty($aVcxprojConfigPlatform)) + { + $configPlatformName = $aVcxprojConfigPlatform + } + else + { + $configPlatformName = $projectValue + } + + if ([string]::IsNullOrEmpty($configPlatformName)) + { + throw "Could not automatically detect a configuration platform" + } + + [string[]] $configAndPlatform = $configPlatformName.Split('|') + Set-Var -Name "Configuration" -Value $configAndPlatform[0] + Set-Var -Name "Platform" -Value $configAndPlatform[1] +} + +function HandleChooseNode([System.Xml.XmlNode] $aChooseNode) +{ + SanitizeProjectNode $aChooseNode + if ($aChooseNode.ChildNodes.Count -eq 0) + { + return + } + + [System.Xml.XmlElement] $selectedChild = $aChooseNode.ChildNodes | ` + Where-Object { $_.GetType().Name -eq "XmlElement" } | ` + Select -first 1 + + foreach ($selectedGrandchild in $selectedChild.ChildNodes) + { + $aChooseNode.ParentNode.AppendChild($selectedGrandchild.Clone()) | Out-Null + } + + $aChooseNode.ParentNode.RemoveChild($aChooseNode) | Out-Null +} + +function SanitizeProjectNode([System.Xml.XmlNode] $node) +{ + if ($node.Name -ieq "#comment") + { + return + } + + [System.Collections.ArrayList] $nodesToRemove = @() + + if ($node.Name -ieq "#text" -and $node.InnerText.Length -gt 0) + { + # evaluate node content + $node.InnerText = Evaluate-MSBuildExpression $node.InnerText + } + + if ($node.Name -ieq "Import") + { + [string] $relPath = Evaluate-MSBuildExpression $node.GetAttribute("Project") + [string[]] $paths = Canonize-Path -base (Get-Location) -child $relPath -ignoreErrors + + foreach ($path in $paths) + { + if (![string]::IsNullOrEmpty($path) -and (Test-Path $path)) + { + Write-Verbose "Property sheet: $path" + SanitizeProjectFile($path) + } + else + { + Write-Verbose "Could not find property sheet $relPath" + } + } + } + + if ( ($node.Name -ieq "ClCompile" -or $node.Name -ieq "ClInclude") -and + ![string]::IsNullOrEmpty($node.GetAttribute("Include")) ) + { + [string] $expandedAttr = Evaluate-MSBuildExpression $node.GetAttribute("Include") + $node.Attributes["Include"].Value = $expandedAttr + } + + if ($node.Name -ieq "Choose") + { + HandleChooseNode $chooseChild + } + + if ($node.Name -ieq "Otherwise") + { + [System.Xml.XmlElement[]] $siblings = $node.ParentNode.ChildNodes | ` + Where-Object { $_.GetType().Name -ieq "XmlElement" -and $_ -ne $node } + if ($siblings.Count -gt 0) + { + # means there's a element that matched + # should not be evaluated, we could set unwated properties + return + } + } + + if ($node.Name -ieq "ItemGroup" -and $node.GetAttribute("Label") -ieq "ProjectConfigurations") + { + Detect-ProjectDefaultConfigPlatform $node.ChildNodes[0].GetAttribute("Include") + } + + if ($node.ParentNode.Name -ieq "PropertyGroup") + { + # set new property value + [string] $propertyName = $node.Name + [string] $propertyValue = Evaluate-MSBuildExpression $node.InnerText + + Set-Var -Name $propertyName -Value $propertyValue + + return + } + + foreach ($child in $node.ChildNodes) + { + [bool] $validChild = $true + if ($child.GetType().Name -ieq "XmlElement") + { + if ($child.HasAttribute("Condition")) + { + # process node condition + [string] $nodeCondition = $child.GetAttribute("Condition") + $validChild = ((Evaluate-MSBuildCondition($nodeCondition)) -eq $true) + if ($validChild) + { + $child.RemoveAttribute("Condition") + } + } + } + if (!$validChild) + { + $nodesToRemove.Add($child) | out-null + continue + } + else + { + SanitizeProjectNode($child) + } + } + + foreach ($nodeToRemove in $nodesToRemove) + { + $nodeToRemove.ParentNode.RemoveChild($nodeToRemove) | out-null + } +} + +<# +.DESCRIPTION + Sanitizes a project xml file, by removing config-platform pairs different from the + one we selected. + This is needed so that our XPath selectors don't get confused when looking for data. +#> +function SanitizeProjectFile([string] $projectFilePath) +{ + Write-Verbose "`nSanitizing $projectFilePath" + + [xml] $fileXml = Get-Content $projectFilePath + $global:projectFiles += @($fileXml) + $global:xpathNS = New-Object System.Xml.XmlNamespaceManager($fileXml.NameTable) + $global:xpathNS.AddNamespace("ns", $fileXml.DocumentElement.NamespaceURI) + + Push-Location (Get-FileDirectory -filePath $projectFilePath) + + InitializeMsBuildCurrentFileProperties -filePath $projectFilePath + SanitizeProjectNode($fileXml.Project) + + Pop-Location +} + +<# +.DESCRIPTION + Tries to find a Directory.Build.props property sheet, starting from the + project directories, going up. When one is found, the search stops. + + Multiple Directory.Build.props sheets are not supported. +#> +function Get-AutoPropertySheet() +{ + $startPath = $global:vcxprojPath + while ($true) + { + $propSheetPath = Canonize-Path -base $startPath ` + -child "Directory.Build.props" ` + -ignoreErrors + if (![string]::IsNullOrEmpty($propSheetPath)) + { + return $propSheetPath + } + + $newPath = Canonize-Path -base $startPath -child ".." + if ($newPath -eq $startPath) + { + return "" + } + $startPath = $newPath + } +} + +<# +.DESCRIPTION +Loads vcxproj and property sheets into memory. This needs to be called only once +when processing a project. Accessing project nodes can be done using Select-ProjectNodes. +#> +function LoadProject([string] $vcxprojPath) +{ + $global:vcxprojPath = $vcxprojPath + + InitializeMsBuildProjectProperties + + # see if we can find a Directory.Build.props automatic prop sheet + [string[]] $propSheetAbsolutePaths = @() + [xml[]] $autoPropSheetXmls = $null + $autoPropSheet = Get-AutoPropertySheet + if (![string]::IsNullOrEmpty($autoPropSheet)) + { + SanitizeProjectFile -projectFilePath $autoPropSheet + $autoPropSheetXmls = $global:projectFiles + } + + # the auto-prop sheet has to be last in the node retrieval sources + # but properties defined in it have to be accessible in all project files :( + $global:projectFiles = @() + + SanitizeProjectFile -projectFilePath $global:vcxprojPath + + if ($autoPropSheetXml) + { + $global:projectFiles += $autoPropSheetXmls + } +} + +<# +.DESCRIPTION + Retrieve array of preprocessor definitions for a given project, in Clang format (-DNAME ) +#> +Function Get-ProjectPreprocessorDefines() +{ + [string[]] $tokens = (Select-ProjectNodes $kVcxprojXpathPreprocessorDefs).InnerText -split ";" + + # make sure we add the required prefix and escape double quotes + [string[]]$defines = ( $tokens | ` + Where-Object { $_ } | ` + ForEach-Object { '"' + $(($kClangDefinePrefix + $_) -replace '"','\"') + '"' } ) + + if (Is-Project-Unicode) + { + $defines += $kDefinesUnicode + } + + [string] $platformToolset = Get-ProjectPlatformToolset + if ($platformToolset.EndsWith("xp")) + { + $defines += $kDefinesClangXpTargeting + } + + return $defines +} + +Function Get-ProjectAdditionalIncludes() +{ + [string[]] $tokens = @() + + $data = Select-ProjectNodes $kVcxprojXpathAdditionalIncludes + $tokens += ($data).InnerText -split ";" + + foreach ($token in $tokens) + { + if ([string]::IsNullOrEmpty($token)) + { + continue + } + + [string] $includePath = Canonize-Path -base $ProjectDir -child $token -ignoreErrors + if (![string]::IsNullOrEmpty($includePath)) + { + $includePath -replace '\\$', '' + } + } +} + +Function Get-ProjectForceIncludes() +{ + [System.Xml.XmlElement] $forceIncludes = Select-ProjectNodes $kVcxprojXpathForceIncludes + if ($forceIncludes) + { + return $forceIncludes.InnerText -split ";" + } + + return $null +} + +Function Get-ExeToCall([Parameter(Mandatory=$true)][WorkloadType] $workloadType) +{ + switch ($workloadType) + { + "Compile" { return $kClangCompiler } + "Tidy" { return $kClangTidy } + "TidyFix" { return $kClangTidy } + } +} + +Function Get-CompileCallArguments( [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$false)][string[]] $forceIncludeFiles + , [Parameter(Mandatory=$false)][string] $pchFilePath + , [Parameter(Mandatory=$true)][string] $fileToCompile) +{ + [string[]] $projectCompileArgs = @() + if (! [string]::IsNullOrEmpty($pchFilePath)) + { + $projectCompileArgs += @($kClangFlagIncludePch , """$pchFilePath""") + } + + $projectCompileArgs += @( $kClangFlagFileIsCPP + , """$fileToCompile""" + , @(Get-ClangCompileFlags) + , $kClangFlagSupressLINK + , $preprocessorDefinitions + ) + + $projectCompileArgs += Get-ClangIncludeDirectories -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + if ($forceIncludeFiles) + { + $projectCompileArgs += $kClangFlagNoMsInclude; + + foreach ($file in $forceIncludeFiles) + { + $projectCompileArgs += "$kClangFlagForceInclude $file" + } + } + + return $projectCompileArgs +} + +Function Get-TidyCallArguments( [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$false)][string[]] $forceIncludeFiles + , [Parameter(Mandatory=$true)][string] $fileToTidy + , [Parameter(Mandatory=$false)][string] $pchFilePath + , [Parameter(Mandatory=$false)][switch] $fix) +{ + [string[]] $tidyArgs = @("""$fileToTidy""") + if ($fix -and $aTidyFixFlags -ne $kClangTidyUseFile) + { + $tidyArgs += "$kClangTidyFlagChecks$aTidyFixFlags" + } + elseif ($aTidyFlags -ne $kClangTidyUseFile) + { + $tidyArgs += "$kClangTidyFlagChecks$aTidyFlags" + } + + # The header-filter flag enables clang-tidy to run on headers too. + if (![string]::IsNullOrEmpty($aTidyHeaderFilter)) + { + if ($aTidyHeaderFilter -eq '_') + { + [string] $fileNameMatch = """$(Get-FileName -path $fileToTidy -noext).*""" + $tidyArgs += "$kClangTidyFlagHeaderFilter$fileNameMatch" + } + else + { + $tidyArgs += "$kClangTidyFlagHeaderFilter""$aTidyHeaderFilter""" + } + } + + if ($fix) + { + if (![string]::IsNullOrEmpty($aAfterTidyFixFormatStyle)) + { + $tidyArgs += "$kClangTidyFormatStyle$aAfterTidyFixFormatStyle" + } + + $tidyArgs += $kClangTidyFixFlags + } + else + { + $tidyArgs += $kClangTidyFlags + } + + $tidyArgs += Get-ClangIncludeDirectories -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + # We reuse flags used for compilation and preprocessor definitions. + $tidyArgs += @(Get-ClangCompileFlags) + $tidyArgs += $preprocessorDefinitions + $tidyArgs += $kClangFlagFileIsCPP + + if (! [string]::IsNullOrEmpty($pchFilePath)) + { + $tidyArgs += @($kClangFlagIncludePch , """$pchFilePath""") + } + + if ($forceIncludeFiles) + { + $tidyArgs += $kClangFlagNoMsInclude; + + foreach ($file in $forceIncludeFiles) + { + $tidyArgs += "$kClangFlagForceInclude $file" + } + } + + return $tidyArgs +} + +Function Get-ExeCallArguments( [Parameter(Mandatory=$false)][string] $pchFilePath + , [Parameter(Mandatory=$false)][string[]] $includeDirectories + , [Parameter(Mandatory=$false)][string[]] $additionalIncludeDirectories + , [Parameter(Mandatory=$false)][string[]] $preprocessorDefinitions + , [Parameter(Mandatory=$false)][string[]] $forceIncludeFiles + , [Parameter(Mandatory=$true) ][string] $currentFile + , [Parameter(Mandatory=$true) ][WorkloadType] $workloadType) +{ + switch ($workloadType) + { + Compile { return Get-CompileCallArguments -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories ` + -forceIncludeFiles $forceIncludeFiles ` + -pchFilePath $pchFilePath ` + -fileToCompile $currentFile } + Tidy { return Get-TidyCallArguments -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories ` + -forceIncludeFiles $forceIncludeFiles ` + -pchFilePath $pchFilePath ` + -fileToTidy $currentFile } + TidyFix { return Get-TidyCallArguments -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories ` + -forceIncludeFiles $forceIncludeFiles ` + -pchFilePath $pchFilePath ` + -fileToTidy $currentFile ` + -fix} + } +} + +Function Process-ProjectResult($compileResult) +{ + if (!$compileResult.Success) + { + Write-Err ($compileResult.Output) + + if (!$aContinueOnError) + { + # Wait for other workers to finish. They have a lock on the PCH file + Get-Job -state Running | Wait-Job | Remove-Job | Out-Null + Fail-Script + } + + $global:FoundErrors = $true + } + else + { + if ( $compileResult.Output.Length -gt 0) + { + Write-Output $compileResult.Output + } + } +} + +Function Wait-AndProcessBuildJobs([switch]$any) +{ + $runningJobs = @(Get-Job -state Running) + + if ($any) + { + $runningJobs | Wait-Job -Any | Out-Null + } + else + { + $runningJobs | Wait-Job | Out-Null + } + + $jobData = Get-Job -State Completed + foreach ($job in $jobData) + { + $buildResult = Receive-Job $job + Process-ProjectResult -compileResult $buildResult + } + + Remove-Job -State Completed +} + +Function Wait-ForWorkerJobSlot() +{ + # We allow as many background workers as we have logical CPU cores + $runningJobs = @(Get-Job -State Running) + + if ($runningJobs.Count -ge $kLogicalCoreCount) + { + Wait-AndProcessBuildJobs -any + } +} + +Function Run-ClangJobs([Parameter(Mandatory=$true)] $clangJobs) +{ + # Script block (lambda) for logic to be used when running a clang job. + $jobWorkToBeDone = ` + { + param( $job ) + + Push-Location $job.WorkingDirectory + + $callOutput = & $job.FilePath $job.ArgumentList.Split(' ') 2>&1 |` + ForEach-Object { $_.ToString() } |` + Out-String + + $callSuccess = $LASTEXITCODE -eq 0 + + Pop-Location + + return New-Object PsObject -Prop @{ "File" = $job.File; + "Success" = $callSuccess; + "Output" = $callOutput } + } + + [int] $jobCount = $clangJobs.Count + [int] $crtJobCount = $jobCount + + foreach ($job in $clangJobs) + { + # Check if we must wait for background jobs to complete + Wait-ForWorkerJobSlot + + # Inform console what CPP we are processing next + Write-Output "$($crtJobCount): $($job.File)" + + if ($aUseParallelCompile) + { + Start-Job -ScriptBlock $jobWorkToBeDone ` + -ArgumentList $job ` + -ErrorAction Continue | Out-Null + } + else + { + $compileResult = Invoke-Command -ScriptBlock $jobWorkToBeDone ` + -ArgumentList $job + Process-ProjectResult -compileResult $compileResult + } + + $crtJobCount -= 1 + } + + Wait-AndProcessBuildJobs +} + +Function Process-Project( [Parameter(Mandatory=$true)][string] $vcxprojPath + , [Parameter(Mandatory=$true)][WorkloadType] $workloadType) +{ + # Load data + LoadProject($vcxprojPath) + + #----------------------------------------------------------------------------------------------- + # FIND FORCE INCLUDES + + [string[]] $forceIncludeFiles = Get-ProjectForceIncludes + Write-Verbose "Force includes: $forceIncludeFiles" + + #----------------------------------------------------------------------------------------------- + # LOCATE STDAFX.H DIRECTORY + + [string] $stdafxCpp = Get-Project-PchCpp + [string] $stdafxDir = "" + [string] $stdafxHeader = "" + + if (![string]::IsNullOrEmpty($stdafxCpp)) + { + Write-Verbose "PCH cpp name: $stdafxCpp" + + if ($forceIncludeFiles.Count -gt 0) + { + $stdafxHeader = $forceIncludeFiles[0] + } + else + { + $stdafxHeader = Get-PchCppIncludeHeader -pchCppFile $stdafxCpp + } + + Write-Verbose "PCH header name: $stdafxHeader" + $stdafxDir = Get-ProjectStdafxDir -pchHeaderName $stdafxHeader + } + + if ([string]::IsNullOrEmpty($stdafxDir)) + { + Write-Verbose ("PCH not enabled for this project!") + } + else + { + Write-Verbose ("PCH directory: $stdafxDir") + } + #----------------------------------------------------------------------------------------------- + # DETECT PROJECT PREPROCESSOR DEFINITIONS + + [string[]] $preprocessorDefinitions = Get-ProjectPreprocessorDefines + if ($aVisualStudioVersion -eq "2017") + { + # [HACK] pch generation crashes on VS 15.5 because of STL library, known bug. + # Triggered by addition of line directives to improve std::function debugging. + # There's a definition that supresses line directives. + + [string] $mscVer = Get-MscVer -visualStudioPath $vsPath + if ($mscVer -eq "14.12.25827") + { + $preprocessorDefinitions += "-D_DEBUG_FUNCTIONAL_MACHINERY" + } + } + + Write-Verbose-Array -array $preprocessorDefinitions -name "Preprocessor definitions" + + #----------------------------------------------------------------------------------------------- + # DETECT PLATFORM TOOLSET + + [string] $platformToolset = Get-ProjectPlatformToolset + Write-Verbose "Platform toolset: $platformToolset" + + #----------------------------------------------------------------------------------------------- + # DETECT PROJECT ADDITIONAL INCLUDE DIRECTORIES AND CONSTRUCT INCLUDE PATHS + + [string[]] $additionalIncludeDirectories = Get-ProjectAdditionalIncludes + Write-Verbose-Array -array $additionalIncludeDirectories -name "Additional include directories" + + [string[]] $includeDirectories = Get-ProjectIncludeDirectories -stdafxDir $stdafxDir + Write-Verbose-Array -array $includeDirectories -name "Include directories" + + #----------------------------------------------------------------------------------------------- + # FIND LIST OF CPPs TO PROCESS + + [string[]] $projCpps = Get-ProjectFilesToCompile -pchCppName $stdafxCpp + + if (![string]::IsNullOrEmpty($aCppToCompile)) + { + $projCpps = ( $projCpps | + Where-Object { IsFileMatchingName -filePath $_ ` + -matchName $aCppToCompile } ) + } + Write-Verbose ("Processing " + $projCpps.Count + " cpps") + + #----------------------------------------------------------------------------------------------- + # CREATE PCH IF NEED BE, ONLY FOR TWO CPPS OR MORE + + [string] $pchFilePath = "" + if ($projCpps.Count -ge 2 -and + ![string]::IsNullOrEmpty($stdafxDir)) + { + # COMPILE PCH + Write-Verbose "Generating PCH..." + $pchFilePath = Generate-Pch -stdafxDir $stdafxDir ` + -stdafxHeaderName $stdafxHeader ` + -preprocessorDefinitions $preprocessorDefinitions ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + Write-Verbose "PCH: $pchFilePath" + } + + #----------------------------------------------------------------------------------------------- + # PROCESS CPP FILES. CONSTRUCT COMMAND LINE JOBS TO BE INVOKED + + $clangJobs = @() + + foreach ($cpp in $projCpps) + { + [string] $exeToCall = Get-ExeToCall -workloadType $workloadType + + [string] $exeArgs = Get-ExeCallArguments -workloadType $workloadType ` + -pchFilePath $pchFilePath ` + -preprocessorDefinitions $preprocessorDefinitions ` + -forceIncludeFiles $forceIncludeFiles ` + -currentFile $cpp ` + -includeDirectories $includeDirectories ` + -additionalIncludeDirectories $additionalIncludeDirectories + + $newJob = New-Object PsObject -Prop @{ 'FilePath' = $exeToCall; + 'WorkingDirectory'= Get-SourceDirectory; + 'ArgumentList' = $exeArgs; + 'File' = $cpp } + $clangJobs += $newJob + } + + #----------------------------------------------------------------------------------------------- + # PRINT DIAGNOSTICS + + if ($clangJobs.Count -ge 1) + { + Write-Verbose "INVOKE: ""$($global:llvmLocation)\$exeToCall"" $($clangJobs[0].ArgumentList)" + } + + #----------------------------------------------------------------------------------------------- + # RUN CLANG JOBS + + Run-ClangJobs -clangJobs $clangJobs + + #----------------------------------------------------------------------------------------------- + # CLEAN GLOBAL VARIABLES SPECIFIC TO CURRENT PROJECT + + Clear-Vars +} + +#------------------------------------------------------------------------------------------------- +# Script entry point + +Clear-Host # clears console + +#------------------------------------------------------------------------------------------------- +# Print script parameters + +$bParams = $PSCmdlet.MyInvocation.BoundParameters +if ($bParams) +{ + [string] $paramStr = "clang-build.ps1 invocation args: `n" + foreach ($key in $bParams.Keys) + { + $paramStr += " $($key) = $($bParams[$key]) `n" + } + Write-Verbose $paramStr +} + +#------------------------------------------------------------------------------------------------- +# Script entry point + +Write-Verbose "CPU logical core count: $kLogicalCoreCount" + +# If LLVM is not in PATH try to detect it automatically +if (! (Exists-Command($kClangCompiler)) ) +{ + foreach ($locationLLVM in $kLLVMInstallLocations) + { + if (Test-Path $locationLLVM) + { + Write-Verbose "LLVM location: $locationLLVM" + $env:Path += ";$locationLLVM" + $global:llvmLocation = $locationLLVM + break + } + } +} + +Push-Location (Get-SourceDirectory) + +# fetch .sln paths and data +Load-Solutions + +# This powershell process may already have completed jobs. Discard them. +Remove-Job -State Completed + +Write-Verbose "Source directory: $(Get-SourceDirectory)" +Write-Verbose "Scanning for project files" + +[System.IO.FileInfo[]] $projects = Get-Projects +Write-Verbose ("Found $($projects.Count) projects") + +[System.IO.FileInfo[]] $projectsToProcess = @() + +if ([string]::IsNullOrEmpty($aVcxprojToCompile) -and + [string]::IsNullOrEmpty($aVcxprojToIgnore)) +{ + Write-Verbose "PROCESSING ALL PROJECTS" + $projectsToProcess = $projects +} +else +{ + $projectsToProcess = $projects | + Where-Object { (Should-CompileProject -vcxprojPath $_.FullName) ` + -and !(Should-IgnoreProject -vcxprojPath $_.FullName ) } + + if ($projectsToProcess.Count -gt 1) + { + Write-Output ("PROJECTS: `n`t" + ($projectsToProcess -join "`n`t")) + $projectsToProcess = $projectsToProcess + } + + if ($projectsToProcess.Count -eq 0) + { + Write-Err "Cannot find given project" + } +} + +$projectCounter = $projectsToProcess.Length; +foreach ($project in $projectsToProcess) +{ + [string] $vcxprojPath = $project.FullName; + + [WorkloadType] $workloadType = [WorkloadType]::Compile + + if (![string]::IsNullOrEmpty($aTidyFlags)) + { + $workloadType = [WorkloadType]::Tidy + } + + if (![string]::IsNullOrEmpty($aTidyFixFlags)) + { + $workloadType = [WorkloadType]::TidyFix + } + + Write-Output ("`nPROJECT$(if ($projectCounter -gt 1) { " #$projectCounter" } else { } ): " + $vcxprojPath) + Process-Project -vcxprojPath $vcxprojPath -workloadType $workloadType + + $projectCounter -= 1 +} + +if ($global:FoundErrors) +{ + Fail-Script +} +else +{ + Exit-Script +} \ No newline at end of file diff --git a/scripts/msbuild_translation_tests.ps1 b/scripts/msbuild_translation_tests.ps1 new file mode 100644 index 0000000000..0340cf2eed --- /dev/null +++ b/scripts/msbuild_translation_tests.ps1 @@ -0,0 +1,334 @@ +# Tests for ClangPowerTools MSBUILD Expression/Condition translation + +$Configuration = "Release2" +$Platform = "Win32" +$UserRootDir = "c:\test" +$SolutionDir = "C:\AI Trunk\ClangPowerToolsProblem" +$ProjectDir = "C:\AI Trunk\win" +$TargetName = "YOLOTest" +$varB = 1 + +# ------------------------------------------------------------------------------------------------------------------- + +Set-Variable -name "kMsbuildExpressionToPsRules" -option Constant ` + -value @(<# backticks are control characters in PS, replace them #> + ('`' , '''' )` + <# Temporarily replace $( #> ` + , ('\$\s*\(' , '!@#' )` + <# Escape $ #> ` + , ('\$' , '`$' )` + <# Put back $( #> ` + , ('!@#' , '$(' )` + <# Various operators #> ` + , ("([\s\)\'""])!=" , '$1 -ne ' )` + , ("([\s\)\'""])<=" , '$1 -le ' )` + , ("([\s\)\'""])>=" , '$1 -ge ' )` + , ("([\s\)\'""])==" , '$1 -eq ' )` + , ("([\s\)\'""])<" , '$1 -lt ' )` + , ("([\s\)\'""])>" , '$1 -gt ' )` + , ("([\s\)\'""])or" , '$1 -or ' )` + , ("([\s\)\'""])and" , '$1 -and ' )` + <# Use only double quotes #> ` + , ("\'" , '"' )` + , ("Exists\((.*?)\)(\s|$)" , '(Exists($1))$2' )` + , ("HasTrailingSlash\((.*?)\)(\s|$)" , '(HasTrailingSlash($1))$2' )` + , ("(\`$\()(Registry:)(.*?)(\))" , '$$(GetRegValue("$3"))' )` + ) + +Set-Variable -name "kMsbuildConditionToPsRules" -option Constant ` + -value @(<# Use only double quotes #> ` + ("\'" , '"' )` + <# We need to escape double quotes since we will eval() the condition #> ` + , ('"' , '""' )` + ) + +function GetRegValue([Parameter(Mandatory=$true)][string] $regPath) +{ + [int] $separatorIndex = $regPath.IndexOf('@') + [string] $valueName = "" + if ($separatorIndex -gt 0) + { + [string] $valueName = $regPath.Substring($separatorIndex + 1) + $regPath = $regPath.Substring(0, $separatorIndex) + } + if ([string]::IsNullOrEmpty($valueName)) + { + throw "Cannot retrieve an empty registry value" + } + $regPath = $regPath -replace "HKEY_LOCAL_MACHINE\\", "HKLM:\" + + if (Test-Path $regPath) + { + return (Get-Item $regPath).GetValue($valueName) + } + else + { + return "" + } +} + +function HasTrailingSlash([Parameter(Mandatory=$true)][string] $str) +{ + return $str.EndsWith('\') -or $str.EndsWith('/') +} + +function Exists([Parameter(Mandatory=$false)][string] $path) +{ + if ([string]::IsNullOrEmpty($path)) + { + return $false + } + return Test-Path $path +} + +function Evaluate-MSBuildExpression([string] $expression, [switch] $isCondition) +{ + Write-Debug "Start evaluate MSBuild expression $expression" + + foreach ($rule in $kMsbuildExpressionToPsRules) + { + $expression = $expression -replace $rule[0], $rule[1] + } + + if ( !$isCondition -and ($expression.IndexOf('$') -lt 0)) + { + # we can stop here, further processing is not required + return $expression + } + + [int] $expressionStartIndex = -1 + [int] $openParantheses = 0 + for ([int] $i = 0; $i -lt $expression.Length; $i += 1) + { + if ($expression.Substring($i, 1) -eq '(') + { + if ($i -gt 0 -and $expressionStartIndex -lt 0 -and $expression.Substring($i - 1, 1) -eq '$') + { + $expressionStartIndex = $i - 1 + } + + if ($expressionStartIndex -ge 0) + { + $openParantheses += 1 + } + } + + if ($expression.Substring($i, 1) -eq ')' -and $expressionStartIndex -ge 0) + { + $openParantheses -= 1 + if ($openParantheses -lt 0) + { + throw "Parse error" + } + if ($openParantheses -eq 0) + { + [string] $content = $expression.Substring($expressionStartIndex + 2, + $i - $expressionStartIndex - 2) + [int] $initialLength = $content.Length + + if ([regex]::Match($content, "[a-zA-Z_][a-zA-Z0-9_\-]+").Value -eq $content) + { + # we have a plain property retrieval + $content = "`${$content}" + } + else + { + # dealing with a more complex expression + $content = $content -replace '(^|\s+|\$\()([a-zA-Z_][a-zA-Z0-9_]+)(\.|\)|$)', '$1$$$2$3' + } + + $newCond = $expression.Substring(0, $expressionStartIndex + 2) + + $content + $expression.Substring($i) + $expression = $newCond + + $i += ($content.Length - $initialLength) + $expressionStartIndex = -1 + } + } + } + + Write-Debug "Intermediate PS expression: $expression" + + try + { + [string] $toInvoke = "(`$s = ""$expression"")" + if ($isCondition) + { + $toInvoke = "(`$s = ""`$($expression)"")" + } + + $res = Invoke-Expression $toInvoke + } + catch + { + write-debug $_.Exception.Message + } + + Write-Debug "Evaluated expression to: $res" + + return $res +} + +function Evaluate-MSBuildCondition([Parameter(Mandatory=$true)][string] $condition) +{ + Write-Debug "Evaluating condition $condition" + foreach ($rule in $kMsbuildConditionToPsRules) + { + $condition = $condition -replace $rule[0], $rule[1] + } + $expression = Evaluate-MSBuildExpression -expression $condition -isCondition + + if ($expression -ieq "true") + { + return $true + } + + if ($expression -ieq "false") + { + return $false + } + + [bool] $res = $false + try + { + $res = (Invoke-Expression $expression) -eq $true + } + catch + { + Write-Debug $_.Exception.Message + } + Write-Debug "Evaluated condition to $res" + + return $res +} + +Clear-Host + +function Test-Condition([string] $condition, [bool]$expectation, [switch] $expectFailure) +{ + [boolean] $condValue + try + { + $condValue = Evaluate-MSBuildCondition $condition + } + catch + { + if ($expectFailure) + { + Write-Output "TEST OK" + return + } + else + { + Write-Output $_.Exception.Message + throw "Test failed" + } + } + + if ($condValue -ne $expectation) + { + Write-Output "Expected $expectation | Got $condValue" + throw "Test failed" + } + Write-Output "TEST OK" +} + +function Test-Expression($expresion) +{ + $res = Evaluate-MSBuildExpression $expresion + Write-output $res +} +# ---------------------------------------------------------------------------- + +Test-Condition "'`$(ImportDirectoryBuildProps)' == 'true' and exists('`$(DirectoryBuildPropsPath)')" -expectation $false + +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\VisualStudio\15.0\AD7Metrics\ExpressionEvaluator\{3A12D0B7-C26C-11D0-B442-00A0244A1DD2}\{994B45C4-E6E9-11D2-903F-00C04FA302A1}@LoadInShimManagedEE)' +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder)' +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder)' + +Test-Expression '$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)' +Test-Expression '$(GetRegValue("HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v10.0@InstallationFolder"))' + + +Test-Condition "'`$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A@InstallationFolder)' != ''" ` + -expectation $true + +Test-Condition "'`$(Registry:HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\DevDiv\vs\Servicing\11.0\professional@Version)' == ''" ` + -expectation $true + + +Test-Condition -condition "'`$(Configuration)|`$(Platform)'=='Debug|Win32' or '`$(Configuration)' == 'Release2'" ` + -expectation $true + +Test-Condition -condition "'`$(Platform)'=='x64' or '`$(Platform)'=='Win32' or '`$(Platform)'=='Durango' or exists('`$(UserRootDir)\Microsoft.Cpp.`$(Platform).user.props2')"` + -expectation $true + +Test-Condition -condition "exists('c:\ai trunk')"` + -expectation $true + +Test-Condition -condition "'`$(Configuration)|`$(Platform)'=='Release|Win32'"` + -expectation $false + +Test-Condition -condition '$(Platform.Replace(" ", "")) and $(testB)'` + -expectation $false + +Test-Condition -condition '$(Platform) and $(varB)'` + -expectation $true + +Test-Condition -condition "exists('`$(UserRootDir)\Microsoft.Cpp.`$(Platform).user.props')"` + -expectation $true + +Test-Expression -expression "`$(SolutionDir)\Tools\PropertySheets\Evolution.Module.props" +Test-Expression -expresion "WIN32_LEAN_AND_MEAN and `$(Configuration)" + +Test-Condition -condition "exists('`$([Microsoft.Build.Utilities.ToolLocationHelper]::GetPlatformExtensionSDKLocation(``WindowsMobile, Version=10.0.10240.0``, `$(TargetPlatformIdentifier), `$(TargetPlatformVersion), `$(SDKReferenceDirectoryRoot), `$(SDKExtensionDirectoryRoot), `$(SDKReferenceRegistryRoot)))\DesignTime\CommonConfiguration\Neutral\WindowsMobile.props')"` + -expectFailure + +Test-Expression -expression "`$Foo;`$(ProjectDir);..\..;..\..\third-party" + +Test-Condition -condition "`$(TargetName.EndsWith('Test'))"` + -expectation $true + +Test-Condition -condition "`$(TargetName.EndsWith('Test2'))"` + -expectation $false + +$var = 4 +Test-Condition -condition '$(var) == 2 and 4 == 4'` + -expectation $false + +Test-Expression -expression "%(ASDASD);`$(TargetName)" + +$PkgMicrosoft_Gsl = "..\.." +Test-Condition -condition "Exists('`$(PkgMicrosoft_Gsl)\build\native\Microsoft.Gsl.targets') OR ! Exists('`$(PkgMicrosoft_Gsl)\build\native\Microsoft.Gsl.targets')"` + -expectation $true + +$myVar = 'TwoThree' +$MySelector = "One;Two;Three" +Test-Condition -condition "`$(MySelector.Contains(`$(myVar.Substring(3, 3))))"` + -expectation $true + +$MySelector = "One;Two;Three" +$myVar = "Two" +Test-Condition -condition "`$(MySelector.Contains(`$(myVar)))"` + -expectation $true + +$MySelector = "One;Two;Three" +Test-Condition -condition "`$(MySelector.Contains(Three))"` + -expectFailure + +$MySelector = "One;Two;Three" +Test-Condition -condition "`$(MySelector.Contains('Three'))"` + -expectation $true + +Test-Condition -condition "`$([System.DateTime]::Now.Year) == 2018"` + -expectation $true + +Test-Condition -condition "HasTrailingSlash('c:\windows\')"` + -expectation $true + +Test-Condition -condition "HasTrailingSlash('c:\windows\') and hasTrailingSlash('c:\temp/')"` + -expectation $true + +$prop = "c:\windows\" +Test-Condition -condition "hasTrailingSlash(`$(prop))"` + -expectation $true \ No newline at end of file diff --git a/scripts/sample-clang-build.ps1 b/scripts/sample-clang-build.ps1 new file mode 100644 index 0000000000..577deff5c5 --- /dev/null +++ b/scripts/sample-clang-build.ps1 @@ -0,0 +1,225 @@ +<# +.SYNOPSIS + Compiles or tidies up code from Visual Studio .vcxproj project files. + It sets up the scene required for clang-build.ps1 to do its job, and makes + command-line usage for projects and files quicker. + + Before calling sample-clang-build.ps1 you need to set the current directory + to the root source directory. + +.PARAMETER aVcxprojToCompile + Alias 'proj'. Array of project(s) to compile. If empty, all projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojToIgnore + Alias 'proj-ignore'. Array of project(s) to ignore, from the matched ones. + If empty, all already matched projects are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "msicomp" compiles all msicomp projects. + + Can be passed as comma separated values. + +.PARAMETER aVcxprojConfigPlatform + Alias 'active-config'. The configuration-platform pair, separated by |, + to be used when processing project files. + + E.g. 'Debug|Win32'. + If not specified, the first configuration-plaform found in the current project is used. + +.PARAMETER aCppToCompile + Alias 'file'. What cpp(s) to compile from the found project(s). If empty, all CPPs are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" compiles all CPPs containing 'table'. + +.PARAMETER aCppToIgnore + Alias 'file-ignore'. Array of file(s) to ignore, from the matched ones. + If empty, all already matched files are compiled. + If the -literal switch is present, name is matched exactly. Otherwise, regex matching is used, + e.g. "table" ignores all CPPs containing 'table'. + + Can be passed as comma separated values. + +.PARAMETER aUseParallelCompile + Alias 'parallel'. Switch to run in parallel mode, on all logical CPU cores. + +.PARAMETER aContinueOnError + Alias 'continue'. Switch to continue project compilation even when errors occur. + +.PARAMETER aTreatAdditionalIncludesAsSystemIncludes + Alias 'treat-sai'. Switch to treat project additional include directories as system includes. + +.PARAMETER aClangCompileFlags + Alias 'clang-flags'. Flags given to clang++ when compiling project, + alongside project-specific defines. + +.PARAMETER aDisableNameRegexMatching + Alias 'literal'. Switch to take project and cpp name filters literally, not by regex matching. + +.PARAMETER aTidyFlags + Alias 'tidy'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will not be applied, only simulated. + + If aTidyFixFlags is present, it takes precedence over this parameter. + +.PARAMETER aTidyFixFlags + Alias 'tidy-fix'. If not empty clang-tidy will be called with given flags, instead of clang++. + The tidy operation is applied to whole translation units, meaning all directory headers + included in the CPP will be tidied up too. Changes will be applied to the file(s). + + If present, this parameter takes precedence over aTidyFlags. + +.PARAMETER aAfterTidyFixFormatStyle + Alias 'format-style'. Used in combination with 'tidy-fix'. If present, clang-tidy will + also format the fixed file(s), using the specified style. + Possible values: - not present, no formatting will be done + - 'file' + Literally 'file', not a placeholder. + Uses .clang-format file in the closest parent directory. + - 'llvm' + - 'google' + - 'webkit' + - 'mozilla' + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + Doesn't actually apply the clang-tidy module changes to CPPs. + It will only print the tidy module output. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo,bar -file meow -tidy-fix "-*,modernize-*" + + Runs clang-tidy, using "-*,modernize-*", on all CPPs containing 'meow' in their name from + the projects containing 'foo' or 'bar' in their names. + + It will apply all tidy module changes to CPPs. + +.EXAMPLE + PS .\sample-clang-build.ps1 -dir -proj foo -proj-ignore foobar + + Runs clang++ on all CPPs in foo... projects, except foobar + +.OUTPUTS + Will output Clang warnings and errors to screen. The return code will be 0 for success, >0 for failure. + +.NOTES + Author: Gabriel Diaconita +#> +param( [alias("proj")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToCompile + , [alias("proj-ignore")] [Parameter(Mandatory=$false)][string[]] $aVcxprojToIgnore + , [alias("active-config")][Parameter(Mandatory=$false)][string] $aVcxprojConfigPlatform + , [alias("file")] [Parameter(Mandatory=$false)][string] $aCppToCompile + , [alias("file-ignore")] [Parameter(Mandatory=$false)][string[]] $aCppToIgnore + , [alias("parallel")] [Parameter(Mandatory=$false)][switch] $aUseParallelCompile + , [alias("continue")] [Parameter(Mandatory=$false)][switch] $aContinueOnError + , [alias("treat-sai")] [Parameter(Mandatory=$false)][switch] $aTreatAdditionalIncludesAsSystemIncludes + , [alias("literal")] [Parameter(Mandatory=$false)][switch] $aDisableNameRegexMatching + , [alias("tidy")] [Parameter(Mandatory=$false)][string] $aTidyFlags + , [alias("tidy-fix")] [Parameter(Mandatory=$false)][string] $aTidyFixFlags + , [alias("format-style")] [Parameter(Mandatory=$false)][string] $aAfterTidyFixFormatStyle + ) + +# ------------------------------------------------------------------------------------------------ + +Set-Variable -name kClangCompileFlags -Option Constant ` + -value @( "-Werror" + , "-Wall" + , "-fms-compatibility-version=19.10" + , "-Wmicrosoft" + , "-Wno-invalid-token-paste" + , "-Wno-unknown-pragmas" + , "-Wno-unused-value" + ) + +Set-Variable -name kVisualStudioVersion -value "2017" -Option Constant +Set-Variable -name kVisualStudioSku -value "Professional" -Option Constant + +# ------------------------------------------------------------------------------------------------ + +Function Merge-Array([string[]] $aArray) +{ + # we need to individually wrap items into quotes as values + # can contain PS control characters (e.g. - in -std=c++14) + $quotedArray = ($aArray | ForEach-Object { """$_"""}) + return ($quotedArray -join ",") +} + +[string] $scriptDirectory = (Split-Path -parent $PSCommandPath) + +[string] $clangScript = "$scriptDirectory\clang-build.ps1" +[string[]] $scriptParams = @("-aSolutionsPath", "'$(Get-Location)'") + +if (![string]::IsNullOrEmpty($aVcxprojToCompile)) +{ + $scriptParams += ("-aVcxprojToCompile", (Merge-Array $aVcxprojToCompile)) +} + +if (![string]::IsNullOrEmpty($aVcxprojToIgnore)) +{ + $scriptParams += ("-aVcxprojToIgnore", (Merge-Array $aVcxprojToIgnore)) +} + +if (![string]::IsNullOrEmpty($aVcxprojConfigPlatform)) +{ + $scriptParams += ("-aVcxprojConfigPlatform", (Merge-Array $aVcxprojConfigPlatform)) +} + +if (![string]::IsNullOrEmpty($aCppToCompile)) +{ + $scriptParams += ("-aCppToCompile", (Merge-Array $aCppToCompile)) +} + +if (![string]::IsNullOrEmpty($aCppToIgnore)) +{ + $scriptParams += ("-aCppToIgnore", (Merge-Array $aCppToIgnore)) +} + +$scriptParams += ("-aClangCompileFlags", (Merge-Array $kClangCompileFlags)) + +if (![string]::IsNullOrEmpty($aTidyFlags)) +{ + $scriptParams += ("-aTidyFlags", (Merge-Array (@($aTidyFlags)))) +} + +if (![string]::IsNullOrEmpty($aTidyFixFlags)) +{ + $scriptParams += ("-aTidyFixFlags", (Merge-Array (@($aTidyFixFlags)))) +} + +if (![string]::IsNullOrEmpty($aAfterTidyFixFormatStyle)) +{ + $scriptParams += ("-aAfterTidyFixFormatStyle", $aAfterTidyFixFormatStyle) +} + +if ($aUseParallelCompile) +{ + $scriptParams += ("-aUseParallelCompile") +} + +if ($aContinueOnError) +{ + $scriptParams += ("-aContinueOnError") +} + +if ($aTreatAdditionalIncludesAsSystemIncludes) +{ + $scriptParams += ("-aTreatAdditionalIncludesAsSystemIncludes") +} + +if ($aDisableNameRegexMatching) +{ + $scriptParams += ("-aDisableNameRegexMatching") +} + +$scriptParams += ("-aVisualStudioVersion", $kVisualStudioVersion) +$scriptParams += ("-aVisualStudioSku", $kVisualStudioSku) +$scriptParams += ("-aTidyHeaderFilter", ".*") + +Invoke-Expression "&'$clangScript' $scriptParams"