PartMC  2.3.0
Macros | Functions
condense_solver.c File Reference

Interface to SUNDIALS ODE solver library for condensation. More...

Include dependency graph for condense_solver.c:

Go to the source code of this file.

Macros

#define PMC_CONDENSE_SOLVER_SUCCESS   0
 Result code indicating successful completion. More...
 
#define PMC_CONDENSE_SOLVER_INIT_Y   1
 Result code indicating failure to allocate y vector. More...
 
#define PMC_CONDENSE_SOLVER_INIT_ABSTOL   2
 Result code indicating failure to allocate abstol vector. More...
 
#define PMC_CONDENSE_SOLVER_INIT_CVODE_MEM   3
 Result code indicating failure to create the solver. More...
 
#define PMC_CONDENSE_SOLVER_INIT_CVODE   4
 Result code indicating failure to initialize the solver. More...
 
#define PMC_CONDENSE_SOLVER_SVTOL   5
 Result code indicating failure to set tolerances. More...
 
#define PMC_CONDENSE_SOLVER_SET_MAX_STEPS   6
 Result code indicating failure to set maximum steps. More...
 
#define PMC_CONDENSE_SOLVER_FAIL   7
 Result code indicating failure of the solver. More...
 

Functions

static int condense_vf (realtype t, N_Vector y, N_Vector ydot, void *user_data)
 The ODE vector field to integrate. More...
 
static int condense_check_flag (void *flagvalue, char *funcname, int opt)
 Check the return value from a SUNDIALS call. More...
 
static int condense_solver_Init (CVodeMem cv_mem)
 Initialization routine for the ODE linear equation solver. More...
 
static int condense_solver_Setup (CVodeMem cv_mem, int convfail, N_Vector ypred, N_Vector fpred, booleantype *jcurPtr, N_Vector vtemp1, N_Vector vtemp2, N_Vector vtemp3)
 Setup routine for the ODE linear equation solver. More...
 
static int condense_solver_Solve (CVodeMem cv_mem, N_Vector b, N_Vector weight, N_Vector ycur, N_Vector fcur)
 Linear solver routine for use by the ODE solver. More...
 
static void condense_solver_Free (CVodeMem cv_mem)
 Finalization routine for the ODE linear equation solver. More...
 
int condense_solver (int neq, double *x_f, double *abstol_f, double reltol_f, double t_initial_f, double t_final_f)
 Call the ODE solver. More...
 

Detailed Description

Interface to SUNDIALS ODE solver library for condensation.

Definition in file condense_solver.c.

Macro Definition Documentation

#define PMC_CONDENSE_SOLVER_FAIL   7

Result code indicating failure of the solver.

Definition at line 40 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_INIT_ABSTOL   2

Result code indicating failure to allocate abstol vector.

Definition at line 25 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_INIT_CVODE   4

Result code indicating failure to initialize the solver.

Definition at line 31 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_INIT_CVODE_MEM   3

Result code indicating failure to create the solver.

Definition at line 28 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_INIT_Y   1

Result code indicating failure to allocate y vector.

Definition at line 22 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_SET_MAX_STEPS   6

Result code indicating failure to set maximum steps.

Definition at line 37 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_SUCCESS   0

Result code indicating successful completion.

Definition at line 19 of file condense_solver.c.

#define PMC_CONDENSE_SOLVER_SVTOL   5

Result code indicating failure to set tolerances.

Definition at line 34 of file condense_solver.c.

Function Documentation

static int condense_check_flag ( void *  flagvalue,
char *  funcname,
int  opt 
)
static

Check the return value from a SUNDIALS call.

  • opt == 0 means SUNDIALS function allocates memory so check if flagvalue is not a NULL pointer.
  • opt == 1 means SUNDIALS function returns a flag so check if the int pointed to by flagvalue has flag >= 0.
  • opt == 2 means function allocates memory so check if flagvalue is not a NULL pointer.
Parameters
flagvalueA pointer to check (either for NULL, or as an int pointer giving the flag value).
funcnameA string giving the function name returning this result code.
optA flag indicating the type of check to perform.
Returns
A result code (0 is success).

Definition at line 218 of file condense_solver.c.

int condense_solver ( int  neq,
double *  x_f,
double *  abstol_f,
double  reltol_f,
double  t_initial_f,
double  t_final_f 
)

Call the ODE solver.

Parameters
neqThe number of equations.
x_fA pointer to a vector of neq variables, giving the initial state vector on entry and the final state vector on exit.
abstol_fA pointer to a vector of neq variables, giving the absolute error tolerance for the corresponding state vector component.
reltol_fThe scalar relative tolerance.
t_initial_fThe initial time (s).
t_final_fThe final time (s).
Returns
A result code (0 is success).

Definition at line 73 of file condense_solver.c.

static void condense_solver_Free ( CVodeMem  cv_mem)
static

Finalization routine for the ODE linear equation solver.

Parameters
cv_memThe CVODE solver parameter structure.

Definition at line 328 of file condense_solver.c.

static int condense_solver_Init ( CVodeMem  cv_mem)
static

Initialization routine for the ODE linear equation solver.

Parameters
cv_memThe CVODE solver parameter structure.
Returns
A result code (0 is success).

Definition at line 251 of file condense_solver.c.

static int condense_solver_Setup ( CVodeMem  cv_mem,
int  convfail,
N_Vector  ypred,
N_Vector  fpred,
booleantype *  jcurPtr,
N_Vector  vtemp1,
N_Vector  vtemp2,
N_Vector  vtemp3 
)
static

Setup routine for the ODE linear equation solver.

Parameters
cv_memThe CVODE solver parameter structure.
convfail
ypred
fpred
jcurPtr
vtemp1
vtemp2
vtemp3
Returns
A result code (0 is success).

Definition at line 268 of file condense_solver.c.

static int condense_solver_Solve ( CVodeMem  cv_mem,
N_Vector  b,
N_Vector  weight,
N_Vector  ycur,
N_Vector  fcur 
)
static

Linear solver routine for use by the ODE solver.

Should solve the system $(I - \gamma J) x = b$, where $J$ is the current vector field Jacobian, $\gamma$ is a given scalar, and $b$ is a given vector.

Parameters
cv_memThe CVODE solver parameter structure.
bThe right-hand-side of the linear system.
weight
ycurThe current state vector.
fcurThe current vector field vector.
Returns
A result code (0 is success).

Definition at line 288 of file condense_solver.c.

static int condense_vf ( realtype  t,
N_Vector  y,
N_Vector  ydot,
void *  user_data 
)
static

The ODE vector field to integrate.

Parameters
tThe current time (s).
yThe state vector.
ydotThe rate of change of the state vector.
user_dataA pointer to user-provided data.
Returns
A result code (0 is success).

Definition at line 173 of file condense_solver.c.