Files
ResInsight/ApplicationLibCode/Commands/CompletionExportCommands/RicWellPathExportMswTableData.h
T
Magne Sjaastad 8d0c3f340b CompletionExport: Add RicMswBranchBuilder and RicWellPathExportMswGeometryPath
Add new MswExport subdirectory with branch builder and geometry path classes
as part of the simplified MSW export approach. Update CMakeLists to include
the new files and add CompletionExportCommands to the include path.
2026-03-27 14:47:32 +01:00

205 lines
14 KiB
C++

/////////////////////////////////////////////////////////////////////////////////
//
// 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 "RiaDefines.h"
#include "Tools/enum_bitmask.hpp"
#include <gsl/gsl>
#include <expected>
#include <optional>
#include <QDateTime>
class RicMswCompletion;
class RigCompletionData;
class RicMswSegment;
class RicMswExportInfo;
class RicMswBranch;
class RigActiveCellInfo;
class RimEclipseCase;
class RimFishbones;
class RimPerforationInterval;
class RimWellPath;
class RigMswTableData;
class RimWellPathFracture;
class RimMswCompletionParameters;
class RigWellPath;
class RimModeledWellPath;
struct WellPathCellIntersectionInfo;
//--------------------------------------------------------------------------------------------------
/// This class is responsible for exporting well path MSW table data
/// This class is based on RicWellPathExportMswCompletionsImpl
//--------------------------------------------------------------------------------------------------
class RicWellPathExportMswTableData
{
public:
enum class CompletionType
{
NONE = 0x00,
PERFORATIONS = 0x01,
FISHBONES = 0x02,
FRACTURES = 0x04,
ALL = PERFORATIONS | FISHBONES | FRACTURES
};
// The intention is to extract MSW data from a single well. Any handling of multiple wells is supposed to be managed in a different class
static std::expected<RigMswTableData, std::string> extractSingleWellMswData( RimEclipseCase* eclipseCase,
RimWellPath* wellPath,
bool exportCompletionsAfterMainBoreSegments = true,
CompletionType completionType = CompletionType::ALL,
const std::optional<QDateTime>& exportDate = std::nullopt );
static std::expected<RigMswTableData, std::string> extractSingleWellMswDataTree( RimEclipseCase* eclipseCase,
RimWellPath* wellPath,
bool exportCompletionsAfterMainBoreSegments = true,
CompletionType completionType = CompletionType::ALL,
const std::optional<QDateTime>& exportDate = std::nullopt );
static std::expected<RigMswTableData, std::string>
extractSingleWellMswDataGeometry( RimEclipseCase* eclipseCase,
RimWellPath* wellPath,
bool exportCompletionsAfterMainBoreSegments = true,
CompletionType completionType = CompletionType::ALL,
const std::optional<QDateTime>& exportDate = std::nullopt );
static CompletionType convertFromExportSettings( const class RicExportCompletionDataSettingsUi& settings );
static void generateFishbonesMswExportInfoForWell( const RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
RicMswExportInfo* exportInfo,
RicMswBranch* branch );
static std::vector<WellPathCellIntersectionInfo> generateCellSegments( const RimEclipseCase* eclipseCase, const RimWellPath* wellPath );
static std::vector<WellPathCellIntersectionInfo> filterIntersections( const std::vector<WellPathCellIntersectionInfo>& intersections,
double initialMD,
gsl::not_null<const RigWellPath*> wellPathGeometry,
gsl::not_null<const RimEclipseCase*> eclipseCase );
static std::vector<RimWellPath*> wellPathsWithTieIn( const RimWellPath* wellPath );
static double computeIntitialMeasuredDepth( const RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
const RimMswCompletionParameters* mswParameters,
const std::vector<WellPathCellIntersectionInfo>& allIntersections );
private:
static void updateDataForMultipleItemsInSameGridCell( gsl::not_null<RicMswBranch*> branch );
static bool generateWellSegmentsForMswExportInfo( const RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
bool createSegmentsForPerforations,
const std::optional<QDateTime>& exportDate,
double initialMD,
const std::vector<WellPathCellIntersectionInfo>& cellIntersections,
gsl::not_null<RicMswExportInfo*> exportInfo,
gsl::not_null<RicMswBranch*> branch );
static void appendFishbonesMswExportInfo( const RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
double initialMD,
const std::vector<WellPathCellIntersectionInfo>& cellIntersections,
gsl::not_null<RicMswExportInfo*> exportInfo,
gsl::not_null<RicMswBranch*> branch );
static bool appendFracturesMswExportInfo( RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
double initialMD,
const std::vector<WellPathCellIntersectionInfo>& cellIntersections,
gsl::not_null<RicMswExportInfo*> exportInfo,
gsl::not_null<RicMswBranch*> branch );
static std::pair<double, double> calculateOverlapWithActiveCells( double startMD,
double endMD,
const std::vector<WellPathCellIntersectionInfo>& wellPathIntersections,
const RigActiveCellInfo* activeCellInfo );
static void createWellPathSegments( gsl::not_null<RicMswBranch*> branch,
const std::vector<WellPathCellIntersectionInfo>& cellSegmentIntersections,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
const RimWellPath* wellPath,
const std::optional<QDateTime>& exportDate,
const RimEclipseCase* eclipseCase,
bool* foundSubGridIntersections );
static void createValveCompletions( gsl::not_null<RicMswBranch*> branch,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
const RimWellPath* wellPath,
RiaDefines::EclipseUnitSystem unitSystem );
static void assignValveContributionsToSuperXICDs( gsl::not_null<RicMswBranch*> branch,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
const std::vector<WellPathCellIntersectionInfo>& wellPathIntersections,
const RigActiveCellInfo* activeCellInfo,
RiaDefines::EclipseUnitSystem unitSystem );
static void moveIntersectionsToICVs( gsl::not_null<RicMswBranch*> branch,
const std::vector<const RimPerforationInterval*>& perforationIntervals,
RiaDefines::EclipseUnitSystem unitSystem );
static void moveIntersectionsToSuperXICDs( gsl::not_null<RicMswBranch*> branch );
static void assignFishbonesLateralIntersections( const RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
const RimFishbones* fishbonesSubs,
gsl::not_null<RicMswSegment*> segment,
bool* foundSubGridIntersections,
double maxSegmentLength,
RiaDefines::EclipseUnitSystem unitSystem );
static void assignFractureCompletionsToCellSegment( const RimEclipseCase* eclipseCase,
const RimWellPath* wellPath,
const RimWellPathFracture* fracture,
const std::vector<RigCompletionData>& completionData,
gsl::not_null<RicMswSegment*> segment,
bool* foundSubGridIntersections );
static std::vector<RigCompletionData> generatePerforationIntersections( gsl::not_null<const RimWellPath*> wellPath,
gsl::not_null<const RimPerforationInterval*> perforationInterval,
const std::optional<QDateTime>& exportDate,
gsl::not_null<const RimEclipseCase*> eclipseCase );
static void assignPerforationIntersections( const std::vector<RigCompletionData>& completionData,
gsl::not_null<RicMswCompletion*> perforationCompletion,
const WellPathCellIntersectionInfo& cellIntInfo,
double overlapStart,
double overlapEnd,
bool* foundSubGridIntersections );
static void assignBranchNumbersToPerforations( const RimEclipseCase* eclipseCase, gsl::not_null<RicMswSegment*> segment, int branchNumber );
static void assignBranchNumbersToOtherCompletions( const RimEclipseCase* eclipseCase,
gsl::not_null<RicMswSegment*> segment,
gsl::not_null<int*> branchNumber );
static void assignBranchNumbersToBranch( const RimEclipseCase* eclipseCase,
RicMswExportInfo* exportInfo,
gsl::not_null<RicMswBranch*> branch,
gsl::not_null<int*> branchNumber );
static std::unique_ptr<RicMswBranch> createChildMswBranch( const RimWellPath* childWellPath );
};
ENABLE_BITMASK_OPERATORS( RicWellPathExportMswTableData::CompletionType )