2020-04-15 13:23:05 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2020- 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 "RimcProject.h"
|
2026-09-16 15:30:34 +02:00
|
|
|
#include "RimcViewWindow.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
|
2025-04-25 10:44:55 +02:00
|
|
|
#include "Ensemble/RiaEnsembleImportTools.h"
|
2025-05-12 13:12:31 +02:00
|
|
|
#include "KeyValueStore/RiaKeyValueStoreUtil.h"
|
2021-04-14 10:55:34 +02:00
|
|
|
#include "RiaApplication.h"
|
|
|
|
|
#include "RiaGuiApplication.h"
|
2026-09-16 17:34:39 +02:00
|
|
|
#include "RiaImportEclipseCaseTools.h"
|
2025-04-28 17:46:35 +02:00
|
|
|
#include "RiaLogging.h"
|
2026-09-16 17:33:22 +02:00
|
|
|
#include "RiaPreferencesGrid.h"
|
2026-05-06 12:00:10 +02:00
|
|
|
#include "RiaQStringFormatter.h"
|
2026-09-16 15:30:34 +02:00
|
|
|
#include "RiaRegressionTestRunner.h"
|
2025-08-27 14:22:11 +02:00
|
|
|
#include "RiaResultNames.h"
|
2021-04-14 10:55:34 +02:00
|
|
|
|
2026-09-16 15:30:34 +02:00
|
|
|
#include "ExportCommands/RicSnapshotAllPlotsToFileFeature.h"
|
|
|
|
|
#include "ExportCommands/RicSnapshotAllViewsToFileFeature.h"
|
2026-09-16 17:42:27 +02:00
|
|
|
#include "RicImportFormationNamesFeature.h"
|
2026-09-16 17:33:22 +02:00
|
|
|
#include "RicImportGeneralDataFeature.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
#include "RicImportSummaryCasesFeature.h"
|
2026-08-24 09:43:45 +02:00
|
|
|
#include "ViewLink/RicLinkVisibleViewsFeature.h"
|
|
|
|
|
#include "ViewLink/RicUnLinkViewFeature.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
|
2026-09-16 17:33:22 +02:00
|
|
|
#include "RifReaderSettings.h"
|
|
|
|
|
|
2026-09-16 17:42:27 +02:00
|
|
|
#include "Formations/RimFormationNames.h"
|
2026-08-24 09:43:45 +02:00
|
|
|
#include "Rim3dView.h"
|
2026-09-16 17:52:36 +02:00
|
|
|
#include "RimCalcScript.h"
|
2026-09-16 17:33:22 +02:00
|
|
|
#include "RimCase.h"
|
2025-04-28 17:46:35 +02:00
|
|
|
#include "RimCornerPointCase.h"
|
|
|
|
|
#include "RimEclipseCaseCollection.h"
|
|
|
|
|
#include "RimEclipseCellColors.h"
|
|
|
|
|
#include "RimEclipseView.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
#include "RimFileSummaryCase.h"
|
2026-09-26 09:56:35 +02:00
|
|
|
#include "RimGeneric3dView.h"
|
|
|
|
|
#include "RimGenericViewCollection.h"
|
2026-09-16 17:34:39 +02:00
|
|
|
#include "RimIdenticalGridCaseGroup.h"
|
2025-04-28 17:46:35 +02:00
|
|
|
#include "RimMainPlotCollection.h"
|
2020-08-26 12:31:23 +02:00
|
|
|
#include "RimOilField.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
#include "RimProject.h"
|
|
|
|
|
#include "RimSummaryCase.h"
|
2026-08-12 12:22:40 +02:00
|
|
|
#include "RimSummaryCaseMainCollection.h"
|
2020-08-26 12:31:23 +02:00
|
|
|
#include "RimSurfaceCollection.h"
|
2025-08-07 16:01:21 +02:00
|
|
|
#include "RimTools.h"
|
2025-08-13 12:50:46 +02:00
|
|
|
#include "RimValveTemplateCollection.h"
|
2026-09-26 09:56:35 +02:00
|
|
|
#include "RimViewNameConfig.h"
|
2025-08-07 16:01:21 +02:00
|
|
|
#include "RimWellPathCollection.h"
|
2025-04-28 17:46:35 +02:00
|
|
|
|
|
|
|
|
#include "RiuMainWindow.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
#include "RiuPlotMainWindow.h"
|
|
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-04-15 13:23:05 +02:00
|
|
|
|
2020-09-07 13:56:16 +02:00
|
|
|
#include <QDir>
|
|
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
2020-04-15 13:23:05 +02:00
|
|
|
#include <memory>
|
2026-08-24 09:43:45 +02:00
|
|
|
#include <set>
|
2020-04-15 13:23:05 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_importSummaryCase, "importSummaryCase" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_importSummaryCase::RimProject_importSummaryCase( caf::PdmObjectHandle* self )
|
2025-06-16 11:05:00 +02:00
|
|
|
: PdmObjectCreationMethod( self )
|
|
|
|
|
|
2020-04-15 13:23:05 +02:00
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Import Summary Case", "", "", "Import Summary Case" );
|
2025-06-16 11:05:00 +02:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_fileName, "FileName", "" );
|
2020-04-15 13:23:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-05-07 11:34:59 +02:00
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_importSummaryCase::execute()
|
2020-04-15 13:23:05 +02:00
|
|
|
{
|
2020-09-07 13:56:16 +02:00
|
|
|
QString absolutePath = m_fileName;
|
|
|
|
|
QFileInfo projectPathInfo( absolutePath );
|
|
|
|
|
if ( !projectPathInfo.exists() )
|
|
|
|
|
{
|
|
|
|
|
QDir startDir( RiaApplication::instance()->startDir() );
|
|
|
|
|
absolutePath = startDir.absoluteFilePath( m_fileName );
|
|
|
|
|
}
|
|
|
|
|
|
2023-04-20 10:16:43 +02:00
|
|
|
QStringList summaryFileNames{ absolutePath };
|
2020-04-15 13:23:05 +02:00
|
|
|
|
2025-04-25 10:44:55 +02:00
|
|
|
RiaEnsembleImportTools::CreateConfig createConfig{ .fileType = RiaDefines::FileType::SMSPEC, .ensembleOrGroup = false, .allowDialogs = false };
|
2025-05-12 12:30:15 +02:00
|
|
|
auto newCases = RiaEnsembleImportTools::createSummaryCasesFromFiles( summaryFileNames, createConfig );
|
|
|
|
|
if ( !newCases.empty() )
|
2020-04-15 13:23:05 +02:00
|
|
|
{
|
|
|
|
|
RicImportSummaryCasesFeature::addSummaryCases( newCases );
|
|
|
|
|
|
|
|
|
|
if ( RiaGuiApplication::isRunning() )
|
|
|
|
|
{
|
|
|
|
|
RiuPlotMainWindow* mainPlotWindow = RiaGuiApplication::instance()->mainPlotWindow();
|
|
|
|
|
if ( mainPlotWindow && !newCases.empty() )
|
|
|
|
|
{
|
2022-04-07 16:24:27 +02:00
|
|
|
mainPlotWindow->updateMultiPlotToolBar();
|
2020-04-15 13:23:05 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( newCases.size() == 1 )
|
|
|
|
|
{
|
|
|
|
|
return newCases[0];
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-06-16 11:05:00 +02:00
|
|
|
QString RimProject_importSummaryCase::classKeywordReturnedType() const
|
2021-04-16 10:52:30 +02:00
|
|
|
{
|
2025-06-16 11:05:00 +02:00
|
|
|
return RimFileSummaryCase::classKeywordStatic();
|
2021-04-16 10:52:30 +02:00
|
|
|
}
|
|
|
|
|
|
2020-04-15 13:23:05 +02:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_summaryCase, "summaryCase" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_summaryCase::RimProject_summaryCase( caf::PdmObjectHandle* self )
|
2025-06-16 11:05:00 +02:00
|
|
|
: PdmObjectMethod( self, PdmObjectMethod::NullPointerType::NULL_IS_VALID, PdmObjectMethod::ResultType::PERSISTENT_TRUE )
|
|
|
|
|
|
2020-04-15 13:23:05 +02:00
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Find Summary Case", "", "", "Find Summary Case" );
|
2025-06-16 11:05:00 +02:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseId, "CaseId", -1, "" );
|
2020-04-15 13:23:05 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-05-07 11:34:59 +02:00
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_summaryCase::execute()
|
2020-04-15 13:23:05 +02:00
|
|
|
{
|
2020-05-12 09:50:38 +02:00
|
|
|
auto proj = RimProject::current();
|
2020-04-15 13:23:05 +02:00
|
|
|
auto sumCases = proj->allSummaryCases();
|
|
|
|
|
|
|
|
|
|
for ( auto s : sumCases )
|
|
|
|
|
{
|
|
|
|
|
if ( s->caseId() == m_caseId ) return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-06-16 11:05:00 +02:00
|
|
|
QString RimProject_summaryCase::classKeywordReturnedType() const
|
2020-04-15 13:23:05 +02:00
|
|
|
{
|
2025-06-16 11:05:00 +02:00
|
|
|
return RimFileSummaryCase::classKeywordStatic();
|
2020-04-15 13:23:05 +02:00
|
|
|
}
|
2020-08-26 12:31:23 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_surfaceFolder, "surfaceFolder" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_surfaceFolder::RimProject_surfaceFolder( caf::PdmObjectHandle* self )
|
2025-06-16 11:05:00 +02:00
|
|
|
: PdmObjectCreationMethod( self )
|
2020-08-26 12:31:23 +02:00
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Get Surface Folder", "", "", "Get Surface Folder" );
|
2025-06-16 11:05:00 +02:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_folderName, "FolderName", "" );
|
2020-08-26 12:31:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-05-07 11:34:59 +02:00
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_surfaceFolder::execute()
|
2020-08-26 12:31:23 +02:00
|
|
|
{
|
|
|
|
|
auto proj = RimProject::current();
|
|
|
|
|
RimSurfaceCollection* surfcoll = proj->activeOilField()->surfaceCollection();
|
|
|
|
|
|
2025-06-16 11:05:00 +02:00
|
|
|
// Blank folder name parameter should return the topmost folder
|
2020-08-26 12:31:23 +02:00
|
|
|
if ( m_folderName().isEmpty() ) return surfcoll;
|
|
|
|
|
|
|
|
|
|
for ( auto s : surfcoll->subCollections() )
|
|
|
|
|
{
|
|
|
|
|
if ( s->collectionName() == m_folderName() ) return s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-06-16 11:05:00 +02:00
|
|
|
QString RimProject_surfaceFolder::classKeywordReturnedType() const
|
2020-08-26 12:31:23 +02:00
|
|
|
{
|
2025-06-16 11:05:00 +02:00
|
|
|
return RimSurfaceCollection::classKeywordStatic();
|
2020-08-26 12:31:23 +02:00
|
|
|
}
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2026-09-26 09:56:35 +02:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_createGenericView, "createGenericView" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_createGenericView::RimProject_createGenericView( caf::PdmObjectHandle* self )
|
|
|
|
|
: PdmObjectCreationMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Create Generic View", "", "", "Create a case-less 3D view" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_createGenericView::execute()
|
|
|
|
|
{
|
|
|
|
|
auto proj = RimProject::current();
|
|
|
|
|
if ( !proj ) return std::unexpected( QString( "No project is available." ) );
|
|
|
|
|
|
|
|
|
|
auto oilField = proj->activeOilField();
|
|
|
|
|
if ( !oilField || !oilField->genericViewCollection() ) return std::unexpected( QString( "No generic view collection is available." ) );
|
|
|
|
|
|
|
|
|
|
auto view = oilField->genericViewCollection()->addGenericView();
|
|
|
|
|
if ( !view ) return std::unexpected( QString( "Could not create generic view." ) );
|
|
|
|
|
|
|
|
|
|
if ( !m_name().isEmpty() ) view->nameConfig()->setCustomName( m_name() );
|
|
|
|
|
|
|
|
|
|
oilField->genericViewCollection()->updateAllRequiredEditors();
|
|
|
|
|
view->scheduleCreateDisplayModelAndRedraw();
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProject_createGenericView::classKeywordReturnedType() const
|
|
|
|
|
{
|
|
|
|
|
return RimGeneric3dView::classKeywordStatic();
|
|
|
|
|
}
|
|
|
|
|
|
2025-04-28 17:46:35 +02:00
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_createGridFromKeyValues, "createGridFromKeyValues" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_createGridFromKeyValues::RimProject_createGridFromKeyValues( caf::PdmObjectHandle* self )
|
2025-06-16 11:05:00 +02:00
|
|
|
: PdmObjectCreationMethod( self )
|
2025-04-28 17:46:35 +02:00
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Create grid from key values", "", "", "Create Grid From Key Values" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_name, "Name", "" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_nx, "Nx", "" );
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_ny, "Ny", "" );
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_nz, "Nz", "" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_coordKey, "CoordKey", "" );
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_zcornKey, "ZcornKey", "" );
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_actnumKey, "ActnumKey", "" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-05-07 11:34:59 +02:00
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_createGridFromKeyValues::execute()
|
2025-04-28 17:46:35 +02:00
|
|
|
{
|
|
|
|
|
RiaLogging::info( "Creating grid from key values" );
|
|
|
|
|
|
|
|
|
|
QString name = m_name();
|
2025-05-07 16:09:56 +02:00
|
|
|
if ( name.isEmpty() ) return std::unexpected( "Empty name not allowed" );
|
2025-04-28 17:46:35 +02:00
|
|
|
|
|
|
|
|
int nx = m_nx();
|
|
|
|
|
int ny = m_ny();
|
|
|
|
|
int nz = m_nz();
|
2025-05-07 16:09:56 +02:00
|
|
|
if ( nx <= 0 || ny <= 0 || nz <= 0 ) return std::unexpected( "Invalid grid size. nx, ny and nz must be positive." );
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2026-05-06 12:00:10 +02:00
|
|
|
RiaLogging::info( std::format( "Grid dimensions: [{} {} {}]", nx, ny, nz ) );
|
|
|
|
|
RiaLogging::info( std::format( "Coord: {}", m_coordKey() ) );
|
|
|
|
|
RiaLogging::info( std::format( "Zcorn: {}", m_zcornKey() ) );
|
|
|
|
|
RiaLogging::info( std::format( "Actnum: {}", m_actnumKey() ) );
|
2025-04-28 17:46:35 +02:00
|
|
|
|
|
|
|
|
auto keyValueStore = RiaApplication::instance()->keyValueStore();
|
|
|
|
|
|
2025-05-12 13:12:31 +02:00
|
|
|
std::vector<float> coord = RiaKeyValueStoreUtil::convertToFloatVector( keyValueStore->get( m_coordKey().toStdString() ) );
|
|
|
|
|
std::vector<float> zcorn = RiaKeyValueStoreUtil::convertToFloatVector( keyValueStore->get( m_zcornKey().toStdString() ) );
|
|
|
|
|
std::vector<float> actnum = RiaKeyValueStoreUtil::convertToFloatVector( keyValueStore->get( m_actnumKey().toStdString() ) );
|
2025-04-28 17:46:35 +02:00
|
|
|
if ( coord.empty() || zcorn.empty() || actnum.empty() )
|
|
|
|
|
{
|
2025-05-07 16:09:56 +02:00
|
|
|
return std::unexpected( "Found unexcepted empty coord, zcorn or actnum array." );
|
2025-04-28 17:46:35 +02:00
|
|
|
}
|
|
|
|
|
|
2025-05-07 16:09:56 +02:00
|
|
|
RimProject* project = RimProject::current();
|
|
|
|
|
if ( !project ) return std::unexpected( "Invalid project." );
|
|
|
|
|
|
|
|
|
|
RimEclipseCaseCollection* analysisModels = project->activeOilField() ? project->activeOilField()->analysisModels() : nullptr;
|
|
|
|
|
if ( !analysisModels ) return std::unexpected( "Missing analysis models." );
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2025-05-07 16:09:56 +02:00
|
|
|
auto result = RimCornerPointCase::createFromCoordinatesArray( nx, ny, nz, coord, zcorn, actnum );
|
|
|
|
|
if ( !result.has_value() ) return result;
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2025-05-07 16:09:56 +02:00
|
|
|
RimCornerPointCase* grid = result.value();
|
|
|
|
|
grid->setCustomCaseName( name );
|
|
|
|
|
project->assignCaseIdToCase( grid );
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2025-05-07 16:09:56 +02:00
|
|
|
analysisModels->cases.push_back( grid );
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2025-05-07 16:09:56 +02:00
|
|
|
RimMainPlotCollection::current()->ensureDefaultFlowPlotsAreCreated();
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2025-05-20 18:07:51 +02:00
|
|
|
if ( RiaGuiApplication::isRunning() )
|
2025-05-07 16:09:56 +02:00
|
|
|
{
|
2025-05-20 18:07:51 +02:00
|
|
|
if ( RimEclipseView* riv = grid->createAndAddReservoirView() )
|
2025-04-28 17:46:35 +02:00
|
|
|
{
|
2025-05-20 18:07:51 +02:00
|
|
|
riv->loadDataAndUpdate();
|
2025-04-28 17:46:35 +02:00
|
|
|
|
2025-05-20 18:07:51 +02:00
|
|
|
if ( !riv->cellResult()->hasResult() )
|
|
|
|
|
{
|
|
|
|
|
riv->cellResult()->setResultVariable( RiaResultNames::undefinedResultName() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
analysisModels->updateConnectedEditors();
|
2025-04-28 17:46:35 +02:00
|
|
|
|
|
|
|
|
if ( RiuMainWindow::instance() ) RiuMainWindow::instance()->selectAsCurrentItem( riv->cellResult() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
keyValueStore->remove( m_coordKey().toStdString() );
|
|
|
|
|
keyValueStore->remove( m_zcornKey().toStdString() );
|
|
|
|
|
keyValueStore->remove( m_actnumKey().toStdString() );
|
|
|
|
|
|
|
|
|
|
return grid;
|
|
|
|
|
}
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2025-06-16 11:05:00 +02:00
|
|
|
QString RimProject_createGridFromKeyValues::classKeywordReturnedType() const
|
2025-04-28 17:46:35 +02:00
|
|
|
{
|
2025-06-16 11:05:00 +02:00
|
|
|
return RimCornerPointCase::classKeywordStatic();
|
2025-04-28 17:46:35 +02:00
|
|
|
}
|
2025-08-07 16:01:21 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_wellPathCollection, "wellPathCollection" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_wellPathCollection::RimProject_wellPathCollection( caf::PdmObjectHandle* self )
|
|
|
|
|
: PdmObjectMethod( self, PdmObjectMethod::NullPointerType::NULL_IS_INVALID, PdmObjectMethod::ResultType::PERSISTENT_TRUE )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Get Well Path Collection", "", "", "Get Well Path Collection" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_wellPathCollection::execute()
|
|
|
|
|
{
|
2026-03-17 20:18:20 +01:00
|
|
|
auto wellPathCollection = RimWellPathCollection::instance();
|
2025-08-07 16:01:21 +02:00
|
|
|
if ( !wellPathCollection )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( "No well path collection found." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return wellPathCollection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProject_wellPathCollection::classKeywordReturnedType() const
|
|
|
|
|
{
|
|
|
|
|
return RimWellPathCollection::classKeywordStatic();
|
|
|
|
|
}
|
2025-08-13 12:50:46 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_valveTemplates, "valveTemplates" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_valveTemplates::RimProject_valveTemplates( caf::PdmObjectHandle* self )
|
|
|
|
|
: PdmObjectMethod( self, PdmObjectMethod::NullPointerType::NULL_IS_INVALID, PdmObjectMethod::ResultType::PERSISTENT_TRUE )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Get Valve Template Collection", "", "", "Get Valve Template Collection" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_valveTemplates::execute()
|
|
|
|
|
{
|
|
|
|
|
auto valveTemplateCollection = RimTools::valveTemplateCollection();
|
|
|
|
|
if ( !valveTemplateCollection )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( "No valve template collection found." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return valveTemplateCollection;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProject_valveTemplates::classKeywordReturnedType() const
|
|
|
|
|
{
|
|
|
|
|
return RimValveTemplateCollection::classKeywordStatic();
|
|
|
|
|
}
|
2026-08-24 09:43:45 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_tileViews, "tileViews" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_tileViews::RimProject_tileViews( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmVoidObjectMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Tile Views", "", "", "Tile all visible 3D view windows" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_tileViews::execute()
|
|
|
|
|
{
|
|
|
|
|
if ( !RiaGuiApplication::isRunning() )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( "Tiling views requires ResInsight to run with the graphical user interface." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RiuMainWindow* mainWindow = RiuMainWindow::instance();
|
|
|
|
|
if ( !mainWindow ) return std::unexpected( "No 3D main window is available." );
|
|
|
|
|
|
|
|
|
|
mainWindow->tileViewWindows();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_linkViews, "linkViews" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_linkViews::RimProject_linkViews( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmVoidObjectMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Link Views", "", "", "Link the specified 3D views" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_views, "Views", "Views to link" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_linkViews::execute()
|
|
|
|
|
{
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
std::set<Rim3dView*> seenViews;
|
|
|
|
|
std::vector<Rim3dView*> uniqueViews;
|
|
|
|
|
|
|
|
|
|
// Use the set only for duplicate detection. The vector preserves input order because the first
|
|
|
|
|
// unlinked view becomes the master view when a new view linker is created.
|
|
|
|
|
for ( Rim3dView* view : m_views.ptrReferencedObjectsByType() )
|
|
|
|
|
{
|
|
|
|
|
auto insertResult = seenViews.insert( view );
|
|
|
|
|
if ( insertResult.second ) uniqueViews.push_back( view );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( uniqueViews.size() < 2 ) return std::unexpected( "At least two unique views are required." );
|
|
|
|
|
|
|
|
|
|
std::vector<Rim3dView*> linkableViews;
|
|
|
|
|
for ( Rim3dView* view : uniqueViews )
|
|
|
|
|
{
|
|
|
|
|
if ( !view->assosiatedViewLinker() ) linkableViews.push_back( view );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RicLinkVisibleViewsFeature::linkViews( linkableViews );
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_unlinkViews, "unlinkViews" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_unlinkViews::RimProject_unlinkViews( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmVoidObjectMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Unlink Views", "", "", "Unlink the specified 3D views" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_views, "Views", "Views to unlink" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_unlinkViews::execute()
|
|
|
|
|
{
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
std::set<Rim3dView*> seenViews;
|
|
|
|
|
std::vector<Rim3dView*> uniqueViews;
|
|
|
|
|
for ( Rim3dView* view : m_views.ptrReferencedObjectsByType() )
|
|
|
|
|
{
|
|
|
|
|
auto insertResult = seenViews.insert( view );
|
|
|
|
|
if ( insertResult.second ) uniqueViews.push_back( view );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( uniqueViews.empty() ) return std::unexpected( "At least one view is required." );
|
|
|
|
|
|
|
|
|
|
RicUnLinkViewFeature::unlinkViews( uniqueViews );
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2026-09-16 15:30:34 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_exportSnapshots, "exportSnapshots" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_exportSnapshots::RimProject_exportSnapshots( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmVoidObjectMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Export Snapshots", "", "", "Export snapshots of all 3D views and/or plots in the project" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_contentType,
|
|
|
|
|
"ContentType",
|
|
|
|
|
RiaDefines::SnapshotContentType::ALL,
|
|
|
|
|
"Content Type",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"Export 3D views, plots or both" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_exportFolder,
|
|
|
|
|
"ExportFolder",
|
|
|
|
|
QString(),
|
|
|
|
|
"Export Folder",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"Folder to export to. Defaults to the 'snapshots' folder next to the project file." );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_prefix, "Prefix", QString(), "Prefix", "", "", "Prefix for the generated file names" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_width, "Width", -1, "Width", "", "", "Image width in pixels. Use -1 for the current size." );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_height, "Height", -1, "Height", "", "", "Image height in pixels. Use -1 for the current size." );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_plotFileFormat,
|
|
|
|
|
"PlotFileFormat",
|
|
|
|
|
RiaDefines::SnapshotFileFormat::PNG,
|
|
|
|
|
"Plot File Format",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"Output file format for plots. 3D views are always exported as PNG." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_exportSnapshots::setContentType( RiaDefines::SnapshotContentType contentType )
|
|
|
|
|
{
|
|
|
|
|
m_contentType = contentType;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_exportSnapshots::setExportFolder( const QString& exportFolder )
|
|
|
|
|
{
|
|
|
|
|
m_exportFolder = exportFolder;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_exportSnapshots::setPrefix( const QString& prefix )
|
|
|
|
|
{
|
|
|
|
|
m_prefix = prefix;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_exportSnapshots::setWidth( int width )
|
|
|
|
|
{
|
|
|
|
|
m_width = width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_exportSnapshots::setHeight( int height )
|
|
|
|
|
{
|
|
|
|
|
m_height = height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_exportSnapshots::setPlotFileFormat( RiaDefines::SnapshotFileFormat fileFormat )
|
|
|
|
|
{
|
|
|
|
|
m_plotFileFormat = fileFormat;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_exportSnapshots::execute()
|
|
|
|
|
{
|
|
|
|
|
if ( !RiaGuiApplication::isRunning() ) return std::unexpected( "Snapshots cannot be exported without a GUI." );
|
|
|
|
|
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
const QString exportFolder = RimViewWindow_exportSnapshot::resolveExportFolder( m_exportFolder() );
|
|
|
|
|
|
|
|
|
|
int width = m_width();
|
|
|
|
|
int height = m_height();
|
|
|
|
|
if ( RiaRegressionTestRunner::instance()->isRunningRegressionTests() )
|
|
|
|
|
{
|
|
|
|
|
QSize defaultSize = RiaRegressionTestRunner::regressionDefaultImageSize();
|
|
|
|
|
width = defaultSize.width();
|
|
|
|
|
height = defaultSize.height();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const bool exportViews = m_contentType() != RiaDefines::SnapshotContentType::PLOTS;
|
|
|
|
|
const bool exportPlots = m_contentType() != RiaDefines::SnapshotContentType::VIEWS;
|
|
|
|
|
|
|
|
|
|
if ( exportViews )
|
|
|
|
|
{
|
|
|
|
|
RicSnapshotAllViewsToFileFeature::exportSnapshotOfViewsIntoFolder( exportFolder, width, height, m_prefix() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( exportPlots )
|
|
|
|
|
{
|
|
|
|
|
const bool activateWidget = !RiaRegressionTestRunner::instance()->isRunningRegressionTests();
|
|
|
|
|
const QString fileSuffix = m_plotFileFormat() == RiaDefines::SnapshotFileFormat::PDF ? ".pdf" : ".png";
|
|
|
|
|
|
|
|
|
|
RicSnapshotAllPlotsToFileFeature::exportSnapshotOfPlotsIntoFolder( exportFolder, width, height, activateWidget, m_prefix(), -1, fileSuffix );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|
2026-09-16 17:33:22 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_loadCase, "loadCase" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_loadCase::RimProject_loadCase( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmObjectCreationMethod( 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_gridOnly, "GridOnly", false, "Grid Only", "", "", "Load the grid geometry only, without results" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_loadCase::setPath( const QString& path )
|
|
|
|
|
{
|
|
|
|
|
m_path = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_loadCase::setGridOnly( bool gridOnly )
|
|
|
|
|
{
|
|
|
|
|
m_gridOnly = gridOnly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_loadCase::execute()
|
|
|
|
|
{
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
if ( m_path().isEmpty() ) return std::unexpected( "No path specified." );
|
|
|
|
|
|
|
|
|
|
QString absolutePath = m_path();
|
|
|
|
|
QFileInfo pathInfo( absolutePath );
|
|
|
|
|
if ( !pathInfo.exists() )
|
|
|
|
|
{
|
|
|
|
|
QDir startDir( RiaApplication::instance()->startDir() );
|
|
|
|
|
absolutePath = startDir.absoluteFilePath( m_path() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RifReaderSettings readerSettings = m_gridOnly() ? RiaPreferencesGrid::gridOnlyReaderSettings()
|
|
|
|
|
: RiaPreferencesGrid::current()->readerSettings();
|
|
|
|
|
|
|
|
|
|
const bool createPlot = false;
|
|
|
|
|
const bool createView = false;
|
|
|
|
|
auto fileOpenMetaData =
|
|
|
|
|
RicImportGeneralDataFeature::openEclipseFilesFromFileNames( QStringList{ absolutePath }, createPlot, createView, readerSettings );
|
|
|
|
|
|
|
|
|
|
if ( fileOpenMetaData.createdCaseIds.empty() )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( QString( "Unable to load case from %1" ).arg( absolutePath ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const int caseId = fileOpenMetaData.createdCaseIds.front();
|
|
|
|
|
for ( RimCase* rimCase : project->allGridCases() )
|
|
|
|
|
{
|
|
|
|
|
if ( rimCase && rimCase->caseId() == caseId ) return rimCase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return std::unexpected( QString( "Case loaded from %1 was not found in the project" ).arg( absolutePath ) );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProject_loadCase::classKeywordReturnedType() const
|
|
|
|
|
{
|
|
|
|
|
return RimCase::classKeywordStatic();
|
|
|
|
|
}
|
2026-09-16 17:34:39 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_createGridCaseGroup, "createGridCaseGroup" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_createGridCaseGroup::RimProject_createGridCaseGroup( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmObjectCreationMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Create Grid Case Group", "", "", "Create a grid case group from a list of grid files with identical grids" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_casePaths, "CasePaths", std::vector<QString>(), "Case Paths", "", "", "Paths to the grid files" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_createGridCaseGroup::setCasePaths( const std::vector<QString>& casePaths )
|
|
|
|
|
{
|
|
|
|
|
m_casePaths = casePaths;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_createGridCaseGroup::execute()
|
|
|
|
|
{
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
if ( m_casePaths().empty() ) return std::unexpected( "No case paths specified." );
|
|
|
|
|
|
|
|
|
|
QStringList casePaths;
|
|
|
|
|
for ( QString casePath : m_casePaths() )
|
|
|
|
|
{
|
|
|
|
|
QFileInfo casePathInfo( casePath );
|
|
|
|
|
if ( !casePathInfo.exists() )
|
|
|
|
|
{
|
|
|
|
|
QDir startDir( RiaApplication::instance()->startDir() );
|
|
|
|
|
casePath = startDir.absoluteFilePath( casePath );
|
|
|
|
|
}
|
|
|
|
|
casePaths.push_back( casePath );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RimIdenticalGridCaseGroup* caseGroup = nullptr;
|
|
|
|
|
if ( !RiaImportEclipseCaseTools::addEclipseCases( casePaths, &caseGroup ) || !caseGroup )
|
|
|
|
|
{
|
|
|
|
|
return std::unexpected( "Could not load grid case group" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return caseGroup;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProject_createGridCaseGroup::classKeywordReturnedType() const
|
|
|
|
|
{
|
|
|
|
|
return RimIdenticalGridCaseGroup::classKeywordStatic();
|
|
|
|
|
}
|
2026-09-16 17:42:27 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_importFormationNames, "importFormationNames" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_importFormationNames::RimProject_importFormationNames( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmObjectCreationMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Import Formation Names", "", "", "Import formation names from files and return the formation names object" );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_formationFiles,
|
|
|
|
|
"FormationFiles",
|
|
|
|
|
std::vector<QString>(),
|
|
|
|
|
"Formation Files",
|
|
|
|
|
"",
|
|
|
|
|
"",
|
|
|
|
|
"Formation files to import (.lyr, .fmu, ...)" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_importFormationNames::setFormationFiles( const std::vector<QString>& formationFiles )
|
|
|
|
|
{
|
|
|
|
|
m_formationFiles = formationFiles;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_importFormationNames::execute()
|
|
|
|
|
{
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
if ( m_formationFiles().empty() ) return std::unexpected( "No formation files provided" );
|
|
|
|
|
|
|
|
|
|
QStringList formationFileList;
|
|
|
|
|
QStringList missingFiles;
|
|
|
|
|
for ( const QString& formationFile : m_formationFiles() )
|
|
|
|
|
{
|
|
|
|
|
if ( QFileInfo::exists( formationFile ) )
|
|
|
|
|
{
|
|
|
|
|
formationFileList.push_back( formationFile );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
missingFiles.push_back( formationFile );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !missingFiles.empty() ) return std::unexpected( QString( "%1 does not exist" ).arg( missingFiles.join( ", " ) ) );
|
|
|
|
|
|
|
|
|
|
RimFormationNames* formationNames = RicImportFormationNamesFeature::importFormationFiles( formationFileList );
|
|
|
|
|
if ( !formationNames ) return std::unexpected( "Could not import formation names" );
|
|
|
|
|
|
|
|
|
|
return formationNames;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
QString RimProject_importFormationNames::classKeywordReturnedType() const
|
|
|
|
|
{
|
|
|
|
|
return RimFormationNames::classKeywordStatic();
|
|
|
|
|
}
|
2026-09-16 17:52:36 +02:00
|
|
|
|
|
|
|
|
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_runOctaveScript, "runOctaveScript" );
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RimProject_runOctaveScript::RimProject_runOctaveScript( caf::PdmObjectHandle* self )
|
|
|
|
|
: caf::PdmVoidObjectMethod( self )
|
|
|
|
|
{
|
|
|
|
|
CAF_PDM_InitObject( "Run Octave Script", "", "", "Run an Octave script once per case. Empty case list means all Eclipse cases." );
|
|
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_path, "Path", QString(), "Path", "", "", "Path to the Octave script" );
|
|
|
|
|
CAF_PDM_InitScriptableFieldNoDefault( &m_cases, "Cases", "Cases", "", "", "Cases to run the script for. Empty means all Eclipse cases." );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_runOctaveScript::setPath( const QString& path )
|
|
|
|
|
{
|
|
|
|
|
m_path = path;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
void RimProject_runOctaveScript::setCases( const std::vector<RimCase*>& cases )
|
|
|
|
|
{
|
|
|
|
|
m_cases.setValue( cases );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
///
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
std::expected<caf::PdmObjectHandle*, QString> RimProject_runOctaveScript::execute()
|
|
|
|
|
{
|
|
|
|
|
auto* project = self<RimProject>();
|
|
|
|
|
if ( !project ) return std::unexpected( "No project is available." );
|
|
|
|
|
|
|
|
|
|
if ( m_path().isEmpty() ) return std::unexpected( "No script path specified." );
|
|
|
|
|
if ( !QFileInfo::exists( m_path() ) ) return std::unexpected( QString( "Script %1 does not exist" ).arg( m_path() ) );
|
|
|
|
|
|
|
|
|
|
std::vector<int> caseIds;
|
|
|
|
|
for ( RimCase* rimCase : m_cases.ptrReferencedObjectsByType() )
|
|
|
|
|
{
|
|
|
|
|
if ( rimCase ) caseIds.push_back( rimCase->caseId() );
|
|
|
|
|
}
|
|
|
|
|
if ( caseIds.empty() )
|
|
|
|
|
{
|
|
|
|
|
for ( RimEclipseCase* eclipseCase : project->eclipseCases() )
|
|
|
|
|
{
|
|
|
|
|
caseIds.push_back( eclipseCase->caseId() );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
RiaApplication* app = RiaApplication::instance();
|
|
|
|
|
QString octavePath = app->octavePath();
|
|
|
|
|
QStringList processArguments = RimCalcScript::createCommandLineArguments( m_path() );
|
|
|
|
|
|
|
|
|
|
bool ok = false;
|
|
|
|
|
if ( caseIds.empty() )
|
|
|
|
|
{
|
|
|
|
|
ok = app->launchProcess( octavePath, processArguments, app->octaveProcessEnvironment() );
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ok = app->launchProcessForMultipleCases( octavePath, processArguments, caseIds, app->octaveProcessEnvironment() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !ok ) return std::unexpected( QString( "Could not execute script %1" ).arg( m_path() ) );
|
|
|
|
|
|
|
|
|
|
app->waitForProcess();
|
|
|
|
|
return nullptr;
|
|
|
|
|
}
|