mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-09 23:16:00 -06:00
#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:
parent
007fc87283
commit
cf9f886856
@ -192,10 +192,10 @@ void RimSimWellInView::wellHeadTopBottomPosition(size_t frameIndex, cvf::Vec3d*
|
||||
|
||||
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 RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.m_wellHead);
|
||||
const RigCell& whCell = rigReservoir->cellFromWellResultCell(wellResultFrame.wellHeadOrStartCell());
|
||||
|
||||
// Match this position with pipe start position in RivWellPipesPartMgr::calculateWellPipeCenterline()
|
||||
|
||||
|
@ -97,6 +97,39 @@ bool RigSimWellData::hasWellResult(size_t resultTimeStepIndex) const
|
||||
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)
|
||||
{
|
||||
return
|
||||
@ -340,3 +373,18 @@ const RigWellResultPoint* RigWellResultFrame::findResultCell(size_t gridIndex, s
|
||||
|
||||
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
|
||||
}
|
||||
|
@ -166,6 +166,7 @@ public:
|
||||
|
||||
const RigWellResultPoint* findResultCell(size_t gridIndex, size_t gridCellIndex) const;
|
||||
|
||||
RigWellResultPoint wellHeadOrStartCell() const;
|
||||
WellProductionType m_productionType;
|
||||
bool m_isOpen;
|
||||
RigWellResultPoint m_wellHead;
|
||||
@ -187,6 +188,8 @@ public:
|
||||
bool isMultiSegmentWell() const;
|
||||
|
||||
bool hasWellResult(size_t resultTimeStepIndex) const;
|
||||
bool hasAnyValidCells(size_t resultTimeStepIndex) const;
|
||||
|
||||
const RigWellResultFrame& wellResultFrame(size_t resultTimeStepIndex) const;
|
||||
bool isOpen(size_t resultTimeStepIndex) const;
|
||||
RigWellResultFrame::WellProductionType wellProductionType(size_t resultTimeStepIndex) const;
|
||||
|
@ -91,8 +91,12 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF
|
||||
std::vector<std::vector<cvf::Vec3d>> &pipeBranchesCLCoords,
|
||||
std::vector<std::vector<RigWellResultPoint>> &pipeBranchesCellIds)
|
||||
{
|
||||
// Initialize the return arrays
|
||||
pipeBranchesCLCoords.clear();
|
||||
pipeBranchesCellIds.clear();
|
||||
|
||||
if ( !wellResults) return;
|
||||
if ( timeStepIndex >= 0 && !wellResults->hasWellResult(timeStepIndex) ) return;
|
||||
if ( timeStepIndex >= 0 && !wellResults->hasAnyValidCells(timeStepIndex) ) return;
|
||||
|
||||
const RigWellResultFrame* wellFramePtr = nullptr;
|
||||
|
||||
@ -118,24 +122,14 @@ void RigSimulationWellCenterLineCalculator::calculateWellPipeCenterlineFromWellF
|
||||
#endif
|
||||
|
||||
const RigWellResultFrame& wellFrame = *wellFramePtr;
|
||||
|
||||
// Initialize the return arrays
|
||||
pipeBranchesCLCoords.clear();
|
||||
pipeBranchesCellIds.clear();
|
||||
|
||||
if ( wellFrame.m_wellResultBranches.size() == 0 ) return;
|
||||
const std::vector<RigWellResultBranch>& resBranches = wellFrame.m_wellResultBranches;
|
||||
|
||||
// Well head
|
||||
// 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);
|
||||
const RigWellResultPoint* whResCell = &(wellFrame.m_wellHead);
|
||||
|
||||
|
||||
const std::vector<RigWellResultBranch>& resBranches = wellFrame.m_wellResultBranches;
|
||||
|
||||
if ( ! hasAnyResultCells(resBranches) ) return;
|
||||
const RigWellResultPoint* whResCell = &(wellFrame.wellHeadOrStartCell());
|
||||
|
||||
// Add extra coordinate between cell face and cell center
|
||||
// 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
|
||||
{
|
||||
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);
|
||||
|
||||
buildResBranchToBranchLineEndsDistMap(whStartPos, -1);
|
||||
@ -693,7 +687,7 @@ private:
|
||||
m_branchedWell.m_wellResultBranches.push_back(RigWellResultBranch());
|
||||
branchIdx = static_cast<int>( m_branchedWell.m_wellResultBranches.size()) - 1;
|
||||
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);
|
||||
|
||||
wellHeadAsPoint.m_bottomPosition = whStartPos;
|
||||
|
Loading…
Reference in New Issue
Block a user