Skip to content

Commit

Permalink
clang-format
Browse files Browse the repository at this point in the history
  • Loading branch information
lucbv committed Jun 5, 2024
1 parent 9218a41 commit 8dc5236
Showing 1 changed file with 12 additions and 11 deletions.
23 changes: 12 additions & 11 deletions ode/impl/KokkosODE_RungeKutta_impl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ template <class ode_type, class table_type, class vec_type, class mv_type,
class scalar_type>
KOKKOS_FUNCTION void RKStep(ode_type& ode, const table_type& table,
scalar_type t, scalar_type dt,
const vec_type& y_old, const vec_type& y_new,
const vec_type& temp, const mv_type& k_vecs) {
const vec_type& y_old, const vec_type& y_new,
const vec_type& temp, const mv_type& k_vecs) {
const int neqs = ode.neqs;
const int nstages = table.nstages;

Expand Down Expand Up @@ -122,29 +122,29 @@ KOKKOS_FUNCTION Experimental::ode_solver_status RKSolve(

// Compute the largest error and decide on
// the size of the next time step to take.
error = 0;
error = 0;

// Compute estimation of the error using k_vecs and table.e
if (adapt == true) {

// Compute the error
for (int eqIdx = 0; eqIdx < ode.neqs; ++eqIdx) {
tol = params.abs_tol +
params.rel_tol *
Kokkos::max(Kokkos::abs(y(eqIdx)), Kokkos::abs(y0(eqIdx)));
error_n = 0;
for (int stageIdx = 0; stageIdx < table.nstages; ++stageIdx) {
error_n += dt * table.e[stageIdx] * k_vecs(stageIdx, eqIdx);
}
error_n = 0;
for (int stageIdx = 0; stageIdx < table.nstages; ++stageIdx) {
error_n += dt * table.e[stageIdx] * k_vecs(stageIdx, eqIdx);
}
error = Kokkos::max(error, Kokkos::abs(error_n) / tol);
}

// Reduce the time step if error
// is too large and current step
// is rejected.
if (error > 1) {
dt = dt *
Kokkos::max(0.2, 0.8 * Kokkos::pow(error, -1.0 / (table.order + 1)));
dt =
dt * Kokkos::max(
0.2, 0.8 * Kokkos::pow(error, -1.0 / (table.order + 1)));
dt_was_reduced = true;
}

Expand All @@ -165,7 +165,8 @@ KOKKOS_FUNCTION Experimental::ode_solver_status RKSolve(
dt = dt *
Kokkos::min(
10.0,
Kokkos::max(2.0, 0.9 * Kokkos::pow(error, -1.0 / (table.order + 1))));
Kokkos::max(
2.0, 0.9 * Kokkos::pow(error, -1.0 / (table.order + 1))));
}
} else {
return Experimental::ode_solver_status::SUCCESS;
Expand Down

0 comments on commit 8dc5236

Please sign in to comment.