14 #include "sundials/sundials_types.h" 15 #include "sundials/sundials_math.h" 16 #include "sundials/sundials_nvector.h" 17 #include "nvector/nvector_serial.h" 18 #include "cvodes/cvodes.h" 19 #include "cvodes/cvodes_lapack.h" 39 void intDriver (
const int NUM,
const double t,
const double t_end,
40 const double *pr_global,
double *y_global)
44 #pragma omp parallel for shared(y_global, pr_global, integrators, y_locals) private(tid, t_next) 45 for (tid = 0; tid < NUM; ++tid) {
46 int index = omp_get_thread_num();
50 double pr_local = pr_global[tid];
53 double* y_local = NV_DATA_S(fill);
55 for (
int i = 0; i <
NSP; i++)
57 y_local[i] = y_global[tid + i * NUM];
61 int flag = CVodeReInit(
integrators[index], t, fill);
62 if (flag != CV_SUCCESS)
64 printf(
"Error reinitializing integrator for thread %d, code: %d\n", tid, flag);
69 flag = CVodeSetUserData(
integrators[index], &pr_local);
70 if (flag != CV_SUCCESS)
72 printf(
"Error setting user data for thread %d, code: %d\n", tid, flag);
78 if (flag != CV_SUCCESS)
80 printf(
"Error setting end time for thread %d, code: %d\n", tid, flag);
85 flag = CVode(
integrators[index], t_end, fill, &t_next, CV_NORMAL);
86 if ((flag != CV_SUCCESS && flag != CV_TSTOP_RETURN) || t_next != t_end)
88 printf(
"Error on integration step for thread %d, code %d\n", tid, flag);
93 for (
int i = 0; i <
NSP; i++)
95 y_global[tid + i * NUM] = y_local[i];
Contains skeleton of all methods that need to be defined on a per solver basis.
void intDriver(const int NUM, const double t, const double t_end, const double *pr_global, double *y_global)
Integration driver for the CPU integrators.