deal.II version GIT relicensing-7058-gb35ee29762 2026-11-11 09:30: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
23
24# include <sundials/sundials_linearsolver.h>
25# include <sundials/sundials_nvector.h>
26
27# include <exception>
28# include <functional>
29# include <memory>
30
31#endif
32
34
35#ifdef DEAL_II_WITH_SUNDIALS
36namespace SUNDIALS
37{
38# ifndef DOXYGEN
39 // forward declarations
40 namespace internal
41 {
42 template <typename VectorType>
43 struct LinearSolverContent;
44 }
45# endif
46
50 template <typename VectorType>
52 {
56 void
57 vmult(VectorType &dst, const VectorType &src) const;
58
59# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
68 SUNATimesFn a_times_fn,
70# else
77 SundialsOperator(void *A_data, ATimesFn a_times_fn);
78# endif
79
80 private:
84 void *A_data;
85
86# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
91 SUNATimesFn a_times_fn;
92
97# else
102 ATimesFn a_times_fn;
103# endif
104 };
105
106
107
113 template <typename VectorType>
115 {
123 void
124 vmult(VectorType &dst, const VectorType &src) const;
125
126# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
141 SUNPSolveFn p_solve_fn,
143 double tol);
144# else
157 SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, double tol);
158# endif
159
160 private:
164 void *P_data;
165
166# if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
171 SUNPSolveFn p_solve_fn;
172
177# else
182 PSolveFn p_solve_fn;
183# endif
184
189 double tol;
190 };
191
218 template <typename VectorType>
220 std::function<void(SundialsOperator<VectorType> &op,
222 VectorType &x,
223 const VectorType &b,
224 double tol)>;
225
226 namespace internal
227 {
234 template <typename VectorType>
236 {
237 public:
240 std::exception_ptr &pending_exception
242 ,
243 SUNContext linsol_ctx
244# endif
245 );
246
251
260
264
268 operator SUNLinearSolver() const;
269
270 private:
271 SUNLinearSolver sun_linear_solver;
272 std::unique_ptr<LinearSolverContent<VectorType>> content;
273 };
274
275
276
282 {
283 using Handle = SUNLinearSolver;
284
285 static void
286 free(Handle solver)
287 {
288 SUNLinSolFree(solver);
289 }
290 };
291
300
311 make_spgmr_linear_solver(N_Vector y_template,
312 const InvocationContext &inv_ctx);
313 } // namespace internal
314} // namespace SUNDIALS
315
316#endif
317
319#endif
LinearSolverWrapper(LinearSolverWrapper &&other) noexcept
LinearSolverWrapper(const LinearSolverWrapper &)=delete
std::unique_ptr< LinearSolverContent< VectorType > > content
LinearSolverWrapper & operator=(const LinearSolverWrapper &)=delete
LinearSolverWrapper(const LinearSolveFunction< VectorType > &lsolve, std::exception_ptr &pending_exception, SUNContext linsol_ctx)
LinearSolverWrapper & operator=(LinearSolverWrapper &&other) noexcept
#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
SundialsLinearSolver make_spgmr_linear_solver(N_Vector y_template, const InvocationContext &inv_ctx)
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