Reference documentation for deal.II version Git 713825e468 2021-05-17 16:05:53 -0400
\(\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 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 #ifndef dealii_sundials_sunlinsol_wrapper_h
17 #define dealii_sundials_sunlinsol_wrapper_h
18 
19 #include <deal.II/base/config.h>
20 
21 #ifdef DEAL_II_WITH_SUNDIALS
22 # if DEAL_II_SUNDIALS_VERSION_GTE(4, 0, 0)
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 
60  SundialsOperator(void *A_data, ATimesFn a_times_fn);
61 
62  private:
66  void *A_data;
67 
72  ATimesFn a_times_fn;
73  };
74 
75 
76 
82  template <typename VectorType>
84  {
92  void
93  vmult(VectorType &dst, const VectorType &src) const;
94 
103  SundialsPreconditioner(void *P_data, PSolveFn p_solve_fn, double tol);
104 
105  private:
109  void *P_data;
110 
115  PSolveFn p_solve_fn;
116 
121  double tol;
122  };
123 
149  template <typename VectorType>
150  using LinearSolveFunction =
151  std::function<int(SundialsOperator<VectorType> & op,
153  VectorType & x,
154  const VectorType & b,
155  double tol)>;
156 
157  namespace internal
158  {
165  template <typename VectorType>
167  {
168  public:
170 
172 
176  operator SUNLinearSolver();
177 
178  private:
179  SUNLinearSolver sun_linear_solver;
180  std::unique_ptr<LinearSolverContent<VectorType>> content;
181  };
182  } // namespace internal
183 } // namespace SUNDIALS
184 
186 
187 # endif
188 #endif
189 #endif
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:396
SymmetricTensor< 2, dim, Number > b(const Tensor< 2, dim, Number > &F)
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:395
std::function< int(SundialsOperator< VectorType > &op, SundialsPreconditioner< VectorType > &prec, VectorType &x, const VectorType &b, double tol)> LinearSolveFunction
std::unique_ptr< LinearSolverContent< VectorType > > content