SimpleTable.hpp
Go to the documentation of this file.
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
25
26#include <map>
27#include <memory>
28#include <string>
29#include <vector>
30
31namespace Opm {
32
33 class DeckItem;
34
36
37 public:
38 SimpleTable() = default;
39 SimpleTable(TableSchema, const DeckItem& deckItem);
41
43
44 void addColumns();
45 void init(const DeckItem& deckItem );
46 void init( const DeckItem& deckItem, double scaling_factor);
47 size_t numColumns() const;
48 size_t numRows() const;
49 void addRow( const std::vector<double>& row);
50 const TableColumn& getColumn(const std::string &name) const;
51 const TableColumn& getColumn(size_t colIdx) const;
52 bool hasColumn(const std::string& name) const;
53
55 TableColumn& getColumn(size_t colIdx);
56
57 double get(const std::string& column , size_t row) const;
58 double get(size_t column , size_t row) const;
65 double evaluate(const std::string& columnName, double xPos) const;
66
68 void assertJFuncPressure(const bool jf) const;
69
70 bool operator==(const SimpleTable& data) const;
71
72 template<class Serializer>
73 void serializeOp(Serializer& serializer)
74 {
75 m_schema.serializeOp(serializer);
76 m_columns.serializeOp(serializer);
77 serializer(m_jfunc);
78 }
79
80 protected:
83 bool m_jfunc = false;
84 };
85}
86
87#endif
const char *const name
Definition: cJSON.h:258
const char *const string
Definition: cJSON.h:170
Definition: DeckItem.hpp:37
Definition: OrderedMap.hpp:32
Definition: Serializer.hpp:38
Definition: SimpleTable.hpp:35
SimpleTable(TableSchema)
TableColumn & getColumn(const std::string &name)
static SimpleTable serializeObject()
size_t numColumns() const
const TableColumn & getColumn(const std::string &name) const
void assertJFuncPressure(const bool jf) const
throws std::invalid_argument if jf != m_jfunc
OrderedMap< std::string, TableColumn > m_columns
Definition: SimpleTable.hpp:82
bool m_jfunc
Definition: SimpleTable.hpp:83
double evaluate(const std::string &columnName, double xPos) const
Evaluate a column of the table at a given position.
TableSchema m_schema
Definition: SimpleTable.hpp:81
bool hasColumn(const std::string &name) const
double get(const std::string &column, size_t row) const
size_t numRows() const
const TableColumn & getColumn(size_t colIdx) const
bool operator==(const SimpleTable &data) const
double get(size_t column, size_t row) const
void serializeOp(Serializer &serializer)
Definition: SimpleTable.hpp:73
void addRow(const std::vector< double > &row)
void init(const DeckItem &deckItem)
SimpleTable()=default
TableColumn & getColumn(size_t colIdx)
void init(const DeckItem &deckItem, double scaling_factor)
SimpleTable(TableSchema, const DeckItem &deckItem)
Definition: TableColumn.hpp:32
Definition: TableSchema.hpp:31
void serializeOp(Serializer &serializer)
Definition: TableSchema.hpp:46
Definition: A.hpp:4
static std::string data()
Definition: exprtk.hpp:40022