mirror of
https://github.com/OPM/ResInsight.git
synced 2025-02-25 18:55:39 -06:00
#5372 Implement getting reservoir bounding box from Python
This commit is contained in:
@@ -14,6 +14,7 @@ service Case
|
|||||||
rpc GetDaysSinceStart(CaseRequest) returns (DaysSinceStart) {}
|
rpc GetDaysSinceStart(CaseRequest) returns (DaysSinceStart) {}
|
||||||
rpc GetCaseInfo(CaseRequest) returns (CaseInfo) {}
|
rpc GetCaseInfo(CaseRequest) returns (CaseInfo) {}
|
||||||
rpc GetPdmObject(CaseRequest) returns (PdmObject) {}
|
rpc GetPdmObject(CaseRequest) returns (PdmObject) {}
|
||||||
|
rpc GetReservoirBoundingBox(CaseRequest) returns (BoundingBox) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
message CaseRequest {
|
message CaseRequest {
|
||||||
@@ -33,6 +34,16 @@ message CaseInfoArray
|
|||||||
repeated CaseInfo data = 1;
|
repeated CaseInfo data = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
message BoundingBox
|
||||||
|
{
|
||||||
|
double min_x = 1;
|
||||||
|
double max_x = 2;
|
||||||
|
double min_y = 3;
|
||||||
|
double max_y = 4;
|
||||||
|
double min_z = 5;
|
||||||
|
double max_z = 6;
|
||||||
|
}
|
||||||
|
|
||||||
message CaseGroup
|
message CaseGroup
|
||||||
{
|
{
|
||||||
int32 id = 1;
|
int32 id = 1;
|
||||||
|
@@ -18,6 +18,7 @@ if resinsight is not None:
|
|||||||
print("Case name: " + case.name)
|
print("Case name: " + case.name)
|
||||||
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())
|
||||||
|
|
||||||
timesteps = case.time_steps()
|
timesteps = case.time_steps()
|
||||||
for t in timesteps:
|
for t in timesteps:
|
||||||
|
@@ -222,6 +222,19 @@ class Case(PdmObject):
|
|||||||
"""
|
"""
|
||||||
return self.__case_stub.GetTimeSteps(self.__request).dates
|
return self.__case_stub.GetTimeSteps(self.__request).dates
|
||||||
|
|
||||||
|
def reservoir_boundingbox(self):
|
||||||
|
"""Get the reservoir bounding box
|
||||||
|
Returns: A class with six double members: min_x, max_x, min_y, max_y, min_z, max_z
|
||||||
|
"""
|
||||||
|
return self.__case_stub.GetReservoirBoundingBox(self.__request)
|
||||||
|
|
||||||
|
def reservoir_depth_range(self):
|
||||||
|
"""Get the reservoir depth range
|
||||||
|
Returns: A tuple with two members. The first is the minimum depth, the second is the maximum depth
|
||||||
|
"""
|
||||||
|
bbox = self.reservoir_boundingbox()
|
||||||
|
return -bbox.max_z, -bbox.min_z
|
||||||
|
|
||||||
def days_since_start(self):
|
def days_since_start(self):
|
||||||
"""Get a list of decimal values representing days since the start of the simulation"""
|
"""Get a list of decimal values representing days since the start of the simulation"""
|
||||||
return self.__case_stub.GetDaysSinceStart(self.__request).day_decimals
|
return self.__case_stub.GetDaysSinceStart(self.__request).day_decimals
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import math
|
||||||
import pytest
|
import pytest
|
||||||
import grpc
|
import grpc
|
||||||
import tempfile
|
import tempfile
|
||||||
@@ -23,6 +24,21 @@ def test_OneCase(rips_instance, initialize_test):
|
|||||||
cases = rips_instance.project.cases()
|
cases = rips_instance.project.cases()
|
||||||
assert(len(cases) is 1)
|
assert(len(cases) is 1)
|
||||||
|
|
||||||
|
def test_BoundingBox(rips_instance, initialize_test):
|
||||||
|
case = rips_instance.project.load_case(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||||
|
assert(case.name == "TEST10K_FLT_LGR_NNC")
|
||||||
|
boundingbox = case.reservoir_boundingbox()
|
||||||
|
assert(math.isclose(3382.90, boundingbox.min_x, abs_tol=1.0e-1))
|
||||||
|
assert(math.isclose(5850.48, boundingbox.max_x, abs_tol=1.0e-1))
|
||||||
|
assert(math.isclose(4157.45, boundingbox.min_y, abs_tol=1.0e-1))
|
||||||
|
assert(math.isclose(7354.93, boundingbox.max_y, abs_tol=1.0e-1))
|
||||||
|
assert(math.isclose(-4252.61, boundingbox.min_z, abs_tol=1.0e-1))
|
||||||
|
assert(math.isclose(-4103.60, boundingbox.max_z, abs_tol=1.0e-1))
|
||||||
|
|
||||||
|
min_depth, max_depth = case.reservoir_depth_range()
|
||||||
|
assert(math.isclose(4103.60, min_depth, abs_tol=1.0e-1))
|
||||||
|
assert(math.isclose(4252.61, max_depth, abs_tol=1.0e-1))
|
||||||
|
|
||||||
def test_MultipleCases(rips_instance, initialize_test):
|
def test_MultipleCases(rips_instance, initialize_test):
|
||||||
case_paths = []
|
case_paths = []
|
||||||
case_paths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
case_paths.append(dataroot.PATH + "/TEST10K_FLT_LGR_NNC/TEST10K_FLT_LGR_NNC.EGRID")
|
||||||
|
@@ -338,7 +338,7 @@ grpc::Status RiaGrpcCaseService::GetCaseInfo( grpc::ServerContext* context,
|
|||||||
reply->set_type( caseType.toStdString() );
|
reply->set_type( caseType.toStdString() );
|
||||||
return Status::OK;
|
return Status::OK;
|
||||||
}
|
}
|
||||||
return Status( grpc::NOT_FOUND, "No cases found" );
|
return Status( grpc::NOT_FOUND, "Case not found" );
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -367,6 +367,28 @@ grpc::Status RiaGrpcCaseService::GetCellInfoForActiveCells( grpc::ServerContext*
|
|||||||
return stateHandler->assignReply( reply );
|
return stateHandler->assignReply( reply );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
grpc::Status RiaGrpcCaseService::GetReservoirBoundingBox( grpc::ServerContext* context,
|
||||||
|
const rips::CaseRequest* request,
|
||||||
|
rips::BoundingBox* reply )
|
||||||
|
{
|
||||||
|
RimCase* rimCase = findCase( request->id() );
|
||||||
|
if ( rimCase )
|
||||||
|
{
|
||||||
|
cvf::BoundingBox boundingBox = rimCase->reservoirBoundingBox();
|
||||||
|
reply->set_min_x( boundingBox.min().x() );
|
||||||
|
reply->set_min_y( boundingBox.min().y() );
|
||||||
|
reply->set_min_z( boundingBox.min().z() );
|
||||||
|
reply->set_max_x( boundingBox.max().x() );
|
||||||
|
reply->set_max_y( boundingBox.max().y() );
|
||||||
|
reply->set_max_z( boundingBox.max().z() );
|
||||||
|
return Status::OK;
|
||||||
|
}
|
||||||
|
return Status( grpc::NOT_FOUND, "Case not found" );
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
@@ -392,7 +414,10 @@ std::vector<RiaGrpcCallbackInterface*> RiaGrpcCaseService::createCallbacks()
|
|||||||
RiaActiveCellInfoStateHandler>( this,
|
RiaActiveCellInfoStateHandler>( this,
|
||||||
&Self::GetCellInfoForActiveCells,
|
&Self::GetCellInfoForActiveCells,
|
||||||
&Self::RequestGetCellInfoForActiveCells,
|
&Self::RequestGetCellInfoForActiveCells,
|
||||||
new RiaActiveCellInfoStateHandler )};
|
new RiaActiveCellInfoStateHandler ),
|
||||||
|
new RiaGrpcUnaryCallback<Self, CaseRequest, BoundingBox>( this,
|
||||||
|
&Self::GetReservoirBoundingBox,
|
||||||
|
&Self::RequestGetReservoirBoundingBox )};
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool RiaGrpcCaseService_init = RiaGrpcServiceFactory::instance()->registerCreator<RiaGrpcCaseService>(
|
static bool RiaGrpcCaseService_init = RiaGrpcServiceFactory::instance()->registerCreator<RiaGrpcCaseService>(
|
||||||
|
@@ -85,10 +85,14 @@ public:
|
|||||||
grpc::Status
|
grpc::Status
|
||||||
GetCaseInfo( grpc::ServerContext* context, const rips::CaseRequest* request, rips::CaseInfo* reply ) override;
|
GetCaseInfo( grpc::ServerContext* context, const rips::CaseRequest* request, rips::CaseInfo* reply ) override;
|
||||||
grpc::Status
|
grpc::Status
|
||||||
GetPdmObject( grpc::ServerContext* context, const rips::CaseRequest* request, rips::PdmObject* reply ) override;
|
GetPdmObject( grpc::ServerContext* context, const rips::CaseRequest* request, rips::PdmObject* reply ) override;
|
||||||
grpc::Status GetCellInfoForActiveCells( grpc::ServerContext* context,
|
grpc::Status GetCellInfoForActiveCells( grpc::ServerContext* context,
|
||||||
const rips::CellInfoRequest* request,
|
const rips::CellInfoRequest* request,
|
||||||
rips::CellInfoArray* reply,
|
rips::CellInfoArray* reply,
|
||||||
RiaActiveCellInfoStateHandler* stateHandler );
|
RiaActiveCellInfoStateHandler* stateHandler );
|
||||||
|
grpc::Status GetReservoirBoundingBox( grpc::ServerContext* context,
|
||||||
|
const rips::CaseRequest* request,
|
||||||
|
rips::BoundingBox* reply );
|
||||||
|
|
||||||
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
std::vector<RiaGrpcCallbackInterface*> createCallbacks() override;
|
||||||
};
|
};
|
||||||
|
@@ -62,6 +62,7 @@ public:
|
|||||||
virtual QStringList timeStepStrings() const = 0;
|
virtual QStringList timeStepStrings() const = 0;
|
||||||
virtual QString timeStepName( int frameIdx ) const = 0;
|
virtual QString timeStepName( int frameIdx ) const = 0;
|
||||||
|
|
||||||
|
virtual cvf::BoundingBox reservoirBoundingBox() = 0;
|
||||||
virtual cvf::BoundingBox activeCellsBoundingBox() const = 0;
|
virtual cvf::BoundingBox activeCellsBoundingBox() const = 0;
|
||||||
virtual cvf::BoundingBox allCellsBoundingBox() const = 0;
|
virtual cvf::BoundingBox allCellsBoundingBox() const = 0;
|
||||||
|
|
||||||
|
@@ -657,6 +657,14 @@ void RimEclipseCase::createTimeStepFormatString()
|
|||||||
m_timeStepFormatString = RiaQDateTimeTools::createTimeFormatStringFromDates( timeStepDates );
|
m_timeStepFormatString = RiaQDateTimeTools::createTimeFormatStringFromDates( timeStepDates );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::BoundingBox RimEclipseCase::reservoirBoundingBox()
|
||||||
|
{
|
||||||
|
return activeCellsBoundingBox();
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@@ -109,6 +109,7 @@ public:
|
|||||||
QString timeStepName( int frameIdx ) const override;
|
QString timeStepName( int frameIdx ) const override;
|
||||||
std::vector<QDateTime> timeStepDates() const override;
|
std::vector<QDateTime> timeStepDates() const override;
|
||||||
|
|
||||||
|
cvf::BoundingBox reservoirBoundingBox() override;
|
||||||
cvf::BoundingBox activeCellsBoundingBox() const override;
|
cvf::BoundingBox activeCellsBoundingBox() const override;
|
||||||
cvf::BoundingBox allCellsBoundingBox() const override;
|
cvf::BoundingBox allCellsBoundingBox() const override;
|
||||||
cvf::Vec3d displayModelOffset() const override;
|
cvf::Vec3d displayModelOffset() const override;
|
||||||
|
@@ -26,7 +26,9 @@
|
|||||||
#include "RicfCommandObject.h"
|
#include "RicfCommandObject.h"
|
||||||
#include "RifOdbReader.h"
|
#include "RifOdbReader.h"
|
||||||
|
|
||||||
|
#include "RigFemPart.h"
|
||||||
#include "RigFemPartCollection.h"
|
#include "RigFemPartCollection.h"
|
||||||
|
#include "RigFemPartGrid.h"
|
||||||
#include "RigFemPartResultsCollection.h"
|
#include "RigFemPartResultsCollection.h"
|
||||||
#include "RigFormationNames.h"
|
#include "RigFormationNames.h"
|
||||||
#include "RigGeoMechCaseData.h"
|
#include "RigGeoMechCaseData.h"
|
||||||
@@ -52,9 +54,13 @@
|
|||||||
#include "cafPdmUiTreeOrdering.h"
|
#include "cafPdmUiTreeOrdering.h"
|
||||||
#include "cafUtils.h"
|
#include "cafUtils.h"
|
||||||
|
|
||||||
|
#include "cvfVector3.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QIcon>
|
#include <QIcon>
|
||||||
|
|
||||||
|
#include <array>
|
||||||
|
|
||||||
CAF_PDM_SOURCE_INIT( RimGeoMechCase, "ResInsightGeoMechCase" );
|
CAF_PDM_SOURCE_INIT( RimGeoMechCase, "ResInsightGeoMechCase" );
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
@@ -441,6 +447,43 @@ QString RimGeoMechCase::timeStepName( int frameIdx ) const
|
|||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
///
|
||||||
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
cvf::BoundingBox RimGeoMechCase::reservoirBoundingBox()
|
||||||
|
{
|
||||||
|
cvf::BoundingBox boundingBox;
|
||||||
|
|
||||||
|
RigGeoMechCaseData* rigCaseData = this->geoMechData();
|
||||||
|
if ( rigCaseData && rigCaseData->femPartResults() && rigCaseData->femParts()->part( 0 ) )
|
||||||
|
{
|
||||||
|
RigFemPart* femPart = rigCaseData->femParts()->part( 0 );
|
||||||
|
const RigFemPartGrid* femPartGrid = femPart->getOrCreateStructGrid();
|
||||||
|
|
||||||
|
RigFemResultAddress porBarAddr( RigFemResultPosEnum::RIG_ELEMENT_NODAL, "POR-Bar", "" );
|
||||||
|
const std::vector<float>& resultValues = rigCaseData->femPartResults()->resultValues( porBarAddr, 0, 0 );
|
||||||
|
|
||||||
|
for ( int i = 0; i < femPart->elementCount(); ++i )
|
||||||
|
{
|
||||||
|
size_t resValueIdx = femPart->elementNodeResultIdx( (int)i, 0 );
|
||||||
|
CVF_ASSERT( resValueIdx < resultValues.size() );
|
||||||
|
double scalarValue = resultValues[resValueIdx];
|
||||||
|
bool validPorValue = scalarValue != std::numeric_limits<double>::infinity();
|
||||||
|
|
||||||
|
if ( validPorValue )
|
||||||
|
{
|
||||||
|
std::array<cvf::Vec3d, 8> hexCorners;
|
||||||
|
femPartGrid->cellCornerVertices( i, hexCorners.data() );
|
||||||
|
for ( size_t c = 0; c < 8; ++c )
|
||||||
|
{
|
||||||
|
boundingBox.add( hexCorners[c] );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return boundingBox;
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
///
|
///
|
||||||
//--------------------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------------------
|
||||||
|
@@ -75,6 +75,7 @@ public:
|
|||||||
QStringList timeStepStrings() const override;
|
QStringList timeStepStrings() const override;
|
||||||
QString timeStepName( int frameIdx ) const override;
|
QString timeStepName( int frameIdx ) const override;
|
||||||
|
|
||||||
|
cvf::BoundingBox reservoirBoundingBox() override;
|
||||||
cvf::BoundingBox activeCellsBoundingBox() const override;
|
cvf::BoundingBox activeCellsBoundingBox() const override;
|
||||||
cvf::BoundingBox allCellsBoundingBox() const override;
|
cvf::BoundingBox allCellsBoundingBox() const override;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user