From 10d0c662624b347c9d69bf0c8ca282ec0363ba62 Mon Sep 17 00:00:00 2001 From: Magne Sjaastad Date: Thu, 7 Jun 2018 22:10:50 +0200 Subject: [PATCH] #3018 Fracture Truncation : Evaluate fault throw as diff between average z value for two base edge vertices --- .../RimFractureContainmentTools.cpp | 69 ++++++++++++++----- 1 file changed, 52 insertions(+), 17 deletions(-) diff --git a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp index 08932f15f9..f891c8c49f 100644 --- a/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp +++ b/ApplicationCode/ProjectDataModel/Completions/RimFractureContainmentTools.cpp @@ -56,6 +56,39 @@ void RimFractureContainmentTools::appendNeighborCellForFace(const std::setglobalCellArray()[globalReservoirCellIndex]; + + cvf::Vec3d hexCorners[8]; + mainGrid->cellCornerVertices(globalReservoirCellIndex, hexCorners); + + double avgZ = 0.0; + + cvf::ubyte faceVertexIndices[4]; + cvf::StructGridInterface::cellFaceVertexIndices(face, faceVertexIndices); + + for (const auto& faceIdx : faceVertexIndices) + { + // Face indices 0-3 are defined to have deepest Z + // See void StructGridInterface::cellFaceVertexIndices(FaceType face, cvf::ubyte vertexIndices[4]) + + if (faceIdx < 4) + { + avgZ += hexCorners[faceIdx].z(); + } + } + + avgZ /= 2.0; + + return avgZ; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -77,29 +110,31 @@ void RimFractureContainmentTools::checkFaultAndAppendNeighborCell(const std::set { // See RigMainGrid::calculateFaults() - // TODO: Remove when we know if LGR can have faults + size_t neighborGlobalReservoirCellIndex = 0; + { + const RigGridBase* hostGrid = nullptr; + size_t gridLocalCellIndex; + hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalReservoirCellIndex, &gridLocalCellIndex); + CVF_ASSERT(hostGrid); - const RigGridBase* hostGrid = nullptr; + size_t i, j, k; + hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); - size_t gridLocalCellIndex; - hostGrid = mainGrid->gridAndGridLocalIdxFromGlobalCellIdx(globalReservoirCellIndex, &gridLocalCellIndex); + size_t neighborGridLocalCellIndex; - size_t i, j, k; - hostGrid->ijkFromCellIndex(gridLocalCellIndex, &i, &j, &k); + bool foundCell = hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridLocalCellIndex); + CVF_ASSERT(foundCell); - size_t neighborGridLocalCellIndex; + neighborGlobalReservoirCellIndex = + mainGrid->reservoirCellIndexByGridAndGridLocalCellIndex(hostGrid->gridIndex(), neighborGridLocalCellIndex); + } - bool foundCell = hostGrid->cellIJKNeighbor(i, j, k, face, &neighborGridLocalCellIndex); - CVF_ASSERT(foundCell); + double currentCellAvgZ = computeAverageZFromTwoDeepestZ(mainGrid, globalReservoirCellIndex, face); + double neighborCellAvgZ = computeAverageZFromTwoDeepestZ( + mainGrid, neighborGlobalReservoirCellIndex, cvf::StructGridInterface::oppositeFace(face)); - size_t neighborGlobalReservoirCellIndex = hostGrid->reservoirCellIndex(neighborGridLocalCellIndex); - - const RigCell& currentCell = mainGrid->globalCellArray()[globalReservoirCellIndex]; - const RigCell& neightborCell = mainGrid->globalCellArray()[neighborGlobalReservoirCellIndex]; - - auto diffBetweenFaceCenters = - currentCell.faceCenter(face) - neightborCell.faceCenter(cvf::StructGridInterface::oppositeFace(face)); - if (diffBetweenFaceCenters.length() > maximumFaultThrow) + double faultThrow = fabs(currentCellAvgZ - neighborCellAvgZ); + if (faultThrow > maximumFaultThrow) { return; }