From d5aa8e4f30a245d7f0e2d314c50b191eadc2598b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 26 Aug 2013 15:10:34 +0200 Subject: [PATCH] MswRollUp: Principal fixes to the MSW algorithms Add point contributions even when it is undefined to store the segment below id, which is needed for the traversal. The undefined positions comes from bottom end segments without connections. Also cleaned up the the static well calculation This is an intermediate commit and does not compile p4#: 22226 --- .../FileInterface/RifReaderEclipseOutput.cpp | 93 ++++++++++--------- .../RivWellPipesPartMgr.cpp | 1 + .../RigSingleWellResultsData.cpp | 21 +---- 3 files changed, 51 insertions(+), 64 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 2df75f1875..27aae6ed1d 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -854,8 +854,6 @@ void propagatePosContribDownwards(std::map >::iterator posContribIt; posContribIt = segmentIdToPositionContrib.find(ertSegmentId); - well_segment_type *segment = well_segment_collection_get( allErtSegments , posContribIt->first); - double sementLength = well_segment_get_length(segment); if ( posContribIt != segmentIdToPositionContrib.end()) { @@ -867,7 +865,12 @@ void propagatePosContribDownwards(std::mapsecond[i].m_segmentIdUnder); } - // If we do naot have the contribution represented, add it, and accumulate the length + // Get the segment length to add to the contributions + + well_segment_type *segment = well_segment_collection_get( allErtSegments , posContribIt->first); + double sementLength = well_segment_get_length(segment); + + // If we do not have the contribution represented, add it, and accumulate the length // If it is already present, do not touch for (size_t i = 0; i < posContrib.size(); ++i) { @@ -883,8 +886,8 @@ void propagatePosContribDownwards(std::mapsecond.push_back(posContrib[i]); posContrib[i].m_lengthFromConnection += sementLength; + posContribIt->second.push_back(posContrib[i]); } } @@ -1072,12 +1075,11 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) wellResultBranch.m_branchResultPoints.push_back(data); // Store data for segment position calculation - if (lastConnectionPos != cvf::Vec3d::UNDEFINED) - { - segmentIdToPositionContrib[well_segment_get_id(segment)].push_back( - SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow)); - accLengthFromLastConnection += well_segment_get_length(segment); - } + + segmentIdToPositionContrib[well_segment_get_id(segment)].push_back( + SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow)); + accLengthFromLastConnection += well_segment_get_length(segment); + } segmentIdBelow = well_segment_get_id(segment); @@ -1133,9 +1135,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) // Store data for segment position calculation, and propagate it upwards until we meet a segment with connections - if (lastConnectionPos != cvf::Vec3d::UNDEFINED) - { - segmentIdToPositionContrib[well_segment_get_id(outletSegment)].push_back( + segmentIdToPositionContrib[well_segment_get_id(outletSegment)].push_back( SegmentPositionContribution(lastConnectionSegmentId, lastConnectionPos, accLengthFromLastConnection, segmentIdBelow)); /// Loop further to add this position contribution until a segment with connections is found @@ -1193,12 +1193,14 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) aboveOutletSegment = well_segment_get_outlet(aboveOutletSegment); } } - } + + } } else { - // Add wellhead as result point ? + // Add wellhead as result point Nope. Not Yet, but it is a good idea. + // The centerline calculations would be a bit simpler, I think. } // Reverse the order of the resultpoints in this branch, making the deepest come last @@ -1214,35 +1216,46 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) { RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches[ bIdx]; bool previousResultPointWasCell = false; + if (bIdx == 0) previousResultPointWasCell = true; // Wellhead + for (size_t rpIdx = 0; rpIdx < wellResultBranch.m_branchResultPoints.size(); ++rpIdx) { - if ( wellResultBranch.m_branchResultPoints[rpIdx].isCell() ) + RigWellResultPoint resPoint = wellResultBranch.m_branchResultPoints[rpIdx]; + if ( resPoint.isCell() ) { previousResultPointWasCell = true; } - else if (previousResultPointWasCell) + else { - CVF_ASSERT(rpIdx > 0); - RigWellResultPoint prevResPoint = wellResultBranch.m_branchResultPoints[rpIdx - 1 ]; - cvf::Vec3d lastConnectionPos = grids[prevResPoint.m_gridIndex]->cell(prevResPoint.m_gridCellIndex).center(); - well_segment_type *segment = well_segment_collection_get( allErtSegments , prevResPoint.m_ertSegmentId); - const well_conn_collection_type* connections = well_segment_get_connections(segment, this->ertGridName(prevResPoint.m_gridIndex).data()); - int connectionCount = well_conn_collection_get_size(connections); + if (previousResultPointWasCell) + { + RigWellResultPoint prevResPoint; + if (bIdx == 0 && rpIdx == 0) + { + prevResPoint = wellResFrame.m_wellHead; + } + else + { + prevResPoint = wellResultBranch.m_branchResultPoints[rpIdx - 1 ]; + } - double accLengthFromLastConnection = well_segment_get_length(segment)/(connectionCount+1); + cvf::Vec3d lastConnectionPos = grids[prevResPoint.m_gridIndex]->cell(prevResPoint.m_gridCellIndex).center(); - SegmentPositionContribution posContrib(prevResPoint.m_ertSegmentId, lastConnectionPos, accLengthFromLastConnection, -1); + SegmentPositionContribution posContrib(prevResPoint.m_ertSegmentId, lastConnectionPos, 0.0, -1); - int ertSegmentId = wellResultBranch.m_branchResultPoints[rpIdx].m_ertSegmentId; + int ertSegmentId = resPoint.m_ertSegmentId; - std::map >::iterator posContribIt; - posContribIt = segmentIdToPositionContrib.find(ertSegmentId); - CVF_ASSERT(posContribIt != segmentIdToPositionContrib.end()); + std::map >::iterator posContribIt; + posContribIt = segmentIdToPositionContrib.find(ertSegmentId); + CVF_ASSERT(posContribIt != segmentIdToPositionContrib.end()); - std::vector posContributions = posContribIt->second; - posContributions.push_back(posContrib); + std::vector posContributions = posContribIt->second; + posContributions.push_back(posContrib); - propagatePosContribDownwards(segmentIdToPositionContrib, allErtSegments, ertSegmentId, posContributions); + propagatePosContribDownwards(segmentIdToPositionContrib, allErtSegments, ertSegmentId, posContributions); + } + + previousResultPointWasCell = false; } } } @@ -1579,19 +1592,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) // All the grids does not necessarily have a well head definition. } - - std::string gridName; - if (gridNr == 0) - { - gridName = ECL_GRID_GLOBAL_GRID; - } - else - { - RigGridBase* rigGrid = m_eclipseCase->grid(gridNr); - gridName = rigGrid->gridName(); - } - - const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, gridName.data()); + const well_conn_collection_type* connections = well_state_get_grid_connections(ert_well_state, this->ertGridName(gridNr).data()); // Import all well result cells for all connections if (connections) @@ -1603,7 +1604,7 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) RigWellResultBranch& wellResultBranch = wellResFrame.m_wellResultBranches.back(); wellResultBranch.m_branchIndex = 0; - wellResultBranch.m_ertBranchId = -1; + wellResultBranch.m_ertBranchId = 0; // Normal wells have only one branch size_t existingCellCount = wellResultBranch.m_branchResultPoints.size(); wellResultBranch.m_branchResultPoints.resize(existingCellCount + connectionCount); diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index ffd969401f..98903f94cf 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -206,6 +206,7 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector if (resBranches[i].m_branchResultPoints.size() != 0) { hasResultCells = true; + break; } } } diff --git a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp index 120bc22ac0..bbe158fc5f 100644 --- a/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp +++ b/ApplicationCode/ReservoirDataModel/RigSingleWellResultsData.cpp @@ -126,7 +126,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath() for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[0].m_wellResultBranches.size(); ++bIdx) { - size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchIndex; + size_t branchNumber = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_ertBranchId; std::vector& frameCells = m_wellCellsTimeSteps[0].m_wellResultBranches[bIdx].m_branchResultPoints; std::list< RigWellResultPoint >& branch = staticWellBranches[branchNumber]; @@ -145,7 +145,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath() for (size_t bIdx = 0; bIdx < m_wellCellsTimeSteps[tIdx].m_wellResultBranches.size(); ++bIdx) { - size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchIndex; + size_t branchNumber = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_ertBranchId; std::vector& resBranch = m_wellCellsTimeSteps[tIdx].m_wellResultBranches[bIdx].m_branchResultPoints; std::list< RigWellResultPoint >& stBranch = staticWellBranches[branchNumber]; @@ -161,17 +161,9 @@ void RigSingleWellResultsData::computeStaticWellCellPath() bool found = false; if (stBranch.size()) { - size_t sGridIdx = sEndIt->m_gridIndex; - size_t sCellIdx = sEndIt->m_gridCellIndex; - for (rEndIdx = 0; !found && rEndIdx < resBranch.size(); ++rEndIdx) { - size_t rGridIdx = resBranch[rEndIdx].m_gridIndex; - size_t rCellIdx = resBranch[rEndIdx].m_gridCellIndex; - - //if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; } if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; } - } } @@ -206,16 +198,9 @@ void RigSingleWellResultsData::computeStaticWellCellPath() if (sEndIt != stBranch.end()) ++sEndIt; for ( ; sEndIt != stBranch.end() ; ++sEndIt) { - size_t sGridIdx = sEndIt->m_gridIndex; - size_t sCellIdx = sEndIt->m_gridCellIndex; - bool found = false; for (rEndIdx += 1; !found && rEndIdx < resBranch.size(); ++rEndIdx) { - size_t rGridIdx = resBranch[rEndIdx].m_gridIndex; - size_t rCellIdx = resBranch[rEndIdx].m_gridCellIndex; - - //if (sGridIdx == rGridIdx && sCellIdx == rCellIdx) { found = true; break; } if ((*sEndIt) == (resBranch[rEndIdx])) { found = true; break; } } @@ -264,7 +249,7 @@ void RigSingleWellResultsData::computeStaticWellCellPath() // Copy from first time step RigWellResultBranch rigBranch = m_wellCellsTimeSteps[0].m_wellResultBranches[bIt->first]; - rigBranch.m_branchIndex = bIt->first; + rigBranch.m_ertBranchId = bIt->first; // Clear well cells, and insert the collection of well cells for the static situation rigBranch.m_branchResultPoints.clear();