Skip to content

Commit

Permalink
work in progress
Browse files Browse the repository at this point in the history
  • Loading branch information
jonjenssen committed Sep 25, 2023
1 parent fea3269 commit a143da3
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include "RigCaseCellResultsData.h"
#include "RigEclipseCaseData.h"
#include "RigEclipseResultAddress.h"
#include "RigFault.h"
#include "RigMainGrid.h"
#include "RigResultAccessorFactory.h"

Expand All @@ -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" );
Expand All @@ -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
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
class RimEclipseCase;
class RigEclipseCaseData;
class RigResultAccessor;
class RigMainGrid;

//==================================================================================================
///
Expand All @@ -45,6 +46,7 @@ class RimFaultReactivationDataAccess
private:
RimEclipseCase* m_case;
RigEclipseCaseData* m_caseData;
const RigMainGrid* m_mainGrid;
size_t m_timeStepIndex;
cvf::ref<RigResultAccessor> m_resultAccessor;
};
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,29 @@ caf::PdmFieldHandle* RimFaultReactivationModel::userDescriptionField()
return &m_userDescription;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::pair<bool, std::string> 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, "" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly
QString userDescription();
void setUserDescription( QString description );

std::pair<bool, std::string> validateBeforeRun();

void setFault( RimFaultInView* fault );
RimFaultInView* fault() const;

Expand Down

0 comments on commit a143da3

Please sign in to comment.