mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#2959 Fix crash when loading ODB file without overburden.
This commit is contained in:
@@ -101,6 +101,7 @@ void RigFemPartGrid::generateStructGridData()
|
||||
int iCoord = 0;
|
||||
while (true)
|
||||
{
|
||||
CVF_ASSERT(elmIdxInI >= 0 && size_t(elmIdxInI) < m_ijkPrElement.size());
|
||||
// Assign ijk coordinate
|
||||
m_ijkPrElement[elmIdxInI] = cvf::Vec3i(iCoord, jCoord, kCoord);
|
||||
|
||||
@@ -180,8 +181,12 @@ void RigFemPartGrid::generateStructGridData()
|
||||
|
||||
for (int elmIdx = 0; elmIdx < m_femPart->elementCount(); ++elmIdx)
|
||||
{
|
||||
cvf::Vec3i ijk = m_ijkPrElement[elmIdx];
|
||||
m_elmIdxPrIJK.at(ijk[0], ijk[1], ijk[2]) = elmIdx;
|
||||
size_t i, j, k;
|
||||
bool validIndex = ijkFromCellIndex(elmIdx, &i, &j, &k);
|
||||
if (validIndex)
|
||||
{
|
||||
m_elmIdxPrIJK.at(i, j, k) = elmIdx;
|
||||
}
|
||||
}
|
||||
|
||||
// IJK bounding box
|
||||
@@ -194,7 +199,8 @@ void RigFemPartGrid::generateStructGridData()
|
||||
{
|
||||
RigElementType elementType = m_femPart->elementType(elmIdx);
|
||||
size_t i, j, k;
|
||||
if (elementType == HEX8P && ijkFromCellIndex(elmIdx, &i, &j, &k))
|
||||
bool validIndex = ijkFromCellIndex(elmIdx, &i, &j, &k);
|
||||
if (elementType == HEX8P && validIndex)
|
||||
{
|
||||
if (i < min.x()) min.x() = i;
|
||||
if (j < min.y()) min.y() = j;
|
||||
@@ -424,11 +430,19 @@ size_t RigFemPartGrid::cellIndexFromIJK(size_t i, size_t j, size_t k) const
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RigFemPartGrid::ijkFromCellIndex(size_t cellIndex, size_t* i, size_t* j, size_t* k) const
|
||||
{
|
||||
*i = m_ijkPrElement[cellIndex][0];
|
||||
*j = m_ijkPrElement[cellIndex][1];
|
||||
*k = m_ijkPrElement[cellIndex][2];
|
||||
int signed_i = m_ijkPrElement[cellIndex][0];
|
||||
int signed_j = m_ijkPrElement[cellIndex][1];
|
||||
int signed_k = m_ijkPrElement[cellIndex][2];
|
||||
|
||||
return true;
|
||||
if (signed_i >= 0 && signed_j >= 0 && signed_k >= 0)
|
||||
{
|
||||
*i = signed_i;
|
||||
*j = signed_j;
|
||||
*k = signed_k;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -597,10 +597,13 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateTimeLapseResult(
|
||||
int baseFrameIdx = resVarAddr.timeLapseBaseFrameIdx;
|
||||
if ( baseFrameIdx >= frameCount ) return dstDataFrames;
|
||||
const std::vector<float>& baseFrameData = srcDataFrames->frameData(baseFrameIdx);
|
||||
if (baseFrameData.empty()) return dstDataFrames;
|
||||
|
||||
for ( int fIdx = 0; fIdx < frameCount; ++fIdx )
|
||||
{
|
||||
const std::vector<float>& srcFrameData = srcDataFrames->frameData(fIdx);
|
||||
if (srcFrameData.empty()) continue; // Create empty results
|
||||
|
||||
std::vector<float>& dstFrameData = dstDataFrames->frameData(fIdx);
|
||||
size_t valCount = srcFrameData.size();
|
||||
dstFrameData.resize(valCount);
|
||||
@@ -1613,7 +1616,10 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSE(int partIndex
|
||||
for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
|
||||
if (elmNodResIdx < srcSFrameData.size())
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1621,8 +1627,10 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateSE(int partIndex
|
||||
for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
|
||||
dstFrameData[elmNodResIdx] = inf;
|
||||
if (elmNodResIdx < dstFrameData.size())
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = inf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1680,12 +1688,15 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateST_11_22_33(int
|
||||
for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx);
|
||||
if (elmNodResIdx < srcSFrameData.size())
|
||||
{
|
||||
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx);
|
||||
|
||||
float por = srcPORFrameData[nodeIdx];
|
||||
if (por == inf) por = 0.0f;
|
||||
float por = srcPORFrameData[nodeIdx];
|
||||
if (por == inf) por = 0.0f;
|
||||
|
||||
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx] + por;
|
||||
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx] + por;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -1693,7 +1704,10 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateST_11_22_33(int
|
||||
for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
|
||||
if (elmNodResIdx < srcSFrameData.size())
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = -srcSFrameData[elmNodResIdx];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1809,20 +1823,23 @@ RigFemScalarResultFrames* RigFemPartResultsCollection::calculateFormationIndices
|
||||
int elmNodeCount = RigFemTypes::elmentNodeCount(elmType);
|
||||
|
||||
size_t i, j, k;
|
||||
femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k);
|
||||
int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k);
|
||||
|
||||
for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
|
||||
bool validIndex = femPart->structGrid()->ijkFromCellIndex(elmIdx, &i, &j, &k);
|
||||
if (validIndex)
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
int formNameIdx = activeFormNames->formationIndexFromKLayerIdx(k);
|
||||
|
||||
if (formNameIdx != -1)
|
||||
for (int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx)
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = formNameIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = HUGE_VAL;
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
|
||||
if (formNameIdx != -1)
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = formNameIdx;
|
||||
}
|
||||
else
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = HUGE_VAL;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2046,14 +2063,17 @@ void RigFemPartResultsCollection::calculateGammaFromFrames(int partIndex,
|
||||
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx);
|
||||
if (elmNodResIdx < srcSTFrameData.size())
|
||||
{
|
||||
int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx(elmNodResIdx);
|
||||
|
||||
float por = srcPORFrameData[nodeIdx];
|
||||
float por = srcPORFrameData[nodeIdx];
|
||||
|
||||
if ( por == inf || fabs(por) < 0.01e6*1.0e-5 )
|
||||
dstFrameData[elmNodResIdx] = inf;
|
||||
else
|
||||
dstFrameData[elmNodResIdx] = srcSTFrameData[elmNodResIdx]/por;
|
||||
if (por == inf || fabs(por) < 0.01e6*1.0e-5)
|
||||
dstFrameData[elmNodResIdx] = inf;
|
||||
else
|
||||
dstFrameData[elmNodResIdx] = srcSTFrameData[elmNodResIdx] / por;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2061,7 +2081,10 @@ void RigFemPartResultsCollection::calculateGammaFromFrames(int partIndex,
|
||||
for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx )
|
||||
{
|
||||
size_t elmNodResIdx = femPart->elementNodeResultIdx(elmIdx, elmNodIdx);
|
||||
dstFrameData[elmNodResIdx] = inf;
|
||||
if (elmNodResIdx < dstFrameData.size())
|
||||
{
|
||||
dstFrameData[elmNodResIdx] = inf;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2713,8 +2736,8 @@ void findReferenceElementForNode(const RigFemPart& part, size_t nodeIdx, size_t
|
||||
size_t i, j, k;
|
||||
for (const size_t elemIdx : refElementCandidates)
|
||||
{
|
||||
grid->ijkFromCellIndex(elemIdx, &i, &j, &k);
|
||||
if (k == kRefLayer)
|
||||
bool validIndex = grid->ijkFromCellIndex(elemIdx, &i, &j, &k);
|
||||
if (validIndex && k == kRefLayer)
|
||||
{
|
||||
const std::vector<size_t> nodeIndices = nodesForElement(part, elemIdx);
|
||||
CVF_ASSERT(nodeIndices.size() == 8);
|
||||
|
||||
@@ -398,7 +398,8 @@ RigCaseToCaseRangeFilterMapper::findBestFemCellFromEclCell(const RigMainGrid* ma
|
||||
|
||||
if (elmIdxToBestMatch != -1)
|
||||
{
|
||||
dependentFemPart->structGrid()->ijkFromCellIndex(elmIdxToBestMatch, fi, fj, fk);
|
||||
bool validIndex = dependentFemPart->structGrid()->ijkFromCellIndex(elmIdxToBestMatch, fi, fj, fk);
|
||||
CVF_ASSERT(validIndex);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -604,6 +604,7 @@ public:
|
||||
size_t i, j, k;
|
||||
size_t gridIndex;
|
||||
int caseId;
|
||||
bool validIndex = true;
|
||||
if (item->type() == RiuSelectionItem::ECLIPSE_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuEclipseSelectionItem* eclipseItem = static_cast<const RiuEclipseSelectionItem*>(item);
|
||||
@@ -615,8 +616,8 @@ public:
|
||||
else if (item->type() == RiuSelectionItem::GEOMECH_SELECTION_OBJECT)
|
||||
{
|
||||
const RiuGeoMechSelectionItem* geomechItem = static_cast<const RiuGeoMechSelectionItem*>(item);
|
||||
|
||||
geomechItem->m_view->femParts()->part(geomechItem->m_gridIndex)->structGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k);
|
||||
validIndex = geomechItem->m_view->femParts()->part(geomechItem->m_gridIndex)->structGrid()->ijkFromCellIndex(geomechItem->m_cellIndex, &i, &j, &k);
|
||||
CVF_ASSERT(validIndex);
|
||||
gridIndex = geomechItem->m_gridIndex;
|
||||
caseId = geomechItem->m_view->geoMechCase()->caseId;
|
||||
}
|
||||
@@ -625,7 +626,7 @@ public:
|
||||
continue;
|
||||
}
|
||||
|
||||
if (caseId == reservoirCase->caseId)
|
||||
if (caseId == reservoirCase->caseId && validIndex)
|
||||
{
|
||||
caseNumber.push_back(static_cast<int>(caseId));
|
||||
gridNumber.push_back(static_cast<int>(gridIndex));
|
||||
|
||||
@@ -379,12 +379,16 @@ void RiuMohrsCirclePlot::queryData(RimGeoMechView* geoMechView, size_t gridIndex
|
||||
double frictionAngleDeg = geoMechView->geoMechCase()->frictionAngleDeg();
|
||||
|
||||
size_t i, j, k;
|
||||
femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k);
|
||||
bool validIndex = femPart->structGrid()->ijkFromCellIndex(elmIndex, &i, &j, &k);
|
||||
|
||||
CVF_ASSERT(validIndex);
|
||||
if (validIndex)
|
||||
{
|
||||
MohrsCirclesInfo mohrsCircle(
|
||||
principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color);
|
||||
|
||||
MohrsCirclesInfo mohrsCircle(
|
||||
principals, gridIndex, elmIndex, i, j, k, geoMechView, calculateFOS(principals, frictionAngleDeg, cohesion), color);
|
||||
|
||||
addMohrsCirclesInfo(mohrsCircle);
|
||||
addMohrsCirclesInfo(mohrsCircle);
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user