diff --git a/.github/workflows/ResInsightWithCache.yml b/.github/workflows/ResInsightWithCache.yml index 5d2bb583c7..4d2be6dd14 100644 --- a/.github/workflows/ResInsightWithCache.yml +++ b/.github/workflows/ResInsightWithCache.yml @@ -129,7 +129,7 @@ jobs: uses: actions/cache@v3 with: path: ${{ env.BUILDCACHE_DIR }} - key: ${{ matrix.config.os }}-${{ matrix.config.cc }}-cache-v02-${{ steps.current-time.outputs.formattedTime }} + key: ${{ matrix.config.os }}-${{ matrix.config.cc }}-cache-v03-${{ steps.current-time.outputs.formattedTime }} - name: Create Folder for buildcache run: New-Item ${{ env.BUILDCACHE_DIR }} -ItemType "directory" -Force shell: pwsh diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake b/ApplicationLibCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake index 2aef75e722..26aece0cb1 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/CMakeLists_files.cmake @@ -6,6 +6,7 @@ set(SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.h + ${CMAKE_CURRENT_LIST_DIR}/RicPasteCellFiltersFeature.h ) set(SOURCE_GROUP_SOURCE_FILES @@ -16,6 +17,7 @@ set(SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RicPasteEclipseViewsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicPasteGeoMechViewsFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicPasteIntersectionsFeature.cpp + ${CMAKE_CURRENT_LIST_DIR}/RicPasteCellFiltersFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES}) diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp index 61cd114bd9..83bf35ea71 100644 --- a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicCopyReferencesToClipboardFeature.cpp @@ -20,6 +20,7 @@ #include "RicCopyReferencesToClipboardFeature.h" #include "RimBoxIntersection.h" +#include "RimCellFilter.h" #include "RimEclipseCase.h" #include "RimEclipseView.h" #include "RimEnsembleCurveSet.h" @@ -136,6 +137,7 @@ bool RicCopyReferencesToClipboardFeature::isCopyOfObjectSupported( caf::PdmObjec if ( dynamic_cast( pdmObject ) ) return true; if ( dynamic_cast( pdmObject ) ) return true; if ( dynamic_cast( pdmObject ) ) return true; + if ( dynamic_cast( pdmObject ) ) return true; // Copy support based combined logic RimWellAllocationPlot* wellAllocPlot = pdmObject->firstAncestorOrThisOfType(); diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp new file mode 100644 index 0000000000..c809985609 --- /dev/null +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.cpp @@ -0,0 +1,99 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- Equinor 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 "RicPasteCellFiltersFeature.h" + +#include "RicPasteFeatureImpl.h" + +#include "RimCase.h" +#include "RimCellFilter.h" +#include "RimCellFilterCollection.h" + +#include "cafPdmObjectGroup.h" +#include "cafPdmPointer.h" +#include "cafSelectionManager.h" + +#include + +CAF_CMD_SOURCE_INIT( RicPasteCellFiltersFeature, "RicPasteCellFiltersFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicPasteCellFiltersFeature::isCommandEnabled() const +{ + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup ); + + std::vector> typedObjects; + objectGroup.objectsByType( &typedObjects ); + if ( typedObjects.empty() ) + { + return false; + } + + if ( dynamic_cast( caf::SelectionManager::instance()->selectedItem() ) ) + { + return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteCellFiltersFeature::onActionTriggered( bool isChecked ) +{ + auto cellFilterCollection = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( !cellFilterCollection ) return; + + auto eclipseCase = cellFilterCollection->firstAncestorOfType(); + + caf::PdmObjectGroup objectGroup; + RicPasteFeatureImpl::findObjectsFromClipboardRefs( &objectGroup ); + + for ( auto obj : objectGroup.objects ) + { + auto duplicatedObject = + dynamic_cast( obj->xmlCapability()->copyByXmlSerialization( caf::PdmDefaultObjectFactory::instance() ) ); + + if ( duplicatedObject ) + { + cellFilterCollection->addFilterAndNotifyChanges( duplicatedObject, eclipseCase ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteCellFiltersFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setText( "Paste Filter" ); + + RicPasteFeatureImpl::setIconAndShortcuts( actionToSetup ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicPasteCellFiltersFeature::pasteGeometryCellFilters( RimCellFilterCollection* cellFilterCollection ) +{ + if ( !cellFilterCollection ) return; +} diff --git a/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.h b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.h new file mode 100644 index 0000000000..aedc9df244 --- /dev/null +++ b/ApplicationLibCode/Commands/OperationsUsingObjReferences/RicPasteCellFiltersFeature.h @@ -0,0 +1,39 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2023- Equinor 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 RimCellFilterCollection; + +//================================================================================================== +/// +//================================================================================================== +class RicPasteCellFiltersFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() const override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + void pasteGeometryCellFilters( RimCellFilterCollection* cellFilterCollection ); +}; diff --git a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp index 4c8227c1aa..6b411262b9 100644 --- a/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp +++ b/ApplicationLibCode/FileInterface/RifOpmCommonSummary.cpp @@ -111,7 +111,10 @@ bool RifOpmCommonEclipseSummary::open( const QString& fileName, bool includeRest { auto temporarySummaryFile = std::make_unique( smspecFileName.toStdString(), includeRestartFiles ); - temporarySummaryFile->make_esmry_file(); + if ( temporarySummaryFile->numberOfTimeSteps() > 0 ) + { + temporarySummaryFile->make_esmry_file(); + } RifOpmCommonEclipseSummary::increaseEsmryFileCount(); } @@ -214,15 +217,22 @@ void RifOpmCommonEclipseSummary::buildMetaData() if ( m_enhancedReader ) { - keywords = m_enhancedReader->keywordList(); - startOfSimulation = m_enhancedReader->startdate(); - daysSinceStartOfSimulation = m_enhancedReader->get( "TIME" ); + keywords = m_enhancedReader->keywordList(); + startOfSimulation = m_enhancedReader->startdate(); + + if ( m_enhancedReader->numberOfTimeSteps() > 0 ) + { + daysSinceStartOfSimulation = m_enhancedReader->get( "TIME" ); + } } else if ( m_standardReader ) { - keywords = m_standardReader->keywordList(); - startOfSimulation = m_standardReader->startdate(); - daysSinceStartOfSimulation = m_standardReader->get( "TIME" ); + keywords = m_standardReader->keywordList(); + startOfSimulation = m_standardReader->startdate(); + if ( m_standardReader->numberOfTimeSteps() > 0 ) + { + daysSinceStartOfSimulation = m_standardReader->get( "TIME" ); + } } const auto startAsTimeT = std::chrono::system_clock::to_time_t( startOfSimulation ); diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp index 79641b5765..4625282d4e 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.cpp @@ -292,6 +292,16 @@ RimUserDefinedIndexFilter* RimCellFilterCollection::addNewUserDefinedIndexFilter return pFilter; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimCellFilterCollection::addFilterAndNotifyChanges( RimCellFilter* pFilter, RimCase* srcCase ) +{ + addFilter( pFilter ); + pFilter->setCase( srcCase ); + onFilterUpdated( pFilter ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h index 55ff8330d6..87a7d808ba 100644 --- a/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h +++ b/ApplicationLibCode/ProjectDataModel/CellFilters/RimCellFilterCollection.h @@ -58,6 +58,7 @@ class RimCellFilterCollection : public caf::PdmObject RimUserDefinedFilter* addNewUserDefinedFilter( RimCase* srcCase ); RimUserDefinedIndexFilter* addNewUserDefinedIndexFilter( RimCase* srcCase, const std::vector& defCellIndexes = {} ); + void addFilterAndNotifyChanges( RimCellFilter* pFilter, RimCase* srcCase ); void removeFilter( RimCellFilter* filter ); void notifyGridReload(); diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 15e13f6228..8745c6db91 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -1034,6 +1034,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() } else if ( dynamic_cast( firstUiItem ) ) { + menuBuilder << "RicPasteCellFiltersFeature"; + menuBuilder << "Separator"; menuBuilder << "RicNewPolygonFilterFeature"; menuBuilder << "RicNewUserDefinedFilterFeature"; menuBuilder << "RicNewUserDefinedIndexFilterFeature"; diff --git a/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp b/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp index 6f658f0a6e..e563561f0b 100644 --- a/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimEclipseCellColors.cpp @@ -145,7 +145,10 @@ void RimEclipseCellColors::changeLegendConfig( QString resultVarNameOfNewLegend int caseId = 0; if ( eclipseCase() ) caseId = eclipseCase()->caseId(); - auto newLegend = createLegendForResult( caseId, resultVarNameOfNewLegend, m_useDiscreteLogLevels, hasCategoryResult() ); + bool useCategoryLegend = hasCategoryResult(); + if ( m_resultType() == RiaDefines::ResultCatType::FORMATION_NAMES ) useCategoryLegend = true; + + auto newLegend = createLegendForResult( caseId, resultVarNameOfNewLegend, m_useDiscreteLogLevels, useCategoryLegend ); newLegend->changed.connect( this, &RimEclipseCellColors::onLegendConfigChanged ); diff --git a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp index e86e272ce3..2e99a4e360 100644 --- a/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp +++ b/ApplicationLibCode/ProjectDataModel/Summary/RimSummaryCurve.cpp @@ -843,7 +843,7 @@ double RimSummaryCurve::computeCurveZValue() { zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_STAT_CURVE ); } - else if ( sumCase->ensemble() ) + else if ( firstAncestorOrThisOfType() ) { zOrder = RiuQwtPlotCurveDefines::zDepthForIndex( RiuQwtPlotCurveDefines::ZIndex::Z_ENSEMBLE_CURVE ); } diff --git a/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp b/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp index 19f6723940..9c95cd0725 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigVisibleCategoriesCalculator.cpp @@ -240,6 +240,8 @@ void RigVisibleCategoriesCalculator::appendVisibleIntersectionCells( RimEclipseV for ( const auto geoGenerator : intersectionGeoGenerators ) { + if ( !geoGenerator->isAnyGeometryPresent() ) continue; + for ( const auto& cIdx : geoGenerator->triangleToCellIndex() ) { visibleCells.insert( cIdx ); diff --git a/ApplicationLibCode/UnitTests/TestData/SummaryData/empty-file/BLASTO_PRED-19.SMSPEC b/ApplicationLibCode/UnitTests/TestData/SummaryData/empty-file/BLASTO_PRED-19.SMSPEC new file mode 100644 index 0000000000..5e7d5ef53b Binary files /dev/null and b/ApplicationLibCode/UnitTests/TestData/SummaryData/empty-file/BLASTO_PRED-19.SMSPEC differ diff --git a/ApplicationLibCode/UnitTests/TestData/SummaryData/empty-file/BLASTO_PRED-19.UNSMRY b/ApplicationLibCode/UnitTests/TestData/SummaryData/empty-file/BLASTO_PRED-19.UNSMRY new file mode 100644 index 0000000000..53ce7ac5ec Binary files /dev/null and b/ApplicationLibCode/UnitTests/TestData/SummaryData/empty-file/BLASTO_PRED-19.UNSMRY differ diff --git a/ApplicationLibCode/UnitTests/opm-summary-Test.cpp b/ApplicationLibCode/UnitTests/opm-summary-Test.cpp index 5c9b6ab0a6..88abcce1c0 100644 --- a/ApplicationLibCode/UnitTests/opm-summary-Test.cpp +++ b/ApplicationLibCode/UnitTests/opm-summary-Test.cpp @@ -16,6 +16,7 @@ #include "opm/io/eclipse/ExtESmry.hpp" #include +#include static const QString H5_TEST_DATA_DIRECTORY = QString( "%1/h5-file/" ).arg( TEST_DATA_DIR ); @@ -295,6 +296,20 @@ TEST( OpmSummaryTests, OpmComputeSegmentTopology ) } } +TEST( OpmSummaryTests, OpenEmptySummaryFile ) +{ + QString SUMMARY_TEST_DATA_DIRECTORY = QString( "%1/SummaryData/empty-file/" ).arg( TEST_DATA_DIR ); + QString rootPath = SUMMARY_TEST_DATA_DIRECTORY + "BLASTO_PRED-19"; + QString smspecFilePath = rootPath + ".SMSPEC"; + + Opm::EclIO::ESmry eSmry( smspecFilePath.toStdString() ); + + // Test to verify that is is possible to read an empty summary file + // eSmry.make_esmry_file() will fail if the summary file is empty + + EXPECT_TRUE( eSmry.numberOfTimeSteps() == 0 ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ResInsightVersion.cmake b/ResInsightVersion.cmake index 2a4aeddbe2..82126a123d 100644 --- a/ResInsightVersion.cmake +++ b/ResInsightVersion.cmake @@ -5,7 +5,7 @@ set(RESINSIGHT_PATCH_VERSION 0) # Opional text with no restrictions #set(RESINSIGHT_VERSION_TEXT "-dev") -set(RESINSIGHT_VERSION_TEXT "-RC_02") +set(RESINSIGHT_VERSION_TEXT "-RC_03") # Optional text # Must be unique and increasing within one combination of major/minor/patch version