My Project
Loading...
Searching...
No Matches
DeckSection.hpp
1/*
2 Copyright 2013 Statoil ASA.
3
4 This file is part of the Open Porous Media project (OPM).
5
6 OPM is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
10
11 OPM is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with OPM. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef SECTION_HPP
21#define SECTION_HPP
22
23#include <string>
24
25#include <opm/input/eclipse/Deck/DeckView.hpp>
26
27namespace Opm {
28
29class Deck;
30class ErrorGuard;
31
32enum class Section {
33 RUNSPEC,
34 GRID,
35 EDIT,
36 PROPS,
37 REGIONS,
38 SOLUTION,
39 SUMMARY,
40 SCHEDULE
41};
42
43 class UnitSystem;
44 class Parser;
45
46
47class DeckSection : public DeckView {
48 public:
49
50 DeckSection( const Deck& deck, const std::string& startKeyword );
51 const std::string& name() const;
52 const UnitSystem& unitSystem() const;
53
54 static bool hasRUNSPEC( const Deck& );
55 static bool hasGRID( const Deck& );
56 static bool hasEDIT( const Deck& );
57 static bool hasPROPS( const Deck& );
58 static bool hasREGIONS( const Deck& );
59 static bool hasSOLUTION( const Deck& );
60 static bool hasSUMMARY( const Deck& );
61 static bool hasSCHEDULE( const Deck& );
62
63 // returns whether the deck has all mandatory sections and if all sections are in
64 // the right order
65 static bool checkSectionTopology(const Deck& deck,
66 const Parser&,
67 ErrorGuard& errorGuard,
68 bool ensureKeywordSectionAffiliation = false);
69
70
71 // ---------------------------------------------------------------------------------
72 // Highly deprecated shims
73 const DeckKeyword& getKeyword(const std::string& keyword, std::size_t index) const {
74 auto view = this->operator[](keyword);
75 return view[index];
76 }
77
78 const DeckKeyword& getKeyword(const std::string& keyword) const {
79 auto view = this->operator[](keyword);
80 return view.back();
81 }
82
83
84 std::vector<const DeckKeyword*> getKeywordList(const std::string& keyword) const {
85 std::vector<const DeckKeyword*> kw_list;
86 auto view = this->operator[](keyword);
87 for (const auto& kw : view)
88 kw_list.push_back(&kw);
89 return kw_list;
90 }
91
92 template <class Keyword>
93 std::vector<const DeckKeyword*> getKeywordList() const {
94 return this->getKeywordList(Keyword::keywordName);
95 }
96
97
98 bool hasKeyword(const std::string& keyword) const {
99 return this->has_keyword(keyword);
100 }
101
102 template <class Keyword>
103 bool hasKeyword() const {
104 return this->has_keyword(Keyword::keywordName);
105 }
106
107 // ---------------------------------------------------------------------------------
108
109
110 private:
111 std::string section_name;
112 const UnitSystem& units;
113
114 };
115
117 public:
118 explicit RUNSPECSection(const Deck& deck) : DeckSection(deck, "RUNSPEC") {}
119 };
120
121 class GRIDSection : public DeckSection {
122 public:
123 explicit GRIDSection(const Deck& deck) : DeckSection(deck, "GRID") {}
124 };
125
126 class EDITSection : public DeckSection {
127 public:
128 explicit EDITSection(const Deck& deck) : DeckSection(deck, "EDIT") {}
129 };
130
131 class PROPSSection : public DeckSection {
132 public:
133 explicit PROPSSection(const Deck& deck) : DeckSection(deck, "PROPS") {}
134 };
135
137 public:
138 explicit REGIONSSection(const Deck& deck) : DeckSection(deck, "REGIONS") {}
139 };
140
142 public:
143 explicit SOLUTIONSection(const Deck& deck) : DeckSection(deck, "SOLUTION") {}
144 };
145
147 public:
148 explicit SUMMARYSection(const Deck& deck) : DeckSection(deck, "SUMMARY") {}
149 };
150
152 public:
153 explicit SCHEDULESection(const Deck& deck) : DeckSection(deck, "SCHEDULE") {}
154 };
155}
156
157#endif // SECTION_HPP
Definition DeckKeyword.hpp:36
Definition DeckSection.hpp:47
Definition DeckView.hpp:31
Definition Deck.hpp:49
Definition DeckSection.hpp:126
Definition ErrorGuard.hpp:29
Definition DeckSection.hpp:121
Definition DeckSection.hpp:131
The hub of the parsing process.
Definition Parser.hpp:60
Definition DeckSection.hpp:136
Definition DeckSection.hpp:116
Definition DeckSection.hpp:151
Definition DeckSection.hpp:141
Definition DeckSection.hpp:146
Definition UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30