Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Coarse level options for AMG preconditioner #359

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

sseraj
Copy link
Collaborator

@sseraj sseraj commented May 31, 2024

Purpose

This PR adds separate ASM overlap, ILU fill level, and inner (ILU) iteration options for the coarse levels when using the AMG preconditioner. The motivation behind this is to allow for cheaper iterations at the coarse levels to speed up the overall solution time. The defaults for the coarse levels are set to the cheapest options possible (no ASM overlap, no ILU fill, 1 inner iteration). This changes the default behavior but should be advantageous for most cases.

Expected time until merged

2-3 weeks

Type of change

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (non-backwards-compatible fix or feature)
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no API changes)
  • Documentation update
  • Maintenance update
  • Other (please describe)

Testing

I added an AMG test with non-default options. The default options are used in the existing tests.

Checklist

  • I have run flake8 and black to make sure the Python code adheres to PEP-8 and is consistently formatted
  • I have formatted the Fortran code with fprettify or C/C++ code with clang-format as applicable
  • I have run unit and regression tests which pass locally with my changes
  • I have added new tests that prove my fix is effective or that my feature works
  • I have added necessary documentation

@sseraj sseraj requested a review from a team as a code owner May 31, 2024 18:22
@sseraj sseraj requested review from lamkina and eirikurj May 31, 2024 18:22
@sseraj sseraj changed the title Coarse grid options for AMG preconditioner Coarse level options for AMG preconditioner May 31, 2024
Copy link

codecov bot commented May 31, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 41.13%. Comparing base (6706920) to head (8491661).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #359   +/-   ##
=======================================
  Coverage   41.13%   41.13%           
=======================================
  Files          13       13           
  Lines        4108     4108           
=======================================
  Hits         1690     1690           
  Misses       2418     2418           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

anilyil
anilyil previously approved these changes Jun 17, 2024
@anilyil anilyil self-requested a review June 18, 2024 21:49
@anilyil
Copy link
Contributor

anilyil commented Jun 18, 2024

After reviewing this a bit more, I noticed that we do not have the option to add iterative refinement with the AMG PC. Even though NK and ANK solvers default to no refinement, would it make sense to add a similar block like:

        ! Set the orthogonalization method for GMRES
        select case (GMRESOrthogType)
        case ('modified_gram_schmidt')
            ! Use modified Gram-Schmidt
            call KSPGMRESSetOrthogonalization(kspObject, KSPGMRESModifiedGramSchmidtOrthogonalization, ierr)
        case ('cgs_never_refine')
            ! Use classical Gram-Schmidt with no refinement
            call KSPGMRESSetCGSRefinementType(kspObject, KSP_GMRES_CGS_REFINE_NEVER, ierr)
        case ('cgs_refine_if_needed')
            ! Use classical Gram-Schmidt with refinement if needed
            call KSPGMRESSetCGSRefinementType(kspObject, KSP_GMRES_CGS_REFINE_IFNEEDED, ierr)
        case ('cgs_always_refine')
            ! Use classical Gram-Schmidt with refinement at every iteration
            call KSPGMRESSetCGSRefinementType(kspObject, KSP_GMRES_CGS_REFINE_ALWAYS, ierr)
        end select
        call EChk(ierr, __FILE__, __LINE__)

to the AMG PC setup?

@anilyil
Copy link
Contributor

anilyil commented Jul 5, 2024

The new changes look good. I also want to add the option to enable iterative refinement to ANK and NK if desired. Default should be no refinement as that is what the code is doing for all cases now.

I want to add 2 python options that control this behavior: ANKUseGMRESRefinement and NKUseGMRESRefinement or we can replace GMRES with "Orthog" or something along those lines. Then these options can be added around the code where ANK and NK disables refinement (e.g. here for ANK: https://github.com/mdolab/adflow/blob/main/src/NKSolver/NKSolvers.F90#L2027-L2029)

Should we make this change in this PR or should I create a new PR for this? I can also make these changes here and push. Up to you @sseraj.

@sseraj
Copy link
Collaborator Author

sseraj commented Jul 6, 2024

I think it would be better to make the ANK and NK changes in a separate PR

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.

None yet

3 participants