Skip to content

Commit

Permalink
ODESolvers: reduce calling rhs by storeing k1
Browse files Browse the repository at this point in the history
  • Loading branch information
lwJi committed Sep 19, 2024
1 parent 0d77e9d commit 193ef55
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions ODESolvers/src/solve.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -982,13 +982,8 @@ extern "C" void ODESolvers_Solve(CCTK_ARGUMENTS) {
// y0
const auto old = copy_state(var, make_valid_all());

// replace state u with u_p
statecomp_t::lincomb(var, 0.0, reals<1>{1.0}, states<1>{&pre},
make_valid_all());

// calculate k0
calcrhs(1);
const auto k0 = copy_state(rhs, make_valid_int());
// copy k0 from pre
const auto k0 = copy_state(pre, make_valid_int());
calcupdate(1, dt / 2, 0.0, reals<1>{1.0}, states<1>{&old});

// calculate k1
Expand All @@ -1009,9 +1004,9 @@ extern "C" void ODESolvers_Solve(CCTK_ARGUMENTS) {
calcupdate(4, dt, 0.0, reals<5>{1.0, c6, c7, c8, c9},
states<5>{&old, &k0, &k1, &k2, &k3});

// update pre
statecomp_t::lincomb(pre, 0.0, reals<1>{1.0}, states<1>{&old},
make_valid_all());
// update pre with k1
statecomp_t::lincomb(pre, 0.0, reals<1>{1.0}, states<1>{&k1},
make_valid_int());

} else if (CCTK_EQUALS(method, "RKF78")) {

Expand Down

0 comments on commit 193ef55

Please sign in to comment.