mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#4430 Add python method to get coarsening info for case.
Equivalent to GetCoarseningInfo in Octave.
This commit is contained in:
parent
d497f04d0d
commit
8167d9f700
@ -1,6 +1,6 @@
|
|||||||
###################################################################################
|
###################################################################################
|
||||||
# This example will connect to ResInsight, retrieve a list of cases and print info
|
# This example will connect to ResInsight, retrieve a list of cases and print info
|
||||||
#
|
#
|
||||||
###################################################################################
|
###################################################################################
|
||||||
|
|
||||||
# Import the ResInsight Processing Server Module
|
# Import the ResInsight Processing Server Module
|
||||||
@ -19,11 +19,16 @@ if resinsight is not None:
|
|||||||
print("Case type: " + case.type)
|
print("Case type: " + case.type)
|
||||||
print("Case grid path: " + case.grid_path())
|
print("Case grid path: " + case.grid_path())
|
||||||
print("Case reservoir bounding box:", case.reservoir_boundingbox())
|
print("Case reservoir bounding box:", case.reservoir_boundingbox())
|
||||||
|
|
||||||
timesteps = case.time_steps()
|
timesteps = case.time_steps()
|
||||||
for t in timesteps:
|
for t in timesteps:
|
||||||
print("Year: " + str(t.year))
|
print("Year: " + str(t.year))
|
||||||
print("Month: " + str(t.month))
|
print("Month: " + str(t.month))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
coarsening_info = case.coarsening_info()
|
||||||
|
if coarsening_info:
|
||||||
|
print("Coarsening information:")
|
||||||
|
|
||||||
|
for c in coarsening_info:
|
||||||
|
print("[{}, {}, {}] - [{}, {}, {}]".format(c.min.x, c.min.y, c.min.z,
|
||||||
|
c.max.x, c.max.y, c.max.z))
|
||||||
|
@ -971,3 +971,12 @@ class Case(PdmObject):
|
|||||||
for value in chunk.cells:
|
for value in chunk.cells:
|
||||||
cells.append(value)
|
cells.append(value)
|
||||||
return cells
|
return cells
|
||||||
|
|
||||||
|
def coarsening_info(self):
|
||||||
|
"""Get a coarsening information for all grids in the case.
|
||||||
|
|
||||||
|
Returns:
|
||||||
|
A list of CoarseningInfo objects with two Vec3i min and max objects
|
||||||
|
for each entry.
|
||||||
|
"""
|
||||||
|
return self.__case_stub.GetCoarseningInfoArray(self.__request).data
|
||||||
|
@ -113,6 +113,10 @@ def test_10k(rips_instance, initialize_test):
|
|||||||
check_corner(cell_corners[cell_index].c6, expected_corners[6])
|
check_corner(cell_corners[cell_index].c6, expected_corners[6])
|
||||||
check_corner(cell_corners[cell_index].c7, expected_corners[7])
|
check_corner(cell_corners[cell_index].c7, expected_corners[7])
|
||||||
|
|
||||||
|
# No coarsening info for this case
|
||||||
|
coarsening_info = case.coarsening_info()
|
||||||
|
assert(len(coarsening_info) == 0)
|
||||||
|
|
||||||
def test_PdmObject(rips_instance, initialize_test):
|
def test_PdmObject(rips_instance, initialize_test):
|
||||||
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
case_path = dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID"
|
||||||
case = rips_instance.project.load_case(path=case_path)
|
case = rips_instance.project.load_case(path=case_path)
|
||||||
|
@ -698,6 +698,46 @@ grpc::Status RiaGrpcCaseService::GetReservoirBoundingBox( grpc::ServerContext*
|
|||||||
return Status( grpc::NOT_FOUND, "Case not found" );
|
return Status( grpc::NOT_FOUND, "Case not found" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
grpc::Status RiaGrpcCaseService::GetCoarseningInfoArray( grpc::ServerContext* context,
|
||||||
|
const rips::CaseRequest* request,
|
||||||
|
rips::CoarseningInfoArray* reply )
|
||||||
|
{
|
||||||
|
RimEclipseCase* rimCase = dynamic_cast<RimEclipseCase*>( findCase( request->id() ) );
|
||||||
|
if ( rimCase && rimCase->eclipseCaseData() && rimCase->eclipseCaseData()->mainGrid() )
|
||||||
|
{
|
||||||
|
for ( size_t gridIdx = 0; gridIdx < rimCase->eclipseCaseData()->gridCount(); gridIdx++ )
|
||||||
|
{
|
||||||
|
RigGridBase* grid = rimCase->eclipseCaseData()->grid( gridIdx );
|
||||||
|
|
||||||
|
size_t localCoarseningBoxCount = grid->coarseningBoxCount();
|
||||||
|
for ( size_t boxIdx = 0; boxIdx < localCoarseningBoxCount; boxIdx++ )
|
||||||
|
{
|
||||||
|
size_t i1, i2, j1, j2, k1, k2;
|
||||||
|
grid->coarseningBox( boxIdx, &i1, &i2, &j1, &j2, &k1, &k2 );
|
||||||
|
|
||||||
|
rips::CoarseningInfo* coarseningInfo = reply->add_data();
|
||||||
|
|
||||||
|
rips::Vec3i* min = new rips::Vec3i;
|
||||||
|
min->set_i( (int)i1 );
|
||||||
|
min->set_j( (int)j1 );
|
||||||
|
min->set_k( (int)k1 );
|
||||||
|
coarseningInfo->set_allocated_min( min );
|
||||||
|
|
||||||
|
rips::Vec3i* max = new rips::Vec3i;
|
||||||
|
max->set_i( (int)i2 );
|
||||||
|
max->set_j( (int)j2 );
|
||||||
|
max->set_k( (int)k2 );
|
||||||
|
coarseningInfo->set_allocated_max( max );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Status::OK;
|
||||||
|
}
|
||||||
|
return Status( grpc::NOT_FOUND, "Case not found" );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@ -743,7 +783,11 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcCaseService::createCallbacks()
|
|||||||
new RiaSelectedCellsStateHandler ),
|
new RiaSelectedCellsStateHandler ),
|
||||||
new RiaGrpcUnaryCallback<Self, CaseRequest, BoundingBox>( this,
|
new RiaGrpcUnaryCallback<Self, CaseRequest, BoundingBox>( this,
|
||||||
&Self::GetReservoirBoundingBox,
|
&Self::GetReservoirBoundingBox,
|
||||||
&Self::RequestGetReservoirBoundingBox )};
|
&Self::RequestGetReservoirBoundingBox ),
|
||||||
|
|
||||||
|
new RiaGrpcUnaryCallback<Self, CaseRequest, CoarseningInfoArray>( this,
|
||||||
|
&Self::GetCoarseningInfoArray,
|
||||||
|
&Self::RequestGetCoarseningInfoArray )};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RiaGrpcCaseService_init =
|
static bool RiaGrpcCaseService_init =
|
||||||
|
@ -141,6 +141,9 @@ public:
|
|||||||
grpc::Status GetReservoirBoundingBox( grpc::ServerContext* context,
|
grpc::Status GetReservoirBoundingBox( grpc::ServerContext* context,
|
||||||
const rips::CaseRequest* request,
|
const rips::CaseRequest* request,
|
||||||
rips::BoundingBox* reply );
|
rips::BoundingBox* reply );
|
||||||
|
grpc::Status GetCoarseningInfoArray( grpc::ServerContext* context,
|
||||||
|
const rips::CaseRequest* request,
|
||||||
|
rips::CoarseningInfoArray* reply );
|
||||||
|
|
||||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user