cvode_direct_impl.h 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*
  2. * -----------------------------------------------------------------
  3. * $Revision: 4075 $
  4. * $Date: 2014-04-24 10:46:58 -0700 (Thu, 24 Apr 2014) $
  5. * -----------------------------------------------------------------
  6. * Programmer: Radu Serban @ LLNL
  7. * -----------------------------------------------------------------
  8. * LLNS Copyright Start
  9. * Copyright (c) 2014, Lawrence Livermore National Security
  10. * This work was performed under the auspices of the U.S. Department
  11. * of Energy by Lawrence Livermore National Laboratory in part under
  12. * Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
  13. * Produced at the Lawrence Livermore National Laboratory.
  14. * All rights reserved.
  15. * For details, see the LICENSE file.
  16. * LLNS Copyright End
  17. * -----------------------------------------------------------------
  18. * Common implementation header file for the CVDLS linear solvers.
  19. * -----------------------------------------------------------------
  20. */
  21. #ifndef _CVDLS_IMPL_H
  22. #define _CVDLS_IMPL_H
  23. #include "cvode/cvode_direct.h"
  24. #ifdef __cplusplus /* wrapper to enable C++ usage */
  25. extern "C" {
  26. #endif
  27. /*
  28. * -----------------------------------------------------------------
  29. * CVDLS solver constants
  30. * -----------------------------------------------------------------
  31. * CVD_MSBJ maximum number of steps between Jacobian evaluations
  32. * CVD_DGMAX maximum change in gamma between Jacobian evaluations
  33. * -----------------------------------------------------------------
  34. */
  35. #define CVD_MSBJ 50
  36. #define CVD_DGMAX RCONST(0.2)
  37. /*
  38. * -----------------------------------------------------------------
  39. * Types : CVDlsMemRec, CVDlsMem
  40. * -----------------------------------------------------------------
  41. * CVDlsMem is pointer to a CVDlsMemRec structure.
  42. * -----------------------------------------------------------------
  43. */
  44. typedef struct CVDlsMemRec {
  45. int d_type; /* SUNDIALS_DENSE or SUNDIALS_BAND */
  46. long int d_n; /* problem dimension */
  47. long int d_ml; /* lower bandwidth of Jacobian */
  48. long int d_mu; /* upper bandwidth of Jacobian */
  49. long int d_smu; /* upper bandwith of M = MIN(N-1,d_mu+d_ml) */
  50. booleantype d_jacDQ; /* TRUE if using internal DQ Jacobian approx. */
  51. CVDlsDenseJacFn d_djac; /* dense Jacobian routine to be called */
  52. CVDlsBandJacFn d_bjac; /* band Jacobian routine to be called */
  53. void *d_J_data; /* user data is passed to djac or bjac */
  54. DlsMat d_M; /* M = I - gamma * df/dy */
  55. DlsMat d_savedJ; /* savedJ = old Jacobian */
  56. int *d_pivots; /* pivots = int pivot array for PM = LU */
  57. long int *d_lpivots; /* lpivots = long int pivot array for PM = LU */
  58. long int d_nstlj; /* nstlj = nst at last Jacobian eval. */
  59. long int d_nje; /* nje = no. of calls to jac */
  60. long int d_nfeDQ; /* no. of calls to f due to DQ Jacobian approx. */
  61. long int d_last_flag; /* last error return flag */
  62. } *CVDlsMem;
  63. /*
  64. * -----------------------------------------------------------------
  65. * Prototypes of internal functions
  66. * -----------------------------------------------------------------
  67. */
  68. SUNDIALS_EXPORT int cvDlsDenseDQJac(long int N, realtype t,
  69. N_Vector y, N_Vector fy,
  70. DlsMat Jac, void *data,
  71. N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
  72. SUNDIALS_EXPORT int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
  73. realtype t, N_Vector y, N_Vector fy,
  74. DlsMat Jac, void *data,
  75. N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);
  76. /*
  77. * -----------------------------------------------------------------
  78. * Error Messages
  79. * -----------------------------------------------------------------
  80. */
  81. #define MSGD_CVMEM_NULL "Integrator memory is NULL."
  82. #define MSGD_BAD_NVECTOR "A required vector operation is not implemented."
  83. #define MSGD_BAD_SIZES "Illegal bandwidth parameter(s). Must have 0 <= ml, mu <= N-1."
  84. #define MSGD_MEM_FAIL "A memory request failed."
  85. #define MSGD_LMEM_NULL "Linear solver memory is NULL."
  86. #define MSGD_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."
  87. #ifdef __cplusplus
  88. }
  89. #endif
  90. #endif