20#ifndef OPM_PRESSURE_SOLVER_POLICY_HEADER_INCLUDED
21#define OPM_PRESSURE_SOLVER_POLICY_HEADER_INCLUDED
26#include <dune/istl/solver.hh>
27#include <dune/istl/owneroverlapcopy.hh>
33 template <
class OperatorType,
class Solver,
class LevelTransferPolicy>
49 using X =
typename Operator::range_type;
56 struct PressureInverseOperator :
public Dune::InverseOperator<X, X>
59 template <
typename GlobalIndex,
typename LocalIndex>
60 PressureInverseOperator(
Operator& op,
62 const Dune::OwnerOverlapCopyCommunication<GlobalIndex, LocalIndex>& comm)
65 assert(op.category() == Dune::SolverCategory::overlapping);
68 linsolver_ = std::make_unique<Solver>(op, comm, prm, std::function<X()>(),
73 PressureInverseOperator(
Operator& op,
75 const SequentialInformation&)
78 assert(op.category() != Dune::SolverCategory::overlapping);
81 linsolver_ = std::make_unique<Solver>(op, prm, std::function<X()>(),
86 Dune::SolverCategory::Category category()
const override
88 return linsolver_->category();
91 bool hasPerfectUpdate()
const
93 return linsolver_->preconditioner().hasPerfectUpdate();
98 linsolver_->apply(x, b, reduction, res);
103 linsolver_->apply(x, b, res);
106 void updatePreconditioner()
108 linsolver_->preconditioner().update();
112 std::unique_ptr<Solver> linsolver_;
128 coarseOperator_ = transferPolicy.getCoarseLevelOperator();
133 coarseOperator_ = transferPolicy.getCoarseLevelOperator();
134 auto& tp =
dynamic_cast<LevelTransferPolicy&
>(transferPolicy);
135 PressureInverseOperator* inv
136 =
new PressureInverseOperator(*coarseOperator_, prm_, tp.getCoarseLevelCommunication());
142 std::shared_ptr<Operator> coarseOperator_;
Definition: PressureSolverPolicy.hpp:35
CoarseLevelSolver * createCoarseLevelSolver(LTP &transferPolicy)
Definition: PressureSolverPolicy.hpp:131
PressureSolverPolicy(const Opm::PropertyTree &prm)
Constructs the coarse solver policy.
Definition: PressureSolverPolicy.hpp:43
OperatorType Operator
The type of the linear operator used.
Definition: PressureSolverPolicy.hpp:38
PressureInverseOperator CoarseLevelSolver
The type of solver constructed for the coarse level.
Definition: PressureSolverPolicy.hpp:117
void setCoarseOperator(LTP &transferPolicy)
Constructs a coarse level solver.
Definition: PressureSolverPolicy.hpp:126
Hierarchical collection of key/value pairs.
Definition: PropertyTree.hpp:39
Definition: fvbaseprimaryvariables.hh:141
Dune::InverseOperatorResult InverseOperatorResult
Definition: GpuBridge.hpp:32