Fault reactivation assessment #7321 (#7690)

Fault Reactivation Assessment implementation (ref issue #7321)
This commit is contained in:
jonjenssen 2021-05-18 14:28:54 +02:00 committed by GitHub
parent 33c9b47e9e
commit 4a4db5a3f2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
64 changed files with 4623 additions and 16 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 223 B

View File

@ -14,6 +14,7 @@
<file>AppLogo48x48.png</file>
<file>Axes16x16.png</file>
<file>BottomAxis16x16.png</file>
<file>Bullet.png</file>
<file>CascadeWindows.svg</file>
<file>Case.svg</file>
<file>Cases16x16.png</file>
@ -50,6 +51,7 @@
<file>EnsembleCurveSets16x16.png</file>
<file>Erase.png</file>
<file>ExportCompletionsSymbol16x16.png</file>
<file>fault_react_24x24.png</file>
<file>FishBoneGroup16x16.png</file>
<file>FishBoneGroupFromFile16x16.png</file>
<file>FishBoneLateralFromFile16x16.png</file>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

@ -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

View File

@ -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();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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<QString> m_multiLateralWellPattern;
// GeoMech things
caf::PdmChildField<RiaPreferencesGeoMech*> m_geoMechPreferences;
// Summary data
caf::PdmChildField<RiaPreferencesSummary*> m_summaryPreferences;

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RiaPreferencesGeoMech.h"
#include "RiaApplication.h"
#include "RiaPreferences.h"
#include "cafPdmUiFilePathEditor.h"
#include <QFile>
#include <QStringList>
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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<QString> m_geomechFRAPreprocCommand;
caf::PdmField<QString> m_geomechFRAPostprocCommand;
caf::PdmField<QString> m_geomechFRAMacrisCommand;
caf::PdmField<QString> m_geomechFRADefaultBasicXML;
caf::PdmField<QString> m_geomechFRADefaultAdvXML;
};

View File

@ -281,6 +281,14 @@ QString RiaResultNames::mobilePoreVolumeName()
return "MOBPORV";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RiaResultNames::faultReactAssessmentPrefix()
{
return "FAULT_";
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -60,6 +60,8 @@ QString riCellVolumeResultName();
QString riOilVolumeResultName();
QString mobilePoreVolumeName();
QString faultReactAssessmentPrefix();
QString completionTypeResultName();
// Well path derived results

View File

@ -243,7 +243,7 @@ bool RiaImportEclipseCaseTools::openEclipseCaseShowTimeStepFilter( const QString
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( const QStringList& fileNames,
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();
}
//--------------------------------------------------------------------------------------------------

View File

@ -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 );

View File

@ -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

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QAction>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
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<RimEclipseInputCase*>( 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<RimGeoMechCase*> geomechCases = caf::selectedObjectsByTypeStrict<RimGeoMechCase*>();
std::vector<RimEclipseResultCase*> eclipseCases = caf::selectedObjectsByTypeStrict<RimEclipseResultCase*>();
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<RimEclipseView*> 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();
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<QString> m_parameterFilesToCleanUp;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QAction>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
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" );
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QAction>
#include <QDebug>
#include <QDir>
#include <QMessageBox>
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" );
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QAction>
#include <QDebug>
#include <QDir>
#include <QDirIterator>
#include <QMessageBox>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicRunFaultReactAssessmentFeature::RicRunFaultReactAssessmentFeature()
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFaultInViewCollection* RicRunFaultReactAssessmentFeature::faultCollection()
{
RimFaultInViewCollection* faultColl =
dynamic_cast<RimFaultInViewCollection*>( caf::SelectionManager::instance()->selectedItem() );
if ( faultColl ) return faultColl;
RimFaultInView* selObj = dynamic_cast<RimFaultInView*>( 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<RimFaultInView*>( 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 );
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafCmdFeature.h"
class RimFaultInViewCollection;
class RimFaultRASettings;
class RimSurfaceCollection;
#include <QString>
//==================================================================================================
///
//==================================================================================================
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<QString> m_parameterFilesToCleanUp;
};

View File

@ -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;

View File

@ -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

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifFaultRAJsonWriter.h"
#include "RimFaultRAPreprocSettings.h"
#include "RimFaultRASettings.h"
#include <QFile>
#include <QTextStream>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
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(){};
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifFaultRAXmlWriter.h"
#include "RimFaultRASettings.h"
#include "RimGenericParameter.h"
#include <QFile>
#include <QXmlStreamReader>
RifFaultRAXmlWriter::RifFaultRAXmlWriter( RimFaultRASettings* settings )
: m_settings( settings )
{
}
RifFaultRAXmlWriter::~RifFaultRAXmlWriter()
{
}
bool RifFaultRAXmlWriter::writeCalculateFile( QString filename, int faultID, QString& outErrorText )
{
std::list<RimGenericParameter*> paramlist = m_settings->basicParameters( faultID );
return writeParametersToXML( filename, paramlist, outErrorText );
}
bool RifFaultRAXmlWriter::writeCalibrateFile( QString filename, int faultID, QString& outErrorText )
{
std::list<RimGenericParameter*> paramlist = m_settings->advancedParameters( faultID );
return writeParametersToXML( filename, paramlist, outErrorText );
}
bool RifFaultRAXmlWriter::writeParametersToXML( QString filename, std::list<RimGenericParameter*>& 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 << "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>" << endl;
stream << "<project type_id=\"0\">" << endl;
for ( auto& p : params )
{
QString tmpStr = QString( "<%1>%2</%1>" ).arg( p->name(), p->stringValue() );
stream << tmpStr << endl;
}
stream << "</project>" << endl;
bResult = true;
}
else
{
outErrorText += "Could not open file.";
}
if ( bResult ) outErrorText = "";
return bResult;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <list>
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<RimGenericParameter*>& params, QString& outErrorText );
RimFaultRASettings* m_settings;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RifParameterXmlReader.h"
#include "RimDoubleParameter.h"
#include "RimGenericParameter.h"
#include "RimIntegerParameter.h"
#include "RimStringParameter.h"
#include "RimParameterGroup.h"
#include <QFile>
#include <QXmlStreamReader>
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<QString> 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<RimParameterGroup*>& RifParameterXmlReader::parameterGroups()
{
return m_parameters;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QString>
#include <list>
class RimParameterGroup;
class RifParameterXmlReader
{
public:
RifParameterXmlReader( QString filename );
~RifParameterXmlReader();
bool parseFile( QString& outErrorText );
std::list<RimParameterGroup*>& parameterGroups();
private:
std::list<RimParameterGroup*> m_parameters;
QString m_filename;
};

View File

@ -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

View File

@ -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<caf::PdmPointer<RimFaultInView>> 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;
}

View File

@ -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<bool> showFaultFaces;
caf::PdmField<bool> 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;
void defineUiTreeOrdering( caf::PdmUiTreeOrdering& uiTreeOrdering, QString uiConfigName = "" ) override;
RimEclipseView* parentView() const;
private:
caf::PdmField<bool> m_showFaultsOutsideFilters;
caf::PdmChildField<RimFaultRASettings*> m_faultRASettings;
caf::PdmField<bool> m_enableFaultRA;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<int> steps )
{
m_steps.clear();
m_steps.insert( m_steps.begin(), steps.begin(), steps.end() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::list<int>& 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";
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <list>
#include <QString>
class RimFaultRAPostprocSettings
{
public:
RimFaultRAPostprocSettings();
~RimFaultRAPostprocSettings();
void setBaseDirectory( QString baseDir );
void setStepsToLoad( std::list<int> steps );
std::list<int>& stepsToLoad();
QString postprocParameterFilename() const;
QString databaseDirectory() const;
QString macrisCalcCalibPath() const;
QString macrisCalcPath() const;
protected:
QString m_baseDir;
std::list<int> m_steps;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <QDir>
#include <QFileInfo>
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<caf::PdmOptionItemInfo>
RimFaultRAPreprocSettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> 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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
RimCase* startCase() const;
caf::PdmField<int> m_startTimestepEclipse;
caf::PdmField<int> m_endTimestepEclipse;
caf::PdmField<int> m_startTimestepGeoMech;
caf::PdmField<int> m_endTimestepGeoMech;
caf::PdmPtrField<RimEclipseResultCase*> m_eclipseCase;
caf::PdmField<bool> m_smoothEclipseData;
caf::PdmPtrField<RimGeoMechCase*> m_geomechCase;
caf::PdmField<QString> m_baseDir;
caf::PdmField<bool> m_cleanBaseDir;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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<caf::PdmOptionItemInfo> RimFaultRASettings::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly )
{
QList<caf::PdmOptionItemInfo> 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<RimGenericParameter*> RimFaultRASettings::basicParameters( int faultID )
{
m_basicParametersRI->setParameterValue( "eclipse_input_grid", eclipseCaseFilename() );
m_basicParametersRI->setParameterValue( "faultid", faultID );
std::list<RimGenericParameter*> 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<RimGenericParameter*> 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<RimGenericParameter*> 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";
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include "cafPdmPtrField.h"
#include <list>
#include <string>
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<RimGenericParameter*> basicParameters( int faultID );
std::list<RimGenericParameter*> 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<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions,
bool* useOptionsOnly ) override;
private:
void setupResInsightParameters();
private:
caf::PdmPtrField<RimEclipseInputCase*> m_eclipseFRAGeneratedCase;
caf::PdmPtrField<RimEclipseCase*> m_eclipseCase;
caf::PdmPtrField<RimGeoMechCase*> m_geomechCase;
caf::PdmField<QString> m_baseDir;
caf::PdmField<int> m_startTimestepEclipse;
caf::PdmField<int> m_endTimestepEclipse;
caf::PdmField<int> m_startTimestepGeoMech;
caf::PdmField<int> m_endTimestepGeoMech;
caf::PdmChildArrayField<RimParameterGroup*> m_basicParameters;
caf::PdmChildArrayField<RimParameterGroup*> m_advancedParameters;
caf::PdmPtrField<RimParameterGroup*> m_basicParametersRI;
caf::PdmPtrField<RimParameterGroup*> m_advancedParametersRI;
};

View File

@ -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 )

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimDoubleParameter.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include <cmath>
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() );
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
#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<double> m_value;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimGenericParameter.h"
#include "RiuGuiTheme.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include <cmath>
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();
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
//==================================================================================================
///
///
//==================================================================================================
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<QString> m_name;
caf::PdmField<QString> m_label;
caf::PdmField<QString> m_description;
caf::PdmField<bool> m_advanced;
caf::PdmField<bool> m_valid;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimIntegerParameter.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include <cmath>
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() );
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
#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<int> m_value;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// 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 <cmath>
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<RimGenericParameter*>& 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<caf::PdmUiTableViewEditorAttribute*>( 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<RimGenericParameter*> 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;
}
}
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmChildArrayField.h"
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
#include <vector>
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<RimGenericParameter*>& 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<RimGenericParameter*> 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<RimGenericParameter*> m_parameters;
caf::PdmField<bool> m_showExpanded;
caf::PdmField<QString> m_name;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimStringParameter.h"
#include "cafPdmFieldScriptingCapability.h"
#include "cafPdmObjectScriptingCapability.h"
#include "cafPdmUiCheckBoxEditor.h"
#include "cafPdmUiLineEditor.h"
#include <cmath>
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();
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QString>
#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<QString> m_value;
};

View File

@ -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 )

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimProcess.h"
#include "RiaLogging.h"
#include "RimProcessMonitor.h"
#include "cafPdmFieldCapability.h"
#include <QProcess>
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;
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObject.h"
#include <QProcess>
#include <QString>
#include <QStringList>
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<QString> m_command;
QStringList m_arguments;
caf::PdmField<QString> m_description;
caf::PdmField<int> m_id;
static int m_nextProcessId;
RimProcessMonitor* m_monitor;
};

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#include "RimProcessMonitor.h"
#include "RiaLogging.h"
#include <QProcess>
#include <QtCore/QtCore>
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" ) );
}

View File

@ -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 <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <QObject>
#include <QProcess>
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;
};

View File

@ -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<RimEclipseResultCase*>( firstUiItem ) )
{
menuBuilder << "RicNewFaultReactAssessmentFeature";
menuBuilder << "Separator";
}
#endif
}
else if ( dynamic_cast<RimGridInfoCollection*>( firstUiItem ) )
{
@ -286,6 +295,8 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
menuBuilder << "Separator";
menuBuilder << "RicGeoMechCopyCaseFeature";
menuBuilder << "Separator";
menuBuilder << "RicNewFaultReactAssessmentFeature";
menuBuilder << "Separator";
}
else if ( dynamic_cast<RimIdenticalGridCaseGroup*>( firstUiItem ) )
{
@ -1115,6 +1126,19 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
else if ( dynamic_cast<RimFaultInView*>( firstUiItem ) )
{
menuBuilder << "RicExportFaultsFeature";
#ifdef USE_ODB_API
menuBuilder.subMenuStart( "Reactivation Assessment" );
menuBuilder << "RicRunBasicFaultReactAssessmentFeature";
menuBuilder << "RicRunAdvFaultReactAssessmentFeature";
menuBuilder.subMenuEnd();
}
else if ( dynamic_cast<RimFaultInViewCollection*>( firstUiItem ) )
{
menuBuilder.subMenuStart( "Reactivation Assessment" );
menuBuilder << "RicRunBasicFaultReactAssessmentFeature";
menuBuilder << "RicRunAdvFaultReactAssessmentFeature";
menuBuilder.subMenuEnd();
#endif
}
else if ( dynamic_cast<RimSimWellInView*>( firstUiItem ) )
{

View File

@ -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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -166,6 +166,7 @@ public:
std::vector<RimEclipseCase*> eclipseCases() const;
RimEclipseCase* eclipseCaseFromGridFileName( const QString& gridFileName ) const;
RimEclipseCase* eclipseCaseFromCaseId( const int caseId ) const;
std::vector<QString> simulationWellNames() const;

View File

@ -1013,6 +1013,14 @@ bool RimRegularLegendConfig::showLegend() const
return m_showLegend;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimRegularLegendConfig::setShowLegend( bool show )
{
m_showLegend = show;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -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;

View File

@ -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<RimSurface*>& surfsToReload )
void RimSurfaceCollection::updateViews( const std::vector<RimSurface*>& surfsToReload, bool showLegend /* = true */ )
{
RimProject* proj = RimProject::current();
@ -289,6 +293,7 @@ void RimSurfaceCollection::updateViews( const std::vector<RimSurface*>& 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<RimFileSurface*> missingSurfaces;
// check if a filesurface references a file no longer present
for ( auto& surface : surfaces() )
{
RimFileSurface* fileSurface = dynamic_cast<RimFileSurface*>( 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<RimFileSurface*>( surface );
if ( fileSurface == nullptr ) continue;
if ( fileSurface->surfaceFilePath() == filename ) return true;
}
return false;
}

View File

@ -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<RimSurface*> surfaces );
RimSurface* addSurfacesAtIndex( int index, std::vector<RimSurface*> 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<RimSurface*> surfaces );
void removeSurface( RimSurface* surface );
void removeMissingFileSurfaces();
void loadData();
void updateViews();
void updateViews( const std::vector<RimSurface*>& surfsToReload );
void updateViews( const std::vector<RimSurface*>& surfsToReload, bool showLegend = true );
void onChildDeleted( caf::PdmChildArrayFieldHandle* childArray,
std::vector<caf::PdmObjectHandle*>& referringObjects ) override;

View File

@ -21,7 +21,6 @@
#include "RigFlowDiagResults.h"
#include "RigFlowDiagVisibleCellsStatCalc.h"
//#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "cvfArray.h"

View File

@ -18,6 +18,7 @@
#pragma once
#include <cstddef>
#include <set>
class RimEclipseView;