deal.II version GIT relicensing-6834-g5b78e6bcdf 2026-10-01 11:20:01+00:00
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
sunlinsol_wrapper.h
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception OR LGPL-2.1-or-later
4// Copyright (C) 2021 - 2026 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Detailed license information governing the source code and contributions
9// can be found in LICENSE.md and CONTRIBUTING.md at the top level directory.
10//
11// -----------------------------------------------------------------------------
12
13
14#ifndef dealii_sundials_sunlinsol_wrapper_h
15#define dealii_sundials_sunlinsol_wrapper_h
16
17#include <deal.II/base/config.h>
18
19#ifdef DEAL_II_WITH_SUNDIALS
20
21# include <sundials/sundials_linearsolver.h>
22
23# include <exception>
24# include <functional>
25# include <memory>
26
27#endif
28
30
31#ifdef DEAL_II_WITH_SUNDIALS
32namespace SUNDIALS
33{
34# ifndef DOXYGEN
35 // forward declarations
36 namespace internal
37 {
38 template <typename VectorType>
39 struct LinearSolverContent;
40 }
41# endif
42
46 template <typename VectorType>
48 {
52 void
53 vmult(VectorType &dst, const VectorType &src) const;
54
55# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
64 SUNATimesFn a_times_fn,
66# else
73 SundialsOperator(void *A_data, ATimesFn a_times_fn);
74# endif
75
76 private:
80 void *A_data;
81
82# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
87 SUNATimesFn a_times_fn;
88
93# else
98 ATimesFn a_times_fn;
99# endif
100 };
101
102
103
109 template <typename VectorType>
111 {
119 void
120 vmult(VectorType &dst, const VectorType &src) const;
121
122# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
137 SUNPSolveFn p_solve_fn,
139 double tol);
140# else
153 SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, double tol);
154# endif
155
156 private:
160 void *P_data;
161
162# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
167 SUNPSolveFn p_solve_fn;
168
173# else
178 PSolveFn p_solve_fn;
179# endif
180
185 double tol;
186 };
187
214 template <typename VectorType>
216 std::function<void(SundialsOperator<VectorType> &op,
218 VectorType &x,
219 const VectorType &b,
220 double tol)>;
221
222 namespace internal
223 {
230 template <typename VectorType>
232 {
233 public:
236 std::exception_ptr &pending_exception
238 ,
239 SUNContext linsol_ctx
240# endif
241 );
242
244
248 operator SUNLinearSolver();
249
250 private:
252 std::unique_ptr<LinearSolverContent<VectorType>> content;
253 };
254 } // namespace internal
255} // namespace SUNDIALS
256
257#endif
258
260#endif
std::unique_ptr< LinearSolverContent< VectorType > > content
LinearSolverWrapper(const LinearSolveFunction< VectorType > &lsolve, std::exception_ptr &pending_exception, SUNContext linsol_ctx)
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:38
#define DEAL_II_SUNDIALS_VERSION_GTE(major, minor, patch)
Definition config.h:532
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:39
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