My Project
Loading...
Searching...
No Matches
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#ifndef BOX_HPP_
21#define BOX_HPP_
22
23#include <opm/input/eclipse/EclipseState/Grid/GridDims.hpp>
24
25#include <array>
26#include <cstddef>
27#include <functional>
28#include <vector>
29
30namespace Opm {
31 class DeckRecord;
32}
33
34namespace Opm
35{
36 class Box
37 {
38 public:
39 using IsActive = std::function<bool(const std::size_t globalIdx)>;
40 using ActiveIdx = std::function<std::size_t(const std::size_t globalIdx)>;
41
43 {
44 std::size_t global_index;
45 std::size_t active_index;
46 std::size_t data_index;
47
48 cell_index(std::size_t g,std::size_t a, std::size_t d)
49 : global_index(g)
50 , active_index(a)
51 , data_index(d)
52 {}
53
54 // This constructor should is used by the global_index_list() member
55 // which will return a list of *all* the cells in the box. In this
56 // case the active_index will be set to the global_index. This is a
57 // hack to simplify the treatment of global fields in the FieldProps
58 // implementation.
59 cell_index(std::size_t g, std::size_t d)
60 : global_index(g)
61 , active_index(g)
62 , data_index(d)
63 {}
64 };
65
66 explicit Box(const GridDims& gridDims,
67 IsActive isActive,
68 ActiveIdx activeIdx);
69
70 Box(const GridDims& gridDims,
71 IsActive isActive,
72 ActiveIdx activeIdx,
73 int i1, int i2,
74 int j1, int j2,
75 int k1, int k2);
76
77 void update(const DeckRecord& deckRecord);
78 void reset();
79
80 bool isGlobal() const;
81 std::size_t size() const;
82 std::size_t getDim(std::size_t idim) const;
83
84 const std::vector<cell_index>& index_list() const;
85 const std::vector<cell_index>& global_index_list() const;
86
87 bool operator==(const Box& other) const;
88 bool equal(const Box& other) const;
89
90 int I1() const;
91 int I2() const;
92 int J1() const;
93 int J2() const;
94 int K1() const;
95 int K2() const;
96
97 private:
98 GridDims m_globalGridDims_{};
99 IsActive m_globalIsActive_{};
100 ActiveIdx m_globalActiveIdx_{};
101
102 std::array<std::size_t, 3> m_dims{};
103 std::array<std::size_t, 3> m_offset{};
104
105 std::vector<cell_index> m_active_index_list;
106 std::vector<cell_index> m_global_index_list;
107
108 void init(int i1, int i2, int j1, int j2, int k1, int k2);
109 void initIndexList();
110 int lower(int dim) const;
111 int upper(int dim) const;
112 };
113}
114
115
116#endif
Definition Box.hpp:37
Definition DeckRecord.hpp:32
Definition GridDims.hpp:31
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition Exceptions.hpp:30
Definition Box.hpp:43