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