25 #include <unordered_set>
28 #include <fmt/format.h>
30 #include <opm/parser/eclipse/Deck/DeckKeyword.hpp>
31 #include <opm/parser/eclipse/Deck/FileDeck.hpp>
32 #include <opm/common/utility/FileSystem.hpp>
34 namespace fs = Opm::filesystem;
41 static const std::unordered_set<std::string> rst_keep_in_solution;
44 enum class OutputMode {
53 std::size_t file_index;
54 std::size_t keyword_index;
56 Index(std::size_t file_index_arg, std::size_t keyword_index_arg,
const FileDeck* deck_arg)
57 : file_index(file_index_arg)
58 , keyword_index(keyword_index_arg)
63 Index operator--(
int);
65 Index operator++(
int);
66 bool operator==(
const Index& other)
const;
67 bool operator!=(
const Index& other)
const;
68 bool operator<(
const Index& other)
const;
79 explicit Block(
const std::string& filename);
80 std::size_t size()
const;
81 void load(
const Deck& deck, std::size_t deck_index);
82 std::optional<std::size_t> find(
const std::string& keyword)
const;
85 void insert(std::size_t keyword_index,
const DeckKeyword& keyword);
90 std::vector<DeckKeyword> keywords;
97 std::optional<Index> find(
const std::string& keyword)
const;
98 void erase(
const Index& index);
99 void erase(
const Index& begin,
const Index& end);
102 void dump_stdout(
const std::string& output_dir, OutputMode mode)
const;
103 void dump(
const std::string& dir,
const std::string& fname, OutputMode mode)
const;
105 const Index start()
const;
106 const Index stop()
const;
108 void rst_solution(
const std::string& rst_base,
int report_step);
109 void insert_skiprest();
112 std::vector<Block> blocks;
113 std::string input_directory;
114 std::unordered_set<std::string> modified_files;
118 std::unordered_map<std::string, std::ofstream> stream_map;
119 std::unordered_map<std::string, std::string> file_map;
121 bool has_file(
const std::string& fname)
const {
122 return this->file_map.count(fname) > 0;
125 std::optional<std::ofstream *> get_stream(
const std::string& deck_name) {
126 auto name_iter = this->file_map.find(deck_name);
127 if (name_iter == this->file_map.end())
130 return &this->stream_map.at(name_iter->second);
134 std::ofstream& open_file(
const std::string& deck_name,
const fs::path& output_file)
136 if (this->stream_map.count(output_file.string()) == 0) {
137 this->file_map.insert(std::make_pair( deck_name, output_file.string() ));
139 if (!fs::is_directory(output_file.parent_path()))
140 fs::create_directories(output_file.parent_path());
142 std::ofstream stream{output_file};
144 throw std::logic_error(fmt::format(
"Opening {} for writing failed", output_file.string()));
145 this->stream_map.insert(std::make_pair(output_file.string(), std::move(stream)));
147 return this->stream_map.at(output_file.string());
152 void dump(std::ostream& os)
const;
153 void dump_shared(std::ostream& stream,
const std::string& output_dir)
const;
154 void dump_inline()
const;
155 std::string dump_block(
const Block& block,
const std::string& dir,
const std::optional<std::string>& fname, DumpContext& context)
const;
156 void include_block(
const std::string& source_file,
const std::string& target_file,
const std::string& dir, DumpContext& context)
const;
Definition: DeckKeyword.hpp:36
Definition: DeckOutput.hpp:29
Definition: DeckTree.hpp:38
Definition: FileDeck.hpp:77
Definition: FileDeck.hpp:39
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: FileDeck.hpp:52