From b69665ce238178dae4ea453456d69778647b3961 Mon Sep 17 00:00:00 2001 From: Kristian Bendiksen Date: Mon, 16 Aug 2021 14:52:09 +0200 Subject: [PATCH] #7871 StimPlan Model: Add data source ordering for EQLNUM extraction --- .../StimPlanModel/CMakeLists_files.cmake | 2 + .../RimExtractionConfiguration.cpp | 48 ++++++ .../RimExtractionConfiguration.h | 38 +++++ .../StimPlanModel/RimStimPlanModel.cpp | 54 +++++++ .../StimPlanModel/RimStimPlanModel.h | 4 + .../RimStimPlanModelWellLogCalculator.cpp | 142 ++++++++++++++++-- .../RimStimPlanModelWellLogCalculator.h | 22 ++- 7 files changed, 294 insertions(+), 16 deletions(-) create mode 100644 ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.cpp create mode 100644 ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.h diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/CMakeLists_files.cmake b/ApplicationLibCode/ProjectDataModel/StimPlanModel/CMakeLists_files.cmake index 215e8ad39c..f9c826737f 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/CMakeLists_files.cmake +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/CMakeLists_files.cmake @@ -23,6 +23,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimNonNetLayers.h ${CMAKE_CURRENT_LIST_DIR}/RimFaciesInitialPressureConfig.h ${CMAKE_CURRENT_LIST_DIR}/RimPressureTableItem.h ${CMAKE_CURRENT_LIST_DIR}/RimPressureTable.h +${CMAKE_CURRENT_LIST_DIR}/RimExtractionConfiguration.h ) set (SOURCE_GROUP_SOURCE_FILES @@ -47,6 +48,7 @@ ${CMAKE_CURRENT_LIST_DIR}/RimNonNetLayers.cpp ${CMAKE_CURRENT_LIST_DIR}/RimFaciesInitialPressureConfig.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPressureTableItem.cpp ${CMAKE_CURRENT_LIST_DIR}/RimPressureTable.cpp +${CMAKE_CURRENT_LIST_DIR}/RimExtractionConfiguration.cpp ) list(APPEND CODE_HEADER_FILES diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.cpp new file mode 100644 index 0000000000..548548e33c --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.cpp @@ -0,0 +1,48 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- 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 "RimExtractionConfiguration.h" + +#include "cafAppEnum.h" + +namespace caf +{ +template <> +void caf::AppEnum::setUp() +{ + addItem( RimExtractionConfiguration::EclipseCaseType::STATIC_CASE, "STATIC_CASE", "Static Case" ); + addItem( RimExtractionConfiguration::EclipseCaseType::DYNAMIC_CASE, "DYNAMIC_CASE", "Dynamic Case" ); + addItem( RimExtractionConfiguration::EclipseCaseType::INITIAL_PRESSURE_CASE, + "INITIAL_PRESSURE_CASE", + "Initial Pressure Case" ); + + setDefault( RimExtractionConfiguration::EclipseCaseType::STATIC_CASE ); +} +}; // namespace caf + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +RimExtractionConfiguration::RimExtractionConfiguration( const QString& resultVar, + RiaDefines::ResultCatType resultCat, + EclipseCaseType eclipseCase ) +{ + resultVariable = resultVar; + resultCategory = resultCat; + eclipseCaseType = eclipseCase; +} diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.h new file mode 100644 index 0000000000..79f1bf6685 --- /dev/null +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimExtractionConfiguration.h @@ -0,0 +1,38 @@ +///////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) 2021- 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 "RiaDefines.h" + +class RimExtractionConfiguration +{ +public: + enum class EclipseCaseType + { + STATIC_CASE, + DYNAMIC_CASE, + INITIAL_PRESSURE_CASE + }; + + RimExtractionConfiguration( const QString& resultVar, RiaDefines::ResultCatType resultCat, EclipseCaseType eclipseCase ); + + RiaDefines::ResultCatType resultCategory; + QString resultVariable; + EclipseCaseType eclipseCaseType; +}; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp index efd841505b..0894928f96 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.cpp @@ -40,6 +40,7 @@ #include "RimEclipseCase.h" #include "RimEclipseResultDefinition.h" #include "RimEclipseView.h" +#include "RimExtractionConfiguration.h" #include "RimFaciesProperties.h" #include "RimFaultInView.h" #include "RimFaultInViewCollection.h" @@ -1710,3 +1711,56 @@ QString RimStimPlanModel::pressureDate() const else return QString(); } + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::deque + RimStimPlanModel::extractionConfigurations( RiaDefines::CurveProperty curveProperty ) const +{ + if ( curveProperty == RiaDefines::CurveProperty::EQLNUM ) + { + return { + RimExtractionConfiguration( "EQLNUM_1", + RiaDefines::ResultCatType::INPUT_PROPERTY, + RimExtractionConfiguration::EclipseCaseType::INITIAL_PRESSURE_CASE ), + RimExtractionConfiguration( "EQLNUM", + RiaDefines::ResultCatType::INPUT_PROPERTY, + RimExtractionConfiguration::EclipseCaseType::INITIAL_PRESSURE_CASE ), + RimExtractionConfiguration( "EQLNUM_1", + RiaDefines::ResultCatType::INPUT_PROPERTY, + RimExtractionConfiguration::EclipseCaseType::DYNAMIC_CASE ), + RimExtractionConfiguration( "EQLNUM", + RiaDefines::ResultCatType::INPUT_PROPERTY, + RimExtractionConfiguration::EclipseCaseType::DYNAMIC_CASE ), + RimExtractionConfiguration( "EQLNUM_1", + RiaDefines::ResultCatType::INPUT_PROPERTY, + RimExtractionConfiguration::EclipseCaseType::STATIC_CASE ), + RimExtractionConfiguration( "EQLNUM", + RiaDefines::ResultCatType::INPUT_PROPERTY, + RimExtractionConfiguration::EclipseCaseType::STATIC_CASE ), + RimExtractionConfiguration( "EQLNUM", + RiaDefines::ResultCatType::STATIC_NATIVE, + RimExtractionConfiguration::EclipseCaseType::STATIC_CASE ), + RimExtractionConfiguration( "EQLNUM", + RiaDefines::ResultCatType::STATIC_NATIVE, + RimExtractionConfiguration::EclipseCaseType::INITIAL_PRESSURE_CASE ), + RimExtractionConfiguration( "EQLNUM", + RiaDefines::ResultCatType::STATIC_NATIVE, + RimExtractionConfiguration::EclipseCaseType::DYNAMIC_CASE ), + + }; + } + + return std::deque(); +} + +RimEclipseCase* RimStimPlanModel::eclipseCaseForType( RimExtractionConfiguration::EclipseCaseType caseType ) const +{ + if ( caseType == RimExtractionConfiguration::EclipseCaseType::STATIC_CASE ) return m_staticEclipseCase; + if ( caseType == RimExtractionConfiguration::EclipseCaseType::DYNAMIC_CASE ) return m_eclipseCase; + if ( caseType == RimExtractionConfiguration::EclipseCaseType::INITIAL_PRESSURE_CASE ) + return m_initialPressureEclipseCase; + + return nullptr; +} diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h index cdc9e2e677..47bc34b1f0 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModel.h @@ -21,6 +21,7 @@ #include "RiaStimPlanModelDefines.h" #include "RimCheckableNamedObject.h" +#include "RimExtractionConfiguration.h" #include "RimWellPathComponentInterface.h" #include "RigWellLogExtractor.h" @@ -178,6 +179,9 @@ public: RiaDefines::ResultCatType eclipseResultCategory( RiaDefines::CurveProperty curveProperty ) const; QString eclipseResultVariable( RiaDefines::CurveProperty curveProperty ) const; + std::deque extractionConfigurations( RiaDefines::CurveProperty curveProperty ) const; + RimEclipseCase* eclipseCaseForType( RimExtractionConfiguration::EclipseCaseType ) const; + static double findFaciesValue( const RimColorLegend& colorLegend, const QString& name ); bool isScaledByNetToGross( RiaDefines::CurveProperty curveProperty ) const; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.cpp b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.cpp index e27ea48911..1e879cec20 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.cpp +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.cpp @@ -37,6 +37,7 @@ #include "RimEclipseInputProperty.h" #include "RimEclipseInputPropertyCollection.h" #include "RimEclipseResultDefinition.h" +#include "RimExtractionConfiguration.h" #include "RimModeledWellPath.h" #include "RimNonNetLayers.h" #include "RimStimPlanModel.h" @@ -83,23 +84,49 @@ bool RimStimPlanModelWellLogCalculator::calculate( RiaDefines::CurveProperty cur { RiaLogging::debug( QString( "Calculating well log for '%1'." ).arg( caf::AppEnum( curveProperty ).uiText() ) ); + + std::deque extractionConfigurations = + stimPlanModel->extractionConfigurations( curveProperty ); + std::deque missingValueStratgies = stimPlanModel->missingValueStrategies( curveProperty ); - if ( !extractValuesForProperty( curveProperty, stimPlanModel, timeStep, values, measuredDepthValues, tvDepthValues, rkbDiff ) ) + if ( extractionConfigurations.empty() ) { - if ( std::find( missingValueStratgies.begin(), - missingValueStratgies.end(), - RimStimPlanModel::MissingValueStrategy::DEFAULT_VALUE ) != missingValueStratgies.end() ) + if ( !extractValuesForProperty( curveProperty, stimPlanModel, timeStep, values, measuredDepthValues, tvDepthValues, rkbDiff ) ) { - RiaLogging::warning( QString( "Extraction failed. Trying fallback" ) ); - if ( !replaceMissingValuesWithDefault( curveProperty, stimPlanModel, values, measuredDepthValues, tvDepthValues, rkbDiff ) ) + if ( std::find( missingValueStratgies.begin(), + missingValueStratgies.end(), + RimStimPlanModel::MissingValueStrategy::DEFAULT_VALUE ) != missingValueStratgies.end() ) { - RiaLogging::error( "Fallback failed too." ); - return false; + RiaLogging::warning( QString( "Extraction failed. Trying fallback" ) ); + if ( !replaceMissingValuesWithDefault( curveProperty, + stimPlanModel, + values, + measuredDepthValues, + tvDepthValues, + rkbDiff ) ) + { + RiaLogging::error( "Fallback failed too." ); + return false; + } } } } + else + { + if ( !extractValuesForPropertyWithConfigurations( curveProperty, + stimPlanModel, + timeStep, + values, + measuredDepthValues, + tvDepthValues, + rkbDiff ) ) + + { + return false; + } + } double overburdenHeight = stimPlanModel->overburdenHeight(); if ( overburdenHeight > 0.0 ) @@ -388,6 +415,65 @@ void RimStimPlanModelWellLogCalculator::scaleByNetToGross( const RimStimPlanMode } } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStimPlanModelWellLogCalculator::extractValuesForPropertyWithConfigurations( RiaDefines::CurveProperty curveProperty, + const RimStimPlanModel* stimPlanModel, + int timeStep, + std::vector& values, + std::vector& measuredDepthValues, + std::vector& tvDepthValues, + double& rkbDiff ) const +{ + std::deque extractionConfigurations = + stimPlanModel->extractionConfigurations( curveProperty ); + + QString curvePropertyName = caf::AppEnum( curveProperty ).uiText(); + + for ( auto extractionConfig : extractionConfigurations ) + { + RiaDefines::ResultCatType resultType = extractionConfig.resultCategory; + QString resultVariable = extractionConfig.resultVariable; + RimExtractionConfiguration::EclipseCaseType eclipseCaseType = extractionConfig.eclipseCaseType; + + RiaLogging::info( + QString( "Trying extraction option for '%1': %2 %3 %4" ) + .arg( curvePropertyName ) + .arg( resultVariable ) + .arg( caf::AppEnum( resultType ).uiText() ) + .arg( caf::AppEnum( eclipseCaseType ).uiText() ) ); + + RimEclipseCase* eclipseCase = stimPlanModel->eclipseCaseForType( eclipseCaseType ); + + if ( !eclipseCase ) + { + RiaLogging::info( "Skipping extraction config due to missing model." ); + } + else + { + bool isOk = extractValuesForProperty( curveProperty, + stimPlanModel, + eclipseCase, + resultType, + resultVariable, + timeStep, + values, + measuredDepthValues, + tvDepthValues, + rkbDiff ); + if ( isOk ) + { + RiaLogging::info( "Extraction succeeded" ); + return true; + } + } + } + + RiaLogging::info( QString( "Extraction failed. Tried %1 configurations." ).arg( extractionConfigurations.size() ) ); + return false; +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- @@ -400,11 +486,37 @@ bool RimStimPlanModelWellLogCalculator::extractValuesForProperty( RiaDefines::Cu double& rkbDiff ) const { RimEclipseCase* eclipseCase = stimPlanModel->eclipseCaseForProperty( curveProperty ); - if ( !eclipseCase ) - { - return false; - } + if ( !eclipseCase ) return false; + RiaDefines::ResultCatType resultType = stimPlanModel->eclipseResultCategory( curveProperty ); + QString resultVariable = stimPlanModel->eclipseResultVariable( curveProperty ); + + return extractValuesForProperty( curveProperty, + stimPlanModel, + eclipseCase, + resultType, + resultVariable, + timeStep, + values, + measuredDepthValues, + tvDepthValues, + rkbDiff ); +} + +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +bool RimStimPlanModelWellLogCalculator::extractValuesForProperty( RiaDefines::CurveProperty curveProperty, + const RimStimPlanModel* stimPlanModel, + RimEclipseCase* eclipseCase, + RiaDefines::ResultCatType resultCategory, + const QString resultVariable, + int timeStep, + std::vector& values, + std::vector& measuredDepthValues, + std::vector& tvDepthValues, + double& rkbDiff ) const +{ if ( !stimPlanModel->thicknessDirectionWellPath() ) { return false; @@ -428,13 +540,13 @@ bool RimStimPlanModelWellLogCalculator::extractValuesForProperty( RiaDefines::Cu RimEclipseResultDefinition eclipseResultDefinition; eclipseResultDefinition.setEclipseCase( eclipseCase ); - eclipseResultDefinition.setResultType( stimPlanModel->eclipseResultCategory( curveProperty ) ); + eclipseResultDefinition.setResultType( resultCategory ); eclipseResultDefinition.setPorosityModel( RiaDefines::PorosityModelType::MATRIX_MODEL ); - eclipseResultDefinition.setResultVariable( stimPlanModel->eclipseResultVariable( curveProperty ) ); + eclipseResultDefinition.setResultVariable( resultVariable ); eclipseResultDefinition.loadResult(); - if ( stimPlanModel->eclipseResultCategory( curveProperty ) != RiaDefines::ResultCatType::DYNAMIC_NATIVE || + if ( resultCategory != RiaDefines::ResultCatType::DYNAMIC_NATIVE || curveProperty == RiaDefines::CurveProperty::INITIAL_PRESSURE ) { timeStep = 0; diff --git a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.h b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.h index a4377227d7..71f557ad0e 100644 --- a/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.h +++ b/ApplicationLibCode/ProjectDataModel/StimPlanModel/RimStimPlanModelWellLogCalculator.h @@ -29,9 +29,10 @@ #include class RigEclipseCaseData; +class RigResultAccessor; class RimEclipseInputPropertyCollection; class RimEclipseResultDefinition; -class RigResultAccessor; +class RimEclipseCase; class RimStimPlanModelWellLogCalculator : public RimStimPlanModelPropertyCalculator { @@ -87,6 +88,25 @@ protected: std::vector& tvDepthValues, double& rkbDiff ) const; + bool extractValuesForProperty( RiaDefines::CurveProperty curveProperty, + const RimStimPlanModel* stimPlanModel, + RimEclipseCase* eclipseCase, + RiaDefines::ResultCatType resultCategory, + const QString resultVariable, + int timeStep, + std::vector& values, + std::vector& measuredDepthValues, + std::vector& tvDepthValues, + double& rkbDiff ) const; + + bool extractValuesForPropertyWithConfigurations( RiaDefines::CurveProperty curveProperty, + const RimStimPlanModel* stimPlanModel, + int timeStep, + std::vector& values, + std::vector& measuredDepthValues, + std::vector& tvDepthValues, + double& rkbDiff ) const; + bool replaceMissingValuesWithDefault( RiaDefines::CurveProperty curveProperty, const RimStimPlanModel* stimPlanModel, std::vector& values,