mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-24 22:27:55 -05:00
Scripting: loadCase opens geomechanical cases and the grid's .pvd surfaces
loadCase only went through the grid case import, so .odb, .inp and .pvd files could not be opened from Python or other gRPC clients. Open them the way the GUI does and return the GeoMechCase. The GUI import also imports "<CASE>*.pvd" surfaces next to the grid file (e.g. fractures written by the simulator); loadCase now does the same, so a scripted load gives the same project as the GUI. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
08f3aa1293
commit
c6090249ad
1 file changed
+30
-1
@@ -22,6 +22,7 @@
|
||||
#include "Ensemble/RiaEnsembleImportTools.h"
|
||||
#include "KeyValueStore/RiaKeyValueStoreUtil.h"
|
||||
#include "RiaApplication.h"
|
||||
#include "RiaDefines.h"
|
||||
#include "RiaGuiApplication.h"
|
||||
#include "RiaImportEclipseCaseTools.h"
|
||||
#include "RiaLogging.h"
|
||||
@@ -30,6 +31,7 @@
|
||||
#include "RiaRegressionTestRunner.h"
|
||||
#include "Summary/RiaSummaryTools.h"
|
||||
|
||||
#include "EclipseCommands/RicImportEclipseCaseFeature.h"
|
||||
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
||||
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
||||
#include "RicImportFormationNamesFeature.h"
|
||||
@@ -49,6 +51,8 @@
|
||||
#include "RimFileSummaryCase.h"
|
||||
#include "RimGeneric3dView.h"
|
||||
#include "RimGenericViewCollection.h"
|
||||
#include "RimGeoMechCase.h"
|
||||
#include "RimGeoMechModels.h"
|
||||
#include "RimIdenticalGridCaseGroup.h"
|
||||
#include "RimMainPlotCollection.h"
|
||||
#include "RimOilField.h"
|
||||
@@ -709,7 +713,13 @@ RimProject_loadCase::RimProject_loadCase( caf::PdmObjectHandle* self )
|
||||
{
|
||||
CAF_PDM_InitObject( "Load Case", "", "", "Load a grid case from file and add it to the project" );
|
||||
|
||||
CAF_PDM_InitScriptableField( &m_path, "Path", QString(), "Path", "", "", "Path to the grid file (EGRID, GRID, GRDECL or ROFF)" );
|
||||
CAF_PDM_InitScriptableField( &m_path,
|
||||
"Path",
|
||||
QString(),
|
||||
"Path",
|
||||
"",
|
||||
"",
|
||||
"Path to the grid file (EGRID, GRID, GRDECL or ROFF) or geomechanical case (ODB, INP or PVD)" );
|
||||
CAF_PDM_InitScriptableField( &m_gridOnly, "GridOnly", false, "Grid Only", "", "", "Load the grid geometry only, without results" );
|
||||
}
|
||||
|
||||
@@ -747,9 +757,25 @@ std::expected<caf::PdmObjectHandle*, QString> RimProject_loadCase::execute()
|
||||
absolutePath = startDir.absoluteFilePath( m_path() );
|
||||
}
|
||||
|
||||
if ( RiaDefines::isGeoMechFileType( RiaDefines::obtainFileTypeFromFileName( absolutePath ) ) )
|
||||
{
|
||||
if ( !RiaApplication::instance()->openOdbCaseFromFile( absolutePath ) )
|
||||
{
|
||||
return std::unexpected( QString( "Unable to load geomechanical case from %1" ).arg( absolutePath ) );
|
||||
}
|
||||
auto geoMechCases = project->activeOilField()->geoMechModels()->cases();
|
||||
if ( geoMechCases.empty() )
|
||||
{
|
||||
return std::unexpected( QString( "Case loaded from %1 was not found in the project" ).arg( absolutePath ) );
|
||||
}
|
||||
return geoMechCases.back();
|
||||
}
|
||||
|
||||
RifReaderSettings readerSettings = m_gridOnly() ? RiaPreferencesGrid::gridOnlyReaderSettings()
|
||||
: RiaPreferencesGrid::current()->readerSettings();
|
||||
|
||||
auto viewsBefore = RicImportEclipseCaseFeature::allEclipseViews( project );
|
||||
|
||||
const bool createPlot = false;
|
||||
const bool createView = false;
|
||||
auto fileOpenMetaData =
|
||||
@@ -760,6 +786,9 @@ std::expected<caf::PdmObjectHandle*, QString> RimProject_loadCase::execute()
|
||||
return std::unexpected( QString( "Unable to load case from %1" ).arg( absolutePath ) );
|
||||
}
|
||||
|
||||
// Surfaces beside the grid (e.g. fractures), as the GUI import does
|
||||
RicImportEclipseCaseFeature::importPvdSurfacesForGridFiles( QStringList{ absolutePath }, viewsBefore );
|
||||
|
||||
const int caseId = fileOpenMetaData.createdCaseIds.front();
|
||||
for ( RimCase* rimCase : project->allGridCases() )
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user