opm-common
Loading...
Searching...
No Matches
DeckKeyword.hpp
1/*
2 Copyright 2016 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 DECKKEYWORD_HPP
21#define DECKKEYWORD_HPP
22
23#include <string>
24#include <vector>
25
26#include <opm/input/eclipse/Deck/DeckRecord.hpp>
27#include <opm/input/eclipse/Deck/value_status.hpp>
28#include <opm/common/OpmLog/KeywordLocation.hpp>
29
30namespace Opm {
31 class DeckOutput;
32 class DeckValue;
33 class ParserKeyword;
34 class UnitSystem;
35
36 class DeckKeyword {
37 public:
38
39
40 typedef std::vector< DeckRecord >::const_iterator const_iterator;
41
42 DeckKeyword();
43 explicit DeckKeyword(const ParserKeyword& parserKeyword);
44 DeckKeyword(const KeywordLocation& location, const ParserKeyword& parserKeyword);
45 DeckKeyword(const KeywordLocation& location, const std::string& keywordName);
46 DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<std::vector<DeckValue>>& record_list, const UnitSystem& system_active, const UnitSystem& system_default);
47 DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<int>& data, const KeywordLocation& location = KeywordLocation {});
48 DeckKeyword(const ParserKeyword& parserKeyword, const std::vector<double>& data, const UnitSystem& system_active, const UnitSystem& system_default, const KeywordLocation& location = KeywordLocation {});
49
50 static DeckKeyword serializationTestObject();
51
52 const std::string& name() const;
53 void setFixedSize();
54 const KeywordLocation& location() const;
55 DeckKeyword emptyStructuralCopy() const;
56
57 size_t size() const;
58 bool empty() const;
59 void addRecord(DeckRecord&& record);
60 const DeckRecord& getRecord(size_t index) const;
61 DeckRecord& getRecord(size_t index);
62 const DeckRecord& getDataRecord() const;
63 const DeckRecord& operator[](std::size_t index) const;
64 DeckRecord& operator[](std::size_t index);
65 void setDataKeyword(bool isDataKeyword = true);
66 void setDoubleRecordKeyword(bool isDoubleRecordKeyword = true);
67 bool isDataKeyword() const;
68 bool isDoubleRecordKeyword() const;
69
70 std::vector<int>& getIntData();
71 std::vector<double>& getRawDoubleData();
72
73 const std::vector<int>& getIntData() const;
74 const std::vector<double>& getRawDoubleData() const;
75 const std::vector<double>& getSIDoubleData() const;
76 const std::vector<std::string>& getStringData() const;
77 const std::vector<value::status>& getValueStatus() const;
78 size_t getDataSize() const;
79 void write( DeckOutput& output ) const;
80 void write_data( DeckOutput& output ) const;
81 void write_TITLE( DeckOutput& output ) const;
82
83 template <class Keyword>
84 bool is() const {
85 if (Keyword::keywordName == this->m_keywordName)
86 return true;
87 else
88 return false;
89 }
90
91 const_iterator begin() const;
92 const_iterator end() const;
93 bool equal_data(const DeckKeyword& other, bool cmp_default = false, bool cmp_numeric = true) const;
94 bool equal(const DeckKeyword& other, bool cmp_default = false, bool cmp_numeric = true) const;
95 bool operator==(const DeckKeyword& other) const;
96 bool operator!=(const DeckKeyword& other) const;
97
98 friend std::ostream& operator<<(std::ostream& os, const DeckKeyword& keyword);
99
100 template<class Serializer>
101 void serializeOp(Serializer& serializer)
102 {
103 serializer(m_keywordName);
104 serializer(m_location);
105 serializer(m_recordList);
106 serializer(m_isDataKeyword);
107 serializer(m_slashTerminated);
108 serializer(m_isDoubleRecordKeyword);
109 }
110
111 private:
112 std::string m_keywordName;
113 KeywordLocation m_location;
114
115 std::vector< DeckRecord > m_recordList;
116 bool m_isDataKeyword;
117 bool m_slashTerminated;
118 bool m_isDoubleRecordKeyword = false;
119 };
120}
121
122#endif /* DECKKEYWORD_HPP */
Definition DeckOutput.hpp:29
Definition DeckRecord.hpp:32
Definition DeckValue.hpp:30
Definition KeywordLocation.hpp:27
Definition ParserKeyword.hpp:85
Class for (de-)serializing.
Definition Serializer.hpp:94
Definition UnitSystem.hpp:34
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30