SummaryState.hpp
Go to the documentation of this file.
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 SUMMARY_STATE_H
21#define SUMMARY_STATE_H
22
23#include <string>
24#include <chrono>
25#include <vector>
26#include <unordered_map>
27#include <unordered_set>
28#include <iosfwd>
29
30namespace Opm{
31
32
33/*
34 The purpose of this class is to serve as a small container object for
35 computed, ready to use summary values. The values will typically be used by
36 the UDQ, WTEST and ACTIONX calculations. Observe that all value *have been
37 converted to the correct output units*.
38
39 The main key used to access the content of this container is the eclipse style
40 colon separated string - i.e. 'WWCT:OPX' to get the watercut in well 'OPX'.
41 The main usage of the SummaryState class is a temporary holding ground while
42 assembling data for the summary output, but it is also used as a context
43 object when evaulating the condition in ACTIONX keywords. For that reason some
44 of the data is duplicated both in the general structure and a specialized
45 structure:
46
47 SummaryState st;
48
49 st.add_well_var("OPX", "WWCT", 0.75);
50 st.add("WGOR:OPY", 120);
51
52 // The WWCT:OPX key has been added with the specialized add_well_var()
53 // method and this data is available both with the general
54 // st.has("WWCT:OPX") and the specialized st.has_well_var("OPX", "WWCT");
55 st.has("WWCT:OPX") => True
56 st.has_well_var("OPX", "WWCT") => True
57
58
59 // The WGOR:OPY key is added with the general add("WGOR:OPY") and is *not*
60 // accessible through the specialized st.has_well_var("OPY", "WGOR").
61 st.has("WGOR:OPY") => True
62 st.has_well_var("OPY", "WGOR") => False
63*/
64
66public:
67 typedef std::unordered_map<std::string, double>::const_iterator const_iterator;
69
70 /*
71 The set() function has to be retained temporarily to support updating of
72 cumulatives from restart files.
73 */
74 void set(const std::string& key, double value);
75
76 bool has(const std::string& key) const;
77 bool has_well_var(const std::string& well, const std::string& var) const;
78 bool has_group_var(const std::string& group, const std::string& var) const;
79
80 void update(const std::string& key, double value);
81 void update_well_var(const std::string& well, const std::string& var, double value);
82 void update_group_var(const std::string& group, const std::string& var, double value);
83 void update_elapsed(double delta);
84
85 double get(const std::string&) const;
86 double get_elapsed() const;
87 double get_well_var(const std::string& well, const std::string& var) const;
88 double get_group_var(const std::string& group, const std::string& var) const;
89
90 std::vector<std::string> wells() const;
91 std::vector<std::string> wells(const std::string& var) const;
92 std::vector<std::string> groups() const;
93 std::vector<std::string> groups(const std::string& var) const;
94 std::vector<char> serialize() const;
95 void deserialize(const std::vector<char>& buffer);
98 std::size_t num_wells() const;
99 std::size_t size() const;
100private:
102 double elapsed = 0;
103 std::unordered_map<std::string,double> values;
104
105 // The first key is the variable and the second key is the well.
106 std::unordered_map<std::string, std::unordered_map<std::string, double>> well_values;
107 std::unordered_set<std::string> m_wells;
108
109 // The first key is the variable and the second key is the group.
110 std::unordered_map<std::string, std::unordered_map<std::string, double>> group_values;
111 std::unordered_set<std::string> m_groups;
112};
113
114
115std::ostream& operator<<(std::ostream& stream, const SummaryState& st);
116
117}
118#endif
const char *const string
Definition: cJSON.h:170
char * buffer
Definition: cJSON.h:161
Definition: SummaryState.hpp:65
SummaryState(std::chrono::system_clock::time_point sim_start_arg)
void update(const std::string &key, double value)
std::vector< std::string > wells(const std::string &var) const
std::size_t size() const
std::vector< char > serialize() const
double get_group_var(const std::string &group, const std::string &var) const
double get(const std::string &) const
const_iterator begin() const
void deserialize(const std::vector< char > &buffer)
std::vector< std::string > groups(const std::string &var) const
void update_elapsed(double delta)
double get_elapsed() const
void set(const std::string &key, double value)
std::size_t num_wells() const
bool has_well_var(const std::string &well, const std::string &var) const
bool has_group_var(const std::string &group, const std::string &var) const
void update_group_var(const std::string &group, const std::string &var, double value)
double get_well_var(const std::string &well, const std::string &var) const
std::unordered_map< std::string, double >::const_iterator const_iterator
Definition: SummaryState.hpp:67
const_iterator end() const
void update_well_var(const std::string &well, const std::string &var, double value)
std::vector< std::string > groups() const
bool has(const std::string &key) const
std::vector< std::string > wells() const
Definition: A.hpp:4
std::chrono::time_point< std::chrono::system_clock, std::chrono::duration< int64_t, std::ratio< 1, 1000 > > > time_point
Definition: TimeService.hpp:31
std::ostream & operator<<(std::ostream &os, const UniformTableLinear< T > &t)
Definition: UniformTableLinear.hpp:249
T value(details::expression_node< T > *n)
Definition: exprtk.hpp:12955