Skip to content

Commit 62ced74

Browse files
pre-commit-ci[bot]dmitry-kabanov
authored andcommitted
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 9120aad commit 62ced74

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

CMakeLists.txt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
1111
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -O0")
1212
endif()
1313

14-
# Incorporate additions by X/Open 7, that includes POSIX 17 additions
15-
# and allow to use things like the `M_PI` constant in the code
16-
# without warnings from static analyzers.
14+
# Incorporate additions by X/Open 7, that includes POSIX 17 additions and allow
15+
# to use things like the `M_PI` constant in the code without warnings from
16+
# static analyzers.
1717
add_compile_definitions(_XOPEN_SOURCE=700)
1818

1919
# DOWNLOAD_EXTRACT_TIMESTAMP = TRUE

examples/call_ivp_from_c_burgers_eq.c

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,22 @@ parse_impl(int argc, char *argv[])
3232
return argv[1];
3333
}
3434
else {
35-
fprintf(stderr, "USAGE: %s [scipy_ode_dopri5 | sundials_cvode | jl_diffeq]\n", argv[0]);
35+
fprintf(stderr, "USAGE: %s [scipy_ode_dopri5 | sundials_cvode | jl_diffeq]\n",
36+
argv[0]);
3637
exit(EXIT_FAILURE);
3738
}
3839
}
3940
}
4041

4142
static int
42-
compute_initial_condition_(size_t N, OIFArrayF64 *u0, OIFArrayF64 *grid, double *dx, double *dt_max)
43+
compute_initial_condition_(size_t N, OIFArrayF64 *u0, OIFArrayF64 *grid, double *dx,
44+
double *dt_max)
4345
{
4446
double a = 0.0;
4547
double b = 2.0;
4648
double *x = grid->data;
4749
*dx = (b - a) / N;
48-
50+
4951
for (int i = 0; i < N; ++i) {
5052
x[i] = a + i * (*dx);
5153
}
@@ -72,7 +74,7 @@ rhs(double t, OIFArrayF64 *y, OIFArrayF64 *rhs_out, void *user_data)
7274
double *u = y->data;
7375
double *udot = rhs_out->data;
7476

75-
double dx = *((double *) user_data);
77+
double dx = *((double *)user_data);
7678

7779
double *flux = malloc(N * sizeof(double));
7880
if (flux == NULL) {
@@ -99,18 +101,17 @@ rhs(double t, OIFArrayF64 *y, OIFArrayF64 *rhs_out, void *user_data)
99101
}
100102

101103
for (int i = 0; i < N - 1; ++i) {
102-
flux_hat[i] = 0.5 * (flux[i] + flux[i + 1]) -
103-
0.5 * local_sound_speed * (u[i + 1] - u[i]);
104+
flux_hat[i] =
105+
0.5 * (flux[i] + flux[i + 1]) - 0.5 * local_sound_speed * (u[i + 1] - u[i]);
104106
}
105107

106108
for (int i = 1; i < N - 1; ++i) {
107109
udot[i] = -1.0 / dx * (flux_hat[i] - flux_hat[i - 1]);
108110
}
109-
double f_rb = 0.5 * (flux[0] + flux[N-1]) -
110-
0.5 * local_sound_speed * (u[0] - u[N-1]);
111+
double f_rb = 0.5 * (flux[0] + flux[N - 1]) - 0.5 * local_sound_speed * (u[0] - u[N - 1]);
111112
double f_lb = f_rb;
112113
udot[0] = -1.0 / dx * (flux_hat[0] - f_lb);
113-
udot[N - 1] = -1.0 / dx * (f_rb - flux_hat[N-2]);
114+
udot[N - 1] = -1.0 / dx * (f_rb - flux_hat[N - 2]);
114115

115116
retval = 0;
116117

@@ -146,7 +147,6 @@ main(int argc, char *argv[])
146147
double dt_max;
147148
int status = 1; // Aux variable to check for errors.
148149

149-
150150
status = compute_initial_condition_(N, y0, grid, &dx, &dt_max);
151151
assert(status == 0);
152152

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

180180
// Time step.
181181
double dt = dt_max;
182-
int n_time_steps = (int) (t_final / dt + 1);
182+
int n_time_steps = (int)(t_final / dt + 1);
183183
for (int i = 0; i < n_time_steps; ++i) {
184184
double t = t0 + (i + 1) * dt;
185185
if (t > t_final) {
@@ -212,4 +212,3 @@ main(int argc, char *argv[])
212212

213213
return retval;
214214
}
215-

0 commit comments

Comments
 (0)