Skip to content

Commit

Permalink
Fault Reactivation Modeling updates (#10602)
Browse files Browse the repository at this point in the history
* Add timestep selection
* Add import geomech model to context menu
* Add command for running fault reactivation 
* Change order of nodes for exported elements
* Add command to quickly show model in 3D view
  • Loading branch information
jonjenssen authored Sep 14, 2023
1 parent e8cbbf5 commit bd7f34f
Show file tree
Hide file tree
Showing 15 changed files with 536 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewWellIntegrityAnalysisFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunWellIntegrityAnalysisFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicNewFaultReactModelingFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactModelingFeature.h
${CMAKE_CURRENT_LIST_DIR}/RicShowFaultReactModelFeature.h
)

set(SOURCE_GROUP_SOURCE_FILES
Expand All @@ -26,6 +28,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RicNewWellIntegrityAnalysisFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunWellIntegrityAnalysisFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicNewFaultReactModelingFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicRunFaultReactModelingFeature.cpp
${CMAKE_CURRENT_LIST_DIR}/RicShowFaultReactModelFeature.cpp
)

list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void RicNewFaultReactModelingFeature::onActionTriggered( bool isChecked )
auto model = eclView->faultReactivationModelCollection()->addNewModel( rimFault, target1, target2, baseDir );
if ( model != nullptr )
{
model->updateTimeSteps();
view->updateAllRequiredEditors();
Riu3DMainWindowTools::selectAsCurrentItem( model );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RicRunFaultReactModelingFeature.h"

#include "RiaApplication.h"
#include "RiaPreferencesGeoMech.h"

#include "RifFaultReactivationModelExporter.h"

#include "RimFaultReactivationModel.h"
#include "RimProcess.h"
#include "RimProject.h"

#include "Riu3DMainWindowTools.h"
#include "RiuFileDialogTools.h"

#include "cafProgressInfo.h"
#include "cafSelectionManagerTools.h"

#include <QAction>
#include <QMessageBox>

CAF_CMD_SOURCE_INIT( RicRunFaultReactModelingFeature, "RicRunFaultReactModelingFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunFaultReactModelingFeature::isCommandEnabled() const
{
return RiaPreferencesGeoMech::current()->validateFRMSettings();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked )
{
RimFaultReactivationModel* model = dynamic_cast<RimFaultReactivationModel*>( caf::SelectionManager::instance()->selectedItem() );
if ( model == nullptr ) return;

const QString frmTitle( "Fault Reactivation Modeling" );

caf::ProgressInfo runProgress( 3, frmTitle + " running , please wait..." );

runProgress.setProgressDescription( "Writing input files." );

if ( model->fault() == nullptr )
{
QMessageBox::critical( nullptr, frmTitle, "A fault has not selected. Please check your model settings." );
return;
}

if ( !model->extractModelData() )
{
QMessageBox::critical( nullptr, frmTitle, "Unable to get necessary data from the input model." );
return;
}

QString exportFile = model->inputFilename();
auto [result, errText] = RifFaultReactivationModelExporter::exportToFile( exportFile.toStdString(), *model->model() );

if ( !result )
{
QString outErrorText =
QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errText ) );
QMessageBox::critical( nullptr, frmTitle, outErrorText );
return;
}

if ( RiaPreferencesGeoMech::current()->waitBeforeRun() )
{
runProgress.setProgressDescription( "Waiting for input file modifications." );

QString infoText = "Input parameter files can now be found in the working folder:";
infoText += " \"" + model->baseDir() + "\"\n";
infoText += "\nClick OK to start the Abaqus modeling or Cancel to stop.";

auto reply = QMessageBox::information( nullptr, frmTitle, infoText, QMessageBox::Ok | QMessageBox::Cancel );

if ( reply != QMessageBox::Ok ) return;
}

runProgress.incrementProgress();
runProgress.setProgressDescription( "Running Abaqus modeling." );

QString command = RiaPreferencesGeoMech::current()->geomechFRMCommand();
QStringList parameters = model->commandParameters();

RimProcess process;
process.setCommand( command );
process.setParameters( parameters );

if ( !process.execute() )
{
QMessageBox::critical( nullptr, frmTitle, "Failed to run modeling. Check log window for additional information." );
return;
}

runProgress.incrementProgress();
runProgress.setProgressDescription( "Loading modeling results." );

RiaApplication* app = RiaApplication::instance();
if ( !app->openOdbCaseFromFile( model->outputOdbFilename() ) )
{
QMessageBox::critical( nullptr,
frmTitle,
"Failed to load modeling results from file \"" + model->outputOdbFilename() +
"\". Check log window for additional information." );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicRunFaultReactModelingFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) );
actionToSetup->setText( "Run..." );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "cafCmdFeature.h"

//==================================================================================================
///
//==================================================================================================
class RicRunFaultReactModelingFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#include "RicShowFaultReactModelFeature.h"

#include "RiaApplication.h"
#include "RiaPreferencesGeoMech.h"

#include "RifFaultReactivationModelExporter.h"

#include "RimFaultReactivationModel.h"
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimProject.h"

#include "Riu3DMainWindowTools.h"

#include "cafSelectionManagerTools.h"

#include <QAction>
#include <QMessageBox>

CAF_CMD_SOURCE_INIT( RicShowFaultReactModelFeature, "RicShowFaultReactModelFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicShowFaultReactModelFeature::isCommandEnabled() const
{
return RiaPreferencesGeoMech::current()->validateFRMSettings();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowFaultReactModelFeature::onActionTriggered( bool isChecked )
{
RimFaultReactivationModel* model = dynamic_cast<RimFaultReactivationModel*>( caf::SelectionManager::instance()->selectedItem() );
if ( model == nullptr ) return;

const QString frmTitle( "Fault Reactivation Modeling" );
const QString exportFile = model->inputFilename();

auto [result, errText] = RifFaultReactivationModelExporter::exportToFile( exportFile.toStdString(), *model->model() );
if ( !result )
{
QString outErrorText =
QString( "Failed to export INP model to file %1.\n\n%2" ).arg( exportFile ).arg( QString::fromStdString( errText ) );
QMessageBox::critical( nullptr, frmTitle, outErrorText );
return;
}

for ( auto gCase : RimProject::current()->geoMechCases() )
{
if ( exportFile == gCase->gridFileName() )
{
gCase->reloadDataAndUpdate();
auto& views = gCase->geoMechViews();
if ( views.size() > 0 )
{
Riu3DMainWindowTools::selectAsCurrentItem( views[0] );
}
else
{
Riu3DMainWindowTools::selectAsCurrentItem( gCase );
}
return;
}
}

RiaApplication* app = RiaApplication::instance();
if ( !app->openOdbCaseFromFile( exportFile ) )
{
QMessageBox::critical( nullptr,
frmTitle,
"Failed to load INP model from file \"" + exportFile + "\". Check log window for additional information." );
}
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RicShowFaultReactModelFeature::setupActionLook( QAction* actionToSetup )
{
actionToSetup->setIcon( QIcon( ":/fault_react_24x24.png" ) );
actionToSetup->setText( "Show Model in 3D View..." );
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023 Equinor ASA
//
// ResInsight is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
// FITNESS FOR A PARTICULAR PURPOSE.
//
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
// for more details.
//
/////////////////////////////////////////////////////////////////////////////////

#pragma once

#include "cafCmdFeature.h"

//==================================================================================================
///
//==================================================================================================
class RicShowFaultReactModelFeature : public caf::CmdFeature
{
CAF_CMD_HEADER_INIT;

protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
Loading

0 comments on commit bd7f34f

Please sign in to comment.