diff --git a/ApplicationCode/Application/RiaDefines.h b/ApplicationCode/Application/RiaDefines.h index 8dd8bd432c..3f79b25b31 100644 --- a/ApplicationCode/Application/RiaDefines.h +++ b/ApplicationCode/Application/RiaDefines.h @@ -188,6 +188,7 @@ QString defaultDirectoryLabel( ImportFileType fileTypes ); enum CaseType { + UNDEFINED_CASE = -1, ECLIPSE_RESULT_CASE = 1, ECLIPSE_INPUT_CASE = 2, ECLIPSE_STAT_CASE = 3, diff --git a/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp b/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp new file mode 100644 index 0000000000..52d237f5e9 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWbsParameters.cpp @@ -0,0 +1,435 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#include "RimWbsParameters.h" + +#include "RigFemPartResultsCollection.h" +#include "RigGeoMechCaseData.h" + +#include "RimGeoMechCase.h" +#include "RimWellLogFile.h" +#include "RimWellPath.h" + +CAF_PDM_SOURCE_INIT( RimWbsParameters, "WbsParameters" ); + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWbsParameters::RimWbsParameters() +{ + CAF_PDM_InitObject( "Well Bore Stability Parameters", ":/WellLogPlot16x16.png", "", "" ); + + CAF_PDM_InitFieldNoDefault( &m_porePressureSource, + "PorePressureSource", + "Pore Pressure", + "", + "Data source for Pore Pressure", + "" ); + + CAF_PDM_InitFieldNoDefault( &m_porePressureShaleSource, + "PorePressureShaleSource", + "Shale Pore Pressure", + "", + "Data source for Pore Pressure in Shale", + "" ); + + CAF_PDM_InitFieldNoDefault( &m_poissonRatioSource, + "PoissionRatioSource", + "Poisson Ratio", + "", + "Data source for Poisson Ratio", + "" ); + + CAF_PDM_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", "" ); + + 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)", + "" ); + + 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)", + "" ); + + 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", + "" ); + // 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]", "" ); + + 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", + "" ); + + CAF_PDM_InitFieldNoDefault( &m_geoMechCase, "GeoMechCase", "GeoMechCase", "", "", "" ); + CAF_PDM_InitFieldNoDefault( &m_wellPath, "WellPath", "WellPath", "", "", "" ); + CAF_PDM_InitField( &m_timeStep, "TimeStep", -1, "TimeStep", "", "", "" ); + + m_parameterSourceFields = {{RigWbsParameter::PP_Sand(), &m_porePressureSource}, + {RigWbsParameter::PP_Shale(), &m_porePressureShaleSource}, + {RigWbsParameter::poissonRatio(), &m_poissonRatioSource}, + {RigWbsParameter::UCS(), &m_ucsSource}, + {RigWbsParameter::OBG0(), &m_OBG0Source}, + {RigWbsParameter::DF(), &m_DFSource}, + {RigWbsParameter::K0_FG(), &m_K0FGSource}, + {RigWbsParameter::K0_SH(), &m_K0SHSource}, + {RigWbsParameter::FG_Shale(), &m_FGShaleSource}}; + + m_userDefinedValueFields = {{RigWbsParameter::PP_Shale(), &m_userDefinedPPShale}, + {RigWbsParameter::poissonRatio(), &m_userDefinedPoissionRatio}, + {RigWbsParameter::UCS(), &m_userDefinedUcs}, + {RigWbsParameter::DF(), &m_userDefinedDF}, + {RigWbsParameter::K0_FG(), &m_userDefinedK0FG}, + {RigWbsParameter::K0_SH(), &m_userDefinedK0SH}, + {RigWbsParameter::FG_Shale(), &m_FGShaleMultiplier}}; + + for ( auto parameterFieldPair : m_parameterSourceFields ) + { + auto sources = parameterFieldPair.first.sources(); + if ( !sources.empty() ) + { + setParameterSource( parameterFieldPair.first, sources.front() ); + } + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWbsParameters::RimWbsParameters( const RimWbsParameters& copyFrom ) +{ + *this = copyFrom; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWbsParameters& RimWbsParameters::operator=( const RimWbsParameters& copyFrom ) +{ + m_geoMechCase = copyFrom.m_geoMechCase(); + m_wellPath = copyFrom.m_wellPath(); + m_timeStep = copyFrom.m_timeStep(); + + for ( auto parameterSourcePair : m_parameterSourceFields ) + { + setParameterSource( parameterSourcePair.first, copyFrom.parameterSource( parameterSourcePair.first ) ); + } + for ( auto parameterUserDefinedValuePair : m_userDefinedValueFields ) + { + setUserDefinedValue( parameterUserDefinedValuePair.first, + copyFrom.userDefinedValue( parameterUserDefinedValuePair.first ) ); + } + return *this; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWbsParameters::~RimWbsParameters() {} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::setGeoMechCase( RimGeoMechCase* geoMechCase ) +{ + m_geoMechCase = geoMechCase; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::setWellPath( RimWellPath* wellPath ) +{ + m_wellPath = wellPath; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::setTimeStep( int timeStep ) +{ + m_timeStep = timeStep; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ) +{ + for ( auto parameterSourcePair : m_parameterSourceFields ) + { + extractor->setWbsParametersSource( parameterSourcePair.first, ( *parameterSourcePair.second )() ); + } + for ( auto parameterUserDefinedValuePair : m_userDefinedValueFields ) + { + extractor->setWbsUserDefinedValue( parameterUserDefinedValuePair.first, + ( *parameterUserDefinedValuePair.second ) ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimWbsParameters::ParameterSource RimWbsParameters::parameterSource( const RigWbsParameter& parameter ) const +{ + auto field = sourceField( parameter ); + if ( field ) + { + return ( *field )(); + } + return RigWbsParameter::INVALID; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +double RimWbsParameters::userDefinedValue( const RigWbsParameter& parameter ) const +{ + auto it = m_userDefinedValueFields.find( parameter ); + if ( it != m_userDefinedValueFields.end() ) + { + return *it->second; + } + return std::numeric_limits::infinity(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::setParameterSource( const RigWbsParameter& parameter, ParameterSource source ) +{ + auto field = sourceField( parameter ); + if ( field ) + { + *field = source; + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::setUserDefinedValue( const RigWbsParameter& parameter, double value ) +{ + auto it = m_userDefinedValueFields.find( parameter ); + if ( it != m_userDefinedValueFields.end() ) + { + it->second->setValue( value ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +caf::PdmField* RimWbsParameters::sourceField( const RigWbsParameter& parameter ) const +{ + auto it = m_parameterSourceFields.find( parameter ); + if ( it != m_parameterSourceFields.end() ) + { + return it->second; + } + return nullptr; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +QList RimWbsParameters::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) +{ + QList options; + + std::set allParameters = RigWbsParameter::allParameters(); + + for ( const RigWbsParameter& parameter : allParameters ) + { + caf::PdmField* field = sourceField( parameter ); + if ( field == fieldNeedingOptions ) + { + std::vector sources = supportedSources( parameter ); + for ( int i = 0; i < (int)sources.size(); ++i ) + { + if ( parameter.exclusiveOptions() || i == (int)sources.size() - 1 || + sources[i] == RigWbsParameter::HYDROSTATIC ) + { + options.push_back( caf::PdmOptionItemInfo( ParameterSourceEnum::uiText( sources[i] ), sources[i] ) ); + } + else + { + QStringList cumulativeSourceLabels; + for ( int j = i; j < (int)sources.size(); ++j ) + { + int index = 1 + ( j - i ); + cumulativeSourceLabels.push_back( + QString( "%1. %2" ).arg( index ).arg( ParameterSourceEnum::uiText( sources[j] ) ) ); + } + options.push_back( caf::PdmOptionItemInfo( cumulativeSourceLabels.join( ", " ), sources[i] ) ); + } + } + break; + } + } + + return options; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::loadDataAndUpdate() +{ + std::set allParameters = RigWbsParameter::allParameters(); + + for ( const RigWbsParameter& parameter : allParameters ) + { + caf::PdmField* field = sourceField( parameter ); + if ( field ) + { + assignValidSource( field, supportedSources( parameter ) ); + } + } + this->updateConnectedEditors(); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +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_userDefinedPPShale ); + } + uiOrdering.add( &m_poissonRatioSource ); + uiOrdering.add( &m_userDefinedPoissionRatio ); + uiOrdering.add( &m_ucsSource ); + uiOrdering.add( &m_userDefinedUcs ); + uiOrdering.add( &m_OBG0Source ); + uiOrdering.add( &m_DFSource ); + uiOrdering.add( &m_userDefinedDF ); + uiOrdering.add( &m_K0SHSource ); + uiOrdering.add( &m_userDefinedK0SH ); + uiOrdering.add( &m_FGShaleSource ); + if ( m_FGShaleSource == RigWbsParameter::PROPORTIONAL_TO_SH ) + { + uiOrdering.add( &m_FGShaleMultiplier ); + } + else + { + uiOrdering.add( &m_K0FGSource ); + uiOrdering.add( &m_userDefinedK0FG ); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWbsParameters::hasLasFileWithChannel( const QString& channel ) const +{ + if ( m_wellPath && !RimWellLogFile::findMdAndChannelValuesForWellPath( m_wellPath, channel ).empty() ) + { + return true; + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimWbsParameters::hasElementPropertyEntry( const RigFemResultAddress& resAddr ) const +{ + RigFemPartResultsCollection* femPartResults = nullptr; + if ( m_geoMechCase && m_timeStep > 0 ) + { + femPartResults = m_geoMechCase->geoMechData()->femPartResults(); + if ( femPartResults ) + { + return !femPartResults->resultValues( resAddr, 0, m_timeStep ).empty(); + } + } + return false; +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWbsParameters::assignValidSource( caf::PdmField* parameterSourceField, + const std::vector& validSources ) +{ + CAF_ASSERT( parameterSourceField ); + if ( std::find( validSources.begin(), validSources.end(), ( *parameterSourceField )() ) == validSources.end() ) + { + *parameterSourceField = validSources.front(); + } +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::vector RimWbsParameters::supportedSources( const RigWbsParameter& parameter ) const +{ + std::vector sources; + + for ( auto source : parameter.sources() ) + { + if ( source == RigWbsParameter::LAS_FILE ) + { + if ( hasLasFileWithChannel( parameter.addressString( RigWbsParameter::LAS_FILE ) ) ) + { + sources.push_back( source ); + } + } + else if ( source == RigWbsParameter::ELEMENT_PROPERTY_TABLE ) + { + RigFemResultAddress resAddr = parameter.femAddress( RigWbsParameter::ELEMENT_PROPERTY_TABLE ); + if ( hasElementPropertyEntry( resAddr ) ) + { + sources.push_back( source ); + } + } + else + { + sources.push_back( source ); + } + } + return sources; +} diff --git a/ApplicationCode/ProjectDataModel/RimWbsParameters.h b/ApplicationCode/ProjectDataModel/RimWbsParameters.h new file mode 100644 index 0000000000..9c7e08fa74 --- /dev/null +++ b/ApplicationCode/ProjectDataModel/RimWbsParameters.h @@ -0,0 +1,103 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2020- Equinor ASA +// +// ResInsight is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY +// WARRANTY; without even the implied warranty of MERCHANTABILITY or +// FITNESS FOR A PARTICULAR PURPOSE. +// +// See the GNU General Public License at +// for more details. +// +///////////////////////////////////////////////////////////////////////////////// +#pragma once + +#include "RigGeoMechWellLogExtractor.h" +#include "RigWbsParameter.h" + +#include "cafPdmField.h" +#include "cafPdmObject.h" +#include "cafPdmPtrField.h" + +#include + +class RimGeoMechCase; +class RimWellPath; + +class RimWbsParameters : public caf::PdmObject +{ + CAF_PDM_HEADER_INIT; + +public: + using ParameterSource = RigGeoMechWellLogExtractor::WbsParameterSource; + using ParameterSourceEnum = RigGeoMechWellLogExtractor::WbsParameterSourceEnum; + +public: + RimWbsParameters(); + ~RimWbsParameters() override; + + RimWbsParameters( const RimWbsParameters& copyFrom ); + RimWbsParameters& operator=( const RimWbsParameters& copyFrom ); + + void setGeoMechCase( RimGeoMechCase* geoMechCase ); + void setWellPath( RimWellPath* wellPath ); + void setTimeStep( int timeStep ); + + void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); + + ParameterSource parameterSource( const RigWbsParameter& parameter ) const; + double userDefinedValue( const RigWbsParameter& parameter ) const; + + void setParameterSource( const RigWbsParameter& parameter, ParameterSource source ); + void setUserDefinedValue( const RigWbsParameter& parameter, double value ); + + caf::PdmField* sourceField( const RigWbsParameter& parameter ) const; + + virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, + bool* useOptionsOnly ) override; + + void loadDataAndUpdate(); + +protected: + void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; + +private: + bool hasLasFileWithChannel( const QString& channel ) const; + bool hasElementPropertyEntry( const RigFemResultAddress& resAddr ) const; + + void assignValidSource( caf::PdmField* parameterSourceField, + const std::vector& validSources ); + + std::vector supportedSources( const RigWbsParameter& parameter ) const; + +private: + caf::PdmField m_porePressureSource; + caf::PdmField m_porePressureShaleSource; + caf::PdmField m_poissonRatioSource; + caf::PdmField m_ucsSource; + caf::PdmField m_OBG0Source; + caf::PdmField m_DFSource; + caf::PdmField m_K0FGSource; + caf::PdmField m_K0SHSource; + caf::PdmField m_FGShaleSource; + + caf::PdmField m_userDefinedPPShale; + caf::PdmField m_userDefinedPoissionRatio; + caf::PdmField m_userDefinedUcs; + caf::PdmField m_userDefinedDF; + caf::PdmField m_userDefinedK0FG; + caf::PdmField m_userDefinedK0SH; + caf::PdmField m_FGShaleMultiplier; + + caf::PdmPtrField m_geoMechCase; + caf::PdmPtrField m_wellPath; + caf::PdmField m_timeStep; + + std::map*> m_parameterSourceFields; + std::map*> m_userDefinedValueFields; +}; diff --git a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp index 4f09d5b488..5957b1d8e9 100644 --- a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.cpp @@ -17,12 +17,14 @@ ///////////////////////////////////////////////////////////////////////////////// #include "RimWellBoreStabilityPlot.h" +#include "RiaDefines.h" #include "RigFemPartResultsCollection.h" #include "RigFemResultAddress.h" #include "RigGeoMechCaseData.h" #include "RimGeoMechCase.h" #include "RimTools.h" +#include "RimWbsParameters.h" #include "RimWellLogCurveCommonDataSource.h" #include "RimWellLogFile.h" @@ -40,102 +42,13 @@ RimWellBoreStabilityPlot::RimWellBoreStabilityPlot() { CAF_PDM_InitObject( "Well Bore Stability Plot", ":/WellLogPlot16x16.png", "", "" ); - CAF_PDM_InitFieldNoDefault( &m_porePressureSource, - "PorePressureSource", - "Pore Pressure", - "", - "Data source for Pore Pressure", - "" ); - - CAF_PDM_InitFieldNoDefault( &m_porePressureShaleSource, - "PorePressureShaleSource", - "Shale Pore Pressure", - "", - "Data source for Pore Pressure in Shale", - "" ); - - CAF_PDM_InitFieldNoDefault( &m_poissonRatioSource, - "PoissionRatioSource", - "Poisson Ratio", - "", - "Data source for Poisson Ratio", - "" ); - - CAF_PDM_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", "" ); - - 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)", - "" ); - - 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)", - "" ); - - 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", - "" ); - // 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]", "" ); - - // TODO: Get reasonable defaults from Lasse. For now all set to 1 - 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", - "" ); - - m_parameterSourceFields = {{RigWbsParameter::PP_Sand(), &m_porePressureSource}, - {RigWbsParameter::PP_Shale(), &m_porePressureShaleSource}, - {RigWbsParameter::poissonRatio(), &m_poissonRatioSource}, - {RigWbsParameter::UCS(), &m_ucsSource}, - {RigWbsParameter::OBG0(), &m_OBG0Source}, - {RigWbsParameter::DF(), &m_DFSource}, - {RigWbsParameter::K0_FG(), &m_K0FGSource}, - {RigWbsParameter::K0_SH(), &m_K0SHSource}, - {RigWbsParameter::FG_Shale(), &m_FGShaleSource}}; - - m_userDefinedValueFields = {{RigWbsParameter::PP_Shale(), &m_userDefinedPPShale}, - {RigWbsParameter::poissonRatio(), &m_userDefinedPoissionRatio}, - {RigWbsParameter::UCS(), &m_userDefinedUcs}, - {RigWbsParameter::DF(), &m_userDefinedDF}, - {RigWbsParameter::K0_FG(), &m_userDefinedK0FG}, - {RigWbsParameter::K0_SH(), &m_userDefinedK0SH}, - {RigWbsParameter::FG_Shale(), &m_FGShaleMultiplier}}; - - for ( auto parameterFieldPair : m_parameterSourceFields ) - { - auto sources = parameterFieldPair.first.sources(); - if ( !sources.empty() ) - { - setParameterSource( parameterFieldPair.first, sources.front() ); - } - } + CAF_PDM_InitFieldNoDefault( &m_wbsParameters, "WbsParameters", "Well Bore Stability Parameters", "", "", "" ); + m_wbsParameters = new RimWbsParameters; m_nameConfig->setCustomName( "Well Bore Stability" ); m_nameConfig->enableAllAutoNameTags( true ); + + m_commonDataSource->setCaseType( RiaDefines::GEOMECH_ODB_CASE ); } //-------------------------------------------------------------------------------------------------- @@ -143,28 +56,7 @@ RimWellBoreStabilityPlot::RimWellBoreStabilityPlot() //-------------------------------------------------------------------------------------------------- void RimWellBoreStabilityPlot::applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ) { - for ( auto parameterSourcePair : m_parameterSourceFields ) - { - extractor->setWbsParametersSource( parameterSourcePair.first, ( *parameterSourcePair.second )() ); - } - for ( auto parameterUserDefinedValuePair : m_userDefinedValueFields ) - { - extractor->setWbsUserDefinedValue( parameterUserDefinedValuePair.first, - ( *parameterUserDefinedValuePair.second ) ); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -RimWellBoreStabilityPlot::ParameterSource RimWellBoreStabilityPlot::parameterSource( const RigWbsParameter& parameter ) const -{ - auto field = sourceField( parameter ); - if ( field ) - { - return ( *field )(); - } - return RigWbsParameter::INVALID; + m_wbsParameters->applyWbsParametersToExtractor( extractor ); } //-------------------------------------------------------------------------------------------------- @@ -172,24 +64,15 @@ RimWellBoreStabilityPlot::ParameterSource RimWellBoreStabilityPlot::parameterSou //-------------------------------------------------------------------------------------------------- double RimWellBoreStabilityPlot::userDefinedValue( const RigWbsParameter& parameter ) const { - auto it = m_userDefinedValueFields.find( parameter ); - if ( it != m_userDefinedValueFields.end() ) - { - return *it->second; - } - return std::numeric_limits::infinity(); + return m_wbsParameters->userDefinedValue( parameter ); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -void RimWellBoreStabilityPlot::setParameterSource( const RigWbsParameter& parameter, ParameterSource source ) +void RimWellBoreStabilityPlot::setWbsParameters( const RimWbsParameters& wbsParameters ) { - auto field = sourceField( parameter ); - if ( field ) - { - *field = source; - } + *m_wbsParameters = wbsParameters; } //-------------------------------------------------------------------------------------------------- @@ -199,32 +82,8 @@ void RimWellBoreStabilityPlot::defineUiOrdering( QString uiConfigName, caf::PdmU { m_commonDataSource->uiOrdering( RimWellLogCurveCommonDataSource::smoothingUiOrderinglabel(), uiOrdering ); - caf::PdmUiGroup* parameterSources = uiOrdering.addNewGroup( "Parameter Sources" ); - parameterSources->add( &m_porePressureSource ); - parameterSources->add( &m_porePressureShaleSource ); - if ( m_porePressureShaleSource == RigWbsParameter::USER_DEFINED ) - { - parameterSources->add( &m_userDefinedPPShale ); - } - parameterSources->add( &m_poissonRatioSource ); - parameterSources->add( &m_userDefinedPoissionRatio ); - parameterSources->add( &m_ucsSource ); - parameterSources->add( &m_userDefinedUcs ); - parameterSources->add( &m_OBG0Source ); - parameterSources->add( &m_DFSource ); - parameterSources->add( &m_userDefinedDF ); - parameterSources->add( &m_K0SHSource ); - parameterSources->add( &m_userDefinedK0SH ); - parameterSources->add( &m_FGShaleSource ); - if ( m_FGShaleSource == RigWbsParameter::PROPORTIONAL_TO_SH ) - { - parameterSources->add( &m_FGShaleMultiplier ); - } - else - { - parameterSources->add( &m_K0FGSource ); - parameterSources->add( &m_userDefinedK0FG ); - } + caf::PdmUiGroup* parametersGroup = uiOrdering.addNewGroup( "Parameter Sources" ); + m_wbsParameters->uiOrdering( uiConfigName, *parametersGroup ); caf::PdmUiGroup* depthGroup = uiOrdering.addNewGroup( "Depth Axis" ); RimWellLogPlot::uiOrderingForDepthAxis( uiConfigName, *depthGroup ); @@ -238,181 +97,45 @@ void RimWellBoreStabilityPlot::defineUiOrdering( QString uiConfigName, caf::PdmU uiOrdering.skipRemainingFields( true ); } -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -QList - RimWellBoreStabilityPlot::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, bool* useOptionsOnly ) -{ - QList options = RimWellLogPlot::calculateValueOptions( fieldNeedingOptions, useOptionsOnly ); - - std::set allParameters = RigWbsParameter::allParameters(); - - for ( const RigWbsParameter& parameter : allParameters ) - { - caf::PdmField* field = sourceField( parameter ); - if ( field == fieldNeedingOptions ) - { - std::vector sources = supportedSources( parameter ); - for ( int i = 0; i < (int)sources.size(); ++i ) - { - if ( parameter.exclusiveOptions() || i == (int)sources.size() - 1 || - sources[i] == RigWbsParameter::HYDROSTATIC ) - { - options.push_back( caf::PdmOptionItemInfo( ParameterSourceEnum::uiText( sources[i] ), sources[i] ) ); - } - else - { - QStringList cumulativeSourceLabels; - for ( int j = i; j < (int)sources.size(); ++j ) - { - int index = 1 + ( j - i ); - cumulativeSourceLabels.push_back( - QString( "%1. %2" ).arg( index ).arg( ParameterSourceEnum::uiText( sources[j] ) ) ); - } - options.push_back( caf::PdmOptionItemInfo( cumulativeSourceLabels.join( ", " ), sources[i] ) ); - } - } - break; - } - } - - return options; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellBoreStabilityPlot::fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) -{ - RimWellLogPlot::fieldChangedByUi( changedField, oldValue, newValue ); - - if ( changedField == &m_porePressureSource || changedField == &m_porePressureShaleSource || - changedField == &m_poissonRatioSource || changedField == &m_ucsSource || changedField == &m_OBG0Source || - changedField == &m_DFSource || changedField == &m_K0FGSource || changedField == &m_K0SHSource || - changedField == &m_FGShaleSource ) - { - this->loadDataAndUpdate(); - } - else if ( changedField == &m_userDefinedPPShale || changedField == &m_userDefinedPoissionRatio || - changedField == &m_userDefinedUcs || changedField == &m_userDefinedDF || - changedField == &m_userDefinedK0FG || changedField == &m_userDefinedK0SH || - changedField == &m_FGShaleMultiplier ) - { - this->loadDataAndUpdate(); - } -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -void RimWellBoreStabilityPlot::assignValidSource( caf::PdmField* parameterSourceField, - const std::vector& validSources ) -{ - CAF_ASSERT( parameterSourceField ); - if ( std::find( validSources.begin(), validSources.end(), ( *parameterSourceField )() ) == validSources.end() ) - { - *parameterSourceField = validSources.front(); - } -} - //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- void RimWellBoreStabilityPlot::onLoadDataAndUpdate() { - std::set allParameters = RigWbsParameter::allParameters(); - - for ( const RigWbsParameter& parameter : allParameters ) - { - caf::PdmField* field = sourceField( parameter ); - if ( field ) - { - assignValidSource( field, supportedSources( parameter ) ); - } - } - + m_wbsParameters->loadDataAndUpdate(); RimWellLogPlot::onLoadDataAndUpdate(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellBoreStabilityPlot::hasLasFileWithChannel( const QString& channel ) const +void RimWellBoreStabilityPlot::childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) { - RimWellPath* wellPath = m_commonDataSource->wellPathToApply(); - if ( wellPath && !RimWellLogFile::findMdAndChannelValuesForWellPath( wellPath, channel ).empty() ) + if ( changedChildField == &m_commonDataSource ) { - return true; + applyDataSource(); + } + else if ( changedChildField == &m_wbsParameters ) + { + this->loadDataAndUpdate(); } - return false; } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -bool RimWellBoreStabilityPlot::hasElementPropertyEntry( const RigFemResultAddress& resAddr ) const +void RimWellBoreStabilityPlot::initAfterRead() { - int timeStep = m_commonDataSource->timeStepToApply(); - RimGeoMechCase* geoMechCase = dynamic_cast( m_commonDataSource->caseToApply() ); - - RigFemPartResultsCollection* femPartResults = nullptr; - if ( geoMechCase && timeStep > 0 ) - { - femPartResults = geoMechCase->geoMechData()->femPartResults(); - if ( femPartResults ) - { - return !femPartResults->resultValues( resAddr, 0, timeStep ).empty(); - } - } - return false; + applyDataSource(); } //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- -caf::PdmField* - RimWellBoreStabilityPlot::sourceField( const RigWbsParameter& parameter ) const +void RimWellBoreStabilityPlot::applyDataSource() { - auto it = m_parameterSourceFields.find( parameter ); - if ( it != m_parameterSourceFields.end() ) - { - return it->second; - } - return nullptr; -} - -//-------------------------------------------------------------------------------------------------- -/// -//-------------------------------------------------------------------------------------------------- -std::vector - RimWellBoreStabilityPlot::supportedSources( const RigWbsParameter& parameter ) const -{ - std::vector sources; - - for ( auto source : parameter.sources() ) - { - if ( source == RigWbsParameter::LAS_FILE ) - { - if ( hasLasFileWithChannel( parameter.addressString( RigWbsParameter::LAS_FILE ) ) ) - { - sources.push_back( source ); - } - } - else if ( source == RigWbsParameter::ELEMENT_PROPERTY_TABLE ) - { - RigFemResultAddress resAddr = parameter.femAddress( RigWbsParameter::ELEMENT_PROPERTY_TABLE ); - if ( hasElementPropertyEntry( resAddr ) ) - { - sources.push_back( source ); - } - } - else - { - sources.push_back( source ); - } - } - return sources; + m_wbsParameters->setGeoMechCase( dynamic_cast( m_commonDataSource->caseToApply() ) ); + m_wbsParameters->setWellPath( m_commonDataSource->wellPathToApply() ); + m_wbsParameters->setTimeStep( m_commonDataSource->timeStepToApply() ); + this->updateConnectedEditors(); } diff --git a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.h b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.h index 476375ac91..7366add013 100644 --- a/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.h +++ b/ApplicationCode/ProjectDataModel/RimWellBoreStabilityPlot.h @@ -26,68 +26,30 @@ #include "cafPdmField.h" #include "cafPdmPtrField.h" -#include - class RimGeoMechCase; class RimWellPath; +class RimWbsParameters; class RimWellBoreStabilityPlot : public RimWellLogPlot -{ +{ CAF_PDM_HEADER_INIT; - using ParameterSource = RigGeoMechWellLogExtractor::WbsParameterSource; - using ParameterSourceEnum = RigGeoMechWellLogExtractor::WbsParameterSourceEnum; - public: RimWellBoreStabilityPlot(); - - void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); - - RimWellBoreStabilityPlot::ParameterSource parameterSource( const RigWbsParameter& parameter ) const; - double userDefinedValue( const RigWbsParameter& parameter ) const; - - void setParameterSource( const RigWbsParameter& parameter, RimWellBoreStabilityPlot::ParameterSource ); + void applyWbsParametersToExtractor( RigGeoMechWellLogExtractor* extractor ); + double userDefinedValue( const RigWbsParameter& parameter ) const; + void setWbsParameters( const RimWbsParameters& wbsParameters ); protected: void defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering ) override; - virtual QList calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions, - bool* useOptionsOnly ) override; - - void fieldChangedByUi( const caf::PdmFieldHandle* changedField, - const QVariant& oldValue, - const QVariant& newValue ) override; - - void assignValidSource( caf::PdmField* parameterSourceField, - const std::vector& validSources ); void onLoadDataAndUpdate() override; - - bool hasLasFileWithChannel( const QString& channel ) const; - bool hasElementPropertyEntry( const RigFemResultAddress& resAddr ) const; - - caf::PdmField* sourceField( const RigWbsParameter& parameter ) const; - - std::vector supportedSources( const RigWbsParameter& parameter ) const; + void childFieldChangedByUi( const caf::PdmFieldHandle* changedChildField ) override; + void initAfterRead() override; private: - caf::PdmField m_porePressureSource; - caf::PdmField m_porePressureShaleSource; - caf::PdmField m_poissonRatioSource; - caf::PdmField m_ucsSource; - caf::PdmField m_OBG0Source; - caf::PdmField m_DFSource; - caf::PdmField m_K0FGSource; - caf::PdmField m_K0SHSource; - caf::PdmField m_FGShaleSource; + void applyDataSource(); - caf::PdmField m_userDefinedPPShale; - caf::PdmField m_userDefinedPoissionRatio; - caf::PdmField m_userDefinedUcs; - caf::PdmField m_userDefinedDF; - caf::PdmField m_userDefinedK0FG; - caf::PdmField m_userDefinedK0SH; - caf::PdmField m_FGShaleMultiplier; - - std::map*> m_parameterSourceFields; - std::map*> m_userDefinedValueFields; +private: + caf::PdmChildField m_wbsParameters; }; diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp index c8480f1367..60f3929487 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.cpp @@ -69,6 +69,7 @@ bool RimWellLogCurveCommonDataSource::DoubleComparator::operator()( const double /// //-------------------------------------------------------------------------------------------------- RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() + : m_caseType( RiaDefines::UNDEFINED_CASE ) { CAF_PDM_InitObject( "Change Data Source", "", "", "" ); @@ -100,6 +101,14 @@ RimWellLogCurveCommonDataSource::RimWellLogCurveCommonDataSource() m_wellPath = nullptr; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +void RimWellLogCurveCommonDataSource::setCaseType( RiaDefines::CaseType caseType ) +{ + m_caseType = caseType; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -749,7 +758,19 @@ QList if ( fieldNeedingOptions == &m_case ) { - RimTools::caseOptionItems( &options ); + if ( m_caseType == RiaDefines::GEOMECH_ODB_CASE ) + { + RimTools::geoMechCaseOptionItems( &options ); + } + else if ( m_caseType == RiaDefines::ECLIPSE_RESULT_CASE || m_caseType == RiaDefines::ECLIPSE_INPUT_CASE || + m_caseType == RiaDefines::ECLIPSE_SOURCE_CASE || m_caseType == RiaDefines::ECLIPSE_STAT_CASE ) + { + RimTools::eclipseCaseOptionItems( &options ); + } + else + { + RimTools::caseOptionItems( &options ); + } if ( caseToApply() == nullptr ) { diff --git a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h index d5d5840793..d458a65a23 100644 --- a/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h +++ b/ApplicationCode/ProjectDataModel/RimWellLogCurveCommonDataSource.h @@ -52,6 +52,8 @@ public: RimWellLogCurveCommonDataSource(); + void setCaseType( RiaDefines::CaseType caseType ); + RimCase* caseToApply() const; void setCaseToApply( RimCase* val ); int trajectoryTypeToApply() const; @@ -102,6 +104,8 @@ protected: void modifyCurrentIndex( caf::PdmValueField* field, int indexOffset ); private: + RiaDefines::CaseType m_caseType; + caf::PdmPtrField m_case; caf::PdmField m_trajectoryType; caf::PdmPtrField m_wellPath;