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

Turn off redundant residual computations if tolerance np.inf #1229

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

jwboth
Copy link
Contributor

@jwboth jwboth commented Sep 17, 2024

Proposed changes

This is a minor change. Currently, the residual is always computed as part of the convergence check. However, in the case when the tolerance for the residual is np.inf, which is also the default value, this computation is redundant. This PR suggests turning off the unnecessary computation. This leads to some design choice how to forward empty residuals and norms. There may be other solutions. I am open for comments.

Types of changes

What types of changes does this PR introduce to PorePy?
Put an x in the boxes that apply.

  • Minor change (e.g., dependency bumps, broken links).
  • Bugfix (non-breaking change which fixes an issue).
  • New feature (non-breaking change which adds functionality).
  • Breaking change (fix or feature that would cause existing functionality to not work as expected).
  • Testing (contribution related to testing of existing or new functionality).
  • Documentation (contribution related to adding, improving, or fixing documentation).
  • Maintenance (e.g., improve logic and performance, remove obsolete code).
  • Other:

Checklist

Put an x in the boxes that apply or explain briefly why the box is not relevant.

  • The documentation is up-to-date.
  • Static typing is included in the update.
  • This PR does not duplicate existing functionality.
  • The update is covered by the test suite (including tests added in the PR).
  • If new skipped tests have been introduced in this PR, pytest was run with the --run-skipped flag.

Copy link
Contributor

@IvarStefansson IvarStefansson left a comment

Choose a reason for hiding this comment

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

I like the idea to avoid computation. Please consider the comment about optional arguments in particular.

src/porepy/models/solution_strategy.py Show resolved Hide resolved
src/porepy/models/solution_strategy.py Outdated Show resolved Hide resolved
src/porepy/models/solution_strategy.py Outdated Show resolved Hide resolved
src/porepy/numerics/nonlinear/nonlinear_solvers.py Outdated Show resolved Hide resolved
Copy link
Contributor

@IvarStefansson IvarStefansson left a comment

Choose a reason for hiding this comment

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

With your clarification of Optional, the rest should be easy.

src/porepy/numerics/nonlinear/nonlinear_solvers.py Outdated Show resolved Hide resolved
src/porepy/numerics/nonlinear/nonlinear_solvers.py Outdated Show resolved Hide resolved
@jwboth
Copy link
Contributor Author

jwboth commented Jan 9, 2025

Sorry for the massive delay...I fixed the remaining issues and followed all of your suggestions.

@keileg
Copy link
Contributor

keileg commented Jan 9, 2025

I think this should be fine now, but please have a short look as well @IvarStefansson.

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