Skip to content

Commit

Permalink
Fix missing fault faces in GetGridSurface() endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgenherje committed Mar 13, 2024
1 parent 4520fe1 commit 50d3385
Show file tree
Hide file tree
Showing 8 changed files with 115 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
#include <vector>

/*
* 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
{
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/ModelVisualization/RivGridPartMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
2 changes: 1 addition & 1 deletion ApplicationLibCode/ReservoirDataModel/RigGridBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 4 additions & 2 deletions ApplicationLibCode/ReservoirDataModel/RigGridBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
};
Original file line number Diff line number Diff line change
@@ -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!")
Original file line number Diff line number Diff line change
@@ -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!")
16 changes: 9 additions & 7 deletions GrpcInterface/RiaGrpcGridGeometryExtractionService.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@
#include "qstring.h"

RiaGrpcGridGeometryExtractionService::RiaGrpcGridGeometryExtractionService()
: m_faceVisibilityFilter( nullptr )
{
}

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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>(
RigGridCellFaceVisibilityFilter( mainGrid, includeFaultFaces ) );

generator.setCellVisibility( cellVisibilities ); // Ownership transferred
generator.addFaceVisibilityFilter( &m_faceVisibilityFilter );
generator.addFaceVisibilityFilter( m_faceVisibilityFilter.get() );

return grpc::Status::OK;
}
Expand All @@ -407,7 +408,8 @@ grpc::Status RiaGrpcGridGeometryExtractionService::loadGridGeometryFromAbsoluteF
QFileInfo projectPathInfo( absolutePath );

std::shared_ptr<RifReaderSettings> readerSettings;
readerSettings = RifReaderSettings::createGridOnlyReaderSettings();
readerSettings = RifReaderSettings::createGridOnlyReaderSettings();
readerSettings->importFaults = true;

// TODO: Set true or false?
bool createPlot = true;
Expand Down
2 changes: 1 addition & 1 deletion GrpcInterface/RiaGrpcGridGeometryExtractionService.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,5 @@ class RiaGrpcGridGeometryExtractionService final : public rips::GridGeometryExtr
RimEclipseCase* m_eclipseCase = nullptr;
RimEclipseView* m_eclipseView = nullptr;

RigGridCellFaceVisibilityFilter m_faceVisibilityFilter;
std::unique_ptr<RigGridCellFaceVisibilityFilter> m_faceVisibilityFilter = nullptr;
};

0 comments on commit 50d3385

Please sign in to comment.