Reference documentation for deal.II version 9.4.0
\(\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 - 2022 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 <functional>
27 # include <memory>
28 
30 
31 namespace SUNDIALS
32 {
33 # ifndef DOXYGEN
34  // forward declarations
35  namespace internal
36  {
37  template <typename VectorType>
38  struct LinearSolverContent;
39  }
40 # endif
41 
45  template <typename VectorType>
47  {
51  void
52  vmult(VectorType &dst, const VectorType &src) const;
53 
54 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
62  SundialsOperator(void *A_data, ATimesFn a_times_fn, SUNContext linsol_ctx);
63 # else
70  SundialsOperator(void *A_data, ATimesFn a_times_fn);
71 # endif
72 
73  private:
77  void *A_data;
78 
83  ATimesFn a_times_fn;
84 
85 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
89  SUNContext linsol_ctx;
90 # endif
91  };
92 
93 
94 
100  template <typename VectorType>
102  {
110  void
111  vmult(VectorType &dst, const VectorType &src) const;
112 
113 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
128  PSolveFn p_solve_fn,
129  SUNContext linsol_ctx,
130  double tol);
131 # else
144  SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, double tol);
145 # endif
146 
147  private:
151  void *P_data;
152 
157  PSolveFn p_solve_fn;
158 
159 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
163  SUNContext linsol_ctx;
164 # endif
165 
170  double tol;
171  };
172 
198  template <typename VectorType>
200  std::function<int(SundialsOperator<VectorType> & op,
202  VectorType & x,
203  const VectorType & b,
204  double tol)>;
205 
206  namespace internal
207  {
214  template <typename VectorType>
216  {
217  public:
219 # if DEAL_II_SUNDIALS_VERSION_GTE(6, 0, 0)
220  ,
221  SUNContext linsol_ctx
222 # endif
223  );
224 
226 
230  operator SUNLinearSolver();
231 
232  private:
233  SUNLinearSolver sun_linear_solver;
234  std::unique_ptr<LinearSolverContent<VectorType>> content;
235  };
236  } // namespace internal
237 } // namespace SUNDIALS
238 
240 
241 #endif
242 #endif
std::unique_ptr< LinearSolverContent< VectorType > > content
LinearSolverWrapper(LinearSolveFunction< VectorType > lsolve, SUNContext linsol_ctx)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:442
#define DEAL_II_SUNDIALS_VERSION_GTE(major, minor, patch)
Definition: config.h:347
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:443
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
std::function< int(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