///////////////////////////////////////////////////////////////////////////////// // // Copyright (C) 2025 Equinor ASA // // ResInsight is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // ResInsight is distributed in the hope that it will be useful, but WITHOUT ANY // WARRANTY; without even the implied warranty of MERCHANTABILITY or // FITNESS FOR A PARTICULAR PURPOSE. // // See the GNU General Public License at // for more details. // ///////////////////////////////////////////////////////////////////////////////// #pragma once #include #include #include #include #include #include #include #include "opm/input/eclipse/Deck/FileDeck.hpp" namespace Opm { class Deck; class DeckKeyword; class DeckItem; class DeckRecord; class ParseContext; } // namespace Opm //================================================================================================== /// /// //================================================================================================== class RifOpmFlowDeckFile { public: RifOpmFlowDeckFile(); ~RifOpmFlowDeckFile(); std::expected loadDeck( std::string filename ); bool saveDeck( std::string folder, std::string filename ); bool saveDeckInline( std::string folder, std::string filename ); int addKeywordAtPosition( int deckPosition, const Opm::DeckKeyword& keyword ); bool addKeywordAtTimeStep( int timeStep, const Opm::DeckKeyword& keyword, std::string insertAfterKeyword = "" ); int mergeKeywordAtPosition( int deckPosition, const Opm::DeckKeyword& keyword ); bool mergeKeywordAtTimeStep( int timeStep, const Opm::DeckKeyword& keyword, std::string insertAfterKeyword = "" ); bool openWellAtTimeStep( int timeStep, Opm::DeckKeyword& openKeyword ); bool openWellAtDeckPosition( int deckPosition, Opm::DeckKeyword& openKeyword ); bool restartAtTimeStep( int timeStep, std::string deckName ); bool stopAtTimeStep( int timeStep ); std::vector keywords( bool includeDates = true ); std::optional findKeyword( const std::string& keyword ); std::vector findAllKeywords( const std::string& keyword ); std::vector> findAllKeywordsWithIndices( const std::string& keyword ); bool hasDatesKeyword(); bool isRestartFile(); std::vector dateStrings(); std::vector dates(); bool appendDateKeywords( const std::vector& dates ); std::set wellGroupsInFile(); std::vector welldims(); bool setWelldims( int maxWells, int maxConnections, int maxGroups, int maxWellsInGroup ); std::vector wsegdims(); bool setWsegdims( int maxMSWells, int maxSegmentsPerWell, int maxBranchesPerWell ); bool setSpecgrid( int nx, int ny, int nz ); bool setDimens( int nx, int ny, int nz ); std::vector regdims(); bool setRegdims( int maxRegions, int maxRegionDefinitions, int maxRegionFlowConnections, int maxFIPRegions, int maxEtrack, int maxCompRegions, int maxOperNum ); bool ensureRegdimsKeyword(); bool addIncludeKeyword( std::string section, std::string keyword, std::string filePath ); Opm::FileDeck* fileDeck(); const Opm::Deck* deck() const; bool addKeyword( const std::string& section, const Opm::DeckKeyword& keyword ); bool replaceKeyword( const std::string& section, const Opm::DeckKeyword& keyword ); bool insertKeywordAtSectionStart( const std::string& section, const Opm::DeckKeyword& keyword ); bool replaceKeyword( const std::string& keyword, const std::vector& data, bool dataKeyword = false ); bool replaceKeyword( const std::string& keyword, const std::vector& data, bool dataKeyword = false ); bool replaceAllKeywords( const std::string& keywordName, const std::vector& keywords ); bool replaceKeywordAtIndex( const Opm::FileDeck::Index& index, const Opm::DeckKeyword& keyword ); int removeKeywords( const std::string& keywordName ); bool removeKeywordAtIndex( const Opm::FileDeck::Index& index ); private: void splitDatesIfNecessary(); private: std::unique_ptr m_deck; std::unique_ptr m_fileDeck; };