Skip to content

Commit c702d0f

Browse files
committed
Clean up
1 parent 280c0c9 commit c702d0f

File tree

1 file changed

+17
-13
lines changed

1 file changed

+17
-13
lines changed

ApplicationLibCode/FileInterface/RifOpmFlowDeckFile.cpp

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "opm/input/eclipse/Parser/InputErrorAction.hpp"
2828
#include "opm/input/eclipse/Parser/ParseContext.hpp"
2929
#include "opm/input/eclipse/Parser/Parser.hpp"
30+
#include "opm/input/eclipse/Parser/ParserKeywords/A.hpp"
31+
#include "opm/input/eclipse/Parser/ParserKeywords/B.hpp"
3032
#include "opm/input/eclipse/Parser/ParserKeywords/C.hpp"
3133
#include "opm/input/eclipse/Parser/ParserKeywords/D.hpp"
3234
#include "opm/input/eclipse/Parser/ParserKeywords/E.hpp"
@@ -220,6 +222,11 @@ static std::optional<Opm::FileDeck::Index> findSectionInsertionPoint( std::uniqu
220222
return insertIdx;
221223
}
222224

225+
static std::map<std::string, std::string> blockKeywordNames =
226+
{ { Opm::ParserKeywords::ACTIONX::keywordName, Opm::ParserKeywords::ENDACTIO::keywordName },
227+
{ Opm::ParserKeywords::BOX::keywordName, Opm::ParserKeywords::ENDBOX::keywordName },
228+
{ Opm::ParserKeywords::ACTIONW::keywordName, Opm::ParserKeywords::ENDACTIO::keywordName } };
229+
223230
} // namespace internal
224231

225232
//--------------------------------------------------------------------------------------------------
@@ -936,9 +943,6 @@ bool RifOpmFlowDeckFile::replaceKeywordAtIndex( const Opm::FileDeck::Index& inde
936943
//--------------------------------------------------------------------------------------------------
937944
int RifOpmFlowDeckFile::removeKeywords( const std::string& keywordName )
938945
{
939-
// special handling of keywords with a potential inner block
940-
const std::map<std::string, std::string> blockKeywords = { { "ACTIONX", "ENDACTIO" }, { "BOX", "ENDBOX" }, { "ACTIONW", "ENDACTIO" } };
941-
942946
int nRemoved = 0;
943947
if ( m_fileDeck.get() == nullptr ) return nRemoved;
944948

@@ -950,21 +954,21 @@ int RifOpmFlowDeckFile::removeKeywords( const std::string& keywordName )
950954
if ( kw.name() == keywordName )
951955
{
952956
skipIndices.push_back( it );
953-
}
954-
if ( blockKeywords.contains( kw.name() ) )
955-
{
956957
// If this is a block keyword, we need to skip all keywords until the corresponding end block
957-
const std::string endBlockName = blockKeywords.at( kw.name() );
958-
while ( it != m_fileDeck->stop() )
958+
if ( internal::blockKeywordNames.contains( keywordName ) )
959959
{
960-
const auto& innerKw = m_fileDeck->operator[]( it );
961-
if ( innerKw.name() == endBlockName )
960+
const std::string endBlockName = internal::blockKeywordNames.at( keywordName );
961+
while ( it != m_fileDeck->stop() )
962962
{
963+
const auto& innerKw = m_fileDeck->operator[]( it );
964+
if ( innerKw.name() == endBlockName )
965+
{
966+
skipIndices.push_back( it );
967+
break;
968+
}
963969
skipIndices.push_back( it );
964-
break;
970+
it++;
965971
}
966-
skipIndices.push_back( it );
967-
it++;
968972
}
969973
}
970974
}

0 commit comments

Comments
 (0)