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
86 template <class Keyword>
87 std::vector<const DeckKeyword*> getKeywordList() const {
88 return this->getKeywordList(Keyword::keywordName);
89 }
90
91
92 bool hasKeyword(const std::string& keyword) const {
93 return this->has_keyword(keyword);
94 }
95
96 template <class Keyword>
97 bool hasKeyword() const {
98 return this->has_keyword(Keyword::keywordName);
99 }
100
101 // ---------------------------------------------------------------------------------
102
103
104 private:
105 std::string section_name;
106 const UnitSystem& units;
107
108 };
109
111 public:
112 explicit RUNSPECSection(const Deck& deck) : DeckSection(deck, "RUNSPEC") {}
113 };
114
115 class GRIDSection : public DeckSection {
116 public:
117 explicit GRIDSection(const Deck& deck) : DeckSection(deck, "GRID") {}
118 };
119
120 class EDITSection : public DeckSection {
121 public:
122 explicit EDITSection(const Deck& deck) : DeckSection(deck, "EDIT") {}
123 };
124
125 class PROPSSection : public DeckSection {
126 public:
127 explicit PROPSSection(const Deck& deck) : DeckSection(deck, "PROPS") {}
128 };
129
131 public:
132 explicit REGIONSSection(const Deck& deck) : DeckSection(deck, "REGIONS") {}
133 };
134
136 public:
137 explicit SOLUTIONSection(const Deck& deck) : DeckSection(deck, "SOLUTION") {}
138 };
139
141 public:
142 explicit SUMMARYSection(const Deck& deck) : DeckSection(deck, "SUMMARY") {}
143 };
144
146 public:
147 explicit SCHEDULESection(const Deck& deck) : DeckSection(deck, "SCHEDULE") {}
148 };
149}
150
151#endif // SECTION_HPP
Definition DeckKeyword.hpp:36
Definition DeckSection.hpp:47
Definition DeckView.hpp:31
Definition Deck.hpp:46
Definition DeckSection.hpp:120
Definition ErrorGuard.hpp:30
Definition DeckSection.hpp:115
Definition DeckSection.hpp:125
The hub of the parsing process.
Definition Parser.hpp:60
Definition DeckSection.hpp:130
Definition DeckSection.hpp:110
Definition DeckSection.hpp:145
Definition DeckSection.hpp:135
Definition DeckSection.hpp:140
Definition UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30