20#ifdef DEAL_II_WITH_SUNDIALS
28# ifdef DEAL_II_WITH_TRILINOS
32# ifdef DEAL_II_WITH_PETSC
48 <<
"One of the SUNDIALS linear solver internal"
49 <<
" functions returned a negative error code: " << arg1
50 <<
". Please consult SUNDIALS manual.");
52# define AssertSundialsSolver(code) \
53 Assert(code >= 0, ExcSundialsSolverError(code))
69 template <
typename F,
typename... Args>
71 call_and_possibly_capture_exception(
const F &f,
72 std::exception_ptr &eptr,
86 std::rethrow_exception(eptr);
103 f(std::forward<Args>(args)...);
113 eptr = std::current_exception();
118 catch (
const std::exception &)
120 eptr = std::current_exception();
132 template <
typename VectorType>
151# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
176 template <
typename VectorType>
189 return SUNLINEARSOLVER_ITERATIVE;
194 template <
typename VectorType>
204 auto *src_b = unwrap_nvector_const<VectorType>(b);
205 auto *dst_x = unwrap_nvector<VectorType>(x);
223 return call_and_possibly_capture_exception(content->
lsolve,
234 template <
typename VectorType>
247 template <
typename VectorType>
258 template <
typename VectorType>
271 template <
typename VectorType>
289 template <
typename VectorType>
292 std::exception_ptr &pending_exception
301# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
313 arkode_linsol_set_preconditioner<VectorType>;
316# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
317 content->linsol_ctx = linsol_ctx;
326 template <
typename VectorType>
329 SUNLinSolFreeEmpty(sun_linear_solver);
334 template <
typename VectorType>
337 return sun_linear_solver;
343# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
344 template <
typename VectorType>
349 , a_times_fn(a_times_fn)
350 , linsol_ctx(linsol_ctx)
357 template <
typename VectorType>
361 , a_times_fn(a_times_fn)
370 template <
typename VectorType>
373 const VectorType &src)
const
375 auto sun_dst = internal::make_nvector_view(dst
381 auto sun_src = internal::make_nvector_view(src
387 int status = a_times_fn(A_data, sun_src, sun_dst);
394# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
395 template <
typename VectorType>
402 , p_solve_fn(p_solve_fn)
403 , linsol_ctx(linsol_ctx)
407 template <
typename VectorType>
413 , p_solve_fn(p_solve_fn)
420 template <
typename VectorType>
423 const VectorType &src)
const
432 auto sun_dst = internal::make_nvector_view(dst
438 auto sun_src = internal::make_nvector_view(src
447 p_solve_fn(P_data, sun_src, sun_dst, tol, 0 );
472# ifdef DEAL_II_WITH_MPI
473# ifdef DEAL_II_WITH_TRILINOS
485# ifdef DEAL_II_WITH_PETSC
486# 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)
std::function< void(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> LinearSolveFunction
void vmult(VectorType &dst, const VectorType &src) const
SundialsOperator(void *A_data, ATimesFn a_times_fn, SUNContext linsol_ctx)
SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, SUNContext linsol_ctx, double tol)
void vmult(VectorType &dst, const VectorType &src) const
std::exception_ptr & pending_exception
LinearSolveFunction< VectorType > lsolve
LinearSolverContent(std::exception_ptr &pending_exception)
PSolveFn preconditioner_solve
PSetupFn preconditioner_setup
#define AssertSundialsSolver(code)