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 13, 2023
1 parent 3148892 commit 83fbf3a
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ void RicNewFaultReactModelingFeature::onActionTriggered( bool isChecked )
auto model = eclView->faultReactivationModelCollection()->addNewModel( rimFault, target1, target2, baseDir );
if ( model != nullptr )
{
model->updateTimeSteps();
view->updateAllRequiredEditors();
Riu3DMainWindowTools::selectAsCurrentItem( model );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,14 @@

CAF_CMD_SOURCE_INIT( RicRunFaultReactModelingFeature, "RicRunFaultReactModelingFeature" );

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
bool RicRunFaultReactModelingFeature::isCommandEnabled() const
{
return RiaPreferencesGeoMech::current()->validateFRMSettings();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -97,7 +105,7 @@ void RicRunFaultReactModelingFeature::onActionTriggered( bool isChecked )
runProgress.incrementProgress();
runProgress.setProgressDescription( "Running Abaqus modeling." );

QString command = RiaPreferencesGeoMech::current()->geomechWIACommand();
QString command = RiaPreferencesGeoMech::current()->geomechFRMCommand();
QStringList parameters = model->commandParameters();

RimProcess process;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class RicRunFaultReactModelingFeature : public caf::CmdFeature
CAF_CMD_HEADER_INIT;

protected:
bool isCommandEnabled() const override;
void onActionTriggered( bool isChecked ) override;
void setupActionLook( QAction* actionToSetup ) override;
};
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#include "cvfTextureImage.h"

#include <QDateTime>
#include <QDir>

CAF_PDM_SOURCE_INIT( RimFaultReactivationModel, "FaultReactivationModel" );

Expand Down Expand Up @@ -94,10 +95,10 @@ RimFaultReactivationModel::RimFaultReactivationModel()
CAF_PDM_InitField( &m_numberOfCellsVertMid, "NumberOfCellsVertMid", 20, "Vertical Number of Cells, Middle Part" );
CAF_PDM_InitField( &m_numberOfCellsVertLow, "NumberOfCellsVertLow", 20, "Vertical Number of Cells, Lower Part" );

CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Time Step Filter" );
m_timeStepFilter.uiCapability()->setUiTreeHidden( true );
m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden( true );
m_timeStepFilter = new RimTimeStepFilter();
// CAF_PDM_InitFieldNoDefault( &m_timeStepFilter, "TimeStepFilter", "Time Step Filter" );
// m_timeStepFilter.uiCapability()->setUiTreeHidden( true );
// m_timeStepFilter.uiCapability()->setUiTreeChildrenHidden( true );
// m_timeStepFilter = new RimTimeStepFilter();

CAF_PDM_InitFieldNoDefault( &m_targets, "Targets", "Targets" );
m_targets.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
Expand Down Expand Up @@ -126,7 +127,6 @@ RimFaultReactivationModel::~RimFaultReactivationModel()
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::initAfterRead()
{
updateTimeSteps();
updateVisualization();
}

Expand Down Expand Up @@ -234,8 +234,6 @@ caf::PickEventHandler* RimFaultReactivationModel::pickEventHandler() const
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::updateVisualization()
{
// if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();

auto view = firstAncestorOrThisOfType<Rim3dView>();
if ( !view ) return;

Expand Down Expand Up @@ -302,8 +300,6 @@ cvf::ref<RigPolyLinesData> RimFaultReactivationModel::polyLinesData() const
//--------------------------------------------------------------------------------------------------
QList<caf::PdmOptionItemInfo> RimFaultReactivationModel::calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions )
{
if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();

QList<caf::PdmOptionItemInfo> options;

if ( fieldNeedingOptions == &m_fault )
Expand Down Expand Up @@ -365,7 +361,7 @@ bool RimFaultReactivationModel::showModel() const
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::PdmUiOrdering& uiOrdering )
{
if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();
// if ( m_timeStepFilter->filteredTimeSteps().size() == 0 ) updateTimeSteps();

auto genGrp = uiOrdering.addNewGroup( "General" );
genGrp->add( &m_userDescription );
Expand Down Expand Up @@ -397,8 +393,8 @@ void RimFaultReactivationModel::defineUiOrdering( QString uiConfigName, caf::Pdm
gridModelGrp->add( &m_numberOfCellsVertMid );
gridModelGrp->add( &m_numberOfCellsVertLow );

caf::PdmUiGroup* timeStepFilterGroup = uiOrdering.addNewGroup( "Time Steps" );
m_timeStepFilter->uiOrdering( uiConfigName, *timeStepFilterGroup );
// caf::PdmUiGroup* timeStepFilterGroup = uiOrdering.addNewGroup( "Time Steps" );
// m_timeStepFilter->uiOrdering( uiConfigName, *timeStepFilterGroup );

auto appModelGrp = modelGrp->addNewGroup( "Appearance" );
appModelGrp->add( &m_modelPart1Color );
Expand Down Expand Up @@ -468,6 +464,12 @@ void RimFaultReactivationModel::defineEditorAttribute( const caf::PdmFieldHandle
RimEclipseCase* RimFaultReactivationModel::eclipseCase()
{
auto eCase = firstAncestorOrThisOfType<RimEclipseCase>();

if ( eCase == nullptr )
{
eCase = dynamic_cast<RimEclipseCase*>( RiaApplication::instance()->activeGridView()->ownerCase() );
}

return eCase;
}

Expand Down Expand Up @@ -507,22 +509,24 @@ void RimFaultReactivationModel::updateTimeSteps()
timeSteps.push_back( std::make_pair( timeStepStrings[i], timeStepDates[i] ) );
}

m_timeStepFilter->setTimeStepsFromFile( timeSteps );
// auto selection = m_timeStepFilter->filteredTimeSteps();
// m_timeStepFilter->setTimeStepsFromFile( timeSteps );
// m_timeStepFilter->filteredTimeSteps() = selection;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
std::vector<QDateTime> RimFaultReactivationModel::selectedTimeSteps() const
{
auto steps = m_timeStepFilter->filteredTimeSteps();
// auto steps = m_timeStepFilter->filteredTimeSteps();

std::vector<QDateTime> selectedSteps;

for ( const auto& step : m_timeStepFilter->allTimeSteps() )
{
selectedSteps.push_back( step.second );
}
// for ( const auto& step : m_timeStepFilter->allTimeSteps() )
//{
// selectedSteps.push_back( step.second );
// }

return selectedSteps;
}
Expand All @@ -532,21 +536,46 @@ std::vector<QDateTime> RimFaultReactivationModel::selectedTimeSteps() const
//--------------------------------------------------------------------------------------------------
QStringList RimFaultReactivationModel::commandParameters() const
{
return QStringList();
QStringList retlist;

retlist << baseDir();
retlist << inputFilename();
retlist << outputOdbFilename();

return retlist;
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::outputOdbFilename() const
{
return baseDir() + "faultreactivation.odb";
QDir directory( baseDir() );
return directory.absoluteFilePath( baseFilename() + ".odb" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::inputFilename() const
{
return baseDir() + "faultreactivation.inp";
QDir directory( baseDir() );
return directory.absoluteFilePath( baseFilename() + ".inp" );
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
QString RimFaultReactivationModel::baseFilename() const
{
QString tmp = m_userDescription();

if ( tmp.isEmpty() ) return "faultReactivation";

tmp.replace( ' ', '_' );
tmp.replace( '/', '_' );
tmp.replace( '\\', '_' );
tmp.replace( ':', '_' );

return tmp;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "RimCheckableNamedObject.h"
#include "RimPolylinePickerInterface.h"
#include "RimPolylinesDataInterface.h"
#include "RimTimeStepFilter.h"

#include "cafFilePath.h"
#include "cafPdmChildArrayField.h"
Expand All @@ -31,6 +32,7 @@
#include "cvfColor3.h"
#include "cvfVector3.h"

#include <QDateTime>
#include <QString>
#include <QStringList>

Expand All @@ -56,6 +58,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly
{
CAF_PDM_HEADER_INIT;

using TimeStepFilterEnum = caf::AppEnum<RimTimeStepFilter::TimeStepFilterTypeEnum>;

public:
RimFaultReactivationModel();
~RimFaultReactivationModel() override;
Expand Down Expand Up @@ -97,6 +101,8 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly
QString outputOdbFilename() const;
QString inputFilename() const;

void updateTimeSteps();

protected:
caf::PdmFieldHandle* userDescriptionField() override;
QList<caf::PdmOptionItemInfo> calculateValueOptions( const caf::PdmFieldHandle* fieldNeedingOptions ) override;
Expand All @@ -109,7 +115,7 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly

void initAfterRead() override;

void updateTimeSteps();
QString baseFilename() const;

private:
std::shared_ptr<RicPolylineTargetsPickEventHandler> m_pickTargetsEventHandler;
Expand Down Expand Up @@ -144,5 +150,6 @@ class RimFaultReactivationModel : public RimCheckableNamedObject, public RimPoly
cvf::ref<RigBasicPlane> m_faultPlane;
cvf::ref<RigFaultReactivationModel> m_modelPlane;

caf::PdmChildField<RimTimeStepFilter*> m_timeStepFilter;
caf::PdmField<TimeStepFilterEnum> m_timeStepFilter;
caf::PdmField<std::vector<QDateTime>> m_selectedTimeSteps;
};
Original file line number Diff line number Diff line change
Expand Up @@ -186,3 +186,14 @@ void RimFaultReactivationModelCollection::appendPartsToModel( Rim3dView*

model->updateBoundingBoxesRecursive();
}

//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
void RimFaultReactivationModelCollection::syncTimeSteps()
{
for ( auto& frm : m_models )
{
frm->updateTimeSteps();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ class RimFaultReactivationModelCollection : public RimCheckableNamedObject
caf::DisplayCoordTransform* transform,
const cvf::BoundingBox& boundingBox );

void syncTimeSteps();

protected:
caf::PdmFieldHandle* userDescriptionField() override;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ caf::CmdFeatureMenuBuilder RimContextCommandBuilder::commandsFromSelection()
}
else if ( dynamic_cast<RimFaultReactivationModel*>( firstUiItem ) )
{
menuBuilder << "RicRunFaultReactModelingFeature";
menuBuilder << "RicExportInpFileFeature";
}
else if ( dynamic_cast<RimPressureTable*>( firstUiItem ) )
Expand Down
2 changes: 2 additions & 0 deletions ApplicationLibCode/ProjectDataModel/RimEclipseView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1115,6 +1115,8 @@ void RimEclipseView::onLoadDataAndUpdate()

m_wellMeasurementCollection->syncWithChangesInWellMeasurementCollection();

m_faultReactivationModelCollection->syncTimeSteps();

scheduleCreateDisplayModelAndRedraw();
}

Expand Down

0 comments on commit 83fbf3a

Please sign in to comment.