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