opm-common
SimpleTable.hpp
1 /*
2  Copyright (C) 2013 by Andreas Lauser
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 OPM_PARSER_SIMPLE_TABLE_HPP
20 #define OPM_PARSER_SIMPLE_TABLE_HPP
21 
22 #include <opm/input/eclipse/EclipseState/Tables/TableColumn.hpp>
23 #include <opm/input/eclipse/EclipseState/Tables/TableSchema.hpp>
24 #include <opm/input/eclipse/EclipseState/Util/OrderedMap.hpp>
25 
26 #include <cstddef>
27 #include <map>
28 #include <memory>
29 #include <string>
30 #include <vector>
31 
32 namespace Opm {
33 
34  class DeckItem;
35 
36  class SimpleTable {
37 
38  public:
39  SimpleTable() = default;
40  SimpleTable(TableSchema, const std::string& tableName, const DeckItem& deckItem, const int tableID);
41  explicit SimpleTable( TableSchema );
42 
43  virtual ~SimpleTable() = default;
44 
45  static SimpleTable serializationTestObject();
46 
47  void addColumns();
53  void init( const std::string& tableName,
54  const DeckItem& deckItem,
55  const int tableID,
56  double scaling_factor = 0.0);
57  std::size_t numColumns() const;
58  std::size_t numRows() const;
59  void addRow( const std::vector<double>& row, const std::string& tableName);
60  const TableColumn& getColumn(const std::string &name) const;
61  const TableColumn& getColumn(std::size_t colIdx) const;
62  bool hasColumn(const std::string& name) const;
63 
64  TableColumn& getColumn(const std::string &name);
65  TableColumn& getColumn(std::size_t colIdx);
66 
67  double get(const std::string& column , std::size_t row) const;
68  double get(std::size_t column , std::size_t row) const;
75  double evaluate(const std::string& columnName, double xPos) const;
76 
78  void assertJFuncPressure(const bool jf) const;
79 
80  bool operator==(const SimpleTable& data) const;
81 
82  template<class Serializer>
83  void serializeOp(Serializer& serializer)
84  {
85  serializer(m_schema);
86  serializer(m_columns);
87  serializer(m_jfunc);
88  }
89 
90  protected:
91  TableSchema m_schema;
92  OrderedMap<TableColumn> m_columns;
93  bool m_jfunc = false;
94  };
95 }
96 
97 #endif
Definition: TableSchema.hpp:32
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
A map with iteration in the order of insertion.
Definition: OrderedMap.hpp:118
Definition: DeckItem.hpp:38
Definition: SimpleTable.hpp:36
Definition: TableColumn.hpp:32
void assertJFuncPressure(const bool jf) const
throws std::invalid_argument if jf != m_jfunc
Definition: SimpleTable.cpp:210
double evaluate(const std::string &columnName, double xPos) const
Evaluate a column of the table at a given position.
Definition: SimpleTable.cpp:203
Class for (de-)serializing.
Definition: Serializer.hpp:95
void init(const std::string &tableName, const DeckItem &deckItem, const int tableID, double scaling_factor=0.0)
Initialize deck item.
Definition: SimpleTable.cpp:105