2018-08-22 11:23:02 +02:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
//
|
|
|
|
|
// Copyright (C) 2017 Statoil ASA
|
2019-09-06 10:40:57 +02:00
|
|
|
//
|
2018-08-22 11:23:02 +02: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 10:40:57 +02:00
|
|
|
//
|
2018-08-22 11:23:02 +02: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 10:40:57 +02:00
|
|
|
//
|
|
|
|
|
// See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
|
2018-08-22 11:23:02 +02:00
|
|
|
// for more details.
|
|
|
|
|
//
|
|
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#include "RicfCreateMultipleFractures.h"
|
|
|
|
|
|
2018-11-07 15:42:45 +01:00
|
|
|
#include "RicfApplicationTools.h"
|
2026-09-16 16:03:31 +02:00
|
|
|
#include "RicfCommandForwarding.h"
|
2018-08-22 11:23:02 +02:00
|
|
|
|
|
|
|
|
#include "RimEclipseCase.h"
|
2019-09-06 10:40:57 +02:00
|
|
|
#include "RimFractureTemplate.h"
|
2018-08-22 11:23:02 +02:00
|
|
|
#include "RimWellPath.h"
|
2026-09-16 16:03:31 +02:00
|
|
|
#include "RimcEclipseCase.h"
|
2018-08-22 11:23:02 +02:00
|
|
|
|
2020-08-21 11:13:07 +02:00
|
|
|
#include "cafPdmFieldScriptingCapability.h"
|
2018-08-22 11:23:02 +02:00
|
|
|
|
2019-09-06 10:40:57 +02:00
|
|
|
CAF_PDM_SOURCE_INIT( RicfCreateMultipleFractures, "createMultipleFractures" );
|
2018-08-22 11:23:02 +02:00
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2018-08-22 11:23:02 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
|
|
|
|
RicfCreateMultipleFractures::RicfCreateMultipleFractures()
|
|
|
|
|
{
|
2021-11-14 14:15:12 +01:00
|
|
|
CAF_PDM_InitScriptableField( &m_caseId, "caseId", -1, "Case ID" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_wellPathNames, "wellPathNames", std::vector<QString>(), "Well Path Names" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_minDistFromWellTd, "minDistFromWellTd", 100.0, "Min Distance From Well TD" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_maxFracturesPerWell, "maxFracturesPerWell", 100, "Max Fractures per Well" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_templateId, "templateId", -1, "Template ID" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_topLayer, "topLayer", -1, "Top Layer" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_baseLayer, "baseLayer", -1, "Base Layer" );
|
|
|
|
|
CAF_PDM_InitScriptableField( &m_spacing, "spacing", 300.0, "Spacing" );
|
2020-08-21 11:13:07 +02:00
|
|
|
CAF_PDM_InitScriptableField( &m_action,
|
|
|
|
|
"action",
|
|
|
|
|
caf::AppEnum<MultipleFractures::Action>( MultipleFractures::Action::APPEND_FRACTURES ),
|
2022-01-07 08:31:52 +01:00
|
|
|
"Action" );
|
2018-08-22 11:23:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//--------------------------------------------------------------------------------------------------
|
2019-09-06 10:40:57 +02:00
|
|
|
///
|
2018-08-22 11:23:02 +02:00
|
|
|
//--------------------------------------------------------------------------------------------------
|
2020-03-10 14:11:22 +01:00
|
|
|
caf::PdmScriptResponse RicfCreateMultipleFractures::execute()
|
2018-08-22 11:23:02 +02:00
|
|
|
{
|
2026-09-16 16:03:31 +02:00
|
|
|
const QString commandName = classKeyword();
|
2019-05-23 13:59:19 +02:00
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
if ( m_caseId() < 0 || m_templateId() < 0 )
|
2019-05-23 13:59:19 +02:00
|
|
|
{
|
2026-09-16 16:03:31 +02:00
|
|
|
return RicfForwarding::errorResponse( "Mandatory argument(s) missing: caseId and templateId are required", commandName );
|
2019-05-23 13:59:19 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
QStringList wellsNotFound;
|
|
|
|
|
std::vector<RimWellPath*> wellPaths =
|
|
|
|
|
RicfApplicationTools::wellPathsFromNames( RicfApplicationTools::toQStringList( m_wellPathNames ), &wellsNotFound );
|
|
|
|
|
if ( !wellsNotFound.empty() )
|
2019-05-23 13:59:19 +02:00
|
|
|
{
|
2026-09-16 16:03:31 +02:00
|
|
|
return RicfForwarding::errorResponse( "These well paths were not found: " + wellsNotFound.join( ", " ), commandName );
|
2019-05-23 13:59:19 +02:00
|
|
|
}
|
2026-09-16 16:03:31 +02:00
|
|
|
if ( wellPaths.empty() ) return RicfForwarding::errorResponse( "No wellpaths found", commandName );
|
2018-08-22 11:23:02 +02:00
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
auto rimCase = RicfForwarding::findCase( m_caseId() );
|
|
|
|
|
if ( !rimCase ) return RicfForwarding::errorResponse( rimCase.error(), commandName );
|
2018-08-22 11:23:02 +02:00
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
auto* eclipseCase = dynamic_cast<RimEclipseCase*>( rimCase.value() );
|
|
|
|
|
if ( !eclipseCase )
|
2019-05-23 13:59:19 +02:00
|
|
|
{
|
2026-09-16 16:03:31 +02:00
|
|
|
return RicfForwarding::errorResponse( QString( "Case with ID %1 is not an Eclipse case" ).arg( m_caseId() ), commandName );
|
2018-08-22 11:23:02 +02:00
|
|
|
}
|
|
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
auto fractureTemplate = RicfForwarding::findFractureTemplate( m_templateId() );
|
|
|
|
|
if ( !fractureTemplate ) return RicfForwarding::errorResponse( fractureTemplate.error(), commandName );
|
2018-08-22 11:23:02 +02:00
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
RimEclipseCase_createMultipleFractures method( eclipseCase );
|
|
|
|
|
method.setWellPaths( wellPaths );
|
|
|
|
|
method.setFractureTemplate( fractureTemplate.value() );
|
|
|
|
|
method.setMinDistFromWellTd( m_minDistFromWellTd() );
|
|
|
|
|
method.setMaxFracturesPerWell( m_maxFracturesPerWell() );
|
|
|
|
|
method.setTopLayer( m_topLayer() );
|
|
|
|
|
method.setBaseLayer( m_baseLayer() );
|
|
|
|
|
method.setSpacing( m_spacing() );
|
|
|
|
|
method.setAction( m_action() );
|
2018-08-22 11:23:02 +02:00
|
|
|
|
2026-09-16 16:03:31 +02:00
|
|
|
return RicfForwarding::toScriptResponse( method.execute(), commandName );
|
2018-08-22 11:23:02 +02:00
|
|
|
}
|