mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-25 22:50:25 -05:00
Support removing user specified keywords from output sector model.
This commit is contained in:
1 parent
1101d74b69
commit
3821434022
8 files changed
+124
-17
No files matched your search
@@ -100,6 +100,13 @@ void RicExportSectorModelFeature::doExport( RicExportSectorModelUi* exportSettin
|
||||
settings.setMax( exportSettings->max() );
|
||||
settings.setRefinement( exportSettings->refinement() );
|
||||
|
||||
std::vector<std::string> keywordsToRemove;
|
||||
for ( auto& s : exportSettings->keywordsToRemove() )
|
||||
{
|
||||
keywordsToRemove.push_back( s.toStdString() );
|
||||
}
|
||||
settings.setKeywordsToRemove( keywordsToRemove );
|
||||
|
||||
std::vector<Opm::DeckRecord> bcpropKeywords;
|
||||
for ( auto bcprop : exportSettings->bcpropKeywords() )
|
||||
{
|
||||
|
||||
@@ -31,10 +31,12 @@
|
||||
#include "RimTools.h"
|
||||
#include "Tools/RimEclipseViewTools.h"
|
||||
|
||||
#include "cafPdmUiButton.h"
|
||||
#include "cafPdmUiCheckBoxEditor.h"
|
||||
#include "cafPdmUiFilePathEditor.h"
|
||||
#include "cafPdmUiGroup.h"
|
||||
#include "cafPdmUiLineEditor.h"
|
||||
#include "cafPdmUiListEditor.h"
|
||||
#include "cafPdmUiRadioButtonEditor.h"
|
||||
#include "cafPdmUiTableViewEditor.h"
|
||||
|
||||
@@ -96,6 +98,10 @@ RicExportSectorModelUi::RicExportSectorModelUi()
|
||||
m_bcpropKeywords.uiCapability()->setUiEditorTypeName( caf::PdmUiTableViewEditor::uiEditorTypeName() );
|
||||
m_bcpropKeywords.uiCapability()->setUiLabelPosition( caf::PdmUiItemInfo::LabelPosition::HIDDEN );
|
||||
|
||||
CAF_PDM_InitFieldNoDefault( &m_keywordsToRemove, "KeywordsToRemove", "Keywords to Remove from Output" );
|
||||
m_keywordsToRemove.uiCapability()->setUiEditorTypeName( caf::PdmUiListEditor::uiEditorTypeName() );
|
||||
setDefaultKeywordsToRemove();
|
||||
|
||||
CAF_PDM_InitField( &m_createSimulationJob, "CreateSimulationJob", false, "Create New Simulation Job" );
|
||||
caf::PdmUiNativeCheckBoxEditor::configureFieldForEditor( &m_createSimulationJob );
|
||||
CAF_PDM_InitFieldNoDefault( &m_simulationJobFolder, "SimulationJobFolder", "Working Folder" );
|
||||
@@ -127,6 +133,9 @@ RicExportSectorModelUi::RicExportSectorModelUi()
|
||||
m_pageNames << "Boundary Conditions";
|
||||
m_pageSubtitles << "Set up the boundary conditions of the new sector model.";
|
||||
|
||||
m_pageNames << "Keyword Adjustments";
|
||||
m_pageSubtitles << "Set up special handling of certain keywords.";
|
||||
|
||||
m_pageNames << "Simulation Job Settings";
|
||||
m_pageSubtitles << "Optionally create and/or run a simulation job using the exported sector model.";
|
||||
}
|
||||
@@ -217,6 +226,17 @@ void RicExportSectorModelUi::defineUiOrdering( QString uiConfigName, caf::PdmUiO
|
||||
uiOrdering.add( &m_bcpropKeywords );
|
||||
}
|
||||
}
|
||||
else if ( uiConfigName == m_pageNames[WizardPageEnum::KeywordAdjustments] )
|
||||
{
|
||||
uiOrdering.add( &m_keywordsToRemove );
|
||||
auto button = uiOrdering.addNewButton( "Reset to Default",
|
||||
[this]()
|
||||
{
|
||||
setDefaultKeywordsToRemove();
|
||||
updateConnectedEditors();
|
||||
} );
|
||||
button->setAlignment( Qt::AlignRight );
|
||||
}
|
||||
else if ( uiConfigName == m_pageNames[WizardPageEnum::SimulationJob] )
|
||||
{
|
||||
auto simGrp = uiOrdering.addNewGroup( "OPM Flow Simulation" );
|
||||
@@ -315,6 +335,22 @@ void RicExportSectorModelUi::defineEditorAttribute( const caf::PdmFieldHandle* f
|
||||
myAttr->m_selectDirectory = true;
|
||||
}
|
||||
}
|
||||
else if ( field == &m_keywordsToRemove )
|
||||
{
|
||||
auto attrib = dynamic_cast<caf::PdmUiListEditorAttribute*>( attribute );
|
||||
if ( attrib )
|
||||
{
|
||||
attrib->heightHint = 200;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RicExportSectorModelUi::setDefaultKeywordsToRemove()
|
||||
{
|
||||
m_keywordsToRemove.setValue( { "ACTION", "ACTIONX", "UDQ" } );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -365,6 +401,14 @@ cvf::Vec3st RicExportSectorModelUi::refinement() const
|
||||
return cvf::Vec3st( m_refinementCountI(), m_refinementCountJ(), m_refinementCountK() );
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
std::vector<QString> RicExportSectorModelUi::keywordsToRemove() const
|
||||
{
|
||||
return m_keywordsToRemove.value();
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
@@ -644,6 +688,16 @@ std::map<QString, QString> RicExportSectorModelUi::validate( const QString& conf
|
||||
{
|
||||
// no validation needed
|
||||
}
|
||||
else if ( configName == m_pageNames[WizardPageEnum::KeywordAdjustments] )
|
||||
{
|
||||
for ( auto& kw : m_keywordsToRemove() )
|
||||
{
|
||||
if ( kw.contains( ' ' ) )
|
||||
{
|
||||
fieldErrors[m_keywordsToRemove.keyword()] = "Keywords to remove cannot contain spaces: " + kw;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ( configName == m_pageNames[WizardPageEnum::SimulationJob] )
|
||||
{
|
||||
if ( m_createSimulationJob() )
|
||||
|
||||
@@ -62,6 +62,8 @@ public:
|
||||
|
||||
cvf::Vec3st refinement() const;
|
||||
|
||||
std::vector<QString> keywordsToRemove() const;
|
||||
|
||||
std::vector<RimKeywordBcprop*> bcpropKeywords() const;
|
||||
RiaModelExportDefines::BoundaryCondition boundaryCondition() const;
|
||||
double porvMultiplier() const;
|
||||
@@ -81,6 +83,8 @@ protected:
|
||||
void fieldChangedByUi( const caf::PdmFieldHandle* changedField, const QVariant& oldValue, const QVariant& newValue ) override;
|
||||
std::map<QString, QString> validate( const QString& configName ) const override;
|
||||
|
||||
void setDefaultKeywordsToRemove();
|
||||
|
||||
private:
|
||||
enum WizardPageEnum : unsigned int
|
||||
{
|
||||
@@ -88,26 +92,20 @@ private:
|
||||
GridBoxSelection = 1,
|
||||
GridRefinement = 2,
|
||||
BoundaryConditions = 3,
|
||||
SimulationJob = 4,
|
||||
TotalPages = 5
|
||||
KeywordAdjustments = 4,
|
||||
SimulationJob = 5,
|
||||
TotalPages = 6
|
||||
};
|
||||
|
||||
void applyBoundaryDefaults();
|
||||
static QString defaultFolder();
|
||||
|
||||
private:
|
||||
caf::PdmField<caf::FilePath> m_exportFolder;
|
||||
caf::PdmField<QString> m_exportDeckName;
|
||||
caf::PdmField<double> m_porvMultiplier;
|
||||
caf::PdmField<int> m_visibleWellsPadding;
|
||||
caf::PdmField<BoundaryConditionEnum> m_boundaryCondition;
|
||||
caf::PdmField<GridBoxSelectionEnum> m_gridBoxSelection;
|
||||
caf::PdmChildArrayField<RimKeywordBcprop*> m_bcpropKeywords;
|
||||
caf::PdmField<caf::FilePath> m_exportFolder;
|
||||
caf::PdmField<QString> m_exportDeckName;
|
||||
|
||||
caf::PdmField<bool> m_refineGrid;
|
||||
caf::PdmField<int> m_refinementCountI;
|
||||
caf::PdmField<int> m_refinementCountJ;
|
||||
caf::PdmField<int> m_refinementCountK;
|
||||
caf::PdmField<int> m_visibleWellsPadding;
|
||||
caf::PdmField<GridBoxSelectionEnum> m_gridBoxSelection;
|
||||
|
||||
caf::PdmField<int> m_minI;
|
||||
caf::PdmField<int> m_maxI;
|
||||
@@ -116,6 +114,17 @@ private:
|
||||
caf::PdmField<int> m_minK;
|
||||
caf::PdmField<int> m_maxK;
|
||||
|
||||
caf::PdmField<bool> m_refineGrid;
|
||||
caf::PdmField<int> m_refinementCountI;
|
||||
caf::PdmField<int> m_refinementCountJ;
|
||||
caf::PdmField<int> m_refinementCountK;
|
||||
|
||||
caf::PdmField<BoundaryConditionEnum> m_boundaryCondition;
|
||||
caf::PdmChildArrayField<RimKeywordBcprop*> m_bcpropKeywords;
|
||||
caf::PdmField<double> m_porvMultiplier;
|
||||
|
||||
caf::PdmField<std::vector<QString>> m_keywordsToRemove;
|
||||
|
||||
caf::PdmField<bool> m_createSimulationJob;
|
||||
caf::PdmField<caf::FilePath> m_simulationJobFolder;
|
||||
caf::PdmField<QString> m_simulationJobName;
|
||||
|
||||
@@ -932,11 +932,13 @@ bool RifOpmFlowDeckFile::replaceKeywordAtIndex( const Opm::FileDeck::Index& inde
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
/// Returns number of removed keywords
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RifOpmFlowDeckFile::removeKeywords( const std::string& keywordName )
|
||||
int RifOpmFlowDeckFile::removeKeywords( const std::string& keywordName )
|
||||
{
|
||||
if ( m_fileDeck.get() == nullptr ) return;
|
||||
int nRemoved = 0;
|
||||
|
||||
if ( m_fileDeck.get() == nullptr ) return nRemoved;
|
||||
|
||||
// Find all the matching keywords
|
||||
std::vector<Opm::FileDeck::Index> skipIndices;
|
||||
@@ -953,7 +955,10 @@ void RifOpmFlowDeckFile::removeKeywords( const std::string& keywordName )
|
||||
for ( auto it = skipIndices.rbegin(); it != skipIndices.rend(); ++it )
|
||||
{
|
||||
m_fileDeck->erase( *it );
|
||||
nRemoved++;
|
||||
}
|
||||
|
||||
return nRemoved;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -97,7 +97,7 @@ public:
|
||||
bool replaceAllKeywords( const std::string& keywordName, const std::vector<Opm::DeckKeyword>& keywords );
|
||||
bool replaceKeywordAtIndex( const Opm::FileDeck::Index& index, const Opm::DeckKeyword& keyword );
|
||||
|
||||
void removeKeywords( const std::string& keywordName );
|
||||
int removeKeywords( const std::string& keywordName );
|
||||
|
||||
private:
|
||||
void splitDatesIfNecessary();
|
||||
|
||||
@@ -80,6 +80,22 @@ void RigSimulationInputSettings::setRefinement( const cvf::Vec3st& refinement )
|
||||
m_refinement = refinement;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
void RigSimulationInputSettings::setKeywordsToRemove( const std::vector<std::string>& keywords )
|
||||
{
|
||||
m_keywordsToRemove = keywords;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
const std::vector<std::string>& RigSimulationInputSettings::keywordsToRemove() const
|
||||
{
|
||||
return m_keywordsToRemove;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -25,6 +25,7 @@
|
||||
#include "cvfVector3.h"
|
||||
|
||||
#include <QString>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
namespace Opm
|
||||
@@ -54,6 +55,10 @@ public:
|
||||
cvf::Vec3st refinement() const;
|
||||
void setRefinement( const cvf::Vec3st& refinement );
|
||||
|
||||
// Keyword handling
|
||||
const std::vector<std::string>& keywordsToRemove() const;
|
||||
void setKeywordsToRemove( const std::vector<std::string>& keywords );
|
||||
|
||||
// Boundary conditions
|
||||
std::vector<Opm::DeckRecord> bcpropKeywords() const;
|
||||
void setBcpropKeywords( const std::vector<Opm::DeckRecord>& keywords );
|
||||
@@ -75,6 +80,7 @@ private:
|
||||
caf::VecIjk0 m_min;
|
||||
caf::VecIjk0 m_max;
|
||||
cvf::Vec3st m_refinement;
|
||||
std::vector<std::string> m_keywordsToRemove;
|
||||
std::vector<Opm::DeckRecord> m_bcpropKeywords;
|
||||
BoundaryConditionEnum m_boundaryCondition;
|
||||
double m_porvMultiplier;
|
||||
|
||||
@@ -75,6 +75,16 @@ std::expected<void, QString> RigSimulationInputTool::exportSimulationInput( RimE
|
||||
QString outputFolder = exportGridInfo.absolutePath();
|
||||
QString outputFile = exportGridInfo.completeBaseName() + ".DATA";
|
||||
|
||||
int noOfRemovedKeywords = 0;
|
||||
for ( auto& kwToRemove : settings.keywordsToRemove() )
|
||||
{
|
||||
noOfRemovedKeywords += deckFile.removeKeywords( kwToRemove );
|
||||
}
|
||||
if ( noOfRemovedKeywords > 0 )
|
||||
{
|
||||
RiaLogging::info( QString( "Removed %1 user specified keywords from deck file." ).arg( noOfRemovedKeywords ) );
|
||||
}
|
||||
|
||||
if ( auto result = updateCornerPointGridInDeckFile( &eclipseCase, settings, deckFile ); !result )
|
||||
{
|
||||
return result;
|
||||
|
||||
Reference in new issue
Block a user