Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 27, 2024
1 parent 43d644f commit 07cd484
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
19 changes: 9 additions & 10 deletions examples/call_ivp_from_c_burgers_eq.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand All @@ -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);
}
Expand All @@ -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) {
Expand All @@ -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;

Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -203,4 +203,3 @@ main(int argc, char *argv[])

return 0;
}

0 comments on commit 07cd484

Please sign in to comment.