opm-common
TableColumn.hpp
1 /*
2  Copyright 2015 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 
21 #ifndef OPM_TABLE_COLUMN_HPP
22 #define OPM_TABLE_COLUMN_HPP
23 
24 #include <string>
25 #include <vector>
26 
27 #include <opm/input/eclipse/EclipseState/Tables/ColumnSchema.hpp>
28 #include <opm/input/eclipse/EclipseState/Tables/TableIndex.hpp>
29 
30 namespace Opm {
31 
32  class TableColumn {
33  public:
34  TableColumn();
35  explicit TableColumn( const ColumnSchema& schema );
36 
37  TableColumn(const TableColumn& c2) { *this = c2; }
38 
39  static TableColumn serializationTestObject();
40 
41  size_t size( ) const;
42  const std::string& name() const;
43  void assertOrder(double value1 , double value2, size_t index,
44  const std::string& tableName) const;
45  void addValue(double, const std::string& tableName);
46  void addDefault(const std::string& tableName);
47  void updateValue(size_t index, double value, const std::string& tableName);
48  double operator[](size_t index) const;
49  bool defaultApplied(size_t index) const;
50  bool hasDefault( ) const;
51  double front() const;
52  double back() const;
53  double min() const;
54  double max() const;
55  bool inRange( double arg ) const;
56 
57  /*
58  Will extrapolate with constant endpoint values if @argValue
59  is out of range.
60  */
61  TableIndex lookup(double argValue) const;
62  double eval( const TableIndex& index) const;
63  void applyDefaults( const TableColumn& argColumn, const std::string& tableName);
64  void assertUnitRange() const;
65  TableColumn& operator= (const TableColumn& other);
66 
67  std::vector<double> vectorCopy() const;
68  std::vector<double>::const_iterator begin() const;
69  std::vector<double>::const_iterator end() const;
70  std::vector<double>::const_reverse_iterator rbegin() const;
71  std::vector<double>::const_reverse_iterator rend() const;
72 
73  bool operator==(const TableColumn& data) const;
74 
75  template<class Serializer>
76  void serializeOp(Serializer& serializer)
77  {
78  serializer(m_schema);
79  serializer(m_name);
80  serializer(m_values);
81  serializer(m_default);
82  serializer(m_defaultCount);
83  }
84 
85  private:
86  void assertUpdate(const std::string& tableName, size_t index, double value) const;
87  void assertPrevious(const std::string& tableName, size_t index , double value) const;
88  void assertNext(const std::string& tableName, size_t index , double value) const;
89 
90  ColumnSchema m_schema;
91  std::string m_name;
92  std::vector<double> m_values;
93  std::vector<bool> m_default;
94  size_t m_defaultCount;
95  };
96 
97 
98 }
99 
100 
101 #endif
Definition: TableIndex.hpp:36
Definition: ColumnSchema.hpp:31
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
Definition: TableColumn.hpp:32
Class for (de-)serializing.
Definition: Serializer.hpp:94