Skip to content

Commit 699d8be

Browse files
committed
template out the copy
1 parent 461079b commit 699d8be

File tree

1 file changed

+28
-10
lines changed

1 file changed

+28
-10
lines changed

integration/integrator.H

+28-10
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,40 @@
77
#include <actual_integrator.H>
88
#endif
99

10-
template <typename BurnT>
10+
template <typename BurnT, bool enable_retry>
1111
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
12-
void integrator (BurnT& state, Real dt)
12+
void integrator_wrapper (BurnT& state, Real dt)
1313
{
1414

15-
burn_t old_state;
16-
if (use_burn_retry) {
17-
old_state = state;
15+
if constexpr (enable_retry) {
16+
burn_t old_state{state};
17+
18+
actual_integrator(state, dt);
19+
20+
if (!state.success) {
21+
state = old_state;
22+
const bool is_retry = true;
23+
actual_integrator(state, dt, is_retry);
24+
}
25+
} else {
26+
actual_integrator(state, dt);
1827
}
1928

20-
actual_integrator(state, dt);
29+
}
30+
31+
32+
template <typename BurnT>
33+
AMREX_GPU_HOST_DEVICE AMREX_FORCE_INLINE
34+
void integrator (BurnT& state, Real dt)
35+
{
36+
37+
if (integrator_rp::use_burn_retry) {
38+
constexpr bool enable_retry{true};
39+
integrator_wrapper<BurnT, enable_retry>(state, dt);
40+
} else {
41+
constexpr bool enable_retry{false};
42+
integrator_wrapper<BurnT, enable_retry>(state, dt);
2143

22-
if (!state.success && use_burn_retry) {
23-
state = old_state;
24-
const bool is_retry = true;
25-
actual_integrator(state, dt, is_retry);
2644
}
2745
}
2846

0 commit comments

Comments
 (0)