#2176 Fix the crash due to an invalid wellhead definition from libecl. Now using first valid connection-cell as proxywellhead in calculations if needed.

This commit is contained in:
Jacob Støren 2017-11-24 12:41:24 +01:00
parent 007fc87283
commit cf9f886856
4 changed files with 63 additions and 18 deletions

View File

@ -192,10 +192,10 @@ void RimSimWellInView::wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d*
RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData(); RigEclipseCaseData* rigReservoir = m_rimReservoirView->eclipseCase()->eclipseCaseData();
if (!this->simWellData()->hasWellResult(frameIndex)) return; if ( !this->simWellData()->hasAnyValidCells(frameIndex) ) return;
const RigWellResultFrame& wellResultFrame = this->simWellData()->wellResultFrame(frameIndex); const RigWellResultFrame& wellResultFrame = this->simWellData()->wellResultFrame(frameIndex);
const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.m_wellHead); const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.wellHeadOrStartCell());
// Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline() // Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline()

View File

@ -97,6 +97,39 @@ bool RigSimWellData::hasWellResult(size_t resultTimeStepIndex) const
return wellTimeStepIndex != cvf::UNDEFINED_SIZE_T; return wellTimeStepIndex != cvf::UNDEFINED_SIZE_T;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RigSimWellData::hasAnyValidCells(size_t resultTimeStepIndex) const
{
if (resultTimeStepIndex >= m_resultTimeStepIndexToWellTimeStepIndex.size())
{
return false;
}
size_t wellTimeStepIndex = m_resultTimeStepIndexToWellTimeStepIndex[resultTimeStepIndex];
if( wellTimeStepIndex == cvf::UNDEFINED_SIZE_T) return false;
if (wellResultFrame(resultTimeStepIndex).m_wellHead.isCell()) return true;
const std::vector<RigWellResultBranch> &resBranches = wellResultFrame(resultTimeStepIndex).m_wellResultBranches;
for ( size_t i = 0 ; i < resBranches.size(); ++i )
{
for (size_t cIdx = 0; cIdx < resBranches[i].m_branchResultPoints.size(); ++cIdx )
{
if (resBranches[i].m_branchResultPoints[cIdx].isCell()) return true;
}
}
return false;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool operator== (const RigWellResultPoint& p1, const RigWellResultPoint& p2) bool operator== (const RigWellResultPoint& p1, const RigWellResultPoint& p2)
{ {
return return
@ -340,3 +373,18 @@ const RigWellResultPoint* RigWellResultFrame::findResultCell(size_t gridIndex, s
return NULL; return NULL;
} }
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWellResultPoint RigWellResultFrame::wellHeadOrStartCell() const
{
if (m_wellHead.isCell()) return m_wellHead;
if (m_wellResultBranches.size() && m_wellResultBranches.front().m_branchResultPoints.size() )
{
return m_wellResultBranches.front().m_branchResultPoints.front();
}
return m_wellHead; // Nothing else to do
}

View File

@ -166,6 +166,7 @@ public:
const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const; const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const;
RigWellResultPoint wellHeadOrStartCell() const;
WellProductionType m_productionType; WellProductionType m_productionType;
bool m_isOpen; bool m_isOpen;
RigWellResultPoint m_wellHead; RigWellResultPoint m_wellHead;
@ -187,6 +188,8 @@ public:
bool isMultiSegmentWell() const; bool isMultiSegmentWell() const;
bool hasWellResult(size_t resultTimeStepIndex) const; bool hasWellResult(size_t resultTimeStepIndex) const;
bool hasAnyValidCells(size_t resultTimeStepIndex) const;
const RigWellResultFrame& wellResultFrame(size_t resultTimeStepIndex) const; const RigWellResultFrame& wellResultFrame(size_t resultTimeStepIndex) const;
bool isOpen(size_t resultTimeStepIndex) const; bool isOpen(size_t resultTimeStepIndex) const;
RigWellResultFrame::WellProductionType wellProductionType(size_t resultTimeStepIndex) const; RigWellResultFrame::WellProductionType wellProductionType(size_t resultTimeStepIndex) const;

View File

@ -91,8 +91,12 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF
std::vector<std::vector<cvf::Vec3d>> &pipeBranchesCLCoords, std::vector<std::vector<cvf::Vec3d>> &pipeBranchesCLCoords,
std::vector<std::vector<RigWellResultPoint>> &pipeBranchesCellIds) std::vector<std::vector<RigWellResultPoint>> &pipeBranchesCellIds)
{ {
// Initialize the return arrays
pipeBranchesCLCoords.clear();
pipeBranchesCellIds.clear();
if ( !wellResults) return; if ( !wellResults) return;
if ( timeStepIndex >= 0 && !wellResults->hasWellResult(timeStepIndex) ) return; if ( timeStepIndex >= 0 && !wellResults->hasAnyValidCells(timeStepIndex) ) return;
const RigWellResultFrame* wellFramePtr = nullptr; const RigWellResultFrame* wellFramePtr = nullptr;
@ -118,24 +122,14 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF
#endif #endif
const RigWellResultFrame& wellFrame = *wellFramePtr; const RigWellResultFrame& wellFrame = *wellFramePtr;
const std::vector<RigWellResultBranch>& resBranches = wellFrame.m_wellResultBranches;
// Initialize the return arrays
pipeBranchesCLCoords.clear();
pipeBranchesCellIds.clear();
if ( wellFrame.m_wellResultBranches.size() == 0 ) return;
// Well head // Well head
// Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts() // Match this position with well head position in RivWellHeadPartMgr::buildWellHeadParts()
const RigCell& whCell = eclipseCaseData->cellFromWellResultCell(wellFrame.m_wellHead); const RigCell& whCell = eclipseCaseData->cellFromWellResultCell(wellFrame.wellHeadOrStartCell());
cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K); cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K);
const RigWellResultPoint* whResCell = &(wellFrame.m_wellHead); const RigWellResultPoint* whResCell = &(wellFrame.wellHeadOrStartCell());
const std::vector<RigWellResultBranch>& resBranches = wellFrame.m_wellResultBranches;
if ( ! hasAnyResultCells(resBranches) ) return;
// Add extra coordinate between cell face and cell center // Add extra coordinate between cell face and cell center
// to make sure the well pipe terminated in a segment parallel to z-axis // to make sure the well pipe terminated in a segment parallel to z-axis
@ -594,7 +588,7 @@ public:
// Calculate wellhead to branch line ends distances // Calculate wellhead to branch line ends distances
{ {
const RigCell& whCell = m_eclipseCaseData->cellFromWellResultCell(m_orgWellResultFrame.m_wellHead); const RigCell& whCell = m_eclipseCaseData->cellFromWellResultCell(m_orgWellResultFrame.wellHeadOrStartCell());
cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K); cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K);
buildResBranchToBranchLineEndsDistMap(whStartPos, -1); buildResBranchToBranchLineEndsDistMap(whStartPos, -1);
@ -693,7 +687,7 @@ private:
m_branchedWell.m_wellResultBranches.push_back(RigWellResultBranch()); m_branchedWell.m_wellResultBranches.push_back(RigWellResultBranch());
branchIdx = static_cast<int>( m_branchedWell.m_wellResultBranches.size()) - 1; branchIdx = static_cast<int>( m_branchedWell.m_wellResultBranches.size()) - 1;
RigWellResultPoint wellHeadAsPoint; RigWellResultPoint wellHeadAsPoint;
const RigCell& whCell = m_eclipseCaseData->cellFromWellResultCell(m_orgWellResultFrame.m_wellHead); const RigCell& whCell = m_eclipseCaseData->cellFromWellResultCell(m_orgWellResultFrame.wellHeadOrStartCell());
cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K); cvf::Vec3d whStartPos = whCell.faceCenter(cvf::StructGridInterface::NEG_K);
wellHeadAsPoint.m_bottomPosition = whStartPos; wellHeadAsPoint.m_bottomPosition = whStartPos;