FlexibleSolverWrapper.hpp
Go to the documentation of this file.
1/*
2 Copyright 2025 Equinor ASA
3
4 This file is part of the Open Porous Media project (OPM).
5 OPM is free software: you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
9 OPM is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 You should have received a copy of the GNU General Public License
14 along with OPM. If not, see <http://www.gnu.org/licenses/>.
15*/
16
17#ifndef OPM_FLEXIBLESOLVERWRAPPER_HEADER_INCLUDED
18#define OPM_FLEXIBLESOLVERWRAPPER_HEADER_INCLUDED
19
20#include <functional>
21
22
23#include <dune/istl/operators.hh>
24#include <dune/istl/solver.hh>
27
29{
30
40template <class Matrix, class Vector, class Comm>
42{
43public:
44 using AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
46 using AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
47
48 using AbstractOperatorPtrType = std::unique_ptr<AbstractOperatorType>;
49 using AbstractSolverPtrType = std::unique_ptr<AbstractSolverType>;
50
51 FlexibleSolverWrapper(const Matrix& matrix,
52 bool parallel,
53 const PropertyTree& prm,
54 std::size_t pressureIndex,
55 const std::function<Vector()>& weightCalculator,
56 bool forceSerial,
57 const Comm* comm);
58
59 void update();
60
61 void apply(Vector& x, Vector& y, Dune::InverseOperatorResult& result);
62
63private:
64 AbstractOperatorPtrType m_operator;
65 AbstractSolverPtrType m_solver;
66
67 AbstractPreconditionerType& m_preconditioner;
68
70 std::tuple<AbstractOperatorPtrType, AbstractSolverPtrType, std::reference_wrapper<AbstractPreconditionerType>>&&
71 solverTuple);
72};
73} // namespace Opm::gpuistl::detail
74
75#endif // OPM_FLEXIBLESOLVERWRAPPER_HEADER_INCLUDED
Dune::OwnerOverlapCopyCommunication< int, int > Comm
Definition: FlexibleSolver_impl.hpp:304
Interface class adding the update() method to the preconditioner interface.
Definition: PreconditionerWithUpdate.hpp:32
Hierarchical collection of key/value pairs.
Definition: PropertyTree.hpp:39
FlexibleSolverWrapper is compilational trick to reduce compile time overhead.
Definition: FlexibleSolverWrapper.hpp:42
Dune::InverseOperator< Vector, Vector > AbstractSolverType
Definition: FlexibleSolverWrapper.hpp:44
std::unique_ptr< AbstractOperatorType > AbstractOperatorPtrType
Definition: FlexibleSolverWrapper.hpp:48
std::unique_ptr< AbstractSolverType > AbstractSolverPtrType
Definition: FlexibleSolverWrapper.hpp:49
Dune::AssembledLinearOperator< Matrix, Vector, Vector > AbstractOperatorType
Definition: FlexibleSolverWrapper.hpp:46
FlexibleSolverWrapper(const Matrix &matrix, bool parallel, const PropertyTree &prm, std::size_t pressureIndex, const std::function< Vector()> &weightCalculator, bool forceSerial, const Comm *comm)
void apply(Vector &x, Vector &y, Dune::InverseOperatorResult &result)
Definition: autotuner.hpp:30
Dune::InverseOperatorResult InverseOperatorResult
Definition: GpuBridge.hpp:32