Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration of the initialization done after interpolation while applying an affect #2507

Merged
merged 2 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Hence, we need to have two separate functions.

function _change_t_via_interpolation!(integrator, t,
modify_save_endpoint::Type{Val{T}}) where {T}
modify_save_endpoint::Type{Val{T}}, reinitialization_method=nothing) where {T}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
modify_save_endpoint::Type{Val{T}}, reinitialization_method=nothing) where {T}
modify_save_endpoint::Type{Val{T}}, initialize_alg=nothing) where {T}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

either this or callback_initializealg? The choice here doesn't follow the naming conventions or the other names.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How about reinitalize_alg? I'm not super happy with simply calling it initialize_alg because it doesn't answer the question of "why does something that occurs mid-solve need to do initialization?" While "reinitialize" doesn't capture that super clearly, I think it's more obvious then just initialize_alg.

# Can get rid of an allocation here with a function
# get_tmp_arr(integrator.cache) which gives a pointer to some
# cache array which can be modified.
Expand All @@ -17,7 +17,7 @@ function _change_t_via_interpolation!(integrator, t,
end
integrator.t = t
integrator.dt = integrator.t - integrator.tprev
DiffEqBase.reeval_internals_due_to_modification!(integrator)
DiffEqBase.reeval_internals_due_to_modification!(integrator; callback_initializealg=reinitialization_method)
if T
solution_endpoint_match_cur_integrator!(integrator)
end
Expand All @@ -28,10 +28,10 @@ function DiffEqBase.change_t_via_interpolation!(integrator::ODEIntegrator,
t,
modify_save_endpoint::Type{Val{T}} = Val{
false,
}) where {
}, reinitialization_method=nothing) where {
T,
}
_change_t_via_interpolation!(integrator, t, modify_save_endpoint)
_change_t_via_interpolation!(integrator, t, modify_save_endpoint, reinitialization_method)
return nothing
end

Expand Down
Loading