My Project
Loading...
Searching...
No Matches
ParallelPAvgDynamicSourceData.hpp
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
25#include <opm/simulators/utils/ParallelCommunication.hpp>
26
27#include <cstddef>
28#include <functional>
29#include <vector>
30
31namespace Opm {
32
35template<class Scalar>
36class ParallelPAvgDynamicSourceData : public PAvgDynamicSourceData<Scalar>
37{
38public:
42 using GlobalToLocal = std::function<int(const std::size_t)>;
43
51 template <typename T>
52 using SourceDataSpan = typename
53 PAvgDynamicSourceData<Scalar>::template SourceDataSpan<T>;
54
64 using Evaluator = std::function<void(int, SourceDataSpan<Scalar>)>;
65
78 ParallelPAvgDynamicSourceData(const Parallel::Communication& comm,
79 const std::vector<std::size_t>& sourceLocations,
81
86 void setToZero();
87
101 void reconstruct(const std::vector<std::size_t>& sourceLocations,
103
109
112 void synchroniseSources();
113
114private:
116 struct LocalLocation
117 {
119 std::size_t ix{};
120
122 int cell{};
123 };
124
126 std::reference_wrapper<const Parallel::Communication> comm_;
127
129 std::vector<LocalLocation> locations_{};
130
132 std::vector<Scalar> localSrc_{};
133
136 std::vector<typename std::vector<Scalar>::size_type> storageIndex_{};
137
139 std::vector<int> allSizes_{}; // Type int to meet API requirements.
140
142 std::vector<int> startPointers_{}; // Type int to meet API requirements.
143
151 [[nodiscard]] typename std::vector<Scalar>::size_type
152 storageIndex(typename std::vector<Scalar>::size_type elemIndex) const override;
153
166 void finaliseConstruction(const std::vector<std::size_t>& sourceLocations,
168
175 localSourceTerm(const std::size_t localIx);
176
180 void defineCommunication();
181};
182
183} // namespace Opm
184
185#endif // PARALLEL_PAVG_DYNAMIC_SOURCE_DATA_HPP
Dynamic source data for block-average pressure calculations.
Definition ParallelPAvgDynamicSourceData.hpp:37
std::function< void(int, SourceDataSpan< Scalar >)> Evaluator
Collect source term contributions from local, on-rank, cell.
Definition ParallelPAvgDynamicSourceData.hpp:64
typename PAvgDynamicSourceData< Scalar >::template SourceDataSpan< T > SourceDataSpan
Fixed-width span/view of a underlying range of contiguous elements.
Definition ParallelPAvgDynamicSourceData.hpp:53
void setToZero()
Clear contents of local source term contributions.
Definition ParallelPAvgDynamicSourceData.cpp:48
void synchroniseSources()
Exchange local contributions to build full, global view of all source terms.
Definition ParallelPAvgDynamicSourceData.cpp:73
std::function< int(const std::size_t)> GlobalToLocal
Translate globally unique, linearised Cartesian cell indices to local, on-rank, cell indices.
Definition ParallelPAvgDynamicSourceData.hpp:42
void collectLocalSources(Evaluator eval)
Compute local, on-rank, contributions to the collection of source terms.
Definition ParallelPAvgDynamicSourceData.cpp:63
void reconstruct(const std::vector< std::size_t > &sourceLocations, GlobalToLocal localCellIdx)
Reconstruct Source Data backing storage and internal mapping tables.
Definition ParallelPAvgDynamicSourceData.cpp:55
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilboundaryratevector.hh:37
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:242