mirror of
https://github.com/OPM/ResInsight.git
synced 2026-10-29 08:30:17 -05:00
Deck File: Add api for including files.
This commit is contained in:
1 parent
7de242ffb0
commit
33b2d14a6b
3 files changed
+160
No files matched your search
@@ -708,6 +708,50 @@ bool RifOpmFlowDeckFile::ensureRegdimsKeyword()
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
bool RifOpmFlowDeckFile::addIncludeKeyword( std::string section, std::string keyword, std::string filePath )
|
||||
{
|
||||
if ( m_fileDeck.get() == nullptr ) return false;
|
||||
|
||||
// Find the specified section
|
||||
auto sectionPos = m_fileDeck->find( section );
|
||||
if ( !sectionPos.has_value() )
|
||||
{
|
||||
return false; // Section not found
|
||||
}
|
||||
|
||||
auto insertPos = sectionPos.value();
|
||||
insertPos++; // Start after the section keyword
|
||||
|
||||
// Find a good insertion point within the section
|
||||
// Look for the end of the section or insert at the end of existing content
|
||||
for ( auto it = insertPos; it != m_fileDeck->stop(); it++ )
|
||||
{
|
||||
auto& kw = m_fileDeck->operator[]( it );
|
||||
|
||||
// Stop if we hit another major section
|
||||
if ( kw.name() == "RUNSPEC" || kw.name() == "GRID" || kw.name() == "EDIT" || kw.name() == "PROPS" || kw.name() == "REGIONS" ||
|
||||
kw.name() == "SOLUTION" || kw.name() == "SUMMARY" || kw.name() == "SCHEDULE" )
|
||||
{
|
||||
insertPos = it;
|
||||
break;
|
||||
}
|
||||
|
||||
// Keep moving forward in the current section
|
||||
insertPos = it;
|
||||
insertPos++;
|
||||
}
|
||||
|
||||
// Create the INCLUDE keyword
|
||||
Opm::DeckKeyword includeKw( Opm::ParserKeyword( "INCLUDE" ) );
|
||||
includeKw.addRecord( Opm::DeckRecord{ { item( "FILENAME", filePath ) } } );
|
||||
|
||||
m_fileDeck->insert( insertPos, includeKw );
|
||||
return true;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
///
|
||||
//--------------------------------------------------------------------------------------------------
|
||||
|
||||
@@ -67,6 +67,8 @@ public:
|
||||
bool setRegdims( int maxRegions, int maxRegionDefinitions, int maxRegionFlowConnections, int maxFIPRegions );
|
||||
bool ensureRegdimsKeyword();
|
||||
|
||||
bool addIncludeKeyword( std::string section, std::string keyword, std::string filePath );
|
||||
|
||||
private:
|
||||
Opm::DeckItem item( std::string name, std::string value );
|
||||
Opm::DeckItem item( std::string name, int value );
|
||||
|
||||
Reference in new issue
Block a user