1 /*-----------------------------------------------------------------
2  * Programmer(s): Daniel R. Reynolds @ SMU
3  *                Alan C. Hindmarsh and Radu Serban @ LLNL
4  *-----------------------------------------------------------------
5  * SUNDIALS Copyright Start
6  * Copyright (c) 2002-2021, Lawrence Livermore National Security
7  * and Southern Methodist University.
8  * All rights reserved.
9  *
10  * See the top-level LICENSE and NOTICE files for details.
11  *
12  * SPDX-License-Identifier: BSD-3-Clause
13  * SUNDIALS Copyright End
14  *-----------------------------------------------------------------
15  * This is the header file (private version) for the IDABBDPRE
16  * module, for a band-block-diagonal preconditioner, i.e. a
17  * block-diagonal matrix with banded blocks, for use with IDA
18  * and an IDASPILS linear solver.
19  *-----------------------------------------------------------------*/
20 
21 #ifndef _IDASBBDPRE_IMPL_H
22 #define _IDASBBDPRE_IMPL_H
23 
24 #include <idas/idas_bbdpre.h>
25 #include <sunmatrix/sunmatrix_band.h>
26 #include <sunlinsol/sunlinsol_band.h>
27 
28 #ifdef __cplusplus  /* wrapper to enable C++ usage */
29 extern "C" {
30 #endif
31 
32 /*
33  * -----------------------------------------------------------------
34  * Definition of IBBDPrecData
35  * -----------------------------------------------------------------
36  */
37 
38 typedef struct IBBDPrecDataRec {
39 
40   /* passed by user to IDABBDPrecAlloc and used by
41      IDABBDPrecSetup/IDABBDPrecSolve functions */
42   sunindextype mudq, mldq, mukeep, mlkeep;
43   realtype rel_yy;
44   IDABBDLocalFn glocal;
45   IDABBDCommFn gcomm;
46 
47   /* set by IDABBDPrecSetup and used by IDABBDPrecSetup and
48      IDABBDPrecSolve functions */
49   sunindextype n_local;
50   SUNMatrix PP;
51   SUNLinearSolver LS;
52   N_Vector zlocal;
53   N_Vector rlocal;
54   N_Vector tempv1;
55   N_Vector tempv2;
56   N_Vector tempv3;
57   N_Vector tempv4;
58 
59   /* available for optional output */
60   long int rpwsize;
61   long int ipwsize;
62   long int nge;
63 
64   /* pointer to ida_mem */
65   void *ida_mem;
66 
67 } *IBBDPrecData;
68 
69 /*
70  * -----------------------------------------------------------------
71  * Type: IDABBDPrecDataB
72  * -----------------------------------------------------------------
73  */
74 
75 typedef struct IDABBDPrecDataRecB {
76 
77   /* BBD user functions (glocB and cfnB) for backward run */
78   IDABBDLocalFnB glocalB;
79   IDABBDCommFnB  gcommB;
80 
81 } *IDABBDPrecDataB;
82 
83 
84 /*
85  * -----------------------------------------------------------------
86  * IDABBDPRE error messages
87  * -----------------------------------------------------------------
88  */
89 
90 #define MSGBBD_MEM_NULL    "Integrator memory is NULL."
91 #define MSGBBD_LMEM_NULL   "Linear solver memory is NULL. One of the SPILS linear solvers must be attached."
92 #define MSGBBD_MEM_FAIL    "A memory request failed."
93 #define MSGBBD_BAD_NVECTOR "A required vector operation is not implemented."
94 #define MSGBBD_SUNMAT_FAIL "An error arose from a SUNBandMatrix routine."
95 #define MSGBBD_SUNLS_FAIL  "An error arose from a SUNBandLinearSolver routine."
96 #define MSGBBD_PMEM_NULL   "BBD peconditioner memory is NULL. IDABBDPrecInit must be called."
97 #define MSGBBD_FUNC_FAILED "The Glocal or Gcomm routine failed in an unrecoverable manner."
98 
99 #define MSGBBD_AMEM_NULL   "idaadj_mem = NULL illegal."
100 #define MSGBBD_PDATAB_NULL "IDABBDPRE memory is NULL for the backward integration."
101 #define MSGBBD_BAD_T       "Bad t for interpolation."
102 
103 #ifdef __cplusplus
104 }
105 #endif
106 
107 #endif
108