RSTConv.hpp
Go to the documentation of this file.
1/*
2 Copyright 2023 SINTEF Digital
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_RST_CONV_HEADER_INCLUDED
21#define OPM_RST_CONV_HEADER_INCLUDED
22
23#include <array>
24#include <functional>
25#include <vector>
26
28
29namespace Opm {
30
31namespace data { class Solution; }
32class RSTConfig;
33
36{
37public:
38 using LocalToGlobalCellFunc = std::function<int(const int)>;
44 : globalCell_(std::move(globalCell))
45 , comm_(comm)
46 {}
47
52 void init(const std::size_t numCells,
53 const RSTConfig& rst_config,
54 const std::array<int,6>& compIdx);
55
57 void outputRestart(data::Solution& sol);
58
60 template<class ResidualVector>
61 void update(const ResidualVector& resid);
62
64 void updateNewton(const std::vector<int>& convNewt);
65
67 const std::vector<std::vector<int>>& getData() const
68 { return cnv_X_; }
69
71 const std::vector<int>& getConvNew() const
72 { return conv_new_; }
73
75 bool hasConv() const;
76
79
80private:
86 template<class ResidualVector>
87 void gatherAndAccumulate(const std::vector<int>& lIdx,
88 const ResidualVector& resid, int comp);
89
90 LocalToGlobalCellFunc globalCell_;
92 std::vector<std::vector<int>> cnv_X_{};
93 std::vector<int> conv_new_{};
94 std::array<int,6> compIdx_{};
95 int N_ = 0;
96};
97
98} // namespace Opm
99
100#endif // OPM_RST_CONV_HEADER_INCLUDED
Class computing RPTRST CONV output.
Definition: RSTConv.hpp:36
void outputRestart(data::Solution &sol)
Inserts the CONV output into the restart output container.
void updateNewton(const std::vector< int > &convNewt)
Adds the CONV_NEW output.
bool hasConv() const
Check if CONV is required.
const std::vector< std::vector< int > > & getData() const
Obtain a const-ref to the accumulated data (only used for unit testing).
Definition: RSTConv.hpp:67
void update(const ResidualVector &resid)
Adds the CONV output for given residual vector.
void prepareConv()
CONV_NEW is restarted at iteration 0.
const std::vector< int > & getConvNew() const
Obtain a const-ref to the CONV_NEW (only used for unit testing).
Definition: RSTConv.hpp:71
RSTConv(LocalToGlobalCellFunc globalCell, Parallel::Communication comm)
Constructor.
Definition: RSTConv.hpp:42
void init(const std::size_t numCells, const RSTConfig &rst_config, const std::array< int, 6 > &compIdx)
Init state at beginning of step.
std::function< int(const int)> LocalToGlobalCellFunc
Definition: RSTConv.hpp:38
Dune::Communication< MPIComm > Communication
Definition: ParallelCommunication.hpp:30
Definition: blackoilboundaryratevector.hh:39