opm-common
PAvgCalculatorCollection.hpp
1 /*
2  Copyright 2020, 2023 Equinor 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 PAVE_CALC_COLLECTIONHPP
21 #define PAVE_CALC_COLLECTIONHPP
22 
23 #include <cstddef>
24 #include <functional>
25 #include <memory>
26 #include <unordered_map>
27 #include <vector>
28 
29 namespace Opm {
30  template<class Scalar> class PAvgCalculator;
31 } // namespace Opm
32 
33 namespace Opm {
34 
36 template<class Scalar>
38 {
39 public:
44  using CalculatorPtr = std::unique_ptr<PAvgCalculator<Scalar>>;
45 
56  using ActivePredicate = std::function<
57  std::vector<bool>(const std::vector<std::size_t>&)>;
58 
60  PAvgCalculatorCollection() = default;
61 
63  ~PAvgCalculatorCollection() = default;
64 
67 
70 
73 
76 
87  std::size_t setCalculator(const std::size_t wellID, CalculatorPtr calculator);
88 
99 
106  PAvgCalculator<Scalar>& operator[](const std::size_t i);
107 
114  const PAvgCalculator<Scalar>& operator[](const std::size_t i) const;
115 
117  bool empty() const;
118 
120  std::size_t numCalculators() const;
121 
126  std::vector<std::size_t> allWBPCells() const;
127 
128 private:
130  using CalcIndex = typename std::vector<CalculatorPtr>::size_type;
131 
133  std::unordered_map<std::size_t, CalcIndex> index_{};
134 
136  std::vector<CalculatorPtr> calculators_{};
137 };
138 
139 } // namespace Opm
140 
141 #endif // PAVE_CALC_COLLECTIONHPP
PAvgCalculator< Scalar > & operator[](const std::size_t i)
Access mutable WBPn calculation object.
Definition: PAvgCalculatorCollection.cpp:88
std::size_t numCalculators() const
Number of WBPn calculation objects owned by this collection.
Definition: PAvgCalculatorCollection.cpp:107
std::unique_ptr< PAvgCalculator< Scalar > > CalculatorPtr
Wrapper for a WBPn calclation object.
Definition: PAvgCalculatorCollection.hpp:44
std::function< std::vector< bool >(const std::vector< std::size_t > &)> ActivePredicate
Predicate for whether or not a particular source location is active.
Definition: PAvgCalculatorCollection.hpp:57
std::vector< std::size_t > allWBPCells() const
Union of all distinct/unique cells/source locations contributing to this complete collection of WBPn ...
Definition: PAvgCalculatorCollection.cpp:114
This class implements a small container which holds the transmissibility mulitpliers for all the face...
Definition: Exceptions.hpp:30
void pruneInactiveWBPCells(ActivePredicate isActive)
Discard inactive source locations from all WBPn calculation objects.
Definition: PAvgCalculatorCollection.cpp:61
std::size_t setCalculator(const std::size_t wellID, CalculatorPtr calculator)
Assign/register a WBPn calculation object for a single well.
Definition: PAvgCalculatorCollection.cpp:40
bool empty() const
Whether or not this collection has any WBPn calculation objects.
Definition: PAvgCalculatorCollection.cpp:101
Facility for deriving well-level pressure values from selected block-averaging procedures.
Definition: PAvgCalculator.hpp:137
PAvgCalculatorCollection()=default
Default constructor.
PAvgCalculatorCollection & operator=(const PAvgCalculatorCollection &)=delete
Assignment operator.
~PAvgCalculatorCollection()=default
Destructor.
Collection of WBPn calculation objects, one for each well.
Definition: PAvgCalculatorCollection.hpp:37