19#ifndef OPM_PRECONDITIONERCPUMATRIXTOGPUMATRIX_HPP
20#define OPM_PRECONDITIONERCPUMATRIXTOGPUMATRIX_HPP
21#include "opm/simulators/linalg/gpuistl/GpuSparseMatrixWrapper.hpp"
22#include <dune/istl/preconditioner.hh>
23#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
24#include <opm/simulators/linalg/gpuistl/GpuVector.hpp>
25#include <opm/simulators/linalg/gpuistl/PreconditionerHolder.hpp>
26#include <opm/simulators/linalg/gpuistl/detail/preconditioner_should_call_post_pre.hpp>
40template <
class X,
class Y,
class CudaPreconditionerType,
class CPUMatrixType>
52 template <
typename...
Args>
56 , m_underlyingPreconditioner(m_gpuMatrix, std::
forward<
Args>(args)...)
66 static_assert(!detail::shouldCallPreconditionerPre<CudaPreconditionerType>(),
67 "We currently do not support Preconditioner::pre().");
76 m_underlyingPreconditioner.apply(
v,
d);
85 static_assert(!detail::shouldCallPreconditionerPost<CudaPreconditionerType>(),
86 "We currently do not support Preconditioner::post().");
91 Dune::SolverCategory::Category
category()
const override
93 return m_underlyingPreconditioner.category();
101 m_underlyingPreconditioner.update();
104 static constexpr bool shouldCallPre()
106 return detail::shouldCallPreconditionerPost<CudaPreconditionerType>();
108 static constexpr bool shouldCallPost()
110 return detail::shouldCallPreconditionerPre<CudaPreconditionerType>();
113 virtual bool hasPerfectUpdate()
const override
115 return m_underlyingPreconditioner.hasPerfectUpdate();
120 GpuSparseMatrixWrapper<field_type> m_gpuMatrix;
Interface class adding the update() method to the preconditioner interface.
Definition PreconditionerWithUpdate.hpp:32
The GpuSparseMatrixWrapper Checks CUDA/HIP version and dispatches a version either using the old or t...
Definition GpuSparseMatrixWrapper.hpp:61
void updateNonzeroValues(const MatrixType &matrix, bool copyNonZeroElementsDirectly=false)
updateNonzeroValues updates the non-zero values by using the non-zero values of the supplied matrix
Definition GpuSparseMatrixWrapper.hpp:374
Convert a CPU matrix to a GPU matrix and use a CUDA preconditioner on the GPU.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:42
void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:64
void apply(X &v, const Y &d) override
Apply the preconditoner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:74
void post(X &x) override
Clean up.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:83
Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:91
void update() override
Copies the CPU matrix to the GPU matrix then calls the GPU preconditioner update function.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:98
Y range_type
The range type of the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:47
X domain_type
The domain type of the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:45
typename X::field_type field_type
The field type of the preconditioner.
Definition PreconditionerCPUMatrixToGPUMatrix.hpp:49
constexpr auto getPropValue()
get the value data member of a property
Definition propertysystem.hh:240