From 42408eda740666c9e4fcf93cad3db1c9978d6e3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jacob=20St=C3=B8ren?= Date: Mon, 26 Aug 2013 14:21:21 +0200 Subject: [PATCH] MswRollUp: Added some guarding to get the Troll_MSW case through. Needs some assert disabling in RigGridBase as well, but it is not included yet This is an intermediate commit and does not compile p4#: 22218 --- .../FileInterface/RifReaderEclipseOutput.cpp | 49 ++++++++++--------- .../RivWellPipesPartMgr.cpp | 15 +++++- 2 files changed, 40 insertions(+), 24 deletions(-) diff --git a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp index 48492de905..c2bf28e0a3 100644 --- a/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp +++ b/ApplicationCode/FileInterface/RifReaderEclipseOutput.cpp @@ -1004,30 +1004,34 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) } } - RigWellResultBranch& outletResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + outletErtBranchIndex]; - - int outletErtSegmentId = well_segment_get_branch_id(outletBranchSegment); - size_t lastCellIndexForSegmentIdInOutletBranch = cvf::UNDEFINED_SIZE_T; - - for (size_t outletCellIdx = 0; outletCellIdx < outletResultBranch.m_branchResultPoints.size(); outletCellIdx++) + if (outletErtBranchIndex != cvf::UNDEFINED_SIZE_T) // Todo: Is this a correct guarding ? Or is it indicating an error ? { - if (outletResultBranch.m_branchResultPoints[outletCellIdx].m_ertSegmentId == outletErtSegmentId) + RigWellResultBranch& outletResultBranch = wellResFrame.m_wellResultBranches[currentGridBranchStartIndex + outletErtBranchIndex]; + + int outletErtSegmentId = well_segment_get_branch_id(outletBranchSegment); + size_t lastCellIndexForSegmentIdInOutletBranch = cvf::UNDEFINED_SIZE_T; + + for (size_t outletCellIdx = 0; outletCellIdx < outletResultBranch.m_branchResultPoints.size(); outletCellIdx++) { - lastCellIndexForSegmentIdInOutletBranch = outletCellIdx; + if (outletResultBranch.m_branchResultPoints[outletCellIdx].m_ertSegmentId == outletErtSegmentId) + { + lastCellIndexForSegmentIdInOutletBranch = outletCellIdx; + } } - } - if (lastCellIndexForSegmentIdInOutletBranch == cvf::UNDEFINED_SIZE_T) - { - // Did not find the cell in the outlet branch based on branch id and segment id from outlet cell in leaf branch - CVF_ASSERT(0); - } - else - { - RigWellResultPoint& outletCell = outletResultBranch.m_branchResultPoints[lastCellIndexForSegmentIdInOutletBranch]; + if (lastCellIndexForSegmentIdInOutletBranch == cvf::UNDEFINED_SIZE_T) + { + // Did not find the cell in the outlet branch based on branch id and segment id from outlet cell in leaf branch + //std::cout << "Did not find the cell in the outlet branch based on branch id and segment id from outlet cell in leaf branch" << std::endl; + //CVF_ASSERT(0); + } + else + { + RigWellResultPoint& outletCell = outletResultBranch.m_branchResultPoints[lastCellIndexForSegmentIdInOutletBranch]; - wellResultLeafBranch.m_outletBranchIndex_OBSOLETE = currentGridBranchStartIndex + outletErtBranchIndex; - wellResultLeafBranch.m_outletBranchHeadCellIndex_OBSOLETE = lastCellIndexForSegmentIdInOutletBranch; + wellResultLeafBranch.m_outletBranchIndex_OBSOLETE = currentGridBranchStartIndex + outletErtBranchIndex; + wellResultLeafBranch.m_outletBranchHeadCellIndex_OBSOLETE = lastCellIndexForSegmentIdInOutletBranch; + } } } @@ -1122,9 +1126,10 @@ void RifReaderEclipseOutput::readWellCells(const ecl_grid_type* mainEclGrid) size_t outCellIdx = wellResFrame.m_wellResultBranches[bIdx].m_outletBranchHeadCellIndex_OBSOLETE; const RigWellResultPoint* resPoint = wellResFrame.findResultCellFromOutletSpecification(outBranchIdx, outCellIdx); - - wellResFrame.m_wellResultBranches[bIdx].m_branchResultPoints.insert(wellResFrame.m_wellResultBranches[bIdx].m_branchResultPoints.begin(), *resPoint); - + if (resPoint) // Todo: Is this a correct guarding or indicating an error ? + { + wellResFrame.m_wellResultBranches[bIdx].m_branchResultPoints.insert(wellResFrame.m_wellResultBranches[bIdx].m_branchResultPoints.begin(), *resPoint); + } } } diff --git a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp index 180df4188b..b42eda1720 100644 --- a/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp +++ b/ApplicationCode/ModelVisualization/RivWellPipesPartMgr.cpp @@ -252,8 +252,19 @@ void RivWellPipesPartMgr::calculateWellPipeCenterline( std::vector< std::vector for (size_t brIdx = 0; brIdx < resBranches.size(); brIdx++) { - if (resBranches[brIdx].m_branchResultPoints.size() == 0) - continue; // Skip empty branches. Do not know why they exist, but they make problems. + + // Skip empty branches. Do not know why they exist, but they make problems. + bool hasValidData = false; + for (size_t cIdx = 0; cIdx < resBranches[brIdx].m_branchResultPoints.size(); ++cIdx) + { + if (resBranches[brIdx].m_branchResultPoints[cIdx].isValid()) + { + hasValidData = true; + break; + } + } + if (!hasValidData) continue; + prevWellResPoint = NULL;