diff --git a/opm/simulators/linalg/bda/amgclSolverBackend.cpp b/opm/simulators/linalg/bda/amgclSolverBackend.cpp index 0aedeb2f3..abe8ce109 100644 --- a/opm/simulators/linalg/bda/amgclSolverBackend.cpp +++ b/opm/simulators/linalg/bda/amgclSolverBackend.cpp @@ -27,6 +27,9 @@ #include #include +#include + + namespace bda { @@ -69,11 +72,12 @@ void amgclSolverBackend::initialize(int N_, int nnz_, int dim, doubl cusparseCreate(&bprm.cusparse_handle); #endif - // set amgcl parameters - prm.precond.damping = 0.9; - prm.solver.maxiter = maxit; - prm.solver.tol = tolerance; - prm.solver.verbose = (verbosity >= 2); + // read amgcl parameters via json file + std::ifstream file("amgcl_options.json"); + boost::property_tree::read_json(file, prm); + + // print json parameters + boost::property_tree::write_json(std::cout, prm); initialized = true; } // end initialize() @@ -143,7 +147,12 @@ void amgclSolverBackend::solve_system(double *b, WellContributions & try { // create matrix object +#if AMGCL_CUDA auto A = std::tie(N, A_rows, A_cols, A_vals); +#else + auto Atmp = std::tie(N, A_rows, A_cols, A_vals); + auto A = amgcl::adapter::block_matrix(Atmp); +#endif // create solver and construct preconditioner // don't reuse this unless the preconditioner can be reused @@ -174,7 +183,7 @@ void amgclSolverBackend::solve_system(double *b, WellContributions & auto X = amgcl::make_iterator_range(x_ptr, x_ptr + N / block_size); // actually solve - std::tie(iters, error) = solve(A, B, X); + std::tie(iters, error) = solve(B, X); #endif } catch (const std::exception& ex) { diff --git a/opm/simulators/linalg/bda/amgclSolverBackend.hpp b/opm/simulators/linalg/bda/amgclSolverBackend.hpp index 0de8d9d61..e92d3015a 100644 --- a/opm/simulators/linalg/bda/amgclSolverBackend.hpp +++ b/opm/simulators/linalg/bda/amgclSolverBackend.hpp @@ -26,6 +26,8 @@ #include #include +#include + #include #include #include @@ -36,6 +38,8 @@ #include #include +#include + #include #define AMGCL_CUDA 0 @@ -72,15 +76,7 @@ class amgclSolverBackend : public BdaSolver typedef amgcl::backend::builtin Backend; #endif - // choose linear solver components - typedef amgcl::relaxation::as_preconditioner Precond; - typedef amgcl::solver::bicgstab IterSolver; - -#if AMGCL_CUDA - typedef amgcl::make_solver Solver; -#else - typedef amgcl::make_block_solver Solver; -#endif + typedef amgcl::make_solver, amgcl::runtime::solver::wrapper > Solver; private: // store matrix in CSR format @@ -89,7 +85,7 @@ private: std::vector x; std::once_flag print_info; - typename Solver::params prm; + boost::property_tree::ptree prm; typename Backend::params bprm; // amgcl backend parameters, only used for cusparseHandle /// Initialize GPU and allocate memory