ConnectionIndexMap.hpp
Go to the documentation of this file.
1/*
2 Copyright 2016 SINTEF ICT, Applied Mathematics.
3 Copyright 2016 - 2017 Statoil ASA.
4 Copyright 2017 Dr. Blatt - HPC-Simulation-Software & Services
5 Copyright 2016 - 2018 IRIS AS
6
7 This file is part of the Open Porous Media project (OPM).
8
9 OPM is free software: you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation, either version 3 of the License, or
12 (at your option) any later version.
13
14 OPM is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
18
19 You should have received a copy of the GNU General Public License
20 along with OPM. If not, see <http://www.gnu.org/licenses/>.
21*/
22
23#ifndef OPM_CONNECTION_INDEX_MAP_HEADER_INCLUDED
24#define OPM_CONNECTION_INDEX_MAP_HEADER_INCLUDED
25
26#include <cstddef>
27#include <vector>
28
29namespace Opm {
30
33{
34public:
39 explicit ConnectionIndexMap(const std::size_t numConns)
40 : local_(numConns, -1)
41 {
42 this->global_.reserve(numConns);
43 this->open_.reserve(numConns);
44 }
45
53 void addActiveConnection(const int connIdx,
54 const bool connIsOpen)
55 {
56 this->local_[connIdx] =
57 static_cast<int>(this->global_.size());
58
59 this->global_.push_back(connIdx);
60
61 const auto open_conn_idx = connIsOpen
62 ? this->num_open_conns_++
63 : -1;
64
65 this->open_.push_back(open_conn_idx);
66 }
67
73 const std::vector<int>& local() const
74 {
75 return this->local_;
76 }
77
83 int global(const int connIdx) const
84 {
85 return this->global_[connIdx];
86 }
87
95 int open(const int connIdx) const
96 {
97 return this->open_[connIdx];
98 }
99
100private:
104 std::vector<int> local_{};
105
108 std::vector<int> global_{};
109
111 std::vector<int> open_{};
112
114 int num_open_conns_{0};
115};
116
117} // namespace Opm
118
119#endif
Connection index mappings.
Definition: ConnectionIndexMap.hpp:33
void addActiveConnection(const int connIdx, const bool connIsOpen)
Definition: ConnectionIndexMap.hpp:53
ConnectionIndexMap(const std::size_t numConns)
Definition: ConnectionIndexMap.hpp:39
const std::vector< int > & local() const
Definition: ConnectionIndexMap.hpp:73
int global(const int connIdx) const
Definition: ConnectionIndexMap.hpp:83
int open(const int connIdx) const
Definition: ConnectionIndexMap.hpp:95
Definition: blackoilboundaryratevector.hh:39