Refactor classes in RigWellResultPoint.h

* Move RigWellResultFrame implementation into separate file
Update/correct includes accordingly

* First step of moving attributes from public to private
- Move public members to private and create interface
- Single public member remains due to strong dependency on usage of reference and reference to its object public members

* Second step of moving attributes from public to privatee
- Remove usage of reference directly to attributes. Interface with copy and set.
- Moving attributes in RigWellResultFrame and RigWellResultBranch

* Move class RigWellResultBranch into separate file
This commit is contained in:
Jørgen Herje 2023-04-14 11:00:45 +02:00 committed by GitHub
parent dc4d4022d2
commit 457dc9080f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
36 changed files with 653 additions and 999 deletions

View File

@ -44,6 +44,7 @@
#include "RigMainGrid.h"
#include "RigNNCData.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "cafProgressInfo.h"
@ -1553,6 +1554,7 @@ private:
std::set<size_t> m_gridCellsWithSubCellWellConnections;
const RigMainGrid* m_mainGrid;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@ -1616,8 +1618,8 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
{
if ( reportNumbers[i] == reportNr )
{
wellResFrame.m_timestamp = timeSteps[i];
haveFoundTimeStamp = true;
wellResFrame.setTimestamp( timeSteps[i] );
haveFoundTimeStamp = true;
}
}
}
@ -1627,34 +1629,34 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
// This fallback will not work for timesteps before 1970.
// Also see RifEclipseOutputFileAccess::timeStepsText for accessing time_t structures
time_t stepTime = well_state_get_sim_time( ert_well_state );
wellResFrame.m_timestamp = QDateTime::fromSecsSinceEpoch( stepTime );
time_t stepTime = well_state_get_sim_time( ert_well_state );
wellResFrame.setTimestamp( QDateTime::fromSecsSinceEpoch( stepTime ) );
}
// Production type
well_type_enum ert_well_type = well_state_get_type( ert_well_state );
if ( ert_well_type == ECL_WELL_PRODUCER )
{
wellResFrame.m_productionType = RiaDefines::WellProductionType::PRODUCER;
wellResFrame.setProductionType( RiaDefines::WellProductionType::PRODUCER );
}
else if ( ert_well_type == ECL_WELL_WATER_INJECTOR )
{
wellResFrame.m_productionType = RiaDefines::WellProductionType::WATER_INJECTOR;
wellResFrame.setProductionType( RiaDefines::WellProductionType::WATER_INJECTOR );
}
else if ( ert_well_type == ECL_WELL_GAS_INJECTOR )
{
wellResFrame.m_productionType = RiaDefines::WellProductionType::GAS_INJECTOR;
wellResFrame.setProductionType( RiaDefines::WellProductionType::GAS_INJECTOR );
}
else if ( ert_well_type == ECL_WELL_OIL_INJECTOR )
{
wellResFrame.m_productionType = RiaDefines::WellProductionType::OIL_INJECTOR;
wellResFrame.setProductionType( RiaDefines::WellProductionType::OIL_INJECTOR );
}
else
{
wellResFrame.m_productionType = RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE;
wellResFrame.setProductionType( RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE );
}
wellResFrame.m_isOpen = well_state_is_open( ert_well_state );
wellResFrame.setIsOpen( well_state_is_open( ert_well_state ) );
if ( importCompleteMswData && well_state_is_MSW( ert_well_state ) )
{
@ -1678,21 +1680,25 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
const well_conn_type* ert_wellhead = well_state_iget_wellhead( ert_well_state, static_cast<int>( gridNr ) );
if ( ert_wellhead )
{
wellResFrame.m_wellHead = createWellResultPoint( grids[gridNr], ert_wellhead, wellName );
auto wellHead = createWellResultPoint( grids[gridNr], ert_wellhead, wellName );
// HACK: Ert returns open as "this is equally wrong as closed for well heads".
// Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016
wellResFrame.m_wellHead.setIsOpen( false );
wellHead.setIsOpen( false );
wellResFrame.setWellHead( wellHead );
break;
}
}
well_branch_collection_type* branches = well_state_get_branches( ert_well_state );
int branchCount = well_branch_collection_get_size( branches );
wellResFrame.m_wellResultBranches.resize( branchCount );
well_branch_collection_type* branches = well_state_get_branches( ert_well_state );
int branchCount = well_branch_collection_get_size( branches );
std::map<int, std::vector<SegmentPositionContribution>> segmentIdToPositionContrib;
std::vector<int> upperSegmentIdsOfUnpositionedSegementGroup;
// Create copy of well result branches for modification
std::vector<RigWellResultBranch> wellResultBranches = wellResFrame.wellResultBranches();
wellResultBranches.resize( branchCount );
// For each branch, go from bottom segment upwards and transfer their connections to WellResultpoints.
// If they have no connections, create a resultpoint representing their bottom position, which will
// receive an actual position at a later stage.
@ -1700,12 +1706,12 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
for ( int bIdx = 0; bIdx < well_branch_collection_get_size( branches ); bIdx++ )
{
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[bIdx];
RigWellResultBranch& wellResultBranch = wellResultBranches[bIdx];
const well_segment_type* segment = well_branch_collection_iget_start_segment( branches, bIdx );
int branchId = well_segment_get_branch_id( segment );
wellResultBranch.m_ertBranchId = branchId;
int branchId = well_segment_get_branch_id( segment );
wellResultBranch.setErtBranchId( branchId );
// Data for segment position calculation
int lastConnectionSegmentId = -1;
@ -1737,7 +1743,7 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
for ( int connIdx = connectionCount - 1; connIdx >= 0; connIdx-- )
{
well_conn_type* ert_connection = well_conn_collection_iget( connections, connIdx );
wellResultBranch.m_branchResultPoints.push_back(
wellResultBranch.addBranchResultPoint(
createWellResultPoint( grids[gridNr], ert_connection, segment, wellName ) );
}
@ -1769,7 +1775,7 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
RigWellResultPoint data;
data.setSegmentData( branchId, well_segment_get_id( segment ) );
wellResultBranch.m_branchResultPoints.push_back( data );
wellResultBranch.addBranchResultPoint( data );
// Store data for segment position calculation
bool isAnInsolationContribution = accLengthFromLastConnection < lastConnectionCellSize;
@ -1825,7 +1831,7 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
// Clear all flow in this result point
resultPoint.clearAllFlow();
wellResultBranch.m_branchResultPoints.push_back( resultPoint );
wellResultBranch.addBranchResultPoint( resultPoint );
outletSegmentHasConnections = true;
break; // Stop looping over grids
@ -1838,7 +1844,7 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
RigWellResultPoint data;
data.setSegmentData( well_segment_get_branch_id( outletSegment ), well_segment_get_id( outletSegment ) );
wellResultBranch.m_branchResultPoints.push_back( data );
wellResultBranch.addBranchResultPoint( data );
// Store data for segment position calculation,
// and propagate it upwards until we meet a segment with connections
@ -1929,27 +1935,30 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
// The centerline calculations would be a bit simpler, I think.
}
// Reverse the order of the resultpoints in this branch, making the deepest come last
std::reverse( wellResultBranch.m_branchResultPoints.begin(), wellResultBranch.m_branchResultPoints.end() );
// Reverse the order of the result points in this branch, making the deepest come last
auto branchResultPoints = wellResultBranch.branchResultPoints();
std::reverse( branchResultPoints.begin(), branchResultPoints.end() );
wellResultBranch.setBranchResultPoints( branchResultPoints );
} // End of the branch loop
// Set modified copy back to frame
wellResFrame.setWellResultBranches( wellResultBranches );
// Propagate position contributions from connections above unpositioned segments downwards
well_segment_collection_type* allErtSegments = well_state_get_segments( ert_well_state );
for ( size_t bIdx = 0; bIdx < wellResFrame.m_wellResultBranches.size(); ++bIdx )
bool isWellHead = true;
for ( const auto& wellResultBranch : wellResFrame.wellResultBranches() )
{
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[bIdx];
bool previousResultPointWasCell = false;
if ( bIdx == 0 ) previousResultPointWasCell = true; // Wellhead
bool previousResultPointWasCell = isWellHead ? true : false;
// Go downwards until we find a none-cell resultpoint just after a cell-resultpoint
// Go downwards until we find a none-cell result point just after a cell result point
// When we do, start propagating
for ( size_t rpIdx = 0; rpIdx < wellResultBranch.m_branchResultPoints.size(); ++rpIdx )
for ( size_t rpIdx = 0; rpIdx < wellResultBranch.branchResultPoints().size(); ++rpIdx )
{
RigWellResultPoint resPoint = wellResultBranch.m_branchResultPoints[rpIdx];
const RigWellResultPoint resPoint = wellResultBranch.branchResultPoints()[rpIdx];
if ( resPoint.isCell() )
{
previousResultPointWasCell = true;
@ -1959,13 +1968,13 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
if ( previousResultPointWasCell )
{
RigWellResultPoint prevResPoint;
if ( bIdx == 0 && rpIdx == 0 )
if ( isWellHead && rpIdx == 0 )
{
prevResPoint = wellResFrame.m_wellHead;
prevResPoint = wellResFrame.wellHead();
}
else
{
prevResPoint = wellResultBranch.m_branchResultPoints[rpIdx - 1];
prevResPoint = wellResultBranch.branchResultPoints()[rpIdx - 1];
}
cvf::Vec3d lastConnectionPos = grids[prevResPoint.gridIndex()]->cell( prevResPoint.cellIndex() ).center();
@ -1992,6 +2001,8 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
previousResultPointWasCell = false;
}
}
isWellHead = false;
}
// Calculate the bottom position of all the unpositioned segments
@ -2005,21 +2016,22 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
++posContribIt;
}
// Distribute the positions to the resultpoints stored in the wellResultBranch.m_branchResultPoints
// Copy content and distribute the positions to the result points stored in the wellResultBranch.branchResultPoints()
// set updated copy back to frame
for ( size_t bIdx = 0; bIdx < wellResFrame.m_wellResultBranches.size(); ++bIdx )
std::vector<RigWellResultBranch> newWellResultBranches = wellResFrame.wellResultBranches();
for ( auto& wellResultBranch : newWellResultBranches )
{
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[bIdx];
for ( size_t rpIdx = 0; rpIdx < wellResultBranch.m_branchResultPoints.size(); ++rpIdx )
RigWellResultBranch& newWellResultBranch = wellResultBranch;
for ( auto& resultPoint : newWellResultBranch.branchResultPoints() )
{
RigWellResultPoint& resPoint = wellResultBranch.m_branchResultPoints[rpIdx];
if ( !resPoint.isCell() )
if ( !resultPoint.isCell() )
{
resPoint.setBottomPosition( bottomPositions[resPoint.segmentId()] );
resultPoint.setBottomPosition( bottomPositions[resultPoint.segmentId()] );
}
}
}
wellResFrame.setWellResultBranches( newWellResultBranches );
} // End of the MSW section
else
{
@ -2037,7 +2049,7 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
// Well heads are not open jfr mail communication with HHGS and JH Statoil 07.01.2016
wellHeadRp.setIsOpen( false );
if ( !subCellConnCalc.hasSubCellConnection( wellHeadRp ) ) wellResFrame.m_wellHead = wellHeadRp;
if ( !subCellConnCalc.hasSubCellConnection( wellHeadRp ) ) wellResFrame.setWellHead( wellHeadRp );
}
const well_conn_collection_type* connections =
@ -2049,13 +2061,12 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
int connectionCount = well_conn_collection_get_size( connections );
if ( connectionCount )
{
wellResFrame.m_wellResultBranches.push_back( RigWellResultBranch() );
RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches.back();
RigWellResultBranch wellResultBranch;
wellResultBranch.setErtBranchId( 0 ); // Normal wells have only one branch
wellResultBranch.m_ertBranchId = 0; // Normal wells have only one branch
size_t existingCellCount = wellResultBranch.m_branchResultPoints.size();
wellResultBranch.m_branchResultPoints.resize( existingCellCount + connectionCount );
std::vector<RigWellResultPoint> branchResultPoints = wellResultBranch.branchResultPoints();
const size_t existingCellCount = branchResultPoints.size();
branchResultPoints.resize( existingCellCount + connectionCount );
for ( int connIdx = 0; connIdx < connectionCount; connIdx++ )
{
@ -2064,9 +2075,11 @@ void RifReaderEclipseOutput::readWellCells( const ecl_grid_type* mainEclGrid, bo
if ( !subCellConnCalc.hasSubCellConnection( wellRp ) )
{
wellResultBranch.m_branchResultPoints[existingCellCount + connIdx] = wellRp;
branchResultPoints[existingCellCount + connIdx] = wellRp;
}
}
wellResultBranch.setBranchResultPoints( branchResultPoints );
wellResFrame.addWellResultBranch( wellResultBranch );
}
}
}

View File

@ -30,7 +30,7 @@
#include "RigVirtualPerforationTransmissibilities.h"
#include "RigWellLogExtractor.h"
#include "RigWellPath.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "Rim3dView.h"
#include "RimCase.h"
@ -335,15 +335,15 @@ void RivSimWellPipesPartMgr::appendVirtualConnectionFactorGeo( const RimEclipseV
for ( const auto& intersectionInfo : wellPathCellIntersections )
{
size_t globalCellIndex = intersectionInfo.globCellIndex;
const RigWellResultPoint* wResCell = wResFrame->findResultCellWellHeadIncluded( 0, globalCellIndex );
size_t globalCellIndex = intersectionInfo.globCellIndex;
const RigWellResultPoint wResCell = wResFrame->findResultCellWellHeadIncluded( 0, globalCellIndex );
if ( !wResCell || !wResCell->isValid() )
if ( !wResCell.isValid() )
{
continue;
}
if ( !virtualPerforationResult->showConnectionFactorsOnClosedConnections() && !wResCell->isOpen() )
if ( !virtualPerforationResult->showConnectionFactorsOnClosedConnections() && !wResCell.isOpen() )
{
continue;
}
@ -363,7 +363,7 @@ void RivSimWellPipesPartMgr::appendVirtualConnectionFactorGeo( const RimEclipseV
cvf::Vec3d anchor = displayXf->transformToDisplayCoord( domainCoord );
{
CompletionVizData data( anchor, direction, wResCell->connectionFactor(), globalCellIndex );
CompletionVizData data( anchor, direction, wResCell.connectionFactor(), globalCellIndex );
completionVizDataItems.push_back( data );
}
@ -590,20 +590,20 @@ void RivSimWellPipesPartMgr::updatePipeResultColor( size_t frameIndex )
for ( size_t wcIdx = 0; wcIdx < cellIds.size(); ++wcIdx )
{
// we need a faster lookup, I guess
const RigWellResultPoint* wResCell = nullptr;
RigWellResultPoint wResCell;
if ( cellIds[wcIdx].isCell() )
{
wResCell = wResFrame->findResultCellWellHeadExcluded( cellIds[wcIdx].gridIndex(), cellIds[wcIdx].cellIndex() );
}
if ( wResCell )
if ( wResCell.isValid() )
{
double cellState = defaultState;
if ( wResCell->isOpen() )
if ( wResCell.isOpen() )
{
switch ( wResFrame->m_productionType )
switch ( wResFrame->productionType() )
{
case RiaDefines::WellProductionType::PRODUCER:
cellState = producerState;
@ -647,7 +647,7 @@ void RivSimWellPipesPartMgr::updatePipeResultColor( size_t frameIndex )
wellBranch.m_surfaceDrawable->setTextureCoordArray( surfTexCoords.p() );
wellBranch.m_largeSurfaceDrawable->setTextureCoordArray( surfTexCoords.p() );
if ( wResFrame->m_isOpen )
if ( wResFrame->isOpen() )
{
// Use slightly larger geometry for open wells to avoid z-fighting when two wells are located at the
// same position

View File

@ -28,7 +28,7 @@
#include "RigFlowDiagResults.h"
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "cafDisplayCoordTransform.h"
#include "cafEffectGenerator.h"
@ -65,11 +65,11 @@ void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBas
if ( !m_rimReservoirView->eclipseCase() ) return;
if ( !m_rimWell->showWell() ) return;
if ( !m_rimWell->simWellData()->hasWellResult( frameIndex ) ) return;
if ( !m_rimWell->simWellData()->wellResultFrame( frameIndex )->m_isOpen ) return;
if ( m_rimWell->simWellData()->wellResultFrame( frameIndex )->m_productionType == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
if ( !m_rimWell->simWellData()->wellResultFrame( frameIndex )->isOpen() ) return;
if ( m_rimWell->simWellData()->wellResultFrame( frameIndex )->productionType() == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
return;
bool isProducer = ( m_rimWell->simWellData()->wellResultFrame( frameIndex )->m_productionType == RiaDefines::WellProductionType::PRODUCER );
bool isProducer = ( m_rimWell->simWellData()->wellResultFrame( frameIndex )->productionType() == RiaDefines::WellProductionType::PRODUCER );
double pipeRadius = m_rimWell->pipeRadius();
cvf::Vec3d wellHeadTop;
@ -132,13 +132,13 @@ void RivWellConnectionsPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBas
{
if ( otherWell == m_rimWell ) continue;
if ( !otherWell->simWellData()->hasWellResult( frameIndex ) ) continue;
if ( !otherWell->simWellData()->wellResultFrame( frameIndex )->m_isOpen ) continue;
if ( otherWell->simWellData()->wellResultFrame( frameIndex )->m_productionType ==
if ( !otherWell->simWellData()->wellResultFrame( frameIndex )->isOpen() ) continue;
if ( otherWell->simWellData()->wellResultFrame( frameIndex )->productionType() ==
RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
continue;
bool isOtherProducer =
( otherWell->simWellData()->wellResultFrame( frameIndex )->m_productionType == RiaDefines::WellProductionType::PRODUCER );
( otherWell->simWellData()->wellResultFrame( frameIndex )->productionType() == RiaDefines::WellProductionType::PRODUCER );
{
std::string otherWellName = otherWell->name().toStdString();

View File

@ -35,7 +35,6 @@ class DrawableGeo;
class Part;
} // namespace cvf
class RigWellResultFrame;
class RimEclipseView;
class RimSimWellInView;
class RivPipeGeometryGenerator;

View File

@ -24,7 +24,7 @@
#include "RigActiveCellInfo.h"
#include "RigCell.h"
#include "RigSimWellData.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
@ -99,7 +99,7 @@ void RivWellDiskPartMgr::buildWellDiskParts( size_t frameIndex, const caf::Displ
if ( !well->simWellData()->hasWellResult( frameIndex ) ) return;
auto productionType = well->simWellData()->wellResultFrame( frameIndex )->m_productionType;
auto productionType = well->simWellData()->wellResultFrame( frameIndex )->productionType();
double pipeRadius = m_rimWell->pipeRadius();
unsigned int numSectors = 100;

View File

@ -46,7 +46,6 @@ enum class WellProductionType : short;
class Rim3dView;
class RimSimWellInView;
class RimSimWellInViewCollection;
class RigWellResultFrame;
class RivWellDiskPartMgr : public cvf::Object
{

View File

@ -27,7 +27,7 @@
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
@ -110,7 +110,7 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ
double pipeRadius = m_rimWell->pipeRadius();
int pipeCrossSectionVxCount = m_rimWell->pipeCrossSectionVertexCount();
if ( wellResultFrame->m_isOpen )
if ( wellResultFrame->isOpen() )
{
// Use slightly larger well head arrow when well is open
pipeRadius *= 1.1;
@ -178,7 +178,7 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ
double arrowLength = characteristicCellSize * simWellInViewCollection()->wellHeadScaleFactor() * m_rimWell->wellHeadScaleFactor();
if ( wellResultFrame->m_isOpen )
if ( wellResultFrame->isOpen() )
{
// Use slightly larger well head arrow when well is open
arrowLength = 1.1 * arrowLength;
@ -188,13 +188,13 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ
textPosition.z() += 1.2 * arrowLength;
cvf::Mat4f matr;
if ( wellResultFrame->m_productionType != RiaDefines::WellProductionType::PRODUCER )
if ( wellResultFrame->productionType() != RiaDefines::WellProductionType::PRODUCER )
{
matr = cvf::Mat4f::fromRotation( cvf::Vec3f( 1.0f, 0.0f, 0.0f ), cvf::Math::toRadians( 180.0f ) );
}
double ijScaleFactor = arrowLength / 6;
if ( wellResultFrame->m_isOpen )
if ( wellResultFrame->isOpen() )
{
ijScaleFactor *= 1.1;
}
@ -202,7 +202,7 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ
matr( 1, 1 ) *= ijScaleFactor;
matr( 2, 2 ) *= arrowLength;
if ( wellResultFrame->m_productionType != RiaDefines::WellProductionType::PRODUCER )
if ( wellResultFrame->productionType() != RiaDefines::WellProductionType::PRODUCER )
{
arrowPosition.z() += arrowLength;
}
@ -248,21 +248,21 @@ void RivWellHeadPartMgr::buildWellHeadParts( size_t frameIndex, const caf::Displ
if ( wellColl && wellColl->showConnectionStatusColors() )
{
if ( wellResultFrame->m_isOpen )
if ( wellResultFrame->isOpen() )
{
if ( wellResultFrame->m_productionType == RiaDefines::WellProductionType::PRODUCER )
if ( wellResultFrame->productionType() == RiaDefines::WellProductionType::PRODUCER )
{
headColor = cvf::Color4f( cvf::Color3::GREEN );
}
else if ( wellResultFrame->m_productionType == RiaDefines::WellProductionType::OIL_INJECTOR )
else if ( wellResultFrame->productionType() == RiaDefines::WellProductionType::OIL_INJECTOR )
{
headColor = cvf::Color4f( cvf::Color3::ORANGE );
}
else if ( wellResultFrame->m_productionType == RiaDefines::WellProductionType::GAS_INJECTOR )
else if ( wellResultFrame->productionType() == RiaDefines::WellProductionType::GAS_INJECTOR )
{
headColor = cvf::Color4f( cvf::Color3::RED );
}
else if ( wellResultFrame->m_productionType == RiaDefines::WellProductionType::WATER_INJECTOR )
else if ( wellResultFrame->productionType() == RiaDefines::WellProductionType::WATER_INJECTOR )
{
headColor = cvf::Color4f( cvf::Color3::BLUE );
}

View File

@ -22,6 +22,7 @@
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "RimEclipseCase.h"
@ -84,9 +85,9 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicLi
std::vector<std::pair<cvf::Vec3f, cvf::Color3f>> centerColorPairs;
for ( const RigWellResultBranch& wellResultBranch : wellResultFrame->m_wellResultBranches )
for ( const RigWellResultBranch& wellResultBranch : wellResultFrame->wellResultBranches() )
{
for ( const RigWellResultPoint& wellResultPoint : wellResultBranch.m_branchResultPoints )
for ( const RigWellResultPoint& wellResultPoint : wellResultBranch.branchResultPoints() )
{
size_t gridIndex = wellResultPoint.gridIndex();
@ -111,7 +112,7 @@ void RivWellSpheresPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicLi
if ( !centerColorPairs.empty() )
{
cvf::ref<cvf::Part> part = createPart( centerColorPairs, wellResultFrame->m_isOpen );
cvf::ref<cvf::Part> part = createPart( centerColorPairs, wellResultFrame->isOpen() );
model->addPart( part.p() );
}
}
@ -209,7 +210,7 @@ cvf::Color3f RivWellSpheresPartMgr::wellCellColor( const RigWellResultFrame* wel
{
if ( wellResultPoint.isOpen() )
{
switch ( wellResultFrame->m_productionType )
switch ( wellResultFrame->productionType() )
{
case RiaDefines::WellProductionType::PRODUCER:
cellColor = cvf::Color3f::GREEN;

View File

@ -24,6 +24,7 @@
#include "RigFlowDiagResults.h"
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "RimEclipseResultCase.h"
@ -178,8 +179,8 @@ std::map<std::string, std::vector<int>> RimFlowDiagSolution::allTracerActiveCell
if ( !simWellData[wIdx]->hasWellResult( timeStepIndex ) ) continue;
const RigWellResultFrame* wellResFrame = simWellData[wIdx]->wellResultFrame( timeStepIndex );
bool isInjectorWell = ( wellResFrame->m_productionType != RiaDefines::WellProductionType::PRODUCER &&
wellResFrame->m_productionType != RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE );
bool isInjectorWell = ( wellResFrame->productionType() != RiaDefines::WellProductionType::PRODUCER &&
wellResFrame->productionType() != RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE );
std::string wellName = simWellData[wIdx]->m_wellName.toStdString();
std::string wellNameXf = addCrossFlowEnding( simWellData[wIdx]->m_wellName ).toStdString();
@ -187,9 +188,9 @@ std::map<std::string, std::vector<int>> RimFlowDiagSolution::allTracerActiveCell
std::vector<int>& tracerCells = tracersWithCells[wellName];
std::vector<int>& tracerCellsCrossFlow = tracersWithCells[wellNameXf];
for ( const RigWellResultBranch& wBr : wellResFrame->m_wellResultBranches )
for ( const RigWellResultBranch& wBr : wellResFrame->wellResultBranches() )
{
for ( const RigWellResultPoint& wrp : wBr.m_branchResultPoints )
for ( const RigWellResultPoint& wrp : wBr.branchResultPoints() )
{
if ( wrp.isValid() && wrp.isOpen() &&
( ( useInjectors && wrp.flowRate() < 0.0 ) || ( !useInjectors && wrp.flowRate() > 0.0 ) ) )
@ -241,14 +242,14 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusOverall(
tracerStatus = TracerStatusType::CLOSED;
for ( const RigWellResultFrame& wellResFrame : simWellData[wIdx]->m_wellCellsTimeSteps )
{
if ( RiaDefines::isInjector( wellResFrame.m_productionType ) )
if ( RiaDefines::isInjector( wellResFrame.productionType() ) )
{
if ( tracerStatus == TracerStatusType::PRODUCER )
tracerStatus = TracerStatusType::VARYING;
else
tracerStatus = TracerStatusType::INJECTOR;
}
else if ( wellResFrame.m_productionType == RiaDefines::WellProductionType::PRODUCER )
else if ( wellResFrame.productionType() == RiaDefines::WellProductionType::PRODUCER )
{
if ( tracerStatus == TracerStatusType::INJECTOR )
tracerStatus = TracerStatusType::VARYING;
@ -294,14 +295,14 @@ RimFlowDiagSolution::TracerStatusType RimFlowDiagSolution::tracerStatusInTimeSte
const RigWellResultFrame* wellResFrame = simWellData[wIdx]->wellResultFrame( timeStepIndex );
if ( RiaDefines::isInjector( wellResFrame->m_productionType ) )
if ( RiaDefines::isInjector( wellResFrame->productionType() ) )
{
if ( hasCrossFlowEnding( tracerName ) ) return TracerStatusType::PRODUCER;
return TracerStatusType::INJECTOR;
}
else if ( wellResFrame->m_productionType == RiaDefines::WellProductionType::PRODUCER ||
wellResFrame->m_productionType == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
else if ( wellResFrame->productionType() == RiaDefines::WellProductionType::PRODUCER ||
wellResFrame->productionType() == RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
{
if ( hasCrossFlowEnding( tracerName ) ) return TracerStatusType::INJECTOR;

View File

@ -28,7 +28,7 @@
#include "RigSimWellData.h"
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigSimulationWellCoordsAndMD.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseCaseTools.h"
@ -501,7 +501,7 @@ QString RimWellAllocationPlot::wellStatusTextForTimeStep( const QString& wellNam
{
const RigWellResultFrame* wellResultFrame = simWellData->wellResultFrame( timeStep );
RiaDefines::WellProductionType prodType = wellResultFrame->m_productionType;
RiaDefines::WellProductionType prodType = wellResultFrame->productionType();
switch ( prodType )
{

View File

@ -27,6 +27,7 @@
#include "RigSimWellData.h"
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigWellAllocationOverTime.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCaseTools.h"
#include "RimEclipseCellColors.h"

View File

@ -34,6 +34,7 @@
#include "RigSimWellData.h"
#include "RigWellLogExtractor.h"
#include "RigWellPath.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "RimDataSourceForRftPlt.h"
@ -409,9 +410,9 @@ public:
const RigMainGrid* mainGrid = eclCase->eclipseCaseData()->mainGrid();
for ( size_t brIdx = 0; brIdx < resFrame->m_wellResultBranches.size(); ++brIdx )
for ( size_t brIdx = 0; brIdx < resFrame->wellResultBranches().size(); ++brIdx )
{
const std::vector<RigWellResultPoint>& branchResPoints = resFrame->m_wellResultBranches[brIdx].m_branchResultPoints;
const std::vector<RigWellResultPoint> branchResPoints = resFrame->branchResultPointsFromBranchIndex( brIdx );
for ( size_t wrpIdx = 0; wrpIdx < branchResPoints.size(); wrpIdx++ )
{
const RigGridBase* grid = mainGrid->gridByIndex( branchResPoints[wrpIdx].gridIndex() );
@ -447,9 +448,9 @@ public:
m_pipeBranchCLCoords.push_back( intersections[wpExIdx].endPoint );
m_pipeBranchMeasuredDepths.push_back( intersections[wpExIdx].endMD );
const RigWellResultPoint& resPoint = resFrame->m_wellResultBranches[it->second.first].m_branchResultPoints[it->second.second];
const RigWellResultPoint resPoint = resFrame->branchResultPointsFromBranchIndex( it->second.first )[it->second.second];
m_pipeBranchWellResultPoints.push_back( resPoint );
if ( wpExIdx < intersections.size() - 1 )
{
m_pipeBranchWellResultPoints.push_back( RigWellResultPoint() ); // Invalid res point describing the

View File

@ -42,7 +42,7 @@
#include "RigNNCData.h"
#include "RigSimWellData.h"
#include "RigVirtualPerforationTransmissibilities.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "Rim2dIntersectionViewCollection.h"
#include "RimCaseCollection.h"
@ -426,9 +426,9 @@ const RigVirtualPerforationTransmissibilities* RimEclipseCase::computeAndGetVirt
if ( wellRes->hasWellResult( i ) )
{
for ( const auto& wellResultBranch : wellRes->wellResultFrame( i )->m_wellResultBranches )
for ( const auto& wellResultBranch : wellRes->wellResultFrame( i )->wellResultBranches() )
{
for ( const auto& r : wellResultBranch.m_branchResultPoints )
for ( const auto& r : wellResultBranch.branchResultPoints() )
{
if ( r.isCell() )
{

View File

@ -38,6 +38,7 @@
#include "RigResultAccessorFactory.h"
#include "RigSimWellData.h"
#include "RigVirtualPerforationTransmissibilities.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "Rim2dIntersectionView.h"
@ -1689,24 +1690,21 @@ void RimEclipseView::calculateVisibleWellCellsIncFence( cvf::UByteArray* visible
if ( !simWellData ) continue;
const std::vector<RigWellResultFrame>& wellResFrames = simWellData->m_wellCellsTimeSteps;
for ( size_t wfIdx = 0; wfIdx < wellResFrames.size(); ++wfIdx )
for ( const auto& frame : wellResFrames )
{
// Add all the cells from the branches
const std::vector<RigWellResultBranch>& wellResSegments = wellResFrames[wfIdx].m_wellResultBranches;
for ( size_t wsIdx = 0; wsIdx < wellResSegments.size(); ++wsIdx )
for ( const auto& segment : frame.wellResultBranches() )
{
const std::vector<RigWellResultPoint>& wsResCells = wellResSegments[wsIdx].m_branchResultPoints;
for ( size_t cIdx = 0; cIdx < wsResCells.size(); ++cIdx )
for ( const auto& cell : segment.branchResultPoints() )
{
if ( wsResCells[cIdx].gridIndex() == grid->gridIndex() )
if ( cell.gridIndex() == grid->gridIndex() )
{
if ( !wsResCells[cIdx].isCell() )
if ( !cell.isCell() )
{
continue;
}
size_t gridCellIndex = wsResCells[cIdx].cellIndex();
size_t gridCellIndex = cell.cellIndex();
( *visibleCells )[gridCellIndex] = true;
// Calculate well fence cells

View File

@ -28,6 +28,7 @@
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigSimulationWellCenterLineCalculator.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "Rim2dIntersectionView.h"
@ -331,8 +332,8 @@ bool RimSimWellInView::intersectsWellCellsFilteredCells( const RigWellResultFram
// First check the wellhead:
size_t gridIndex = wrsf->m_wellHead.gridIndex();
size_t gridCellIndex = wrsf->m_wellHead.cellIndex();
size_t gridIndex = wrsf->wellHead().gridIndex();
size_t gridCellIndex = wrsf->wellHead().cellIndex();
if ( gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T )
{
@ -345,11 +346,10 @@ bool RimSimWellInView::intersectsWellCellsFilteredCells( const RigWellResultFram
// Then check the rest of the well, with all the branches
const std::vector<RigWellResultBranch>& wellResSegments = wrsf->m_wellResultBranches;
const std::vector<RigWellResultBranch> wellResSegments = wrsf->wellResultBranches();
for ( const RigWellResultBranch& branchSegment : wellResSegments )
{
const std::vector<RigWellResultPoint>& wsResCells = branchSegment.m_branchResultPoints;
for ( const RigWellResultPoint& wellResultPoint : wsResCells )
for ( const RigWellResultPoint& wellResultPoint : branchSegment.branchResultPoints() )
{
if ( wellResultPoint.isCell() )
{

View File

@ -38,7 +38,6 @@
class RigSimWellData;
class RigWellResultFrame;
struct RigWellResultPoint;
class RimSimWellFractureCollection;
class RigWellPath;

View File

@ -25,7 +25,7 @@
#include "RigEclipseCaseData.h"
#include "RigSimWellData.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseContourMapView.h"
@ -308,9 +308,9 @@ bool RimSimWellInViewCollection::hasVisibleWellCells()
for ( size_t tIdx = 0; !hasCells && tIdx < well->simWellData()->m_wellCellsTimeSteps.size(); ++tIdx )
{
const RigWellResultFrame& wellResultFrame = well->simWellData()->m_wellCellsTimeSteps[tIdx];
for ( size_t wsIdx = 0; !hasCells && wsIdx < wellResultFrame.m_wellResultBranches.size(); ++wsIdx )
for ( size_t wsIdx = 0; !hasCells && wsIdx < wellResultFrame.wellResultBranches().size(); ++wsIdx )
{
if ( wellResultFrame.m_wellResultBranches[wsIdx].m_branchResultPoints.size() > 0 ) hasCells = true;
if ( !wellResultFrame.branchResultPointsFromBranchIndex( wsIdx ).empty() ) hasCells = true;
}
}
}

View File

@ -25,7 +25,7 @@
#include "RifSummaryReaderInterface.h"
#include "RigSimWellData.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "Rim3dView.h"
#include "RimEclipseResultCase.h"
@ -96,7 +96,7 @@ bool RimSimWellInViewTools::isInjector( RimSimWellInView* well )
{
const RigWellResultFrame* wrf = wRes->wellResultFrame( currentTimeStep );
if ( RiaDefines::isInjector( wrf->m_productionType ) )
if ( RiaDefines::isInjector( wrf->productionType() ) )
{
return true;
}
@ -123,7 +123,7 @@ bool RimSimWellInViewTools::isProducer( RimSimWellInView* well )
{
const RigWellResultFrame* wrf = wRes->wellResultFrame( currentTimeStep );
if ( RiaDefines::WellProductionType::PRODUCER == wrf->m_productionType )
if ( RiaDefines::WellProductionType::PRODUCER == wrf->productionType() )
{
return true;
}

View File

@ -28,7 +28,7 @@
#include "RigResultAccessorFactory.h"
#include "RigSimWellData.h"
#include "RigTracerPoint.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseInputCase.h"
@ -405,18 +405,18 @@ void RimStreamlineInViewCollection::findStartCells( int
auto frame = swdata->wellResultFrame( timeIdx );
for ( auto& branch : frame->m_wellResultBranches )
for ( const auto& branch : frame->wellResultBranches() )
{
for ( const auto& point : branch.m_branchResultPoints )
for ( const auto& point : branch.branchResultPoints() )
{
if ( point.isValid() && point.isOpen() )
{
RigCell cell = grids[point.gridIndex()]->cell( point.cellIndex() );
if ( frame->m_productionType == RiaDefines::WellProductionType::PRODUCER )
if ( frame->productionType() == RiaDefines::WellProductionType::PRODUCER )
{
outProducerCells.push_back( std::pair<QString, RigCell>( swdata->m_wellName, cell ) );
}
else if ( frame->m_productionType != RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
else if ( frame->productionType() != RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
{
outInjectorCells.push_back( std::pair<QString, RigCell>( swdata->m_wellName, cell ) );
}

View File

@ -90,6 +90,8 @@ set(SOURCE_GROUP_HEADER_FILES
${CMAKE_CURRENT_LIST_DIR}/RigPressureDepthData.h
${CMAKE_CURRENT_LIST_DIR}/RigMswCenterLineCalculator.h
${CMAKE_CURRENT_LIST_DIR}/RigWellAllocationOverTime.h
${CMAKE_CURRENT_LIST_DIR}/RigWellResultBranch.h
${CMAKE_CURRENT_LIST_DIR}/RigWellResultFrame.h
)
set(SOURCE_GROUP_SOURCE_FILES
@ -177,6 +179,8 @@ set(SOURCE_GROUP_SOURCE_FILES
${CMAKE_CURRENT_LIST_DIR}/RigPressureDepthData.cpp
${CMAKE_CURRENT_LIST_DIR}/RigMswCenterLineCalculator.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellAllocationOverTime.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellResultBranch.cpp
${CMAKE_CURRENT_LIST_DIR}/RigWellResultFrame.cpp
)
list(APPEND CODE_HEADER_FILES ${SOURCE_GROUP_HEADER_FILES})

View File

@ -33,6 +33,7 @@
#include "RigSimulationWellCoordsAndMD.h"
#include "RigVirtualPerforationTransmissibilities.h"
#include "RigWellPath.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include <QDebug>
@ -241,22 +242,17 @@ void RigEclipseCaseData::computeWellCellsPrGrid()
RigWellResultFrame& wellCells = m_simWellData[wIdx]->m_wellCellsTimeSteps[tIdx];
// Well result branches
for ( size_t sIdx = 0; sIdx < wellCells.m_wellResultBranches.size(); ++sIdx )
for ( const auto& wellSegment : wellCells.wellResultBranches() )
{
RigWellResultBranch& wellSegment = wellCells.m_wellResultBranches[sIdx];
size_t cdIdx;
for ( cdIdx = 0; cdIdx < wellSegment.m_branchResultPoints.size(); ++cdIdx )
for ( const auto& resultPoint : wellSegment.branchResultPoints() )
{
size_t gridIndex = wellSegment.m_branchResultPoints[cdIdx].gridIndex();
size_t gridCellIndex = wellSegment.m_branchResultPoints[cdIdx].cellIndex();
size_t gridIndex = resultPoint.gridIndex();
size_t gridCellIndex = resultPoint.cellIndex();
if ( gridIndex < m_wellCellsInGrid.size() && gridCellIndex < m_wellCellsInGrid[gridIndex]->size() )
{
// NOTE : We do not check if the grid cell is active as we do for well head.
// If we add test for active cell, thorough testing and verification of the new behaviour must
// be adressed
// If we add test for active cell, thorough testing and verification of the new behavior must
// be addressed
m_wellCellsInGrid[gridIndex]->set( gridCellIndex, true );
m_gridCellToResultWellIndex[gridIndex]->set( gridCellIndex, static_cast<cvf::uint>( wIdx ) );
}

View File

@ -25,6 +25,7 @@
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
@ -80,8 +81,8 @@ std::vector<SimulationWellCellBranch>
wellFramePtr = wellResults->wellResultFrame( timeStepIndex );
}
const RigWellResultFrame& wellFrame = *wellFramePtr;
const std::vector<RigWellResultBranch>& resultBranches = wellFrame.m_wellResultBranches;
const RigWellResultFrame& wellFrame = *wellFramePtr;
const std::vector<RigWellResultBranch> resultBranches = wellFrame.wellResultBranches();
std::vector<WellBranch> wellBranches = mergeShortBranchesIntoLongBranches( resultBranches );
@ -89,18 +90,18 @@ std::vector<SimulationWellCellBranch>
for ( const auto& resultBranch : resultBranches )
{
if ( resultBranch.m_branchResultPoints.empty() ) continue;
if ( resultBranch.branchResultPoints().empty() ) continue;
const auto firstResultPoint = resultBranch.m_branchResultPoints.front();
const RigWellResultPoint firstResultPoint = resultBranch.branchResultPoints().front();
for ( auto& wellBranch : wellBranches )
{
if ( wellBranch.m_branchId == resultBranch.m_ertBranchId )
if ( wellBranch.m_branchId == resultBranch.ertBranchId() )
{
if ( firstResultPoint.branchId() == resultBranch.m_ertBranchId )
if ( firstResultPoint.branchId() == resultBranch.ertBranchId() )
{
// The first result point is on the same branch, use well head as outlet
RigWellResultPoint outletResultPoint = wellFrame.m_wellHead;
RigWellResultPoint outletResultPoint = wellFrame.wellHead();
auto gridAndCellIndex = std::make_pair( outletResultPoint.gridIndex(), outletResultPoint.cellIndex() );
wellBranch.m_segmentsWithGridCells[outletResultPoint.segmentId()].push_back( gridAndCellIndex );
@ -157,7 +158,7 @@ std::vector<SimulationWellCellBranch>
RigWellResultPoint resPoint;
for ( const auto& resBranch : resultBranches )
{
for ( const auto& respoint : resBranch.m_branchResultPoints )
for ( const auto& respoint : resBranch.branchResultPoints() )
{
if ( respoint.segmentId() == firstSegment )
{
@ -301,9 +302,9 @@ std::vector<RigMswCenterLineCalculator::WellBranch>
for ( const auto& resultBranch : resBranches )
{
WellBranch branch;
branch.m_branchId = resultBranch.m_ertBranchId;
branch.m_branchId = resultBranch.ertBranchId();
for ( const auto& resPoint : resultBranch.m_branchResultPoints )
for ( const auto& resPoint : resultBranch.branchResultPoints() )
{
size_t gridIndex = resPoint.gridIndex();
size_t gridCellIndex = resPoint.cellIndex();
@ -318,7 +319,7 @@ std::vector<RigMswCenterLineCalculator::WellBranch>
}
const int resultPointThreshold = 3;
if ( resultBranch.m_branchResultPoints.size() > resultPointThreshold )
if ( resultBranch.branchResultPoints().size() > resultPointThreshold )
{
longWellBranches.push_back( branch );
}

View File

@ -18,7 +18,7 @@
#pragma once
#include "RigWellResultPoint.h"
#include "RigWellResultBranch.h"
#include "cvfVector3.h"

View File

@ -26,9 +26,10 @@
#include "RigMainGrid.h"
#include "RigNNCData.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
/* rand example: guess the number */
#include "RigWellResultPoint.h"
#include <cstdio>
#include <cstdlib>
#include <ctime>
@ -393,11 +394,13 @@ void RigReservoirBuilderMock::addWellData( RigEclipseCaseData* eclipseCase, RigG
{
RigWellResultFrame& wellCells = wellCellsTimeHistory->m_wellCellsTimeSteps[timeIdx];
wellCells.m_productionType = RiaDefines::WellProductionType::PRODUCER;
wellCells.m_isOpen = true;
wellCells.setProductionType( RiaDefines::WellProductionType::PRODUCER );
wellCells.setIsOpen( true );
wellCells.m_wellHead.setGridIndex( 0 );
wellCells.m_wellHead.setGridCellIndex( grid->cellIndexFromIJK( 1, 0, 0 ) );
auto wellHead = wellCells.wellHead();
wellHead.setGridIndex( 0 );
wellHead.setGridCellIndex( grid->cellIndexFromIJK( 1, 0, 0 ) );
wellCells.setWellHead( wellHead );
// Connections
// int connectionCount = std::min(dim.x(), std::min(dim.y(), dim.z())) - 2;
@ -405,8 +408,9 @@ void RigReservoirBuilderMock::addWellData( RigEclipseCaseData* eclipseCase, RigG
if ( connectionCount > 0 )
{
// Only main grid supported by now. Must be taken care of when LGRs are supported
wellCells.m_wellResultBranches.resize( 1 );
RigWellResultBranch& wellSegment = wellCells.m_wellResultBranches[0];
auto newWellResultBranches = wellCells.wellResultBranches();
newWellResultBranches.resize( 1 );
RigWellResultBranch& wellSegment = newWellResultBranches[0];
size_t connIdx;
for ( connIdx = 0; connIdx < connectionCount; connIdx++ )
@ -430,10 +434,9 @@ void RigReservoirBuilderMock::addWellData( RigEclipseCaseData* eclipseCase, RigG
data.setIsOpen( false );
}
if ( wellSegment.m_branchResultPoints.size() == 0 ||
wellSegment.m_branchResultPoints.back().cellIndex() != data.cellIndex() )
if ( wellSegment.branchResultPoints().empty() || wellSegment.branchResultPoints().back().cellIndex() != data.cellIndex() )
{
wellSegment.m_branchResultPoints.push_back( data );
wellSegment.addBranchResultPoint( data );
if ( connIdx == connectionCount / 2 )
{
@ -445,13 +448,13 @@ void RigReservoirBuilderMock::addWellData( RigEclipseCaseData* eclipseCase, RigG
deadEndData1.setGridCellIndex( data.cellIndex() + 2 );
deadEndData1.setIsOpen( false );
wellSegment.m_branchResultPoints.push_back( deadEndData );
wellSegment.m_branchResultPoints.push_back( deadEndData1 );
wellSegment.addBranchResultPoint( deadEndData );
wellSegment.addBranchResultPoint( deadEndData1 );
wellSegment.m_branchResultPoints.push_back( deadEndData );
wellSegment.addBranchResultPoint( deadEndData );
data.setIsOpen( true );
wellSegment.m_branchResultPoints.push_back( data );
wellSegment.addBranchResultPoint( data );
}
}
@ -459,13 +462,14 @@ void RigReservoirBuilderMock::addWellData( RigEclipseCaseData* eclipseCase, RigG
{
data.setGridCellIndex( grid->cellIndexFromIJK( 1, 1 + connIdx, 2 + connIdx ) );
if ( wellSegment.m_branchResultPoints.size() == 0 ||
wellSegment.m_branchResultPoints.back().cellIndex() != data.cellIndex() )
if ( wellSegment.branchResultPoints().empty() ||
wellSegment.branchResultPoints().back().cellIndex() != data.cellIndex() )
{
wellSegment.m_branchResultPoints.push_back( data );
wellSegment.addBranchResultPoint( data );
}
}
}
wellCells.setWellResultBranches( newWellResultBranches );
}
}

View File

@ -17,6 +17,7 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include <map>
@ -60,7 +61,7 @@ void RigSimWellData::computeMappingFromResultTimeIndicesToWellTimeIndices( const
qDebug() << "Well TimeStamps";
for ( size_t i = 0; i < m_wellCellsTimeSteps.size(); i++ )
{
qDebug() << m_wellCellsTimeSteps[i].m_timestamp.toString();
qDebug() << m_wellCellsTimeSteps[i].timestamp().toString();
}
qDebug() << "Result TimeStamps";
@ -74,13 +75,13 @@ void RigSimWellData::computeMappingFromResultTimeIndicesToWellTimeIndices( const
for ( size_t resultTimeStepIndex = 0; resultTimeStepIndex < simulationTimeSteps.size(); resultTimeStepIndex++ )
{
while ( wellTimeStepIndex < m_wellCellsTimeSteps.size() &&
m_wellCellsTimeSteps[wellTimeStepIndex].m_timestamp < simulationTimeSteps[resultTimeStepIndex] )
m_wellCellsTimeSteps[wellTimeStepIndex].timestamp() < simulationTimeSteps[resultTimeStepIndex] )
{
wellTimeStepIndex++;
}
if ( wellTimeStepIndex < m_wellCellsTimeSteps.size() &&
m_wellCellsTimeSteps[wellTimeStepIndex].m_timestamp == simulationTimeSteps[resultTimeStepIndex] )
m_wellCellsTimeSteps[wellTimeStepIndex].timestamp() == simulationTimeSteps[resultTimeStepIndex] )
{
m_resultTimeStepIndexToWellTimeStepIndex[resultTimeStepIndex] = wellTimeStepIndex;
}
@ -120,15 +121,14 @@ bool RigSimWellData::hasAnyValidCells( size_t resultTimeStepIndex ) const
if ( wellTimeStepIndex == cvf::UNDEFINED_SIZE_T ) return false;
if ( wellResultFrame( resultTimeStepIndex )->m_wellHead.isCell() ) return true;
if ( wellResultFrame( resultTimeStepIndex )->wellHead().isCell() ) return true;
const std::vector<RigWellResultBranch>& resBranches = wellResultFrame( resultTimeStepIndex )->m_wellResultBranches;
for ( size_t i = 0; i < resBranches.size(); ++i )
const std::vector<RigWellResultBranch> resBranches = wellResultFrame( resultTimeStepIndex )->wellResultBranches();
for ( const auto& branch : resBranches )
{
for ( size_t cIdx = 0; cIdx < resBranches[i].m_branchResultPoints.size(); ++cIdx )
for ( const auto& branchResPoint : branch.branchResultPoints() )
{
if ( resBranches[i].m_branchResultPoints[cIdx].isCell() ) return true;
if ( branchResPoint.isCell() ) return true;
}
}
@ -156,28 +156,31 @@ void RigSimWellData::computeStaticWellCellPath() const
std::map<int, std::list<RigWellResultPoint>> staticWellBranches;
// Add ResultCell data from the first timestep to the final result.
for ( size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx )
for ( const auto& wellResultBranch : m_wellCellsTimeSteps[0].wellResultBranches() )
{
int branchErtId = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_ertBranchId;
const std::vector<RigWellResultPoint>& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchResultPoints;
const int branchErtId = wellResultBranch.ertBranchId();
std::list<RigWellResultPoint>& branch = staticWellBranches[branchErtId];
std::list<RigWellResultPoint>& branch = staticWellBranches[branchErtId];
for ( size_t cIdx = 0; cIdx < frameCells.size(); ++cIdx )
for ( const auto& frameCell : wellResultBranch.branchResultPoints() )
{
branch.push_back( frameCells[cIdx] );
branch.push_back( frameCell );
}
}
for ( size_t tIdx = 1; tIdx < m_wellCellsTimeSteps.size(); ++tIdx )
bool doSkipTimeStep = true;
for ( const auto& wellCellsTimeStep : m_wellCellsTimeSteps )
{
// Merge well branches separately
for ( size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[tIdx].m_wellResultBranches.size(); ++bIdx )
if ( doSkipTimeStep ) // Skip first
{
int branchId = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_ertBranchId;
const std::vector<RigWellResultPoint>& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchResultPoints;
doSkipTimeStep = false;
continue;
}
// Merge well branches separately
for ( const auto& wellResultBranch : wellCellsTimeStep.wellResultBranches() )
{
const int branchId = wellResultBranch.ertBranchId();
const std::vector<RigWellResultPoint> resBranch = wellResultBranch.branchResultPoints();
std::list<RigWellResultPoint>& stBranch = staticWellBranches[branchId];
std::list<RigWellResultPoint>::iterator sEndIt;
@ -270,25 +273,21 @@ void RigSimWellData::computeStaticWellCellPath() const
// Populate the static well info
std::map<int, std::list<RigWellResultPoint>>::iterator bIt;
m_staticWellCells->clearWellResultBranches();
m_staticWellCells->setWellHead( m_wellCellsTimeSteps[0].wellHead() );
m_staticWellCells->m_wellResultBranches.clear();
m_staticWellCells->m_wellHead = m_wellCellsTimeSteps[0].m_wellHead;
for ( bIt = staticWellBranches.begin(); bIt != staticWellBranches.end(); ++bIt )
for ( const auto& [ertBranchId, resultPoints] : staticWellBranches )
{
// Copy from first time step
RigWellResultBranch rigBranch;
rigBranch.m_ertBranchId = bIt->first;
rigBranch.setErtBranchId( ertBranchId );
std::list<RigWellResultPoint>& branch = bIt->second;
std::list<RigWellResultPoint>::iterator cIt;
for ( cIt = branch.begin(); cIt != branch.end(); ++cIt )
for ( const auto& resultPoint : resultPoints )
{
rigBranch.m_branchResultPoints.push_back( *cIt );
rigBranch.addBranchResultPoint( resultPoint );
}
m_staticWellCells->m_wellResultBranches.push_back( rigBranch );
m_staticWellCells->addWellResultBranch( rigBranch );
}
}
@ -316,7 +315,7 @@ RiaDefines::WellProductionType RigSimWellData::wellProductionType( size_t result
if ( hasWellResult( resultTimeStepIndex ) )
{
const RigWellResultFrame* wResFrame = wellResultFrame( resultTimeStepIndex );
return wResFrame->m_productionType;
return wResFrame->productionType();
}
else
{
@ -330,7 +329,7 @@ RiaDefines::WellProductionType RigSimWellData::wellProductionType( size_t result
const RigWellResultFrame* RigSimWellData::staticWellResultFrame() const
{
// Make sure we have computed the static representation of the well
if ( m_staticWellCells->m_wellResultBranches.size() == 0 )
if ( m_staticWellCells->wellResultBranches().empty() )
{
computeStaticWellCellPath();
}
@ -346,73 +345,10 @@ bool RigSimWellData::isOpen( size_t resultTimeStepIndex ) const
if ( hasWellResult( resultTimeStepIndex ) )
{
const RigWellResultFrame* wResFrame = wellResultFrame( resultTimeStepIndex );
return wResFrame->m_isOpen;
return wResFrame->isOpen();
}
else
{
return false;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigWellResultPoint* RigWellResultFrame::findResultCellWellHeadIncluded( size_t gridIndex, size_t gridCellIndex ) const
{
const RigWellResultPoint* wellResultPoint = findResultCellWellHeadExcluded( gridIndex, gridCellIndex );
if ( wellResultPoint ) return wellResultPoint;
// If we could not find the cell among the real connections, we try the wellhead.
// The wellhead does however not have a real connection state, and is rendering using pipe color
// https://github.com/OPM/ResInsight/issues/4328
// This behavior was different prior to release 2019.04 and was rendered as a closed connection (gray)
// https://github.com/OPM/ResInsight/issues/712
if ( m_wellHead.cellIndex() == gridCellIndex && m_wellHead.gridIndex() == gridIndex )
{
return &m_wellHead;
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
const RigWellResultPoint* RigWellResultFrame::findResultCellWellHeadExcluded( size_t gridIndex, size_t gridCellIndex ) const
{
CVF_ASSERT( gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T );
for ( size_t wb = 0; wb < m_wellResultBranches.size(); ++wb )
{
for ( size_t wc = 0; wc < m_wellResultBranches[wb].m_branchResultPoints.size(); ++wc )
{
if ( m_wellResultBranches[wb].m_branchResultPoints[wc].cellIndex() == gridCellIndex &&
m_wellResultBranches[wb].m_branchResultPoints[wc].gridIndex() == gridIndex )
{
return &( m_wellResultBranches[wb].m_branchResultPoints[wc] );
}
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RigWellResultFrame::wellHeadOrStartCell() const
{
if ( m_wellHead.isCell() ) return m_wellHead;
for ( const RigWellResultBranch& resBranch : m_wellResultBranches )
{
for ( const RigWellResultPoint& wrp : resBranch.m_branchResultPoints )
{
if ( wrp.isCell() ) return wrp;
}
}
return m_wellHead; // Nothing else to do
}

View File

@ -26,7 +26,7 @@
#include "RigEclipseCaseData.h"
#include "RigMainGrid.h"
#include "RigSimWellData.h"
#include "RigWellResultPoint.h"
#include "RigWellResultFrame.h"
#include "RimEclipseCase.h"
#include "RimEclipseView.h"
@ -233,8 +233,8 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineForTimeSt
}
#endif
const RigWellResultFrame& wellFrame = *wellFramePtr;
const std::vector<RigWellResultBranch>& resBranches = wellFrame.m_wellResultBranches;
const RigWellResultFrame& wellFrame = *wellFramePtr;
const std::vector<RigWellResultBranch> resBranches = wellFrame.wellResultBranches();
// Well head
// Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts()
@ -290,7 +290,7 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineForTimeSt
// Loop over all the resultPoints in the branch
const std::vector<RigWellResultPoint>& resBranchCells = resBranches[brIdx].m_branchResultPoints;
const std::vector<RigWellResultPoint> resBranchCells = resBranches[brIdx].branchResultPoints();
for ( int cIdx = 0; cIdx < static_cast<int>( resBranchCells.size() ); cIdx++ ) // Need int because cIdx can
// temporarily end on
@ -554,17 +554,11 @@ void RigSimulationWellCenterLineCalculator::addCellCenterPoints( const RigEclips
//--------------------------------------------------------------------------------------------------
bool RigSimulationWellCenterLineCalculator::hasAnyValidDataCells( const RigWellResultBranch& branch )
{
bool hasValidData = false;
for ( size_t cIdx = 0; cIdx < branch.m_branchResultPoints.size(); ++cIdx )
for ( const auto& branchResultPoint : branch.branchResultPoints() )
{
if ( branch.m_branchResultPoints[cIdx].isValid() )
{
hasValidData = true;
break;
}
if ( branchResultPoint.isValid() ) return true;
}
return hasValidData;
return false;
}
//--------------------------------------------------------------------------------------------------
@ -581,616 +575,3 @@ void RigSimulationWellCenterLineCalculator::finishPipeCenterLine( std::vector<st
pipeBranchesCLCoords.back().push_back( entryPointLastCell + 1.5 * ( lastCellCenter - entryPointLastCell ) );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
class BranchSplitter
{
public:
BranchSplitter( const RigWellResultFrame& awellResultFrame, const RigEclipseCaseData* eclipseCaseData )
: m_eclipseCaseData( eclipseCaseData )
, m_orgWellResultFrame( awellResultFrame )
{
CVF_ASSERT( m_orgWellResultFrame.m_wellResultBranches.size() <= 1 );
m_branchedWell = m_orgWellResultFrame;
buildCellSearchTree();
buildCellsToNeighborsMap();
buildUnusedCellsSet();
buildBranchLinesOfContinousNeighbourCells();
class DistToEndPoint
{
public:
DistToEndPoint( double adist, std::list<std::pair<bool, std::deque<size_t>>>::iterator aBranchLineIt, bool aToFrontOfBranchLine2 )
: dist( adist )
, branchLineIt( aBranchLineIt )
, toFrontOfBranchLine( aToFrontOfBranchLine2 )
{
}
double dist;
std::list<std::pair<bool, std::deque<size_t>>>::iterator branchLineIt;
bool toFrontOfBranchLine;
bool operator<( const DistToEndPoint& other ) const { return dist < other.dist; }
};
auto cmp = []( std::list<std::pair<bool, std::deque<size_t>>>::iterator a,
std::list<std::pair<bool, std::deque<size_t>>>::iterator b ) { return &( *a ) < &( *b ); };
std::set<std::list<std::pair<bool, std::deque<size_t>>>::iterator, decltype( cmp )> unusedBranchLineIterators( cmp );
std::map<int, std::multiset<DistToEndPoint>> resBranchIdxToBranchLineEndPointsDists;
/// Creating useful lambda functions
auto buildResBranchToBranchLineEndsDistMap =
[&unusedBranchLineIterators, &resBranchIdxToBranchLineEndPointsDists, this]( const cvf::Vec3d& fromPoint, int resultBranchIndex )
{
for ( auto it : unusedBranchLineIterators )
{
{
double dist = calculateFrontToPointDistance( it->second, fromPoint );
resBranchIdxToBranchLineEndPointsDists[resultBranchIndex].insert( DistToEndPoint( dist, it, true ) );
}
{
double dist = calculateEndToPointDistance( it->second, fromPoint );
resBranchIdxToBranchLineEndPointsDists[resultBranchIndex].insert( DistToEndPoint( dist, it, false ) );
}
}
};
auto removeBranchLineFromDistanceMap =
[&resBranchIdxToBranchLineEndPointsDists]( std::list<std::pair<bool, std::deque<size_t>>>::iterator branchLineToMergeIt )
{
for ( auto& brIdx_DistToEndPointSet : resBranchIdxToBranchLineEndPointsDists )
{
std::vector<std::multiset<DistToEndPoint>::iterator> iteratorsToErase;
for ( auto it = brIdx_DistToEndPointSet.second.begin(); it != brIdx_DistToEndPointSet.second.end(); ++it )
{
if ( it->branchLineIt == branchLineToMergeIt )
{
iteratorsToErase.push_back( it );
}
}
for ( auto itToErase : iteratorsToErase )
brIdx_DistToEndPointSet.second.erase( itToErase );
}
};
// Make the result container ready
m_branchedWell.m_wellResultBranches.clear();
m_branchedWell.m_wellResultBranches.push_back( RigWellResultBranch() );
// Build set of unused branch lines
for ( auto brLIt = m_branchLines.begin(); brLIt != m_branchLines.end(); ++brLIt )
{
if ( brLIt->first ) unusedBranchLineIterators.insert( brLIt );
}
// Calculate wellhead to branch line ends distances
{
const RigCell& whCell = m_eclipseCaseData->cellFromWellResultCell( m_orgWellResultFrame.wellHeadOrStartCell() );
cvf::Vec3d whStartPos = whCell.faceCenter( cvf::StructGridInterface::NEG_K );
buildResBranchToBranchLineEndsDistMap( whStartPos, -1 );
}
// Add the branchLine closest to wellhead into the result
{
auto closestEndPointIt = resBranchIdxToBranchLineEndPointsDists[-1].begin();
addBranchLineToLastWellResultBranch( closestEndPointIt->branchLineIt, closestEndPointIt->toFrontOfBranchLine );
unusedBranchLineIterators.erase( closestEndPointIt->branchLineIt );
removeBranchLineFromDistanceMap( closestEndPointIt->branchLineIt );
}
// Add the branchLines that starts directly from another branchLine
{
for ( auto brLIt = m_branchLines.begin(); brLIt != m_branchLines.end(); ++brLIt )
{
if ( !brLIt->first )
{
m_branchedWell.m_wellResultBranches.push_back( RigWellResultBranch() );
addBranchLineToLastWellResultBranch( brLIt, true );
}
}
}
while ( !unusedBranchLineIterators.empty() )
{
// Calculate distance from end of all currently added result branches to all branch lines
for ( size_t resultBranchIndex = 0; resultBranchIndex < m_branchedWell.m_wellResultBranches.size(); ++resultBranchIndex )
{
if ( !resBranchIdxToBranchLineEndPointsDists.count( (int)resultBranchIndex ) &&
m_branchedWell.m_wellResultBranches[resultBranchIndex].m_branchResultPoints.size() &&
m_branchedWell.m_wellResultBranches[resultBranchIndex].m_branchResultPoints.back().isCell() )
{
const RigCell& whCell = eclipseCaseData->cellFromWellResultCell(
m_branchedWell.m_wellResultBranches[resultBranchIndex].m_branchResultPoints.back() );
cvf::Vec3d branchEndPoint = whCell.center();
buildResBranchToBranchLineEndsDistMap( branchEndPoint, (int)resultBranchIndex );
}
}
// Find the result branch to grow, by finding the one with the closest distance to a branchLine
int minDistanceBrIdx = -1;
DistToEndPoint closestEndPoint( HUGE_VAL, m_branchLines.end(), true );
for ( auto& brIdx_DistToEndPointSet : resBranchIdxToBranchLineEndPointsDists )
{
if ( brIdx_DistToEndPointSet.second.begin()->dist < closestEndPoint.dist )
{
minDistanceBrIdx = brIdx_DistToEndPointSet.first;
closestEndPoint = *( brIdx_DistToEndPointSet.second.begin() );
}
}
// Grow the result branch with the branchLine
auto closestEndPointIt = resBranchIdxToBranchLineEndPointsDists[minDistanceBrIdx].begin();
auto branchLineToAddIt = closestEndPointIt->branchLineIt;
addBranchLineToWellResultBranch( minDistanceBrIdx, branchLineToAddIt, closestEndPointIt->toFrontOfBranchLine );
// Remove the branchLine from the control datastructures
unusedBranchLineIterators.erase( branchLineToAddIt );
resBranchIdxToBranchLineEndPointsDists.erase( minDistanceBrIdx );
removeBranchLineFromDistanceMap( branchLineToAddIt );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultFrame splittedWellResultFrame() { return m_branchedWell; }
private:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void addBranchLineToLastWellResultBranch( std::list<std::pair<bool, std::deque<size_t>>>::iterator branchLineIt, bool startAtFront )
{
addBranchLineToWellResultBranch( static_cast<int>( m_branchedWell.m_wellResultBranches.size() ) - 1, branchLineIt, startAtFront );
}
//--------------------------------------------------------------------------------------------------
/// branchIdx == -1 creates a new branch
//--------------------------------------------------------------------------------------------------
void addBranchLineToWellResultBranch( int branchIdx, std::list<std::pair<bool, std::deque<size_t>>>::iterator branchLineIt, bool startAtFront )
{
if ( branchIdx < 0 )
{
m_branchedWell.m_wellResultBranches.push_back( RigWellResultBranch() );
branchIdx = static_cast<int>( m_branchedWell.m_wellResultBranches.size() ) - 1;
RigWellResultPoint wellHeadAsPoint;
const RigCell& whCell = m_eclipseCaseData->cellFromWellResultCell( m_orgWellResultFrame.wellHeadOrStartCell() );
cvf::Vec3d whStartPos = whCell.faceCenter( cvf::StructGridInterface::NEG_K );
wellHeadAsPoint.setBottomPosition( whStartPos );
m_branchedWell.m_wellResultBranches[branchIdx].m_branchResultPoints.push_back( wellHeadAsPoint );
}
RigWellResultBranch& currentBranch = m_branchedWell.m_wellResultBranches[branchIdx];
std::deque<size_t> wellCellIndices = branchLineIt->second;
if ( !startAtFront ) std::reverse( wellCellIndices.begin(), wellCellIndices.end() );
const std::vector<RigWellResultPoint>& orgWellResultPoints = m_orgWellResultFrame.m_wellResultBranches[0].m_branchResultPoints;
#if 1
if ( wellCellIndices.size() )
{
if ( !branchLineIt->first ) // Is real branch, with first cell as cell *before* entry point on main branch
{
RigWellResultPoint branchStartAsResultPoint;
const RigCell& branchStartCell = m_eclipseCaseData->cellFromWellResultCell( orgWellResultPoints[wellCellIndices.front()] );
cvf::Vec3d branchStartPos = branchStartCell.center();
if ( wellCellIndices.size() > 1 )
{
// Use the shared face between the cell before, and the branching cell as start point for the
// branch, to make the pipe "whole"
cvf::StructGridInterface::FaceType sharedFace = cvf::StructGridInterface::NO_FACE;
m_eclipseCaseData->findSharedSourceFace( sharedFace,
orgWellResultPoints[wellCellIndices[0]],
orgWellResultPoints[wellCellIndices[1]] );
if ( sharedFace != cvf::StructGridInterface::NO_FACE )
{
branchStartPos = branchStartCell.faceCenter( sharedFace );
}
}
branchStartAsResultPoint.setBottomPosition( branchStartPos );
m_branchedWell.m_wellResultBranches[branchIdx].m_branchResultPoints.push_back( branchStartAsResultPoint );
}
else
{
currentBranch.m_branchResultPoints.push_back( orgWellResultPoints[wellCellIndices.front()] );
}
for ( size_t i = 1; i < wellCellIndices.size(); ++i )
{
size_t wcIdx = wellCellIndices[i];
currentBranch.m_branchResultPoints.push_back( orgWellResultPoints[wcIdx] );
}
}
#else
for ( size_t wcIdx : wellCellIndices )
{
currentBranch.m_branchResultPoints.push_back( orgWellResultPoints[wcIdx] );
}
#endif
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void buildCellSearchTree()
{
const std::vector<RigWellResultPoint>& orgWellResultPoints = m_orgWellResultFrame.m_wellResultBranches[0].m_branchResultPoints;
size_t cellCount = orgWellResultPoints.size();
m_cellBoundingBoxes.resize( cellCount );
const std::vector<cvf::Vec3d>& nodes = m_eclipseCaseData->mainGrid()->nodes();
for ( size_t cIdx = 0; cIdx < cellCount; ++cIdx )
{
if ( !orgWellResultPoints[cIdx].isCell() ) continue;
const RigCell& wellCell = m_eclipseCaseData->cellFromWellResultCell( orgWellResultPoints[cIdx] );
if ( wellCell.isInvalid() ) continue;
const std::array<size_t, 8>& cellIndices = wellCell.cornerIndices();
cvf::BoundingBox& cellBB = m_cellBoundingBoxes[cIdx];
for ( size_t i : cellIndices )
{
cellBB.add( nodes[i] );
}
}
m_cellSearchTree.buildTreeFromBoundingBoxes( m_cellBoundingBoxes, nullptr );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void buildCellsToNeighborsMap()
{
const std::vector<RigWellResultPoint>& orgWellResultPoints = m_orgWellResultFrame.m_wellResultBranches[0].m_branchResultPoints;
size_t cellCount = orgWellResultPoints.size();
const std::vector<cvf::Vec3d>& nodes = m_eclipseCaseData->mainGrid()->nodes();
double cellSizeI, cellSizeJ, cellSizeK;
m_eclipseCaseData->mainGrid()->characteristicCellSizes( &cellSizeI, &cellSizeJ, &cellSizeK );
double stdArea = cellSizeK * ( cellSizeI + cellSizeJ ) * 0.5;
for ( size_t cIdx = 0; cIdx < cellCount; ++cIdx )
{
std::vector<size_t> closeCells;
m_cellSearchTree.findIntersections( m_cellBoundingBoxes[cIdx], &closeCells );
const RigCell& c1 = m_eclipseCaseData->cellFromWellResultCell( orgWellResultPoints[cIdx] );
m_cellsWithNeighbors[cIdx]; // Add an empty set for this cell, in case we have no neighbors
for ( size_t idxToCloseCell : closeCells )
{
if ( idxToCloseCell != cIdx && m_cellsWithNeighbors[cIdx].count( idxToCloseCell ) == 0 )
{
const RigCell& c2 = m_eclipseCaseData->cellFromWellResultCell( orgWellResultPoints[idxToCloseCell] );
std::vector<size_t> poygonIndices;
std::vector<cvf::Vec3d> intersections;
auto contactFace = RigCellFaceGeometryTools::calculateCellFaceOverlap( c1,
c2,
*( m_eclipseCaseData->mainGrid() ),
&poygonIndices,
&intersections );
if ( contactFace != cvf::StructGridInterface::NO_FACE )
{
std::vector<cvf::Vec3d> realPolygon;
for ( size_t pIdx = 0; pIdx < poygonIndices.size(); ++pIdx )
{
if ( poygonIndices[pIdx] < nodes.size() )
realPolygon.push_back( nodes[poygonIndices[pIdx]] );
else
realPolygon.push_back( intersections[poygonIndices[pIdx] - nodes.size()] );
}
// Polygon area vector
cvf::Vec3d area = cvf::GeometryTools::polygonAreaNormal3D( realPolygon );
if ( area.length() < 1e-3 * stdArea ) continue;
m_cellsWithNeighbors[cIdx].insert( idxToCloseCell );
m_cellsWithNeighbors[idxToCloseCell].insert( cIdx );
}
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void buildUnusedCellsSet()
{
const std::vector<RigWellResultPoint>& orgWellResultPoints = m_orgWellResultFrame.m_wellResultBranches[0].m_branchResultPoints;
size_t cellCount = orgWellResultPoints.size();
for ( size_t i = 0; i < cellCount; ++i )
{
if ( orgWellResultPoints[i].isCell() ) m_unusedWellCellIndices.insert( i );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void buildBranchLinesOfContinousNeighbourCells()
{
for ( auto& cellWithNeighborsPair : m_cellsWithNeighbors )
{
auto it = m_unusedWellCellIndices.find( cellWithNeighborsPair.first );
if ( it != m_unusedWellCellIndices.end() )
{
m_unusedWellCellIndices.erase( it );
// Create a new branchline containing the cell itself.
m_branchLines.push_back( std::make_pair( true, std::deque<size_t>() ) );
auto currentBranchLineIt = std::prev( m_branchLines.end() );
auto& branchList = currentBranchLineIt->second;
branchList.push_back( cellWithNeighborsPair.first );
unsigned endToGrow = 0; // 0 end, 1 front, > 1 new branch
size_t neighbour = findBestNeighbor( cellWithNeighborsPair.first, cellWithNeighborsPair.second );
while ( neighbour != cvf::UNDEFINED_SIZE_T )
{
m_unusedWellCellIndices.erase( neighbour );
if ( endToGrow == 0 )
{
branchList.push_back( neighbour );
growBranchListEnd( currentBranchLineIt );
endToGrow++;
}
else if ( endToGrow == 1 )
{
branchList.push_front( neighbour );
growBranchListFront( currentBranchLineIt );
endToGrow++;
}
else // if ( endToGrow > 1 )
{
m_branchLines.push_back(
std::make_pair( false, std::deque<size_t>{ branchList.front(), cellWithNeighborsPair.first, neighbour } ) );
auto newBranchLineIt = std::prev( m_branchLines.end() );
growBranchListEnd( newBranchLineIt );
if ( newBranchLineIt->second.size() == 3 )
{
// No real contribution from the branch.
// Put the cell into main stem
// Todo
}
}
neighbour = findBestNeighbor( cellWithNeighborsPair.first, cellWithNeighborsPair.second );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t findBestNeighbor( size_t cell, std::set<size_t> neighbors )
{
size_t posKNeighbor = cvf::UNDEFINED_SIZE_T;
size_t firstUnused = cvf::UNDEFINED_SIZE_T;
const std::vector<RigWellResultPoint>& orgWellResultPoints = m_orgWellResultFrame.m_wellResultBranches[0].m_branchResultPoints;
for ( size_t neighbor : neighbors )
{
if ( m_unusedWellCellIndices.count( neighbor ) )
{
cvf::StructGridInterface::FaceType sharedFace;
m_eclipseCaseData->findSharedSourceFace( sharedFace, orgWellResultPoints[cell], orgWellResultPoints[neighbor] );
if ( sharedFace == cvf::StructGridInterface::NEG_K ) return neighbor;
if ( sharedFace == cvf::StructGridInterface::POS_K )
posKNeighbor = neighbor;
else if ( firstUnused == cvf::UNDEFINED_SIZE_T )
{
firstUnused = neighbor;
}
}
}
if ( posKNeighbor != cvf::UNDEFINED_SIZE_T )
{
return posKNeighbor;
}
else
{
return firstUnused;
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void growBranchListEnd( std::list<std::pair<bool, std::deque<size_t>>>::iterator branchListIt )
{
std::deque<size_t>& branchList = branchListIt->second;
CVF_ASSERT( branchList.size() );
size_t startCell = branchList.back();
size_t prevCell = cvf::UNDEFINED_SIZE_T;
size_t startCellPosInStem = branchList.size() - 1;
if ( branchList.size() > 1 ) prevCell = branchList[branchList.size() - 2];
const auto& neighbors = m_cellsWithNeighbors[startCell];
size_t nb = findBestNeighbor( startCell, neighbors );
if ( nb != cvf::UNDEFINED_SIZE_T )
{
branchList.push_back( nb );
m_unusedWellCellIndices.erase( nb );
growBranchListEnd( branchListIt );
}
startAndGrowSeparateBranchesFromRestOfNeighbors( startCell, prevCell, neighbors, branchList, startCellPosInStem, true );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void startAndGrowSeparateBranchesFromRestOfNeighbors( size_t startCell,
size_t prevCell,
const std::set<size_t>& neighbors,
std::deque<size_t> mainStem,
size_t branchPosInMainStem,
bool stemEndIsGrowing )
{
size_t nb = findBestNeighbor( startCell, neighbors );
while ( nb != cvf::UNDEFINED_SIZE_T )
{
if ( prevCell == cvf::UNDEFINED_SIZE_T )
{
m_branchLines.push_back( std::make_pair( false, std::deque<size_t>{ startCell, nb } ) );
}
else
{
m_branchLines.push_back( std::make_pair( false, std::deque<size_t>{ prevCell, startCell, nb } ) );
}
m_unusedWellCellIndices.erase( nb );
auto lastBranchIt = std::prev( m_branchLines.end() );
size_t separateBranchStartSize = lastBranchIt->second.size();
growBranchListEnd( lastBranchIt );
if ( lastBranchIt->second.size() == separateBranchStartSize )
{
// No use in this branch.
// put cell into main stem instead
if ( stemEndIsGrowing )
mainStem.insert( mainStem.begin() + branchPosInMainStem, nb );
else
mainStem.insert( mainStem.end() - branchPosInMainStem, nb );
m_branchLines.erase( lastBranchIt );
}
nb = findBestNeighbor( startCell, neighbors );
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void growBranchListFront( std::list<std::pair<bool, std::deque<size_t>>>::iterator branchListIt )
{
std::deque<size_t>& branchList = branchListIt->second;
CVF_ASSERT( branchList.size() );
size_t startCell = branchList.front();
size_t prevCell = cvf::UNDEFINED_SIZE_T;
size_t startCellPosInStem = branchList.size() - 1;
if ( branchList.size() > 1 ) prevCell = branchList[1];
const auto& neighbors = m_cellsWithNeighbors[startCell];
size_t nb = findBestNeighbor( startCell, neighbors );
if ( nb != cvf::UNDEFINED_SIZE_T )
{
branchList.push_front( nb );
m_unusedWellCellIndices.erase( nb );
growBranchListFront( branchListIt );
}
startAndGrowSeparateBranchesFromRestOfNeighbors( startCell, prevCell, neighbors, branchList, startCellPosInStem, false );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double calculateFrontToPointDistance( const std::deque<size_t>& second, const cvf::Vec3d& point )
{
// Todo, more fancy virtual curvature based distance using an estimated direction from the branch-end
return calculateWellCellToPointDistance( second.front(), point );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double calculateEndToPointDistance( const std::deque<size_t>& second, const cvf::Vec3d& point )
{
// Todo, more fancy virtual curvature based distance using an estimated direction from the branch-end
return calculateWellCellToPointDistance( second.back(), point );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
double calculateWellCellToPointDistance( size_t wellCellIdx, const cvf::Vec3d& point )
{
const std::vector<RigWellResultPoint>& orgWellResultPoints = m_orgWellResultFrame.m_wellResultBranches[0].m_branchResultPoints;
const RigCell& c = m_eclipseCaseData->cellFromWellResultCell( orgWellResultPoints[wellCellIdx] );
cvf::Vec3d cellCenter = c.center();
return ( point - cellCenter ).length();
}
private:
// The bool tells if this can be expanded in the front,
// Set to false when the branchLine starts from a branching cell (cell with more than two neighbors)
std::list<std::pair<bool, std::deque<size_t>>> m_branchLines;
std::vector<cvf::BoundingBox> m_cellBoundingBoxes;
cvf::BoundingBoxTree m_cellSearchTree;
std::map<size_t, std::set<size_t>> m_cellsWithNeighbors;
std::set<size_t> m_unusedWellCellIndices;
RigWellResultFrame m_branchedWell;
const RigEclipseCaseData* m_eclipseCaseData;
const RigWellResultFrame& m_orgWellResultFrame;
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultFrame RigSimulationWellCenterLineCalculator::splitIntoBranches( const RigWellResultFrame& wellResultFrame,
const RigEclipseCaseData* eclipseCaseData )
{
BranchSplitter splitter( wellResultFrame, eclipseCaseData );
return splitter.splittedWellResultFrame();
}

View File

@ -19,7 +19,7 @@
#pragma once
#include "RigWellResultPoint.h"
#include "RigWellResultBranch.h"
#include "cvfVector3.h"
@ -29,8 +29,6 @@
class RigEclipseCaseData;
class RimSimWellInView;
class RigSimWellData;
struct RigWellResultPoint;
struct RigWellResultBranch;
class RigWellResultFrame;
//--------------------------------------------------------------------------------------------------
@ -63,19 +61,10 @@ private:
std::vector<std::vector<cvf::Vec3d>>& pipeBranchesCLCoords,
std::vector<std::vector<RigWellResultPoint>>& pipeBranchesCellIds );
static std::vector<SimulationWellCellBranch> calculateMswWellPipeGeometryForTimeStep( const RigEclipseCaseData* eclipseCaseData,
const RigSimWellData* simWellData,
int timeStepIndex );
static SimulationWellCellBranch addSegmentsToCellFaces( const std::vector<cvf::Vec3d> branchCoords,
const std::vector<RigWellResultPoint>& resultPoints,
const RigEclipseCaseData* eclipseCaseData );
static bool hasAnyValidDataCells( const RigWellResultBranch& branch );
static void finishPipeCenterLine( std::vector<std::vector<cvf::Vec3d>>& pipeBranchesCLCoords, const cvf::Vec3d& lastCellCenter );
static RigWellResultFrame splitIntoBranches( const RigWellResultFrame& wellResultFrame, const RigEclipseCaseData* eclipseCaseData );
static void addCellCenterPoints( const RigEclipseCaseData* eclipseCaseData,
std::vector<std::vector<cvf::Vec3d>>& pipeBranchesCLCoords,
std::vector<std::vector<RigWellResultPoint>>& pipeBranchesCellIds );
static void addCellCenterPoints( const RigEclipseCaseData* eclipseCaseData,
std::vector<std::vector<cvf::Vec3d>>& pipeBranchesCLCoords,
std::vector<std::vector<RigWellResultPoint>>& pipeBranchesCellIds );
};

View File

@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RigWellResultBranch.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultBranch::RigWellResultBranch()
: m_ertBranchId( -1 )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
int RigWellResultBranch::ertBranchId() const
{
return m_ertBranchId;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultBranch::setErtBranchId( int id )
{
m_ertBranchId = id;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellResultPoint> RigWellResultBranch::branchResultPoints() const
{
return m_branchResultPoints;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultBranch::addBranchResultPoint( const RigWellResultPoint& point )
{
m_branchResultPoints.push_back( point );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultBranch::setBranchResultPoints( const std::vector<RigWellResultPoint>& points )
{
m_branchResultPoints = points;
}

View File

@ -0,0 +1,49 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RigWellResultPoint.h"
#include "cvfVector3.h"
#include <vector>
//==================================================================================================
/// This class contains the connection information from and including a split point to the end of
/// that particular branch.
//==================================================================================================
struct RigWellResultBranch
{
RigWellResultBranch();
int ertBranchId() const;
void setErtBranchId( int id );
std::vector<RigWellResultPoint> branchResultPoints() const;
void addBranchResultPoint( const RigWellResultPoint& point );
void setBranchResultPoints( const std::vector<RigWellResultPoint>& points );
private:
int m_ertBranchId;
std::vector<RigWellResultPoint> m_branchResultPoints;
};
using SimulationWellCellBranch = std::pair<std::vector<cvf::Vec3d>, std::vector<RigWellResultPoint>>;

View File

@ -0,0 +1,210 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RigWellResultFrame.h"
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultFrame::RigWellResultFrame()
: m_productionType( RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
, m_isOpen( false )
{
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RigWellResultFrame::findResultCellWellHeadIncluded( size_t gridIndex, size_t gridCellIndex ) const
{
const RigWellResultPoint wellResultPoint = findResultCellWellHeadExcluded( gridIndex, gridCellIndex );
if ( wellResultPoint.isValid() ) return wellResultPoint;
// If we could not find the cell among the real connections, we try the wellhead.
// The wellhead does however not have a real connection state, and is rendering using pipe color
// https://github.com/OPM/ResInsight/issues/4328
// This behavior was different prior to release 2019.04 and was rendered as a closed connection (gray)
// https://github.com/OPM/ResInsight/issues/712
if ( m_wellHead.cellIndex() == gridCellIndex && m_wellHead.gridIndex() == gridIndex )
{
return m_wellHead;
}
return RigWellResultPoint();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RigWellResultFrame::findResultCellWellHeadExcluded( size_t gridIndex, size_t gridCellIndex ) const
{
CVF_ASSERT( gridIndex != cvf::UNDEFINED_SIZE_T && gridCellIndex != cvf::UNDEFINED_SIZE_T );
for ( const auto& wellResultBranch : m_wellResultBranches )
{
for ( const auto& branchResultPoint : wellResultBranch.branchResultPoints() )
{
if ( branchResultPoint.cellIndex() == gridCellIndex && branchResultPoint.gridIndex() == gridIndex )
{
return branchResultPoint;
}
}
}
return RigWellResultPoint();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::setWellHead( RigWellResultPoint wellHead )
{
m_wellHead = wellHead;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RigWellResultFrame::wellHead() const
{
return m_wellHead;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RigWellResultFrame::wellHeadOrStartCell() const
{
if ( m_wellHead.isCell() ) return m_wellHead;
for ( const RigWellResultBranch& resBranch : m_wellResultBranches )
{
for ( const RigWellResultPoint& wrp : resBranch.branchResultPoints() )
{
if ( wrp.isCell() ) return wrp;
}
}
return m_wellHead; // Nothing else to do
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellResultPoint> RigWellResultFrame::allResultPoints() const
{
std::vector<RigWellResultPoint> allPoints;
for ( const auto& resultBranch : m_wellResultBranches )
{
for ( const auto& resultPoint : resultBranch.branchResultPoints() )
{
allPoints.push_back( resultPoint );
}
}
return allPoints;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::setIsOpen( bool isOpen )
{
m_isOpen = isOpen;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigWellResultFrame::isOpen() const
{
return m_isOpen;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::setProductionType( RiaDefines::WellProductionType productionType )
{
m_productionType = productionType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RiaDefines::WellProductionType RigWellResultFrame::productionType() const
{
return m_productionType;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::setTimestamp( const QDateTime& timeStamp )
{
m_timestamp = timeStamp;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QDateTime RigWellResultFrame::timestamp() const
{
return m_timestamp;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellResultBranch> RigWellResultFrame::wellResultBranches() const
{
return m_wellResultBranches;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::clearWellResultBranches()
{
m_wellResultBranches.clear();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::addWellResultBranch( const RigWellResultBranch& wellResultBranch )
{
m_wellResultBranches.push_back( wellResultBranch );
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RigWellResultFrame::setWellResultBranches( const std::vector<RigWellResultBranch>& wellResultBranches )
{
m_wellResultBranches = wellResultBranches;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellResultPoint> RigWellResultFrame::branchResultPointsFromBranchIndex( size_t index ) const
{
CVF_ASSERT( index < m_wellResultBranches.size() );
return m_wellResultBranches[index].branchResultPoints();
}

View File

@ -0,0 +1,67 @@
/////////////////////////////////////////////////////////////////////////////////
//
// Copyright (C) 2023- 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 "RigWellResultBranch.h"
#include <QDateTime>
#include <vector>
//==================================================================================================
/// This class contains the well information for one timestep.
/// The main content is the vector of RigWellResultBranch which contains all the simple pipe
/// sections that make up the well
//==================================================================================================
class RigWellResultFrame
{
public:
RigWellResultFrame();
RigWellResultPoint findResultCellWellHeadIncluded( size_t gridIndex, size_t gridCellIndex ) const;
RigWellResultPoint findResultCellWellHeadExcluded( size_t gridIndex, size_t gridCellIndex ) const;
std::vector<RigWellResultPoint> allResultPoints() const;
void setIsOpen( bool isOpen );
void setProductionType( RiaDefines::WellProductionType productionType );
void setTimestamp( const QDateTime& timestampe );
void setWellHead( RigWellResultPoint wellHead );
bool isOpen() const;
RiaDefines::WellProductionType productionType() const;
QDateTime timestamp() const;
RigWellResultPoint wellHead() const;
RigWellResultPoint wellHeadOrStartCell() const;
std::vector<RigWellResultBranch> wellResultBranches() const;
void clearWellResultBranches();
void addWellResultBranch( const RigWellResultBranch& wellResultBranch );
void setWellResultBranches( const std::vector<RigWellResultBranch>& wellResultBranches );
std::vector<RigWellResultPoint> branchResultPointsFromBranchIndex( size_t index ) const;
private:
bool m_isOpen;
RiaDefines::WellProductionType m_productionType;
QDateTime m_timestamp;
RigWellResultPoint m_wellHead;
std::vector<RigWellResultBranch> m_wellResultBranches;
};

View File

@ -301,19 +301,3 @@ cvf::Vec3d RigWellResultPoint::bottomPosition() const
{
return m_bottomPosition;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<RigWellResultPoint> RigWellResultFrame::allResultPoints() const
{
std::vector<RigWellResultPoint> allPoints;
for ( const auto& resultBranch : m_wellResultBranches )
{
for ( const auto& resultPoint : resultBranch.m_branchResultPoints )
{
allPoints.push_back( resultPoint );
}
}
return allPoints;
}

View File

@ -90,47 +90,3 @@ private:
double m_connectionFactor;
bool m_isConnectedToValve;
};
//==================================================================================================
/// This class contains the connection information from and including a splitpoint to the end of
/// that particular branch.
//==================================================================================================
struct RigWellResultBranch
{
RigWellResultBranch()
: m_ertBranchId( -1 )
{
}
int m_ertBranchId;
std::vector<RigWellResultPoint> m_branchResultPoints;
};
//==================================================================================================
/// This class contains the well information for one timestep.
/// The main content is the vector of RigWellResultBranch which contains all the simple pipe
/// sections that make up the well
//==================================================================================================
class RigWellResultFrame
{
public:
RigWellResultFrame()
: m_productionType( RiaDefines::WellProductionType::UNDEFINED_PRODUCTION_TYPE )
, m_isOpen( false )
{
}
const RigWellResultPoint* findResultCellWellHeadIncluded( size_t gridIndex, size_t gridCellIndex ) const;
const RigWellResultPoint* findResultCellWellHeadExcluded( size_t gridIndex, size_t gridCellIndex ) const;
std::vector<RigWellResultPoint> allResultPoints() const;
RigWellResultPoint wellHeadOrStartCell() const;
RiaDefines::WellProductionType m_productionType;
bool m_isOpen;
RigWellResultPoint m_wellHead;
QDateTime m_timestamp;
std::vector<RigWellResultBranch> m_wellResultBranches;
};
using SimulationWellCellBranch = std::pair<std::vector<cvf::Vec3d>, std::vector<RigWellResultPoint>>;

View File

@ -25,6 +25,7 @@
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "RimEclipseCase.h"
@ -173,7 +174,7 @@ public:
qint32 wellStatus = 0;
if ( currentWellResult->hasWellResult( tsIdx ) )
{
switch ( currentWellResult->wellResultFrame( tsIdx )->m_productionType )
switch ( currentWellResult->wellResultFrame( tsIdx )->productionType() )
{
case RiaDefines::WellProductionType::PRODUCER:
wellType = "Producer";
@ -189,7 +190,7 @@ public:
break;
}
wellStatus = currentWellResult->wellResultFrame( tsIdx )->m_isOpen ? 1 : 0;
wellStatus = currentWellResult->wellResultFrame( tsIdx )->isOpen() ? 1 : 0;
}
wellTypes.push_back( wellType );
@ -283,29 +284,25 @@ public:
std::vector<RigGridBase*> grids;
rimCase->eclipseCaseData()->allGrids( &grids );
for ( size_t bIdx = 0; bIdx < wellResFrame->m_wellResultBranches.size(); ++bIdx )
for ( const auto& wellResultBranch : wellResFrame->wellResultBranches() )
{
const std::vector<RigWellResultPoint>& branchResPoints = wellResFrame->m_wellResultBranches[bIdx].m_branchResultPoints;
for ( size_t rpIdx = 0; rpIdx < branchResPoints.size(); ++rpIdx )
for ( const auto& branchResultPoint : wellResultBranch.branchResultPoints() )
{
const RigWellResultPoint& resPoint = branchResPoints[rpIdx];
if ( resPoint.isCell() )
if ( branchResultPoint.isCell() )
{
size_t i;
size_t j;
size_t k;
size_t gridIdx = resPoint.gridIndex();
grids[gridIdx]->ijkFromCellIndex( resPoint.cellIndex(), &i, &j, &k );
bool isOpen = resPoint.isOpen();
int branchId = resPoint.branchId();
int segmentId = resPoint.segmentId();
size_t gridIdx = branchResultPoint.gridIndex();
grids[gridIdx]->ijkFromCellIndex( branchResultPoint.cellIndex(), &i, &j, &k );
bool isOpen = branchResultPoint.isOpen();
int branchId = branchResultPoint.branchId();
int segmentId = branchResultPoint.segmentId();
cellIs.push_back( static_cast<qint32>( i + 1 ) ); // NB: 1-based index in Octave
cellJs.push_back( static_cast<qint32>( j + 1 ) ); // NB: 1-based index in Octave
cellKs.push_back( static_cast<qint32>( k + 1 ) ); // NB: 1-based index in Octave
gridIndices.push_back( static_cast<qint32>( gridIdx ) );
cellStatuses.push_back( static_cast<qint32>( isOpen ) );
cellStatuses.push_back( isOpen ? static_cast<qint32>( 1 ) : static_cast<qint32>( 0 ) );
branchIds.push_back( branchId );
segmentIds.push_back( segmentId );
}

View File

@ -28,6 +28,7 @@
#include "RigResultAccessor.h"
#include "RigResultAccessorFactory.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "Rim2dIntersectionView.h"
@ -1168,13 +1169,13 @@ QString RiuResultTextBuilder::wellResultText()
continue;
}
const RigWellResultPoint* wellResultCell = wellResultFrame->findResultCellWellHeadIncluded( m_gridIndex, m_cellIndex );
if ( wellResultCell )
const RigWellResultPoint wellResultCell = wellResultFrame->findResultCellWellHeadIncluded( m_gridIndex, m_cellIndex );
if ( wellResultCell.isValid() )
{
const int branchId = wellResultCell->branchId();
const int segmentId = wellResultCell->segmentId();
const int outletBranchId = wellResultCell->outletBranchId();
const int outletSegmentId = wellResultCell->outletSegmentId();
const int branchId = wellResultCell.branchId();
const int segmentId = wellResultCell.segmentId();
const int outletBranchId = wellResultCell.outletBranchId();
const int outletSegmentId = wellResultCell.outletSegmentId();
text += QString( "-- Well-cell connection info --\n Well Name: %1\n Branch Id: %2\n Segment "
"Id: %3\n Outlet Branch Id: %4\n Outlet Segment Id: %5\n" )

View File

@ -22,6 +22,7 @@
#include "RigEclipseCaseData.h"
#include "RigGridBase.h"
#include "RigSimWellData.h"
#include "RigWellResultFrame.h"
#include "RigWellResultPoint.h"
#include "RimCase.h"
@ -58,7 +59,7 @@ grpc::Status RiaGrpcSimulationWellService::GetSimulationWellStatus( grpc::Server
bool wellStatus = false;
if ( currentWellResult->hasWellResult( tsIdx ) )
{
switch ( currentWellResult->wellResultFrame( tsIdx )->m_productionType )
switch ( currentWellResult->wellResultFrame( tsIdx )->productionType() )
{
case RiaDefines::WellProductionType::PRODUCER:
wellType = "Producer";
@ -74,7 +75,7 @@ grpc::Status RiaGrpcSimulationWellService::GetSimulationWellStatus( grpc::Server
break;
}
wellStatus = currentWellResult->wellResultFrame( tsIdx )->m_isOpen;
wellStatus = currentWellResult->wellResultFrame( tsIdx )->isOpen();
}
reply->set_well_type( wellType.toStdString() );
@ -111,10 +112,9 @@ grpc::Status RiaGrpcSimulationWellService::GetSimulationWellCells( grpc::ServerC
std::vector<RigGridBase*> grids;
eclipseCase->eclipseCaseData()->allGrids( &grids );
for ( size_t bIdx = 0; bIdx < wellResFrame->m_wellResultBranches.size(); ++bIdx )
for ( size_t bIdx = 0; bIdx < wellResFrame->wellResultBranches().size(); ++bIdx )
{
const std::vector<RigWellResultPoint>& branchResPoints =
wellResFrame->m_wellResultBranches[bIdx].m_branchResultPoints;
const std::vector<RigWellResultPoint> branchResPoints = wellResFrame->branchResultPointsFromBranchIndex( bIdx );
for ( size_t rpIdx = 0; rpIdx < branchResPoints.size(); ++rpIdx )
{
const RigWellResultPoint& resPoint = branchResPoints[rpIdx];