Box.hpp
Go to the documentation of this file.
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 <vector>
25#include <cstddef>
26
27namespace Opm {
28 class DeckRecord;
29 class EclipseGrid;
30
31 class Box {
32 public:
33
34 struct cell_index {
35 std::size_t global_index;
36 std::size_t active_index;
37 std::size_t data_index;
38
39 cell_index(std::size_t g,std::size_t a, std::size_t d) :
40 global_index(g),
41 active_index(a),
42 data_index(d)
43 {}
44
45 };
46
47 Box(const EclipseGrid& grid);
48 Box(const EclipseGrid& grid , int i1 , int i2 , int j1 , int j2 , int k1 , int k2);
49 void update(const DeckRecord& deckRecord);
50 void reset();
51
52 size_t size() const;
53 bool isGlobal() const;
54 size_t getDim(size_t idim) const;
55 const std::vector<cell_index>& index_list() const;
56 const std::vector<size_t>& getIndexList() const;
57 bool equal(const Box& other) const;
58
59
60 int I1() const;
61 int I2() const;
62 int J1() const;
63 int J2() const;
64 int K1() const;
65 int K2() const;
66
67 private:
68 void init(int i1, int i2, int j1, int j2, int k1, int k2);
69 void initIndexList();
70 const EclipseGrid& grid;
71 size_t m_stride[3];
72 size_t m_dims[3] = { 0, 0, 0 };
73 size_t m_offset[3];
74
75 bool m_isGlobal;
76 std::vector<size_t> global_index_list;
77 std::vector<cell_index> m_index_list;
78
79 int lower(int dim) const;
80 int upper(int dim) const;
81 };
82}
83
84
85#endif
Definition: Box.hpp:31
Box(const EclipseGrid &grid)
int K2() const
int K1() const
size_t size() const
Box(const EclipseGrid &grid, int i1, int i2, int j1, int j2, int k1, int k2)
int I2() const
size_t getDim(size_t idim) const
bool isGlobal() const
void update(const DeckRecord &deckRecord)
int I1() const
const std::vector< cell_index > & index_list() const
const std::vector< size_t > & getIndexList() const
bool equal(const Box &other) const
int J2() const
int J1() const
void reset()
Definition: DeckRecord.hpp:32
Definition: EclipseGrid.hpp:54
Definition: A.hpp:4
Definition: Box.hpp:34
std::size_t data_index
Definition: Box.hpp:37
std::size_t global_index
Definition: Box.hpp:35
std::size_t active_index
Definition: Box.hpp:36
cell_index(std::size_t g, std::size_t a, std::size_t d)
Definition: Box.hpp:39