1 /*
2  * -----------------------------------------------------------------
3  * Programmer(s): Daniel R. Reynolds @ SMU
4  *                Radu Serban @ LLNL
5  * -----------------------------------------------------------------
6  * SUNDIALS Copyright Start
7  * Copyright (c) 2002-2021, Lawrence Livermore National Security
8  * and Southern Methodist University.
9  * All rights reserved.
10  *
11  * See the top-level LICENSE and NOTICE files for details.
12  *
13  * SPDX-License-Identifier: BSD-3-Clause
14  * SUNDIALS Copyright End
15  * -----------------------------------------------------------------
16  * Implementation header file for the CVBBDPRE module.
17  * -----------------------------------------------------------------
18  */
19 
20 #ifndef _CVSBBDPRE_IMPL_H
21 #define _CVSBBDPRE_IMPL_H
22 
23 #include <cvodes/cvodes_bbdpre.h>
24 #include <sunmatrix/sunmatrix_band.h>
25 #include <sunlinsol/sunlinsol_band.h>
26 
27 #ifdef __cplusplus  /* wrapper to enable C++ usage */
28 extern "C" {
29 #endif
30 
31 /*-----------------------------------------------------------------
32   Type: CVBBDPrecData
33   -----------------------------------------------------------------*/
34 
35 typedef struct CVBBDPrecDataRec {
36 
37   /* passed by user to CVBBDPrecInit and used by PrecSetup/PrecSolve */
38   sunindextype mudq, mldq, mukeep, mlkeep;
39   realtype dqrely;
40   CVLocalFn gloc;
41   CVCommFn cfn;
42 
43   /* set by CVBBDPrecSetup and used by CVBBDPrecSolve */
44   SUNMatrix savedJ;
45   SUNMatrix savedP;
46   SUNLinearSolver LS;
47   N_Vector tmp1;
48   N_Vector tmp2;
49   N_Vector tmp3;
50   N_Vector zlocal;
51   N_Vector rlocal;
52 
53   /* set by CVBBDPrecInit and used by CVBBDPrecSetup */
54   sunindextype n_local;
55 
56   /* available for optional output */
57   long int rpwsize;
58   long int ipwsize;
59   long int nge;
60 
61   /* pointer to cvode_mem */
62   void *cvode_mem;
63 
64 } *CVBBDPrecData;
65 
66 
67 /*-----------------------------------------------------------------
68   Type: CVBBDPrecDataB
69   -----------------------------------------------------------------*/
70 
71 typedef struct CVBBDPrecDataRecB {
72 
73   /* BBD user functions (glocB and cfnB) for backward run */
74   CVLocalFnB glocB;
75   CVCommFnB  cfnB;
76 
77 } *CVBBDPrecDataB;
78 
79 
80 /*-----------------------------------------------------------------
81   CVBBDPRE error messages
82   -----------------------------------------------------------------*/
83 
84 #define MSGBBD_MEM_NULL    "Integrator memory is NULL."
85 #define MSGBBD_LMEM_NULL   "Linear solver memory is NULL. One of the SPILS linear solvers must be attached."
86 #define MSGBBD_MEM_FAIL    "A memory request failed."
87 #define MSGBBD_BAD_NVECTOR "A required vector operation is not implemented."
88 #define MSGBBD_SUNMAT_FAIL "An error arose from a SUNBandMatrix routine."
89 #define MSGBBD_SUNLS_FAIL  "An error arose from a SUNBandLinearSolver routine."
90 #define MSGBBD_PMEM_NULL   "BBD peconditioner memory is NULL. CVBBDPrecInit must be called."
91 #define MSGBBD_FUNC_FAILED "The gloc or cfn routine failed in an unrecoverable manner."
92 
93 #define MSGBBD_NO_ADJ      "Illegal attempt to call before calling CVodeAdjInit."
94 #define MSGBBD_BAD_WHICH   "Illegal value for the which parameter."
95 #define MSGBBD_PDATAB_NULL "BBD preconditioner memory is NULL for the backward integration."
96 #define MSGBBD_BAD_TINTERP "Bad t for interpolation."
97 
98 
99 #ifdef __cplusplus
100 }
101 #endif
102 
103 #endif
104