opm-simulators
Toggle main menu visibility
Loading...
Searching...
No Matches
FlexibleSolverWrapper.hpp
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
#include <memory>
22
#include <type_traits>
23
24
#include <dune/common/parallel/communication.hh>
25
#include <dune/istl/operators.hh>
26
#include <dune/istl/solver.hh>
27
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
28
#include <opm/simulators/linalg/PropertyTree.hpp>
29
#include <opm/simulators/linalg/gpuistl/GpuOwnerOverlapCopy.hpp>
30
31
namespace
Opm::gpuistl::detail
32
{
33
43
template
<
class
Matrix,
class
Vector,
class
Comm>
44
class
FlexibleSolverWrapper
45
{
46
public
:
47
using
AbstractSolverType = Dune::InverseOperator<Vector, Vector>;
48
using
AbstractPreconditionerType =
Dune::PreconditionerWithUpdate<Vector, Vector>
;
49
using
AbstractOperatorType = Dune::AssembledLinearOperator<Matrix, Vector, Vector>;
50
51
using
AbstractOperatorPtrType = std::unique_ptr<AbstractOperatorType>;
52
using
AbstractSolverPtrType = std::unique_ptr<AbstractSolverType>;
53
using
GpuCommunicationType = std::conditional_t<
54
std::is_same_v<Comm, Dune::Communication<int>>,
55
int,
// Dummy type for serial case
56
GpuOwnerOverlapCopy<typename Matrix::field_type, Comm>
>;
57
58
FlexibleSolverWrapper(
const
Matrix& matrix,
59
bool
parallel,
60
const
PropertyTree
& prm,
61
std::size_t pressureIndex,
62
const
std::function<Vector()>& weightCalculator,
63
bool
forceSerial,
64
const
Comm* comm);
65
66
void
update();
67
68
void
apply(Vector& x, Vector& y, Dune::InverseOperatorResult& result);
69
70
private
:
71
AbstractOperatorPtrType m_operator;
72
AbstractSolverPtrType m_solver;
73
74
AbstractPreconditionerType& m_preconditioner;
75
std::shared_ptr<GpuCommunicationType> m_gpuCommunication;
76
77
FlexibleSolverWrapper(
78
std::tuple<AbstractOperatorPtrType, AbstractSolverPtrType, std::reference_wrapper<AbstractPreconditionerType>, std::shared_ptr<GpuCommunicationType>>&&
79
solverTuple);
80
};
81
}
// namespace Opm::gpuistl::detail
82
83
#endif
// OPM_FLEXIBLESOLVERWRAPPER_HEADER_INCLUDED
Dune::PreconditionerWithUpdate
Interface class adding the update() method to the preconditioner interface.
Definition
PreconditionerWithUpdate.hpp:32
Opm::PropertyTree
Hierarchical collection of key/value pairs.
Definition
PropertyTree.hpp:39
Opm::gpuistl::GpuOwnerOverlapCopy
CUDA compatiable variant of Dune::OwnerOverlapCopyCommunication.
Definition
GpuOwnerOverlapCopy.hpp:55
Opm::gpuistl::detail
Contains wrappers to make the CuBLAS library behave as a modern C++ library with function overlading.
Definition
autotuner.hpp:30
opm
simulators
linalg
gpuistl
detail
FlexibleSolverWrapper.hpp
Generated by
1.17.0