Skip to content

Remove allocations from reinit! with reset_dt = true #3231

@jClugstor

Description

@jClugstor

Is your feature request related to a problem? Please describe.
If you reinit! an integrator with reset_dt = true it always allocates. I would like to try to see if there's a way to calculate the initial dt value without allocating.

using OrdinaryDiffEq

# Simple exponential decay: du/dt = -u (in-place)
f!(du, u, _, _) = (du[1] = -u[1]; nothing)

u0 = [1.0]
tspan = (0.0, 1.0)
prob = ODEProblem(f!, u0, tspan)
integrator = init(prob, Tsit5())

# Warm up
reinit!(integrator)
solve!(integrator)

# reinit! allocates even on a plain ODE with no DAE initialization
println("Allocations from reinit!:")
allocs = @allocated reinit!(integrator)
@profview_allocs reinit!(integrator) sample_rate = 1.0
Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions