WellConnections.hpp
1 /*
2  Copyright 2016 Dr. Blatt - HPC-Simulation-Software & Services.
3  Copyright 2016 Statoil AS
4 
5  This file is part of The Open Porous Media project (OPM).
6 
7  OPM is free software: you can redistribute it and/or modify
8  it under the terms of the GNU General Public License as published by
9  the Free Software Foundation, either version 3 of the License, or
10  (at your option) any later version.
11 
12  OPM is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with OPM. If not, see <http://www.gnu.org/licenses/>.
19 */
20 #ifndef DUNE_CPGRID_WELL_CONNECTIONS_HEADER_INCLUDED
21 #define DUNE_CPGRID_WELL_CONNECTIONS_HEADER_INCLUDED
22 
23 #include <set>
24 #include <unordered_set>
25 #include <vector>
26 
27 #ifdef HAVE_MPI
28 #include <opm/grid/utility/platform_dependent/disable_warnings.h>
29 #include "mpi.h"
30 #include <opm/grid/utility/platform_dependent/reenable_warnings.h>
31 #endif
32 
33 #include <dune/common/parallel/mpicollectivecommunication.hh>
34 
35 #include <opm/grid/utility/OpmParserIncludes.hpp>
36 
37 namespace Dune
38 {
39 namespace cpgrid
40 {
41 
49 {
50 
51 public:
53  typedef std::vector<std::set<int> >::const_iterator const_iterator;
54 
57 
58  WellConnections() = default;
59 
66  WellConnections(const OpmEclipseStateType& eclipseState,
67  const std::array<int, 3>& cartesianSize,
68  const std::vector<int>& cartesian_to_compressed);
69 
76  void init(const OpmEclipseStateType& eclipseState,
77  const std::array<int, 3>& cartesianSize,
78  const std::vector<int>& cartesian_to_compressed);
79 
84  const std::set<int>& operator[](std::size_t i) const
85  {
86  return well_indices_[i];
87  }
88 
91  {
92  return well_indices_.begin();
93  }
94 
97  {
98  return well_indices_.end();
99  }
100 
102  std::size_t size() const
103  {
104  return well_indices_.size();
105  }
106 private:
109  std::vector<std::set<int> > well_indices_;
110 };
111 
120 std::vector<std::vector<int> >
121 postProcessPartitioningForWells(std::vector<int>& parts,
122  const OpmEclipseStateType& eclipseState,
123  const WellConnections& well_connections,
124  std::size_t no_procs);
125 
126 #ifdef HAVE_MPI
127 std::unordered_set<std::string>
134 computeDefunctWellNames(const std::vector<std::vector<int> >& wells_on_proc,
135  const OpmEclipseStateType& eclipseState,
136  const CollectiveCommunication<MPI_Comm>& cc,
137  int root);
138 #endif
139 } // end namespace cpgrid
140 } // end namespace Dune
141 #endif
const_iterator end() const
Get the end iterator.
Definition: WellConnections.hpp:96
Holds the implementation of the CpGrid as a pimple.
Definition: OpmParserIncludes.hpp:42
const_iterator begin() const
Get a begin iterator.
Definition: WellConnections.hpp:90
const_iterator iterator
The iterator type (always const).
Definition: WellConnections.hpp:56
void init(const OpmEclipseStateType &eclipseState, const std::array< int, 3 > &cartesianSize, const std::vector< int > &cartesian_to_compressed)
Initialze the data of the container.
Definition: WellConnections.cpp:41
const std::set< int > & operator[](std::size_t i) const
Access all connections of a well.
Definition: WellConnections.hpp:84
std::size_t size() const
Get the number of wells
Definition: WellConnections.hpp:102
std::vector< std::set< int > >::const_iterator const_iterator
The const iterator type.
Definition: WellConnections.hpp:53
A class calculating and representing all connections of wells.
Definition: WellConnections.hpp:48