Skip to content

Commit

Permalink
Copy cvode_direct_impl.h to source (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
PeterMeisrimelModelon authored Apr 20, 2023
1 parent 52e057b commit 0a635ff
Show file tree
Hide file tree
Showing 3 changed files with 120 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@
* Increased Kinsol MAX_RECVR from 5 to 20.
* Added extra fallback in CVode Jacobian computation: Try backward differences if forward differences failed.
* Added __OPENMP flag for SuperLU_mt with MSVC.
* Copied cvode_direct_impl.h file to src/cvode/ and added it into CMakeLists.
118 changes: 118 additions & 0 deletions include/cvode/cvode_direct_impl.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*
* -----------------------------------------------------------------
* $Revision$
* $Date$
* -----------------------------------------------------------------
* Programmer: Radu Serban @ LLNL
* -----------------------------------------------------------------
* LLNS Copyright Start
* Copyright (c) 2014, Lawrence Livermore National Security
* This work was performed under the auspices of the U.S. Department
* of Energy by Lawrence Livermore National Laboratory in part under
* Contract W-7405-Eng-48 and in part under Contract DE-AC52-07NA27344.
* Produced at the Lawrence Livermore National Laboratory.
* All rights reserved.
* For details, see the LICENSE file.
* LLNS Copyright End
* -----------------------------------------------------------------
* Common implementation header file for the CVDLS linear solvers.
* -----------------------------------------------------------------
*/

#ifndef _CVDLS_IMPL_H
#define _CVDLS_IMPL_H

#include "cvode/cvode_direct.h"

#ifdef __cplusplus /* wrapper to enable C++ usage */
extern "C" {
#endif

/*
* -----------------------------------------------------------------
* CVDLS solver constants
* -----------------------------------------------------------------
* CVD_MSBJ maximum number of steps between Jacobian evaluations
* CVD_DGMAX maximum change in gamma between Jacobian evaluations
* -----------------------------------------------------------------
*/

#define CVD_MSBJ 50
#define CVD_DGMAX RCONST(0.2)

/*
* -----------------------------------------------------------------
* Types : CVDlsMemRec, CVDlsMem
* -----------------------------------------------------------------
* CVDlsMem is pointer to a CVDlsMemRec structure.
* -----------------------------------------------------------------
*/

typedef struct CVDlsMemRec {

int d_type; /* SUNDIALS_DENSE or SUNDIALS_BAND */

long int d_n; /* problem dimension */

long int d_ml; /* lower bandwidth of Jacobian */
long int d_mu; /* upper bandwidth of Jacobian */
long int d_smu; /* upper bandwith of M = MIN(N-1,d_mu+d_ml) */

booleantype d_jacDQ; /* TRUE if using internal DQ Jacobian approx. */
CVDlsDenseJacFn d_djac; /* dense Jacobian routine to be called */
CVDlsBandJacFn d_bjac; /* band Jacobian routine to be called */
void *d_J_data; /* user data is passed to djac or bjac */

DlsMat d_M; /* M = I - gamma * df/dy */
DlsMat d_savedJ; /* savedJ = old Jacobian */

int *d_pivots; /* pivots = int pivot array for PM = LU */
long int *d_lpivots; /* lpivots = long int pivot array for PM = LU */

long int d_nstlj; /* nstlj = nst at last Jacobian eval. */

long int d_nje; /* nje = no. of calls to jac */

long int d_nfeDQ; /* no. of calls to f due to DQ Jacobian approx. */

long int d_last_flag; /* last error return flag */

} *CVDlsMem;

/*
* -----------------------------------------------------------------
* Prototypes of internal functions
* -----------------------------------------------------------------
*/

int cvDlsDenseDQJac(long int N, realtype t,
N_Vector y, N_Vector fy,
DlsMat Jac, void *data,
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);

int cvDlsBandDQJac(long int N, long int mupper, long int mlower,
realtype t, N_Vector y, N_Vector fy,
DlsMat Jac, void *data,
N_Vector tmp1, N_Vector tmp2, N_Vector tmp3);

/* Auxilliary functions */
int cvDlsInitializeCounters(CVDlsMem cvdls_mem);

/*
* -----------------------------------------------------------------
* Error Messages
* -----------------------------------------------------------------
*/

#define MSGD_CVMEM_NULL "Integrator memory is NULL."
#define MSGD_BAD_NVECTOR "A required vector operation is not implemented."
#define MSGD_BAD_SIZES "Illegal bandwidth parameter(s). Must have 0 <= ml, mu <= N-1."
#define MSGD_MEM_FAIL "A memory request failed."
#define MSGD_LMEM_NULL "Linear solver memory is NULL."
#define MSGD_JACFUNC_FAILED "The Jacobian routine failed in an unrecoverable manner."

#ifdef __cplusplus
}
#endif

#endif
1 change: 1 addition & 0 deletions src/cvode/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ SET(cvode_HEADERS
cvode_dense.h
cvode_diag.h
cvode_direct.h
cvode_direct_impl.h
cvode.h
cvode_sparse.h
cvode_spbcgs.h
Expand Down

0 comments on commit 0a635ff

Please sign in to comment.