mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
SolverAdapter now takes a reference to scalar product.
This commit is contained in:
parent
042172588d
commit
ea86e45fef
@ -171,7 +171,7 @@ namespace Dune
|
|||||||
*scalarproduct_,
|
*scalarproduct_,
|
||||||
*preconditioner_,
|
*preconditioner_,
|
||||||
tol,// desired residual reduction factor
|
tol,// desired residual reduction factor
|
||||||
restart,
|
restart,
|
||||||
maxiter, // maximum number of iterations
|
maxiter, // maximum number of iterations
|
||||||
verbosity);
|
verbosity);
|
||||||
} else if (solver_type == "flexgmres") {
|
} else if (solver_type == "flexgmres") {
|
||||||
@ -180,7 +180,7 @@ namespace Dune
|
|||||||
*scalarproduct_,
|
*scalarproduct_,
|
||||||
*preconditioner_,
|
*preconditioner_,
|
||||||
tol,// desired residual reduction factor
|
tol,// desired residual reduction factor
|
||||||
restart,
|
restart,
|
||||||
maxiter, // maximum number of iterations
|
maxiter, // maximum number of iterations
|
||||||
verbosity);
|
verbosity);
|
||||||
#if HAVE_SUITESPARSE_UMFPACK
|
#if HAVE_SUITESPARSE_UMFPACK
|
||||||
@ -193,7 +193,7 @@ namespace Dune
|
|||||||
} else if (solver_type == "cubicgstab") {
|
} else if (solver_type == "cubicgstab") {
|
||||||
linsolver_.reset(new Opm::cuistl::SolverAdapter<Operator, Dune::BiCGSTABSolver, VectorType>(
|
linsolver_.reset(new Opm::cuistl::SolverAdapter<Operator, Dune::BiCGSTABSolver, VectorType>(
|
||||||
*linearoperator_for_solver_,
|
*linearoperator_for_solver_,
|
||||||
scalarproduct_,
|
*scalarproduct_,
|
||||||
preconditioner_,
|
preconditioner_,
|
||||||
tol, // desired residual reduction factor
|
tol, // desired residual reduction factor
|
||||||
maxiter, // maximum number of iterations
|
maxiter, // maximum number of iterations
|
||||||
|
@ -56,12 +56,12 @@ public:
|
|||||||
|
|
||||||
// TODO: Use a std::forward
|
// TODO: Use a std::forward
|
||||||
SolverAdapter(Operator& op,
|
SolverAdapter(Operator& op,
|
||||||
std::shared_ptr<Dune::ScalarProduct<X>> sp,
|
Dune::ScalarProduct<X>& sp,
|
||||||
std::shared_ptr<Dune::Preconditioner<X, X>> prec,
|
std::shared_ptr<Dune::Preconditioner<X, X>> prec,
|
||||||
scalar_real_type reduction,
|
scalar_real_type reduction,
|
||||||
int maxit,
|
int maxit,
|
||||||
int verbose)
|
int verbose)
|
||||||
: Dune::IterativeSolver<X, X>(op, *sp, *prec, reduction, maxit, verbose)
|
: Dune::IterativeSolver<X, X>(op, sp, *prec, reduction, maxit, verbose)
|
||||||
, m_opOnCPUWithMatrix(op)
|
, m_opOnCPUWithMatrix(op)
|
||||||
, m_matrix(CuSparseMatrix<real_type>::fromMatrix(op.getmat()))
|
, m_matrix(CuSparseMatrix<real_type>::fromMatrix(op.getmat()))
|
||||||
, m_underlyingSolver(constructSolver(prec, reduction, maxit, verbose))
|
, m_underlyingSolver(constructSolver(prec, reduction, maxit, verbose))
|
||||||
|
@ -79,9 +79,9 @@ createSolverAdapterWithMatrix(const size_t N = 10)
|
|||||||
prm.put<double>("relaxation", 1.0);
|
prm.put<double>("relaxation", 1.0);
|
||||||
prm.put<std::string>("type", "CUILU0");
|
prm.put<std::string>("type", "CUILU0");
|
||||||
auto prec = PrecondFactory::create(*op, prm);
|
auto prec = PrecondFactory::create(*op, prm);
|
||||||
auto solverAdapter = std::make_shared<SolverAdapter>(*op, sp, prec, 1.0, 10, 0);
|
auto solverAdapter = std::make_shared<SolverAdapter>(*op, *sp, prec, 1.0, 10, 0);
|
||||||
|
|
||||||
return std::make_tuple(matrixPtr, solverAdapter, op);
|
return std::make_tuple(matrixPtr, solverAdapter, op, sp);
|
||||||
}
|
}
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
@ -93,7 +93,7 @@ BOOST_AUTO_TEST_CASE(TestCreation)
|
|||||||
BOOST_AUTO_TEST_CASE(TestSolve)
|
BOOST_AUTO_TEST_CASE(TestSolve)
|
||||||
{
|
{
|
||||||
const size_t N = 10;
|
const size_t N = 10;
|
||||||
auto [matrix, solverAdapter, op] = createSolverAdapterWithMatrix(N);
|
auto [matrix, solverAdapter, op, sp] = createSolverAdapterWithMatrix(N);
|
||||||
|
|
||||||
Vector xActual(N), xInitial(N), b(N);
|
Vector xActual(N), xInitial(N), b(N);
|
||||||
for (size_t i = 0; i < N; ++i) {
|
for (size_t i = 0; i < N; ++i) {
|
||||||
|
Loading…
Reference in New Issue
Block a user