2017-08-02 09:51:56 +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.
//
/////////////////////////////////////////////////////////////////////////////////
2018-04-13 12:13:27 +02:00
#include "RicfExportSimWellFractureCompletions.h"
2017-08-02 09:51:56 +02:00
2018-11-07 15:42:45 +01:00
#include "RicfApplicationTools.h"
2017-08-02 09:51:56 +02:00
#include "RicfCommandFileExecutor.h"
#include "RiaApplication.h"
#include "RiaLogging.h"
2017-12-20 11:13:31 +01:00
#include "RimDialogData.h"
2017-08-02 09:51:56 +02:00
#include "RimEclipseCase.h"
2017-10-13 09:29:42 +02:00
#include "RimEclipseCaseCollection.h"
2017-08-02 09:51:56 +02:00
#include "RimEclipseView.h"
2017-10-13 14:20:47 +02:00
#include "RimSimWellInViewCollection.h"
2017-10-13 09:29:42 +02:00
#include "RimOilField.h"
#include "RimProject.h"
#include "RimSimWellInView.h"
#include "RimSimWellInView.h"
2017-08-02 09:51:56 +02:00
#include "RimWellPath.h"
2017-10-13 09:29:42 +02:00
#include "RimWellPathCollection.h"
2017-08-02 09:51:56 +02:00
2018-01-31 07:55:24 +01:00
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h"
2017-08-02 09:51:56 +02:00
2018-04-13 12:13:27 +02:00
CAF_PDM_SOURCE_INIT ( RicfExportSimWellFractureCompletions , "exportSimWellFractureCompletions" );
2017-08-02 09:51:56 +02:00
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-04-13 12:13:27 +02:00
RicfExportSimWellFractureCompletions :: RicfExportSimWellFractureCompletions ()
2017-08-02 09:51:56 +02:00
{
2018-05-09 08:42:11 +02:00
RICF_InitField ( & m_caseId , "caseId" , - 1 , "Case ID" , "" , "" , "" );
RICF_InitField ( & m_viewName , "viewName" , QString ( "" ), "View Name" , "" , "" , "" );
2018-04-13 12:13:27 +02:00
RICF_InitField ( & m_timeStep , "timeStep" , - 1 , "Time Step Index" , "" , "" , "" );
RICF_InitField ( & m_simWellNames , "simulationWellNames" , std :: vector < QString > (), "Simulation Well Names" , "" , "" , "" );
RICF_InitField ( & m_fileSplit , "fileSplit" , RicExportCompletionDataSettingsUi :: ExportSplitType (), "File Split" , "" , "" , "" );
RICF_InitField ( & m_compdatExport , "compdatExport" , RicExportCompletionDataSettingsUi :: CompdatExportType (), "Compdat Export" , "" , "" , "" );
2017-08-02 09:51:56 +02:00
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
2018-04-13 12:13:27 +02:00
void RicfExportSimWellFractureCompletions :: execute ()
2017-08-02 09:51:56 +02:00
{
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
2017-12-20 11:13:31 +01:00
exportSettings -> timeStep = m_timeStep ;
exportSettings -> fileSplit = m_fileSplit ;
exportSettings -> compdatExport = m_compdatExport ;
2017-08-02 09:51:56 +02:00
{
2018-11-07 15:42:45 +01:00
auto eclipseCase = TOOLS :: caseFromId ( m_caseId ());
if ( ! eclipseCase )
2017-08-02 09:51:56 +02:00
{
RiaLogging :: error ( QString ( "exportSimWellCompletions: Could not find case with ID %1" ). arg ( m_caseId ()));
return ;
}
2018-11-07 15:42:45 +01:00
exportSettings -> caseToApply = eclipseCase ;
2017-08-02 09:51:56 +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-08-02 09:51:56 +02:00
2018-05-09 08:42:11 +02:00
std :: vector < RimEclipseView *> views ;
2018-01-09 10:11:28 +01:00
for ( Rim3dView * v : exportSettings -> caseToApply -> views ())
2017-08-02 09:51:56 +02:00
{
2018-05-09 08:42:11 +02:00
RimEclipseView * eclipseView = dynamic_cast < RimEclipseView *> ( v );
if ( eclipseView && eclipseView -> name () == m_viewName ())
{
views . push_back ( eclipseView );
}
2017-08-02 09:51:56 +02:00
}
2018-05-09 08:42:11 +02:00
if ( views . empty ())
2017-08-02 09:51:56 +02:00
{
2018-05-09 08:42:11 +02:00
RiaLogging :: error ( QString ( "exportSimWellCompletions: Could not find any views named \" %1 \" in the case with ID %2" ). arg ( m_viewName ). arg ( m_caseId ()));
2017-08-02 09:51:56 +02:00
return ;
}
2017-10-13 09:29:42 +02:00
std :: vector < RimSimWellInView *> simWells ;
2018-04-13 12:13:27 +02:00
if ( m_simWellNames (). empty ())
2017-08-02 09:51:56 +02:00
{
2018-05-09 08:42:11 +02:00
for ( RimEclipseView * view : views )
{
2018-05-09 12:40:57 +02:00
for ( auto simWell : view -> wellCollection () -> wells )
{
if ( simWell -> showWell ())
{
simWells . push_back ( simWell );
}
}
2018-05-09 08:42:11 +02:00
}
2017-08-02 09:51:56 +02:00
}
else
{
2018-04-13 12:13:27 +02:00
for ( const QString & wellPathName : m_simWellNames ())
2017-08-02 09:51:56 +02:00
{
2018-05-09 08:42:11 +02:00
for ( RimEclipseView * view : views )
2017-08-02 09:51:56 +02:00
{
2018-05-09 08:42:11 +02:00
RimSimWellInView * simWell = view -> wellCollection () -> findWell ( wellPathName );
if ( simWell )
{
simWells . push_back ( simWell );
}
else
{
RiaLogging :: warning ( QString ( "exportSimWellCompletions: Could not find well with name %1 in view \" %2 \" on case with ID %2" ). arg ( wellPathName ). arg ( m_viewName ). arg ( m_caseId ()));
}
2017-08-02 09:51:56 +02:00
}
}
}
std :: vector < RimWellPath *> wellPaths ;
2018-01-31 07:42:19 +01:00
RicWellPathExportCompletionDataFeatureImpl :: exportCompletions ( wellPaths , simWells , * exportSettings );
2017-08-02 09:51:56 +02:00
}