diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp index 7e3d65cb31..03264a65b8 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultCalculatorMudWeightWindow.cpp @@ -141,6 +141,22 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( const bool OBG0FromGrid = m_resultCollection->getCalculationParameterAddress( RimMudWeightWindowParameters::ParameterType::OBG0 ).isEmpty(); + RimMudWeightWindowParameters::NonReservoirPorePressureType PP_NonReservoirType = + m_resultCollection->nonReservoirPorePressureTypeMudWeightWindow(); + double hydrostaticMultiplier = m_resultCollection->hydrostaticMultiplierPPNonRes(); + const QString& nonReservoirAddress = m_resultCollection->nonReservoirPorePressureAddressMudWeightWindow(); + RigFemScalarResultFrames* nonReservoirResultFrames = nullptr; + + if ( PP_NonReservoirType != RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC && + !nonReservoirAddress.isEmpty() ) + { + nonReservoirResultFrames = + m_resultCollection->findOrLoadScalarResult( partIndex, + RigFemResultAddress( RIG_ELEMENT, + nonReservoirAddress.toStdString(), + "" ) ); + } + float inf = std::numeric_limits::infinity(); frameCountProgress.setNextProgressIncrement( 1u ); @@ -173,6 +189,12 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( parameterFrameData[parameterType] = loadDataForFrame( parameterType, parameterFrames, fIdx ); } + std::vector nonReservoirPP; + if ( nonReservoirResultFrames ) + { + nonReservoirPP = nonReservoirResultFrames->frameData( 0 ); + } + // Load stress RigFemResultAddress stressResAddr( RIG_ELEMENT_NODAL, "ST", "" ); std::vector vertexStressesFloat = m_resultCollection->tensors( stressResAddr, partIndex, fIdx ); @@ -225,7 +247,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( int elmNodeCount = RigFemTypes::elementNodeCount( femPart->elementType( elmIdx ) ); - if ( elmType == HEX8P ) + if ( elmType == HEX8P || elmType == HEX8 ) { for ( int elmNodIdx = 0; elmNodIdx < elmNodeCount; ++elmNodIdx ) { @@ -242,8 +264,8 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( int nodeIdx = femPart->nodeIdxFromElementNodeResultIdx( elmNodResIdx ); // Pore pressure (unit: Bar) - double porePressureBar = porFrameData[nodeIdx]; - double initialPorePressureBar = initialPorFrameData[nodeIdx]; + float porePressureBar = porFrameData[nodeIdx]; + float initialPorePressureBar = initialPorFrameData[nodeIdx]; // Initial overburden gradient if ( OBG0FromGrid ) @@ -254,6 +276,24 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( // FG is for sands, SFG for shale. Sands has valid PP, shale does not. bool isSand = ( porePressureBar != inf ); + // + if ( porePressureBar == inf ) + { + // + if ( PP_NonReservoirType == + RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC ) + { + porePressureBar = cellCenterHydroStaticPressure * hydrostaticMultiplier; + initialPorePressureBar = cellCenterHydroStaticPressure * hydrostaticMultiplier; + } + else if ( !nonReservoirPP.empty() ) + { + // Get from element table + porePressureBar = nonReservoirPP[elmIdx]; + initialPorePressureBar = nonReservoirPP[elmIdx]; + } + } + caf::Ten3d segmentStress = caf::Ten3d( vertexStressesFloat[nodeIdx] ); cvf::Vec3d wellPathTangent = calculateWellPathTangent( wellPathAzimuth, wellPathDeviation ); @@ -309,7 +349,7 @@ RigFemScalarResultFrames* RigFemPartResultCalculatorMudWeightWindow::calculate( else { double SFG = sigmaCalculator.solveStassiDalia(); - lowerLimit = std::max( porePressureBar, SFG ); + lowerLimit = std::max( porePressureBar, static_cast( SFG ) ); } } diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp index 9d76f90fdc..24b950897a 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.cpp @@ -120,9 +120,11 @@ RigFemPartResultsCollection::RigFemPartResultsCollection( RifGeoMechReaderInterf m_initialPermeabilityResultAddress = ""; m_permeabilityExponent = 1.0; - m_airGapMudWeightWindow = 0.0; - m_referenceLayerMudWeightWindow = 0; - m_shMultiplierMudWeightWindow = 1.05; + m_airGapMudWeightWindow = 0.0; + m_referenceLayerMudWeightWindow = 0; + m_shMultiplierMudWeightWindow = 1.05; + m_nonReservoirPorePressureAddressMudWeightWindow = ""; + m_hydrostaticMultiplierPPNonResMudWeightWindow = 1.0; m_resultCalculators.push_back( std::unique_ptr( new RigFemPartResultCalculatorTimeLapse( *this ) ) ); @@ -1722,6 +1724,14 @@ RimMudWeightWindowParameters::NonReservoirPorePressureType return m_nonReservoirPorePressureTypeMudWeightWindow; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +const QString& RigFemPartResultsCollection::nonReservoirPorePressureAddressMudWeightWindow() const +{ + return m_nonReservoirPorePressureAddressMudWeightWindow; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -1757,7 +1767,8 @@ void RigFemPartResultsCollection::setMudWeightWindowParameters( RimMudWeightWindowParameters::FractureGradientCalculationType fgCalculationType, double shMultiplier, RimMudWeightWindowParameters::NonReservoirPorePressureType nonReservoirPorePressureType, - double hydrostaticMultiplierPPNonRes ) + double hydrostaticMultiplierPPNonRes, + const QString& nonReservoirPorePressureAddress ) { m_airGapMudWeightWindow = airGap; m_upperLimitParameterMudWeightWindow = upperLimit; @@ -1767,6 +1778,7 @@ void RigFemPartResultsCollection::setMudWeightWindowParameters( m_shMultiplierMudWeightWindow = shMultiplier; m_nonReservoirPorePressureTypeMudWeightWindow = nonReservoirPorePressureType; m_hydrostaticMultiplierPPNonResMudWeightWindow = hydrostaticMultiplierPPNonRes; + m_nonReservoirPorePressureAddressMudWeightWindow = nonReservoirPorePressureAddress; // Invalidate dependent results for ( auto result : mudWeightWindowResults() ) diff --git a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h index 85e494464b..79206bb121 100644 --- a/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h +++ b/ApplicationCode/GeoMech/GeoMechDataModel/RigFemPartResultsCollection.h @@ -95,13 +95,15 @@ public: RimMudWeightWindowParameters::FractureGradientCalculationType fgCalculationType, double shMultiplier, RimMudWeightWindowParameters::NonReservoirPorePressureType nonReservoirPorePressureType, - double hydroStaticMultiplierPPNonRes ); + double hydroStaticMultiplierPPNonRes, + const QString& nonReservoirPorePressureAddress ); double airGapMudWeightWindow() const; double shMultiplierMudWeightWindow() const; double hydrostaticMultiplierPPNonRes() const; RimMudWeightWindowParameters::NonReservoirPorePressureType nonReservoirPorePressureTypeMudWeightWindow() const; + const QString& nonReservoirPorePressureAddressMudWeightWindow() const; RimMudWeightWindowParameters::UpperLimitType upperLimitParameterMudWeightWindow() const; RimMudWeightWindowParameters::LowerLimitType lowerLimitParameterMudWeightWindow() const; @@ -217,6 +219,7 @@ private: RimMudWeightWindowParameters::NonReservoirPorePressureType m_nonReservoirPorePressureTypeMudWeightWindow; double m_hydrostaticMultiplierPPNonResMudWeightWindow; + QString m_nonReservoirPorePressureAddressMudWeightWindow; std::map parameterAddresses; std::map parameterValues; diff --git a/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp b/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp index b0daebe5ca..4c57211deb 100644 --- a/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp +++ b/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.cpp @@ -92,7 +92,7 @@ void caf::AppEnum template <> void caf::AppEnum::setUp() { - addItem( RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC, "PORE_PRESSURE", "Pore Pressure" ); + addItem( RimMudWeightWindowParameters::NonReservoirPorePressureType::HYDROSTATIC, "HYDROSTATIC", "Hydrostatic" ); addItem( RimMudWeightWindowParameters::NonReservoirPorePressureType::PER_ELEMENT, "PER_ELEMENT", "From element properties" ); @@ -189,6 +189,8 @@ RimMudWeightWindowParameters::RimMudWeightWindowParameters( void ) "Data source for Non-Reservoir Pore Pressure", "" ); CAF_PDM_InitField( &m_userDefinedPPNonReservoir, "UserPPNonReservoir", 1.0, " Multiplier of hydrostatic PP", "", "", "" ); + CAF_PDM_InitField( &m_porePressureNonReservoirAddress, "PPNonReservoirAddress", QString( "" ), "Value", "", "", "" ); + m_porePressureNonReservoirAddress.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() ); CAF_PDM_InitField( &m_referenceLayer, "ReferenceLayer", -1, "Reference Layer", "", "", "" ); } @@ -385,7 +387,7 @@ void RimMudWeightWindowParameters::fieldChangedByUi( const caf::PdmFieldHandle* else if ( changedField == &m_airGap || changedField == &m_upperLimitType || changedField == &m_lowerLimitType || changedField == &m_referenceLayer || changedField == &m_fractureGradientCalculationType || changedField == &m_shMultiplier || changedField == &m_porePressureNonReservoirSource || - changedField == &m_userDefinedPPNonReservoir ) + changedField == &m_userDefinedPPNonReservoir || changedField == &m_porePressureNonReservoirAddress ) { RigGeoMechCaseData* rigCaseData = geoMechCase->geoMechData(); if ( rigCaseData && rigCaseData->femPartResults() ) @@ -397,7 +399,8 @@ void RimMudWeightWindowParameters::fieldChangedByUi( const caf::PdmFieldHandle* m_fractureGradientCalculationType.value(), m_shMultiplier, m_porePressureNonReservoirSource.value(), - m_userDefinedPPNonReservoir ); + m_userDefinedPPNonReservoir, + m_porePressureNonReservoirAddress ); geoMechCase->updateConnectedViews(); } } @@ -504,6 +507,11 @@ void RimMudWeightWindowParameters::defineUiOrdering( QString uiConfigName, caf:: m_obg0Fixed.uiCapability()->setUiHidden( true ); m_obg0Address.uiCapability()->setUiHidden( !( isDerivedFromK0_FG && m_obg0Type == RimMudWeightWindowParameters::SourceType::PER_ELEMENT ) ); + + bool ppNonResPerElement = + ( m_porePressureNonReservoirSource == RimMudWeightWindowParameters::NonReservoirPorePressureType::PER_ELEMENT ); + m_userDefinedPPNonReservoir.uiCapability()->setUiHidden( ppNonResPerElement ); + m_porePressureNonReservoirAddress.uiCapability()->setUiHidden( !ppNonResPerElement ); } //-------------------------------------------------------------------------------------------------- @@ -574,7 +582,8 @@ QList } else if ( fieldNeedingOptions == &m_wellDeviationAddress || fieldNeedingOptions == &m_wellAzimuthAddress || fieldNeedingOptions == &m_UCSAddress || fieldNeedingOptions == &m_poissonsRatioAddress || - fieldNeedingOptions == &m_K0_FGAddress || fieldNeedingOptions == &m_obg0Address ) + fieldNeedingOptions == &m_K0_FGAddress || fieldNeedingOptions == &m_obg0Address || + fieldNeedingOptions == &m_porePressureNonReservoirAddress ) { std::vector elementProperties = geoMechCase->possibleElementPropertyFieldNames(); diff --git a/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.h b/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.h index 018d4547b4..43f0a04e34 100644 --- a/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.h +++ b/ApplicationCode/ProjectDataModel/RimMudWeightWindowParameters.h @@ -154,5 +154,7 @@ private: caf::PdmField> m_fractureGradientCalculationType; caf::PdmField> m_porePressureNonReservoirSource; + caf::PdmField m_porePressureNonReservoirAddress; + caf::PdmField m_referenceLayer; };