20 #ifndef OPM_AMGCLSOLVER_BACKEND_HEADER_INCLUDED
21 #define OPM_AMGCLSOLVER_BACKEND_HEADER_INCLUDED
25 #include <opm/simulators/linalg/bda/BdaResult.hpp>
26 #include <opm/simulators/linalg/bda/BdaSolver.hpp>
27 #include <opm/simulators/linalg/bda/WellContributions.hpp>
29 #include <boost/property_tree/ptree.hpp>
31 #include <amgcl/amg.hpp>
32 #include <amgcl/backend/builtin.hpp>
33 #include <amgcl/adapter/crs_tuple.hpp>
34 #include <amgcl/make_block_solver.hpp>
35 #include <amgcl/relaxation/as_preconditioner.hpp>
36 #include <amgcl/relaxation/ilu0.hpp>
37 #include <amgcl/solver/bicgstab.hpp>
38 #include <amgcl/preconditioner/runtime.hpp>
39 #include <amgcl/value_type/static_matrix.hpp>
46 template <
unsigned int block_size>
55 using Base::verbosity;
56 using Base::platformID;
59 using Base::tolerance;
60 using Base::initialized;
62 typedef amgcl::static_matrix<double, block_size, block_size> dmat_type;
63 typedef amgcl::static_matrix<double, block_size, 1> dvec_type;
64 typedef amgcl::backend::builtin<dmat_type> CPU_Backend;
66 typedef amgcl::make_solver<amgcl::runtime::preconditioner<CPU_Backend>, amgcl::runtime::solver::wrapper<CPU_Backend> > CPU_Solver;
71 enum Amgcl_backend_type {
78 std::vector<unsigned> A_rows, A_cols;
79 std::vector<double> A_vals, rhs;
80 std::vector<double> x;
81 std::once_flag print_info;
82 Amgcl_backend_type backend_type = cpu;
89 std::once_flag cuda_initialize;
90 void solve_cuda(
double *b);
94 std::once_flag vexcl_initialize;
100 void initialize(
int N,
int nnz,
int dim);
105 void convert_sparsity_pattern(
int *rows,
int *cols);
110 void convert_data(
double *vals,
int *rows);
115 void solve_system(
double *b,
BdaResult &res);
124 amgclSolverBackend(
int linear_solver_verbosity,
int maxit,
double tolerance,
unsigned int platformID,
unsigned int deviceID);
144 SolverStatus solve_system(
int N,
int nnz,
int dim,
double *vals,
int *rows,
int *cols,
double *b,
WellContributions& wellContribs,
BdaResult &res)
override;
This class serves to eliminate the need to include the WellContributions into the matrix (with –matri...
Definition: WellContributions.hpp:61
This class is based on InverseOperatorResult struct from dune/istl/solver.hh It is needed to prevent ...
Definition: BdaResult.hpp:29
This class serves to simplify choosing between different backend solvers, such as cusparseSolver and ...
Definition: BdaSolver.hpp:43
This class does not implement a solver, but converts the BCSR format to normal CSR and uses amgcl for...
Definition: amgclSolverBackend.hpp:48
~amgclSolverBackend()
Destroy a openclSolver, and free memory.
Definition: amgclSolverBackend.cpp:49
amgclSolverBackend(int linear_solver_verbosity, int maxit, double tolerance, unsigned int platformID, unsigned int deviceID)
Construct a openclSolver.
Definition: amgclSolverBackend.cpp:45
void get_result(double *x) override
Get result after linear solve, and peform postprocessing if necessary.
Definition: amgclSolverBackend.cpp:347
Definition: PropertyTree.hpp:29