Support setting of child fields from Python and pass in WbsParameters if provided

Also fixes #5354
This commit is contained in:
Gaute Lindkvist 2020-01-17 10:35:42 +01:00
parent 5b8b76179b
commit 954bf1e02e
27 changed files with 314 additions and 174 deletions

View File

@ -25,6 +25,7 @@
#include "RimGeoMechCase.h"
#include "RimGeoMechView.h"
#include "RimProject.h"
#include "RimWbsParameters.h"
#include "RimWellBoreStabilityPlot.h"
#include "RimWellPath.h"
@ -51,6 +52,8 @@ RicfCreateWellBoreStabilityPlotFeature::RicfCreateWellBoreStabilityPlotFeature()
RICF_InitField( &m_caseId, "caseId", -1, "GeoMech Case Id", "", "", "" );
RICF_InitField( &m_wellPath, "wellPath", QString( "" ), "Well Path", "", "", "" );
RICF_InitField( &m_timeStep, "timeStep", -1, "Time Step", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_wbsParameters, "wbsParameters", "WbsParameters", "", "", "" );
}
//--------------------------------------------------------------------------------------------------
@ -87,7 +90,8 @@ RicfCommandResponse RicfCreateWellBoreStabilityPlotFeature::execute()
{
RimWellBoreStabilityPlot* wbsPlot = RicNewWellBoreStabilityPlotFeature::createPlot( chosenCase,
chosenWellPath,
m_timeStep() );
m_timeStep(),
m_wbsParameters() );
RicfCommandResponse response;
response.setResult( new RicfCreateWbsPlotResult( wbsPlot->id() ) );
return response;

View File

@ -18,8 +18,11 @@
#pragma once
#include "RicfCommandObject.h"
#include "cafPdmChildField.h"
#include "cafPdmField.h"
class RimWbsParameters;
//==================================================================================================
//
//
@ -50,7 +53,8 @@ public:
RicfCommandResponse execute() override;
private:
caf::PdmField<int> m_caseId;
caf::PdmField<QString> m_wellPath;
caf::PdmField<int> m_timeStep;
caf::PdmField<int> m_caseId;
caf::PdmField<QString> m_wellPath;
caf::PdmField<int> m_timeStep;
caf::PdmChildField<RimWbsParameters*> m_wbsParameters;
};

View File

@ -66,12 +66,16 @@ CAF_CMD_SOURCE_INIT( RicNewWellBoreStabilityPlotFeature, "RicNewWellBoreStabilit
///
//--------------------------------------------------------------------------------------------------
RimWellBoreStabilityPlot*
RicNewWellBoreStabilityPlotFeature::createPlot( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep )
RicNewWellBoreStabilityPlotFeature::createPlot( RimGeoMechCase* geoMechCase,
RimWellPath* wellPath,
int timeStep,
const RimWbsParameters* parameters /* = nullptr*/ )
{
caf::ProgressInfo progInfo( 100, "Creating Well Bore Stability Plot" );
RimWellBoreStabilityPlot* plot = RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( false,
"Well Bore Stability" );
"Well Bore Stability",
parameters );
{
auto task = progInfo.task( "Creating formation track", 2 );

View File

@ -22,6 +22,7 @@
class RimGeoMechCase;
class RimGeoMechView;
class RimWbsParameters;
class RimWellBoreStabilityPlot;
class RimWellPath;
@ -33,7 +34,10 @@ class RicNewWellBoreStabilityPlotFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;
public:
static RimWellBoreStabilityPlot* createPlot( RimGeoMechCase* geoMechCase, RimWellPath* wellPath, int timeStep );
static RimWellBoreStabilityPlot* createPlot( RimGeoMechCase* geoMechCase,
RimWellPath* wellPath,
int timeStep,
const RimWbsParameters* parameters = nullptr );
protected:
// Overrides

View File

@ -43,7 +43,8 @@
//--------------------------------------------------------------------------------------------------
RimWellBoreStabilityPlot*
RicNewWellLogPlotFeatureImpl::createWellBoreStabilityPlot( bool showAfterCreation /*= true*/,
const QString& plotDescription /*= QString("")*/ )
const QString& plotDescription /*= QString("")*/,
const RimWbsParameters* params /*= nullptr*/ )
{
RimWellLogPlotCollection* wellLogPlotColl = wellLogPlotCollection();
CVF_ASSERT( wellLogPlotColl );
@ -52,6 +53,11 @@ RimWellBoreStabilityPlot*
RiaGuiApplication::instance()->getOrCreateMainPlotWindow();
RimWellBoreStabilityPlot* plot = new RimWellBoreStabilityPlot();
if ( params )
{
plot->copyWbsParameters( params );
}
plot->setAsPlotMdiWindow();
wellLogPlotColl->wellLogPlots().push_back( plot );

View File

@ -21,6 +21,7 @@
#include <QString>
class RimWbsParameters;
class RimWellBoreStabilityPlot;
class RimWellLogPlotCollection;
class RimWellLogPlot;
@ -33,7 +34,8 @@ class RicNewWellLogPlotFeatureImpl
{
public:
static RimWellBoreStabilityPlot* createWellBoreStabilityPlot( bool showAfterCreation = true,
const QString& plotDescription = QString( "" ) );
const QString& plotDescription = QString( "" ),
const RimWbsParameters* params = nullptr );
static RimWellLogPlot* createWellLogPlot( bool showAfterCreation = true,
const QString& plotDescription = QString( "" ) );
static RimWellLogTrack* createWellLogPlotTrack( bool updateAfterCreation = true,

View File

@ -2,6 +2,7 @@ syntax = "proto3";
import "Case.proto";
import "Definitions.proto";
import "PdmObject.proto";
package rips;
@ -274,9 +275,10 @@ message CloneViewRequest
message CreateWbsPlotRequest
{
int32 caseId = 1;
string wellPath = 2;
int32 timeStep = 3;
int32 caseId = 1;
string wellPath = 2;
int32 timeStep = 3;
PdmObject wbsParameters = 4;
}
message ImportWellPathsRequest

View File

@ -29,7 +29,6 @@ message CreatePdmChildObjectRequest
{
PdmObject object = 1;
string child_field = 2;
string child_class = 3;
}
message PdmParentObjectRequest

View File

@ -750,7 +750,7 @@ class Case(PdmObject):
exportFile=export_file,
))
def create_well_bore_stability_plot(self, well_path, time_step):
def create_well_bore_stability_plot(self, well_path, time_step, wbsParameters=None):
""" Create a new well bore stability plot
Arguments:
@ -762,7 +762,8 @@ class Case(PdmObject):
"""
plot_result = self._execute_command(createWellBoreStabilityPlot=Cmd.CreateWbsPlotRequest(caseId=self.case_id,
wellPath=well_path,
timeStep=time_step))
timeStep=time_step,
wbsParameters=wbsParameters))
return self._project.plot(view_id=plot_result.createWbsPlotResult.viewId)
def import_formation_names(self, formation_files=None):

View File

@ -23,8 +23,10 @@
#include "RicfSetTimeStep.h"
#include "cafAssert.h"
#include "cafPdmChildField.h"
#include "cafPdmDataValueField.h"
#include "cafPdmDefaultObjectFactory.h"
#include "cafPdmObject.h"
#include "cafPdmValueField.h"
#include <google/protobuf/reflection.h>
@ -52,13 +54,13 @@ grpc::Status
auto grpcOneOfMessage = requestDescriptor->FindFieldByNumber( (int)paramsCase );
CAF_ASSERT( grpcOneOfMessage->type() == FieldDescriptor::TYPE_MESSAGE );
const Message& params = request->GetReflection()->GetMessage( *request, grpcOneOfMessage );
QString grpcOneOfMessageName = QString::fromStdString( grpcOneOfMessage->name() );
auto pdmObjectHandle = caf::PdmDefaultObjectFactory::instance()->create( grpcOneOfMessageName );
auto commandHandle = dynamic_cast<RicfCommandObject*>( pdmObjectHandle );
QString grpcOneOfMessageName = QString::fromStdString( grpcOneOfMessage->name() );
auto pdmObjectHandle = caf::PdmDefaultObjectFactory::instance()->create( grpcOneOfMessageName );
auto commandHandle = dynamic_cast<RicfCommandObject*>( pdmObjectHandle );
if ( commandHandle )
{
// Copy parameters
RicfMultiCaseReplace* multiCaseReplaceCommand = dynamic_cast<RicfMultiCaseReplace*>( commandHandle );
if ( multiCaseReplaceCommand )
{
@ -74,24 +76,13 @@ grpc::Status
}
else
{
auto subMessageDescriptor = grpcOneOfMessage->message_type();
int numParameters = subMessageDescriptor->field_count();
for ( int i = 0; i < numParameters; ++i )
{
auto parameter = subMessageDescriptor->field( i );
if ( parameter )
{
QString parameterName = QString::fromStdString( parameter->name() );
auto pdmValueFieldHandle = dynamic_cast<caf::PdmValueField*>(
pdmObjectHandle->findField( parameterName ) );
if ( pdmValueFieldHandle )
{
assignPdmFieldValue( pdmValueFieldHandle, params, parameter );
}
}
}
assignPdmObjectValues( commandHandle, *request, grpcOneOfMessage );
}
// Execute command
RicfCommandResponse response = commandHandle->execute();
// Copy results
if ( response.status() == RicfCommandResponse::COMMAND_ERROR )
{
return grpc::Status( grpc::FAILED_PRECONDITION, response.sanitizedResponseMessage().toStdString() );
@ -234,6 +225,60 @@ void RiaGrpcCommandService::assignPdmFieldValue( caf::PdmValueField* pdmValue
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGrpcCommandService::assignPdmObjectValues( caf::PdmObjectHandle* pdmObjectHandle,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor )
{
FieldDescriptor::Type fieldDataType = paramDescriptor->type();
const Reflection* reflection = params.GetReflection();
CAF_ASSERT( fieldDataType == FieldDescriptor::TYPE_MESSAGE );
const Message& subMessage = reflection->GetMessage( params, paramDescriptor );
auto messageDescriptor = paramDescriptor->message_type();
int numParameters = messageDescriptor->field_count();
for ( int i = 0; i < numParameters; ++i )
{
auto parameter = messageDescriptor->field( i );
if ( parameter )
{
QString parameterName = QString::fromStdString( parameter->name() );
auto pdmChildFieldHandle = dynamic_cast<caf::PdmChildFieldHandle*>(
pdmObjectHandle->findField( parameterName ) );
auto pdmValueFieldHandle = dynamic_cast<caf::PdmValueField*>( pdmObjectHandle->findField( parameterName ) );
if ( pdmChildFieldHandle )
{
std::vector<caf::PdmObjectHandle*> childObjects;
pdmChildFieldHandle->childObjects( &childObjects );
caf::PdmObjectHandle* childObject = nullptr;
CAF_ASSERT( childObjects.size() <= 1u ); // We do not support child array fields yet
if ( childObjects.size() == 1u )
{
childObject = childObjects.front();
}
else if ( childObjects.empty() )
{
childObject = emplaceChildField( pdmChildFieldHandle );
}
CAF_ASSERT( childObject );
if ( childObject )
{
assignPdmObjectValues( childObject, subMessage, parameter );
}
}
else if ( pdmValueFieldHandle )
{
assignPdmFieldValue( pdmValueFieldHandle, subMessage, parameter );
}
}
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------

View File

@ -26,8 +26,10 @@
namespace caf
{
class PdmChildFieldHandle;
class PdmValueField;
class PdmObject;
class PdmObjectHandle;
template <typename T>
class PdmField;
} // namespace caf
@ -58,8 +60,12 @@ private:
void assignPdmFieldValue( caf::PdmValueField* pdmValueField,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor );
void assignGrpcFieldValue( google::protobuf::Message* reply,
const google::protobuf::FieldDescriptor* fieldDescriptor,
const caf::PdmValueField* pdmValueField );
void assignResultToReply( const caf::PdmObject* result, rips::CommandReply* reply );
void assignPdmObjectValues( caf::PdmObjectHandle* pdmObject,
const google::protobuf::Message& params,
const google::protobuf::FieldDescriptor* paramDescriptor );
void assignGrpcFieldValue( google::protobuf::Message* reply,
const google::protobuf::FieldDescriptor* fieldDescriptor,
const caf::PdmValueField* pdmValueField );
void assignResultToReply( const caf::PdmObject* result, rips::CommandReply* reply );
};

View File

@ -212,9 +212,8 @@ grpc::Status RiaGrpcPdmObjectService::CreateChildPdmObject( grpc::ServerContext*
{
CAF_ASSERT( request );
caf::PdmObject* pdmObject = emplaceChildArrayField( matchingObject,
QString::fromStdString( request->child_field() ),
QString::fromStdString( request->child_class() ) );
caf::PdmObjectHandle* pdmObject = emplaceChildField( matchingObject,
QString::fromStdString( request->child_field() ) );
if ( pdmObject )
{
copyPdmObjectFromCafToRips( pdmObject, reply );

View File

@ -24,6 +24,8 @@
#include "RicfFieldHandle.h"
#include "RicfMessages.h"
#include "cafPdmChildArrayField.h"
#include "cafPdmChildField.h"
#include "cafPdmDataValueField.h"
#include "cafPdmObject.h"
#include "cafPdmXmlFieldHandle.h"
@ -64,11 +66,12 @@ size_t RiaGrpcServiceInterface::numberOfMessagesForByteCount( size_t messageSize
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGrpcServiceInterface::copyPdmObjectFromCafToRips( const caf::PdmObject* source, rips::PdmObject* destination )
void RiaGrpcServiceInterface::copyPdmObjectFromCafToRips( const caf::PdmObjectHandle* source,
rips::PdmObject* destination )
{
CAF_ASSERT( source && destination );
CAF_ASSERT( source && destination && source->xmlCapability() );
destination->set_class_keyword( source->classKeyword().toStdString() );
destination->set_class_keyword( source->xmlCapability()->classKeyword().toStdString() );
destination->set_address( reinterpret_cast<uint64_t>( source ) );
std::vector<caf::PdmFieldHandle*> fields;
source->fields( fields );
@ -95,10 +98,11 @@ void RiaGrpcServiceInterface::copyPdmObjectFromCafToRips( const caf::PdmObject*
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject* source, caf::PdmObject* destination )
void RiaGrpcServiceInterface::copyPdmObjectFromRipsToCaf( const rips::PdmObject* source,
caf::PdmObjectHandle* destination )
{
CAF_ASSERT( source && destination );
CAF_ASSERT( source->class_keyword() == destination->classKeyword().toStdString() );
CAF_ASSERT( source && destination && destination->xmlCapability() );
CAF_ASSERT( source->class_keyword() == destination->xmlCapability()->classKeyword().toStdString() );
CAF_ASSERT( source->address() == reinterpret_cast<uint64_t>( destination ) );
std::vector<caf::PdmFieldHandle*> fields;
destination->fields( fields );
@ -134,34 +138,50 @@ void RiaGrpcServiceInterface::assignFieldValue( const QString& stringValue, caf:
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObject* RiaGrpcServiceInterface::emplaceChildArrayField( caf::PdmObject* parent,
const QString& fieldLabel,
const QString& classKeyword )
caf::PdmObjectHandle* RiaGrpcServiceInterface::emplaceChildField( caf::PdmObject* parent, const QString& fieldLabel )
{
std::vector<caf::PdmFieldHandle*> fields;
parent->fields( fields );
QString childClassKeyword = classKeyword;
for ( auto field : fields )
{
auto pdmChildArrayField = dynamic_cast<caf::PdmChildArrayFieldHandle*>( field );
auto pdmChildField = dynamic_cast<caf::PdmChildFieldHandle*>( field );
if ( pdmChildArrayField && pdmChildArrayField->keyword() == fieldLabel )
{
if ( childClassKeyword.isEmpty() )
{
childClassKeyword = pdmChildArrayField->xmlCapability()->childClassKeyword();
}
auto pdmObjectHandle = caf::PdmDefaultObjectFactory::instance()->create( childClassKeyword );
caf::PdmObject* pdmObject = dynamic_cast<caf::PdmObject*>( pdmObjectHandle );
CAF_ASSERT( pdmObject );
if ( pdmObject )
{
pdmChildArrayField->insertAt( -1, pdmObject );
return pdmObject;
}
return emplaceChildArrayField( pdmChildArrayField );
}
else if ( pdmChildField && pdmChildField->keyword() == fieldLabel )
{
return emplaceChildField( pdmChildField );
}
}
return nullptr;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RiaGrpcServiceInterface::emplaceChildField( caf::PdmChildFieldHandle* childField )
{
QString childClassKeyword = childField->xmlCapability()->childClassKeyword();
auto pdmObjectHandle = caf::PdmDefaultObjectFactory::instance()->create( childClassKeyword );
CAF_ASSERT( pdmObjectHandle );
childField->setChildObject( pdmObjectHandle );
return pdmObjectHandle;
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
caf::PdmObjectHandle* RiaGrpcServiceInterface::emplaceChildArrayField( caf::PdmChildArrayFieldHandle* childArrayField )
{
QString childClassKeyword = childArrayField->xmlCapability()->childClassKeyword();
auto pdmObjectHandle = caf::PdmDefaultObjectFactory::instance()->create( childClassKeyword );
CAF_ASSERT( pdmObjectHandle );
childArrayField->insertAt( -1, pdmObjectHandle );
return pdmObjectHandle;
}

View File

@ -26,7 +26,10 @@ class RimCase;
namespace caf
{
class PdmChildArrayFieldHandle;
class PdmChildFieldHandle;
class PdmObject;
class PdmObjectHandle;
class PdmValueField;
} // namespace caf
@ -50,13 +53,15 @@ public:
static RimCase* findCase( int caseId );
static size_t numberOfMessagesForByteCount( size_t messageSize, size_t byteCount = 64 * 1024u );
static void copyPdmObjectFromCafToRips( const caf::PdmObject* source, rips::PdmObject* destination );
static void copyPdmObjectFromRipsToCaf( const rips::PdmObject* source, caf::PdmObject* destination );
static void copyPdmObjectFromCafToRips( const caf::PdmObjectHandle* source, rips::PdmObject* destination );
static void copyPdmObjectFromRipsToCaf( const rips::PdmObject* source, caf::PdmObjectHandle* destination );
static void assignFieldValue( const QString& stringValue, caf::PdmValueField* field );
static caf::PdmObject*
emplaceChildArrayField( caf::PdmObject* parent, const QString& fieldLabel, const QString& classKeyword );
static caf::PdmObjectHandle* emplaceChildField( caf::PdmObject* parent, const QString& fieldLabel );
static caf::PdmObjectHandle* emplaceChildField( caf::PdmChildFieldHandle* childField );
static caf::PdmObjectHandle* emplaceChildArrayField( caf::PdmChildArrayFieldHandle* childArrayField );
};
#include "cafFactory.h"

View File

@ -82,6 +82,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.h
${CMAKE_CURRENT_LIST_DIR}/RimWellBoreStabilityPlot.h
${CMAKE_CURRENT_LIST_DIR}/RimWbsParameters.h
${CMAKE_CURRENT_LIST_DIR}/RimViewLinker.h
${CMAKE_CURRENT_LIST_DIR}/RimViewLinkerCollection.h
${CMAKE_CURRENT_LIST_DIR}/RimWellLogExtractionCurve.h
@ -232,6 +233,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimPlotWindow.cpp
${CMAKE_CURRENT_LIST_DIR}/RimMultiPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellBoreStabilityPlot.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWbsParameters.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogTrack.cpp
${CMAKE_CURRENT_LIST_DIR}/RimWellLogCurve.cpp
${CMAKE_CURRENT_LIST_DIR}/RimViewLinker.cpp

View File

@ -17,6 +17,8 @@
/////////////////////////////////////////////////////////////////////////////////
#include "RimWbsParameters.h"
#include "RicfCommandObject.h"
#include "RigFemPartResultsCollection.h"
#include "RigGeoMechCaseData.h"
@ -33,78 +35,80 @@ RimWbsParameters::RimWbsParameters()
{
CAF_PDM_InitObject( "Well Bore Stability Parameters", ":/WellLogPlot16x16.png", "", "" );
CAF_PDM_InitFieldNoDefault( &m_porePressureSource,
"PorePressureSource",
"Pore Pressure",
"",
"Data source for Pore Pressure",
"" );
RICF_InitFieldNoDefault( &m_porePressureSource,
"PorePressureReservoirSource",
"Reservoir Pore Pressure",
"",
"Data source for Pore Pressure in reservoir",
"" );
CAF_PDM_InitFieldNoDefault( &m_porePressureShaleSource,
"PorePressureShaleSource",
"Shale Pore Pressure",
"",
"Data source for Pore Pressure in Shale",
"" );
RICF_InitFieldNoDefault( &m_porePressureNonReservoirSource,
"PorePressureNonReservoirSource",
"Non-Reservoir Pore Pressure",
"",
"Data source for Pore Pressure outside reservoir",
"" );
RICF_InitField( &m_userDefinedPPShale, "UserPPNonReservoir", 1.05, " Multiplier of hydrostatic PP", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_poissonRatioSource,
"PoissionRatioSource",
"Poisson Ratio",
"",
"Data source for Poisson Ratio",
"" );
RICF_InitFieldNoDefault( &m_poissonRatioSource,
"PoissionRatioSource",
"Poisson Ratio",
"",
"Data source for Poisson Ratio",
"" );
CAF_PDM_InitFieldNoDefault( &m_ucsSource, "UcsSource", "Uniaxial Compressive Strength", "", "Data source for UCS", "" );
RICF_InitFieldNoDefault( &m_ucsSource, "UcsSource", "Uniaxial Compressive Strength", "", "Data source for UCS", "" );
CAF_PDM_InitFieldNoDefault( &m_OBG0Source, "OBG0Source", "Initial Overburden Gradient", "", "Data source for OBG0", "" );
CAF_PDM_InitFieldNoDefault( &m_DFSource, "DFSource", "Depletion Factor (DF)", "", "Data source for Depletion Factor", "" );
RICF_InitFieldNoDefault( &m_OBG0Source, "OBG0Source", "Initial Overburden Gradient", "", "Data source for OBG0", "" );
RICF_InitFieldNoDefault( &m_DFSource, "DFSource", "Depletion Factor (DF)", "", "Data source for Depletion Factor", "" );
CAF_PDM_InitFieldNoDefault( &m_K0SHSource,
"K0SHSource",
"K0_SH",
"",
"SH in Shale (Matthews & Kelly) = K0_SH * (OBG0-PP0) + PP0 + DF * (PP-PP0)\nK0_SH = "
"(SH - PP)/(OBG-PP)",
"" );
RICF_InitFieldNoDefault( &m_K0SHSource,
"K0SHSource",
"K0_SH",
"",
"SH in Shale (Matthews & Kelly) = K0_SH * (OBG0-PP0) + PP0 + DF * (PP-PP0)\nK0_SH = "
"(SH - PP)/(OBG-PP)",
"" );
CAF_PDM_InitFieldNoDefault( &m_FGShaleSource, "FGShaleSource", "FG in Shale Calculation", "", "", "" );
CAF_PDM_InitFieldNoDefault( &m_K0FGSource,
"K0FGSource",
"K0_FG",
"",
"FG in shale = K0_FG * (OBG0-PP0)\nK0_FG = (FG-PP)/(OBG-PP)",
"" );
RICF_InitFieldNoDefault( &m_FGShaleSource, "FGShaleSource", "FG in Shale Calculation", "", "", "" );
RICF_InitFieldNoDefault( &m_K0FGSource,
"K0FGSource",
"K0_FG",
"",
"FG in shale = K0_FG * (OBG0-PP0)\nK0_FG = (FG-PP)/(OBG-PP)",
"" );
CAF_PDM_InitField( &m_userDefinedPPShale, "UserPPShale", 1.05, "Multiplier of hydrostatic PP", "", "", "" );
CAF_PDM_InitField( &m_userDefinedPoissionRatio,
"UserPoissionRatio",
0.35,
"User Defined Poisson Ratio",
"",
"User Defined Poisson Ratio",
"" );
RICF_InitField( &m_userDefinedPoissionRatio,
"UserPoissionRatio",
0.35,
"User Defined Poisson Ratio",
"",
"User Defined Poisson Ratio",
"" );
// Typical UCS: http://ceae.colorado.edu/~amadei/CVEN5768/PDF/NOTES8.pdf
// Typical UCS for Shale is 5 - 100 MPa -> 50 - 1000 bar.
CAF_PDM_InitField( &m_userDefinedUcs, "UserUcs", 100.0, "User Defined UCS [bar]", "", "User Defined UCS [bar]", "" );
RICF_InitField( &m_userDefinedUcs, "UserUcs", 100.0, "User Defined UCS [bar]", "", "User Defined UCS [bar]", "" );
CAF_PDM_InitField( &m_userDefinedDF, "UserDF", 0.7, "User Defined DF", "", "User Defined Depletion Factor", "" );
CAF_PDM_InitField( &m_userDefinedK0FG, "UserK0FG", 0.75, "User Defined K0_FG", "", "", "" );
CAF_PDM_InitField( &m_userDefinedK0SH, "UserK0SH", 0.65, "User Defined K0_SH", "", "", "" );
CAF_PDM_InitField( &m_FGShaleMultiplier,
"FGMultiplier",
1.05,
"SH Multiplier for FG in Shale",
"",
"FG in Shale = Multiplier * SH",
"" );
RICF_InitField( &m_userDefinedDF, "UserDF", 0.7, "User Defined DF", "", "User Defined Depletion Factor", "" );
RICF_InitField( &m_userDefinedK0FG, "UserK0FG", 0.75, "User Defined K0_FG", "", "", "" );
RICF_InitField( &m_userDefinedK0SH, "UserK0SH", 0.65, "User Defined K0_SH", "", "", "" );
RICF_InitField( &m_FGShaleMultiplier,
"FGMultiplier",
1.05,
"SH Multiplier for FG in Shale",
"",
"FG in Shale = Multiplier * SH",
"" );
CAF_PDM_InitFieldNoDefault( &m_geoMechCase, "GeoMechCase", "GeoMechCase", "", "", "" );
m_geoMechCase.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "WellPath", "", "", "" );
m_wellPath.uiCapability()->setUiHidden( true );
CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep", "", "", "" );
m_timeStep.uiCapability()->setUiHidden( true );
m_parameterSourceFields = {{RigWbsParameter::PP_Sand(), &m_porePressureSource},
{RigWbsParameter::PP_Shale(), &m_porePressureShaleSource},
m_parameterSourceFields = {{RigWbsParameter::PP_Reservoir(), &m_porePressureSource},
{RigWbsParameter::PP_NonReservoir(), &m_porePressureNonReservoirSource},
{RigWbsParameter::poissonRatio(), &m_poissonRatioSource},
{RigWbsParameter::UCS(), &m_ucsSource},
{RigWbsParameter::OBG0(), &m_OBG0Source},
@ -113,7 +117,7 @@ RimWbsParameters::RimWbsParameters()
{RigWbsParameter::K0_SH(), &m_K0SHSource},
{RigWbsParameter::FG_Shale(), &m_FGShaleSource}};
m_userDefinedValueFields = {{RigWbsParameter::PP_Shale(), &m_userDefinedPPShale},
m_userDefinedValueFields = {{RigWbsParameter::PP_NonReservoir(), &m_userDefinedPPShale},
{RigWbsParameter::poissonRatio(), &m_userDefinedPoissionRatio},
{RigWbsParameter::UCS(), &m_userDefinedUcs},
{RigWbsParameter::DF(), &m_userDefinedDF},
@ -150,7 +154,11 @@ RimWbsParameters& RimWbsParameters::operator=( const RimWbsParameters& copyFrom
for ( auto parameterSourcePair : m_parameterSourceFields )
{
setParameterSource( parameterSourcePair.first, copyFrom.parameterSource( parameterSourcePair.first ) );
auto paramSource = copyFrom.parameterSource( parameterSourcePair.first );
if ( paramSource != RigWbsParameter::UNDEFINED )
{
setParameterSource( parameterSourcePair.first, paramSource );
}
}
for ( auto parameterUserDefinedValuePair : m_userDefinedValueFields )
{
@ -215,7 +223,7 @@ RimWbsParameters::ParameterSource RimWbsParameters::parameterSource( const RigWb
{
return ( *field )();
}
return RigWbsParameter::INVALID;
return RigWbsParameter::UNDEFINED;
}
//--------------------------------------------------------------------------------------------------
@ -334,8 +342,8 @@ void RimWbsParameters::loadDataAndUpdate()
void RimWbsParameters::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
uiOrdering.add( &m_porePressureSource );
uiOrdering.add( &m_porePressureShaleSource );
if ( m_porePressureShaleSource == RigWbsParameter::USER_DEFINED )
uiOrdering.add( &m_porePressureNonReservoirSource );
if ( m_porePressureNonReservoirSource == RigWbsParameter::USER_DEFINED )
{
uiOrdering.add( &m_userDefinedPPShale );
}
@ -358,6 +366,7 @@ void RimWbsParameters::defineUiOrdering( QString uiConfigName, caf::PdmUiOrderin
uiOrdering.add( &m_K0FGSource );
uiOrdering.add( &m_userDefinedK0FG );
}
uiOrdering.skipRemainingFields( true );
}
//--------------------------------------------------------------------------------------------------

View File

@ -77,7 +77,7 @@ private:
private:
caf::PdmField<ParameterSourceEnum> m_porePressureSource;
caf::PdmField<ParameterSourceEnum> m_porePressureShaleSource;
caf::PdmField<ParameterSourceEnum> m_porePressureNonReservoirSource;
caf::PdmField<ParameterSourceEnum> m_poissonRatioSource;
caf::PdmField<ParameterSourceEnum> m_ucsSource;
caf::PdmField<ParameterSourceEnum> m_OBG0Source;

View File

@ -70,9 +70,12 @@ double RimWellBoreStabilityPlot::userDefinedValue( const RigWbsParameter& parame
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimWellBoreStabilityPlot::setWbsParameters( const RimWbsParameters& wbsParameters )
void RimWellBoreStabilityPlot::copyWbsParameters( const RimWbsParameters* wbsParameters )
{
*m_wbsParameters = wbsParameters;
if ( wbsParameters )
{
*m_wbsParameters = *wbsParameters;
}
}
//--------------------------------------------------------------------------------------------------

View File

@ -38,7 +38,7 @@ public:
RimWellBoreStabilityPlot();
void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor );
double userDefinedValue( const RigWbsParameter& parameter ) const;
void setWbsParameters( const RimWbsParameters& wbsParameters );
void copyWbsParameters( const RimWbsParameters* wbsParameters );
protected:
void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override;

View File

@ -541,7 +541,7 @@ void RimWellLogExtractionCurve::findAndLoadWbsParametersFromLasFiles( const RimW
auto allParams = RigWbsParameter::allParameters();
for ( const RigWbsParameter& parameter : allParams )
{
if ( parameter == RigWbsParameter::PP_Sand() || parameter == RigWbsParameter::PP_Shale() )
if ( parameter == RigWbsParameter::PP_Reservoir() || parameter == RigWbsParameter::PP_NonReservoir() )
{
findAndLoadPorePressuresFromLasFiles( wellPath, parameter, geomExtractor );
}

View File

@ -21,6 +21,8 @@
#include "RiaApplication.h"
#include "RicfCommandObject.h"
#include "RigWellLogCurveData.h"
#include "RigWellPath.h"
@ -82,24 +84,24 @@ RimWellLogPlot::RimWellLogPlot()
m_commonDataSource.xmlCapability()->disableIO();
m_commonDataSource = new RimWellLogCurveCommonDataSource;
CAF_PDM_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" );
RICF_InitField( &m_showPlotWindowTitle, "ShowTitleInPlot", true, "Show Title", "", "", "" );
CAF_PDM_InitField( &m_plotWindowTitle, "PlotDescription", QString( "" ), "Name", "", "", "" );
m_plotWindowTitle.xmlCapability()->setIOWritable( false );
caf::AppEnum<RimWellLogPlot::DepthTypeEnum> depthType = RiaDefines::MEASURED_DEPTH;
CAF_PDM_InitField( &m_depthType, "DepthType", depthType, "Type", "", "", "" );
RICF_InitField( &m_depthType, "DepthType", depthType, "Type", "", "", "" );
caf::AppEnum<RiaDefines::DepthUnitType> depthUnit = RiaDefines::UNIT_METER;
CAF_PDM_InitField( &m_depthUnit, "DepthUnit", depthUnit, "Unit", "", "", "" );
RICF_InitField( &m_depthUnit, "DepthUnit", depthUnit, "Unit", "", "", "" );
CAF_PDM_InitField( &m_minVisibleDepth, "MinimumDepth", 0.0, "Min", "", "", "" );
CAF_PDM_InitField( &m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max", "", "", "" );
RICF_InitField( &m_minVisibleDepth, "MinimumDepth", 0.0, "Min", "", "", "" );
RICF_InitField( &m_maxVisibleDepth, "MaximumDepth", 1000.0, "Max", "", "", "" );
m_minVisibleDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
m_maxVisibleDepth.uiCapability()->setUiEditorTypeName( caf::PdmUiDoubleValueEditor::uiEditorTypeName() );
CAF_PDM_InitFieldNoDefault( &m_depthAxisGridVisibility, "ShowDepthGridLines", "Show Grid Lines", "", "", "" );
CAF_PDM_InitField( &m_isAutoScaleDepthEnabled, "AutoScaleDepthEnabled", true, "Auto Scale", "", "", "" );
RICF_InitFieldNoDefault( &m_depthAxisGridVisibility, "ShowDepthGridLines", "Show Grid Lines", "", "", "" );
RICF_InitField( &m_isAutoScaleDepthEnabled, "AutoScaleDepthEnabled", true, "Auto Scale", "", "", "" );
m_isAutoScaleDepthEnabled.uiCapability()->setUiHidden( true );
CAF_PDM_InitFieldNoDefault( &m_nameConfig, "NameConfig", "", "", "", "" );

View File

@ -2290,8 +2290,9 @@ void RimWellLogTrack::updateCurveDataRegionsOnPlot()
caf::ColorTable colorTable( RimRegularLegendConfig::colorArrayFromColorType( m_colorShadingPalette() ) );
std::vector<QString> sourceNames =
RigWbsParameter::PP_Sand().allSourceLabels( "\n",
wbsPlot->userDefinedValue( RigWbsParameter::PP_Shale() ) );
RigWbsParameter::PP_Reservoir().allSourceLabels( "\n",
wbsPlot->userDefinedValue(
RigWbsParameter::PP_NonReservoir() ) );
curveData.data = ppSourceRegions;
std::vector<QString> sourceNamesToPlot;

View File

@ -211,16 +211,16 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
{
RigFemPartResultsCollection* resultCollection = m_caseData->femPartResults();
std::vector<WbsParameterSource> finalSourcesPerSegment( m_intersections.size(), RigWbsParameter::INVALID );
std::vector<WbsParameterSource> finalSourcesPerSegment( m_intersections.size(), RigWbsParameter::UNDEFINED );
outputValues->resize( m_intersections.size(), std::numeric_limits<double>::infinity() );
if ( primarySource == RigWbsParameter::INVALID )
if ( primarySource == RigWbsParameter::UNDEFINED )
{
return finalSourcesPerSegment;
}
bool isPPresult = parameter == RigWbsParameter::PP_Sand() || parameter == RigWbsParameter::PP_Shale();
bool isPPresult = parameter == RigWbsParameter::PP_Reservoir() || parameter == RigWbsParameter::PP_NonReservoir();
std::vector<WbsParameterSource> allSources = parameter.sources();
auto primary_it = std::find( allSources.begin(), allSources.end(), primarySource );
@ -438,7 +438,7 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
CVF_ASSERT( values );
values->resize( m_intersections.size(), std::numeric_limits<double>::infinity() );
std::vector<WbsParameterSource> sources( m_intersections.size(), RigWbsParameter::INVALID );
std::vector<WbsParameterSource> sources( m_intersections.size(), RigWbsParameter::UNDEFINED );
if ( resAddr.fieldName == RiaDefines::wbsPPResult().toStdString() )
{
@ -446,12 +446,10 @@ std::vector<RigGeoMechWellLogExtractor::WbsParameterSource>
std::vector<double> ppSandValues( m_intersections.size(), std::numeric_limits<double>::infinity() );
std::vector<double> ppShaleValues( m_intersections.size(), std::numeric_limits<double>::infinity() );
std::vector<WbsParameterSource> ppSandSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Sand(),
frameIndex,
&ppSandValues );
std::vector<WbsParameterSource> ppShaleSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Shale(),
0,
&ppShaleValues );
std::vector<WbsParameterSource> ppSandSources =
calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(), frameIndex, &ppSandValues );
std::vector<WbsParameterSource> ppShaleSources =
calculateWbsParameterForAllSegments( RigWbsParameter::PP_NonReservoir(), 0, &ppShaleValues );
#pragma omp parallel for
for ( int64_t intersectionIdx = 0; intersectionIdx < (int64_t)m_intersections.size(); ++intersectionIdx )
@ -504,7 +502,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres
RigFemResultAddress porBarResAddr( RIG_ELEMENT_NODAL, "POR-Bar", "" );
// Allow POR as an element property value
RigFemResultAddress ppSandElementPropertyAddr = RigWbsParameter::PP_Sand().femAddress(
RigFemResultAddress ppSandElementPropertyAddr = RigWbsParameter::PP_Reservoir().femAddress(
RigWbsParameter::ELEMENT_PROPERTY_TABLE );
RigFemResultAddress poissonResAddr = RigWbsParameter::poissonRatio().femAddress(
@ -531,7 +529,7 @@ void RigGeoMechWellLogExtractor::wellBoreWallCurveData( const RigFemResultAddres
values->resize( m_intersections.size(), 0.0f );
std::vector<double> ppSandAllSegments( m_intersections.size(), std::numeric_limits<double>::infinity() );
std::vector<WbsParameterSource> ppSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Sand(),
std::vector<WbsParameterSource> ppSources = calculateWbsParameterForAllSegments( RigWbsParameter::PP_Reservoir(),
RigWbsParameter::GRID,
frameIndex,
&ppSandAllSegments );

View File

@ -29,10 +29,10 @@ void RigWbsParameter::SourceEnum::setUp()
addItem( RigWbsParameter::ELEMENT_PROPERTY_TABLE, "ELEMENT_PROPERTY_TABLE", "Property Table" );
addItem( RigWbsParameter::USER_DEFINED, "USER_DEFINED", "User Defined" );
addItem( RigWbsParameter::HYDROSTATIC, "HYDROSTATIC", "Hydrostatic" );
addItem( RigWbsParameter::DERIVED_FROM_K0FG, "K0FG", "FG derived from K0_FG" );
addItem( RigWbsParameter::DERIVED_FROM_K0FG, "DERIVED_FROM_K0FG", "FG derived from K0_FG" );
addItem( RigWbsParameter::PROPORTIONAL_TO_SH, "PROPORTIONAL_TO_SH", "Proportional to SH" );
addItem( RigWbsParameter::INVALID, "UNDEFINED", "Undefined" );
setDefault( RigWbsParameter::INVALID );
addItem( RigWbsParameter::UNDEFINED, "UNDEFINED", "Undefined" );
setDefault( RigWbsParameter::UNDEFINED );
}
} // End namespace caf
@ -169,7 +169,7 @@ bool RigWbsParameter::operator<( const RigWbsParameter& rhs ) const
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWbsParameter RigWbsParameter::PP_Sand()
RigWbsParameter RigWbsParameter::PP_Reservoir()
{
SourceVector sources = {{GRID, SourceAddress( "POR-Bar" )},
{LAS_FILE, SourceAddress( "POR" )},
@ -180,11 +180,11 @@ RigWbsParameter RigWbsParameter::PP_Sand()
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
RigWbsParameter RigWbsParameter::PP_Shale()
RigWbsParameter RigWbsParameter::PP_NonReservoir()
{
return RigWbsParameter( "PP Shale",
return RigWbsParameter( "PP Non-Reservoir",
true,
{{LAS_FILE, SourceAddress( "POR_Shale" )},
{{LAS_FILE, SourceAddress( "POR_NonReservoir" )},
{HYDROSTATIC, SourceAddress( "Hydrostatic" )},
{USER_DEFINED, SourceAddress()}} );
}
@ -209,7 +209,7 @@ RigWbsParameter RigWbsParameter::UCS()
return RigWbsParameter( "UCS",
false,
{{LAS_FILE, SourceAddress( "UCS" )},
{ELEMENT_PROPERTY_TABLE, SourceAddress( "RATIO" )},
{ELEMENT_PROPERTY_TABLE, SourceAddress( "UCS" )},
{USER_DEFINED, SourceAddress()}} );
}
@ -285,7 +285,7 @@ RigWbsParameter RigWbsParameter::FG_Shale()
//--------------------------------------------------------------------------------------------------
std::set<RigWbsParameter> RigWbsParameter::allParameters()
{
return {PP_Sand(), PP_Shale(), poissonRatio(), UCS(), OBG(), OBG0(), SH(), DF(), K0_FG(), K0_SH(), FG_Shale()};
return {PP_Reservoir(), PP_NonReservoir(), poissonRatio(), UCS(), OBG(), OBG0(), SH(), DF(), K0_FG(), K0_SH(), FG_Shale()};
}
//--------------------------------------------------------------------------------------------------

View File

@ -39,7 +39,7 @@ public:
HYDROSTATIC,
DERIVED_FROM_K0FG, // FG in shale
PROPORTIONAL_TO_SH, // FG in shale
INVALID = 1000,
UNDEFINED = 1000,
};
using SourceEnum = caf::AppEnum<Source>;
using SourceVector = std::vector<std::pair<Source, SourceAddress>>;
@ -66,8 +66,8 @@ public:
bool operator==( const RigWbsParameter& rhs ) const;
bool operator<( const RigWbsParameter& rhs ) const;
static RigWbsParameter PP_Sand();
static RigWbsParameter PP_Shale();
static RigWbsParameter PP_Reservoir();
static RigWbsParameter PP_NonReservoir();
static RigWbsParameter poissonRatio();
static RigWbsParameter UCS();
static RigWbsParameter OBG();

View File

@ -16,8 +16,14 @@ template< typename T> class PdmFieldXmlCap;
/// This is supposed to be renamed to PdmChildField
//==================================================================================================
class PdmChildFieldHandle : public PdmFieldHandle
{
public:
virtual void setChildObject(PdmObjectHandle* object) = 0;
};
template<typename DataType>
class PdmChildField : public PdmFieldHandle
class PdmChildField : public PdmChildFieldHandle
{
public:
PdmChildField()
@ -27,7 +33,7 @@ public:
};
template<typename DataType >
class PdmChildField <DataType*> : public PdmFieldHandle
class PdmChildField <DataType*> : public PdmChildFieldHandle
{
typedef DataType* DataTypePtr;
public:
@ -52,9 +58,9 @@ public:
const PdmPointer<DataType>& operator()() const { return m_fieldValue; }
const PdmPointer<DataType>& v() const { return m_fieldValue; }
// Child objects
// Child objects
virtual void childObjects(std::vector<PdmObjectHandle*>* objects);
void setChildObject(PdmObjectHandle* object) override;
virtual void removeChildObject(PdmObjectHandle* object);
private:

View File

@ -1,3 +1,4 @@
#include "cafPdmObjectHandle.h"
#include <vector>
#include <iostream>
@ -19,6 +20,23 @@ void caf::PdmChildField<DataType*>::childObjects(std::vector<PdmObjectHandle*>*
}
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template<typename DataType >
void caf::PdmChildField<DataType*>::setChildObject(PdmObjectHandle* object)
{
if (m_fieldValue.rawPtr() != NULL)
{
PdmObjectHandle* oldObject = m_fieldValue.rawPtr();
this->removeChildObject(oldObject);
delete oldObject;
}
m_fieldValue.setRawPtr(object);
object->setAsParentField(this);
}
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------