20#ifdef DEAL_II_WITH_SUNDIALS
28# ifdef DEAL_II_WITH_TRILINOS
32# ifdef DEAL_II_WITH_PETSC
40# include <sundials/sundials_iterative.h>
41# include <sundials/sundials_linearsolver.h>
51 <<
"One of the SUNDIALS linear solver internal"
52 <<
" functions returned a negative error code: " << arg1
53 <<
". Please consult SUNDIALS manual.");
55# define AssertSundialsSolver(code) \
56 Assert(code >= 0, ExcSundialsSolverError(code))
72 template <
typename F,
typename... Args>
74 call_and_possibly_capture_exception(
const F &f,
75 std::exception_ptr &eptr,
89 std::rethrow_exception(eptr);
106 f(std::forward<Args>(args)...);
116 eptr = std::current_exception();
121 catch (
const std::exception &)
123 eptr = std::current_exception();
135 template <
typename VectorType>
150# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
183 template <
typename VectorType>
196 return SUNLINEARSOLVER_ITERATIVE;
201 template <
typename VectorType>
211 auto *src_b = unwrap_nvector_const<VectorType>(b);
212 auto *dst_x = unwrap_nvector<VectorType>(x);
241 template <
typename VectorType>
254 template <
typename VectorType>
264 template <
typename VectorType>
284 template <
typename VectorType>
308 template <
typename VectorType>
311 std::exception_ptr &pending_exception
320# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
332 arkode_linsol_set_preconditioner<VectorType>;
335# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
336 content->linsol_ctx = linsol_ctx;
345 template <
typename VectorType>
348 SUNLinSolFreeEmpty(sun_linear_solver);
353 template <
typename VectorType>
356 return sun_linear_solver;
362# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
363 template <
typename VectorType>
368 , a_times_fn(a_times_fn)
369 , linsol_ctx(linsol_ctx)
376 template <
typename VectorType>
380 , a_times_fn(a_times_fn)
389 template <
typename VectorType>
392 const VectorType &src)
const
394 auto sun_dst = internal::make_nvector_view(dst
400 auto sun_src = internal::make_nvector_view(src
406 int status = a_times_fn(A_data, sun_src, sun_dst);
413# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
414 template <
typename VectorType>
421 , p_solve_fn(p_solve_fn)
422 , linsol_ctx(linsol_ctx)
426 template <
typename VectorType>
432 , p_solve_fn(p_solve_fn)
439 template <
typename VectorType>
442 const VectorType &src)
const
451 auto sun_dst = internal::make_nvector_view(dst
457 auto sun_src = internal::make_nvector_view(src
466 p_solve_fn(P_data, sun_src, sun_dst, tol, 0 );
491# ifdef DEAL_II_WITH_MPI
492# ifdef DEAL_II_WITH_TRILINOS
504# ifdef DEAL_II_WITH_PETSC
505# ifndef PETSC_USE_COMPLEX
std::unique_ptr< LinearSolverContent< VectorType > > content
SUNLinearSolver sun_linear_solver
LinearSolverWrapper(const LinearSolveFunction< VectorType > &lsolve, std::exception_ptr &pending_exception, SUNContext linsol_ctx)
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_SUNDIALS_VERSION_GTE(major, minor, patch)
#define DEAL_II_NAMESPACE_CLOSE
#define Assert(cond, exc)
static ::ExceptionBase & ExcInternalError()
#define DeclException1(Exception1, type1, outsequence)
static ::ExceptionBase & RecoverableUserCallbackError()
static ::ExceptionBase & ExcSundialsSolverError(int arg1)
#define AssertThrow(cond, exc)
int call_and_possibly_capture_exception(const F &f, std::exception_ptr &eptr, Args &&...args)
std::function< void(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> LinearSolveFunction
SundialsOperator(void *A_data, SUNATimesFn a_times_fn, SUNContext linsol_ctx)
void vmult(VectorType &dst, const VectorType &src) const
SundialsPreconditioner(void *P_data, SUNPSolveFn p_solve_fn, SUNContext linsol_ctx, double tol)
void vmult(VectorType &dst, const VectorType &src) const
std::exception_ptr & pending_exception
SUNPSetupFn preconditioner_setup
LinearSolveFunction< VectorType > lsolve
LinearSolverContent(std::exception_ptr &pending_exception)
SUNPSolveFn preconditioner_solve
#define AssertSundialsSolver(code)