20#ifndef OPM_AMGCLSOLVER_BACKEND_HEADER_INCLUDED
21#define OPM_AMGCLSOLVER_BACKEND_HEADER_INCLUDED
27#include <boost/property_tree/ptree.hpp>
29#include <amgcl/amg.hpp>
30#include <amgcl/backend/builtin.hpp>
31#include <amgcl/adapter/crs_tuple.hpp>
32#include <amgcl/make_block_solver.hpp>
33#include <amgcl/relaxation/as_preconditioner.hpp>
34#include <amgcl/relaxation/ilu0.hpp>
35#include <amgcl/solver/bicgstab.hpp>
36#include <amgcl/preconditioner/runtime.hpp>
37#include <amgcl/value_type/static_matrix.hpp>
48template<
class Scalar,
unsigned int block_size>
64 using dmat_type = amgcl::static_matrix<Scalar, block_size, block_size>;
65 using dvec_type = amgcl::static_matrix<Scalar, block_size, 1>;
66 using CPU_Backend = std::conditional_t<block_size == 1,
67 amgcl::backend::builtin<Scalar>,
68 amgcl::backend::builtin<dmat_type>>;
70 using CPU_Solver = amgcl::make_solver<amgcl::runtime::preconditioner<CPU_Backend>,
71 amgcl::runtime::solver::wrapper<CPU_Backend>>;
75 enum Amgcl_backend_type {
82 std::vector<unsigned> A_rows, A_cols;
83 std::vector<Scalar> A_vals, rhs;
84 std::vector<Scalar> x;
85 std::once_flag print_info;
86 Amgcl_backend_type backend_type = cpu;
93 std::once_flag cuda_initialize;
94 void solve_cuda(Scalar* b);
98 std::once_flag vexcl_initialize;
103 void initialize(
int Nb,
int nnzbs);
108 void convert_sparsity_pattern(
int *rows,
int *cols);
113 void convert_data(Scalar* vals,
int* rows);
118 void solve_system(Scalar* b,
BdaResult& res);
128 Scalar tolerance,
unsigned int platformID,
129 unsigned int deviceID);
Definition: BdaResult.hpp:31
Definition: BdaSolver.hpp:46
int maxit
Definition: BdaSolver.hpp:55
int nnzb
Definition: BdaSolver.hpp:61
bool initialized
Definition: BdaSolver.hpp:66
int verbosity
Definition: BdaSolver.hpp:53
unsigned int deviceID
Definition: BdaSolver.hpp:64
int N
Definition: BdaSolver.hpp:58
int Nb
Definition: BdaSolver.hpp:59
int nnz
Definition: BdaSolver.hpp:60
Scalar tolerance
Definition: BdaSolver.hpp:56
unsigned int platformID
Definition: BdaSolver.hpp:63
Definition: BlockedMatrix.hpp:29
Definition: amgclSolverBackend.hpp:50
~amgclSolverBackend()
Destroy a openclSolver, and free memory.
SolverStatus solve_system(std::shared_ptr< BlockedMatrix< Scalar > > matrix, Scalar *b, std::shared_ptr< BlockedMatrix< Scalar > > jacMatrix, WellContributions< Scalar > &wellContribs, BdaResult &res) override
amgclSolverBackend(int linear_solver_verbosity, int maxit, Scalar tolerance, unsigned int platformID, unsigned int deviceID)
void get_result(Scalar *x) override
Definition: WellContributions.hpp:53
Definition: PropertyTree.hpp:29
Definition: amgclSolverBackend.hpp:44
SolverStatus
Definition: BdaSolver.hpp:35