opm-common
ScheduleBlock.hpp
1 /*
2  Copyright 2021 Equinor 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 #ifndef SCHEDULE_BLOCK_HPP
20 #define SCHEDULE_BLOCK_HPP
21 
22 #include <opm/common/OpmLog/KeywordLocation.hpp>
23 #include <opm/common/utility/TimeService.hpp>
24 
25 #include <opm/input/eclipse/Deck/DeckKeyword.hpp>
26 
27 #include <cstddef>
28 #include <optional>
29 #include <vector>
30 
31 namespace Opm {
32  class UnitSystem;
33 }
34 
35 namespace Opm {
36 
37 class DeckOutput;
38 
39 enum class ScheduleTimeType {
40  START = 0,
41  DATES = 1,
42  TSTEP = 2,
43  RESTART = 3,
44 };
45 
46 /*
47  The ScheduleBlock is collection of all the Schedule keywords from one
48  report step.
49 */
50 
52 {
53 public:
54  ScheduleBlock() = default;
55  ScheduleBlock(const KeywordLocation& location,
56  ScheduleTimeType time_type,
57  const time_point& start_time);
58  std::size_t size() const;
59  void push_back(const DeckKeyword& keyword);
60  std::optional<DeckKeyword> get(const std::string& kw) const;
61  const time_point& start_time() const;
62  const std::optional<time_point>& end_time() const;
63  void end_time(const time_point& t);
64  ScheduleTimeType time_type() const;
65  const KeywordLocation& location() const;
66  const DeckKeyword& operator[](const std::size_t index) const;
67  std::vector<DeckKeyword>::const_iterator begin() const;
68  std::vector<DeckKeyword>::const_iterator end() const;
69 
70  bool operator==(const ScheduleBlock& other) const;
71  static ScheduleBlock serializationTestObject();
72 
73  void clearKeywords();
74 
75  template<class Serializer>
76  void serializeOp(Serializer& serializer)
77  {
78  serializer(m_time_type);
79  serializer(m_start_time);
80  serializer(m_end_time);
81  serializer(m_keywords);
82  serializer(m_location);
83  }
84 
85  void dump_deck(const UnitSystem& usys,
86  DeckOutput& output,
87  time_point& current_time) const;
88 
89 private:
90  ScheduleTimeType m_time_type{ScheduleTimeType::START};
91  time_point m_start_time{};
92  std::optional<time_point> m_end_time{};
93  KeywordLocation m_location{};
94  std::vector<DeckKeyword> m_keywords{};
95 
96  void dump_time(const UnitSystem& usys,
97  time_point current_time,
98  DeckOutput& output) const;
99 
100  void writeDates(DeckOutput& output) const;
101 
102  void writeTStep(const UnitSystem& usys,
103  time_point current_time,
104  DeckOutput& output) const;
105 };
106 
107 } // end namespace Opm
108 
109 #endif // SCHEDULE_BLOCK_HPP
Definition: KeywordLocation.hpp:27
Definition: ScheduleBlock.hpp:51
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: DeckOutput.hpp:29
Definition: UnitSystem.hpp:34
Class for (de-)serializing.
Definition: Serializer.hpp:94
Definition: DeckKeyword.hpp:36