opm-simulators
GlobalWellInfo.hpp
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 <cstdint>
25 #include <map>
26 #include <string>
27 #include <vector>
28 
29 namespace Opm {
30 
31 class Schedule;
32 class Well;
33 enum class WellInjectorCMode : std::uint16_t;
34 enum class WellProducerCMode : std::uint16_t;
35 enum class WellStatus : std::uint8_t;
36 
37 
38 /*
39  The context of the GlobalWellInfo class is the situation where the wells are
40  distributed among different processors. Most well processing only considers
41  the wells defined on the local process, but in some cases we need global
42  information about all the wells. This class maintains the following:
43 
44  - Mapping between global well index and well name.
45 
46  - Mapping between local well index and global index (only used internally in
47  class).
48 
49  - Functionality to query well whether it is currently injecting or producing
50  under group control.
51 */
52 
53 template<class Scalar>
55 public:
56 
57 
58  /*
59  Will sum the m_in_injecting_group and m_in_producing_group vectors across
60  all processes, so that all processes can query for an arbitrary well.
61  */
62  template <typename Comm>
63  void communicate(const Comm& comm) {
64  auto size = this->m_in_injecting_group.size();
65  comm.sum( this->m_in_injecting_group.data(), size);
66  comm.sum( this->m_in_producing_group.data(), size);
67  comm.sum( this->m_is_open.data(), size);
68  comm.min( this->m_efficiency_scaling_factors.data(), size);
69  is_rank0_ = (comm.rank() == 0);
70  }
71 
72 
73 
74  GlobalWellInfo(const Schedule& sched, std::size_t report_step, const std::vector<Well>& local_wells);
75  bool in_producing_group(const std::string& wname) const;
76  bool in_injecting_group(const std::string& wname) const;
77  bool is_open(const std::string& wname) const;
78  std::size_t well_index(const std::string& wname) const;
79  const std::string& well_name(std::size_t well_index) const;
80  void update_injector(std::size_t well_index, WellStatus well_status, WellInjectorCMode injection_cmode);
81  void update_producer(std::size_t well_index, WellStatus well_status, WellProducerCMode production_cmode);
82  void update_efficiency_scaling_factor(std::size_t well_index, const Scalar efficiency_scaling_factor);
83  Scalar efficiency_scaling_factor(const std::string& wname) const;
84  void clear();
85  bool isRank0() const;
86 
87 private:
88  std::vector<std::size_t> local_map; // local_index -> global_index
89 
90  std::map<std::string, std::size_t> name_map; // string -> global_index
91  std::vector<int> m_in_injecting_group; // global_index -> int/bool
92  std::vector<int> m_in_producing_group; // global_index -> int/bool
93  std::vector<int> m_is_open; // global_index -> int/bool
94  std::vector<Scalar> m_efficiency_scaling_factors; // global_index --> double
95  bool is_rank0_{true};
96 };
97 
98 
99 }
100 
101 #endif
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: blackoilbioeffectsmodules.hh:45
Definition: GlobalWellInfo.hpp:54