34 (*y_host) = (
double*)malloc(NUM *
NN *
sizeof(
double));
35 (*variable_host) = (
double*)malloc(NUM *
sizeof(
double));
36 FILE *fp = fopen (filename,
"rb");
39 fprintf(stderr,
"Could not open file: %s\n", filename);
42 double buffer[
NN + 2];
45 for (
int i = 0; i < NUM; ++i)
48 int count = fread(buffer,
sizeof(
double),
NN + 2, fp);
49 if (count != (
NN + 2))
51 fprintf(stderr,
"File (%s) is incorrectly formatted, %d doubles were expected but only %d were read.\\n", filename,
NN + 1, count);
57 (*y_host)[i] = buffer[1];
59 (*variable_host)[i] = buffer[2];
61 double pres = buffer[2];
63 for (
int j = 0; j <
NSP; j++)
64 (*y_host)[i + (j + 1) * NUM] = buffer[j + 3];
71 for (
int j = 1; j <
NN; ++j)
73 Yi[j - 1] = (*y_host)[i + j * NUM];
77 (*variable_host)[i] = getDensity ((*y_host)[i], pres, Xi);
Defines some simple macros to simplify GPU indexing.
void apply_mask(double *y_host)
Not needed for van der Pol.
void read_initial_conditions(const char *filename, int NUM, double **y_host, double **variable_host)
Reads initial conditions for IVPs from binary file.
Headers for GPU memory initialization.