From a143da336bb1f7d583b339b2a1c0866ce3eac8ac Mon Sep 17 00:00:00 2001 From: jonjenssen Date: Tue, 26 Sep 2023 01:22:21 +0200 Subject: [PATCH] work in progress --- .../RicRunFaultReactModelingFeature.cpp | 6 +++-- .../Faults/RimFaultReactivationDataAccess.cpp | 20 +++++++++++----- .../Faults/RimFaultReactivationDataAccess.h | 2 ++ .../Faults/RimFaultReactivationModel.cpp | 23 +++++++++++++++++++ .../Faults/RimFaultReactivationModel.h | 2 ++ 5 files changed, 45 insertions(+), 8 deletions(-) diff --git a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp index 0fc62668606..1f5cece1c85 100644 --- a/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp +++ b/ApplicationLibCode/Commands/GeoMechCommands/RicRunFaultReactModelingFeature.cpp @@ -62,9 +62,11 @@ void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked ) runProgress.setProgressDescription( "Writing input files." ); - if ( model->fault() == nullptr ) + auto [modelOk, errorMsg] = model->validateBeforeRun(); + + if ( !modelOk ) { - QMessageBox::critical( nullptr, frmTitle, "A fault has not selected. Please check your model settings." ); + QMessageBox::critical( nullptr, frmTitle, QString::fromStdString( errorMsg ) ); return; } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp index 83b2ff53b86..93eea3dc958 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.cpp @@ -23,6 +23,7 @@ #include "RigCaseCellResultsData.h" #include "RigEclipseCaseData.h" #include "RigEclipseResultAddress.h" +#include "RigFault.h" #include "RigMainGrid.h" #include "RigResultAccessorFactory.h" @@ -34,9 +35,14 @@ RimFaultReactivationDataAccess::RimFaultReactivationDataAccess( RimEclipseCase* thecase, size_t timeStepIndex ) : m_case( thecase ) , m_caseData( nullptr ) + , m_mainGrid( nullptr ) , m_timeStepIndex( timeStepIndex ) { - if ( m_case ) m_caseData = m_case->eclipseCaseData(); + if ( m_case ) + { + m_caseData = m_case->eclipseCaseData(); + m_mainGrid = m_case->mainGrid(); + } if ( m_caseData ) { RigEclipseResultAddress resVarAddress( RiaDefines::ResultCatType::DYNAMIC_NATIVE, "PRESSURE" ); @@ -63,14 +69,16 @@ double RimFaultReactivationDataAccess::porePressureAtPosition( cvf::Vec3d positi double retValue = 0.0; size_t cellIdx = cvf::UNDEFINED_SIZE_T; - if ( ( m_case != nullptr ) && ( m_caseData != nullptr ) ) + if ( ( m_mainGrid != nullptr ) && m_resultAccessor.notNull() ) { - auto grid = m_case->mainGrid(); - if ( grid != nullptr ) cellIdx = grid->findReservoirCellIndexFromPoint( position ); + cellIdx = m_mainGrid->findReservoirCellIndexFromPoint( position ); + + // TODO - adjust cell index to be on correct side of fault - if ( ( cellIdx != cvf::UNDEFINED_SIZE_T ) && m_resultAccessor.notNull() ) + if ( ( cellIdx != cvf::UNDEFINED_SIZE_T ) ) { - return m_resultAccessor->cellScalar( cellIdx ); + double value = m_resultAccessor->cellScalar( cellIdx ); + if ( !std::isinf( value ) ) return 100000.0 * m_resultAccessor->cellScalar( cellIdx ); // return in pascal, not bar } } diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.h index 7435cd2a0dd..f1a88109a19 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationDataAccess.h @@ -24,6 +24,7 @@ class RimEclipseCase; class RigEclipseCaseData; class RigResultAccessor; +class RigMainGrid; //================================================================================================== /// @@ -45,6 +46,7 @@ class RimFaultReactivationDataAccess private: RimEclipseCase* m_case; RigEclipseCaseData* m_caseData; + const RigMainGrid* m_mainGrid; size_t m_timeStepIndex; cvf::ref m_resultAccessor; }; diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp index 473115fdf05..9df165c79d1 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.cpp @@ -164,6 +164,29 @@ caf::PdmFieldHandle* RimFaultReactivationModel::userDescriptionField() return &m_userDescription; } +//-------------------------------------------------------------------------------------------------- +/// +//-------------------------------------------------------------------------------------------------- +std::pair RimFaultReactivationModel::validateBeforeRun() +{ + if ( fault() == nullptr ) + { + return std::make_pair( false, "A fault has not selected. Please check your model settings." ); + } + + if ( selectedTimeSteps().size() < 2 ) + { + return std::make_pair( false, "You need at least 2 selected timesteps. Please check your model settings." ); + } + + if ( selectedTimeSteps()[0] != m_availableTimeSteps[0] ) + { + return std::make_pair( false, "The first available timestep must always be selected. Please check your model settings." ); + } + + return std::make_pair( true, "" ); +} + //-------------------------------------------------------------------------------------------------- /// //-------------------------------------------------------------------------------------------------- diff --git a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h index ed3195b9099..4a204bfa4a3 100644 --- a/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h +++ b/ApplicationLibCode/ProjectDataModel/Faults/RimFaultReactivationModel.h @@ -67,6 +67,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly QString userDescription(); void setUserDescription( QString description ); + std::pair validateBeforeRun(); + void setFault( RimFaultInView* fault ); RimFaultInView* fault() const;