Remove obsolete fault reactivation assessment feature

This commit is contained in:
Jon Jenssen
2022-11-16 17:33:52 +01:00
committed by jonjenssen
parent 6a859e0860
commit 10d5246644
31 changed files with 0 additions and 3189 deletions

View File

@@ -8,12 +8,6 @@ set(SOURCE_GROUP_HEADER_FILES
${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}/RicRunBasicFaultReactAssessment3dFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunAdvFaultReactAssessment3dFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactAssessmentFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewWellIntegrityAnalysisFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunWellIntegrityAnalysisFeature.h
)
@@ -28,12 +22,6 @@ set(SOURCE_GROUP_SOURCE_FILES
${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}/RicRunAdvFaultReactAssessment3dFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessmentFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunBasicFaultReactAssessment3dFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactAssessmentFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewWellIntegrityAnalysisFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunWellIntegrityAnalysisFeature.cpp
)

View File

@@ -1,308 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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",
"Fault Reactivation Assessment has not been properly set up.\nPlease go to ResInsight "
"preferences and set/check the GeoMechanical settings." );
return;
}
// ask user for preprocessing settings
if ( !showSettingsGUI( frapSettings ) ) return;
if ( frapSettings.cleanBaseDirectory() )
{
auto reply = QMessageBox::question( nullptr,
QString( "Clean output directory" ),
QString( "Are you sure you want to delete all files and subfolders in the "
"selected output directory?\n%1 " )
.arg( frapSettings.outputBaseDirectory() ),
QMessageBox::Yes | QMessageBox::No,
QMessageBox::No );
if ( reply == QMessageBox::No )
{
frapSettings.setCleanBaseDirectory( false );
}
}
// 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
bool createView = true;
int caseId = RiaImportEclipseCaseTools::openEclipseInputCaseFromFileNames( gridList, createView );
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 );
if ( settings.geoMechSelected() )
propertyDialog.resize( QSize( 520, 520 ) );
else
propertyDialog.resize( QSize( 520, 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()
{
if ( !RiaPreferencesGeoMech::current()->keepTemporaryFiles() )
{
for ( auto& filename : m_parameterFilesToCleanUp )
{
if ( QFile::exists( filename ) ) QFile::remove( filename );
}
}
m_parameterFilesToCleanUp.clear();
}

View File

@@ -1,50 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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:
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

@@ -1,46 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicRunAdvFaultReactAssessment3dFeature.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicRunAdvFaultReactAssessment3dFeature, "RicRunAdvFaultReactAssessment3dFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunAdvFaultReactAssessment3dFeature::onActionTriggered( bool isChecked )
{
QVariant userData = this->userData();
if ( userData.isNull() || userData.type() != QVariant::String ) return;
QString faultName = userData.toString();
int faultID = faultIDFromName( faultName );
if ( faultID >= 0 ) runAdvancedProcessing( faultID );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunAdvFaultReactAssessment3dFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) );
actionToSetup->setText( "Run Advanced Processing" );
}

View File

@@ -1,33 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicRunBasicFaultReactAssessment3dFeature.h"
//==================================================================================================
///
//==================================================================================================
class RicRunAdvFaultReactAssessment3dFeature : public RicRunBasicFaultReactAssessment3dFeature
{
CAF_CMD_HEADER_INIT;
protected:
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -1,58 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimFaultInViewCollection.h"
#include "RimFaultRASettings.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicRunAdvFaultReactAssessmentFeature, "RicRunAdvFaultReactAssessmentFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunAdvFaultReactAssessmentFeature::isCommandEnabled()
{
RimFaultInViewCollection* faultColl = faultCollection();
if ( faultColl )
{
return faultColl->faultRAAdvancedEnabled();
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunAdvFaultReactAssessmentFeature::onActionTriggered( bool isChecked )
{
runAdvancedProcessing( selectedFaultID() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunAdvFaultReactAssessmentFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) );
actionToSetup->setText( "Run Advanced Processing" );
}

View File

@@ -1,34 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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

@@ -1,75 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RicRunBasicFaultReactAssessment3dFeature.h"
#include "RimEclipseView.h"
#include "RimFaultInViewCollection.h"
#include "RimFaultRASettings.h"
#include "RimGridView.h"
#include "RiaApplication.h"
#include <QAction>
#include <QVariant>
CAF_CMD_SOURCE_INIT( RicRunBasicFaultReactAssessment3dFeature, "RicRunBasicFaultReactAssessment3dFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunBasicFaultReactAssessment3dFeature::isCommandEnabled()
{
return true;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunBasicFaultReactAssessment3dFeature::onActionTriggered( bool isChecked )
{
QVariant userData = this->userData();
if ( userData.isNull() || userData.type() != QVariant::String ) return;
QString faultName = userData.toString();
int faultID = faultIDFromName( faultName );
if ( faultID >= 0 ) runBasicProcessing( faultID );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunBasicFaultReactAssessment3dFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) );
actionToSetup->setText( "Run Basic Processing" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimFaultInViewCollection* RicRunBasicFaultReactAssessment3dFeature::faultCollection()
{
RimGridView* viewOrComparisonView = RiaApplication::instance()->activeMainOrComparisonGridView();
RimEclipseView* theView = dynamic_cast<RimEclipseView*>( viewOrComparisonView );
CAF_ASSERT( theView );
return theView->faultCollection();
}

View File

@@ -1,36 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 RicRunBasicFaultReactAssessment3dFeature : public RicRunFaultReactAssessmentFeature
{
CAF_CMD_HEADER_INIT;
protected:
RimFaultInViewCollection* faultCollection() override;
bool isCommandEnabled() override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};

View File

@@ -1,57 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RimFaultInViewCollection.h"
#include "RimFaultRASettings.h"
#include <QAction>
CAF_CMD_SOURCE_INIT( RicRunBasicFaultReactAssessmentFeature, "RicRunBasicFaultReactAssessmentFeature" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunBasicFaultReactAssessmentFeature::isCommandEnabled()
{
RimFaultInViewCollection* faultColl = faultCollection();
if ( faultColl )
{
return ( faultColl->faultRAEnabled() );
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunBasicFaultReactAssessmentFeature::onActionTriggered( bool isChecked )
{
runBasicProcessing( selectedFaultID() );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunBasicFaultReactAssessmentFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) );
actionToSetup->setText( "Run Basic Processing" );
}

View File

@@ -1,34 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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

@@ -1,391 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RifFaultRAXmlWriter.h"
#include "RimEclipseInputCase.h"
#include "RimEclipseResultCase.h"
#include "RimEclipseView.h"
#include "RimFaultInView.h"
#include "RimFaultInViewCollection.h"
#include "RimFaultRAPostprocSettings.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::faultIDFromName( QString faultName ) const
{
int retval = -1;
QString lookFor = RiaResultNames::faultReactAssessmentPrefix();
QString name = faultName;
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;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RicRunFaultReactAssessmentFeature::selectedFaultID()
{
int retval = -1;
RimFaultInView* selObj = dynamic_cast<RimFaultInView*>( caf::SelectionManager::instance()->selectedItem() );
if ( selObj )
{
return faultIDFromName( selObj->name() );
}
return retval;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunFaultReactAssessmentFeature::runPostProcessing( int faultID, RimFaultRASettings* settings )
{
RimFaultRAPostprocSettings postproc_settings;
postproc_settings.initFromSettings( settings );
QString outErrorText;
if ( !RifFaultRAJSonWriter::writeToPostprocFile( faultID, &postproc_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 = postproc_settings.postprocCommandParameters( faultID );
RimProcess process;
process.setCommand( command );
process.setParameters( parameters );
addParameterFileForCleanUp( postproc_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()
{
if ( !RiaPreferencesGeoMech::current()->keepTemporaryFiles() )
{
for ( auto& filename : m_parameterFilesToCleanUp )
{
removeFile( filename );
}
}
m_parameterFilesToCleanUp.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunFaultReactAssessmentFeature::removeFile( QString filename )
{
if ( QFile::exists( filename ) ) QFile::remove( filename );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
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();
bool showLegendInView = false;
// ask the collection to reload the existing files
surfColl->reloadSurfaces( surfColl->surfaces(), showLegendInView );
// 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
surfColl->importSurfacesFromFiles( newFiles, showLegendInView );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunFaultReactAssessmentFeature::runBasicProcessing( int faultID )
{
RimFaultInViewCollection* coll = faultCollection();
if ( coll == nullptr ) return;
RimFaultRASettings* fraSettings = coll->faultRASettings();
if ( fraSettings == nullptr ) return;
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 );
// remove any existing database file
removeFile( fraSettings->basicMacrisDatabase() );
// 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 RicRunFaultReactAssessmentFeature::runAdvancedProcessing( int faultID )
{
RimFaultInViewCollection* coll = faultCollection();
if ( coll == nullptr ) return;
RimFaultRASettings* fraSettings = coll->faultRASettings();
if ( fraSettings == nullptr ) return;
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 );
// remove any existing database file
removeFile( fraSettings->advancedMacrisDatabase() );
// 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();
}

View File

@@ -1,57 +0,0 @@
/////////////////////////////////////////////////////////////////////////////////
//
// 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();
virtual RimFaultInViewCollection* faultCollection();
int selectedFaultID();
int faultIDFromName( QString faultname ) const;
RimSurfaceCollection* surfaceCollection();
bool runPostProcessing( int faultID, RimFaultRASettings* settings );
void reloadSurfaces( RimFaultRASettings* settings );
void addParameterFileForCleanUp( QString filename );
void cleanUpParameterFiles();
void removeFile( QString filename );
void runBasicProcessing( int faultID );
void runAdvancedProcessing( int faultID );
private:
std::list<QString> m_parameterFilesToCleanUp;
};