Skip to content

Commit

Permalink
improve handling of mesh adaptation of collocation
Browse files Browse the repository at this point in the history
  • Loading branch information
rveltz committed Apr 15, 2024
1 parent eafc49b commit 6d00223
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/periodicorbit/NormalForms.jl
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@ function period_doubling_normal_form(pbwrap::WrapPOColl,
# computation of c
# we need B(t, v₁(t), h₂(t))
for i=1:size(Bₛ, 2)
Bₛ[:,i] .= B(u₀ₛ[:,i], par, v₁ₛ[:,i], h₂ₛ[:,i])
Bₛ[:,i] .= B(u₀ₛ[:,i], par, v₁ₛ[:,i], h₂ₛ[:,i])
end
# _plot(vcat(vec( Bₛ ),1), label = "Bₛ for h2")
# _plot(vcat(vec(@. Bₛ * v₁★ₛ ),1), label = "Bₛ*v1star")
Expand Down
10 changes: 9 additions & 1 deletion src/periodicorbit/PeriodicOrbitUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,16 @@ function (finalizer::Finaliser{ <: Union{ <: PeriodicOrbitOCollProblem,
state = get(kF, :state, nothing)
success = converged(state)
bisection = in_bisection(state)
is_mesh_updated = false

# mesh adaptation
if success && coll.meshadapt && bisection == false
if success &&
coll.meshadapt &&
bisection == false &&
mod_counter(step, updateSectionEveryStep) == 1 &&
step > 2
@debug "[Collocation] update mesh"
is_mesh_updated = true
oldsol = _copy(z) # avoid possible overwrite in compute_error!
oldmesh = get_times(coll) .* getperiod(coll, oldsol.u, nothing)
adapt = compute_error!(coll, oldsol.u;
Expand All @@ -95,6 +102,7 @@ function (finalizer::Finaliser{ <: Union{ <: PeriodicOrbitOCollProblem,
return false
end
end

if success && mod_counter(step, updateSectionEveryStep) == 1 && bisection == false
@debug "[collocation] update section"
updatesection!(coll, z.u, setparam(contResult, z.p))
Expand Down

0 comments on commit 6d00223

Please sign in to comment.