25#include <dune/common/version.hh>
26#if DUNE_VERSION_NEWER(DUNE_ISTL, 2, 7)
27#include <dune/istl/paamg/matrixhierarchy.hh>
29#include <dune/istl/paamg/hierarchy.hh>
31#include <dune/istl/umfpack.hh>
33#include <opm/simulators/linalg/bda/opencl/opencl.hpp>
34#include <opm/simulators/linalg/bda/opencl/BILU0.hpp>
35#include <opm/simulators/linalg/bda/Matrix.hpp>
36#include <opm/simulators/linalg/bda/opencl/OpenclMatrix.hpp>
37#include <opm/simulators/linalg/bda/ILUReorder.hpp>
38#include <opm/simulators/linalg/bda/opencl/Preconditioner.hpp>
40#include <opm/simulators/linalg/bda/opencl/openclSolverBackend.hpp>
50template <
unsigned int block_size>
59 using Base::verbosity;
67 std::vector<double> weights, coarse_vals, coarse_x, coarse_y;
68 std::vector<Matrix> Amatrices, Rmatrices;
69 std::vector<OpenclMatrix> d_Amatrices, d_Rmatrices;
70 std::vector<std::vector<int> > PcolIndices;
71 std::vector<cl::Buffer> d_PcolIndices;
72 std::vector<std::vector<double> > invDiags;
73 std::vector<cl::Buffer> d_invDiags;
74 std::vector<cl::Buffer> d_t, d_f, d_u;
75 std::unique_ptr<cl::Buffer> d_rs;
76 std::unique_ptr<cl::Buffer> d_weights;
77 std::unique_ptr<OpenclMatrix> d_mat;
78 std::unique_ptr<cl::Buffer> d_coarse_y, d_coarse_x;
79 std::once_flag opencl_buffers_allocated;
81 std::unique_ptr<BILU0<block_size> > bilu0;
84 using DuneMat = Dune::BCRSMatrix<Dune::FieldMatrix<double, 1, 1> >;
85 using DuneVec = Dune::BlockVector<Dune::FieldVector<double, 1> >;
86 using MatrixOperator = Dune::MatrixAdapter<DuneMat, DuneVec, DuneVec>;
87 using DuneAmg = Dune::Amg::MatrixHierarchy<MatrixOperator, Dune::Amg::SequentialInformation>;
88 std::unique_ptr<DuneAmg> dune_amg;
89 std::unique_ptr<DuneMat> dune_coarse;
90 std::shared_ptr<MatrixOperator> dune_op;
91 std::vector<int> level_sizes;
92 std::vector<std::vector<int> > diagIndices;
94 bool always_recalculate_aggregates =
false;
95 bool recalculate_aggregates =
true;
96 const int pressure_idx = 1;
97 unsigned num_pre_smooth_steps;
98 unsigned num_post_smooth_steps;
100 std::unique_ptr<openclSolverBackend<1> > coarse_solver;
101 ILUReorder opencl_ilu_reorder;
104 void analyzeHierarchy();
108 void analyzeAggregateMaps();
111 void init_opencl_buffers();
114 void opencl_upload();
117 void apply_amg(
const cl::Buffer& y, cl::Buffer& x);
119 void amg_cycle_gpu(
const int level, cl::Buffer &y, cl::Buffer &x);
125 CPR(
int verbosity, ILUReorder opencl_ilu_reorder);
131 void setOpencl(std::shared_ptr<cl::Context>& context, std::shared_ptr<cl::CommandQueue>& queue)
override;
135 void apply(
const cl::Buffer& y, cl::Buffer& x)
override;
140 int* getToOrder()
override
142 return bilu0->getToOrder();
145 int* getFromOrder()
override
147 return bilu0->getFromOrder();
152 return bilu0->getRMat();
159void solve_transposed_3x3(
const double *A,
const double *b,
double *x);
This struct resembles a blocked csr matrix, like Dune::BCRSMatrix.
Definition: BlockedMatrix.hpp:37
This class implements a Constrained Pressure Residual (CPR) preconditioner.
Definition: CPR.hpp:52
Definition: Preconditioner.hpp:36
This file contains a set of helper functions used by VFPProd / VFPInj.
Definition: BlackoilPhases.hpp:27