2017-07-27 10:28:41 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-07-27 10:28:41 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2017-07-27 10:28:41 +02:00
|
|
|
// 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.
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-07-27 10:28:41 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicfExportWellPathCompletions.h"
|
|
|
|
|
|
|
|
|
|
#include "RicfCommandFileExecutor.h"
|
2026-09-16 15:54:55 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2017-07-27 10:28:41 +02:00
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-07-27 14:26:59 +02:00
|
|
|
#include "RiaLogging.h"
|
2017-07-27 10:28:41 +02:00
|
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "RimOilField.h"
|
|
|
|
|
#include "RimProject.h"
|
2017-07-27 10:28:41 +02:00
|
|
|
#include "RimWellPath.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "RimWellPathCollection.h"
|
2026-09-16 15:54:55 +02:00
|
|
|
#include "RimcEclipseCase.h"
|
2017-07-27 10:28:41 +02:00
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2023-02-10 15:11:03 +01:00
|
|
|
#include <QFileInfo>
|
|
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfExportWellPathCompletions, "exportWellPathCompletions" );
|
2017-07-27 10:28:41 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-07-27 10:28:41 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfExportWellPathCompletions::RicfExportWellPathCompletions()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_timeStep, "timeStep", -1, "Time Step Index" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names" );
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2022-01-07 08:31:52 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split" );
|
2023-02-26 10:48:40 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_compdatExport, "compdatExport", RicExportCompletionDataSettingsUi::CompdatExportType(), "Compdat Export" );
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_includeMsw, "includeMsw", true, "Export Multi Segment Well Model" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_useLateralNTG, "useNtgHorizontally", false, "Use NTG Horizontally" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_includePerforations, "includePerforations", true, "Include Perforations" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_includeFishbones, "includeFishbones", true, "Include Fishbones" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_includeFractures, "includeFractures", true, "Include Fractures" );
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2023-02-26 10:48:40 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_excludeMainBoreForFishbones, "excludeMainBoreForFishbones", false, "Exclude Main Bore for Fishbones" );
|
2020-03-10 14:11:22 +01:00
|
|
|
|
2022-01-07 08:31:52 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_performTransScaling, "performTransScaling", false, "Perform Transmissibility Scaling" );
|
2023-02-26 10:48:40 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_transScalingTimeStep, "transScalingTimeStep", 0, "Transmissibility Scaling Pressure Time Step" );
|
2025-01-10 18:25:46 +01:00
|
|
|
CAF_PDM_InitScriptableFieldWithScriptKeyword( &m_transScalingInitialWBHP,
|
|
|
|
|
"transScalingWBHPFromSummary",
|
|
|
|
|
"transScalingWbhpFromSummary",
|
|
|
|
|
RicExportCompletionDataSettingsUi::TransScalingWBHPSource(),
|
|
|
|
|
"Transmissibility Scaling WBHP from summary" );
|
|
|
|
|
CAF_PDM_InitScriptableFieldWithScriptKeyword( &m_transScalingWBHP,
|
|
|
|
|
"transScalingWBHP",
|
|
|
|
|
"transScalingWbhp",
|
|
|
|
|
200.0,
|
|
|
|
|
"Transmissibility Scaling Constant WBHP Value" );
|
2022-01-07 08:31:52 +01:00
|
|
|
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_exportDataSourceAsComments, "exportComments", true, "Export Data Source as Comments" );
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_exportWelspec, "exportWelspec", true, "Export WELSPEC keyword" );
|
2023-02-10 15:11:03 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_customFileNameIncludingPath, "customFileName", QString(), "Custom Filename" );
|
2017-07-27 10:28:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2017-07-27 10:28:41 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfExportWellPathCompletions::execute()
|
2017-07-27 10:28:41 +02:00
|
|
|
{
|
2026-09-16 15:54:55 +02:00
|
|
|
const QString commandName = classKeyword();
|
2018-11-07 15:42:45 +01:00
|
|
|
|
2026-09-16 15:54:55 +02:00
|
|
|
auto rimCase = RicfForwarding::findCase( m_caseId() );
|
|
|
|
|
if ( !rimCase ) return RicfForwarding::errorResponse( rimCase.error(), commandName );
|
2019-09-06 10:40:57 +02:00
|
|
|
|
2026-09-16 15:54:55 +02:00
|
|
|
auto* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase.value() );
|
|
|
|
|
if ( !eclipseCase )
|
2018-04-13 12:13:27 +02:00
|
|
|
{
|
2026-09-16 15:54:55 +02:00
|
|
|
return RicfForwarding::errorResponse( QString( "Case with ID %1 is not an Eclipse case" ).arg( m_caseId() ), commandName );
|
2018-04-13 12:13:27 +02:00
|
|
|
}
|
2023-02-10 15:11:03 +01:00
|
|
|
|
2026-09-16 15:54:55 +02:00
|
|
|
// Resolve the export folder and custom file name. The Rimc method requires an explicit folder.
|
2023-02-10 15:11:03 +01:00
|
|
|
QString exportFolderPath;
|
2026-09-16 15:54:55 +02:00
|
|
|
QString customFileName;
|
2023-02-10 15:11:03 +01:00
|
|
|
if ( m_customFileNameIncludingPath().isEmpty() )
|
|
|
|
|
{
|
2023-02-26 10:48:40 +01:00
|
|
|
exportFolderPath = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
|
2023-02-10 15:11:03 +01:00
|
|
|
if ( exportFolderPath.isNull() )
|
|
|
|
|
{
|
|
|
|
|
exportFolderPath = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2026-09-16 15:54:55 +02:00
|
|
|
QFileInfo fi( m_customFileNameIncludingPath() );
|
|
|
|
|
customFileName = fi.fileName();
|
2023-02-10 15:11:03 +01:00
|
|
|
|
|
|
|
|
auto pathCandidate = fi.path();
|
|
|
|
|
if ( pathCandidate.size() > 2 )
|
|
|
|
|
{
|
|
|
|
|
exportFolderPath = pathCandidate;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse response;
|
2019-05-23 13:59:19 +02:00
|
|
|
|
2026-09-16 15:54:55 +02:00
|
|
|
// Resolve well path names to objects. Unknown names are warnings, matching the legacy behavior.
|
2017-07-27 10:28:41 +02:00
|
|
|
std::vector<RimWellPath*> wellPaths;
|
2026-09-16 15:54:55 +02:00
|
|
|
for ( const QString& wellPathName : m_wellPathNames() )
|
2017-07-27 10:28:41 +02:00
|
|
|
{
|
2026-09-16 15:54:55 +02:00
|
|
|
RimWellPath* wellPath = RimProject::current()->activeOilField()->wellPathCollection->wellPathByName( wellPathName );
|
|
|
|
|
if ( wellPath )
|
2018-05-09 12:40:57 +02:00
|
|
|
{
|
2026-09-16 15:54:55 +02:00
|
|
|
wellPaths.push_back( wellPath );
|
2018-05-09 12:40:57 +02:00
|
|
|
}
|
2026-09-16 15:54:55 +02:00
|
|
|
else
|
2017-07-27 10:28:41 +02:00
|
|
|
{
|
2026-09-16 15:54:55 +02:00
|
|
|
QString warning = QString( "%1: Could not find well path with name %2" ).arg( commandName ).arg( wellPathName );
|
|
|
|
|
RiaLogging::warning( warning.toStdString() );
|
|
|
|
|
response.updateStatus( caf::PdmScriptResponse::COMMAND_WARNING, warning );
|
2017-07-27 10:28:41 +02:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2026-09-16 15:54:55 +02:00
|
|
|
// Legacy behavior: if names were given but none resolved, nothing is exported (not all visible wells)
|
|
|
|
|
if ( !m_wellPathNames().empty() && wellPaths.empty() ) return response;
|
|
|
|
|
|
|
|
|
|
RimEclipseCase_exportCompletions method( eclipseCase );
|
|
|
|
|
method.setWellPaths( wellPaths );
|
|
|
|
|
method.setTimeStep( m_timeStep() );
|
|
|
|
|
method.setExportFolder( exportFolderPath );
|
|
|
|
|
method.setCustomFileName( customFileName );
|
|
|
|
|
method.setFileSplit( m_fileSplit() );
|
|
|
|
|
method.setCompdatExport( m_compdatExport() );
|
|
|
|
|
method.setIncludeMsw( m_includeMsw() );
|
|
|
|
|
method.setUseNtgHorizontally( m_useLateralNTG() );
|
|
|
|
|
method.setIncludePerforations( m_includePerforations() );
|
|
|
|
|
method.setIncludeFishbones( m_includeFishbones() );
|
|
|
|
|
method.setIncludeFractures( m_includeFractures() );
|
|
|
|
|
method.setExcludeMainBoreForFishbones( m_excludeMainBoreForFishbones() );
|
|
|
|
|
method.setPerformTransScaling( m_performTransScaling() );
|
|
|
|
|
method.setTransScalingTimeStep( m_transScalingTimeStep() );
|
|
|
|
|
method.setTransScalingWbhpSource( m_transScalingInitialWBHP() );
|
|
|
|
|
method.setTransScalingWbhp( m_transScalingWBHP() );
|
|
|
|
|
method.setExportComments( m_exportDataSourceAsComments() );
|
|
|
|
|
method.setExportWelspec( m_exportWelspec() );
|
|
|
|
|
|
|
|
|
|
auto result = method.execute();
|
|
|
|
|
if ( !result ) return RicfForwarding::errorResponse( result.error(), commandName );
|
2019-05-23 13:59:19 +02:00
|
|
|
|
|
|
|
|
return response;
|
2017-07-27 10:28:41 +02:00
|
|
|
}
|