Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] sundials 3 compatiblity #206

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 18 additions & 5 deletions bng2/Network3/src/network.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3032,14 +3032,17 @@ int print_rates_network(FILE* out, int discrete) {

#include "sundials/sundials_types.h"
#include "cvode/cvode.h"
#include "cvode/cvode_direct.h"
#include "nvector/nvector_serial.h"

#include "cvode/cvode_dense.h"
#include "sundials/sundials_dense.h"
#include "sundials/sundials_direct.h"
#include "sunmatrix/sunmatrix_sparse.h"

#include "sunlinsol/sunlinsol_dense.h"
#include "sunlinsol/sunlinsol_spgmr.h"


#include "cvode/cvode_spgmr.h"
#include "sundials/sundials_spgmr.h"

typedef struct jacnode* jacnode_ref;

Expand Down Expand Up @@ -3391,6 +3394,8 @@ int propagate_cvode_network(double* t, double delta_t, double* n_steps, double*
static N_Vector y;
static void* cvode_mem;
static int initflag = 0;
static SUNMatrix A;
static SUNLinearSolver LS;
long int cvode_maxnumsteps = 2000;

/* Initializations at the beginning of new propagation */
Expand Down Expand Up @@ -3423,18 +3428,26 @@ int propagate_cvode_network(double* t, double delta_t, double* n_steps, double*
* Jacobian vs finite difference
*/
if (SOLVER == GMRES || SOLVER == GMRES_J) {
CVSpgmr(cvode_mem, PREC_NONE, 0);
if (SOLVER == GMRES_J) {
cout << "ERROR: Jacobian no longer supported for GMRES solver" << endl;
exit(1);
}

// CVSpgmr(cvode_mem, PREC_NONE, 0);
A = SUNSparseMatrix(n_species, n_species, 0, CSC_MAT);
LS = SUNSPGMR(y, PREC_NONE, 0);
CVDlsSetLinearSolver(cvode_mem, LS, A);
}
else if (SOLVER == DENSE || SOLVER == DENSE_J) {
CVDense(cvode_mem, n_species);
if (SOLVER == DENSE_J) {
cout << "ERROR: Jacobian no longer supported for dense solver" << endl;
exit(1);
}

// CVDense(cvode_mem, n_species);
A = SUNDenseMatrix(n_species, n_species);
LS = SUNDenseLinearSolver(y, A);
CVDlsSetLinearSolver(cvode_mem, LS, A);
}
else {
fprintf(stderr, "ERROR: Invalid CVODE solver.\n");
Expand Down