Section.hpp
Go to the documentation of this file.
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 
24 
25 #include <iostream>
26 #include <string>
27 #include <memory>
28 
29 #include <boost/iterator/iterator_facade.hpp>
30 
32 
33 
34 namespace Opm {
35 
36 class Section : public Deck
37  {
38  public:
39  Section(DeckConstPtr deck, const std::string& startKeyword);
40  const std::string& name() const;
41  size_t count(const std::string& keyword) const;
42 
43  static bool hasRUNSPEC(DeckConstPtr deck) { return hasSection( deck , "RUNSPEC" ); }
44  static bool hasGRID(DeckConstPtr deck) { return hasSection( deck , "GRID" ); }
45  static bool hasEDIT(DeckConstPtr deck) { return hasSection( deck , "EDIT" ); }
46  static bool hasPROPS(DeckConstPtr deck) { return hasSection( deck , "PROPS" ); }
47  static bool hasREGIONS(DeckConstPtr deck) { return hasSection( deck , "REGIONS" ); }
48  static bool hasSOLUTION(DeckConstPtr deck) { return hasSection( deck , "SOLUTION" ); }
49  static bool hasSUMMARY(DeckConstPtr deck) { return hasSection( deck , "SUMMARY" ); }
50  static bool hasSCHEDULE(DeckConstPtr deck) { return hasSection( deck , "SCHEDULE" ); }
51 
52 
53  // returns whether the deck has all mandatory sections and if all sections are in
54  // the right order
55  static bool checkSectionTopology(DeckConstPtr deck,
56  bool ensureKeywordSectionAffiliation = false);
57 
58  private:
59  std::string m_name;
60  static bool isSectionDelimiter(const std::string& keywordName);
61  static bool hasSection(DeckConstPtr deck, const std::string& startKeyword);
62  void populateSection(DeckConstPtr deck, const std::string& startKeyword);
63  };
64 
65  typedef std::shared_ptr<Section> SectionPtr;
66  typedef std::shared_ptr<const Section> SectionConstPtr;
67 
68  class RUNSPECSection : public Section {
69  public:
70  RUNSPECSection(DeckConstPtr deck) : Section(deck, "RUNSPEC") {}
71  };
72 
73  class GRIDSection : public Section {
74  public:
75  GRIDSection(DeckConstPtr deck) : Section(deck, "GRID") {}
76  };
77 
78  class EDITSection : public Section {
79  public:
80  EDITSection(DeckConstPtr deck) : Section(deck, "EDIT") {}
81  };
82 
83  class PROPSSection : public Section {
84  public:
85  PROPSSection(DeckConstPtr deck) : Section(deck, "PROPS") {}
86  };
87 
88  class REGIONSSection : public Section {
89  public:
90  REGIONSSection(DeckConstPtr deck) : Section(deck, "REGIONS") {}
91  };
92 
93  class SOLUTIONSection : public Section {
94  public:
95  SOLUTIONSection(DeckConstPtr deck) : Section(deck, "SOLUTION") {}
96  };
97 
98  class SUMMARYSection : public Section {
99  public:
100  SUMMARYSection(DeckConstPtr deck) : Section(deck, "SUMMARY") {}
101  };
102 }
103 
104 #endif // SECTION_HPP
std::shared_ptr< Section > SectionPtr
Definition: Section.hpp:65
REGIONSSection(DeckConstPtr deck)
Definition: Section.hpp:90
SUMMARYSection(DeckConstPtr deck)
Definition: Section.hpp:100
static bool hasSUMMARY(DeckConstPtr deck)
Definition: Section.hpp:49
Definition: Section.hpp:98
static bool hasSCHEDULE(DeckConstPtr deck)
Definition: Section.hpp:50
Definition: Deck.hpp:29
static bool checkSectionTopology(DeckConstPtr deck, bool ensureKeywordSectionAffiliation=false)
Definition: Section.hpp:83
PROPSSection(DeckConstPtr deck)
Definition: Section.hpp:85
Definition: Section.hpp:36
Definition: Deck.hpp:31
Definition: Section.hpp:78
RUNSPECSection(DeckConstPtr deck)
Definition: Section.hpp:70
std::shared_ptr< const Deck > DeckConstPtr
Definition: Deck.hpp:86
GRIDSection(DeckConstPtr deck)
Definition: Section.hpp:75
size_t count(const std::string &keyword) const
Section(DeckConstPtr deck, const std::string &startKeyword)
static bool hasPROPS(DeckConstPtr deck)
Definition: Section.hpp:46
Definition: Section.hpp:73
std::shared_ptr< const Section > SectionConstPtr
Definition: Section.hpp:66
static bool hasGRID(DeckConstPtr deck)
Definition: Section.hpp:44
static bool hasREGIONS(DeckConstPtr deck)
Definition: Section.hpp:47
Definition: Section.hpp:68
static bool hasSOLUTION(DeckConstPtr deck)
Definition: Section.hpp:48
static bool hasRUNSPEC(DeckConstPtr deck)
Definition: Section.hpp:43
EDITSection(DeckConstPtr deck)
Definition: Section.hpp:80
Definition: Section.hpp:88
const std::string & name() const
SOLUTIONSection(DeckConstPtr deck)
Definition: Section.hpp:95
Definition: Section.hpp:93
static bool hasEDIT(DeckConstPtr deck)
Definition: Section.hpp:45