19#ifndef OPM_CUISTL_GPUBLOCKPRECONDITIONER_HPP
20#define OPM_CUISTL_GPUBLOCKPRECONDITIONER_HPP
22#include <dune/common/shared_ptr.hh>
24#include <opm/simulators/linalg/PreconditionerWithUpdate.hpp>
25#include <opm/simulators/linalg/gpuistl/PreconditionerHolder.hpp>
26#include <opm/simulators/linalg/gpuistl/detail/preconditioner_should_call_post_pre.hpp>
33template <
class X,
class Y,
class C,
class P = Dune::PreconditionerWithUpdate<X, Y>>
37 using domain_type = X;
39 using field_type =
typename X::field_type;
40 using communication_type = C;
58 , m_communication(Dune::stackobject_to_shared_ptr(c))
65 virtual void pre(X& x, Y& b)
override
68 m_communication->copyOwnerToAll(x, x);
70 m_preconditioner->pre(x, b);
77 virtual void apply(X& v,
const Y& d)
override
79 m_preconditioner->apply(v, d);
80 m_communication->copyOwnerToAll(v, v);
84 virtual void update()
override
86 m_preconditioner->update();
89 virtual void post(X& x)
override
92 m_preconditioner->post(x);
97 virtual Dune::SolverCategory::Category
category()
const override
99 return Dune::SolverCategory::overlapping;
102 static constexpr bool shouldCallPre()
106 static constexpr bool shouldCallPost()
113 return m_preconditioner;
116 virtual bool hasPerfectUpdate()
const override {
123 std::shared_ptr<P> m_preconditioner;
126 std::shared_ptr<const communication_type> m_communication;
Interface class adding the update() method to the preconditioner interface.
Definition PreconditionerWithUpdate.hpp:32
Is an adaptation of Dune::BlockPreconditioner that works within the CuISTL framework.
Definition GpuBlockPreconditioner.hpp:35
virtual Dune::SolverCategory::Category category() const override
Category of the preconditioner (see SolverCategory::Category)
Definition GpuBlockPreconditioner.hpp:97
virtual void apply(X &v, const Y &d) override
Apply the preconditioner.
Definition GpuBlockPreconditioner.hpp:77
virtual void pre(X &x, Y &b) override
Prepare the preconditioner.
Definition GpuBlockPreconditioner.hpp:65
virtual std::shared_ptr< Dune::PreconditionerWithUpdate< X, Y > > getUnderlyingPreconditioner() override
getUnderlyingPreconditioner gets the underlying preconditioner (preconditioner being held)
Definition GpuBlockPreconditioner.hpp:111
GpuBlockPreconditioner(const std::shared_ptr< P > &p, const std::shared_ptr< const communication_type > &c)
Constructor.
Definition GpuBlockPreconditioner.hpp:50
Common interface for adapters that hold preconditioners.
Definition PreconditionerHolder.hpp:34
constexpr bool shouldCallPreconditionerPost()
Tests (compile time) if the preconditioner type needs to call post() after a call to apply(....
Definition preconditioner_should_call_post_pre.hpp:52
constexpr bool shouldCallPreconditionerPre()
Tests (compile time) if the preconditioner type needs to call pre() before a call to apply()
Definition preconditioner_should_call_post_pre.hpp:34