GlobalWellInfo.hpp
Go to the documentation of this file.
1/*
2 Copyright 2021 Equinor
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 OPM_GLOBAL_WELL_INFO_HEADER_INCLUDED
21#define OPM_GLOBAL_WELL_INFO_HEADER_INCLUDED
22
23#include <cstddef>
24#include <map>
25#include <string>
26#include <vector>
27
28namespace Opm {
29
30class Schedule;
31class Well;
32enum class WellInjectorCMode;
33enum class WellProducerCMode;
34enum class WellStatus;
35
36
37/*
38 The context of the GlobalWellInfo class is the situation where the wells are
39 distributed among different processors. Most well processing only considers
40 the wells defined on the local process, but in some cases we need global
41 information about all the wells. This class maintains the following:
42
43 - Mapping between global well index and well name.
44
45 - Mapping between local well index and global index (only used internally in
46 class).
47
48 - Functionality to query well whether it is currently injecting or producing
49 under group control.
50*/
51
52
54public:
55
56
57 /*
58 Will sum the m_in_injecting_group and m_in_producing_group vectors across
59 all processes, so that all processes can query for an arbitrary well.
60 */
61 template <typename Comm>
62 void communicate(const Comm& comm) {
63 auto size = this->m_in_injecting_group.size();
64 comm.sum( this->m_in_injecting_group.data(), size);
65 comm.sum( this->m_in_producing_group.data(), size);
66 }
67
68
69
70 GlobalWellInfo(const Schedule& sched, std::size_t report_step, const std::vector<Well>& local_wells);
71 bool in_producing_group(const std::string& wname) const;
72 bool in_injecting_group(const std::string& wname) const;
73 std::size_t well_index(const std::string& wname) const;
74 const std::string& well_name(std::size_t well_index) const;
75 void update_injector(std::size_t well_index, WellStatus well_status, WellInjectorCMode injection_cmode);
76 void update_producer(std::size_t well_index, WellStatus well_status, WellProducerCMode production_cmode);
77 void clear();
78
79private:
80 std::vector<std::size_t> local_map; // local_index -> global_index
81
82 std::map<std::string, std::size_t> name_map; // string -> global_index
83 std::vector<int> m_in_injecting_group; // global_index -> int/bool
84 std::vector<int> m_in_producing_group; // global_index -> int/bool
85};
86
87
88}
89
90#endif
91
Dune::OwnerOverlapCopyCommunication< int, int > Comm
Definition: FlexibleSolver_impl.hpp:270
Definition: GlobalWellInfo.hpp:53
bool in_injecting_group(const std::string &wname) const
void update_producer(std::size_t well_index, WellStatus well_status, WellProducerCMode production_cmode)
const std::string & well_name(std::size_t well_index) const
bool in_producing_group(const std::string &wname) const
GlobalWellInfo(const Schedule &sched, std::size_t report_step, const std::vector< Well > &local_wells)
std::size_t well_index(const std::string &wname) const
void communicate(const Comm &comm)
Definition: GlobalWellInfo.hpp:62
void update_injector(std::size_t well_index, WellStatus well_status, WellInjectorCMode injection_cmode)
Definition: BlackoilPhases.hpp:27