My Project
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;
30
31enum class Section {
32 RUNSPEC,
33 GRID,
34 EDIT,
35 PROPS,
36 REGIONS,
37 SOLUTION,
38 SUMMARY,
39 SCHEDULE
40};
41
42 class UnitSystem;
43 class Parser;
44
45
46class DeckSection : public DeckView {
47 public:
48
49 DeckSection( const Deck& deck, const std::string& startKeyword );
50 const std::string& name() const;
51 const UnitSystem& unitSystem() const;
52
53 static bool hasRUNSPEC( const Deck& );
54 static bool hasGRID( const Deck& );
55 static bool hasEDIT( const Deck& );
56 static bool hasPROPS( const Deck& );
57 static bool hasREGIONS( const Deck& );
58 static bool hasSOLUTION( const Deck& );
59 static bool hasSUMMARY( const Deck& );
60 static bool hasSCHEDULE( const Deck& );
61
62 // returns whether the deck has all mandatory sections and if all sections are in
63 // the right order
64 static bool checkSectionTopology(const Deck& deck,
65 const Parser&,
66 bool ensureKeywordSectionAffiliation = false);
67
68
69 // ---------------------------------------------------------------------------------
70 // Highly deprecated shims
71 const DeckKeyword& getKeyword(const std::string& keyword, std::size_t index) const {
72 auto view = this->operator[](keyword);
73 return view[index];
74 }
75
76 const DeckKeyword& getKeyword(const std::string& keyword) const {
77 auto view = this->operator[](keyword);
78 return view.back();
79 }
80
81
82 std::vector<const DeckKeyword*> getKeywordList(const std::string& keyword) const {
83 std::vector<const DeckKeyword*> kw_list;
84 auto view = this->operator[](keyword);
85 for (const auto& kw : view)
86 kw_list.push_back(&kw);
87 return kw_list;
88 }
89
90 template <class Keyword>
91 std::vector<const DeckKeyword*> getKeywordList() const {
92 return this->getKeywordList(Keyword::keywordName);
93 }
94
95
96 bool hasKeyword(const std::string& keyword) const {
97 return this->has_keyword(keyword);
98 }
99
100 template <class Keyword>
101 bool hasKeyword() const {
102 return this->has_keyword(Keyword::keywordName);
103 }
104
105 // ---------------------------------------------------------------------------------
106
107
108 private:
109 std::string section_name;
110 const UnitSystem& units;
111
112 };
113
115 public:
116 explicit RUNSPECSection(const Deck& deck) : DeckSection(deck, "RUNSPEC") {}
117 };
118
119 class GRIDSection : public DeckSection {
120 public:
121 explicit GRIDSection(const Deck& deck) : DeckSection(deck, "GRID") {}
122 };
123
124 class EDITSection : public DeckSection {
125 public:
126 explicit EDITSection(const Deck& deck) : DeckSection(deck, "EDIT") {}
127 };
128
129 class PROPSSection : public DeckSection {
130 public:
131 explicit PROPSSection(const Deck& deck) : DeckSection(deck, "PROPS") {}
132 };
133
135 public:
136 explicit REGIONSSection(const Deck& deck) : DeckSection(deck, "REGIONS") {}
137 };
138
140 public:
141 explicit SOLUTIONSection(const Deck& deck) : DeckSection(deck, "SOLUTION") {}
142 };
143
145 public:
146 explicit SUMMARYSection(const Deck& deck) : DeckSection(deck, "SUMMARY") {}
147 };
148
150 public:
151 explicit SCHEDULESection(const Deck& deck) : DeckSection(deck, "SCHEDULE") {}
152 };
153}
154
155#endif // SECTION_HPP
Definition: DeckKeyword.hpp:36
Definition: DeckSection.hpp:46
Definition: DeckView.hpp:30
Definition: Deck.hpp:49
Definition: DeckSection.hpp:124
Definition: DeckSection.hpp:119
Definition: DeckSection.hpp:129
The hub of the parsing process.
Definition: Parser.hpp:60
Definition: DeckSection.hpp:134
Definition: DeckSection.hpp:114
Definition: DeckSection.hpp:149
Definition: DeckSection.hpp:139
Definition: DeckSection.hpp:144
Definition: UnitSystem.hpp:33
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30