Add valve visualization to MSW wells

* Refactor geo generator
* Add valve visualization to segments that are connected to a valve
This commit is contained in:
Magne Sjaastad
2023-03-02 13:06:38 +01:00
committed by GitHub
parent 8a2d9ec83e
commit d47d4060cc
16 changed files with 452 additions and 200 deletions

View File

@@ -87,18 +87,16 @@ void RivFishbonesSubsPartMgr::buildParts( const caf::DisplayCoordTransform* disp
RimWellPath* wellPath = nullptr;
m_rimFishbonesSubs->firstAncestorOrThisOfTypeAsserted( wellPath );
RivPipeGeometryGenerator geoGenerator;
for ( const auto& [subIndex, lateralIndex] : m_rimFishbonesSubs->installedLateralIndices() )
{
std::vector<cvf::Vec3d> lateralDomainCoords = m_rimFishbonesSubs->coordsForLateral( subIndex, lateralIndex );
std::vector<cvf::Vec3d> displayCoords = displayCoordTransform->transformToDisplayCoords( lateralDomainCoords );
geoGenerator.cylinderWithCenterLineParts( &m_parts,
displayCoords,
m_rimFishbonesSubs->fishbonesColor(),
wellPath->combinedScaleFactor() * characteristicCellSize * 0.5 );
RivPipeGeometryGenerator::cylinderWithCenterLineParts( &m_parts,
displayCoords,
m_rimFishbonesSubs->fishbonesColor(),
wellPath->combinedScaleFactor() * characteristicCellSize * 0.5 );
}
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( m_rimFishbonesSubs );

View File

@@ -57,6 +57,14 @@ void RivPipeGeometryGenerator::setPipeCenterCoords( const cvf::Vec3dArray* coord
clearComputedData();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
cvf::cref<cvf::Vec3dArray> RivPipeGeometryGenerator::pipeCenterCoords() const
{
return m_originalPipeCenterCoords.p();
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -273,7 +281,7 @@ cvf::ref<cvf::DrawableGeo> RivPipeGeometryGenerator::generateExtrudedCylinder( d
size_t i;
for ( i = 0; i < extrudedNodes.size(); i++ )
{
crossSectionVertices.push_back( cvf::Vec3f( extrudedNodes[i] ) );
crossSectionVertices.emplace_back( extrudedNodes[i] );
}
// Calculate first valid pipe direction, to be able to handle centerNodes in the same place
@@ -435,9 +443,9 @@ cvf::ref<cvf::DrawableGeo> RivPipeGeometryGenerator::generateVariableRadiusTube(
std::vector<cvf::Vec3f> cylinderSegmentNormals;
// Insert the first set of vertices
for ( size_t i = 0; i < lastExtrudedNodes.size(); i++ )
for ( const auto& lastExtrudedNode : lastExtrudedNodes )
{
crossSectionVertices.push_back( cvf::Vec3f( lastExtrudedNodes[i] ) );
crossSectionVertices.emplace_back( lastExtrudedNode );
}
// Loop along the cylinder center coords and calculate the cross section vertexes in each center vertex
@@ -500,7 +508,7 @@ cvf::ref<cvf::DrawableGeo> RivPipeGeometryGenerator::generateVariableRadiusTube(
cvf::Vec3f circleDir = ( nextNodeAlongCircle - lastNodeAlongCircle ).getNormalized();
cvf::Vec3f segmentNormal = ( wellDirectionDir ^ circleDir ).getNormalized();
crossSectionVertices.push_back( cvf::Vec3f( nextNodeAlongWellPath ) );
crossSectionVertices.emplace_back( nextNodeAlongWellPath );
cylinderSegmentNormals.push_back( segmentNormal );
}
@@ -629,7 +637,7 @@ void RivPipeGeometryGenerator::computeExtrudedCoordsAndNormals( cvf::Vec3d
void RivPipeGeometryGenerator::updateFilteredPipeCenterCoords()
{
if ( m_originalPipeCenterCoords->size() < 2 ) return;
if ( m_filteredPipeCenterCoords.size() > 0 ) return;
if ( !m_filteredPipeCenterCoords.empty() ) return;
double squareDistanceTolerance = 1e-4 * 1e-4;
@@ -778,13 +786,15 @@ void RivPipeGeometryGenerator::cylinderWithCenterLineParts( cvf::Collection<cvf:
const cvf::Color3f& color,
double radius )
{
setRadius( radius );
setCrossSectionVertexCount( 12 );
RivPipeGeometryGenerator geoGenerator;
geoGenerator.setRadius( radius );
geoGenerator.setCrossSectionVertexCount( 12 );
cvf::ref<cvf::Vec3dArray> cvfCoords = new cvf::Vec3dArray( centerCoords );
setPipeCenterCoords( cvfCoords.p() );
geoGenerator.setPipeCenterCoords( cvfCoords.p() );
cvf::ref<cvf::DrawableGeo> surfaceGeo = createPipeSurface();
cvf::ref<cvf::DrawableGeo> surfaceGeo = geoGenerator.createPipeSurface();
if ( surfaceGeo.notNull() )
{
cvf::Part* part = new cvf::Part;
@@ -799,7 +809,7 @@ void RivPipeGeometryGenerator::cylinderWithCenterLineParts( cvf::Collection<cvf:
destinationParts->push_back( part );
}
cvf::ref<cvf::DrawableGeo> centerLineGeo = createCenterLine();
cvf::ref<cvf::DrawableGeo> centerLineGeo = geoGenerator.createCenterLine();
if ( centerLineGeo.notNull() )
{
cvf::Part* part = new cvf::Part;
@@ -823,12 +833,10 @@ void RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( cvf::Col
const std::vector<double>& radii,
const cvf::Color3f& color )
{
setCrossSectionVertexCount( 12 );
cvf::ref<cvf::Vec3dArray> activeCoords = new cvf::Vec3dArray( centerCoords );
setPipeCenterCoords( activeCoords.p() );
cvf::ref<cvf::DrawableGeo> surfaceGeo = generateVariableRadiusTube( m_crossSectionNodeCount, activeCoords.p(), radii );
const size_t crossSectionNodeCount = 12;
cvf::ref<cvf::DrawableGeo> surfaceGeo = generateVariableRadiusTube( crossSectionNodeCount, activeCoords.p(), radii );
if ( surfaceGeo.notNull() )
{
@@ -844,7 +852,7 @@ void RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( cvf::Col
destinationParts->push_back( part );
}
cvf::ref<cvf::DrawableGeo> centerLineGeo = createCenterLine();
cvf::ref<cvf::DrawableGeo> centerLineGeo = generateLine( activeCoords.p() );
if ( centerLineGeo.notNull() )
{
cvf::Part* part = new cvf::Part;

View File

@@ -42,7 +42,8 @@ public:
~RivPipeGeometryGenerator() override;
// Coordinates and orientations
void setPipeCenterCoords( const cvf::Vec3dArray* coords );
void setPipeCenterCoords( const cvf::Vec3dArray* coords );
cvf::cref<cvf::Vec3dArray> pipeCenterCoords() const;
// Appearance
void setRadius( double radius );
@@ -59,15 +60,15 @@ public:
void setFirstVisibleSegmentIndex( size_t segmentIndex );
size_t segmentIndexFromTriangleIndex( size_t triangleIndex ) const;
void cylinderWithCenterLineParts( cvf::Collection<cvf::Part>* destinationParts,
const std::vector<cvf::Vec3d>& centerCoords,
const cvf::Color3f& color,
double radius );
static void cylinderWithCenterLineParts( cvf::Collection<cvf::Part>* destinationParts,
const std::vector<cvf::Vec3d>& centerCoords,
const cvf::Color3f& color,
double radius );
void tubeWithCenterLinePartsAndVariableWidth( cvf::Collection<cvf::Part>* destinationParts,
const std::vector<cvf::Vec3d>& centerCoords,
const std::vector<double>& radii,
const cvf::Color3f& color );
static void tubeWithCenterLinePartsAndVariableWidth( cvf::Collection<cvf::Part>* destinationParts,
const std::vector<cvf::Vec3d>& centerCoords,
const std::vector<double>& radii,
const cvf::Color3f& color );
private:
void clearComputedData();

View File

@@ -33,6 +33,7 @@
#include "RigWellResultPoint.h"
#include "Rim3dView.h"
#include "RimCase.h"
#include "RimEclipseView.h"
#include "RimRegularLegendConfig.h"
#include "RimSimWellInView.h"
@@ -50,10 +51,14 @@
#include "cafEffectGenerator.h"
#include "cvfDrawableGeo.h"
#include "cvfGeometryBuilderDrawableGeo.h"
#include "cvfGeometryUtils.h"
#include "cvfModelBasicList.h"
#include "cvfPart.h"
#include "cvfScalarMapperDiscreteLinear.h"
#include <numbers>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
@@ -110,6 +115,11 @@ void RivSimWellPipesPartMgr::appendDynamicGeometryPartsToModel( cvf::ModelBasicL
{
model->addPart( it->m_connectionFactorsPart.p() );
}
for ( auto valvePart : it->m_valveParts )
{
model->addPart( valvePart.p() );
}
}
}
@@ -156,7 +166,6 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
m_wellBranches.clear();
m_flattenedBranchWellHeadOffsets.clear();
m_pipeBranchesCLCoords.clear();
auto createSimWells = []( RimSimWellInView* simWellInView ) -> std::vector<SimulationWellCellBranch> {
std::vector<SimulationWellCellBranch> simWellBranches;
@@ -176,8 +185,8 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
auto simWells = createSimWells( m_simWellInView );
const auto& [coords, wellCells] = RigSimulationWellCenterLineCalculator::extractBranchData( simWells );
m_pipeBranchesCLCoords = coords;
std::vector<std::vector<RigWellResultPoint>> pipeBranchesCellIds = wellCells;
auto pipeBranchesCLCoords = coords;
auto pipeBranchesCellIds = wellCells;
double pipeRadius = m_simWellInView->pipeRadius();
int crossSectionVertexCount = m_simWellInView->pipeCrossSectionVertexCount();
@@ -185,7 +194,7 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
// Take branch selection into account
size_t branchIdxStart = 0;
size_t branchIdxStop = pipeBranchesCellIds.size();
if ( m_pipeBranchesCLCoords.size() > 1 )
if ( pipeBranchesCLCoords.size() > 1 )
{
if ( branchIndex >= 0 && branchIndex < static_cast<int>( branchIdxStop ) )
{
@@ -195,16 +204,16 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
}
cvf::Vec3d flattenedStartOffset = cvf::Vec3d::ZERO;
if ( m_pipeBranchesCLCoords.size() > branchIdxStart && m_pipeBranchesCLCoords[branchIdxStart].size() )
if ( pipeBranchesCLCoords.size() > branchIdxStart && !pipeBranchesCLCoords[branchIdxStart].empty() )
{
flattenedStartOffset = { 0.0, 0.0, m_pipeBranchesCLCoords[branchIdxStart][0].z() };
flattenedStartOffset = { 0.0, 0.0, pipeBranchesCLCoords[branchIdxStart][0].z() };
}
for ( size_t brIdx = branchIdxStart; brIdx < branchIdxStop; ++brIdx )
{
cvf::ref<RivSimWellPipeSourceInfo> sourceInfo = new RivSimWellPipeSourceInfo( m_simWellInView, brIdx );
m_wellBranches.push_back( RivPipeBranchData() );
m_wellBranches.emplace_back();
RivPipeBranchData& pbd = m_wellBranches.back();
pbd.m_cellIds = pipeBranchesCellIds[brIdx];
@@ -215,15 +224,15 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
pbd.m_pipeGeomGenerator->setCrossSectionVertexCount( crossSectionVertexCount );
cvf::ref<cvf::Vec3dArray> cvfCoords = new cvf::Vec3dArray;
cvfCoords->assign( m_pipeBranchesCLCoords[brIdx] );
cvfCoords->assign( pipeBranchesCLCoords[brIdx] );
flattenedStartOffset.z() = m_pipeBranchesCLCoords[brIdx][0].z();
flattenedStartOffset.z() = pipeBranchesCLCoords[brIdx][0].z();
m_flattenedBranchWellHeadOffsets.push_back( flattenedStartOffset.x() );
if ( doFlatten )
{
std::vector<cvf::Mat4d> flatningCSs = RivSectionFlattener::calculateFlatteningCSsForPolyline( m_pipeBranchesCLCoords[brIdx],
std::vector<cvf::Mat4d> flatningCSs = RivSectionFlattener::calculateFlatteningCSsForPolyline( pipeBranchesCLCoords[brIdx],
cvf::Vec3d::Z_AXIS,
flattenedStartOffset,
&flattenedStartOffset );
@@ -280,93 +289,238 @@ void RivSimWellPipesPartMgr::buildWellPipeParts( const caf::DisplayCoordTransfor
pbd.m_connectionFactorGeometryGenerator = nullptr;
pbd.m_connectionFactorsPart = nullptr;
pbd.m_valveParts.clear();
RimEclipseView* eclipseView = nullptr;
m_simWellInView->firstAncestorOrThisOfType( eclipseView );
if ( eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible() )
appendVirtualConnectionFactorGeo( eclipseView, frameIndex, brIdx, displayXf, pipeRadius, pbd );
appendValvesGeo( eclipseView, frameIndex, brIdx, displayXf, pipeRadius, pbd );
if ( doFlatten ) flattenedStartOffset += { 2 * flattenedIntersectionExtentLength, 0.0, 0.0 };
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::appendVirtualConnectionFactorGeo( const RimEclipseView* eclipseView,
size_t frameIndex,
size_t brIdx,
const caf::DisplayCoordTransform* displayXf,
double pipeRadius,
RivPipeBranchData& pbd )
{
if ( eclipseView && eclipseView->isVirtualConnectionFactorGeometryVisible() )
{
RigSimWellData* simWellData = m_simWellInView->simWellData();
if ( simWellData && simWellData->hasWellResult( frameIndex ) )
{
RigSimWellData* simWellData = m_simWellInView->simWellData();
const RigWellResultFrame* wResFrame = simWellData->wellResultFrame( frameIndex );
if ( simWellData && simWellData->hasWellResult( frameIndex ) )
std::vector<CompletionVizData> completionVizDataItems;
RimVirtualPerforationResults* virtualPerforationResult = eclipseView->virtualPerforationResult();
{
const RigWellResultFrame* wResFrame = simWellData->wellResultFrame( frameIndex );
auto wellPaths = m_simWellInView->wellPipeBranches();
std::vector<CompletionVizData> completionVizDataItems;
const RigWellPath* wellPath = wellPaths[brIdx];
RimVirtualPerforationResults* virtualPerforationResult = eclipseView->virtualPerforationResult();
RigEclipseWellLogExtractor* extractor = RiaExtractionTools::findOrCreateSimWellExtractor( m_simWellInView, wellPath );
if ( extractor )
{
auto wellPaths = m_simWellInView->wellPipeBranches();
std::vector<WellPathCellIntersectionInfo> wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath();
const RigWellPath* wellPath = wellPaths[brIdx];
RigEclipseWellLogExtractor* extractor = RiaExtractionTools::findOrCreateSimWellExtractor( m_simWellInView, wellPath );
if ( extractor )
for ( const auto& intersectionInfo : wellPathCellIntersections )
{
std::vector<WellPathCellIntersectionInfo> wellPathCellIntersections = extractor->cellIntersectionInfosAlongWellPath();
size_t globalCellIndex = intersectionInfo.globCellIndex;
const RigWellResultPoint* wResCell = wResFrame->findResultCellWellHeadIncluded( 0, globalCellIndex );
for ( const auto& intersectionInfo : wellPathCellIntersections )
if ( !wResCell || !wResCell->isValid() )
{
size_t globalCellIndex = intersectionInfo.globCellIndex;
const RigWellResultPoint* wResCell = wResFrame->findResultCellWellHeadIncluded( 0, globalCellIndex );
continue;
}
if ( !wResCell || !wResCell->isValid() )
{
continue;
}
if ( !virtualPerforationResult->showConnectionFactorsOnClosedConnections() && !wResCell->isOpen() )
{
continue;
}
if ( !virtualPerforationResult->showConnectionFactorsOnClosedConnections() && !wResCell->isOpen() )
{
continue;
}
double startMD = intersectionInfo.startMD;
double endMD = intersectionInfo.endMD;
double startMD = intersectionInfo.startMD;
double endMD = intersectionInfo.endMD;
double middleMD = ( startMD + endMD ) / 2.0;
double middleMD = ( startMD + endMD ) / 2.0;
cvf::Vec3d domainCoord = wellPath->interpolatedPointAlongWellPath( middleMD );
cvf::Vec3d domainCoord = wellPath->interpolatedPointAlongWellPath( middleMD );
cvf::Vec3d p1;
cvf::Vec3d p2;
wellPath->twoClosestPoints( domainCoord, &p1, &p2 );
cvf::Vec3d p1;
cvf::Vec3d p2;
wellPath->twoClosestPoints( domainCoord, &p1, &p2 );
cvf::Vec3d direction = ( p2 - p1 ).getNormalized();
cvf::Vec3d direction = ( p2 - p1 ).getNormalized();
cvf::Vec3d anchor = displayXf->transformToDisplayCoord( domainCoord );
{
CompletionVizData data( anchor, direction, wResCell->connectionFactor(), globalCellIndex );
cvf::Vec3d anchor = displayXf->transformToDisplayCoord( domainCoord );
{
CompletionVizData data( anchor, direction, wResCell->connectionFactor(), globalCellIndex );
completionVizDataItems.push_back( data );
}
completionVizDataItems.push_back( data );
}
}
}
}
if ( !completionVizDataItems.empty() )
if ( !completionVizDataItems.empty() )
{
double radius = pipeRadius * virtualPerforationResult->geometryScaleFactor();
radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry
// scale factor is set to 1.0
pbd.m_connectionFactorGeometryGenerator = new RivWellConnectionFactorGeometryGenerator( completionVizDataItems, radius );
cvf::ScalarMapper* scalarMapper = virtualPerforationResult->legendConfig()->scalarMapper();
cvf::ref<cvf::Part> part =
pbd.m_connectionFactorGeometryGenerator->createSurfacePart( scalarMapper, eclipseView->isLightingDisabled() );
if ( part.notNull() )
{
double radius = pipeRadius * virtualPerforationResult->geometryScaleFactor();
radius *= 2.0; // Enlarge the radius slightly to make the connection factor visible if geometry
// scale factor is set to 1.0
pbd.m_connectionFactorGeometryGenerator = new RivWellConnectionFactorGeometryGenerator( completionVizDataItems, radius );
cvf::ScalarMapper* scalarMapper = virtualPerforationResult->legendConfig()->scalarMapper();
cvf::ref<cvf::Part> part =
pbd.m_connectionFactorGeometryGenerator->createSurfacePart( scalarMapper, eclipseView->isLightingDisabled() );
if ( part.notNull() )
{
cvf::ref<RivSimWellConnectionSourceInfo> simWellSourceInfo =
new RivSimWellConnectionSourceInfo( m_simWellInView, pbd.m_connectionFactorGeometryGenerator.p() );
part->setSourceInfo( simWellSourceInfo.p() );
}
pbd.m_connectionFactorsPart = part;
cvf::ref<RivSimWellConnectionSourceInfo> simWellSourceInfo =
new RivSimWellConnectionSourceInfo( m_simWellInView, pbd.m_connectionFactorGeometryGenerator.p() );
part->setSourceInfo( simWellSourceInfo.p() );
}
pbd.m_connectionFactorsPart = part;
}
}
}
}
if ( doFlatten ) flattenedStartOffset += { 2 * flattenedIntersectionExtentLength, 0.0, 0.0 };
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RivSimWellPipesPartMgr::appendValvesGeo( const RimEclipseView* eclipseView,
size_t frameIndex,
size_t brIdx,
const caf::DisplayCoordTransform* displayXf,
double wellPathRadius,
RivPipeBranchData& pbd )
{
if ( !m_simWellInView || !m_simWellInView->isWellValvesVisible( frameIndex ) ) return;
if ( !eclipseView || !eclipseView->ownerCase() ) return;
const auto characteristicCellSize = eclipseView->ownerCase()->characteristicCellSize();
const auto coords = pbd.m_pipeGeomGenerator->pipeCenterCoords();
std::set<std::pair<size_t, size_t>> resultPointWithValve;
for ( size_t i = 0; i < pbd.m_cellIds.size(); i++ )
{
const auto resultPoint = pbd.m_cellIds[i];
if ( resultPointWithValve.contains( { resultPoint.gridIndex(), resultPoint.cellIndex() } ) ) continue;
const auto segmentStartCoord = coords->get( i );
const auto segmentEndCoord = coords->get( i + 1 );
const auto segmentLength = ( segmentEndCoord - segmentStartCoord ).length();
const double valveLength = characteristicCellSize * 0.2;
// Insert valve geometry if the length of the segment is sufficient
if ( resultPoint.isConnectedToValve() && ( valveLength * 2 < segmentLength ) )
{
resultPointWithValve.insert( { resultPoint.gridIndex(), resultPoint.cellIndex() } );
const auto segmentDirection = ( segmentEndCoord - segmentStartCoord ).getNormalized();
// A segment ends at the center of a simulation cell
auto valveCenterCoord = ( segmentEndCoord + segmentStartCoord ) / 2.0;
const cvf::Color3f valveColor = cvf::Color3f::ORANGE;
const auto measuredDepthsRelativeToStartMD = { 0.0, 1.0, valveLength - 1.0, valveLength };
const auto outerValveRadius = wellPathRadius * 1.3;
const auto radii = { wellPathRadius, outerValveRadius, outerValveRadius, wellPathRadius };
// The location of the valve is adjusted to locate the valve at the center of the segment
double locationAdjustment = -valveLength / 2.0;
std::vector<cvf::Vec3d> displayCoords;
for ( const auto& mdRelativeToStart : measuredDepthsRelativeToStartMD )
{
displayCoords.push_back( valveCenterCoord + ( locationAdjustment + mdRelativeToStart ) * segmentDirection );
}
RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( &pbd.m_valveParts, displayCoords, radii, valveColor );
auto computeRotationAxisAndAngle = []( const cvf::Vec3f& direction ) {
// Compute upwards normal based on direction
// Compute the rotation axis and angle between up vector and Z_AXIS
cvf::Vec3f crossBetweenZAndDirection;
crossBetweenZAndDirection.cross( cvf::Vec3f::Z_AXIS, cvf::Vec3f( direction ) );
cvf::Vec3f upVector;
upVector.cross( cvf::Vec3f( direction ), crossBetweenZAndDirection );
cvf::Vec3f rotationAxis;
rotationAxis.cross( upVector, cvf::Vec3f::Z_AXIS );
upVector.normalize();
float angle = cvf::Math::acos( upVector * cvf::Vec3f::Z_AXIS );
return std::make_pair( rotationAxis, angle );
};
const auto& [rotationAxis, angle] = computeRotationAxisAndAngle( cvf::Vec3f( segmentDirection ) );
// Add visualization of valves openings for segments close to horizontal segments
if ( !std::isnan( angle ) && ( std::fabs( angle ) < ( std::numbers::pi / 2.0 ) ) )
{
cvf::GeometryBuilderDrawableGeo builder;
const float bottomRadius = wellPathRadius * 0.4f;
const float topRadius = bottomRadius;
const float height = outerValveRadius * 2.1f;
const float topOffsetX = 0.0f;
const float topOffsetY = 0.0f;
const uint numSlices = 12;
const bool normalsOutwards = true;
const bool closedBot = true;
const bool closedTop = true;
const uint numPolysZDir = 1;
cvf::GeometryUtils::createObliqueCylinder( bottomRadius,
topRadius,
height,
topOffsetX,
topOffsetY,
numSlices,
normalsOutwards,
closedBot,
closedTop,
numPolysZDir,
&builder );
// Move center of cylinder to origo
builder.transformVertexRange( 0, builder.vertexCount() - 1, cvf::Mat4f::fromTranslation( cvf::Vec3f( 0.0, 0.0, -height / 2.0 ) ) );
// Rotate cylinder to match the be normal to the well path direction
const cvf::Mat4f rotMat = cvf::Mat4f::fromRotation( rotationAxis, -angle );
builder.transformVertexRange( 0, builder.vertexCount() - 1, rotMat );
// Move the cylinder to display coordinate location
builder.transformVertexRange( 0, builder.vertexCount() - 1, cvf::Mat4f::fromTranslation( cvf::Vec3f( valveCenterCoord ) ) );
auto drawableGeo = builder.drawableGeo();
auto part = new cvf::Part;
part->setName( "RivPipeGeometryGenerator::surface" );
part->setDrawable( drawableGeo.p() );
caf::SurfaceEffectGenerator surfaceGen( cvf::Color4f( cvf::Color3f::BLACK ), caf::PO_1 );
auto eff = surfaceGen.generateCachedEffect();
part->setEffect( eff.p() );
pbd.m_valveParts.push_back( part );
}
}
}
}

View File

@@ -20,11 +20,12 @@
#include "RigSimWellData.h"
#include "cafPdmPointer.h"
#include "cvfCollection.h"
#include "cvfObject.h"
#include "cvfVector3.h"
#include "cafPdmPointer.h"
#include <list>
namespace cvf
@@ -42,6 +43,7 @@ class DisplayCoordTransform;
class RivPipeGeometryGenerator;
class Rim3dView;
class RimSimWellInView;
class RimEclipseView;
class RivWellConnectionFactorGeometryGenerator;
struct RigWellResultPoint;
@@ -65,15 +67,6 @@ public:
std::vector<double> flattenedBranchWellHeadOffsets();
private:
Rim3dView* viewWithSettings();
void buildWellPipeParts( const caf::DisplayCoordTransform* displayXf,
bool doFlatten,
double flattenedIntersectionExtentLength,
int branchIndex,
size_t frameIndex );
caf::PdmPointer<RimSimWellInView> m_simWellInView;
struct RivPipeBranchData
{
std::vector<RigWellResultPoint> m_cellIds;
@@ -87,10 +80,35 @@ private:
cvf::ref<RivWellConnectionFactorGeometryGenerator> m_connectionFactorGeometryGenerator;
cvf::ref<cvf::Part> m_connectionFactorsPart;
cvf::Collection<cvf::Part> m_valveParts;
};
Rim3dView* viewWithSettings();
void buildWellPipeParts( const caf::DisplayCoordTransform* displayXf,
bool doFlatten,
double flattenedIntersectionExtentLength,
int branchIndex,
size_t frameIndex );
void appendVirtualConnectionFactorGeo( const RimEclipseView* eclipseView,
size_t frameIndex,
size_t brIdx,
const caf::DisplayCoordTransform* displayXf,
double pipeRadius,
RivPipeBranchData& pbd );
void appendValvesGeo( const RimEclipseView* eclipseView,
size_t frameIndex,
size_t brIdx,
const caf::DisplayCoordTransform* displayXf,
double pipeRadius,
RivPipeBranchData& pbd );
private:
caf::PdmPointer<RimSimWellInView> m_simWellInView;
std::list<RivPipeBranchData> m_wellBranches;
std::vector<std::vector<cvf::Vec3d>> m_pipeBranchesCLCoords;
std::vector<double> m_flattenedBranchWellHeadOffsets;
std::vector<double> m_flattenedBranchWellHeadOffsets;
};

View File

@@ -961,11 +961,10 @@ void RivWellFracturePartMgr::appendFracturePerforationLengthParts( const RimEcli
double perforationRadius = wellPathRadius * 1.2;
cvf::Collection<cvf::Part> parts;
RivPipeGeometryGenerator geoGenerator;
geoGenerator.cylinderWithCenterLineParts( &parts,
displayCoords,
RiaColorTables::wellPathComponentColors()[RiaDefines::WellPathComponentType::PERFORATION_INTERVAL],
perforationRadius );
RivPipeGeometryGenerator::cylinderWithCenterLineParts( &parts,
displayCoords,
RiaColorTables::wellPathComponentColors()[RiaDefines::WellPathComponentType::PERFORATION_INTERVAL],
perforationRadius );
for ( auto part : parts )
{

View File

@@ -400,7 +400,6 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
double wellPathRadius = this->wellPathRadius( characteristicCellSize, wellPathCollection );
double perforationRadius = wellPathRadius * 1.1;
RivPipeGeometryGenerator geoGenerator;
std::vector<RimPerforationInterval*> perforations;
m_rimWellPath->descendantsIncludingThisOfType( perforations );
for ( RimPerforationInterval* perforation : perforations )
@@ -449,7 +448,7 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( perforation );
cvf::Collection<cvf::Part> parts;
geoGenerator.cylinderWithCenterLineParts( &parts, perfIntervalCLDiplayCS, cvf::Color3f::GREEN, perforationRadius );
RivPipeGeometryGenerator::cylinderWithCenterLineParts( &parts, perfIntervalCLDiplayCS, cvf::Color3f::GREEN, perforationRadius );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
@@ -457,7 +456,7 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
}
}
appendPerforationValvesToModel( model, perforation, wellPathRadius, displayCoordTransform, geoGenerator );
appendPerforationValvesToModel( model, perforation, wellPathRadius, displayCoordTransform );
}
}
@@ -467,31 +466,83 @@ void RivWellPathPartMgr::appendPerforationsToModel( cvf::ModelBasicList*
void RivWellPathPartMgr::appendPerforationValvesToModel( cvf::ModelBasicList* model,
RimPerforationInterval* perforation,
double wellPathRadius,
const caf::DisplayCoordTransform* displayCoordTransform,
RivPipeGeometryGenerator& geoGenerator )
const caf::DisplayCoordTransform* displayCoordTransform )
{
// Valves
for ( RimWellPathValve* valve : perforation->valves() )
{
for ( RimWellPathValve* valve : perforation->valves() )
if ( !valve->isChecked() ) continue;
std::vector<double> measuredDepthsRelativeToStartMD;
std::vector<double> radii;
cvf::Color3f valveColor = valve->defaultComponentColor();
if ( valve->componentType() == RiaDefines::WellPathComponentType::ICV )
{
if ( !valve->isChecked() ) continue;
measuredDepthsRelativeToStartMD = { 0.0, 1.0, 1.5, 4.0, 5.0, 5.5, 8.0, 9.0 };
radii = { wellPathRadius,
wellPathRadius * 1.8,
wellPathRadius * 2.0,
wellPathRadius * 2.0,
wellPathRadius * 1.8,
wellPathRadius * 1.7,
wellPathRadius * 1.7,
wellPathRadius };
std::vector<double> measuredDepthsRelativeToStartMD;
std::vector<double> radii;
cvf::Color3f valveColor = valve->defaultComponentColor();
if ( valve->componentType() == RiaDefines::WellPathComponentType::ICV )
double startMD = valve->startMD();
std::vector<cvf::Vec3d> displayCoords;
for ( double mdRelativeToStart : measuredDepthsRelativeToStartMD )
{
measuredDepthsRelativeToStartMD = { 0.0, 1.0, 1.5, 4.0, 5.0, 5.5, 8.0, 9.0 };
radii = { wellPathRadius,
wellPathRadius * 1.8,
wellPathRadius * 2.0,
wellPathRadius * 2.0,
wellPathRadius * 1.8,
wellPathRadius * 1.7,
wellPathRadius * 1.7,
wellPathRadius };
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( mdRelativeToStart * 0.333 * wellPathRadius + startMD ) ) );
}
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( valve );
cvf::Collection<cvf::Part> parts;
RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, valveColor );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
model->addPart( part.p() );
}
}
else if ( valve->componentType() == RiaDefines::WellPathComponentType::ICD ||
valve->componentType() == RiaDefines::WellPathComponentType::AICD )
{
std::vector<double> valveLocations = valve->valveLocations();
for ( double startMD : valveLocations )
{
int size = 16;
measuredDepthsRelativeToStartMD.resize( size );
radii.resize( size );
for ( int i = 0; i < size; i += 2 )
{
measuredDepthsRelativeToStartMD[i] = double( i / 2 );
measuredDepthsRelativeToStartMD[i + 1] = double( i / 2 + 0.5 );
}
radii[0] = wellPathRadius;
bool inner = false;
int nInners = 0;
for ( int i = 1; i < size - 1; i += 2 )
{
if ( inner && valve->componentType() == RiaDefines::WellPathComponentType::AICD && nInners > 0 )
{
radii[i + 1] = radii[i] = wellPathRadius * 1.7;
nInners = 0;
}
else if ( inner )
{
radii[i + 1] = radii[i] = wellPathRadius * 1.9;
nInners++;
}
else
{
radii[i + 1] = radii[i] = wellPathRadius * 2.0;
}
inner = !inner;
}
radii[size - 1] = wellPathRadius;
double startMD = valve->startMD();
std::vector<cvf::Vec3d> displayCoords;
for ( double mdRelativeToStart : measuredDepthsRelativeToStartMD )
{
@@ -503,70 +554,13 @@ void RivWellPathPartMgr::appendPerforationValvesToModel( cvf::ModelBasicList*
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( valve );
cvf::Collection<cvf::Part> parts;
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, valveColor );
RivPipeGeometryGenerator::tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, valveColor );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
model->addPart( part.p() );
}
}
else if ( valve->componentType() == RiaDefines::WellPathComponentType::ICD ||
valve->componentType() == RiaDefines::WellPathComponentType::AICD )
{
std::vector<double> valveLocations = valve->valveLocations();
for ( double startMD : valveLocations )
{
int size = 16;
measuredDepthsRelativeToStartMD.resize( size );
radii.resize( size );
for ( int i = 0; i < size; i += 2 )
{
measuredDepthsRelativeToStartMD[i] = double( i / 2 );
measuredDepthsRelativeToStartMD[i + 1] = double( i / 2 + 0.5 );
}
radii[0] = wellPathRadius;
bool inner = false;
int nInners = 0;
for ( int i = 1; i < size - 1; i += 2 )
{
if ( inner && valve->componentType() == RiaDefines::WellPathComponentType::AICD && nInners > 0 )
{
radii[i + 1] = radii[i] = wellPathRadius * 1.7;
nInners = 0;
}
else if ( inner )
{
radii[i + 1] = radii[i] = wellPathRadius * 1.9;
nInners++;
}
else
{
radii[i + 1] = radii[i] = wellPathRadius * 2.0;
}
inner = !inner;
}
radii[size - 1] = wellPathRadius;
std::vector<cvf::Vec3d> displayCoords;
for ( double mdRelativeToStart : measuredDepthsRelativeToStartMD )
{
displayCoords.push_back( displayCoordTransform->transformToDisplayCoord(
m_rimWellPath->wellPathGeometry()->interpolatedPointAlongWellPath( mdRelativeToStart * 0.333 * wellPathRadius +
startMD ) ) );
}
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( valve );
cvf::Collection<cvf::Part> parts;
geoGenerator.tubeWithCenterLinePartsAndVariableWidth( &parts, displayCoords, radii, valveColor );
for ( auto part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );
model->addPart( part.p() );
}
}
}
}
}
}
@@ -1027,8 +1021,6 @@ void RivWellPathPartMgr::appendWellIntegrityIntervalsToModel( cvf::ModelBasicLis
double wellPathRadius = this->wellPathRadius( characteristicCellSize, wellPathCollection );
double wiaIntervalRadius = wellPathRadius * 1.15;
RivPipeGeometryGenerator geoGenerator;
for ( auto wiaModel : m_rimWellPath->wellIASettingsCollection()->settings() )
{
if ( !wiaModel->isChecked() ) continue;
@@ -1053,7 +1045,7 @@ void RivWellPathPartMgr::appendWellIntegrityIntervalsToModel( cvf::ModelBasicLis
cvf::ref<RivObjectSourceInfo> objectSourceInfo = new RivObjectSourceInfo( wiaModel );
cvf::Collection<cvf::Part> parts;
geoGenerator.cylinderWithCenterLineParts( &parts, intervalCLDisplayCS, cvf::Color3f::ORCHID, wiaIntervalRadius );
RivPipeGeometryGenerator::cylinderWithCenterLineParts( &parts, intervalCLDisplayCS, cvf::Color3f::ORCHID, wiaIntervalRadius );
for ( auto& part : parts )
{
part->setSourceInfo( objectSourceInfo.p() );

View File

@@ -107,8 +107,7 @@ private:
void appendPerforationValvesToModel( cvf::ModelBasicList* model,
RimPerforationInterval* perforation,
double wellPathRadius,
const caf::DisplayCoordTransform* displayCoordTransform,
RivPipeGeometryGenerator& geoGenerator );
const caf::DisplayCoordTransform* displayCoordTransform );
void appendVirtualTransmissibilitiesToModel( cvf::ModelBasicList* model,
size_t timeStepIndex,