2017-07-27 03:29:45 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-07-27 03:29:45 -05: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 03:40:57 -05:00
|
|
|
//
|
2017-07-27 03:29:45 -05: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 03:40:57 -05:00
|
|
|
//
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2017-07-27 03:29:45 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "RicfExportMsw.h"
|
|
|
|
|
2018-11-07 08:42:45 -06:00
|
|
|
#include "RicfApplicationTools.h"
|
2017-07-27 03:29:45 -05:00
|
|
|
#include "RicfCommandFileExecutor.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
2017-07-27 07:26:59 -05:00
|
|
|
#include "RiaLogging.h"
|
2017-07-27 03:29:45 -05:00
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimEclipseCaseCollection.h"
|
2021-02-26 07:27:59 -06:00
|
|
|
#include "RimFishbones.h"
|
2017-07-27 03:29:45 -05:00
|
|
|
#include "RimFishbonesCollection.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimWellPath.h"
|
|
|
|
#include "RimWellPathCollection.h"
|
2017-07-27 03:29:45 -05:00
|
|
|
|
2018-12-06 06:29:34 -06:00
|
|
|
#include "CompletionExportCommands/RicExportCompletionDataSettingsUi.h"
|
|
|
|
#include "CompletionExportCommands/RicWellPathExportMswCompletionsImpl.h"
|
2017-07-27 03:29:45 -05:00
|
|
|
|
2020-08-21 04:13:07 -05:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2020-03-10 08:11:22 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfExportMsw, "exportMsw" );
|
2017-07-27 03:29:45 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-07-27 03:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
RicfExportMsw::RicfExportMsw()
|
|
|
|
{
|
2021-11-14 07:15:12 -06:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" );
|
|
|
|
CAF_PDM_InitScriptableField( &m_wellPathName, "wellPath", QString(), "Well Path Name" );
|
|
|
|
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" );
|
2022-01-07 01:31:52 -06:00
|
|
|
CAF_PDM_InitScriptableField( &m_fileSplit, "fileSplit", RicExportCompletionDataSettingsUi::ExportSplitType(), "File Split" );
|
2017-07-27 03:29:45 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-07-27 03:29:45 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 08:11:22 -05:00
|
|
|
caf::PdmScriptResponse RicfExportMsw::execute()
|
2017-07-27 03:29:45 -05:00
|
|
|
{
|
2018-11-07 08:42:45 -06:00
|
|
|
using TOOLS = RicfApplicationTools;
|
|
|
|
|
2018-12-06 06:29:34 -06:00
|
|
|
RicExportCompletionDataSettingsUi exportSettings;
|
2017-07-27 03:29:45 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
auto eclipseCase = TOOLS::caseFromId( m_caseId() );
|
|
|
|
if ( !eclipseCase )
|
2017-07-27 03:29:45 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString error = QString( "exportMsw: Could not find case with ID %1." ).arg( m_caseId() );
|
|
|
|
RiaLogging::error( error );
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
|
2017-07-27 03:29:45 -05:00
|
|
|
}
|
|
|
|
|
2020-04-24 01:22:32 -05:00
|
|
|
QString exportFolder =
|
|
|
|
RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::ExportType::COMPLETIONS );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( exportFolder.isNull() )
|
2017-07-27 03:29:45 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );
|
2017-07-27 03:29:45 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings.caseToApply = eclipseCase;
|
|
|
|
exportSettings.folder = exportFolder;
|
2018-12-06 06:29:34 -06:00
|
|
|
exportSettings.includePerforations = m_includePerforations;
|
2019-09-06 03:40:57 -05:00
|
|
|
exportSettings.includeFishbones = m_includeFishbones;
|
|
|
|
exportSettings.includeFractures = m_includeFractures;
|
|
|
|
exportSettings.fileSplit = m_fileSplit;
|
2017-07-27 03:29:45 -05:00
|
|
|
|
2020-05-12 02:50:38 -05:00
|
|
|
RimWellPath* wellPath = RimProject::current()->wellPathByName( m_wellPathName );
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( !wellPath )
|
2017-07-27 07:26:59 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString error = QString( "exportMsw: Could not find well path with name %1" ).arg( m_wellPathName() );
|
|
|
|
RiaLogging::error( error );
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse( caf::PdmScriptResponse::COMMAND_ERROR, error );
|
2017-07-27 07:26:59 -05:00
|
|
|
}
|
2017-07-27 03:29:45 -05:00
|
|
|
|
2020-11-06 03:46:38 -06:00
|
|
|
RicWellPathExportMswCompletionsImpl::exportWellSegmentsForAllCompletions( exportSettings, { wellPath } );
|
2019-05-23 06:59:19 -05:00
|
|
|
|
2020-03-10 08:11:22 -05:00
|
|
|
return caf::PdmScriptResponse();
|
2017-07-27 03:29:45 -05:00
|
|
|
}
|