Loading...
Searching...
No Matches
RSTConv.hpp
/*
Copyright 2023 SINTEF Digital
This file is part of the Open Porous Media project (OPM).
OPM is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OPM is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OPM. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef OPM_RST_CONV_HEADER_INCLUDED
#define OPM_RST_CONV_HEADER_INCLUDED
#include <array>
#include <functional>
#include <vector>
#include <opm/simulators/utils/ParallelCommunication.hpp>
namespace Opm {
namespace data { class Solution; }
class RSTConfig;
class RSTConv
{
public:
using LocalToGlobalCellFunc = std::function<int(const int)>;
RSTConv(LocalToGlobalCellFunc globalCell,
Parallel::Communication comm)
: globalCell_(std::move(globalCell))
, comm_(comm)
{}
void init(const std::size_t numCells,
const RSTConfig& rst_config,
const std::array<int,6>& compIdx);
void outputRestart(data::Solution& sol);
template<class ResidualVector>
void update(const ResidualVector& resid);
void updateNewton(const std::vector<int>& convNewt);
const std::vector<std::vector<int>>& getData() const
{ return cnv_X_; }
const std::vector<int>& getConvNew() const
{ return conv_new_; }
bool hasConv() const;
void prepareConv();
private:
template<class ResidualVector>
void gatherAndAccumulate(const std::vector<int>& lIdx,
const ResidualVector& resid, int comp);
LocalToGlobalCellFunc globalCell_;
Parallel::Communication comm_;
std::vector<std::vector<int>> cnv_X_{};
std::vector<int> conv_new_{};
std::array<int,6> compIdx_{};
int N_ = 0;
};
} // namespace Opm
#endif // OPM_RST_CONV_HEADER_INCLUDED
Opm::RSTConv::outputRestart
void outputRestart(data::Solution &sol)
Inserts the CONV output into the restart output container.
Definition RSTConv.cpp:61
Opm::RSTConv::updateNewton
void updateNewton(const std::vector< int > &convNewt)
Adds the CONV_NEW output.
Definition RSTConv.cpp:88
Opm::RSTConv::hasConv
bool hasConv() const
Check if CONV is required.
Definition RSTConv.cpp:78
Opm::RSTConv::getData
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
Opm::RSTConv::update
void update(const ResidualVector &resid)
Adds the CONV output for given residual vector.
Definition RSTConv.cpp:114
Opm::RSTConv::prepareConv
void prepareConv()
CONV_NEW is restarted at iteration 0.
Definition RSTConv.cpp:83
Opm::RSTConv::getConvNew
const std::vector< int > & getConvNew() const
Obtain a const-ref to the CONV_NEW (only used for unit testing).
Definition RSTConv.hpp:71
Opm::RSTConv::RSTConv
RSTConv(LocalToGlobalCellFunc globalCell, Parallel::Communication comm)
Constructor.
Definition RSTConv.hpp:42
Opm::RSTConv::init
void init(const std::size_t numCells, const RSTConfig &rst_config, const std::array< int, 6 > &compIdx)
Init state at beginning of step.
Definition RSTConv.cpp:37
Opm
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition blackoilbioeffectsmodules.hh:43