#12719 Allow import of same well multiple times

Also exposes the well path collection object through the project object, and updates examples.
This commit is contained in:
Magne Sjaastad committed 2025-08-08 08:56:15 +02:00
1 parent 871973d02a
commit 377d300767
17 files changed
+204 -54

No files matched your search

@@ -19,6 +19,7 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RimcWellPathGeometryDef.h
${CMAKE_CURRENT_LIST_DIR}/RimcModeledWellPath.h
${CMAKE_CURRENT_LIST_DIR}/RimcWellPath.h
${CMAKE_CURRENT_LIST_DIR}/RimcWellPathCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplateCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplate.h
${CMAKE_CURRENT_LIST_DIR}/RimcThermalFractureTemplate.h
@@ -53,6 +54,7 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RimcWellPathGeometryDef.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcModeledWellPath.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcWellPath.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcWellPathCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplateCollection.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcFractureTemplate.cpp
${CMAKE_CURRENT_LIST_DIR}/RimcThermalFractureTemplate.cpp
@@ -36,6 +36,8 @@
#include "RimProject.h"
#include "RimSummaryCase.h"
#include "RimSurfaceCollection.h"
#include "RimTools.h"
#include "RimWellPathCollection.h"
#include "RiuMainWindow.h"
#include "RiuPlotMainWindow.h"
@@ -284,3 +286,36 @@ QString RimProject_createGridFromKeyValues::classKeywordReturnedType() const
{
return RimCornerPointCase::classKeywordStatic();
}
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimProject, RimProject_wellPathCollection, "wellPathCollection" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimProject_wellPathCollection::RimProject_wellPathCollection( caf::PdmObjectHandle* self )
: PdmObjectMethod( self, PdmObjectMethod::NullPointerType::NULL_IS_INVALID, PdmObjectMethod::ResultType::PERSISTENT_TRUE )
{
CAF_PDM_InitObject( "Get Well Path Collection", "", "", "Get Well Path Collection" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::expected<caf::PdmObjectHandle*, QString> RimProject_wellPathCollection::execute()
{
auto wellPathCollection = RimTools::wellPathCollection();
if ( !wellPathCollection )
{
return std::unexpected( "No well path collection found." );
}
return wellPathCollection;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimProject_wellPathCollection::classKeywordReturnedType() const
{
return RimWellPathCollection::classKeywordStatic();
}
@@ -99,3 +99,17 @@ private:
caf::PdmField<QString> m_zcornKey;
caf::PdmField<QString> m_actnumKey;
};
//==================================================================================================
///
//==================================================================================================
class RimProject_wellPathCollection : public caf::PdmObjectMethod
{
CAF_PDM_HEADER_INIT;
public:
RimProject_wellPathCollection( caf::PdmObjectHandle* self );
std::expected<caf::PdmObjectHandle*, QString> execute() override;
QString classKeywordReturnedType() const override;
};
@@ -0,0 +1,79 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 Equinor 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 "RimcWellPathCollection.h"
#include "RimWellPath.h"
#include "RimWellPathCollection.h"
#include "WellPathCommands/RicImportWellPaths.h"
#include "cafPdmFieldScriptingCapability.h"
CAF_PDM_OBJECT_METHOD_SOURCE_INIT( RimWellPathCollection, RimcWellPathCollection_importWellPath, "ImportWellPath" );
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RimcWellPathCollection_importWellPath::RimcWellPathCollection_importWellPath( caf::PdmObjectHandle* self )
: caf::PdmObjectCreationMethod( self )
{
CAF_PDM_InitObject( "Import Well Path" );
CAF_PDM_InitScriptableFieldNoDefault( &m_fileName, "FileName", "File Name" );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::expected<caf::PdmObjectHandle*, QString> RimcWellPathCollection_importWellPath::execute()
{
auto wellPathCollection = self<RimWellPathCollection>();
if ( !wellPathCollection )
{
return std::unexpected( QString( "Well path collection is null. Cannot add well path." ) );
}
if ( m_fileName().isEmpty() )
{
return std::unexpected( QString( "File name is empty. Cannot add well path." ) );
}
QStringList errorMessages;
std::vector<RimWellPath*> importedWellPaths = wellPathCollection->addWellPaths( { m_fileName() }, &errorMessages );
if ( importedWellPaths.empty() )
{
if ( !errorMessages.empty() )
{
return std::unexpected( errorMessages.join( "\n" ) );
}
else
{
return std::unexpected( QString( "No well paths were imported from file '%1'." ).arg( m_fileName() ) );
}
}
return importedWellPaths.front();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimcWellPathCollection_importWellPath::classKeywordReturnedType() const
{
return RimWellPath::classKeywordStatic();
}
@@ -0,0 +1,42 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2025 Equinor 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.
//
/////////////////////////////////////////////////////////////////////////////////
#pragma once
#include "cafPdmField.h"
#include "cafPdmObjectHandle.h"
#include "cafPdmObjectMethod.h"
#include <QString>
//==================================================================================================
///
//==================================================================================================
class RimcWellPathCollection_importWellPath : public caf::PdmObjectCreationMethod
{
CAF_PDM_HEADER_INIT;
public:
RimcWellPathCollection_importWellPath( caf::PdmObjectHandle* self );
std::expected<caf::PdmObjectHandle*, QString> execute() override;
QString classKeywordReturnedType() const override;
private:
caf::PdmField<QString> m_fileName;
};