mirror of
https://github.com/OPM/ResInsight.git
synced 2026-08-27 05:37:21 -05:00
#12209 Create a new well path based on the geometry of a simulation well
This commit is contained in:
@@ -1,11 +1,13 @@
|
||||
set(SOURCE_GROUP_HEADER_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellFeatureImpl.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellShowFeatures.h
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateWellPathFromSimulationWellFeature.h
|
||||
)
|
||||
|
||||
set(SOURCE_GROUP_SOURCE_FILES
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellFeatureImpl.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicEclipseWellShowFeatures.cpp
|
||||
${CMAKE_CURRENT_LIST_DIR}/RicCreateWellPathFromSimulationWellFeature.cpp
|
||||
)
|
||||
|
||||
list(APPEND COMMAND_CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})
|
||||
|
||||
+150
@@ -0,0 +1,150 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "RicCreateWellPathFromSimulationWellFeature.h"
|
||||
|
||||
#include "RiaColorTables.h"
|
||||
|
||||
#include "RicEclipseWellFeatureImpl.h"
|
||||
|
||||
#include "RimEclipseCase.h"
|
||||
#include "RimModeledWellPath.h"
|
||||
#include "RimProject.h"
|
||||
#include "RimSimWellInView.h"
|
||||
#include "RimSimWellInViewCollection.h"
|
||||
#include "RimTools.h"
|
||||
#include "RimWellPath.h"
|
||||
#include "RimWellPathCollection.h"
|
||||
#include "RimWellPathGeometryDef.h"
|
||||
|
||||
#include "Riu3DMainWindowTools.h"
|
||||
|
||||
#include "Well/RigSimulationWellCenterLineCalculator.h"
|
||||
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <QAction>
|
||||
|
||||
CAF_CMD_SOURCE_INIT( RicCreateWellPathFromSimulationWellFeature, "RicCreateWellPathFromSimulationWellFeature" );
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellPathFromSimulationWellFeature::onActionTriggered( bool isChecked )
|
||||
{
|
||||
auto createWellPathForSimulationWell = []( const RimSimWellInView& simulationWell ) -> std::vector<cvf::Vec3d>
|
||||
{
|
||||
auto simWellCellBranches = simulationWell.wellBranchesForVisualization();
|
||||
const auto& [coords, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWellCellBranches );
|
||||
|
||||
if ( coords.empty() ) return {};
|
||||
|
||||
// Take only the first branch.
|
||||
return coords.front();
|
||||
};
|
||||
|
||||
auto filterWellPathPoints = []( const std::vector<cvf::Vec3d>& wellPathPoints, double distance )
|
||||
{
|
||||
std::vector<cvf::Vec3d> filteredWellPathPoints;
|
||||
if ( wellPathPoints.size() > 2 )
|
||||
{
|
||||
// Always keep first point
|
||||
filteredWellPathPoints.push_back( wellPathPoints.front() );
|
||||
|
||||
// Keep only points that are a given distance apart to get
|
||||
// reasonable number of them in the well path.
|
||||
size_t lastUsedPoint = 0;
|
||||
for ( size_t i = 1; i < wellPathPoints.size() - 1; i++ )
|
||||
{
|
||||
if ( wellPathPoints[lastUsedPoint].pointDistance( wellPathPoints[i] ) > distance )
|
||||
{
|
||||
filteredWellPathPoints.push_back( wellPathPoints[i] );
|
||||
lastUsedPoint = i;
|
||||
}
|
||||
}
|
||||
|
||||
// Always keep last point
|
||||
filteredWellPathPoints.push_back( wellPathPoints.back() );
|
||||
}
|
||||
|
||||
return filteredWellPathPoints;
|
||||
};
|
||||
|
||||
std::vector<RimSimWellInView*> selection = RicEclipseWellFeatureImpl::selectedWells();
|
||||
|
||||
RimProject* project = RimProject::current();
|
||||
if ( !project ) return;
|
||||
|
||||
RimWellPathCollection* wellPathCollection = RimTools::wellPathCollection();
|
||||
if ( !wellPathCollection ) return;
|
||||
|
||||
std::vector<RimWellPath*> newWellPaths;
|
||||
|
||||
size_t numAddedWells = 0;
|
||||
size_t modelledWellpathCount = wellPathCollection->modelledWellPathCount();
|
||||
|
||||
RimModeledWellPath* lastAddedWell = nullptr;
|
||||
for ( const RimSimWellInView* simulationWell : selection )
|
||||
{
|
||||
auto wellPathPoints = createWellPathForSimulationWell( *simulationWell );
|
||||
|
||||
std::vector<cvf::Vec3d> filteredWellPathPoints = filterWellPathPoints( wellPathPoints, 100.0 );
|
||||
|
||||
// Need at least two points to add create a well
|
||||
if ( filteredWellPathPoints.size() > 2 )
|
||||
{
|
||||
auto newModeledWellPath = new RimModeledWellPath();
|
||||
newModeledWellPath->geometryDefinition()->createAndInsertTargets( filteredWellPathPoints );
|
||||
newModeledWellPath->createWellPathGeometry();
|
||||
newModeledWellPath->setUnitSystem( project->commonUnitSystemForAllCases() );
|
||||
|
||||
newModeledWellPath->setWellPathColor(
|
||||
RiaColorTables::editableWellPathsPaletteColors().cycledColor3f( modelledWellpathCount + numAddedWells ) );
|
||||
|
||||
newModeledWellPath->setName( simulationWell->name );
|
||||
newWellPaths.push_back( newModeledWellPath );
|
||||
|
||||
lastAddedWell = newModeledWellPath;
|
||||
numAddedWells++;
|
||||
}
|
||||
}
|
||||
|
||||
wellPathCollection->addWellPaths( newWellPaths );
|
||||
wellPathCollection->uiCapability()->updateConnectedEditors();
|
||||
|
||||
project->scheduleCreateDisplayModelAndRedrawAllViews();
|
||||
|
||||
if ( lastAddedWell ) Riu3DMainWindowTools::selectAsCurrentItem( lastAddedWell->geometryDefinition() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicCreateWellPathFromSimulationWellFeature::setupActionLook( QAction* actionToSetup )
|
||||
{
|
||||
actionToSetup->setText( "Create Well Path" );
|
||||
actionToSetup->setIcon( QIcon( ":/Well.svg" ) );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RicCreateWellPathFromSimulationWellFeature::isCommandEnabled() const
|
||||
{
|
||||
return RicEclipseWellFeatureImpl::isAnyWellSelected();
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
/////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// 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 "cafCmdFeature.h"
|
||||
|
||||
//==================================================================================================
|
||||
///
|
||||
//==================================================================================================
|
||||
class RicCreateWellPathFromSimulationWellFeature : public caf::CmdFeature
|
||||
{
|
||||
CAF_CMD_HEADER_INIT;
|
||||
|
||||
protected:
|
||||
void onActionTriggered( bool isChecked ) override;
|
||||
void setupActionLook( QAction* actionToSetup ) override;
|
||||
bool isCommandEnabled() const override;
|
||||
};
|
||||
@@ -1202,6 +1202,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
|
||||
else if ( dynamic_cast<RimSimWellInView*>( firstUiItem ) )
|
||||
{
|
||||
menuBuilder << "RicShowContributingWellsFeature";
|
||||
menuBuilder << "RicCreateWellPathFromSimulationWellFeature";
|
||||
menuBuilder << "Separator";
|
||||
menuBuilder << "RicEclipseWellShowLabelFeature";
|
||||
menuBuilder << "RicEclipseWellShowHeadFeature";
|
||||
|
||||
Reference in New Issue
Block a user