diff --git a/ApplicationExeCode/Resources/Bullet.png b/ApplicationExeCode/Resources/Bullet.png new file mode 100644 index 0000000000..fd70936024 Binary files /dev/null and b/ApplicationExeCode/Resources/Bullet.png differ diff --git a/ApplicationExeCode/Resources/ResInsight.qrc b/ApplicationExeCode/Resources/ResInsight.qrc index 6081a9ec41..90ca2b8c23 100644 --- a/ApplicationExeCode/Resources/ResInsight.qrc +++ b/ApplicationExeCode/Resources/ResInsight.qrc @@ -14,6 +14,7 @@ AppLogo48x48.png Axes16x16.png BottomAxis16x16.png + Bullet.png CascadeWindows.svg Case.svg Cases16x16.png @@ -50,6 +51,7 @@ EnsembleCurveSets16x16.png Erase.png ExportCompletionsSymbol16x16.png + fault_react_24x24.png FishBoneGroup16x16.png FishBoneGroupFromFile16x16.png FishBoneLateralFromFile16x16.png diff --git a/ApplicationExeCode/Resources/fault_react_24x24.png b/ApplicationExeCode/Resources/fault_react_24x24.png new file mode 100644 index 0000000000..7c9a6af585 Binary files /dev/null and b/ApplicationExeCode/Resources/fault_react_24x24.png differ diff --git a/ApplicationLibCode/Application/CMakeLists_files.cmake b/ApplicationLibCode/Application/CMakeLists_files.cmake index c4efba02b1..b5729e5b33 100644 --- a/ApplicationLibCode/Application/CMakeLists_files.cmake +++ b/ApplicationLibCode/Application/CMakeLists_files.cmake @@ -8,6 +8,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaFractureDefines.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.h ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.h +${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.h ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.h ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.h ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.h @@ -33,6 +34,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RiaDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaFractureDefines.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferences.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesSummary.cpp +${CMAKE_CURRENT_LIST_DIR}/RiaPreferencesGeoMech.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaPorosityModel.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaSummaryCurveDefinition.cpp ${CMAKE_CURRENT_LIST_DIR}/RiaCurveSetDefinition.cpp diff --git a/ApplicationLibCode/Application/RiaPreferences.cpp b/ApplicationLibCode/Application/RiaPreferences.cpp index d4e4992d51..2cfab922ca 100644 --- a/ApplicationLibCode/Application/RiaPreferences.cpp +++ b/ApplicationLibCode/Application/RiaPreferences.cpp @@ -23,6 +23,7 @@ #include "RiaApplication.h" #include "RiaColorTables.h" +#include "RiaPreferencesGeoMech.h" #include "RiaPreferencesSummary.h" #include "RiaValidRegExpValidator.h" @@ -332,6 +333,9 @@ RiaPreferences::RiaPreferences() CAF_PDM_InitFieldNoDefault( &m_summaryPreferences, "summaryPreferences", "summaryPreferences", "", "", "" ); m_summaryPreferences = new RiaPreferencesSummary; + + CAF_PDM_InitFieldNoDefault( &m_geoMechPreferences, "geoMechPreferences", "geoMechPreferences", "", "", "" ); + m_geoMechPreferences = new RiaPreferencesGeoMech; } //-------------------------------------------------------------------------------------------------- @@ -453,6 +457,12 @@ void RiaPreferences::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& m_summaryPreferences()->uiOrdering( uiConfigName, *group ); } } +#ifdef USE_ODB_API + else if ( uiConfigName == RiaPreferences::tabNameGeomech() ) + { + m_geoMechPreferences()->appendItems( uiOrdering ); + } +#endif else if ( uiConfigName == RiaPreferences::tabNamePlotting() ) { uiOrdering.add( &m_dateFormat ); @@ -625,6 +635,14 @@ QString RiaPreferences::tabNameEclipseSummary() return "Eclipse Summary"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferences::tabNameGeomech() +{ + return "GeoMechanical"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -691,6 +709,9 @@ QStringList RiaPreferences::tabNames() names << tabNameGeneral(); names << tabNameEclipseGrid(); names << tabNameEclipseSummary(); +#ifdef USE_ODB_API + names << tabNameGeomech(); +#endif names << tabNamePlotting(); names << tabNameScripting(); names << tabNameExport(); @@ -1055,6 +1076,14 @@ RiaPreferencesSummary* RiaPreferences::summaryPreferences() const return m_summaryPreferences(); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesGeoMech* RiaPreferences::geoMechPreferences() const +{ + return m_geoMechPreferences(); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaPreferences.h b/ApplicationLibCode/Application/RiaPreferences.h index a5453c5dd1..8cc108106d 100644 --- a/ApplicationLibCode/Application/RiaPreferences.h +++ b/ApplicationLibCode/Application/RiaPreferences.h @@ -41,6 +41,7 @@ class RifReaderSettings; class RiaPreferencesSummary; +class RiaPreferencesGeoMech; //-------------------------------------------------------------------------------------------------- /// @@ -120,6 +121,7 @@ public: QString pythonExecutable() const; QString octaveExecutable() const; + RiaPreferencesGeoMech* geoMechPreferences() const; RiaPreferencesSummary* summaryPreferences() const; public: @@ -166,6 +168,7 @@ private: static QString tabNameGeneral(); static QString tabNameEclipseGrid(); static QString tabNameEclipseSummary(); + static QString tabNameGeomech(); static QString tabNamePlotting(); static QString tabNameScripting(); static QString tabNameExport(); @@ -219,6 +222,9 @@ private: // Well Path Import caf::PdmField m_multiLateralWellPattern; + // GeoMech things + caf::PdmChildField m_geoMechPreferences; + // Summary data caf::PdmChildField m_summaryPreferences; diff --git a/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp b/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp new file mode 100644 index 0000000000..c0b2b473e2 --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesGeoMech.cpp @@ -0,0 +1,159 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RiaPreferencesGeoMech.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" + +#include "cafPdmUiFilePathEditor.h" + +#include +#include + +CAF_PDM_SOURCE_INIT( RiaPreferencesGeoMech, "RiaPreferencesGeoMech" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesGeoMech::RiaPreferencesGeoMech() +{ + CAF_PDM_InitFieldNoDefault( &m_geomechFRAPreprocCommand, "geomechFRAPreprocCommand", "Pre-Processing Command", "", "", "" ); + m_geomechFRAPreprocCommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_geomechFRAPreprocCommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + + CAF_PDM_InitFieldNoDefault( &m_geomechFRAPostprocCommand, "geomechFRAPostprocCommand", "Post-Processing Command", "", "", "" ); + m_geomechFRAPostprocCommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_geomechFRAPostprocCommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + + CAF_PDM_InitFieldNoDefault( &m_geomechFRAMacrisCommand, "geomechFRAMacrisCommand", "Main Macris Command", "", "", "" ); + m_geomechFRAMacrisCommand.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_geomechFRAMacrisCommand.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + + CAF_PDM_InitFieldNoDefault( &m_geomechFRADefaultBasicXML, + "geomechFRADefaultXML", + "Basic Processing Parameter XML File", + "", + "", + "" ); + m_geomechFRADefaultBasicXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_geomechFRADefaultBasicXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); + + CAF_PDM_InitFieldNoDefault( &m_geomechFRADefaultAdvXML, + "geomechFRADefaultAdvXML", + "Advanced Processing Parameter XML File", + "", + "", + "" ); + m_geomechFRADefaultAdvXML.uiCapability()->setUiEditorTypeName( caf::PdmUiFilePathEditor::uiEditorTypeName() ); + m_geomechFRADefaultAdvXML.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::TOP ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RiaPreferencesGeoMech* RiaPreferencesGeoMech::current() +{ + return RiaApplication::instance()->preferences()->geoMechPreferences(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesGeoMech::appendItems( caf::PdmUiOrdering& uiOrdering ) const +{ + caf::PdmUiGroup* faultRAGroup = uiOrdering.addNewGroup( "Fault Reactivation Assessment" ); + caf::PdmUiGroup* cmdGroup = faultRAGroup->addNewGroup( "Commands (without parameters)" ); + + cmdGroup->add( &m_geomechFRAPreprocCommand ); + cmdGroup->add( &m_geomechFRAPostprocCommand ); + cmdGroup->add( &m_geomechFRAMacrisCommand ); + + caf::PdmUiGroup* paramGroup = faultRAGroup->addNewGroup( "Parameters" ); + paramGroup->add( &m_geomechFRADefaultBasicXML ); + paramGroup->add( &m_geomechFRADefaultAdvXML ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RiaPreferencesGeoMech::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesGeoMech::geomechFRAPreprocCommand() const +{ + return m_geomechFRAPreprocCommand; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesGeoMech::geomechFRAPostprocCommand() const +{ + return m_geomechFRAPostprocCommand; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesGeoMech::geomechFRAMacrisCommand() const +{ + return m_geomechFRAMacrisCommand; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesGeoMech::geomechFRADefaultBasicXML() const +{ + return m_geomechFRADefaultBasicXML; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaPreferencesGeoMech::geomechFRADefaultAdvXML() const +{ + return m_geomechFRADefaultAdvXML; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RiaPreferencesGeoMech::validateFRASettings() const +{ + QStringList files; + files << geomechFRAPreprocCommand(); + files << geomechFRAPostprocCommand(); + files << geomechFRAMacrisCommand(); + files << geomechFRADefaultBasicXML(); + files << geomechFRADefaultAdvXML(); + + for ( int i = 0; i < files.size(); i++ ) + { + if ( files[i].isEmpty() ) return false; + QFile file( files[i] ); + if ( !file.exists() ) return false; + } + + return true; +} diff --git a/ApplicationLibCode/Application/RiaPreferencesGeoMech.h b/ApplicationLibCode/Application/RiaPreferencesGeoMech.h new file mode 100644 index 0000000000..12ff9af54a --- /dev/null +++ b/ApplicationLibCode/Application/RiaPreferencesGeoMech.h @@ -0,0 +1,56 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "cafAppEnum.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +class RiaPreferencesGeoMech : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RiaPreferencesGeoMech(); + + static RiaPreferencesGeoMech* current(); + + void appendItems( caf::PdmUiOrdering& uiOrdering ) const; + bool validateFRASettings() const; + + // geomech settings + QString geomechFRAPreprocCommand() const; + QString geomechFRAPostprocCommand() const; + QString geomechFRAMacrisCommand() const; + QString geomechFRADefaultBasicXML() const; + QString geomechFRADefaultAdvXML() const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + +private: + caf::PdmField m_geomechFRAPreprocCommand; + caf::PdmField m_geomechFRAPostprocCommand; + caf::PdmField m_geomechFRAMacrisCommand; + caf::PdmField m_geomechFRADefaultBasicXML; + caf::PdmField m_geomechFRADefaultAdvXML; +}; diff --git a/ApplicationLibCode/Application/RiaResultNames.cpp b/ApplicationLibCode/Application/RiaResultNames.cpp index f2fbb32215..6b7b85c4aa 100644 --- a/ApplicationLibCode/Application/RiaResultNames.cpp +++ b/ApplicationLibCode/Application/RiaResultNames.cpp @@ -281,6 +281,14 @@ QString RiaResultNames::mobilePoreVolumeName() return "MOBPORV"; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RiaResultNames::faultReactAssessmentPrefix() +{ + return "FAULT_"; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/RiaResultNames.h b/ApplicationLibCode/Application/RiaResultNames.h index c0dc2a34d8..485f538c4f 100644 --- a/ApplicationLibCode/Application/RiaResultNames.h +++ b/ApplicationLibCode/Application/RiaResultNames.h @@ -60,6 +60,8 @@ QString riCellVolumeResultName(); QString riOilVolumeResultName(); QString mobilePoreVolumeName(); +QString faultReactAssessmentPrefix(); + QString completionTypeResultName(); // Well path derived results diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp index 97fad4bad2..48bbf3432c 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.cpp @@ -243,8 +243,8 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilter( const QString //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( const QStringList& fileNames, - QString* fileContainingGrid /*=nullptr*/ ) +int RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( const QStringList& fileNames, + QString* fileContainingGrid /*=nullptr*/ ) { RimEclipseInputCase* rimInputReservoir = new RimEclipseInputCase(); @@ -257,7 +257,7 @@ bool RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( const QString if ( !gridImportSuccess ) { RiaLogging::error( "Failed to import grid" ); - return false; + return -1; } RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() @@ -286,7 +286,7 @@ bool RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( const QString *fileContainingGrid = rimInputReservoir->gridFileName(); } - return true; + return rimInputReservoir->caseId(); } //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h index 684c5c94a9..5c809df264 100644 --- a/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h +++ b/ApplicationLibCode/Application/Tools/RiaImportEclipseCaseTools.h @@ -38,7 +38,7 @@ public: bool noDialog = false ); static bool openEclipseCaseShowTimeStepFilter( const QString& fileName ); - static bool openEclipseInputCaseFromFileNames( const QStringList& fileNames, QString* fileContainingGrid = nullptr ); + static int openEclipseInputCaseFromFileNames( const QStringList& fileNames, QString* fileContainingGrid = nullptr ); static bool openMockModel( const QString& name ); static bool addEclipseCases( const QStringList& fileNames, RimIdenticalGridCaseGroup** resultingCaseGroup = nullptr ); diff --git a/ApplicationLibCode/CMakeLists.txt b/ApplicationLibCode/CMakeLists.txt index 64c33b7475..61668112a2 100644 --- a/ApplicationLibCode/CMakeLists.txt +++ b/ApplicationLibCode/CMakeLists.txt @@ -101,12 +101,14 @@ include_directories( ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Flow ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/GridCrossPlots ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/GeoMech + ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Parameters ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Measurement ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/StimPlanModel ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Summary ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Surfaces ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/Streamlines ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/CellFilters + ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModel/ProcessControl ${CMAKE_CURRENT_SOURCE_DIR}/ProjectDataModelCommands ${CMAKE_CURRENT_SOURCE_DIR}/ResultStatisticsCache ${CMAKE_CURRENT_SOURCE_DIR}/ReservoirDataModel @@ -168,11 +170,13 @@ list( ProjectDataModel/Annotations/CMakeLists_files.cmake ProjectDataModel/Completions/CMakeLists_files.cmake ProjectDataModel/Measurement/CMakeLists_files.cmake + ProjectDataModel/Parameters/CMakeLists_files.cmake ProjectDataModel/PlotTemplates/CMakeLists_files.cmake ProjectDataModel/StimPlanModel/CMakeLists_files.cmake ProjectDataModel/Streamlines/CMakeLists_files.cmake ProjectDataModel/Surfaces/CMakeLists_files.cmake ProjectDataModel/CellFilters/CMakeLists_files.cmake + ProjectDataModel/ProcessControl/CMakeLists_files.cmake ProjectDataModelCommands/CMakeLists_files.cmake GeoMech/GeoMechVisualization/CMakeLists_files.cmake ModelVisualization/CMakeLists_files.cmake diff --git a/ApplicationLibCode/Commands/GeoMechCommands/CMakeLists_files.cmake b/ApplicationLibCode/Commands/GeoMechCommands/CMakeLists_files.cmake index e26c76d485..aa6fb5f2c6 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/CMakeLists_files.cmake +++ b/ApplicationLibCode/Commands/GeoMechCommands/CMakeLists_files.cmake @@ -10,6 +10,11 @@ ${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewExec.h ${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.h ${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseTimeStepFilterFeature.h + +${CMAKE_CURRENT_LIST_DIR}/RicNewFaultReactAssessmentFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessmentFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRunAdvFaultReactAssessmentFeature.h +${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactAssessmentFeature.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -23,6 +28,11 @@ ${CMAKE_CURRENT_LIST_DIR}/RicGeoMechPropertyFilterNewExec.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseFeature.cpp ${CMAKE_CURRENT_LIST_DIR}/RicImportGeoMechCaseTimeStepFilterFeature.cpp + +${CMAKE_CURRENT_LIST_DIR}/RicNewFaultReactAssessmentFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRunAdvFaultReactAssessmentFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessmentFeature.cpp +${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactAssessmentFeature.cpp ) list(APPEND COMMAND_CODE_HEADER_FILES diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.cpp new file mode 100644 index 0000000000..9de3065623 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.cpp @@ -0,0 +1,287 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RicNewFaultReactAssessmentFeature.h" + +#include "RiaApplication.h" +#include "RiaEclipseFileNameTools.h" +#include "RiaImportEclipseCaseTools.h" +#include "RiaPreferencesGeoMech.h" + +#include "RifFaultRAJsonWriter.h" + +#include "RimEclipseInputCase.h" +#include "RimEclipseResultCase.h" +#include "RimEclipseView.h" +#include "RimFaultInViewCollection.h" +#include "RimFaultRAPreprocSettings.h" +#include "RimFaultRASettings.h" +#include "RimGeoMechCase.h" +#include "RimProcess.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafProgressInfo.h" +#include "cafSelectionManagerTools.h" +#include "cafUtils.h" + +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicNewFaultReactAssessmentFeature, "RicNewFaultReactAssessmentFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewFaultReactAssessmentFeature::isCommandEnabled() +{ + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewFaultReactAssessmentFeature::onActionTriggered( bool isChecked ) +{ + RimFaultRAPreprocSettings frapSettings; + + // make sure the user has set up geomech/FRA things in preferences + if ( !RiaPreferencesGeoMech::current()->validateFRASettings() ) + { + QMessageBox::critical( nullptr, + "Fault Reactivation Assessment", + "Please go to ResInsight preferences and set/check the GeoMechanical settings!" ); + return; + } + + // ask user for preprocessing settings + if ( !showSettingsGUI( frapSettings ) ) return; + + // make sure our work dir is there + prepareDirectory( frapSettings.outputBaseDirectory(), frapSettings.cleanBaseDirectory() ); + + // run the preproc steps needed + if ( !runPreProc( frapSettings ) ) return; + + QStringList gridList; + gridList << frapSettings.outputEclipseFilename(); + + // load the new grid + int caseId = RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( gridList ); + if ( caseId < 0 ) + { + QMessageBox::critical( nullptr, "Fault Reactivation Assessment", "Unable to load generated Eclipse grid." ); + return; + } + + RimProject* project = RiaApplication::instance()->project(); + RimEclipseInputCase* fraCase = dynamic_cast( project->eclipseCaseFromCaseId( caseId ) ); + if ( fraCase == nullptr ) + { + QMessageBox::critical( nullptr, "Fault Reactivation Assessment", "Unable to find generated Eclipse grid." ); + return; + } + + RimEclipseView* view = getView( fraCase ); + if ( view == nullptr ) + { + QMessageBox::critical( nullptr, "Fault Reactivation Assessment", "Unable to find view for generated Eclipse grid." ); + return; + } + + if ( view->faultCollection() ) + { + view->faultCollection()->enableFaultRA( true ); + view->faultCollection()->faultRASettings()->initFromPreprocSettings( &frapSettings, fraCase ); + } + + cleanUpParameterFiles(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewFaultReactAssessmentFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) ); + actionToSetup->setText( "New Fault Reactivation Assessment" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewFaultReactAssessmentFeature::prepareDirectory( QString dirname, bool deleteExistingContent ) const +{ + QDir dir( dirname ); + + if ( deleteExistingContent && dir.exists() ) + { + dir.setFilter( QDir::Files | QDir::Dirs | QDir::NoSymLinks ); + + for ( auto& entry : dir.entryInfoList() ) + { + if ( entry.isDir() && entry.fileName() != "." && entry.fileName() != ".." ) + entry.dir().removeRecursively(); + else if ( entry.isFile() ) + QFile::remove( entry.absoluteFilePath() ); + } + } + + dir.mkpath( "." ); + dir.mkpath( "Eclipse" ); + dir.mkpath( "Abaqus" ); + dir.mkpath( "tmp" ); + dir.mkpath( "tsurf" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewFaultReactAssessmentFeature::showSettingsGUI( RimFaultRAPreprocSettings& settings ) +{ + // get the case we should be working with + std::vector geomechCases = caf::selectedObjectsByTypeStrict(); + std::vector eclipseCases = caf::selectedObjectsByTypeStrict(); + if ( geomechCases.empty() && eclipseCases.empty() ) return false; + + // get base directory for our work, should be a new, empty folder somewhere + QString defaultDir = + RiaApplication::instance()->lastUsedDialogDirectoryWithFallbackToProjectFolder( "FAULT_REACT_ASSESSMENT" ); + QString baseDir = RiuFileDialogTools::getExistingDirectory( nullptr, tr( "Select Working Directory" ), defaultDir ); + if ( baseDir.isNull() ) return false; + RiaApplication::instance()->setLastUsedDialogDirectory( "FAULT_REACT_ASSESSMENT", baseDir ); + + // ask the user for the options we need in the preproc step + if ( !geomechCases.empty() ) settings.setGeoMechCase( geomechCases[0] ); + if ( !eclipseCases.empty() ) settings.setEclipseCase( eclipseCases[0] ); + settings.setOutputBaseDirectory( baseDir ); + + caf::PdmUiPropertyViewDialog propertyDialog( nullptr, + &settings, + "Fault Reactivation Assessment Preprocessing", + "", + QDialogButtonBox::Ok | QDialogButtonBox::Cancel ); + propertyDialog.resize( QSize( 400, 420 ) ); + + // make sure we always have an eclipse case selected + while ( true ) + { + if ( propertyDialog.exec() != QDialog::Accepted ) break; + if ( settings.eclipseCase() != nullptr ) return true; + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicNewFaultReactAssessmentFeature::runPreProc( RimFaultRAPreprocSettings& settings ) +{ + caf::ProgressInfo runProgress( 2, "Running preprocessing, please wait..." ); + + // is geomech enabled? If so, run preproc script to generate rpt files + if ( settings.geoMechSelected() ) + { + QString errorText; + if ( !RifFaultRAJSonWriter::writeToPreprocFile( settings, errorText ) ) + { + QMessageBox::warning( nullptr, "Fault Reactivation Assessment Preprocessing", errorText ); + return false; + } + + runProgress.setProgressDescription( "Preproc script." ); + + // run the python preprocessing script + QString command = RiaPreferencesGeoMech::current()->geomechFRAPreprocCommand(); + QStringList parameters = settings.preprocParameterList(); + + addParameterFileForCleanUp( settings.preprocParameterFilename() ); + + RimProcess process; + process.setCommand( command ); + process.setParameters( parameters ); + if ( !process.execute() ) + { + QMessageBox::critical( nullptr, + "Fault Reactivation Assessment Preprocessing", + "Failed to run preprocessing script. Check log window for additional information." ); + return false; + } + } + + runProgress.incrementProgress(); + runProgress.setProgressDescription( "Macris prepare command." ); + + // run the java macris program in prepare mode + QString command = RiaPreferencesGeoMech::current()->geomechFRAMacrisCommand(); + QStringList parameters = settings.macrisPrepareParameterList(); + + RimProcess process; + process.setCommand( command ); + process.setParameters( parameters ); + if ( !process.execute() ) + { + QMessageBox::critical( nullptr, + "Fault Reactivation Assessment Preprocessing", + "Failed to run Macrix prepare command. Check log window for additional information." ); + return false; + } + + runProgress.incrementProgress(); + + return true; +} +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseView* RicNewFaultReactAssessmentFeature::getView( RimEclipseInputCase* eCase ) +{ + std::vector views; + eCase->descendantsOfType( views ); + if ( views.size() > 0 ) return views[0]; + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewFaultReactAssessmentFeature::addParameterFileForCleanUp( QString filename ) +{ + m_parameterFilesToCleanUp.push_back( filename ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicNewFaultReactAssessmentFeature::cleanUpParameterFiles() +{ +#ifndef DEBUG + for ( auto& filename : m_parameterFilesToCleanUp ) + { + if ( QFile::exists( filename ) ) QFile::remove( filename ); + } +#endif + m_parameterFilesToCleanUp.clear(); +} diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h new file mode 100644 index 0000000000..9337e5c3ad --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicNewFaultReactAssessmentFeature.h @@ -0,0 +1,51 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 RimFaultRAPreprocSettings; +class RimEclipseView; +class RimEclipseInputCase; + +//================================================================================================== +/// +//================================================================================================== +class RicNewFaultReactAssessmentFeature : public caf::CmdFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + // Overrides + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + +private: + void prepareDirectory( QString dirname, bool deleteExistingContent ) const; + bool showSettingsGUI( RimFaultRAPreprocSettings& settings ); + bool runPreProc( RimFaultRAPreprocSettings& settings ); + + void addParameterFileForCleanUp( QString filename ); + void cleanUpParameterFiles(); + + RimEclipseView* getView( RimEclipseInputCase* eCase ); + + std::list m_parameterFilesToCleanUp; +}; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp new file mode 100644 index 0000000000..c47e669cd6 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.cpp @@ -0,0 +1,151 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RicRunAdvFaultReactAssessmentFeature.h" + +#include "RiaApplication.h" +#include "RiaEclipseFileNameTools.h" +#include "RiaImportEclipseCaseTools.h" +#include "RiaPreferencesGeoMech.h" +#include "RiaResultNames.h" + +#include "RifFaultRAJsonWriter.h" +#include "RifFaultRAXmlWriter.h" + +#include "RimEclipseInputCase.h" +#include "RimEclipseResultCase.h" +#include "RimEclipseView.h" +#include "RimFaultInView.h" +#include "RimFaultInViewCollection.h" +#include "RimFaultRAPreprocSettings.h" +#include "RimFaultRASettings.h" +#include "RimGeoMechCase.h" +#include "RimProcess.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafProgressInfo.h" +#include "cafSelectionManagerTools.h" +#include "cafUtils.h" + +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicRunAdvFaultReactAssessmentFeature, "RicRunAdvFaultReactAssessmentFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRunAdvFaultReactAssessmentFeature::isCommandEnabled() +{ + RimFaultInViewCollection* faultColl = faultCollection(); + + if ( faultColl ) + { + return ( faultColl->faultRAEnabled() && faultColl->faultRASettings()->geomechCase() != nullptr ); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunAdvFaultReactAssessmentFeature::onActionTriggered( bool isChecked ) +{ + RimFaultInViewCollection* coll = faultCollection(); + if ( coll == nullptr ) return; + + RimFaultRASettings* fraSettings = coll->faultRASettings(); + if ( fraSettings == nullptr ) return; + + int faultID = selectedFaultID(); + caf::ProgressInfo runProgress( 3, "Running Advanced Fault RA processing, please wait..." ); + + runProgress.setProgressDescription( "Macris calibrate command." ); + QString paramfilename = fraSettings->basicParameterXMLFilename( faultID ); + + RifFaultRAXmlWriter xmlwriter( fraSettings ); + QString outErrorText; + if ( !xmlwriter.writeCalculateFile( paramfilename, faultID, outErrorText ) ) + { + QMessageBox::warning( nullptr, + "Fault Reactivation Assessment Processing", + "Unable to write parameter file! " + outErrorText ); + return; + } + + QString paramfilename2 = fraSettings->advancedParameterXMLFilename( faultID ); + if ( !xmlwriter.writeCalibrateFile( paramfilename2, faultID, outErrorText ) ) + { + QMessageBox::warning( nullptr, + "Fault Reactivation Assessment Processing", + "Unable to write calibrate parameter file! " + outErrorText ); + return; + } + + addParameterFileForCleanUp( paramfilename ); + addParameterFileForCleanUp( paramfilename2 ); + + // run the java macris program in calibrate mode + QString command = RiaPreferencesGeoMech::current()->geomechFRAMacrisCommand(); + QStringList parameters = fraSettings->advancedMacrisParameters( faultID ); + + RimProcess process; + process.setCommand( command ); + process.setParameters( parameters ); + if ( !process.execute() ) + { + QMessageBox::critical( nullptr, + "Advanced Fault Reactivation Assessment Processing", + "Failed to run Macris calibrate command. Check log window for additional information." ); + cleanUpParameterFiles(); + return; + } + + runProgress.incrementProgress(); + + runProgress.setProgressDescription( "Generating surface results." ); + + if ( runPostProcessing( faultID, fraSettings ) ) + { + runProgress.incrementProgress(); + + runProgress.setProgressDescription( "Importing surface results." ); + + // reload output surfaces + reloadSurfaces( fraSettings ); + } + + // delete parameter files + cleanUpParameterFiles(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunAdvFaultReactAssessmentFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) ); + actionToSetup->setText( "Run Advanced Processing" ); +} diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.h new file mode 100644 index 0000000000..22038d0394 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunAdvFaultReactAssessmentFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RicRunFaultReactAssessmentFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicRunAdvFaultReactAssessmentFeature : public RicRunFaultReactAssessmentFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; + bool isCommandEnabled() override; +}; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp new file mode 100644 index 0000000000..771db74ed2 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.cpp @@ -0,0 +1,142 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RicRunBasicFaultReactAssessmentFeature.h" + +#include "RiaApplication.h" +#include "RiaEclipseFileNameTools.h" +#include "RiaImportEclipseCaseTools.h" +#include "RiaPreferencesGeoMech.h" +#include "RiaResultNames.h" + +#include "RifFaultRAJsonWriter.h" +#include "RifFaultRAXmlWriter.h" + +#include "RimEclipseInputCase.h" +#include "RimEclipseResultCase.h" +#include "RimEclipseView.h" +#include "RimFaultInView.h" +#include "RimFaultInViewCollection.h" +#include "RimFaultRAPreprocSettings.h" +#include "RimFaultRASettings.h" +#include "RimGeoMechCase.h" +#include "RimProcess.h" +#include "RimProject.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafProgressInfo.h" +#include "cafSelectionManagerTools.h" +#include "cafUtils.h" + +#include +#include +#include +#include + +CAF_CMD_SOURCE_INIT( RicRunBasicFaultReactAssessmentFeature, "RicRunBasicFaultReactAssessmentFeature" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRunBasicFaultReactAssessmentFeature::isCommandEnabled() +{ + RimFaultInViewCollection* faultColl = faultCollection(); + if ( faultColl ) + { + return ( faultColl->faultRAEnabled() ); + } + + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunBasicFaultReactAssessmentFeature::onActionTriggered( bool isChecked ) +{ + RimFaultInViewCollection* coll = faultCollection(); + if ( coll == nullptr ) return; + + RimFaultRASettings* fraSettings = coll->faultRASettings(); + if ( fraSettings == nullptr ) return; + + int faultID = selectedFaultID(); + caf::ProgressInfo runProgress( 3, "Running Basic Fault RA processing, please wait..." ); + + { + runProgress.setProgressDescription( "Macris calculate command." ); + QString paramfilename = fraSettings->basicParameterXMLFilename( faultID ); + + RifFaultRAXmlWriter xmlwriter( fraSettings ); + QString outErrorText; + if ( !xmlwriter.writeCalculateFile( paramfilename, faultID, outErrorText ) ) + { + QMessageBox::warning( nullptr, + "Fault Reactivation Assessment Processing", + "Unable to write parameter file! " + outErrorText ); + return; + } + + addParameterFileForCleanUp( paramfilename ); + + // run the java macris program in calculate mode + QString command = RiaPreferencesGeoMech::current()->geomechFRAMacrisCommand(); + QStringList parameters = fraSettings->basicMacrisParameters( faultID ); + + RimProcess process; + process.setCommand( command ); + process.setParameters( parameters ); + if ( !process.execute() ) + { + QMessageBox::critical( nullptr, + "Basic Fault Reactivation Assessment Processing", + "Failed to run Macris calculate command. Check log window for additional " + "information." ); + cleanUpParameterFiles(); + return; + } + + runProgress.incrementProgress(); + } + + runProgress.setProgressDescription( "Generating surface results." ); + + if ( runPostProcessing( faultID, fraSettings ) ) + { + runProgress.incrementProgress(); + + runProgress.setProgressDescription( "Importing surface results." ); + + // reload output surfaces + reloadSurfaces( fraSettings ); + } + // delete parameter files + cleanUpParameterFiles(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunBasicFaultReactAssessmentFeature::setupActionLook( QAction* actionToSetup ) +{ + actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) ); + actionToSetup->setText( "Run Basic Processing" ); +} diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.h new file mode 100644 index 0000000000..68339f0eb1 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunBasicFaultReactAssessmentFeature.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RicRunFaultReactAssessmentFeature.h" + +//================================================================================================== +/// +//================================================================================================== +class RicRunBasicFaultReactAssessmentFeature : public RicRunFaultReactAssessmentFeature +{ + CAF_CMD_HEADER_INIT; + +protected: + bool isCommandEnabled() override; + void onActionTriggered( bool isChecked ) override; + void setupActionLook( QAction* actionToSetup ) override; +}; diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp new file mode 100644 index 0000000000..6c59653c13 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.cpp @@ -0,0 +1,222 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RicRunFaultReactAssessmentFeature.h" + +#include "RiaApplication.h" +#include "RiaEclipseFileNameTools.h" +#include "RiaImportEclipseCaseTools.h" +#include "RiaPreferencesGeoMech.h" +#include "RiaResultNames.h" + +#include "RifFaultRAJsonWriter.h" + +#include "RimEclipseInputCase.h" +#include "RimEclipseResultCase.h" +#include "RimEclipseView.h" +#include "RimFaultInView.h" +#include "RimFaultInViewCollection.h" +#include "RimFaultRAPreprocSettings.h" +#include "RimFaultRASettings.h" +#include "RimFileSurface.h" +#include "RimGeoMechCase.h" +#include "RimOilField.h" +#include "RimProcess.h" +#include "RimProject.h" +#include "RimSurface.h" +#include "RimSurfaceCollection.h" + +#include "Riu3DMainWindowTools.h" +#include "RiuFileDialogTools.h" + +#include "cafPdmUiPropertyViewDialog.h" +#include "cafProgressInfo.h" +#include "cafSelectionManagerTools.h" +#include "cafUtils.h" + +#include +#include +#include +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RicRunFaultReactAssessmentFeature::RicRunFaultReactAssessmentFeature() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultInViewCollection* RicRunFaultReactAssessmentFeature::faultCollection() +{ + RimFaultInViewCollection* faultColl = + dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + + if ( faultColl ) return faultColl; + + RimFaultInView* selObj = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( selObj ) + { + if ( !selObj->name().startsWith( RiaResultNames::faultReactAssessmentPrefix() ) ) return nullptr; + selObj->firstAncestorOrThisOfType( faultColl ); + } + + return faultColl; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RicRunFaultReactAssessmentFeature::selectedFaultID() +{ + int retval = -1; + RimFaultInView* selObj = dynamic_cast( caf::SelectionManager::instance()->selectedItem() ); + if ( selObj ) + { + QString lookFor = RiaResultNames::faultReactAssessmentPrefix(); + QString name = selObj->name(); + if ( !name.startsWith( lookFor ) ) return retval; + + name = name.mid( lookFor.length() ); + if ( name.size() == 0 ) return retval; + + bool bOK; + retval = name.toInt( &bOK ); + if ( !bOK ) retval = -1; + } + + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RicRunFaultReactAssessmentFeature::runPostProcessing( int faultID, RimFaultRASettings* settings ) +{ + QString outErrorText; + if ( !RifFaultRAJSonWriter::writeToPostprocFile( faultID, settings, outErrorText ) ) + { + QMessageBox::warning( nullptr, + "Fault Reactivation Assessment Processing", + "Unable to write postproc parameter file! " + outErrorText ); + return false; + } + + QString command = RiaPreferencesGeoMech::current()->geomechFRAPostprocCommand(); + QStringList parameters = settings->postprocParameters( faultID ); + + RimProcess process; + process.setCommand( command ); + process.setParameters( parameters ); + + addParameterFileForCleanUp( settings->postprocParameterFilename( faultID ) ); + + if ( !process.execute() ) + { + QMessageBox::critical( nullptr, + "Fault Reactivation Assessment Processing", + "Failed to run post processing command. Check log window for additional " + "information." ); + return false; + } + + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunFaultReactAssessmentFeature::addParameterFileForCleanUp( QString filename ) +{ + m_parameterFilesToCleanUp.push_back( filename ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunFaultReactAssessmentFeature::cleanUpParameterFiles() +{ +#ifndef DEBUG + for ( auto& filename : m_parameterFilesToCleanUp ) + { + if ( QFile::exists( filename ) ) QFile::remove( filename ); + } +#endif + m_parameterFilesToCleanUp.clear(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimSurfaceCollection* RicRunFaultReactAssessmentFeature::surfaceCollection() +{ + RimProject* proj = RimProject::current(); + RimSurfaceCollection* surfColl = proj->activeOilField()->surfaceCollection(); + + if ( surfColl ) + { + for ( auto& subColl : surfColl->subCollections() ) + { + if ( subColl->collectionName() == "FaultRA" ) + { + return subColl; + } + } + + // No FaultRA collection found, make one + RimSurfaceCollection* fraCollection = new RimSurfaceCollection(); + fraCollection->setCollectionName( "FaultRA" ); + surfColl->addSubCollection( fraCollection ); + return fraCollection; + } + + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RicRunFaultReactAssessmentFeature::reloadSurfaces( RimFaultRASettings* settings ) +{ + RimSurfaceCollection* surfColl = surfaceCollection(); + if ( !surfColl ) return; + + // get rid of any files removed by the processing + surfColl->removeMissingFileSurfaces(); + + // ask the collection to reload the existing files + surfColl->reloadSurfaces( surfColl->surfaces() ); + + // get all the files in the folder, skip the ones we alreday have + QStringList newFiles; + + QDirIterator tsurfIt( settings->tsurfOutputDirectory(), { "*.ts" }, QDir::Files ); + while ( tsurfIt.hasNext() ) + { + QString filename = tsurfIt.next(); + if ( surfColl->containsFileSurface( filename ) ) continue; + newFiles << filename; + } + + // import the new surfaces + bool showLegendInView = false; + surfColl->importSurfacesFromFiles( newFiles, showLegendInView ); +} diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h new file mode 100644 index 0000000000..bfa3567477 --- /dev/null +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactAssessmentFeature.h @@ -0,0 +1,50 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 RimFaultInViewCollection; +class RimFaultRASettings; +class RimSurfaceCollection; + +#include + +//================================================================================================== +/// +//================================================================================================== +class RicRunFaultReactAssessmentFeature : public caf::CmdFeature +{ +protected: + RicRunFaultReactAssessmentFeature(); + + RimFaultInViewCollection* faultCollection(); + int selectedFaultID(); + + RimSurfaceCollection* surfaceCollection(); + + bool runPostProcessing( int faultID, RimFaultRASettings* settings ); + void reloadSurfaces( RimFaultRASettings* settings ); + + void addParameterFileForCleanUp( QString filename ); + void cleanUpParameterFiles(); + +private: + std::list m_parameterFilesToCleanUp; +}; diff --git a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp index d6d6457fa4..6b0558bab0 100644 --- a/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp +++ b/ApplicationLibCode/Commands/RicImportGeneralDataFeature.cpp @@ -248,7 +248,7 @@ bool RicImportGeneralDataFeature::openEclipseCaseFromFileNames( const QStringLis bool RicImportGeneralDataFeature::openInputEclipseCaseFromFileNames( const QStringList& fileNames ) { QString fileContainingGrid; - if ( RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( fileNames, &fileContainingGrid ) ) + if ( RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( fileNames, &fileContainingGrid ) >= 0 ) { RiaApplication::instance()->addToRecentFiles( fileContainingGrid ); return true; diff --git a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake index a07d098491..0f8a314edd 100644 --- a/ApplicationLibCode/FileInterface/CMakeLists_files.cmake +++ b/ApplicationLibCode/FileInterface/CMakeLists_files.cmake @@ -60,6 +60,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelDeviationFrkExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelPerfsFrkExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelAsymmetricFrkExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.h +${CMAKE_CURRENT_LIST_DIR}/RifFaultRAXmlWriter.h +${CMAKE_CURRENT_LIST_DIR}/RifFaultRAJsonWriter.h +${CMAKE_CURRENT_LIST_DIR}/RifParameterXmlReader.h ${CMAKE_CURRENT_LIST_DIR}/RifOpmCommonSummary.h ${CMAKE_CURRENT_LIST_DIR}/RifEnsembleFractureStatisticsExporter.h ${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderMultipleFiles.h @@ -128,6 +131,9 @@ ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelDeviationFrkExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelPerfsFrkExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifStimPlanModelAsymmetricFrkExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSurfaceExporter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifFaultRAXmlWriter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifFaultRAJsonWriter.cpp +${CMAKE_CURRENT_LIST_DIR}/RifParameterXmlReader.cpp ${CMAKE_CURRENT_LIST_DIR}/RifOpmCommonSummary.cpp ${CMAKE_CURRENT_LIST_DIR}/RifEnsembleFractureStatisticsExporter.cpp ${CMAKE_CURRENT_LIST_DIR}/RifSummaryReaderMultipleFiles.cpp diff --git a/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp b/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp new file mode 100644 index 0000000000..5f69541938 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.cpp @@ -0,0 +1,102 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RifFaultRAJsonWriter.h" + +#include "RimFaultRAPreprocSettings.h" +#include "RimFaultRASettings.h" + +#include +#include + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifFaultRAJSonWriter::writeToPreprocFile( RimFaultRAPreprocSettings& settings, QString& outErrorText ) +{ + QString filename = settings.preprocParameterFilename(); + + outErrorText = "Unable to write to file \"" + filename + "\" - "; + + QFile file( filename ); + if ( file.open( QIODevice::ReadWrite ) ) + { + QTextStream stream( &file ); + + stream << "{" << endl; + stream << "\"odb_path\": \"" + settings.geomechCaseFilename() + "\"," << endl; + stream << "\"time_start\": \"" + settings.startTimeStepGeoMech() + "\"," << endl; + stream << "\"time_end\": \"" + settings.endTimeStepGeoMech() + "\"" << endl; + stream << "\"out_path\": \"" + settings.outputAbaqusDirectory() + "\"" << endl; + stream << "}" << endl; + + file.close(); + } + else + { + outErrorText += "Could not open file."; + return false; + } + + outErrorText = ""; + return true; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RifFaultRAJSonWriter::writeToPostprocFile( int faultID, RimFaultRASettings* settings, QString& outErrorText ) +{ + QString filename = settings->postprocParameterFilename( faultID ); + + outErrorText = "Unable to write to file \"" + filename + "\" - "; + + QFile file( filename ); + if ( file.open( QIODevice::ReadWrite ) ) + { + QTextStream stream( &file ); + + stream << "{" << endl; + + if ( settings->geomechCase() != nullptr ) + { + if ( QFile::exists( settings->advancedMacrisDatabase() ) ) + stream << "\"MacrisCalcCalibration_path\": \"" + settings->advancedMacrisDatabase() + "\"," << endl; + } + + stream << "\"MacrisCalc_path\": \"" + settings->basicMacrisDatabase() + "\"," << endl; + + stream << "\"base_directory_path\": \"" + settings->outputBaseDirectory() + "\"," << endl; + + QStringList timesteps; + timesteps.push_back( QString::number( settings->endTimeStepEclipseIndex() ) ); + + stream << "\"tsurf_loadsteps\": [ " + timesteps.join( ',' ) + " ]" << endl; + stream << "}" << endl; + + file.close(); + } + else + { + outErrorText += "Could not open file."; + return false; + } + + outErrorText = ""; + return true; +} diff --git a/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.h b/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.h new file mode 100644 index 0000000000..5bb7b82df2 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifFaultRAJsonWriter.h @@ -0,0 +1,34 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 + +class RimFaultRAPreprocSettings; +class RimFaultRASettings; + +class RifFaultRAJSonWriter +{ +public: + static bool writeToPreprocFile( RimFaultRAPreprocSettings& settings, QString& outErrorText ); + static bool writeToPostprocFile( int faultID, RimFaultRASettings* settings, QString& outErrorText ); + +private: + RifFaultRAJSonWriter(){}; +}; diff --git a/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp b/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp new file mode 100644 index 0000000000..282b3ace13 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.cpp @@ -0,0 +1,79 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RifFaultRAXmlWriter.h" + +#include "RimFaultRASettings.h" +#include "RimGenericParameter.h" + +#include +#include + +RifFaultRAXmlWriter::RifFaultRAXmlWriter( RimFaultRASettings* settings ) + : m_settings( settings ) +{ +} + +RifFaultRAXmlWriter::~RifFaultRAXmlWriter() +{ +} + +bool RifFaultRAXmlWriter::writeCalculateFile( QString filename, int faultID, QString& outErrorText ) +{ + std::list paramlist = m_settings->basicParameters( faultID ); + return writeParametersToXML( filename, paramlist, outErrorText ); +} + +bool RifFaultRAXmlWriter::writeCalibrateFile( QString filename, int faultID, QString& outErrorText ) +{ + std::list paramlist = m_settings->advancedParameters( faultID ); + return writeParametersToXML( filename, paramlist, outErrorText ); +} + +bool RifFaultRAXmlWriter::writeParametersToXML( QString filename, std::list& params, QString& outErrorText ) +{ + bool bResult = false; + + outErrorText = "Unable to write to file \"" + filename + "\" - "; + + QFile file( filename ); + if ( file.open( QIODevice::ReadWrite ) ) + { + QTextStream stream( &file ); + + stream << "" << endl; + stream << "" << endl; + + for ( auto& p : params ) + { + QString tmpStr = QString( "<%1>%2" ).arg( p->name(), p->stringValue() ); + stream << tmpStr << endl; + } + stream << "" << endl; + + bResult = true; + } + else + { + outErrorText += "Could not open file."; + } + + if ( bResult ) outErrorText = ""; + + return bResult; +} diff --git a/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.h b/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.h new file mode 100644 index 0000000000..132a33aa26 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifFaultRAXmlWriter.h @@ -0,0 +1,41 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 + +#include + +class RimFaultRASettings; +class RimGenericParameter; + +class RifFaultRAXmlWriter +{ +public: + RifFaultRAXmlWriter( RimFaultRASettings* settings ); + ~RifFaultRAXmlWriter(); + + bool writeCalculateFile( QString filename, int faultID, QString& outErrorText ); + bool writeCalibrateFile( QString filename, int faultID, QString& outErrorText ); + +private: + bool writeParametersToXML( QString filename, std::list& params, QString& outErrorText ); + + RimFaultRASettings* m_settings; +}; diff --git a/ApplicationLibCode/FileInterface/RifParameterXmlReader.cpp b/ApplicationLibCode/FileInterface/RifParameterXmlReader.cpp new file mode 100644 index 0000000000..8a4650e069 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifParameterXmlReader.cpp @@ -0,0 +1,176 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RifParameterXmlReader.h" + +#include "RimDoubleParameter.h" +#include "RimGenericParameter.h" +#include "RimIntegerParameter.h" +#include "RimStringParameter.h" + +#include "RimParameterGroup.h" + +#include +#include + +RifParameterXmlReader::RifParameterXmlReader( QString filename ) + : m_filename( filename ) +{ +} + +RifParameterXmlReader::~RifParameterXmlReader() +{ +} + +RimGenericParameter* getParameterFromTypeStr( QString typestr ) +{ + // check that we have a type we support + if ( typestr == "float" ) + { + return new RimDoubleParameter(); + } + else if ( typestr == "int" ) + { + return new RimIntegerParameter(); + } + else if ( typestr == "string" ) + { + return new RimStringParameter(); + } + + return nullptr; +} + +bool RifParameterXmlReader::parseFile( QString& outErrorText ) +{ + m_parameters.clear(); + + outErrorText = "XML read error from file " + m_filename + " : "; + + QFile dataFile( m_filename ); + if ( !dataFile.open( QFile::ReadOnly ) ) + { + outErrorText += "Could not open file."; + return false; + } + + QXmlStreamReader xml; + xml.setDevice( &dataFile ); + QString parameter; + QString unit; + + RimParameterGroup* group = nullptr; + + std::list reqattrs = { QString( "name" ), QString( "label" ), QString( "type" ) }; + + bool bResult = true; + + while ( !xml.atEnd() ) + { + if ( xml.readNextStartElement() ) + { + if ( xml.name() == "group" ) + { + if ( group != nullptr ) + { + m_parameters.push_back( group ); + } + + group = new RimParameterGroup(); + if ( xml.attributes().hasAttribute( "label" ) ) + { + group->setName( xml.attributes().value( "label" ).toString() ); + } + if ( xml.attributes().hasAttribute( "expanded" ) ) + { + group->setExpanded( xml.attributes().value( "expanded" ).toString().toLower() == "true" ); + } + continue; + } + + if ( xml.name() == "parameter" ) + { + if ( group == nullptr ) continue; + + // check that we have the required attributes + for ( auto& reqattr : reqattrs ) + { + if ( !xml.attributes().hasAttribute( reqattr ) ) + { + outErrorText += "Missing required attribute \"" + reqattr + "\" for a parameter."; + bResult = false; + break; + } + } + + // get a parameter of the required type + QString paramtypestr = xml.attributes().value( "type" ).toString().toLower(); + + RimGenericParameter* parameter = getParameterFromTypeStr( paramtypestr ); + if ( parameter == nullptr ) + { + outErrorText += "Unsupported parameter type found: " + paramtypestr; + bResult = false; + break; + } + + parameter->setName( xml.attributes().value( "name" ).toString() ); + parameter->setLabel( xml.attributes().value( "label" ).toString() ); + parameter->setAdvanced( false ); + + if ( xml.attributes().hasAttribute( "advanced" ) ) + { + if ( xml.attributes().value( "advanced" ).toString().toLower() == "true" ) + parameter->setAdvanced( true ); + } + + if ( xml.attributes().hasAttribute( "description" ) ) + { + parameter->setDescription( xml.attributes().value( "description" ).toString() ); + } + + parameter->setValue( xml.readElementText().trimmed() ); + if ( !parameter->isValid() ) + { + outErrorText += "Invalid parameter value found for parameter: " + parameter->name(); + delete parameter; + bResult = false; + break; + } + + group->addParameter( parameter ); + } + } + } + + if ( group != nullptr ) + { + m_parameters.push_back( group ); + } + + dataFile.close(); + + if ( bResult ) outErrorText = ""; + + return bResult; +} + +std::list& RifParameterXmlReader::parameterGroups() +{ + return m_parameters; +} diff --git a/ApplicationLibCode/FileInterface/RifParameterXmlReader.h b/ApplicationLibCode/FileInterface/RifParameterXmlReader.h new file mode 100644 index 0000000000..f90dca6ad5 --- /dev/null +++ b/ApplicationLibCode/FileInterface/RifParameterXmlReader.h @@ -0,0 +1,40 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 + +#include + +class RimParameterGroup; + +class RifParameterXmlReader +{ +public: + RifParameterXmlReader( QString filename ); + ~RifParameterXmlReader(); + + bool parseFile( QString& outErrorText ); + + std::list& parameterGroups(); + +private: + std::list m_parameters; + QString m_filename; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Faults/CMakeLists_files.cmake index ceb053d9a6..9ef6fc1e25 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/Faults/CMakeLists_files.cmake @@ -2,11 +2,17 @@ set (SOURCE_GROUP_HEADER_FILES ${CMAKE_CURRENT_LIST_DIR}/RimFaultInView.h ${CMAKE_CURRENT_LIST_DIR}/RimFaultInViewCollection.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultRASettings.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultRAPreprocSettings.h +${CMAKE_CURRENT_LIST_DIR}/RimFaultRAPostprocSettings.h ) set (SOURCE_GROUP_SOURCE_FILES ${CMAKE_CURRENT_LIST_DIR}/RimFaultInView.cpp ${CMAKE_CURRENT_LIST_DIR}/RimFaultInViewCollection.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultRASettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultRAPreprocSettings.cpp +${CMAKE_CURRENT_LIST_DIR}/RimFaultRAPostprocSettings.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp index 19f59fb44e..7a5fad8f87 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.cpp @@ -27,8 +27,10 @@ #include "RigMainGrid.h" #include "RimEclipseCase.h" +#include "RimEclipseInputCase.h" #include "RimEclipseView.h" #include "RimFaultInView.h" +#include "RimFaultRASettings.h" #include "RimIntersectionCollection.h" #include "RiuMainWindow.h" @@ -36,6 +38,7 @@ #include "cafAppEnum.h" #include "cafPdmFieldCvfColor.h" #include "cafPdmFieldCvfMat4d.h" +#include "cafPdmUiTreeOrdering.h" namespace caf { @@ -89,6 +92,14 @@ RimFaultInViewCollection::RimFaultInViewCollection() CAF_PDM_InitFieldNoDefault( &faults, "Faults", "Faults", "", "", "" ); faults.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_enableFaultRA, "EnableFaultRA", false, "Enable Fault RA", "", "", "" ); + m_enableFaultRA.uiCapability()->setUiHidden( true ); + m_enableFaultRA.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_faultRASettings, "FaultRASettings", "Reactivation Assessment Settings", "", "", "" ); + m_faultRASettings = new RimFaultRASettings(); + m_faultRASettings.uiCapability()->setUiHidden( true ); } //-------------------------------------------------------------------------------------------------- @@ -217,8 +228,6 @@ void RimFaultInViewCollection::syncronizeFaults() } } - // Find faults with - std::vector> newFaults; // Find corresponding fault from data model, or create a new @@ -297,6 +306,19 @@ void RimFaultInViewCollection::defineUiOrdering( QString uiConfigName, caf::PdmU uiOrderingFaults( uiConfigName, uiOrdering ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName ) +{ + RimEclipseInputCase* inputCase = nullptr; + this->firstAncestorOrThisOfType( inputCase ); + if ( ( inputCase != nullptr ) && m_enableFaultRA() ) + { + uiTreeOrdering.add( &m_faultRASettings ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -325,3 +347,27 @@ void RimFaultInViewCollection::setShowFaultsOutsideFilter( bool show ) { m_showFaultsOutsideFilters = show; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRASettings* RimFaultInViewCollection::faultRASettings() const +{ + return m_faultRASettings(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultInViewCollection::faultRAEnabled() const +{ + return m_enableFaultRA(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultInViewCollection::enableFaultRA( bool enable ) +{ + m_enableFaultRA = enable; +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h index 369c4c7a0c..6175573cb3 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultInViewCollection.h @@ -33,6 +33,7 @@ class RimEclipseView; class RimFaultInView; +class RimFaultRASettings; //================================================================================================== /// @@ -61,6 +62,10 @@ public: bool isShowingFaultsAndFaultsOutsideFilters() const; void setShowFaultsOutsideFilter( bool show ); + RimFaultRASettings* faultRASettings() const; + bool faultRAEnabled() const; + void enableFaultRA( bool enable ); + caf::PdmField showFaultFaces; caf::PdmField showOppositeFaultFaces; @@ -81,9 +86,15 @@ public: private: void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override; caf::PdmFieldHandle* objectToggleField() override; - void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - RimEclipseView* parentView() const; + + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override; + + RimEclipseView* parentView() const; private: caf::PdmField m_showFaultsOutsideFilters; + + caf::PdmChildField m_faultRASettings; + caf::PdmField m_enableFaultRA; }; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp new file mode 100644 index 0000000000..922f2add2e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.cpp @@ -0,0 +1,90 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RimFaultRAPostprocSettings.h" + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRAPostprocSettings::RimFaultRAPostprocSettings() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRAPostprocSettings::~RimFaultRAPostprocSettings() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPostprocSettings::setBaseDirectory( QString baseDir ) +{ + m_baseDir = baseDir + "/base_dir"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPostprocSettings::setStepsToLoad( std::list steps ) +{ + m_steps.clear(); + m_steps.insert( m_steps.begin(), steps.begin(), steps.end() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::list& RimFaultRAPostprocSettings::stepsToLoad() +{ + return m_steps; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPostprocSettings::postprocParameterFilename() const +{ + return m_baseDir + "/post_processing.json"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPostprocSettings::databaseDirectory() const +{ + return m_baseDir; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPostprocSettings::macrisCalcCalibPath() const +{ + return m_baseDir + "/MacrisCalcCalibration.sqlite3"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPostprocSettings::macrisCalcPath() const +{ + return m_baseDir + "/MacrisCalcResult.sqlite3"; +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.h new file mode 100644 index 0000000000..4d8534627a --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPostprocSettings.h @@ -0,0 +1,43 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 + +#include + +class RimFaultRAPostprocSettings +{ +public: + RimFaultRAPostprocSettings(); + ~RimFaultRAPostprocSettings(); + + void setBaseDirectory( QString baseDir ); + void setStepsToLoad( std::list steps ); + + std::list& stepsToLoad(); + + QString postprocParameterFilename() const; + QString databaseDirectory() const; + QString macrisCalcCalibPath() const; + QString macrisCalcPath() const; + +protected: + QString m_baseDir; + std::list m_steps; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp new file mode 100644 index 0000000000..f5e335d936 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.cpp @@ -0,0 +1,427 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RimFaultRAPreprocSettings.h" + +#include "RiaApplication.h" +#include "RiaPreferences.h" +#include "RimEclipseResultCase.h" +#include "RimGeoMechCase.h" +#include "RimProject.h" +#include "RimTools.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiComboBoxEditor.h" + +#include +#include + +CAF_PDM_SOURCE_INIT( RimFaultRAPreprocSettings, "RimFaultRAPreprocSettings" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRAPreprocSettings::RimFaultRAPreprocSettings() +{ + CAF_PDM_InitObject( "Fault RA Preproc Settings", ":/fault_react_24x24.png", "", "" ); + + CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step", "", "", "" ); + m_startTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step", "", "", "" ); + m_endTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_startTimestepGeoMech, "StartTimeStepGeoMech", 0, "Start Time Step", "", "", "" ); + m_startTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_endTimestepGeoMech, "EndTimeStepGeoMech", 0, "End Time Step", "", "", "" ); + m_endTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case", "", "", "" ); + m_eclipseCase.setValue( nullptr ); + + CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case", "", "", "" ); + m_geomechCase.setValue( nullptr ); + + CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Output Directory", "", "", "" ); + m_baseDir.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitField( &m_cleanBaseDir, "CleanBaseDir", false, "Clean Output Directory", "", "", "" ); + CAF_PDM_InitField( &m_smoothEclipseData, "SmoothEclipseData", false, "Smooth Eclipse Data", "", "", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRAPreprocSettings::~RimFaultRAPreprocSettings() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPreprocSettings::fieldChangedByUi( const caf::PdmFieldHandle* changedField, + const QVariant& oldValue, + const QVariant& newValue ) +{ + if ( ( changedField == &m_eclipseCase ) && ( m_startTimestepEclipse == m_endTimestepEclipse ) ) + { + m_endTimestepEclipse = m_eclipseCase()->timeStepStrings().size() - 1; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPreprocSettings::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPreprocSettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + if ( m_geomechCase() ) + { + auto geomechGroup = uiOrdering.addNewGroup( "GeoMechanical Model" ); + geomechGroup->add( &m_geomechCase ); + geomechGroup->add( &m_startTimestepGeoMech ); + geomechGroup->add( &m_endTimestepGeoMech ); + } + + auto eclipseGroup = uiOrdering.addNewGroup( "Eclipse Model" ); + eclipseGroup->add( &m_eclipseCase ); + eclipseGroup->add( &m_smoothEclipseData ); + eclipseGroup->add( &m_startTimestepEclipse ); + eclipseGroup->add( &m_endTimestepEclipse ); + + auto outputGroup = uiOrdering.addNewGroup( "Output Settings" ); + outputGroup->add( &m_baseDir ); + outputGroup->add( &m_cleanBaseDir ); + + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList + RimFaultRAPreprocSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) +{ + QList options; + + if ( fieldNeedingOptions == &m_eclipseCase ) + { + RimTools::eclipseCaseOptionItems( &options ); + } + else if ( fieldNeedingOptions == &m_geomechCase ) + { + RimTools::geoMechCaseOptionItems( &options ); + } + + if ( m_geomechCase() ) + { + if ( fieldNeedingOptions == &m_startTimestepGeoMech ) + { + RimTools::timeStepsForCase( m_geomechCase, &options ); + } + else if ( fieldNeedingOptions == &m_endTimestepGeoMech ) + { + RimTools::timeStepsForCase( m_geomechCase, &options ); + } + } + + if ( m_eclipseCase() ) + { + if ( fieldNeedingOptions == &m_startTimestepEclipse ) + { + RimTools::timeStepsForCase( m_eclipseCase, &options ); + } + else if ( fieldNeedingOptions == &m_endTimestepEclipse ) + { + RimTools::timeStepsForCase( m_eclipseCase, &options ); + } + } + + return options; +} + +RimCase* RimFaultRAPreprocSettings::startCase() const +{ + if ( m_geomechCase() ) return m_geomechCase(); + return m_eclipseCase(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRAPreprocSettings::startTimeStepEclipseIndex() const +{ + return m_startTimestepEclipse(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::startTimeStepEclipse() const +{ + if ( m_eclipseCase() ) + { + if ( ( m_startTimestepEclipse >= 0 ) && ( m_startTimestepEclipse <= m_eclipseCase->timeStepStrings().size() ) ) + return m_eclipseCase->timeStepStrings()[m_startTimestepEclipse]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRAPreprocSettings::endTimeStepEclipseIndex() const +{ + return m_endTimestepEclipse(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::endTimeStepEclipse() const +{ + if ( m_eclipseCase() ) + { + if ( ( m_endTimestepEclipse >= 0 ) && ( m_endTimestepEclipse <= m_eclipseCase->timeStepStrings().size() ) ) + return m_eclipseCase->timeStepStrings()[m_endTimestepEclipse]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::eclipseCaseFilename() const +{ + if ( m_eclipseCase ) return m_eclipseCase->gridFileName(); + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRAPreprocSettings::startTimeStepGeoMechIndex() const +{ + return m_startTimestepGeoMech(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::startTimeStepGeoMech() const +{ + if ( m_geomechCase() ) + { + if ( ( m_startTimestepGeoMech >= 0 ) && ( m_startTimestepGeoMech <= m_geomechCase->timeStepStrings().size() ) ) + return m_geomechCase->timeStepStrings()[m_startTimestepEclipse]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRAPreprocSettings::endTimeStepGeoMechIndex() const +{ + return m_endTimestepGeoMech(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::endTimeStepGeoMech() const +{ + if ( m_geomechCase() ) + { + if ( ( m_endTimestepGeoMech >= 0 ) && ( m_endTimestepGeoMech <= m_geomechCase->timeStepStrings().size() ) ) + return m_geomechCase->timeStepStrings()[m_endTimestepGeoMech]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::geomechCaseFilename() const +{ + if ( m_geomechCase ) return m_geomechCase->gridFileName(); + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::preprocParameterFilename() const +{ + return m_baseDir + "/tmp/pre_processing.json"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::outputBaseDirectory() const +{ + return m_baseDir(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultRAPreprocSettings::cleanBaseDirectory() const +{ + return m_cleanBaseDir(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultRAPreprocSettings::smoothEclipseData() const +{ + return m_smoothEclipseData(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPreprocSettings::setGeoMechCase( RimGeoMechCase* geomechCase ) +{ + m_geomechCase = geomechCase; + if ( geomechCase ) m_endTimestepGeoMech = geomechCase->timeStepStrings().size() - 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCase* RimFaultRAPreprocSettings::geoMechCase() const +{ + return m_geomechCase(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPreprocSettings::setEclipseCase( RimEclipseResultCase* eclipseCase ) +{ + m_eclipseCase = eclipseCase; + if ( eclipseCase ) m_endTimestepEclipse = eclipseCase->timeStepStrings().size() - 1; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimFaultRAPreprocSettings::eclipseCase() const +{ + return m_eclipseCase(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRAPreprocSettings::setOutputBaseDirectory( QString baseDir ) +{ + m_baseDir = baseDir; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::outputEclipseFilename() const +{ + QString retval = outputEclipseDirectory(); + retval += QDir::separator(); + + QFileInfo fi( eclipseCaseFilename() ); + retval += fi.baseName() + "_RI.GRDECL"; + + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::outputEclipseDirectory() const +{ + QString retval = m_baseDir; + retval += "/Eclipse"; + + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRAPreprocSettings::outputAbaqusDirectory() const +{ + QString retval = m_baseDir; + retval += "/Abaqus"; + + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimFaultRAPreprocSettings::preprocParameterList() const +{ + QStringList retlist; + retlist << preprocParameterFilename(); + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimFaultRAPreprocSettings::macrisPrepareParameterList() const +{ + QStringList retlist; + + retlist << "prepare"; + + retlist << "-o"; + + retlist << outputEclipseDirectory(); + + if ( m_smoothEclipseData ) + { + retlist << "-ds"; + } + else + { + retlist << "-d"; + } + + retlist << m_eclipseCase()->gridFileName(); + + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimFaultRAPreprocSettings::geoMechSelected() const +{ + return m_geomechCase.value() != nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h new file mode 100644 index 0000000000..f6d6550d69 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRAPreprocSettings.h @@ -0,0 +1,93 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +class RimEclipseResultCase; +class RimEclipseCase; +class RimGeoMechCase; +class RimCase; + +class RimFaultRAPreprocSettings : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimFaultRAPreprocSettings(); + ~RimFaultRAPreprocSettings() override; + + void setGeoMechCase( RimGeoMechCase* geomechCase ); + RimGeoMechCase* geoMechCase() const; + + void setEclipseCase( RimEclipseResultCase* eclipseCase ); + RimEclipseCase* eclipseCase() const; + + void setOutputBaseDirectory( QString baseDir ); + QString outputBaseDirectory() const; + + int startTimeStepGeoMechIndex() const; + QString startTimeStepGeoMech() const; + int endTimeStepGeoMechIndex() const; + QString endTimeStepGeoMech() const; + + int startTimeStepEclipseIndex() const; + QString startTimeStepEclipse() const; + int endTimeStepEclipseIndex() const; + QString endTimeStepEclipse() const; + + QString eclipseCaseFilename() const; + QString geomechCaseFilename() const; + bool cleanBaseDirectory() const; + bool smoothEclipseData() const; + + bool geoMechSelected() const; + + QString preprocParameterFilename() const; + QString outputEclipseFilename() const; + QString outputEclipseDirectory() const; + + QString outputAbaqusDirectory() const; + + QStringList preprocParameterList() const; + QStringList macrisPrepareParameterList() const; + +protected: + 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; + + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) override; + + RimCase* startCase() const; + + caf::PdmField m_startTimestepEclipse; + caf::PdmField m_endTimestepEclipse; + caf::PdmField m_startTimestepGeoMech; + caf::PdmField m_endTimestepGeoMech; + caf::PdmPtrField m_eclipseCase; + caf::PdmField m_smoothEclipseData; + caf::PdmPtrField m_geomechCase; + caf::PdmField m_baseDir; + caf::PdmField m_cleanBaseDir; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp new file mode 100644 index 0000000000..409bd16a65 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.cpp @@ -0,0 +1,598 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimFaultRASettings.h" +#include "RimFaultRAPreprocSettings.h" + +#include "RiaApplication.h" +#include "RiaPreferencesGeoMech.h" +#include "RimDoubleParameter.h" +#include "RimEclipseCase.h" +#include "RimEclipseInputCase.h" +#include "RimEclipseResultCase.h" +#include "RimGenericParameter.h" +#include "RimGeoMechCase.h" +#include "RimIntegerParameter.h" +#include "RimParameterGroup.h" +#include "RimProject.h" +#include "RimStringParameter.h" +#include "RimTools.h" + +#include "RifParameterXmlReader.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiComboBoxEditor.h" +#include "cafPdmUiTableViewEditor.h" + +CAF_PDM_SOURCE_INIT( RimFaultRASettings, "RimFaultRASettings" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRASettings::RimFaultRASettings() +{ + CAF_PDM_InitObject( "Reactivation Assessment Settings", ":/fault_react_24x24.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_eclipseCase, "EclipseCase", "Eclipse Case", "", "", "" ); + m_eclipseCase.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_geomechCase, "GeomechCase", "GeoMech Case", "", "", "" ); + m_geomechCase.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_eclipseFRAGeneratedCase, "EclipseFRACase", "Eclipse FRA Case", "", "", "" ); + m_eclipseFRAGeneratedCase.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_baseDir, "BaseDir", "Working Directory", "", "", "" ); + m_baseDir.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitField( &m_startTimestepEclipse, "StartTimeStepEclipse", 0, "Start Time Step", "", "", "" ); + m_startTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + CAF_PDM_InitField( &m_endTimestepEclipse, "EndTimeStepEclipse", 0, "End Time Step", "", "", "" ); + m_endTimestepEclipse.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + + CAF_PDM_InitField( &m_startTimestepGeoMech, "StartTimeStepGeoMech", 0, "Start Time Step", "", "", "" ); + m_startTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + m_startTimestepGeoMech.uiCapability()->setUiReadOnly( true ); + CAF_PDM_InitField( &m_endTimestepGeoMech, "EndTimeStepGeoMech", 0, "End Time Step", "", "", "" ); + m_endTimestepGeoMech.uiCapability()->setUiEditorTypeName( caf::PdmUiComboBoxEditor::uiEditorTypeName() ); + m_endTimestepGeoMech.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_basicParameters, "BasicParameters", "Basic Processing Parameters", ":/Bullet.png", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_advancedParameters, + "AdvancedParameters", + "Advanced Processing Parameters", + ":/Bullet.png", + "", + "" ); + + CAF_PDM_InitFieldNoDefault( &m_basicParametersRI, "BasicParametersRI", "Basic ResInsight Parameters", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_advancedParametersRI, "AdvancedParametersRI", "Advanced ResInsight Parameters", "", "", "" ); + setupResInsightParameters(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimFaultRASettings::~RimFaultRASettings() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimFaultRASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) +{ + QList options; + + if ( fieldNeedingOptions == &m_eclipseCase ) + { + RimTools::eclipseCaseOptionItems( &options ); + } + else if ( fieldNeedingOptions == &m_geomechCase ) + { + RimTools::geoMechCaseOptionItems( &options ); + } + + if ( m_geomechCase() ) + { + if ( fieldNeedingOptions == &m_startTimestepGeoMech ) + { + RimTools::timeStepsForCase( m_geomechCase, &options ); + } + else if ( fieldNeedingOptions == &m_endTimestepGeoMech ) + { + RimTools::timeStepsForCase( m_geomechCase, &options ); + } + } + + if ( m_eclipseCase() ) + { + if ( fieldNeedingOptions == &m_startTimestepEclipse ) + { + RimTools::timeStepsForCase( m_eclipseCase(), &options ); + } + else if ( fieldNeedingOptions == &m_endTimestepEclipse ) + { + RimTools::timeStepsForCase( m_eclipseCase(), &options ); + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + uiOrdering.add( &m_baseDir ); + auto eclipseGroup = uiOrdering.addNewGroup( "Eclipse Time Steps" ); + eclipseGroup->add( &m_startTimestepEclipse ); + eclipseGroup->add( &m_endTimestepEclipse ); + + if ( m_geomechCase() != nullptr ) + { + auto geomechGroup = uiOrdering.addNewGroup( "GeoMech Time Steps" ); + geomechGroup->add( &m_startTimestepGeoMech ); + geomechGroup->add( &m_endTimestepGeoMech ); + } + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::eclipseCaseFilename() const +{ + if ( m_eclipseCase ) return m_eclipseCase->gridFileName(); + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimFaultRASettings::eclipseCase() const +{ + return m_eclipseCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseInputCase* RimFaultRASettings::eclipseFRAGeneratedCase() const +{ + return m_eclipseFRAGeneratedCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::geomechCaseFilename() const +{ + if ( m_geomechCase ) return m_geomechCase->gridFileName(); + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGeoMechCase* RimFaultRASettings::geomechCase() const +{ + return m_geomechCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::basicCalcParameterFilename() const +{ + return m_baseDir + "/calc_parameters.xml"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::advancedCalcParameterFilename() const +{ + return m_baseDir + "/calib_parameters.xml"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::outputBaseDirectory() const +{ + return m_baseDir(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::setGeoMechCase( RimGeoMechCase* geomechCase ) +{ + m_geomechCase = geomechCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::setOutputBaseDirectory( QString baseDir ) +{ + m_baseDir = baseDir; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::initFromPreprocSettings( RimFaultRAPreprocSettings* preprocSettings, + RimEclipseInputCase* eclipseCase ) +{ + m_geomechCase = preprocSettings->geoMechCase(); + m_eclipseCase = preprocSettings->eclipseCase(); + m_eclipseFRAGeneratedCase = eclipseCase; + m_baseDir = preprocSettings->outputBaseDirectory(); + m_startTimestepEclipse = preprocSettings->startTimeStepEclipseIndex(); + m_endTimestepEclipse = preprocSettings->endTimeStepEclipseIndex(); + m_startTimestepGeoMech = preprocSettings->startTimeStepGeoMechIndex(); + m_endTimestepGeoMech = preprocSettings->endTimeStepGeoMechIndex(); + + QString errorText; + + RifParameterXmlReader basicreader( RiaPreferencesGeoMech::current()->geomechFRADefaultBasicXML() ); + if ( !basicreader.parseFile( errorText ) ) return; + + m_basicParameters.clear(); + for ( auto group : basicreader.parameterGroups() ) + { + m_basicParameters.push_back( group ); + } + + if ( geomechCase() != nullptr ) + { + RifParameterXmlReader advreader( RiaPreferencesGeoMech::current()->geomechFRADefaultAdvXML() ); + if ( !advreader.parseFile( errorText ) ) return; + + m_advancedParameters.clear(); + for ( auto group : advreader.parameterGroups() ) + { + m_advancedParameters.push_back( group ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRASettings::startTimeStepEclipseIndex() const +{ + return m_startTimestepEclipse(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::startTimeStepEclipse() const +{ + if ( m_eclipseCase() ) + { + if ( ( m_startTimestepEclipse >= 0 ) && ( m_startTimestepEclipse <= m_eclipseCase->timeStepStrings().size() ) ) + return m_eclipseCase->timeStepStrings()[m_startTimestepEclipse]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRASettings::endTimeStepEclipseIndex() const +{ + return m_endTimestepEclipse(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::endTimeStepEclipse() const +{ + if ( m_eclipseCase() ) + { + if ( ( m_endTimestepEclipse >= 0 ) && ( m_endTimestepEclipse <= m_eclipseCase->timeStepStrings().size() ) ) + return m_eclipseCase->timeStepStrings()[m_endTimestepEclipse]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRASettings::startTimeStepGeoMechIndex() const +{ + return m_startTimestepGeoMech(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::startTimeStepGeoMech() const +{ + if ( m_geomechCase() ) + { + if ( ( m_startTimestepGeoMech >= 0 ) && ( m_startTimestepGeoMech <= m_geomechCase->timeStepStrings().size() ) ) + return m_geomechCase->timeStepStrings()[m_startTimestepEclipse]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimFaultRASettings::endTimeStepGeoMechIndex() const +{ + return m_endTimestepGeoMech(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::endTimeStepGeoMech() const +{ + if ( m_geomechCase() ) + { + if ( ( m_endTimestepGeoMech >= 0 ) && ( m_endTimestepGeoMech <= m_geomechCase->timeStepStrings().size() ) ) + return m_geomechCase->timeStepStrings()[m_endTimestepGeoMech]; + } + return ""; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::setEclipseTimeStepIndexes( int start, int stop ) +{ + m_startTimestepEclipse = start; + m_endTimestepEclipse = stop; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::setGeomechTimeStepIndexes( int start, int stop ) +{ + m_startTimestepGeoMech = start; + m_endTimestepGeoMech = stop; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::list RimFaultRASettings::basicParameters( int faultID ) +{ + m_basicParametersRI->setParameterValue( "eclipse_input_grid", eclipseCaseFilename() ); + m_basicParametersRI->setParameterValue( "faultid", faultID ); + + std::list retlist; + + for ( auto& p : m_basicParametersRI->parameters() ) + { + retlist.push_back( p ); + } + + for ( auto& group : m_basicParameters.childObjects() ) + { + for ( auto& p : group->parameters() ) + { + retlist.push_back( p ); + } + } + + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::list RimFaultRASettings::advancedParameters( int faultID ) +{ + m_advancedParametersRI->setParameterValue( "eclipse_loadstep_start", startTimeStepEclipse() ); + m_advancedParametersRI->setParameterValue( "eclipse_loadstep_end", m_endTimestepEclipse() ); + m_advancedParametersRI->setParameterValue( "faultid_calibration", faultID ); + m_advancedParametersRI->setParameterValue( "abaqus_elastic_properties", elasticPropertiesFilename() ); + m_advancedParametersRI->setParameterValue( "abaqus_stress_start", stressStartFilename() ); + m_advancedParametersRI->setParameterValue( "abaqus_stress_end", stressEndFilename() ); + + std::list retlist; + + for ( auto& p : m_advancedParametersRI->parameters() ) + { + retlist.push_back( p ); + } + + for ( auto& group : m_advancedParameters.childObjects() ) + { + for ( auto& p : group->parameters() ) + { + retlist.push_back( p ); + } + } + + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimFaultRASettings::setupResInsightParameters() +{ + m_basicParametersRI = new RimParameterGroup(); + m_basicParametersRI->setName( "ResInsight Basic" ); + m_basicParametersRI->addParameter( "eclipse_input_grid", "" ); + m_basicParametersRI->addParameter( "faultid", -1 ); + + m_advancedParametersRI = new RimParameterGroup(); + m_advancedParametersRI->setName( "ResInsight Advanced" ); + m_advancedParametersRI->addParameter( "abaqus_elastic_properties", "" ); + m_advancedParametersRI->addParameter( "abaqus_stress_start", "" ); + m_advancedParametersRI->addParameter( "abaqus_stress_end", "" ); + m_advancedParametersRI->addParameter( "faultid_calibration", -1 ); + m_advancedParametersRI->addParameter( "eclipse_loadstep_start", "" ); + m_advancedParametersRI->addParameter( "eclipse_loadstep_end", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::elasticPropertiesFilename() const +{ + return m_baseDir + "/Abaqus/ELASTIC_TABLE_res.inp"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::stressStartFilename() const +{ + QString filename = QString( "/%1/%2_%3_stress.rpt" ).arg( "Abaqus", geomechCase()->uiName(), startTimeStepGeoMech() ); + return m_baseDir + filename; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::stressEndFilename() const +{ + QString filename = QString( "/%1/%2_%3_stress.rpt" ).arg( "Abaqus", geomechCase()->uiName(), endTimeStepGeoMech() ); + return m_baseDir + filename; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::basicMacrisDatabase() const +{ + return m_baseDir + "/MacrisCalcResult.sqlite3"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::advancedMacrisDatabase() const +{ + return m_baseDir + "/MacrisCalcCalibration.sqlite3"; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::loadStepStart() const +{ + QString retval = QString( "PRESSURE_%1" ).arg( startTimeStepEclipseIndex(), 2, 10, QChar( '0' ) ); + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::loadStepEnd() const +{ + QString retval = QString( "PRESSURE_%1" ).arg( endTimeStepEclipseIndex(), 2, 10, QChar( '0' ) ); + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::basicParameterXMLFilename( int faultID ) const +{ + QString retval = m_baseDir; + retval += QString( "/tmp/calculate_%1.xml" ).arg( faultID, 3, 10, QChar( '0' ) ); + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::advancedParameterXMLFilename( int faultID ) const +{ + QString retval = m_baseDir; + retval += QString( "/tmp/calibrate_%1.xml" ).arg( faultID, 3, 10, QChar( '0' ) ); + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::postprocParameterFilename( int faultID ) const +{ + QString retval = m_baseDir; + retval += QString( "/tmp/postproc_%1.json" ).arg( faultID, 3, 10, QChar( '0' ) ); + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimFaultRASettings::basicMacrisParameters( int faultID ) const +{ + QStringList retlist; + + retlist << "calculate"; + retlist << basicCalcParameterFilename(); + retlist << m_baseDir(); + retlist << "-i"; + retlist << loadStepStart(); + retlist << loadStepEnd(); + + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimFaultRASettings::advancedMacrisParameters( int faultID ) const +{ + QStringList retlist; + + retlist << "calibrate"; + retlist << basicCalcParameterFilename(); + retlist << advancedCalcParameterFilename(); + retlist << m_baseDir(); + + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimFaultRASettings::postprocParameters( int faultID ) const +{ + QStringList retlist; + + retlist << postprocParameterFilename( faultID ); + + return retlist; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimFaultRASettings::tsurfOutputDirectory() const +{ + return m_baseDir + "/tsurf"; +} diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h new file mode 100644 index 0000000000..ee03cd1944 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultRASettings.h @@ -0,0 +1,116 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +#include +#include + +class RimEclipseInputCase; +class RimEclipseCase; +class RimGeoMechCase; +class RimParameterGroup; +class RimFaultRAPreprocSettings; +class RimGenericParameter; + +class RimFaultRASettings : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimFaultRASettings(); + ~RimFaultRASettings() override; + + void initFromPreprocSettings( RimFaultRAPreprocSettings* preprocsettings, RimEclipseInputCase* eclipseCase ); + + void setGeoMechCase( RimGeoMechCase* geomechCase ); + RimGeoMechCase* geomechCase() const; + QString geomechCaseFilename() const; + + RimEclipseInputCase* eclipseFRAGeneratedCase() const; + RimEclipseCase* eclipseCase() const; + QString eclipseCaseFilename() const; + + void setOutputBaseDirectory( QString baseDir ); + QString outputBaseDirectory() const; + + QString basicCalcParameterFilename() const; + QString advancedCalcParameterFilename() const; + + int startTimeStepGeoMechIndex() const; + QString startTimeStepGeoMech() const; + int endTimeStepGeoMechIndex() const; + QString endTimeStepGeoMech() const; + + void setEclipseTimeStepIndexes( int start, int stop ); + void setGeomechTimeStepIndexes( int start, int stop ); + + int startTimeStepEclipseIndex() const; + QString startTimeStepEclipse() const; + QString loadStepStart() const; + int endTimeStepEclipseIndex() const; + QString endTimeStepEclipse() const; + QString loadStepEnd() const; + + std::list basicParameters( int faultID ); + std::list advancedParameters( int faultID ); + + QString elasticPropertiesFilename() const; + QString stressStartFilename() const; + QString stressEndFilename() const; + QString basicMacrisDatabase() const; + QString advancedMacrisDatabase() const; + + QString basicParameterXMLFilename( int faultID ) const; + QString advancedParameterXMLFilename( int faultID ) const; + QString postprocParameterFilename( int faultID ) const; + + QStringList basicMacrisParameters( int faultID ) const; + QStringList advancedMacrisParameters( int faultID ) const; + QStringList postprocParameters( int faultID ) const; + + QString tsurfOutputDirectory() const; + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) override; + +private: + void setupResInsightParameters(); + +private: + caf::PdmPtrField m_eclipseFRAGeneratedCase; + caf::PdmPtrField m_eclipseCase; + caf::PdmPtrField m_geomechCase; + caf::PdmField m_baseDir; + + caf::PdmField m_startTimestepEclipse; + caf::PdmField m_endTimestepEclipse; + caf::PdmField m_startTimestepGeoMech; + caf::PdmField m_endTimestepGeoMech; + + caf::PdmChildArrayField m_basicParameters; + caf::PdmChildArrayField m_advancedParameters; + caf::PdmPtrField m_basicParametersRI; + caf::PdmPtrField m_advancedParametersRI; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/Parameters/CMakeLists_files.cmake new file mode 100644 index 0000000000..406c4bad86 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/CMakeLists_files.cmake @@ -0,0 +1,26 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RimGenericParameter.h +${CMAKE_CURRENT_LIST_DIR}/RimDoubleParameter.h +${CMAKE_CURRENT_LIST_DIR}/RimIntegerParameter.h +${CMAKE_CURRENT_LIST_DIR}/RimStringParameter.h +${CMAKE_CURRENT_LIST_DIR}/RimParameterGroup.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RimGenericParameter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimDoubleParameter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimIntegerParameter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimStringParameter.cpp +${CMAKE_CURRENT_LIST_DIR}/RimParameterGroup.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +source_group( "ProjectDataModel\\Parameters" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp new file mode 100644 index 0000000000..fc1872da08 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.cpp @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimDoubleParameter.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiLineEditor.h" + +#include + +CAF_PDM_SOURCE_INIT( RimDoubleParameter, "DoubleParameter" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimDoubleParameter::RimDoubleParameter() +{ + CAF_PDM_InitField( &m_value, "Value", 0.0, "Value", "", "", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimDoubleParameter::~RimDoubleParameter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDoubleParameter::setValue( double value ) +{ + m_value = value; + setValid( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimDoubleParameter::setValue( QString value ) +{ + bool bOk = false; + m_value = value.toDouble( &bOk ); + setValid( bOk ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QVariant RimDoubleParameter::variantValue() const +{ + return QVariant( m_value() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimDoubleParameter::stringValue() const +{ + return QString::number( m_value() ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.h b/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.h new file mode 100644 index 0000000000..0ad8c95e30 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimDoubleParameter.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include + +#include "RimGenericParameter.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimDoubleParameter : public RimGenericParameter +{ + CAF_PDM_HEADER_INIT; + +public: + RimDoubleParameter(); + ~RimDoubleParameter() override; + + void setValue( double value ); + void setValue( QString value ) override; + QVariant variantValue() const override; + QString stringValue() const override; + +private: + caf::PdmField m_value; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp new file mode 100644 index 0000000000..e75feeb38e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.cpp @@ -0,0 +1,145 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimGenericParameter.h" + +#include "RiuGuiTheme.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiLineEditor.h" + +#include + +CAF_PDM_ABSTRACT_SOURCE_INIT( RimGenericParameter, "GenericParameter" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGenericParameter::RimGenericParameter() +{ + CAF_PDM_InitObject( "Parameter", ":/Bullet.png", "", "" ); + + CAF_PDM_InitField( &m_name, "Name", QString(), "Name", "", "", "" ); + m_name.uiCapability()->setUiReadOnly( true ); + m_name.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_label, "Label", QString(), "Name", "", "", "" ); + m_label.uiCapability()->setUiReadOnly( true ); + m_label.uiCapability()->setUiContentTextColor( RiuGuiTheme::getColorByVariableName( "textColor" ) ); + + CAF_PDM_InitField( &m_description, "Description", QString(), "Description", "", "", "" ); + m_description.uiCapability()->setUiReadOnly( true ); + m_description.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_advanced, "Advanced", false, "Advanced", "", "", "" ); + m_advanced.uiCapability()->setUiReadOnly( true ); + m_advanced.uiCapability()->setUiHidden( true ); + + CAF_PDM_InitField( &m_valid, "Valid", false, "Valid", "", "", "" ); + m_valid.uiCapability()->setUiReadOnly( true ); + m_valid.uiCapability()->setUiHidden( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimGenericParameter::~RimGenericParameter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGenericParameter::setName( QString name ) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGenericParameter::setLabel( QString labelText ) +{ + m_label = labelText; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGenericParameter::setDescription( QString description ) +{ + m_description = description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGenericParameter::setAdvanced( bool isAdvanced ) +{ + m_advanced = isAdvanced; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGenericParameter::isAdvanced() const +{ + return m_advanced(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimGenericParameter::isValid() const +{ + return m_valid(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimGenericParameter::setValid( bool valid ) +{ + m_valid = valid; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGenericParameter::name() const +{ + return m_name(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGenericParameter::label() const +{ + return m_label(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimGenericParameter::description() const +{ + return m_description(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.h b/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.h new file mode 100644 index 0000000000..2b4c2a65f7 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimGenericParameter.h @@ -0,0 +1,62 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include + +//================================================================================================== +/// +/// +//================================================================================================== +class RimGenericParameter : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimGenericParameter(); + ~RimGenericParameter() override; + + void setName( QString name ); + void setLabel( QString labelText ); + void setDescription( QString description ); + void setAdvanced( bool isAdvanced = false ); + + virtual void setValue( QString value ) = 0; + virtual QVariant variantValue() const = 0; + virtual QString stringValue() const = 0; + + QString name() const; + QString label() const; + QString description() const; + bool isAdvanced() const; + bool isValid() const; + +protected: + void setValid( bool valid ); + +private: + caf::PdmField m_name; + caf::PdmField m_label; + caf::PdmField m_description; + caf::PdmField m_advanced; + caf::PdmField m_valid; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp new file mode 100644 index 0000000000..6ce5c1d358 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.cpp @@ -0,0 +1,78 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimIntegerParameter.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiLineEditor.h" + +#include + +CAF_PDM_SOURCE_INIT( RimIntegerParameter, "IntegerParameter" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntegerParameter::RimIntegerParameter() +{ + CAF_PDM_InitField( &m_value, "Value", 0, "Value", "", "", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimIntegerParameter::~RimIntegerParameter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntegerParameter::setValue( QString value ) +{ + bool bOk = false; + m_value = value.toInt( &bOk ); + setValid( bOk ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimIntegerParameter::setValue( int value ) +{ + m_value = value; + setValid( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QVariant RimIntegerParameter::variantValue() const +{ + return QVariant( m_value() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimIntegerParameter::stringValue() const +{ + return QString::number( m_value() ); +} diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.h b/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.h new file mode 100644 index 0000000000..dd53ad7046 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimIntegerParameter.h @@ -0,0 +1,47 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include + +#include "RimGenericParameter.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimIntegerParameter : public RimGenericParameter +{ + CAF_PDM_HEADER_INIT; + +public: + RimIntegerParameter(); + ~RimIntegerParameter() override; + + void setValue( int value ); + void setValue( QString value ) override; + QVariant variantValue() const override; + QString stringValue() const override; + +private: + caf::PdmField m_value; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp new file mode 100644 index 0000000000..488a99fc21 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.cpp @@ -0,0 +1,229 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimParameterGroup.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiTableViewEditor.h" + +#include "RimDoubleParameter.h" +#include "RimGenericParameter.h" +#include "RimIntegerParameter.h" +#include "RimStringParameter.h" + +#include + +CAF_PDM_SOURCE_INIT( RimParameterGroup, "ParameterGroup" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimParameterGroup::RimParameterGroup() +{ + CAF_PDM_InitObject( "Parameter Group", ":/Bullet.png", "", "" ); + uiCapability()->setUiTreeChildrenHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_parameters, "Parameters", "Parameters", "", "", "" ); + m_parameters.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() ); + m_parameters.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::HIDDEN ); + m_parameters.uiCapability()->setCustomContextMenuEnabled( true ); + m_parameters.uiCapability()->setUiTreeChildrenHidden( true ); + + CAF_PDM_InitFieldNoDefault( &m_name, "Name", "Name", "", "", "" ); + m_name.uiCapability()->setUiHidden( true ); + m_name.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_showExpanded, "Expanded", "Expanded", "", "", "" ); + m_name.uiCapability()->setUiHidden( true ); + m_name.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimParameterGroup::~RimParameterGroup() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmFieldHandle* RimParameterGroup::userDescriptionField() +{ + return &m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::addParameter( RimGenericParameter* parameter ) +{ + m_parameters.push_back( parameter ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::addParameter( QString name, int value ) +{ + RimIntegerParameter* p = new RimIntegerParameter(); + p->setName( name ); + p->setLabel( name ); + p->setValue( value ); + + m_parameters.push_back( p ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::addParameter( QString name, QString value ) +{ + RimStringParameter* p = new RimStringParameter(); + p->setName( name ); + p->setLabel( name ); + p->setValue( value ); + + m_parameters.push_back( p ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::addParameter( QString name, double value ) +{ + RimDoubleParameter* p = new RimDoubleParameter(); + p->setName( name ); + p->setLabel( name ); + p->setValue( value ); + + m_parameters.push_back( p ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::appendParametersToList( std::list& parameterList ) +{ + for ( auto p : m_parameters() ) + { + parameterList.push_back( p ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) +{ + if ( field == &m_parameters ) + { + auto tvAttribute = dynamic_cast( attribute ); + if ( tvAttribute ) + { + tvAttribute->resizePolicy = caf::PdmUiTableViewEditorAttribute::RESIZE_TO_FILL_CONTAINER; + tvAttribute->alwaysEnforceResizePolicy = true; + tvAttribute->minimumHeight = 300; + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) +{ + auto group = uiOrdering.addNewGroup( name() ); + group->add( &m_parameters ); + + uiOrdering.skipRemainingFields( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::setName( QString name ) +{ + m_name = name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::setExpanded( bool expand ) +{ + m_showExpanded = expand; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimParameterGroup::isExpanded() const +{ + return m_showExpanded; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimParameterGroup::name() const +{ + return m_name; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimParameterGroup::parameters() const +{ + return m_parameters.childObjects(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::setParameterValue( QString name, int value ) +{ + setParameterValue( name, QString::number( value ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::setParameterValue( QString name, double value ) +{ + setParameterValue( name, QString::number( value ) ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimParameterGroup::setParameterValue( QString name, QString value ) +{ + for ( auto& p : m_parameters.childObjects() ) + { + if ( p->name() == name ) + { + p->setValue( value ); + break; + } + } +} diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.h b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.h new file mode 100644 index 0000000000..5b9dc40264 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimParameterGroup.h @@ -0,0 +1,72 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "cafPdmChildArrayField.h" +#include "cafPdmField.h" +#include "cafPdmObject.h" + +#include +#include + +class RimGenericParameter; + +//================================================================================================== +/// +/// +//================================================================================================== +class RimParameterGroup : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimParameterGroup(); + ~RimParameterGroup() override; + + void addParameter( RimGenericParameter* p ); + void addParameter( QString name, int value ); + void addParameter( QString name, QString value ); + void addParameter( QString name, double value ); + + void appendParametersToList( std::list& parameterList ); + + void setName( QString name ); + void setExpanded( bool expand ); + + void setParameterValue( QString name, int value ); + void setParameterValue( QString name, QString value ); + void setParameterValue( QString name, double value ); + + bool isExpanded() const; + QString name() const; + + std::vector parameters() const; + +private: + void defineEditorAttribute( const caf::PdmFieldHandle* field, + QString uiConfigName, + caf::PdmUiEditorAttribute* attribute ) override; + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + caf::PdmFieldHandle* userDescriptionField() override; + +private: + caf::PdmChildArrayField m_parameters; + caf::PdmField m_showExpanded; + caf::PdmField m_name; +}; diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp b/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp new file mode 100644 index 0000000000..9416fac698 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.cpp @@ -0,0 +1,68 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimStringParameter.h" + +#include "cafPdmFieldScriptingCapability.h" +#include "cafPdmObjectScriptingCapability.h" +#include "cafPdmUiCheckBoxEditor.h" +#include "cafPdmUiLineEditor.h" + +#include + +CAF_PDM_SOURCE_INIT( RimStringParameter, "StringParameter" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStringParameter::RimStringParameter() +{ + CAF_PDM_InitField( &m_value, "Value", QString(), "Value", "", "", "" ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimStringParameter::~RimStringParameter() +{ +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimStringParameter::setValue( QString value ) +{ + m_value = value; + setValid( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QVariant RimStringParameter::variantValue() const +{ + return QVariant( m_value() ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimStringParameter::stringValue() const +{ + return m_value(); +} diff --git a/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.h b/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.h new file mode 100644 index 0000000000..9929e57ca5 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/Parameters/RimStringParameter.h @@ -0,0 +1,46 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include + +#include "RimGenericParameter.h" + +//================================================================================================== +/// +/// +//================================================================================================== +class RimStringParameter : public RimGenericParameter +{ + CAF_PDM_HEADER_INIT; + +public: + RimStringParameter(); + ~RimStringParameter() override; + + void setValue( QString value ) override; + QVariant variantValue() const override; + QString stringValue() const override; + +private: + caf::PdmField m_value; +}; diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/ProcessControl/CMakeLists_files.cmake new file mode 100644 index 0000000000..c35d4e717e --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/CMakeLists_files.cmake @@ -0,0 +1,24 @@ + +set (SOURCE_GROUP_HEADER_FILES +${CMAKE_CURRENT_LIST_DIR}/RimProcess.h +${CMAKE_CURRENT_LIST_DIR}/RimProcessMonitor.h +) + +set (SOURCE_GROUP_SOURCE_FILES +${CMAKE_CURRENT_LIST_DIR}/RimProcess.cpp +${CMAKE_CURRENT_LIST_DIR}/RimProcessMonitor.cpp +) + +list(APPEND CODE_HEADER_FILES +${SOURCE_GROUP_HEADER_FILES} +) + +list(APPEND CODE_SOURCE_FILES +${SOURCE_GROUP_SOURCE_FILES} +) + +list(APPEND COMMAND_QT_MOC_HEADERS +${CMAKE_CURRENT_LIST_DIR}/RimProcessMonitor.h +) + +source_group( "ProjectDataModel\\ProcessControl" FILES ${SOURCE_GROUP_HEADER_FILES} ${SOURCE_GROUP_SOURCE_FILES} ${CMAKE_CURRENT_LIST_DIR}/CMakeLists_files.cmake ) diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp new file mode 100644 index 0000000000..df5851ce0b --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.cpp @@ -0,0 +1,210 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 - 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 "RimProcess.h" + +#include "RiaLogging.h" +#include "RimProcessMonitor.h" + +#include "cafPdmFieldCapability.h" + +#include + +CAF_PDM_SOURCE_INIT( RimProcess, "RimProcess" ); + +int RimProcess::m_nextProcessId = 1; + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimProcess::RimProcess() +{ + int defId = m_nextProcessId++; + m_monitor = new RimProcessMonitor( defId ); + + CAF_PDM_InitObject( "ResInsight Process", ":/Erase.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_command, "Command", "Command", "", "", "" ); + m_command.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitFieldNoDefault( &m_description, "Description", "Description", "", "", "" ); + m_description.uiCapability()->setUiReadOnly( true ); + + CAF_PDM_InitField( &m_id, "ID", defId, "ID", "", "", "" ); + m_id.uiCapability()->setUiReadOnly( true ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimProcess::~RimProcess() +{ + delete m_monitor; +} + +caf::PdmFieldHandle* RimProcess::userDescriptionField() +{ + return &m_description; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProcess::addParameter( QString paramStr ) +{ + m_arguments << paramStr.trimmed(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProcess::setParameters( QStringList parameterList ) +{ + m_arguments.clear(); + for ( int i = 0; i < parameterList.size(); i++ ) + { + addParameter( parameterList[i] ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProcess::setCommand( QString cmdStr ) +{ + m_command = cmdStr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimProcess::setDescription( QString desc ) +{ + m_description = desc; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimProcess::command() const +{ + return m_command; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QStringList RimProcess::parameters() const +{ + return m_arguments; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +int RimProcess::ID() const +{ + return m_id; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimProcess::execute() +{ + QProcess* proc = new QProcess(); + QString cmd = commandLine(); + + RiaLogging::info( QString( "Start process %1: %2" ).arg( m_id ).arg( cmd ) ); + + QObject::connect( proc, + SIGNAL( finished( int, QProcess::ExitStatus ) ), + m_monitor, + SLOT( finished( int, QProcess::ExitStatus ) ) ); + QObject::connect( proc, SIGNAL( readyReadStandardOutput() ), m_monitor, SLOT( readyReadStandardOutput() ) ); + QObject::connect( proc, SIGNAL( readyReadStandardError() ), m_monitor, SLOT( readyReadStandardError() ) ); + QObject::connect( proc, SIGNAL( started() ), m_monitor, SLOT( started() ) ); + + bool retval = false; + + proc->start( cmd ); + if ( proc->waitForStarted( -1 ) ) + { + while ( !proc->waitForFinished( 500 ) ) + { + QApplication::processEvents( QEventLoop::ExcludeUserInputEvents ); + } + retval = ( proc->exitCode() == 0 ); + } + else + { + RiaLogging::error( QString( "Failed to start process %1." ).arg( m_id ) ); + } + + proc->deleteLater(); + + return retval; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimProcess::needsCommandInterpreter() const +{ +#ifdef WIN32 + if ( m_command.value().isNull() ) return false; + return m_command.value().endsWith( ".cmd", Qt::CaseInsensitive ) || + m_command.value().endsWith( ".bat", Qt::CaseInsensitive ); +#endif + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimProcess::commandLine() const +{ + QString cmdline; + + if ( needsCommandInterpreter() ) + { + cmdline += "cmd.exe /c "; + } + + cmdline += handleSpaces( m_command ); + + for ( int i = 0; i < m_arguments.size(); i++ ) + { + cmdline += " "; + cmdline += handleSpaces( m_arguments[i] ); + } + + return cmdline; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QString RimProcess::handleSpaces( QString arg ) const +{ + if ( arg.contains( " " ) && !arg.startsWith( "\"" ) ) + { + return QString( "\"" + arg + "\"" ); + } + return arg; +} diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h new file mode 100644 index 0000000000..5156d9cc02 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcess.h @@ -0,0 +1,64 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "cafPdmField.h" +#include "cafPdmObject.h" + +#include +#include +#include + +class RimProcessMonitor; + +class RimProcess : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + RimProcess(); + ~RimProcess() override; + + void setDescription( QString desc ); + void setCommand( QString cmdStr ); + void addParameter( QString paramStr ); + void setParameters( QStringList parameterList ); + + QString commandLine() const; + + QString command() const; + QStringList parameters() const; + int ID() const; + + bool execute(); + +protected: + caf::PdmFieldHandle* userDescriptionField() override; + +private: + bool needsCommandInterpreter() const; + QString handleSpaces( QString argument ) const; + + caf::PdmField m_command; + QStringList m_arguments; + caf::PdmField m_description; + caf::PdmField m_id; + + static int m_nextProcessId; + RimProcessMonitor* m_monitor; +}; diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcessMonitor.cpp b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcessMonitor.cpp new file mode 100644 index 0000000000..896a1b51fe --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcessMonitor.cpp @@ -0,0 +1,113 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 "RimProcessMonitor.h" + +#include "RiaLogging.h" + +#include +#include + +RimProcessMonitor::RimProcessMonitor( int processId ) + : QObject( nullptr ) + , m_processId( processId ) +{ +} + +QString RimProcessMonitor::addPrefix( QString message ) +{ + return QString( "Process %1: %2" ).arg( m_processId ).arg( message ); +} + +void RimProcessMonitor::error( QProcess::ProcessError error ) +{ + QString errorStr; + + switch ( error ) + { + case QProcess::FailedToStart: + errorStr = "Failed to start"; + break; + case QProcess::Crashed: + errorStr = "Crashed"; + break; + case QProcess::Timedout: + errorStr = "Timed out"; + break; + case QProcess::ReadError: + errorStr = "Read error"; + break; + case QProcess::WriteError: + errorStr = "Write error"; + break; + case QProcess::UnknownError: + default: + errorStr = "Unknown"; + break; + } + + RiaLogging::error( addPrefix( errorStr ) ); +} + +void RimProcessMonitor::finished( int exitCode, QProcess::ExitStatus exitStatus ) +{ + QString finishStr; + switch ( exitStatus ) + { + case QProcess::NormalExit: + finishStr = QString( "Normal exit, code %1" ).arg( exitCode ); + break; + case QProcess::CrashExit: + default: + finishStr = QString( "Crash exit, code %1" ).arg( exitCode ); + break; + } + + RiaLogging::debug( addPrefix( finishStr ) ); +} + +void RimProcessMonitor::readyReadStandardError() +{ + QProcess* p = (QProcess*)sender(); + p->setReadChannel( QProcess::StandardError ); + while ( p->canReadLine() ) + { + QString line = p->readLine(); + line = line.trimmed(); + if ( line.size() == 0 ) continue; + RiaLogging::error( addPrefix( line ) ); + } +} + +void RimProcessMonitor::readyReadStandardOutput() +{ + QProcess* p = (QProcess*)sender(); + p->setReadChannel( QProcess::StandardOutput ); + while ( p->canReadLine() ) + { + QString line = p->readLine(); + line = line.trimmed(); + if ( line.size() == 0 ) continue; + RiaLogging::info( addPrefix( line ) ); + } +} + +void RimProcessMonitor::started() +{ + RiaLogging::debug( addPrefix( "Started" ) ); +} diff --git a/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcessMonitor.h b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcessMonitor.h new file mode 100644 index 0000000000..6f7f9b67d6 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/ProcessControl/RimProcessMonitor.h @@ -0,0 +1,42 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021 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 +#include + +class RimProcessMonitor : public QObject +{ + Q_OBJECT + +public: + explicit RimProcessMonitor( int processId ); + +signals: + +public slots: + void error( QProcess::ProcessError error ); + void finished( int exitCode, QProcess::ExitStatus exitStatus ); + void readyReadStandardError(); + void readyReadStandardOutput(); + void started(); + +private: + QString addPrefix( QString message ); + int m_processId; +}; diff --git a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp index 871f7aac01..d2e8715f5d 100644 --- a/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimContextCommandBuilder.cpp @@ -56,6 +56,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipsePropertyFilter.h" #include "RimEclipsePropertyFilterCollection.h" +#include "RimEclipseResultCase.h" #include "RimEclipseStatisticsCase.h" #include "RimEclipseView.h" #include "RimElasticProperties.h" @@ -66,6 +67,7 @@ #include "RimEnsembleFractureStatisticsCollection.h" #include "RimExtrudedCurveIntersection.h" #include "RimFaultInView.h" +#include "RimFaultInViewCollection.h" #include "RimFishbones.h" #include "RimFishbonesCollection.h" #include "RimFlowCharacteristicsPlot.h" @@ -269,6 +271,13 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicCopyReferencesToClipboardFeature"; menuBuilder << "Separator"; +#ifdef USE_ODB_API + if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder << "RicNewFaultReactAssessmentFeature"; + menuBuilder << "Separator"; + } +#endif } else if ( dynamic_cast( firstUiItem ) ) { @@ -286,6 +295,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() menuBuilder << "Separator"; menuBuilder << "RicGeoMechCopyCaseFeature"; menuBuilder << "Separator"; + menuBuilder << "RicNewFaultReactAssessmentFeature"; + menuBuilder << "Separator"; } else if ( dynamic_cast( firstUiItem ) ) { @@ -1115,6 +1126,19 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection() else if ( dynamic_cast( firstUiItem ) ) { menuBuilder << "RicExportFaultsFeature"; +#ifdef USE_ODB_API + menuBuilder.subMenuStart( "Reactivation Assessment" ); + menuBuilder << "RicRunBasicFaultReactAssessmentFeature"; + menuBuilder << "RicRunAdvFaultReactAssessmentFeature"; + menuBuilder.subMenuEnd(); + } + else if ( dynamic_cast( firstUiItem ) ) + { + menuBuilder.subMenuStart( "Reactivation Assessment" ); + menuBuilder << "RicRunBasicFaultReactAssessmentFeature"; + menuBuilder << "RicRunAdvFaultReactAssessmentFeature"; + menuBuilder.subMenuEnd(); +#endif } else if ( dynamic_cast( firstUiItem ) ) { diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.cpp b/ApplicationLibCode/ProjectDataModel/RimProject.cpp index cff1b92eb6..1f2f44ab5a 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimProject.cpp @@ -1071,6 +1071,21 @@ RimEclipseCase* RimProject::eclipseCaseFromGridFileName( const QString& gridFile return nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimEclipseCase* RimProject::eclipseCaseFromCaseId( const int caseId ) const +{ + for ( RimEclipseCase* eclCase : eclipseCases() ) + { + if ( eclCase->caseId() == caseId ) + { + return eclCase; + } + } + return nullptr; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimProject.h b/ApplicationLibCode/ProjectDataModel/RimProject.h index 9e5a522f3b..dff2e37f00 100644 --- a/ApplicationLibCode/ProjectDataModel/RimProject.h +++ b/ApplicationLibCode/ProjectDataModel/RimProject.h @@ -166,6 +166,7 @@ public: std::vector eclipseCases() const; RimEclipseCase* eclipseCaseFromGridFileName( const QString& gridFileName ) const; + RimEclipseCase* eclipseCaseFromCaseId( const int caseId ) const; std::vector simulationWellNames() const; diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp index cf4e1aa03e..0107325629 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.cpp @@ -1013,6 +1013,14 @@ bool RimRegularLegendConfig::showLegend() const return m_showLegend; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimRegularLegendConfig::setShowLegend( bool show ) +{ + m_showLegend = show; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h index c77a943a09..dc5ea86a85 100644 --- a/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h +++ b/ApplicationLibCode/ProjectDataModel/RimRegularLegendConfig.h @@ -154,6 +154,7 @@ public: const cvf::ScalarMapper* scalarMapper() const { return m_currentScalarMapper.p(); } bool showLegend() const; + void setShowLegend( bool show ); const caf::TitledOverlayFrame* titledOverlayFrame() const override; caf::TitledOverlayFrame* titledOverlayFrame() override; diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp index 9f342d8a5d..0243127dfc 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.cpp @@ -25,14 +25,18 @@ #include "RimGridCaseSurface.h" #include "RimGridView.h" #include "RimProject.h" +#include "RimRegularLegendConfig.h" #include "RimSurface.h" #include "RimSurfaceInView.h" +#include "RimSurfaceResultDefinition.h" #include "cafPdmFieldReorderCapability.h" #include "cafPdmFieldScriptingCapability.h" #include "cafPdmObjectScriptingCapability.h" +#include "QFile" + CAF_PDM_SOURCE_INIT( RimSurfaceCollection, "SurfaceCollection" ); //-------------------------------------------------------------------------------------------------- @@ -107,7 +111,7 @@ void RimSurfaceCollection::addSurface( RimSurface* surface ) //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fileNames ) +RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fileNames, bool showLegend /* = true */ ) { size_t newSurfCount = 0; size_t existingSurfCount = m_surfaces().size(); @@ -144,7 +148,7 @@ RimSurface* RimSurfaceCollection::importSurfacesFromFiles( const QStringList& fi this->updateConnectedEditors(); - updateViews( surfacesToLoad ); + updateViews( surfacesToLoad, showLegend ); if ( newSurfCount > 0 && !m_surfaces.empty() ) { @@ -265,7 +269,7 @@ void RimSurfaceCollection::loadData() //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimSurfaceCollection::updateViews( const std::vector& surfsToReload ) +void RimSurfaceCollection::updateViews( const std::vector& surfsToReload, bool showLegend /* = true */ ) { RimProject* proj = RimProject::current(); @@ -289,6 +293,7 @@ void RimSurfaceCollection::updateViews( const std::vector& surfsToR for ( auto surfInView : surfsInView ) { surfInView->clearGeometry(); + surfInView->surfaceResultDefinition()->legendConfig()->setShowLegend( showLegend ); RimGridView* gridView; surfInView->firstAncestorOrThisOfType( gridView ); @@ -351,6 +356,34 @@ void RimSurfaceCollection::removeSurface( RimSurface* surface ) m_surfaces.removeChildObject( surface ); } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimSurfaceCollection::removeMissingFileSurfaces() +{ + // get the existing surfaces + std::list missingSurfaces; + + // check if a filesurface references a file no longer present + for ( auto& surface : surfaces() ) + { + RimFileSurface* fileSurface = dynamic_cast( surface ); + if ( fileSurface == nullptr ) continue; + + QString filename = fileSurface->surfaceFilePath(); + if ( !QFile::exists( filename ) ) + { + missingSurfaces.push_back( fileSurface ); + } + } + + // remove all surfaces with a missing input file + for ( auto& surface : missingSurfaces ) + { + removeSurface( surface ); + } +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -446,3 +479,18 @@ bool RimSurfaceCollection::containsSurface() } return containsSurface; } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimSurfaceCollection::containsFileSurface( QString filename ) +{ + for ( auto& surface : surfaces() ) + { + RimFileSurface* fileSurface = dynamic_cast( surface ); + if ( fileSurface == nullptr ) continue; + if ( fileSurface->surfaceFilePath() == filename ) return true; + } + + return false; +} diff --git a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h index ea46851e4d..79ae301e9d 100644 --- a/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h +++ b/ApplicationLibCode/ProjectDataModel/Surfaces/RimSurfaceCollection.h @@ -36,7 +36,7 @@ public: void addSurface( RimSurface* surface ); void setAsTopmostFolder(); - RimSurface* importSurfacesFromFiles( const QStringList& fileNames ); + RimSurface* importSurfacesFromFiles( const QStringList& fileNames, bool showLegend = true ); RimSurface* addGridCaseSurface( RimCase* sourceCase ); RimSurface* copySurfaces( std::vector surfaces ); RimSurface* addSurfacesAtIndex( int index, std::vector surfaces ); @@ -44,15 +44,17 @@ public: void addSubCollection( RimSurfaceCollection* collection ); RimSurfaceCollection* getSubCollection( const QString name ); + bool containsFileSurface( QString filename ); bool containsSurface(); void reloadSurfaces( std::vector surfaces ); void removeSurface( RimSurface* surface ); + void removeMissingFileSurfaces(); void loadData(); void updateViews(); - void updateViews( const std::vector& surfsToReload ); + void updateViews( const std::vector& surfsToReload, bool showLegend = true ); void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray, std::vector& referringObjects ) override; diff --git a/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.cpp b/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.cpp index 5701e994f6..a949f02ba8 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.cpp @@ -21,7 +21,6 @@ #include "RigFlowDiagResults.h" #include "RigFlowDiagVisibleCellsStatCalc.h" -//#include "RimEclipseResultCase.h" #include "RimEclipseView.h" #include "cvfArray.h" diff --git a/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.h b/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.h index 2addfb7fc8..35faa96f35 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.h +++ b/ApplicationLibCode/ReservoirDataModel/RigVisibleTracerFilter.h @@ -18,6 +18,7 @@ #pragma once +#include #include class RimEclipseView;