diff --git a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp index 1416773136..7b9f585962 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicExportFishbonesWellSegmentsFeature.cpp @@ -297,13 +297,13 @@ void RicExportFishbonesWellSegmentsFeature::generateWelsegsTable(RifEclipseDataT { if (wellPath->fishbonesCollection()->lengthAndDepth() == RimFishbonesCollection::INC) { - depth = intersection.depth; - length = intersection.length; + depth = intersection.tvdChangeFromPreviousIntersection; + length = intersection.mdFromPreviousIntersection; } else { - depth += intersection.depth; - length += intersection.length; + depth += intersection.tvdChangeFromPreviousIntersection; + length += intersection.mdFromPreviousIntersection; } double diameter = computeEffectiveDiameter(location.fishbonesSubs->tubingDiameter(unitSystem), location.fishbonesSubs->holeDiameter(unitSystem)); formatter.add(intersection.segmentNumber); @@ -370,10 +370,10 @@ void RicExportFishbonesWellSegmentsFeature::generateCompsegsTable(RifEclipseData formatter.addZeroBasedCellIndex(i).addZeroBasedCellIndex(j).addZeroBasedCellIndex(k); formatter.add(lateral.branchNumber); formatter.add(aggregatedLength); - formatter.add(aggregatedLength + intersection.length); + formatter.add(aggregatedLength + intersection.mdFromPreviousIntersection); formatter.rowCompleted(); - aggregatedLength += intersection.length; + aggregatedLength += intersection.mdFromPreviousIntersection; } } } diff --git a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp index 3804595e3f..0db211a755 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicFishbonesTransmissibilityCalculationFeatureImp.cpp @@ -37,7 +37,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWellBoreParts(std::map >& wellBorePartsInCells, const RimWellPath* wellPath, const RicExportCompletionDataSettingsUi& settings) +void RicFishbonesTransmissibilityCalculationFeatureImp::findFishboneLateralsWellBoreParts(std::map >& wellBorePartsInCells, + const RimWellPath* wellPath, + const RicExportCompletionDataSettingsUi& settings) { // Generate data const RigEclipseCaseData* caseData = settings.caseToApply()->eclipseCaseData(); diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp index 827e57dc78..a5ec9c4f40 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.cpp @@ -848,7 +848,7 @@ std::vector RicWellPathExportCompletionDataFeature::findWel } std::sort(wellSegmentLocations.begin(), wellSegmentLocations.end(), wellSegmentLocationOrdering); - assignBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations); + assignLateralIntersectionsAndBranchAndSegmentNumbers(caseToApply, &wellSegmentLocations); return wellSegmentLocations; } @@ -856,14 +856,15 @@ std::vector RicWellPathExportCompletionDataFeature::findWel //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const RimEclipseCase* caseToApply, +void RicWellPathExportCompletionDataFeature::assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum) { for (WellSegmentLateral& lateral : location->laterals) { - lateral.branchNumber = ++(*branchNum); + ++(*branchNum); + lateral.branchNumber = (*branchNum); std::vector > lateralCoordMDPairs = location->fishbonesSubs->coordsAndMDForLateral(location->subIndex, lateral.lateralIndex); @@ -884,8 +885,8 @@ void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const lateralMDs); auto intersection = intersections.cbegin(); - double length = 0; - double depth = 0; + double mdFromPreviousIntersection = 0; + double tvdChangeFromPreviousIntersection = 0; cvf::Vec3d startPoint = lateralCoords[0]; int attachedSegmentNumber = location->icdSegmentNumber; @@ -893,28 +894,31 @@ void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const { if (isPointBetween(startPoint, lateralCoords[i], intersection->endPoint)) { - length += (intersection->endPoint - startPoint).length(); - depth += intersection->endPoint.z() - startPoint.z(); + mdFromPreviousIntersection += (intersection->endPoint - startPoint).length(); + tvdChangeFromPreviousIntersection += intersection->endPoint.z() - startPoint.z(); + ++(*segmentNum); - WellSegmentLateralIntersection lateralIntersection( ++(*segmentNum), + WellSegmentLateralIntersection lateralIntersection((*segmentNum), attachedSegmentNumber, intersection->globCellIndex, - length, - depth); + mdFromPreviousIntersection, + tvdChangeFromPreviousIntersection, + intersection->internalCellLengths); - lateralIntersection.lengthsInCell = intersection->internalCellLengths; lateral.intersections.push_back(lateralIntersection); - length = 0; - depth = 0; + mdFromPreviousIntersection = 0; + tvdChangeFromPreviousIntersection = 0; + startPoint = intersection->endPoint; - attachedSegmentNumber = *segmentNum; + + attachedSegmentNumber = (*segmentNum); ++intersection; } else { - length += (lateralCoords[i] - startPoint).length(); - depth += lateralCoords[i].z() - startPoint.z(); + mdFromPreviousIntersection += (lateralCoords[i] - startPoint).length(); + tvdChangeFromPreviousIntersection += lateralCoords[i].z() - startPoint.z(); startPoint = lateralCoords[i]; } } @@ -924,10 +928,11 @@ void RicWellPathExportCompletionDataFeature::calculateLateralIntersections(const //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RicWellPathExportCompletionDataFeature::assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) +void RicWellPathExportCompletionDataFeature::assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations) { int segmentNumber = 1; int branchNumber = 1; + // First loop over the locations so that each segment on the main stem is an incremental number for (WellSegmentLocation& location : *locations) { @@ -935,10 +940,11 @@ void RicWellPathExportCompletionDataFeature::assignBranchAndSegmentNumbers(const location.icdBranchNumber = ++branchNumber; location.icdSegmentNumber = ++segmentNumber; } + // Then assign branch and segment numbers to each lateral parts for (WellSegmentLocation& location : *locations) { - calculateLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber); + assignLateralIntersections(caseToApply, &location, &branchNumber, &segmentNumber); } } diff --git a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h index 5dcfa9d450..c72ce87fb8 100644 --- a/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h +++ b/ApplicationCode/Commands/CompletionCommands/RicWellPathExportCompletionDataFeature.h @@ -43,12 +43,18 @@ class RimWellPath; /// //================================================================================================== struct WellSegmentLateralIntersection { - WellSegmentLateralIntersection(int segmentNumber, int attachedSegmentNumber, size_t cellIndex, double length, double depth) + WellSegmentLateralIntersection(int segmentNumber, + int attachedSegmentNumber, + size_t cellIndex, + double length, + double depth, + const cvf::Vec3d& lengthsInCell) : segmentNumber(segmentNumber), attachedSegmentNumber(attachedSegmentNumber), cellIndex(cellIndex), - length(length), - depth(depth), + mdFromPreviousIntersection(length), + tvdChangeFromPreviousIntersection(depth), + lengthsInCell(lengthsInCell), mainBoreCell(false) {} @@ -56,8 +62,8 @@ struct WellSegmentLateralIntersection { int attachedSegmentNumber; size_t cellIndex; bool mainBoreCell; - double length; - double depth; + double mdFromPreviousIntersection; + double tvdChangeFromPreviousIntersection; cvf::Vec3d lengthsInCell; }; @@ -172,8 +178,8 @@ private: static bool wellSegmentLocationOrdering(const WellSegmentLocation& first, const WellSegmentLocation& second); static bool isPointBetween(const cvf::Vec3d& pointA, const cvf::Vec3d& pointB, const cvf::Vec3d& needle); - static void calculateLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); - static void assignBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); + static void assignLateralIntersections(const RimEclipseCase* caseToApply, WellSegmentLocation* location, int* branchNum, int* segmentNum); + static void assignLateralIntersectionsAndBranchAndSegmentNumbers(const RimEclipseCase* caseToApply, std::vector* locations); static void appendCompletionData(std::map >* completionData, const std::vector& data); diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp index a96e8fe928..239ce837d3 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.cpp @@ -55,13 +55,17 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateIntersections(const RimProject* project, const RimEclipseCase* eclipseCase, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate) +void RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(const RimProject* project, + const RimEclipseCase* eclipseCase, + const RigMainGrid* grid, + std::vector& completionTypeCellResults, + const QDateTime& fromDate) { for (const RimWellPath* wellPath : project->activeOilField()->wellPathCollection->wellPaths) { if (wellPath->showWellPath()) { - calculateWellPathIntersections(wellPath, grid, values, fromDate); + calculateWellPathIntersections(wellPath, grid, completionTypeCellResults, fromDate); } } @@ -72,7 +76,7 @@ void RimCompletionCellIntersectionCalc::calculateIntersections(const RimProject* { for (RimSimWellFracture* fracture : simWell->simwellFractureCollection()->simwellFractures()) { - calculateFractureIntersections(grid, fracture, values); + calculateFractureIntersections(grid, fracture, completionTypeCellResults); } } } @@ -82,9 +86,13 @@ void RimCompletionCellIntersectionCalc::calculateIntersections(const RimProject* //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const RimWellPath* wellPath, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate) +void RimCompletionCellIntersectionCalc::calculateWellPathIntersections(const RimWellPath* wellPath, + const RigMainGrid* grid, + std::vector& values, + const QDateTime& fromDate) { - std::vector intersections = RigWellPathIntersectionTools::getIntersectedCells(grid, wellPath->wellPathGeometry()->m_wellPathPoints); + std::vector intersections = RigWellPathIntersectionTools::getIntersectedCells(grid, + wellPath->wellPathGeometry()->m_wellPathPoints); for (auto& intersection : intersections) { diff --git a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h index 9613fdf348..d7d997aff7 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h +++ b/ApplicationCode/ProjectDataModel/Completions/RimCompletionCellIntersectionCalc.h @@ -41,8 +41,12 @@ class QDateTime; class RimCompletionCellIntersectionCalc { public: - static void calculateIntersections(const RimProject* project, const RimEclipseCase* eclipseCase, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate); - + static void calculateCompletionTypeResult(const RimProject* project, + const RimEclipseCase* eclipseCase, + const RigMainGrid* grid, + std::vector& completionTypeCellResult, + const QDateTime& fromDate); + private: static void calculateWellPathIntersections(const RimWellPath* wellPath, const RigMainGrid* grid, std::vector& values, const QDateTime& fromDate); static void calculateFishbonesIntersections(const RimFishbonesMultipleSubs* fishbonesSubs, const RigMainGrid* grid, std::vector& values); diff --git a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp index d1979ac7ed..8b35439fb3 100644 --- a/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigCaseCellResultsData.cpp @@ -2257,7 +2257,7 @@ void RigCaseCellResultsData::computeCompletionTypeForTimeStep(size_t timeStep) QDateTime timeStepDate = this->timeStepDates()[timeStep]; - RimCompletionCellIntersectionCalc::calculateIntersections(project, eclipseCase, m_ownerMainGrid, completionTypeResult, timeStepDate); + RimCompletionCellIntersectionCalc::calculateCompletionTypeResult(project, eclipseCase, m_ownerMainGrid, completionTypeResult, timeStepDate); } diff --git a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp index 8779c0d681..7f55a2aa4c 100644 --- a/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigEclipseWellLogExtractor.cpp @@ -153,9 +153,15 @@ std::vector RigEclipseWellLogExtractor::cellInters if (cellIdx1 == cellIdx2) { cvf::Vec3d internalCellLengths; - internalCellLengths = RigWellPathIntersectionTools::calculateLengthInCell( m_caseData->mainGrid(), cellIdx1, m_intersections[cpIdx], m_intersections[cpIdx+1] ); + internalCellLengths = RigWellPathIntersectionTools::calculateLengthInCell(m_caseData->mainGrid(), + cellIdx1, + m_intersections[cpIdx], + m_intersections[cpIdx+1]); - cellIntersectionInfos.push_back(WellPathCellIntersectionInfo(cellIdx1, m_intersections[cpIdx], m_intersections[cpIdx+1], internalCellLengths)); + cellIntersectionInfos.push_back(WellPathCellIntersectionInfo(cellIdx1, + m_intersections[cpIdx], + m_intersections[cpIdx+1], + internalCellLengths)); } } } diff --git a/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.cpp b/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.cpp index 5c1edbe2b8..ee9472bd79 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellLogExtractor.cpp @@ -25,7 +25,9 @@ //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -RigWellLogExtractor::RigWellLogExtractor(const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName) : m_wellPath(wellpath), m_wellCaseErrorMsgName(wellCaseErrorMsgName) +RigWellLogExtractor::RigWellLogExtractor(const RigWellPath* wellpath, const std::string& wellCaseErrorMsgName) + : m_wellPath(wellpath), + m_wellCaseErrorMsgName(wellCaseErrorMsgName) { } @@ -95,9 +97,9 @@ void RigWellLogExtractor::insertIntersectionsInMap(const std::vectorinsert(std::make_pair(RigMDCellIdxEnterLeaveKey(measuredDepthOfPoint, - intersections[intIdx].m_hexIndex, - intersections[intIdx].m_isIntersectionEntering), - intersections[intIdx])); + intersections[intIdx].m_hexIndex, + intersections[intIdx].m_isIntersectionEntering), + intersections[intIdx])); } } diff --git a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp index 7194975fad..9fc2c99f82 100644 --- a/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp +++ b/ApplicationCode/ReservoirDataModel/RigWellPathIntersectionTools.cpp @@ -42,15 +42,16 @@ std::vector RigWellPathIntersectionTools::findCell const RigMainGrid* grid = caseData->mainGrid(); if (pathCoords.size() < 2) return intersectionInfos; + cvf::ref dummyWellPath = new RigWellPath; dummyWellPath->m_wellPathPoints = pathCoords; dummyWellPath->m_measuredDepths = pathMds; - cvf::ref extractor = new RigEclipseWellLogExtractor(caseData, dummyWellPath.p(), caseData->ownerCase()->caseUserDescription().toStdString()); + cvf::ref extractor = new RigEclipseWellLogExtractor(caseData, + dummyWellPath.p(), + caseData->ownerCase()->caseUserDescription().toStdString()); return extractor->cellIntersectionInfo(); - - } //--------------------------------------------------------------------------------------------------