mirror of
https://github.com/OPM/ResInsight.git
synced 2026-11-24 06:48:13 -06:00
#15088 Well Log Extractor: Use parametric tolerance for well path cell intersections
This commit is contained in:
1 parent
a8805f1b9f
commit
577b4e770e
10 files changed
+252
-16
No files matched your search
@@ -33,7 +33,8 @@ int RigHexIntersectionTools::lineHexCellIntersection( const cvf::Vec3d&
|
||||
const cvf::Vec3d& p2,
|
||||
const std::array<cvf::Vec3d, 8>& hexCorners,
|
||||
const size_t hexIndex,
|
||||
std::vector<HexIntersectionInfo>* intersections )
|
||||
std::vector<HexIntersectionInfo>* intersections,
|
||||
double parametricTolerance )
|
||||
{
|
||||
CAF_ASSERT( intersections != nullptr );
|
||||
|
||||
@@ -61,7 +62,8 @@ int RigHexIntersectionTools::lineHexCellIntersection( const cvf::Vec3d&
|
||||
hexCorners[faceVertexIndices[next]],
|
||||
faceCenter,
|
||||
&intersection,
|
||||
&isEntering );
|
||||
&isEntering,
|
||||
parametricTolerance );
|
||||
if ( intsStatus == 1 )
|
||||
{
|
||||
uniqueIntersections.insert(
|
||||
|
||||
@@ -56,7 +56,8 @@ struct RigHexIntersectionTools
|
||||
const cvf::Vec3d& p2,
|
||||
const std::array<cvf::Vec3d, 8>& hexCorners,
|
||||
const size_t hexIndex,
|
||||
std::vector<HexIntersectionInfo>* intersections );
|
||||
std::vector<HexIntersectionInfo>* intersections,
|
||||
double parametricTolerance = 0.0 );
|
||||
|
||||
static bool lineIntersectsHexCell( const cvf::Vec3d& p1, const cvf::Vec3d& p2, const std::array<cvf::Vec3d, 8>& hexCorners );
|
||||
|
||||
|
||||
@@ -89,7 +89,12 @@ void RigEclipseWellLogExtractor::calculateIntersection()
|
||||
if ( cell.isInvalid() || cell.subGrid() != nullptr ) continue;
|
||||
|
||||
std::array<cvf::Vec3d, 8> hexCorners = m_caseData->mainGrid()->cellCornerVertices( globalCellIndex );
|
||||
RigHexIntersectionTools::lineHexCellIntersection( p1, p2, hexCorners, globalCellIndex, &intersections );
|
||||
RigHexIntersectionTools::lineHexCellIntersection( p1,
|
||||
p2,
|
||||
hexCorners,
|
||||
globalCellIndex,
|
||||
&intersections,
|
||||
RigWellLogExtractionTools::intersectionParametricTolerance );
|
||||
}
|
||||
|
||||
if ( !isCellFaceNormalsOut )
|
||||
|
||||
@@ -1161,9 +1161,12 @@ void RigGeoMechWellLogExtractor::calculateIntersection()
|
||||
hexCorners[6] = cvf::Vec3d( nodeCoords[cornerIndices[6]] );
|
||||
hexCorners[7] = cvf::Vec3d( nodeCoords[cornerIndices[7]] );
|
||||
|
||||
// int intersectionCount = RigHexIntersector::lineHexCellIntersection(p1, p2, hexCorners,
|
||||
// closeCells[ccIdx], &intersections);
|
||||
RigHexIntersectionTools::lineHexCellIntersection( p1, p2, hexCorners, closeCells[ccIdx], &intersections );
|
||||
RigHexIntersectionTools::lineHexCellIntersection( p1,
|
||||
p2,
|
||||
hexCorners,
|
||||
closeCells[ccIdx],
|
||||
&intersections,
|
||||
RigWellLogExtractionTools::intersectionParametricTolerance );
|
||||
}
|
||||
|
||||
// Now, with all the intersections of this piece of line, we need to
|
||||
|
||||
@@ -30,6 +30,13 @@
|
||||
|
||||
struct RigWellLogExtractionTools
|
||||
{
|
||||
// Parametric tolerance for the line segment/triangle test when a well path is intersected with the grid cells.
|
||||
// Simulation well centre lines go through cell face centres, which are also the apex of the four triangles a
|
||||
// face is split into, so the exact test (tolerance 0) depends on the rounding of the last bit and can miss the
|
||||
// crossing on both segments that share the point (#15088). On a 100 m segment this is 1e-7 m, well above the
|
||||
// rounding error at UTM coordinates and well below the measured depth tolerance.
|
||||
static constexpr double intersectionParametricTolerance = 1e-9;
|
||||
|
||||
static bool isEqualDepth( double d1, double d2, const double tolerance )
|
||||
{
|
||||
double depthDiff = d1 - d2;
|
||||
|
||||
@@ -21,6 +21,8 @@
|
||||
|
||||
#include "cafAssert.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
namespace cvf
|
||||
{
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -488,6 +490,9 @@ double GeometryTools::linePointSquareDist( const cvf::Vec3d& p1, const cvf::Vec3
|
||||
//
|
||||
/// Intersect a line segment with a 3D triangle
|
||||
/// Input: A line segment p0, p1. A triangle t0, t1, t2.
|
||||
/// parametricTolerance: the segment parameter r and the triangle coordinates s, t are accepted
|
||||
/// within [-parametricTolerance, 1 + parametricTolerance]. r is clamped to [0, 1] before the point is
|
||||
/// computed, so the reported point is always on the segment. The default 0.0 is the exact test.
|
||||
/// Output: *intersectionPoint = intersection point (when it exists)
|
||||
/// Return: -1 = triangle is degenerate (a segment or point)
|
||||
/// 0 = disjoint (no intersect)
|
||||
@@ -505,7 +510,8 @@ int GeometryTools::intersectLineSegmentTriangle( const cvf::Vec3d& p0,
|
||||
const cvf::Vec3d& t1,
|
||||
const cvf::Vec3d& t2,
|
||||
cvf::Vec3d* intersectionPoint,
|
||||
bool* isLineDirDotNormalNegative )
|
||||
bool* isLineDirDotNormalNegative,
|
||||
double parametricTolerance )
|
||||
{
|
||||
CAF_ASSERT( intersectionPoint != nullptr );
|
||||
CAF_ASSERT( isLineDirDotNormalNegative != nullptr );
|
||||
@@ -538,12 +544,14 @@ int GeometryTools::intersectLineSegmentTriangle( const cvf::Vec3d& p0,
|
||||
|
||||
// get intersect point of ray with triangle plane
|
||||
r = a / b;
|
||||
if ( r < 0.0 ) // ray goes away from triangle
|
||||
if ( r < -parametricTolerance ) // ray goes away from triangle
|
||||
return 0; // => no intersect
|
||||
|
||||
if ( r > 1.0 ) // Line segment does not reach triangle
|
||||
if ( r > 1.0 + parametricTolerance ) // Line segment does not reach triangle
|
||||
return 0;
|
||||
|
||||
r = std::clamp( r, 0.0, 1.0 ); // keep the point on the segment when the tolerance accepted it
|
||||
|
||||
*intersectionPoint = p0 + r * dir; // intersect point of ray and plane
|
||||
|
||||
// is I inside T?
|
||||
@@ -559,11 +567,11 @@ int GeometryTools::intersectLineSegmentTriangle( const cvf::Vec3d& p0,
|
||||
// get and test parametric coords
|
||||
double s, t;
|
||||
s = ( uv * wv - vv * wu ) / D;
|
||||
if ( s < 0.0 || s > 1.0 ) // I is outside T
|
||||
if ( s < -parametricTolerance || s > 1.0 + parametricTolerance ) // I is outside T
|
||||
return 0;
|
||||
|
||||
t = ( uv * wu - uu * wv ) / D;
|
||||
if ( t < 0.0 || ( s + t ) > 1.0 ) // I is outside T
|
||||
if ( t < -parametricTolerance || ( s + t ) > 1.0 + parametricTolerance ) // I is outside T
|
||||
return 0;
|
||||
|
||||
return 1; // I is in T
|
||||
|
||||
@@ -54,7 +54,8 @@ public:
|
||||
const cvf::Vec3d& t1,
|
||||
const cvf::Vec3d& t2,
|
||||
cvf::Vec3d* intersectionPoint,
|
||||
bool* isLineDirDotNormalNegative );
|
||||
bool* isLineDirDotNormalNegative,
|
||||
double parametricTolerance = 0.0 );
|
||||
static cvf::Vec3d barycentricCoords( const cvf::Vec3d& t0, const cvf::Vec3d& t1, const cvf::Vec3d& t2, const cvf::Vec3d& p );
|
||||
static cvf::Vec4d
|
||||
barycentricCoords( const cvf::Vec3d& v0, const cvf::Vec3d& v1, const cvf::Vec3d& v2, const cvf::Vec3d& v3, const cvf::Vec3d& p );
|
||||
|
||||
Reference in new issue
Block a user