diff --git a/CMakeLists.txt b/CMakeLists.txt index e696dee2..354e6e21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0") endif() -# Incorporate additions by X/Open 7, that includes POSIX 17 additions -# and allow to use things like the `M_PI` constant in the code -# without warnings from static analyzers. +# Incorporate additions by X/Open 7, that includes POSIX 17 additions and allow +# to use things like the `M_PI` constant in the code without warnings from +# static analyzers. add_compile_definitions(_XOPEN_SOURCE=700) # DOWNLOAD_EXTRACT_TIMESTAMP = TRUE diff --git a/examples/call_ivp_from_c_burgers_eq.c b/examples/call_ivp_from_c_burgers_eq.c index fadcb6ab..09dadfad 100644 --- a/examples/call_ivp_from_c_burgers_eq.c +++ b/examples/call_ivp_from_c_burgers_eq.c @@ -32,7 +32,8 @@ parse_impl(int argc, char *argv[]) return argv[1]; } else { - fprintf(stderr, "USAGE: %s [scipy_ode_dopri5 | sundials_cvode | jl_diffeq]\n", argv[0]); + fprintf(stderr, "USAGE: %s [scipy_ode_dopri5 | sundials_cvode | jl_diffeq]\n", + argv[0]); exit(EXIT_FAILURE); } } @@ -45,7 +46,7 @@ compute_initial_condition_(size_t N, OIFArrayF64 *u0, double *dx, double *dt_max double b = 2.0; double *x = malloc(N * sizeof(double)); *dx = (b - a) / N; - + for (int i = 0; i < N; ++i) { x[i] = a + i * (*dx); } @@ -72,7 +73,7 @@ rhs(double t, OIFArrayF64 *y, OIFArrayF64 *rhs_out, void *user_data) double *u = y->data; double *udot = rhs_out->data; - double dx = *((double *) user_data); + double dx = *((double *)user_data); double *flux = malloc(N * sizeof(double)); if (flux == NULL) { @@ -99,18 +100,17 @@ rhs(double t, OIFArrayF64 *y, OIFArrayF64 *rhs_out, void *user_data) } for (int i = 0; i < N - 1; ++i) { - flux_hat[i] = 0.5 * (flux[i] + flux[i + 1]) - - 0.5 * local_sound_speed * (u[i + 1] - u[i]); + flux_hat[i] = + 0.5 * (flux[i] + flux[i + 1]) - 0.5 * local_sound_speed * (u[i + 1] - u[i]); } for (int i = 1; i < N - 1; ++i) { udot[i] = -1.0 / dx * (flux_hat[i] - flux_hat[i - 1]); } - double f_rb = 0.5 * (flux[0] + flux[N-1]) - - 0.5 * local_sound_speed * (u[0] - u[N-1]); + double f_rb = 0.5 * (flux[0] + flux[N - 1]) - 0.5 * local_sound_speed * (u[0] - u[N - 1]); double f_lb = f_rb; udot[0] = -1.0 / dx * (flux_hat[0] - f_lb); - udot[N - 1] = -1.0 / dx * (f_rb - flux_hat[N-2]); + udot[N - 1] = -1.0 / dx * (f_rb - flux_hat[N - 2]); retval = 0; @@ -172,7 +172,7 @@ main(int argc, char *argv[]) OIFArrayF64 *y = oif_create_array_f64(1, (intptr_t[1]){N}); // Time step. double dt = dt_max; - int n_time_steps = (int) (t_final / dt + 1); + int n_time_steps = (int)(t_final / dt + 1); for (int i = 0; i < n_time_steps; ++i) { printf("%d\n", i); double t = t0 + (i + 1) * dt; @@ -203,4 +203,3 @@ main(int argc, char *argv[]) return 0; } -