Reference documentation for deal.II version 9.3.2
\(\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_newempty.h
Go to the documentation of this file.
1 //-----------------------------------------------------------
2 //
3 // Copyright (C) 2020 - 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 /*
17  * The functions in this file are based on an implementation distributed within
18  * the SUNDIALS package, see the license here:
19  * https://computing.llnl.gov/projects/sundials/license.
20  * -----------------------------------------------------------------
21  * Programmer(s): Daniel Reynolds @ SMU
22  * David J. Gardner, Carol S. Woodward, and
23  * Slaven Peles @ LLNL
24  * -----------------------------------------------------------------*/
25 
26 #ifndef dealii_sundials_sunlinsol_newempty_h
27 #define dealii_sundials_sunlinsol_newempty_h
28 
29 #include <deal.II/base/config.h>
30 
31 #ifdef DEAL_II_WITH_SUNDIALS
32 
33 # include <sundials/sundials_linearsolver.h>
34 
36 namespace SUNDIALS
37 {
38  namespace internal
39  {
44  inline SUNLinearSolver
46  {
47  /* create linear solver object */
48  SUNLinearSolver LS = new _generic_SUNLinearSolver;
49 
50  /* create linear solver ops structure */
51  SUNLinearSolver_Ops ops = new _generic_SUNLinearSolver_Ops;
52 
53  /* initialize operations to nullptr */
54  ops->gettype = nullptr;
55  ops->setatimes = nullptr;
56  ops->setpreconditioner = nullptr;
57  ops->setscalingvectors = nullptr;
58  ops->initialize = nullptr;
59  ops->setup = nullptr;
60  ops->solve = nullptr;
61  ops->numiters = nullptr;
62  ops->resnorm = nullptr;
63  ops->resid = nullptr;
64  ops->lastflag = nullptr;
65  ops->space = nullptr;
66  ops->free = nullptr;
67 
68  /* attach ops and initialize content to nullptr */
69  LS->ops = ops;
70  LS->content = nullptr;
71 
72  return (LS);
73  }
74 
83  inline void
84  SUNLinSolFreeEmpty(SUNLinearSolver solver)
85  {
86  if (solver == nullptr)
87  return;
88 
89  /* free non-nullptr ops structure */
90  if (solver->ops)
91  delete solver->ops;
92  solver->ops = nullptr;
93 
94  /* free overall linear solver object */
95  delete solver;
96  return;
97  }
98 
99  } // namespace internal
100 } // namespace SUNDIALS
102 
103 #endif // DEAL_II_WITH_SUNDIALS
104 #endif // dealii_sundials_sunlinsol_newempty_h
#define DEAL_II_NAMESPACE_OPEN
Definition: config.h:396
#define DEAL_II_NAMESPACE_CLOSE
Definition: config.h:397
void SUNLinSolFreeEmpty(SUNLinearSolver solver)
SUNLinearSolver SUNLinSolNewEmpty()