Skip to content

Conversation

albert-de-montserrat
Copy link
Collaborator

Adds a new keyword ϵ_nonlinear (Inf by default) to the Stokes solvers. Non linearities (viscosity and plastic corrections) are not considered while the global error is err > ϵ_nonlinear. Seems to help convergence in highly complex models.

# compute buoyancy forces and viscosity
compute_ρg!(ρg, phase_ratios, rheology, args)
compute_viscosity!(stokes, phase_ratios, args, rheology, viscosity_cutoff)
displacement2velocity!(stokes, dt, flow_bcs)

while iter ≤ iterMax
iterMin < iter && ((err / err_it1) < ϵ_rel || err < ϵ_abs) && break
# iterMin < iter && ((err / err_it1) < ϵ_rel && err < ϵ_abs) && break
Copy link
Collaborator

@aelligp aelligp Jul 28, 2025

Choose a reason for hiding this comment

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

Suggested change
# iterMin < iter && ((err / err_it1) < ϵ_rel && err < ϵ_abs) && break
iterMin < iter && ((err / err_it1) < ϵ_rel || err < ϵ_abs) && break

this needs to be like this. otherwise it doesn't break if the relative tolerance is below its set value but the abs is not. same vise versa.
And I think it shouldn't be commented as there's no break condition anymore.

Copy link
Collaborator Author

@albert-de-montserrat albert-de-montserrat Jul 29, 2025

Choose a reason for hiding this comment

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

Needs to be &&, otherwise imagine you have ϵ_rel=1e-2 and your PT iterations starts at an error in the order of 1e2, then it would break at around err=1e0, which is not what you want

@@ -724,8 +725,9 @@ function _solve!(
isnan(err) && error("NaN(s)")
end

if igg.me == 0 && ((err / err_it1) < ϵ_rel || (err < ϵ_abs))
if igg.me == 0 && iterMin < iter && ((err / err_it1) < ϵ_rel && err < ϵ_abs)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
if igg.me == 0 && iterMin < iter && ((err / err_it1) < ϵ_rel && err < ϵ_abs)
if igg.me == 0 && iterMin < iter && ((err / err_it1) < ϵ_rel ||err < ϵ_abs)

see above

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants