Skip to content

Add in riesz map and remove pc update#713

Merged
jshipton merged 13 commits into
mainfrom
compressible_fix
Mar 24, 2026
Merged

Add in riesz map and remove pc update#713
jshipton merged 13 commits into
mainfrom
compressible_fix

Conversation

@atb1995

@atb1995 atb1995 commented Mar 12, 2026

Copy link
Copy Markdown
Collaborator

Quick fixes to compressible solver to speed it up

Comment thread gusto/solvers/preconditioners.py Outdated
Comment thread gusto/solvers/preconditioners.py Outdated
Comment on lines +485 to +489
self.theta_solver_parameters = self._get_sub_params(opts, prefix + "theta_backsub")
self.exner_avg_solver_parameters = self._get_sub_params(opts, prefix + "exner_ave")
self.rho_avg_solver_parameters = self._get_sub_params(opts, prefix + "rho_ave")
self.riesz_map_parameters = self._get_sub_params(opts, prefix + "riesz_map")
self.scpc_solve_parameters = self._get_sub_params(opts, prefix + "scpc_solve")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This isn't necessary, just give each solver the right prefix and they will grab these options themselves.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

So something like:

      self.exner_avg_solver = LinearVariationalSolver(
            options_prefix=pc.getOptionsPrefix()+'exner_ave'
        )
        

What about RieszMap which has no options_prefix as an argument?

@JHopeCollins JHopeCollins Mar 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Arguably that is an oversight. Nevertheless, you can ask PETSc to get all the options with a particular prefix:

prefixed_options = PETSc.Options("prefix_")  # This is another Options object
options_dict = PETSc.Options("prefix_").getAll()  # this is a python dict for solver_parameters

If PETSc.Options() contains "prefix_obj_option" then PETSc.Options("prefix_") will contain "obj_option"`.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

But yes for the other solvers that is exactly what I meant.

Comment thread gusto/solvers/preconditioners.py Outdated
Comment thread gusto/solvers/solver_presets.py Outdated
# bespoke hybridization preconditioner for this system owing to the
# nonlinear pressure gradient term.
r_tol = 1e-8
a_tol = 1e-8

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The right atol depends on the dimension of the problem, so hardcoding it may lead to some unexpected behaviour if someone tries a problem with particularly different scales.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You would suggest just not setting it at all?

@JHopeCollins JHopeCollins Mar 19, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Personally no, but that's it is opinion, I was just pointing it out. If atol was part of the options before then it isn't up to me to decide gusto policy!
If the majority of use cases have scales O(earth) then it isn't unreasonable, it just needs bearing in mind.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If both rtol and atol are set, does it stop as soon as either are met? I wonder which one we're hitting...

@JHopeCollins JHopeCollins Mar 23, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yes, it will stop as soon as any of atol, rtol, divtol, stol, or max_it are hit. If you are hitting divtol or stol you are definitely in trouble but it tends to be obvious.

The message from either ksp_converged_reason, ksp_converged_rate, or snes_converged_reason will say what convergence criteria was met.

atol might mean you stop prematurely if you have something with small physical scales that hasn't been nondimensionalised.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@atb1995 @tommbendall do either of you have any logs that contain the convergence reasons? In general, I agree with Josh that we should not be setting atol but I am also wary of changing too much in one go!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I imagine it is unlikely for you to be hitting atol for anything on the globe. But maybe for something local or nondimensionalised if the initial residual is O(1) or smaller.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

It is always hitting r_tol as far as I am aware, we are getting nowhere near 1e-8 atol for a lot of the runs I am doing at least

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

let's get rid then

@atb1995 atb1995 marked this pull request as ready for review March 20, 2026 15:55
@atb1995 atb1995 self-assigned this Mar 20, 2026
@atb1995 atb1995 requested a review from tommbendall March 20, 2026 15:55
@jshipton jshipton merged commit b2b34f8 into main Mar 24, 2026
7 of 9 checks passed
@jshipton jshipton deleted the compressible_fix branch March 24, 2026 17:03
tommbendall pushed a commit that referenced this pull request Apr 22, 2026
Co-authored-by: Josh Hope-Collins <joshua.hope-collins13@imperial.ac.uk>
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.

3 participants