cvode_bandpre.h 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * -----------------------------------------------------------------
  3. * $Revision: 4378 $
  4. * $Date: 2015-02-19 10:55:14 -0800 (Thu, 19 Feb 2015) $
  5. * -----------------------------------------------------------------
  6. * Programmer(s): Alan C. Hindmarsh and 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. * This is the header file for the CVBANDPRE module, which
  19. * provides a banded difference quotient Jacobian-based
  20. * preconditioner and solver routines for use with CVSPGMR,
  21. * CVSPBCG, or CVSPTFQMR.
  22. *
  23. * Summary:
  24. * These routines provide a band matrix preconditioner based on
  25. * difference quotients of the ODE right-hand side function f.
  26. * The user supplies parameters
  27. * mu = upper half-bandwidth (number of super-diagonals)
  28. * ml = lower half-bandwidth (number of sub-diagonals)
  29. * The routines generate a band matrix of bandwidth ml + mu + 1
  30. * and use this to form a preconditioner for use with the Krylov
  31. * linear solver in CVSP*. Although this matrix is intended to
  32. * approximate the Jacobian df/dy, it may be a very crude
  33. * approximation. The true Jacobian need not be banded, or its
  34. * true bandwith may be larger than ml + mu + 1, as long as the
  35. * banded approximation generated here is sufficiently accurate
  36. * to speed convergence as a preconditioner.
  37. *
  38. * Usage:
  39. * The following is a summary of the usage of this module.
  40. * Details of the calls to CVodeCreate, CVodeInit, CVSp*,
  41. * and CVode are available in the User Guide.
  42. * To use these routines, the sequence of calls in the user
  43. * main program should be as follows:
  44. *
  45. * #include <cvode/cvode_bandpre.h>
  46. * #include <nvector_serial.h>
  47. * ...
  48. * Set y0
  49. * ...
  50. * cvode_mem = CVodeCreate(...);
  51. * ier = CVodeInit(...);
  52. * ...
  53. * flag = CVSptfqmr(cvode_mem, pretype, maxl);
  54. * -or-
  55. * flag = CVSpgmr(cvode_mem, pretype, maxl);
  56. * -or-
  57. * flag = CVSpbcg(cvode_mem, pretype, maxl);
  58. * ...
  59. * flag = CVBandPrecInit(cvode_mem, N, mu, ml);
  60. * ...
  61. * flag = CVode(...);
  62. * ...
  63. * Free y0
  64. * ...
  65. * CVodeFree(&cvode_mem);
  66. *
  67. * Notes:
  68. * (1) Include this file for the CVBandPrecData type definition.
  69. * (2) In the CVBandPrecAlloc call, the arguments N is the
  70. * problem dimension.
  71. * (3) In the CVBPSp* call, the user is free to specify
  72. * the input pretype and the optional input maxl.
  73. * -----------------------------------------------------------------
  74. */
  75. #ifndef _CVBANDPRE_H
  76. #define _CVBANDPRE_H
  77. #include <sundials/sundials_nvector.h>
  78. #ifdef __cplusplus /* wrapper to enable C++ usage */
  79. extern "C" {
  80. #endif
  81. /*
  82. * -----------------------------------------------------------------
  83. * Function : CVBandPrecInit
  84. * -----------------------------------------------------------------
  85. * CVBandPrecInit allocates and initializes the BANDPRE preconditioner
  86. * module. This functino must be called AFTER one of the SPILS linear
  87. * solver modules has been attached to the CVODE integrator.
  88. *
  89. * The parameters of CVBandPrecInit are as follows:
  90. *
  91. * cvode_mem is the pointer to CVODE memory returned by CVodeCreate.
  92. *
  93. * N is the problem size.
  94. *
  95. * mu is the upper half bandwidth.
  96. *
  97. * ml is the lower half bandwidth.
  98. *
  99. * The return value of CVBandPrecInit is one of:
  100. * CVSPILS_SUCCESS if no errors occurred
  101. * CVSPILS_MEM_NULL if the integrator memory is NULL
  102. * CVSPILS_LMEM_NULL if the linear solver memory is NULL
  103. * CVSPILS_ILL_INPUT if an input has an illegal value
  104. * CVSPILS_MEM_FAIL if a memory allocation request failed
  105. *
  106. * NOTE: The band preconditioner assumes a serial implementation
  107. * of the NVECTOR package. Therefore, CVBandPrecInit will
  108. * first test for a compatible N_Vector internal
  109. * representation by checking for required functions.
  110. * -----------------------------------------------------------------
  111. */
  112. SUNDIALS_EXPORT int CVBandPrecInit(void *cvode_mem, long int N, long int mu, long int ml);
  113. /*
  114. * -----------------------------------------------------------------
  115. * Optional output functions : CVBandPrecGet*
  116. * -----------------------------------------------------------------
  117. * CVBandPrecGetWorkSpace returns the real and integer work space used
  118. * by CVBANDPRE.
  119. * CVBandPrecGetNumRhsEvals returns the number of calls made from
  120. * CVBANDPRE to the user's right-hand side
  121. * routine f.
  122. *
  123. * The return value of CVBandPrecGet* is one of:
  124. * CVSPILS_SUCCESS if no errors occurred
  125. * CVSPILS_MEM_NULL if the integrator memory is NULL
  126. * CVSPILS_LMEM_NULL if the linear solver memory is NULL
  127. * CVSPILS_PMEM_NULL if the preconditioner memory is NULL
  128. * -----------------------------------------------------------------
  129. */
  130. SUNDIALS_EXPORT int CVBandPrecGetWorkSpace(void *cvode_mem, long int *lenrwLS, long int *leniwLS);
  131. SUNDIALS_EXPORT int CVBandPrecGetNumRhsEvals(void *cvode_mem, long int *nfevalsBP);
  132. #ifdef __cplusplus
  133. }
  134. #endif
  135. #endif