Skip to content

Sync API is cumbersome (in my opinion) #12

@kylebeggs

Description

@kylebeggs

If my understanding is correct, to add a sync function to a GenericSplitFunction, you need to overload synchronize_solution_with_parameters!(integrator, params, sync::MySync) where MySync is some type the user must define. To be concrete, at minimum I need to define all the below:

struct MySync end
sync = MySync()

function OrdinaryDiffEqOperatorSplitting.synchronize_solution_with_parameters!(
    outer_integrator::OrdinaryDiffEqOperatorSplitting.OperatorSplittingIntegrator,
    ::SciMLBase.NullParameters,
    ::MySync
)
    @info "Sync called at time $(outer_integrator.t)"
end

I feel this is a bit cumbersome and would like to suggest just a function-based approach where the user just needs to supply a function directly such as

my_sync(outer_integrator, params) = ...

We would just need to add

function synchronize_solution_with_parameters!(outer_integrator::OperatorSplittingIntegrator, p, sync::F) where {F<:Function}
    sync(outer_integrator, p)
end

and we could still keep the other way as well. This should be OK since the functions should be known at compile time.

Am I missing something why this can't work? Or will hamper other wanted behavior?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions