#3019 Fault Truncation : Make sure faults in LGR is handled correctly

This commit is contained in:
Magne Sjaastad 2018-06-08 08:38:52 +02:00
parent 1b1dd0c695
commit 54ed12a2f7

View File

@ -34,6 +34,39 @@
#include <array> #include <array>
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
size_t findNeighborReservoirCellIndex(const RigMainGrid* mainGrid,
cvf::StructGridInterface::FaceType face,
size_t globalReservoirCellIndex)
{
size_t neighborGlobalReservoirCellIndex = cvf::UNDEFINED_SIZE_T;
if (mainGrid)
{
size_t gridLocalCellIndex = cvf::UNDEFINED_SIZE_T;
const RigGridBase* hostGrid =
mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalReservoirCellIndex, &gridLocalCellIndex);
if (hostGrid && gridLocalCellIndex != cvf::UNDEFINED_SIZE_T)
{
size_t i, j, k;
hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
size_t neighborGridLocalCellIndex;
bool foundCell = hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridLocalCellIndex);
if (foundCell)
{
neighborGlobalReservoirCellIndex = hostGrid->reservoirCellIndex(neighborGridLocalCellIndex);
}
}
}
return neighborGlobalReservoirCellIndex;
}
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
@ -44,13 +77,8 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::set<size_
std::set<size_t>& connectedCells, std::set<size_t>& connectedCells,
double maximumFaultThrow) double maximumFaultThrow)
{ {
// TODO: Remove when we know if LGR can have faults size_t candidate = findNeighborReservoirCellIndex(mainGrid, face, currentCell);
if (candidate != cvf::UNDEFINED_SIZE_T)
size_t anchorI, anchorJ, anchorK;
mainGrid->ijkFromCellIndex(currentCell, &anchorI, &anchorJ, &anchorK);
size_t candidate;
if (mainGrid->cellIJKNeighbor(anchorI, anchorJ, anchorK, face, &candidate))
{ {
appendNeighborCells(allFracturedCells, mainGrid, candidate, connectedCells, maximumFaultThrow); appendNeighborCells(allFracturedCells, mainGrid, candidate, connectedCells, maximumFaultThrow);
} }
@ -59,9 +87,9 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::set<size_
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
/// ///
//-------------------------------------------------------------------------------------------------- //--------------------------------------------------------------------------------------------------
double computeAverageZFromTwoDeepestZ(const RigMainGrid* mainGrid, double computeAverageZForTwoDeepestZ(const RigMainGrid* mainGrid,
size_t globalReservoirCellIndex, size_t globalReservoirCellIndex,
cvf::StructGridInterface::FaceType face) cvf::StructGridInterface::FaceType face)
{ {
const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex]; const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex];
@ -108,28 +136,23 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set
} }
else else
{ {
// See RigMainGrid::calculateFaults() // See RigMainGrid::calculateFaults() for reference
size_t neighborGlobalReservoirCellIndex = 0; // This function is intended to support fractures in LGR-grids
// Currently, only faults in main grid is supported when reading fault specifications from input text files
// Eclipse 300 supports faults in LGR
// https://github.com/OPM/ResInsight/issues/3019
size_t neighborGlobalReservoirCellIndex = findNeighborReservoirCellIndex(mainGrid, face, globalReservoirCellIndex);
if (neighborGlobalReservoirCellIndex == cvf::UNDEFINED_SIZE_T)
{ {
const RigGridBase* hostGrid = nullptr; // This is probably an assert condition, but we return directly to ensure we are robust
size_t gridLocalCellIndex; fault->o
hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalReservoirCellIndex, &gridLocalCellIndex); return;
CVF_ASSERT(hostGrid);
size_t i, j, k;
hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k);
size_t neighborGridLocalCellIndex;
bool foundCell = hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridLocalCellIndex);
CVF_ASSERT(foundCell);
neighborGlobalReservoirCellIndex = hostGrid->reservoirCellIndex(neighborGridLocalCellIndex);
} }
double currentCellAvgZ = computeAverageZFromTwoDeepestZ(mainGrid, globalReservoirCellIndex, face); double currentCellAvgZ = computeAverageZForTwoDeepestZ(mainGrid, globalReservoirCellIndex, face);
double neighborCellAvgZ = computeAverageZFromTwoDeepestZ( double neighborCellAvgZ = computeAverageZForTwoDeepestZ(
mainGrid, neighborGlobalReservoirCellIndex, cvf::StructGridInterface::oppositeFace(face)); mainGrid, neighborGlobalReservoirCellIndex, cvf::StructGridInterface::oppositeFace(face));
double faultThrow = fabs(currentCellAvgZ - neighborCellAvgZ); double faultThrow = fabs(currentCellAvgZ - neighborCellAvgZ);