KnutAM / FESolvers.jl

Solvers for Ferrite.jl problems
https://knutam.github.io/FESolvers.jl/dev
MIT License
3 stars 0 forks source link

convergence status generalization #26

Closed KnutAM closed 6 months ago

KnutAM commented 1 year ago

Currently, the non-convergence is just a bool returned from solve_nonlinear!, however, it might make sense to allow more custom behavior if, for example, the linear solve doesn't converge. One solution could be that the nonlinear solvers should keep track of their status, and the outer time stepping loop could change from

while !(converged && islaststep(timestepper, t, step))
    t, step = update_time(solver, t, step, converged)
    update_to_next_step!(problem, t)
    converged = solve_nonlinear!(problem, nlsolver, converged)
    if converged
        copy!(xold, getunknowns(problem))
        postprocess!(problem, step, solver)
        handle_converged!(problem)
    else
        # Reset unknowns if it didn't converge to 
        setunknowns!(problem, xold)
    end
end

to

while !(is_converged(nlsolver) && islaststep(timestepper, t, step))
    t, step = update_time(solver, t, step)
    update_to_next_step!(problem, t)
    solve_nonlinear!(problem, nlsolver)
    if is_converged(nlsolver)
        copy!(xold, getunknowns(problem))
        postprocess!(problem, step, solver)
        handle_converged!(problem)
    else
        # Reset unknowns if it didn't converge to 
        setunknowns!(problem, xold)
    end
end
KnutAM commented 1 year ago

Side note For the time stepping, it could also make sense that the time steppers should keep track of the time and step number, and then the following simplifications could be made