Loading...
Searching...
No Matches
GpuJac.hpp
/*
Copyright 2022-2023 SINTEF AS
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_GPUJAC_HPP
#define OPM_GPUJAC_HPP
#include <dune/istl/preconditioner.hh>
#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
#include <opm/simulators/linalg/gpuistl/GpuSparseMatrixWrapper.hpp>
#include <opm/simulators/linalg/gpuistl/detail/CuMatrixDescription.hpp>
#include <opm/simulators/linalg/gpuistl/detail/CuSparseHandle.hpp>
#include <opm/simulators/linalg/gpuistl/detail/CuSparseResource.hpp>
namespace Opm::gpuistl
{
template <class M, class X, class Y, int l = 1>
class GpuJac : public Dune::PreconditionerWithUpdate<X, Y>
{
public:
using matrix_type = typename std::remove_const<M>::type;
using domain_type = X;
using range_type = Y;
using field_type = typename X::field_type;
GpuJac(const M& A, field_type w);
virtual void pre(X& x, Y& b) override;
virtual void apply(X& v, const Y& d) override;
virtual void post(X& x) override;
virtual Dune::SolverCategory::Category category() const override;
virtual void update() override;
static constexpr bool shouldCallPre()
{
return false;
}
static constexpr bool shouldCallPost()
{
return false;
}
virtual bool hasPerfectUpdate() const override {
return true;
}
private:
const M& m_matrix;
const field_type m_relaxationFactor;
GpuVector<field_type> m_diagInvFlattened;
void invertDiagonalAndFlatten();
template<int blocksize>
void dispatchInvertDiagonalAndFlatten();
};
} // end namespace Opm::gpuistl
#endif
Dune::PreconditionerWithUpdate
Interface class adding the update() method to the preconditioner interface.
Definition PreconditionerWithUpdate.hpp:32
Opm::gpuistl::GpuJac::field_type
typename X::field_type field_type
The field type of the preconditioner.
Definition GpuJac.hpp:56
Opm::gpuistl::GpuJac::range_type
Y range_type
The range type of the preconditioner.
Definition GpuJac.hpp:54
Opm::gpuistl::GpuJac::update
virtual void update() override
Updates the matrix data.
Definition GpuJac.cpp:78
Opm::gpuistl::GpuJac::pre
virtual void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition GpuJac.cpp:46
Opm::gpuistl::GpuJac::shouldCallPre
static constexpr bool shouldCallPre()
Definition GpuJac.hpp:85
Opm::gpuistl::GpuJac::GpuJac
GpuJac(const M &A, field_type w)
Constructor.
Definition GpuJac.cpp:34
Opm::gpuistl::GpuJac::post
virtual void post(X &x) override
Post processing.
Definition GpuJac.cpp:65
Opm::gpuistl::GpuJac::apply
virtual void apply(X &v, const Y &d) override
Apply the preconditoner.
Definition GpuJac.cpp:52
Opm::gpuistl::GpuJac::category
virtual Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category).
Definition GpuJac.cpp:71
Opm::gpuistl::GpuJac::shouldCallPost
static constexpr bool shouldCallPost()
Definition GpuJac.hpp:91
Opm::gpuistl::GpuJac::domain_type
X domain_type
The domain type of the preconditioner.
Definition GpuJac.hpp:52
Opm::gpuistl::GpuJac::matrix_type
typename std::remove_const< M >::type matrix_type
The matrix type the preconditioner is for.
Definition GpuJac.hpp:50