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] authored and dmitry-kabanov committed May 27, 2024
1 parent 9120aad commit 62ced74
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 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
23 changes: 11 additions & 12 deletions examples/call_ivp_from_c_burgers_eq.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,22 @@ 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);
}
}
}

static int
compute_initial_condition_(size_t N, OIFArrayF64 *u0, OIFArrayF64 *grid, double *dx, double *dt_max)
compute_initial_condition_(size_t N, OIFArrayF64 *u0, OIFArrayF64 *grid, double *dx,
double *dt_max)
{
double a = 0.0;
double b = 2.0;
double *x = grid->data;
*dx = (b - a) / N;

for (int i = 0; i < N; ++i) {
x[i] = a + i * (*dx);
}
Expand All @@ -72,7 +74,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 +101,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 @@ -146,7 +147,6 @@ main(int argc, char *argv[])
double dt_max;
int status = 1; // Aux variable to check for errors.


status = compute_initial_condition_(N, y0, grid, &dx, &dt_max);
assert(status == 0);

Expand Down Expand Up @@ -179,7 +179,7 @@ main(int argc, char *argv[])

// 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) {
double t = t0 + (i + 1) * dt;
if (t > t_final) {
Expand Down Expand Up @@ -212,4 +212,3 @@ main(int argc, char *argv[])

return retval;
}

0 comments on commit 62ced74

Please sign in to comment.