ParallelPAvgDynamicSourceData.hpp
Go to the documentation of this file.
1/*
2 Copyright 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 PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
21#define PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
22
23#include <opm/input/eclipse/Schedule/Well/PAvgDynamicSourceData.hpp>
24
26
27#include <cstddef>
28#include <functional>
29#include <vector>
30
31namespace Opm {
32
35class ParallelPAvgDynamicSourceData : public PAvgDynamicSourceData
36{
37public:
41 using GlobalToLocal = std::function<int(const std::size_t)>;
42
52 using Evaluator = std::function<void(int, SourceDataSpan<double>)>;
53
67 const std::vector<std::size_t>& sourceLocations,
68 GlobalToLocal localCellIdx);
69
74 void setToZero();
75
89 void reconstruct(const std::vector<std::size_t>& sourceLocations,
90 GlobalToLocal localCellIdx);
91
97
101
102private:
104 struct LocalLocation
105 {
107 std::size_t ix{};
108
110 int cell{};
111 };
112
114 std::reference_wrapper<const Parallel::Communication> comm_;
115
117 std::vector<LocalLocation> locations_{};
118
120 std::vector<double> localSrc_{};
121
124 std::vector<std::vector<double>::size_type> storageIndex_{};
125
127 std::vector<int> allSizes_{}; // Type int to meet API requirements.
128
130 std::vector<int> startPointers_{}; // Type int to meet API requirements.
131
139 [[nodiscard]] std::vector<double>::size_type
140 storageIndex(std::vector<double>::size_type elemIndex) const override;
141
154 void finaliseConstruction(const std::vector<std::size_t>& sourceLocations,
155 GlobalToLocal localCellIdx);
156
162 [[nodiscard]] SourceDataSpan<double>
163 localSourceTerm(const std::size_t localIx);
164
168 void defineCommunication();
169};
170
171} // namespace Opm
172
173#endif // PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
Definition: ParallelPAvgDynamicSourceData.hpp:36
ParallelPAvgDynamicSourceData(const Parallel::Communication &comm, const std::vector< std::size_t > &sourceLocations, GlobalToLocal localCellIdx)
void collectLocalSources(Evaluator eval)
void reconstruct(const std::vector< std::size_t > &sourceLocations, GlobalToLocal localCellIdx)
std::function< void(int, SourceDataSpan< double >)> Evaluator
Definition: ParallelPAvgDynamicSourceData.hpp:52
std::function< int(const std::size_t)> GlobalToLocal
Definition: ParallelPAvgDynamicSourceData.hpp:41
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: BlackoilPhases.hpp:27