mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
Ensemble Surface improvements
* Performance : Improve surface import * Performance: Use opm when importing files * Surface : Use the triangle size as basis for the maximum search distance * Performance : Resample surfaces in parallell * Performance: Import file surfaces in parallell * Ensemble Surface : Create one ensemble per surface
This commit is contained in:
@@ -104,6 +104,22 @@ void RigSurface::findIntersectingTriangles( const cvf::BoundingBox& inputBB, std
|
||||
m_surfaceBoundingBoxTree->findIntersections( inputBB, triangleStartIndices );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigSurface::maxExtentTriangleInXDirection() const
|
||||
{
|
||||
return m_maxExtentTriangleInXDirection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigSurface::maxExtentTriangleInYDirection() const
|
||||
{
|
||||
return m_maxExtentTriangleInYDirection;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -118,6 +134,9 @@ void RigSurface::ensureIntersectionSearchTreeIsBuilt()
|
||||
cellBoundingBoxes.resize( itemCount );
|
||||
boundingBoxIds.resize( itemCount );
|
||||
|
||||
double maxX = -1.0;
|
||||
double maxY = -1.0;
|
||||
|
||||
for ( size_t triangleIdx = 0; triangleIdx < itemCount; ++triangleIdx )
|
||||
{
|
||||
cvf::BoundingBox& cellBB = cellBoundingBoxes[triangleIdx];
|
||||
@@ -126,8 +145,14 @@ void RigSurface::ensureIntersectionSearchTreeIsBuilt()
|
||||
cellBB.add( m_vertices[m_triangleIndices[triangleIdx * 3 + 2]] );
|
||||
|
||||
boundingBoxIds[triangleIdx] = triangleIdx * 3;
|
||||
|
||||
if ( cellBB.extent().x() > maxX ) maxX = cellBB.extent().x();
|
||||
if ( cellBB.extent().y() > maxY ) maxY = cellBB.extent().y();
|
||||
}
|
||||
|
||||
m_maxExtentTriangleInXDirection = maxX;
|
||||
m_maxExtentTriangleInYDirection = maxY;
|
||||
|
||||
m_surfaceBoundingBoxTree = new cvf::BoundingBoxTree;
|
||||
m_surfaceBoundingBoxTree->buildTreeFromBoundingBoxes( cellBoundingBoxes, &boundingBoxIds );
|
||||
}
|
||||
|
||||
@@ -49,6 +49,9 @@ public:
|
||||
void ensureIntersectionSearchTreeIsBuilt();
|
||||
void findIntersectingTriangles( const cvf::BoundingBox& inputBB, std::vector<size_t>* triangleStartIndices ) const;
|
||||
|
||||
double maxExtentTriangleInXDirection() const;
|
||||
double maxExtentTriangleInYDirection() const;
|
||||
|
||||
private:
|
||||
size_t triangleCount() const;
|
||||
|
||||
@@ -58,4 +61,7 @@ private:
|
||||
std::map<QString, std::vector<float>> m_verticeResults;
|
||||
|
||||
cvf::ref<cvf::BoundingBoxTree> m_surfaceBoundingBoxTree;
|
||||
|
||||
double m_maxExtentTriangleInXDirection;
|
||||
double m_maxExtentTriangleInYDirection;
|
||||
};
|
||||
|
||||
@@ -91,9 +91,8 @@ bool RigSurfaceResampler::resamplePoint( RigSurface* surface,
|
||||
}
|
||||
}
|
||||
|
||||
// Handle cases where no match is found due to floating point imprecision,
|
||||
// or when falling off resulting grid slightly.
|
||||
double maxDistance = 10.0;
|
||||
double maxDistance = computeMaxDistance( surface );
|
||||
|
||||
return findClosestPointXY( pointAbove, vertices, maxDistance, intersectionPoint );
|
||||
}
|
||||
|
||||
@@ -106,24 +105,26 @@ bool RigSurfaceResampler::findClosestPointXY( const cvf::Vec3d& tar
|
||||
double maxDistance,
|
||||
cvf::Vec3d& intersectionPoint )
|
||||
{
|
||||
double maxDistanceSquared = maxDistance * maxDistance;
|
||||
|
||||
// Find closest vertices
|
||||
double shortestDistance = std::numeric_limits<double>::max();
|
||||
double closestZ = std::numeric_limits<double>::infinity();
|
||||
double shortestDistanceSquared = std::numeric_limits<double>::max();
|
||||
double closestZ = std::numeric_limits<double>::infinity();
|
||||
for ( auto v : vertices )
|
||||
{
|
||||
// Ignore height (z) component when finding closest by
|
||||
// moving point to same height as target point above
|
||||
cvf::Vec3d p( v.x(), v.y(), targetPoint.z() );
|
||||
double distance = p.pointDistance( targetPoint );
|
||||
if ( distance < shortestDistance )
|
||||
double distanceSquared = p.pointDistanceSquared( targetPoint );
|
||||
if ( distanceSquared < shortestDistanceSquared )
|
||||
{
|
||||
shortestDistance = distance;
|
||||
closestZ = v.z();
|
||||
shortestDistanceSquared = distanceSquared;
|
||||
closestZ = v.z();
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the closest point is not to far away to be valid
|
||||
if ( shortestDistance < maxDistance )
|
||||
if ( shortestDistanceSquared < maxDistanceSquared )
|
||||
{
|
||||
intersectionPoint = cvf::Vec3d( targetPoint.x(), targetPoint.y(), closestZ );
|
||||
return true;
|
||||
@@ -133,3 +134,26 @@ bool RigSurfaceResampler::findClosestPointXY( const cvf::Vec3d& tar
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
double RigSurfaceResampler::computeMaxDistance( RigSurface* surface )
|
||||
{
|
||||
// Handle cases where no match is found due to floating point imprecision,
|
||||
// or when falling off resulting grid slightly.
|
||||
// Use the XY extent of a triangle to define a suitable search distance
|
||||
|
||||
const double minimumDistance = 10.0;
|
||||
|
||||
if ( !surface ) return minimumDistance;
|
||||
|
||||
auto maxX = surface->maxExtentTriangleInXDirection() / 2.0;
|
||||
auto maxY = surface->maxExtentTriangleInYDirection() / 2.0;
|
||||
|
||||
auto candidate = std::min( maxX, maxY );
|
||||
|
||||
double distance = std::max( minimumDistance, candidate );
|
||||
|
||||
return distance;
|
||||
}
|
||||
|
||||
@@ -39,4 +39,6 @@ private:
|
||||
const std::vector<cvf::Vec3d>& vertices,
|
||||
double maxDistance,
|
||||
cvf::Vec3d& intersectionPoint );
|
||||
|
||||
static double computeMaxDistance( RigSurface* surface );
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user