Skip to content

Commit 78c5eb2

Browse files
authored
Merge branch 'main' into chore/releaseUpdates
2 parents e96ad06 + e2cf31a commit 78c5eb2

File tree

1 file changed

+14
-19
lines changed

1 file changed

+14
-19
lines changed

src/pybammsolvers/idaklu_source/IDAKLUSolverOpenMP.inl

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -484,7 +484,7 @@ SolutionData IDAKLUSolverOpenMP<ExprSet>::solve(
484484
}
485485

486486
if (hit_tinterp) {
487-
// Save the interpolated state at t_prev < t < t_val, for all t in t_interp
487+
// Save the interpolated state at t_prev < t <= t_val, for all t in t_interp
488488
SetStepInterp(
489489
i_interp,
490490
t_interp_next,
@@ -499,26 +499,15 @@ SolutionData IDAKLUSolverOpenMP<ExprSet>::solve(
499499
i_save);
500500
}
501501

502-
if (hit_adaptive || hit_teval || hit_event || hit_final_time) {
503-
if (hit_tinterp) {
504-
// Reset the states and sensitivities at t = t_val
505-
CheckErrors(IDAGetDky(ida_mem, t_val, 0, yy));
506-
if (sensitivity) {
507-
CheckErrors(IDAGetSensDky(ida_mem, t_val, 0, yyS));
508-
}
502+
// Check that we are not saving the same time point twice,
503+
// which is possible if t_interp contains t_val.
504+
if ((t_val != t[i_save-1]) && (hit_adaptive || hit_teval || hit_event || hit_final_time)) {
505+
if (hit_adaptive) {
506+
// Dynamically allocate memory for the adaptive step
507+
ExtendAdaptiveArrays();
509508
}
510509

511-
// Save the current state at t_val
512-
// First, check to make sure that the t_val is not equal to the current t value
513-
// If it is, we don't want to save the current state twice
514-
if (!hit_tinterp || t_val != t.back()) {
515-
if (hit_adaptive) {
516-
// Dynamically allocate memory for the adaptive step
517-
ExtendAdaptiveArrays();
518-
}
519-
520-
SetStep(t_val, y_val, yp_val, yS_val, ypS_val, i_save);
521-
}
510+
SetStep(t_val, y_val, yp_val, yS_val, ypS_val, i_save);
522511
}
523512

524513
if (hit_final_time || hit_event) {
@@ -788,6 +777,12 @@ void IDAKLUSolverOpenMP<ExprSet>::SetStepInterp(
788777
}
789778
t_interp_next = t_interp[i_interp];
790779
}
780+
781+
// Reset the states and sensitivities to t = t_val
782+
CheckErrors(IDAGetDky(ida_mem, t_val, 0, yy));
783+
if (sensitivity) {
784+
CheckErrors(IDAGetSensDky(ida_mem, t_val, 0, yyS));
785+
}
791786
}
792787

793788
template <class ExprSet>

0 commit comments

Comments
 (0)