2017-08-02 02:51:56 -05:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 03:40:57 -05:00
|
|
|
//
|
2017-08-02 02:51:56 -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-08-02 02:51:56 -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-08-02 02:51:56 -05:00
|
|
|
// for more details.
|
|
|
|
//
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2018-04-13 05:13:27 -05:00
|
|
|
#include "RicfExportSimWellFractureCompletions.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
|
2018-11-07 08:42:45 -06:00
|
|
|
#include "RicfApplicationTools.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
#include "RicfCommandFileExecutor.h"
|
|
|
|
|
|
|
|
#include "RiaApplication.h"
|
|
|
|
#include "RiaLogging.h"
|
|
|
|
|
2017-12-20 04:13:31 -06:00
|
|
|
#include "RimDialogData.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
#include "RimEclipseCase.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimEclipseCaseCollection.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
#include "RimEclipseView.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimOilField.h"
|
|
|
|
#include "RimProject.h"
|
|
|
|
#include "RimSimWellInView.h"
|
2019-09-06 03:40:57 -05:00
|
|
|
#include "RimSimWellInViewCollection.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
#include "RimWellPath.h"
|
2017-10-13 02:29:42 -05:00
|
|
|
#include "RimWellPathCollection.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
|
2018-01-31 00:55:24 -06:00
|
|
|
#include "CompletionExportCommands/RicWellPathExportCompletionDataFeatureImpl.h"
|
2017-08-02 02:51:56 -05:00
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfExportSimWellFractureCompletions, "exportSimWellFractureCompletions" );
|
2017-08-02 02:51:56 -05:00
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-02 02:51:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2018-04-13 05:13:27 -05:00
|
|
|
RicfExportSimWellFractureCompletions::RicfExportSimWellFractureCompletions()
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RICF_InitField( &m_caseId, "caseId", -1, "Case ID", "", "", "" );
|
|
|
|
RICF_InitField( &m_viewName, "viewName", QString( "" ), "View Name", "", "", "" );
|
|
|
|
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 02:51:56 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 03:40:57 -05:00
|
|
|
///
|
2017-08-02 02:51:56 -05:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-05-23 06:59:19 -05:00
|
|
|
RicfCommandResponse RicfExportSimWellFractureCompletions::execute()
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2018-11-07 08:42:45 -06:00
|
|
|
using TOOLS = RicfApplicationTools;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RimProject* project = RiaApplication::instance()->project();
|
2018-04-06 07:09:40 -05:00
|
|
|
RicExportCompletionDataSettingsUi* exportSettings = project->dialogData()->exportCompletionData();
|
2019-09-06 03:40:57 -05:00
|
|
|
|
|
|
|
exportSettings->timeStep = m_timeStep;
|
|
|
|
exportSettings->fileSplit = m_fileSplit;
|
2017-12-20 04:13:31 -06:00
|
|
|
exportSettings->compdatExport = m_compdatExport;
|
2017-08-02 02:51:56 -05:00
|
|
|
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
auto eclipseCase = TOOLS::caseFromId( m_caseId() );
|
|
|
|
if ( !eclipseCase )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString error = QString( "exportSimWellCompletions: Could not find case with ID %1" ).arg( m_caseId() );
|
|
|
|
RiaLogging::error( error );
|
|
|
|
return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, error );
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
2018-11-07 08:42:45 -06:00
|
|
|
exportSettings->caseToApply = eclipseCase;
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
QString exportFolder = RicfCommandFileExecutor::instance()->getExportPath( RicfCommandFileExecutor::COMPLETIONS );
|
|
|
|
if ( exportFolder.isNull() )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
exportFolder = RiaApplication::instance()->createAbsolutePathFromProjectRelativePath( "completions" );
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
2017-12-20 04:13:31 -06:00
|
|
|
exportSettings->folder = exportFolder;
|
2017-08-02 02:51:56 -05:00
|
|
|
|
2018-05-09 01:42:11 -05:00
|
|
|
std::vector<RimEclipseView*> views;
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( Rim3dView* v : exportSettings->caseToApply->views() )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimEclipseView* eclipseView = dynamic_cast<RimEclipseView*>( v );
|
|
|
|
if ( eclipseView && eclipseView->name() == m_viewName() )
|
2018-05-09 01:42:11 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
views.push_back( eclipseView );
|
2018-05-09 01:42:11 -05:00
|
|
|
}
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( views.empty() )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString error = QString(
|
|
|
|
"exportSimWellCompletions: Could not find any views named \"%1\" in the case with ID %2" )
|
|
|
|
.arg( m_viewName )
|
|
|
|
.arg( m_caseId() );
|
|
|
|
RiaLogging::error( error );
|
|
|
|
return RicfCommandResponse( RicfCommandResponse::COMMAND_ERROR, error );
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
|
|
|
|
2019-05-23 06:59:19 -05:00
|
|
|
RicfCommandResponse response;
|
|
|
|
|
2017-10-13 02:29:42 -05:00
|
|
|
std::vector<RimSimWellInView*> simWells;
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( m_simWellNames().empty() )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseView* view : views )
|
2018-05-09 01:42:11 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( auto simWell : view->wellCollection()->wells )
|
2018-05-09 05:40:57 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
if ( simWell->showWell() )
|
2018-05-09 05:40:57 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
simWells.push_back( simWell );
|
2018-05-09 05:40:57 -05:00
|
|
|
}
|
|
|
|
}
|
2018-05-09 01:42:11 -05:00
|
|
|
}
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( const QString& wellPathName : m_simWellNames() )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
for ( RimEclipseView* view : views )
|
2017-08-02 02:51:56 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
RimSimWellInView* simWell = view->wellCollection()->findWell( wellPathName );
|
|
|
|
if ( simWell )
|
2018-05-09 01:42:11 -05:00
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
simWells.push_back( simWell );
|
2018-05-09 01:42:11 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-09-06 03:40:57 -05:00
|
|
|
QString 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() );
|
|
|
|
RiaLogging::warning( warning );
|
|
|
|
response.updateStatus( RicfCommandResponse::COMMAND_WARNING, warning );
|
2018-05-09 01:42:11 -05:00
|
|
|
}
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
std::vector<RimWellPath*> wellPaths;
|
|
|
|
|
2019-09-06 03:40:57 -05:00
|
|
|
RicWellPathExportCompletionDataFeatureImpl::exportCompletions( wellPaths, simWells, *exportSettings );
|
2019-05-23 06:59:19 -05:00
|
|
|
|
|
|
|
return response;
|
2017-08-02 02:51:56 -05:00
|
|
|
}
|