From 50d338567bb4de7b8f7310c3fb62d8d31f06a11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8rgen=20Herje?= Date: Wed, 13 Mar 2024 10:57:43 +0100 Subject: [PATCH] Fix missing fault faces in GetGridSurface() endpoint --- .../RivEnclosingPolygonGenerator.h | 2 +- .../ModelVisualization/RivGridPartMgr.cpp | 2 +- .../ReservoirDataModel/RigGridBase.cpp | 2 +- .../ReservoirDataModel/RigGridBase.h | 6 +- ...traction_cut_along_polyline_STRESS_TEST.py | 61 +++++++++++++++++++ ...extraction_get_grid_surface_STRESS_TEST.py | 37 +++++++++++ .../RiaGrpcGridGeometryExtractionService.cpp | 16 ++--- .../RiaGrpcGridGeometryExtractionService.h | 2 +- 8 files changed, 115 insertions(+), 13 deletions(-) create mode 100644 GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_cut_along_polyline_STRESS_TEST.py create mode 100644 GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_get_grid_surface_STRESS_TEST.py diff --git a/ApplicationLibCode/ModelVisualization/Intersections/RivEnclosingPolygonGenerator.h b/ApplicationLibCode/ModelVisualization/Intersections/RivEnclosingPolygonGenerator.h index 3cb7c117a60..36294db6c5f 100644 --- a/ApplicationLibCode/ModelVisualization/Intersections/RivEnclosingPolygonGenerator.h +++ b/ApplicationLibCode/ModelVisualization/Intersections/RivEnclosingPolygonGenerator.h @@ -28,7 +28,7 @@ #include /* - * Class for handling welding of vertices in a polygon to prevent duplicated vertex 3D points within a tolerance margin + * Class for handling welding of vertices internally in a polygon to prevent duplicated vertex 3D points within a tolerance margin */ class PolygonVertexWelder { diff --git a/ApplicationLibCode/ModelVisualization/RivGridPartMgr.cpp b/ApplicationLibCode/ModelVisualization/RivGridPartMgr.cpp index 935d35d4bcd..4e4e156a69f 100644 --- a/ApplicationLibCode/ModelVisualization/RivGridPartMgr.cpp +++ b/ApplicationLibCode/ModelVisualization/RivGridPartMgr.cpp @@ -73,7 +73,7 @@ RivGridPartMgr::RivGridPartMgr( RivCellSetEnum cellSetType, RimEclipseCase* ecli : m_surfaceGenerator( grid, RiaRegressionTestRunner::instance()->useOpenMPForGeometryCreation() ) , m_gridIdx( gridIdx ) , m_grid( grid ) - , m_surfaceFaceFilter( grid ) + , m_surfaceFaceFilter( grid, false ) , m_opacityLevel( 1.0f ) , m_defaultColor( cvf::Color3::WHITE ) , m_eclipseCase( eclipseCase ) diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp index ac27d61adb5..6454ccfdf9c 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp @@ -572,7 +572,7 @@ bool RigGridCellFaceVisibilityFilter::isFaceVisible( size_t const RigFault* fault = m_grid->mainGrid()->findFaultFromCellIndexAndCellFace( nativeResvCellIndex, face ); if ( fault ) { - return false; + return m_includeFaultFaces; } // If the neighbour cell is invisible, we need to draw the face diff --git a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h index 72af3574a0c..98656cc454b 100644 --- a/ApplicationLibCode/ReservoirDataModel/RigGridBase.h +++ b/ApplicationLibCode/ReservoirDataModel/RigGridBase.h @@ -128,13 +128,15 @@ class RigGridBase : public cvf::StructGridInterface class RigGridCellFaceVisibilityFilter : public cvf::CellFaceVisibilityFilter { public: - explicit RigGridCellFaceVisibilityFilter( const RigGridBase* grid ) + explicit RigGridCellFaceVisibilityFilter( const RigGridBase* const grid, bool includeFaultFaces ) : m_grid( grid ) + , m_includeFaultFaces( includeFaultFaces ) { } bool isFaceVisible( size_t i, size_t j, size_t k, cvf::StructGridInterface::FaceType face, const cvf::UByteArray* cellVisibility ) const override; private: - const RigGridBase* m_grid; + const RigGridBase* const m_grid; + const bool m_includeFaultFaces; }; diff --git a/GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_cut_along_polyline_STRESS_TEST.py b/GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_cut_along_polyline_STRESS_TEST.py new file mode 100644 index 00000000000..4818e9d8435 --- /dev/null +++ b/GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_cut_along_polyline_STRESS_TEST.py @@ -0,0 +1,61 @@ +import time + +from rips.instance import * +from rips.generated.GridGeometryExtraction_pb2_grpc import * +from rips.generated.GridGeometryExtraction_pb2 import * + +# from ..instance import * +# from ..generated.GridGeometryExtraction_pb2_grpc import * +# from ..generated.GridGeometryExtraction_pb2 import * + +rips_instance = Instance.find() +grid_geometry_extraction_stub = GridGeometryExtractionStub(rips_instance.channel) + +# grid_file_name = "MOCKED_TEST_GRID" +grid_file_name = ( + "D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID" +) + +# Test polylines +mocked_model_fence_poly_line_utm_xy = [ + 11.2631, + 11.9276, + 14.1083, + 18.2929, + 18.3523, + 10.9173, +] +norne_case_fence_poly_line_utm_xy = [ + 456221, + 7.32113e06, + 457150, + 7.32106e06, + 456885, + 7.32176e06, + 457648, + 7.3226e06, + 458805, + 7.32278e06, +] +norne_case_single_segment_poly_line_utm_xy = [457150, 7.32106e06, 456885, 7.32176e06] +norne_case_single_segment_poly_line_gap_utm_xy = [460877, 7.3236e06, 459279, 7.32477e06] + + +fence_poly_line_utm_xy = norne_case_fence_poly_line_utm_xy + +num_calls = 20 +sleep_time_s = 0.5 + +for i in range(num_calls): + print(f"Call {i+1}/{num_calls}") + cut_along_polyline_request = GridGeometryExtraction__pb2.CutAlongPolylineRequest( + gridFilename=grid_file_name, + fencePolylineUtmXY=fence_poly_line_utm_xy, + ) + cut_along_polyline_response: ( + GridGeometryExtraction__pb2.CutAlongPolylineResponse + ) = grid_geometry_extraction_stub.CutAlongPolyline(cut_along_polyline_request) + + time.sleep(sleep_time_s) + +print("Done!") diff --git a/GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_get_grid_surface_STRESS_TEST.py b/GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_get_grid_surface_STRESS_TEST.py new file mode 100644 index 00000000000..5260ad486c1 --- /dev/null +++ b/GrpcInterface/Python/rips/WebvizPythonExamples/grid_geometry_extraction_get_grid_surface_STRESS_TEST.py @@ -0,0 +1,37 @@ +import time + +from rips.instance import * +from rips.generated.GridGeometryExtraction_pb2_grpc import * +from rips.generated.GridGeometryExtraction_pb2 import * + +rips_instance = Instance.find() +grid_geometry_extraction_stub = GridGeometryExtractionStub(rips_instance.channel) + +# grid_file_name = "MOCKED_TEST_GRID" +grid_file_name = ( + "D:\\Git\\resinsight-tutorials\\model-data\\norne\\NORNE_ATW2013_RFTPLT_V2.EGRID" +) + +# ijk_index_filter = GridGeometryExtraction__pb2.IJKIndexFilter( +# iMin=0, iMax=1, jMin=1, jMax=3, kMin=3, kMax=3 +# ) +ijk_index_filter = None + +num_calls = 30 +sleep_time_s = 0.5 + +for i in range(num_calls): + print(f"Call {i+1}/{num_calls}") + get_grid_surface_request = GridGeometryExtraction__pb2.GetGridSurfaceRequest( + gridFilename=grid_file_name, + ijkIndexFilter=ijk_index_filter, + cellIndexFilter=None, + propertyFilter=None, + ) + get_grid_surface_response: GridGeometryExtraction__pb2.GetGridSurfaceResponse = ( + grid_geometry_extraction_stub.GetGridSurface(get_grid_surface_request) + ) + + time.sleep(sleep_time_s) + +print("Done!") diff --git a/GrpcInterface/RiaGrpcGridGeometryExtractionService.cpp b/GrpcInterface/RiaGrpcGridGeometryExtractionService.cpp index 169886f6821..d7928ac2ddc 100644 --- a/GrpcInterface/RiaGrpcGridGeometryExtractionService.cpp +++ b/GrpcInterface/RiaGrpcGridGeometryExtractionService.cpp @@ -56,7 +56,6 @@ #include "qstring.h" RiaGrpcGridGeometryExtractionService::RiaGrpcGridGeometryExtractionService() - : m_faceVisibilityFilter( nullptr ) { } @@ -91,9 +90,9 @@ grpc::Status RiaGrpcGridGeometryExtractionService::GetGridSurface( grpc::ServerC m_eclipseView->createGridGeometryParts(); // Initialize grid geometry generator - const bool useOpenMP = false; - auto gridGeometryGenerator = cvf::StructGridGeometryGenerator( m_eclipseView->mainGrid(), useOpenMP ); // cvf::ref? - status = initializeGridGeometryGeneratorWithEclipseViewCellVisibility( gridGeometryGenerator ); + const bool useOpenMP = false; + auto gridGeometryGenerator = cvf::StructGridGeometryGenerator( m_eclipseView->mainGrid(), useOpenMP ); + status = initializeGridGeometryGeneratorWithEclipseViewCellVisibility( gridGeometryGenerator ); if ( status.error_code() != grpc::StatusCode::OK ) { return status; @@ -390,10 +389,12 @@ grpc::Status RiaGrpcGridGeometryExtractionService::initializeGridGeometryGenerat m_eclipseView->calculateCurrentTotalCellVisibility( cellVisibilities, firstTimeStep ); // Face visibility filter - m_faceVisibilityFilter = RigGridCellFaceVisibilityFilter( mainGrid ); + const bool includeFaultFaces = true; + m_faceVisibilityFilter = std::make_unique( + RigGridCellFaceVisibilityFilter( mainGrid, includeFaultFaces ) ); generator.setCellVisibility( cellVisibilities ); // Ownership transferred - generator.addFaceVisibilityFilter( &m_faceVisibilityFilter ); + generator.addFaceVisibilityFilter( m_faceVisibilityFilter.get() ); return grpc::Status::OK; } @@ -407,7 +408,8 @@ grpc::Status RiaGrpcGridGeometryExtractionService::loadGridGeometryFromAbsoluteF QFileInfo projectPathInfo( absolutePath ); std::shared_ptr readerSettings; - readerSettings = RifReaderSettings::createGridOnlyReaderSettings(); + readerSettings = RifReaderSettings::createGridOnlyReaderSettings(); + readerSettings->importFaults = true; // TODO: Set true or false? bool createPlot = true; diff --git a/GrpcInterface/RiaGrpcGridGeometryExtractionService.h b/GrpcInterface/RiaGrpcGridGeometryExtractionService.h index 88570e64599..386599c9d21 100644 --- a/GrpcInterface/RiaGrpcGridGeometryExtractionService.h +++ b/GrpcInterface/RiaGrpcGridGeometryExtractionService.h @@ -75,5 +75,5 @@ class RiaGrpcGridGeometryExtractionService final : public rips::GridGeometryExtr RimEclipseCase* m_eclipseCase = nullptr; RimEclipseView* m_eclipseView = nullptr; - RigGridCellFaceVisibilityFilter m_faceVisibilityFilter; + std::unique_ptr m_faceVisibilityFilter = nullptr; };