My Project
Box.hpp
1 /*
2  Copyright 2014 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 BOX_HPP_
22 #define BOX_HPP_
23 
24 #include <cstddef>
25 #include <limits>
26 #include <vector>
27 
28 namespace Opm {
29  class DeckRecord;
30  class EclipseGrid;
31 
32  class Box {
33  public:
34 
35 
36  struct cell_index {
37  std::size_t global_index;
38  std::size_t active_index;
39  std::size_t data_index;
40 
41 
42  cell_index(std::size_t g,std::size_t a, std::size_t d) :
43  global_index(g),
44  active_index(a),
45  data_index(d)
46  {}
47 
48 
49  /*
50  This constructor should is used by the global_index_list() member
51  which will return a list of *all* the cells in the box. In this
52  case the active_index will be set to the global_index. This is a
53  hack to simplify the treatment of global fields in the FieldProps
54  implementation.
55  */
56  cell_index(std::size_t g, std::size_t d) :
57  global_index(g),
58  active_index(g),
59  data_index(d)
60  {}
61  };
62 
63  explicit Box(const EclipseGrid& grid);
64  Box(const EclipseGrid& grid , int i1 , int i2 , int j1 , int j2 , int k1 , int k2);
65  void update(const DeckRecord& deckRecord);
66  void reset();
67 
68  size_t size() const;
69  bool isGlobal() const;
70  size_t getDim(size_t idim) const;
71  const std::vector<cell_index>& index_list() const;
72  const std::vector<Box::cell_index>& global_index_list() const;
73  bool equal(const Box& other) const;
74 
75 
76  int I1() const;
77  int I2() const;
78  int J1() const;
79  int J2() const;
80  int K1() const;
81  int K2() const;
82 
83  private:
84  void init(int i1, int i2, int j1, int j2, int k1, int k2);
85  void initIndexList();
86  const EclipseGrid& grid;
87  size_t m_stride[3];
88  size_t m_dims[3] = { 0, 0, 0 };
89  size_t m_offset[3];
90 
91  bool m_isGlobal;
92  std::vector<cell_index> m_active_index_list;
93  std::vector<cell_index> m_global_index_list;
94 
95  int lower(int dim) const;
96  int upper(int dim) const;
97  };
98 }
99 
100 
101 #endif
Definition: Box.hpp:32
Definition: DeckRecord.hpp:32
About cell information and dimension: The actual grid information is held in a pointer to an ERT ecl_...
Definition: EclipseGrid.hpp:55
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:29
Definition: Box.hpp:36