2017-07-27 03:28:41 -05:00
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2017 Statoil 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 "RicfExportWellPathCompletions.h"
2018-11-07 08:42:45 -06:00
# include "RicfApplicationTools.h"
2017-07-27 03:28:41 -05:00
# include "RicfCommandFileExecutor.h"
# include "RiaApplication.h"
2017-07-27 07:26:59 -05:00
# include "RiaLogging.h"
2017-07-27 03:28:41 -05:00
2017-12-20 04:13:31 -06:00
# include "RimDialogData.h"
2017-07-27 03:28:41 -05:00
# include "RimProject.h"
# include "RimOilField.h"
# include "RimEclipseCaseCollection.h"
# include "RimEclipseCase.h"
# include "RimWellPathCollection.h"
# include "RimWellPath.h"
2018-01-31 00:55:24 -06:00
# include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h"
2017-07-27 03:28:41 -05:00
CAF_PDM_SOURCE_INIT ( RicfExportWellPathCompletions , " exportWellPathCompletions " ) ;
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RicfExportWellPathCompletions : : RicfExportWellPathCompletions ( )
{
2017-08-03 08:00:52 -05:00
RICF_InitField ( & m_caseId , " caseId " , - 1 , " Case ID " , " " , " " , " " ) ;
2017-07-27 03:28:41 -05:00
RICF_InitField ( & m_timeStep , " timeStep " , - 1 , " Time Step Index " , " " , " " , " " ) ;
RICF_InitField ( & m_wellPathNames , " wellPathNames " , std : : vector < QString > ( ) , " Well Path Names " , " " , " " , " " ) ;
2018-04-13 05:13:27 -05:00
2017-07-27 03:28:41 -05:00
RICF_InitField ( & m_fileSplit , " fileSplit " , RicExportCompletionDataSettingsUi : : ExportSplitType ( ) , " File Split " , " " , " " , " " ) ;
RICF_InitField ( & m_compdatExport , " compdatExport " , RicExportCompletionDataSettingsUi : : CompdatExportType ( ) , " Compdat Export " , " " , " " , " " ) ;
2018-04-13 05:13:27 -05:00
RICF_InitField ( & m_combinationMode , " combinationMode " , RicExportCompletionDataSettingsUi : : CombinationModeType ( ) , " Combination Mode " , " " , " " , " " ) ;
RICF_InitField ( & m_useLateralNTG , " useNtgHorizontally " , false , " Use NTG Horizontally " , " " , " " , " " ) ;
RICF_InitField ( & m_includePerforations , " includePerforations " , true , " Include Perforations " , " " , " " , " " ) ;
RICF_InitField ( & m_includeFishbones , " includeFishbones " , true , " Include Fishbones " , " " , " " , " " ) ;
RICF_InitField ( & m_includeFractures , " includeFractures " , true , " Include Fractures " , " " , " " , " " ) ;
RICF_InitField ( & m_excludeMainBoreForFishbones , " excludeMainBoreForFishbones " , false , " Exclude Main Bore for Fishbones " , " " , " " , " " ) ;
2018-09-14 07:00:27 -05:00
2018-11-13 09:47:53 -06:00
RICF_InitField ( & m_performTransScaling , " performTransScaling " , false , " Perform Transmissibility Scaling " , " " , " " , " " ) ;
2018-09-19 01:52:40 -05:00
RICF_InitField ( & m_transScalingTimeStep , " transScalingTimeStep " , 0 , " Transmissibility Scaling Pressure Time Step " , " " , " " , " " ) ;
2018-11-13 09:47:53 -06:00
RICF_InitField ( & m_transScalingInitialWBHP , " transScalingWBHPFromSummary " , RicExportCompletionDataSettingsUi : : TransScalingWBHPSource ( ) , " Transmissibility Scaling WBHP from summary " , " " , " " , " " ) ;
2018-09-18 06:27:59 -05:00
RICF_InitField ( & m_transScalingWBHP , " transScalingWBHP " , 200.0 , " Transmissibility Scaling Constant WBHP Value " , " " , " " , " " ) ;
2017-07-27 03:28:41 -05:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2019-05-23 06:59:19 -05:00
RicfCommandResponse RicfExportWellPathCompletions : : execute ( )
2017-07-27 03:28:41 -05:00
{
2018-11-07 08:42:45 -06:00
using TOOLS = RicfApplicationTools ;
2017-12-20 04:13:31 -06:00
RimProject * project = RiaApplication : : instance ( ) - > project ( ) ;
2018-04-06 07:09:40 -05:00
RicExportCompletionDataSettingsUi * exportSettings = project - > dialogData ( ) - > exportCompletionData ( ) ;
2018-04-13 05:13:27 -05:00
if ( m_timeStep < 0 )
{
exportSettings - > timeStep = 0 ;
}
else
{
exportSettings - > timeStep = m_timeStep ;
}
2017-12-20 04:13:31 -06:00
exportSettings - > fileSplit = m_fileSplit ;
exportSettings - > compdatExport = m_compdatExport ;
2018-04-13 05:13:27 -05:00
2018-11-13 09:47:53 -06:00
exportSettings - > performTransScaling = m_performTransScaling ;
2018-09-18 06:27:59 -05:00
exportSettings - > transScalingTimeStep = m_transScalingTimeStep ;
2018-11-13 09:47:53 -06:00
exportSettings - > transScalingWBHPSource = m_transScalingInitialWBHP ;
2018-09-17 03:51:08 -05:00
exportSettings - > transScalingWBHP = m_transScalingWBHP ;
2018-09-14 07:00:27 -05:00
2018-04-13 05:13:27 -05:00
exportSettings - > useLateralNTG = m_useLateralNTG ;
2017-12-20 04:13:31 -06:00
exportSettings - > includePerforations = m_includePerforations ;
exportSettings - > includeFishbones = m_includeFishbones ;
exportSettings - > excludeMainBoreForFishbones = m_excludeMainBoreForFishbones ;
2018-04-13 05:13:27 -05:00
exportSettings - > includeFractures = m_includeFractures ;
exportSettings - > setCombinationMode ( m_combinationMode ( ) ) ;
2017-07-27 03:28:41 -05:00
{
2018-11-07 08:42:45 -06:00
auto eclipseCase = TOOLS : : caseFromId ( m_caseId ( ) ) ;
if ( ! eclipseCase )
2017-07-27 07:26:59 -05:00
{
2019-05-23 06:59:19 -05:00
QString error = QString ( " exportWellPathCompletions: Could not find case with ID %1 " ) . arg ( m_caseId ( ) ) ;
RiaLogging : : error ( error ) ;
return RicfCommandResponse ( RicfCommandResponse : : COMMAND_ERROR , error ) ;
2017-07-27 03:28:41 -05:00
}
2018-11-07 08:42:45 -06:00
exportSettings - > caseToApply = eclipseCase ;
2017-07-27 03:28:41 -05:00
}
QString exportFolder = RicfCommandFileExecutor : : instance ( ) - > getExportPath ( RicfCommandFileExecutor : : COMPLETIONS ) ;
if ( exportFolder . isNull ( ) )
{
exportFolder = RiaApplication : : instance ( ) - > createAbsolutePathFromProjectRelativePath ( " completions " ) ;
}
2017-12-20 04:13:31 -06:00
exportSettings - > folder = exportFolder ;
2017-07-27 03:28:41 -05:00
2019-05-23 06:59:19 -05:00
RicfCommandResponse response ;
2017-07-27 03:28:41 -05:00
std : : vector < RimWellPath * > wellPaths ;
if ( m_wellPathNames ( ) . empty ( ) )
{
2018-05-09 05:40:57 -05:00
for ( auto wellPath : RiaApplication : : instance ( ) - > project ( ) - > activeOilField ( ) - > wellPathCollection - > wellPaths ( ) )
{
if ( wellPath - > showWellPath ( ) )
{
wellPaths . push_back ( wellPath ) ;
}
}
2017-07-27 03:28:41 -05:00
}
else
{
for ( const QString & wellPathName : m_wellPathNames ( ) )
{
RimWellPath * wellPath = RiaApplication : : instance ( ) - > project ( ) - > activeOilField ( ) - > wellPathCollection - > wellPathByName ( wellPathName ) ;
if ( wellPath )
{
wellPaths . push_back ( wellPath ) ;
}
2017-08-02 02:51:56 -05:00
else
{
2019-05-23 06:59:19 -05:00
QString warning = QString ( " exportWellPathCompletions: Could not find well path with name %1 " ) . arg ( wellPathName ) ;
RiaLogging : : warning ( warning ) ;
response . updateStatus ( RicfCommandResponse : : COMMAND_WARNING , warning ) ;
2017-08-02 02:51:56 -05:00
}
2017-07-27 03:28:41 -05:00
}
}
2017-10-13 02:29:42 -05:00
std : : vector < RimSimWellInView * > simWells ;
2017-08-01 05:44:11 -05:00
2018-01-31 00:42:19 -06:00
RicWellPathExportCompletionDataFeatureImpl : : exportCompletions ( wellPaths , simWells , * exportSettings ) ;
2019-05-23 06:59:19 -05:00
return response ;
2017-07-27 03:28:41 -05:00
}