smspec_node.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2012 Equinor ASA, Norway.
3
4 The file 'smspec_node.h' is part of ERT - Ensemble based Reservoir Tool.
5
6 ERT 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 ERT is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE.
14
15 See the GNU General Public License at <http://www.gnu.org/licenses/gpl.html>
16 for more details.
17*/
18
19
20#ifndef ERT_SMSPEC_NODE_HPP
21#define ERT_SMSPEC_NODE_HPP
22
23#include <stdbool.h>
24#include <stdio.h>
25
26#include <string>
27#include <array>
28
30
31#include <ert/ecl/smspec_node.h>
32
33
34namespace ecl {
35
37 private:
38
39 std::string wgname;
40 std::string keyword; /* The value of the KEYWORDS vector for this elements. */
41 std::string unit; /* The value of the UNITS vector for this elements. */
42 int num; /* The value of the NUMS vector for this elements - NB this will have the value SMSPEC_NUMS_INVALID if the smspec file does not have a NUMS vector. */
43 std::string lgr_name; /* The lgr name of the current variable - will be NULL for non-lgr variables. */
44 std::array<int,3> lgr_ijk;
45
46 /*------------------------------------------- All members below this line are *derived* quantities. */
47
48 std::string gen_key1; /* The main composite key, i.e. WWCT:OP3 for this element. */
49 std::string gen_key2; /* Some of the ijk based elements will have both a xxx:i,j,k and a xxx:num key. Some of the region_2_region elements will have both a xxx:num and a xxx:r2-r2 key. Mostly NULL. */
50 ecl_smspec_var_type var_type; /* The variable type */
51 std::array<int,3> ijk; /* The ijk coordinates (NB: OFFSET 1) corresponding to the nums value - will be NULL if not relevant. */
52 bool rate_variable; /* Is this a rate variable (i.e. WOPR) or a state variable (i.e. BPR). Relevant when doing time interpolation. */
53 bool total_variable; /* Is this a total variable like WOPT? */
54 bool historical; /* Does the name end with 'H'? */
55 int params_index; /* The index of this variable (applies to all the vectors - in particular the PARAMS vectors of the summary files *.Snnnn / *.UNSMRY ). */
56 float default_value; /* Default value for this variable. */
57
58 static ecl_smspec_var_type identify_special_var( const char * var );
59 void set_wgname(const char * wgname);
60 void set_num( const int grid_dims[3] , int num_);
61 void set_gen_keys( const char * key_join_string_);
62 void decode_R1R2( int * r1 , int * r2) const;
63 void set_lgr_ijk( int lgr_i , int lgr_j , int lgr_k);
64
65 public:
66
67 static ecl_smspec_var_type valid_type(const char * keyword, const char * wgname, int num);
68 int cmp(const smspec_node& node2) const;
69 static int cmp(const smspec_node& node1, const smspec_node& node2);
70
71 smspec_node(int param_index,
72 const char * keyword ,
73 const char * wgname,
74 int num,
75 const char * unit ,
76 const int grid_dims[3] ,
77 float default_value,
78 const char * key_join_string);
79
80 smspec_node(int param_index,
81 const char * keyword ,
82 const char * wgname ,
83 const char * unit ,
84 const char * lgr ,
85 int lgr_i, int lgr_j , int lgr_k,
86 float default_value,
87 const char * key_join_string);
88
89 smspec_node(int param_index, const char * keyword, const char * unit, float default_value);
90 smspec_node(int param_index, const char * keyword, int num, const char * unit, const int grid_dims[3], float default_value, const char * key_join_string);
91 smspec_node(int param_index, const char * keyword, int num, const char * unit, float default_value, const char * key_join_string);
92 smspec_node(int param_index, const char * keyword, const char * wgname, const char * unit, float default_value, const char * key_join_string);
93 smspec_node(int param_index, const char * keyword, const char * wgname, int num, const char * unit, float default_value, const char * key_join_string);
94 smspec_node(const smspec_node& node, int param_index);
95
96 static ecl_smspec_var_type identify_var_type(const char * var);
97
98 static int cmp( const smspec_node * node1, const smspec_node * node2) {
99 return node1->cmp(*node2);
100 }
101
102 int get_R1() const;
103 int get_R2() const;
104 const char * get_gen_key1() const;
105 const char * get_gen_key2() const;
107 int get_num() const;
108 const char * get_wgname() const;
109 const char * get_keyword() const;
110 const char * get_unit() const;
111 bool is_rate() const;
112 bool is_total() const;
113 bool is_historical() const;
114 bool need_nums() const;
115 void fprintf__( FILE * stream) const;
116 int get_params_index() const;
117 float get_default() const;
118 const std::array<int,3>& get_ijk() const;
119 const char * get_lgr_name() const;
120 const std::array<int,3>& get_lgr_ijk() const;
121
122 };
123
124}
125
126#endif
const char *const string
Definition: cJSON.h:170
Definition: smspec_node.hpp:36
smspec_node(int param_index, const char *keyword, int num, const char *unit, const int grid_dims[3], float default_value, const char *key_join_string)
bool is_rate() const
const std::array< int, 3 > & get_ijk() const
int cmp(const smspec_node &node2) const
smspec_node(int param_index, const char *keyword, const char *unit, float default_value)
const char * get_gen_key1() const
float get_default() const
bool need_nums() const
int get_num() const
smspec_node(const smspec_node &node, int param_index)
static ecl_smspec_var_type valid_type(const char *keyword, const char *wgname, int num)
smspec_node(int param_index, const char *keyword, const char *wgname, int num, const char *unit, const int grid_dims[3], float default_value, const char *key_join_string)
const char * get_gen_key2() const
const std::array< int, 3 > & get_lgr_ijk() const
int get_R1() const
int get_params_index() const
static int cmp(const smspec_node *node1, const smspec_node *node2)
Definition: smspec_node.hpp:98
int get_R2() const
bool is_total() const
const char * get_lgr_name() const
smspec_node(int param_index, const char *keyword, const char *wgname, const char *unit, float default_value, const char *key_join_string)
smspec_node(int param_index, const char *keyword, const char *wgname, const char *unit, const char *lgr, int lgr_i, int lgr_j, int lgr_k, float default_value, const char *key_join_string)
ecl_smspec_var_type get_var_type() const
const char * get_wgname() const
static int cmp(const smspec_node &node1, const smspec_node &node2)
const char * get_keyword() const
void fprintf__(FILE *stream) const
smspec_node(int param_index, const char *keyword, int num, const char *unit, float default_value, const char *key_join_string)
smspec_node(int param_index, const char *keyword, const char *wgname, int num, const char *unit, float default_value, const char *key_join_string)
const char * get_unit() const
static ecl_smspec_var_type identify_var_type(const char *var)
bool is_historical() const
Definition: ecl_box.hpp:26
ecl_smspec_var_type
Definition: smspec_node.h:28