Reference documentation for deal.II version GIT 35969cdc9b 2023-12-09 01:10:02+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\}}\)
sunlinsol_wrapper.h
Go to the documentation of this file.
1 // ---------------------------------------------------------------------
2 //
3 // Copyright (C) 2021 - 2023 by the deal.II authors
4 //
5 // This file is part of the deal.II library.
6 //
7 // The deal.II library is free software; you can use it, redistribute
8 // it, and/or modify it under the terms of the GNU Lesser General
9 // Public License as published by the Free Software Foundation; either
10 // version 2.1 of the License, or (at your option) any later version.
11 // The full text of the license can be found in the file LICENSE.md at
12 // the top level directory of deal.II.
13 //
14 // ---------------------------------------------------------------------
15 
16 
17 #ifndef dealii_sundials_sunlinsol_wrapper_h
18 #define dealii_sundials_sunlinsol_wrapper_h
19 
20 #include <deal.II/base/config.h>
21 
22 #ifdef DEAL_II_WITH_SUNDIALS
23 
24 # include <sundials/sundials_linearsolver.h>
25 
26 # include <exception>
27 # include <functional>
28 # include <memory>
29 
31 
32 namespace 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 # else
71  SundialsOperator(void *A_data, ATimesFn a_times_fn);
72 # endif
73 
74  private:
78  void *A_data;
79 
84  ATimesFn a_times_fn;
85 
86 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
91 # endif
92  };
93 
94 
95 
101  template <typename VectorType>
103  {
111  void
112  vmult(VectorType &dst, const VectorType &src) const;
113 
114 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
129  PSolveFn p_solve_fn,
131  double tol);
132 # else
145  SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, double tol);
146 # endif
147 
148  private:
152  void *P_data;
153 
158  PSolveFn p_solve_fn;
159 
160 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
165 # endif
166 
171  double tol;
172  };
173 
200  template <typename VectorType>
202  std::function<void(SundialsOperator<VectorType> &op,
204  VectorType &x,
205  const VectorType &b,
206  double tol)>;
207 
208  namespace internal
209  {
216  template <typename VectorType>
218  {
219  public:
220  explicit LinearSolverWrapper(
221  const LinearSolveFunction<VectorType> &lsolve,
222  std::exception_ptr &pending_exception
223 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
224  ,
225  SUNContext linsol_ctx
226 # endif
227  );
228 
230 
234  operator SUNLinearSolver();
235 
236  private:
237  SUNLinearSolver sun_linear_solver;
238  std::unique_ptr<LinearSolverContent<VectorType>> content;
239  };
240  } // namespace internal
241 } // namespace SUNDIALS
242 
244 
245 #endif
246 #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:477
#define DEAL_II_SUNDIALS_VERSION_GTE(major, minor, patch)
Definition: config.h:378
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:478
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
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