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

Refactor cell diameter computation to utilities #1265

Merged
merged 5 commits into from
Aug 29, 2024

Conversation

AmishgaAlphonius
Copy link
Collaborator

@AmishgaAlphonius AmishgaAlphonius commented Aug 27, 2024

Description

The cell diameter calculation was repeated in every scratch data. This PR refactors it in an inline function in the utilities.

Testing

No impact on current tests.

Checklist (will be removed when merged)

See this page for more information about the pull request process.

Code related list:

  • All in-code documentation related to this PR is up to date (Doxygen format)
  • Lethe documentation is up to date
  • The branch is rebased onto master
  • Code is indented with indent-all and .prm files (examples and tests) with prm-indent
  • If parameters are modified, the tests and the documentation of examples are up to date
  • Changelog (CHANGELOG.md) is up to date if the refactor affects the user experience or the codebase

Pull request related list:

  • No other PR is open related to this refactoring
  • Labels are applied
  • There are at least 2 reviewers (or 1 if small feature) excluding the responsible for the merge
  • If this PR closes an issue or is related to a project, it is linked in the "Projects" or "Development" section
  • If any future works is planed, an issue is opened
  • The PR description is cleaned and ready for merge

@AmishgaAlphonius AmishgaAlphonius added Ready for review Refactoring This PR is only refactoring or clean up Utilities labels Aug 27, 2024
@AmishgaAlphonius AmishgaAlphonius self-assigned this Aug 27, 2024
@AmishgaAlphonius AmishgaAlphonius added WIP When a PR is open but not ready for review and removed Ready for review labels Aug 27, 2024
Copy link
Contributor

@blaisb blaisb left a comment

Choose a reason for hiding this comment

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

One small thing to change

Comment on lines 604 to 615
double h;
if constexpr (dim == 2)
h = std::sqrt(4. * cell_measure / numbers::PI) / fe_degree;
else if constexpr (dim == 3)
h = std::pow(6. * cell_measure / numbers::PI, 1. / 3.) / fe_degree;
return h;
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
double h;
if constexpr (dim == 2)
h = std::sqrt(4. * cell_measure / numbers::PI) / fe_degree;
else if constexpr (dim == 3)
h = std::pow(6. * cell_measure / numbers::PI, 1. / 3.) / fe_degree;
return h;
if constexpr (dim == 2)
return std::sqrt(4. * cell_measure / numbers::PI) / fe_degree;
else if constexpr (dim == 3)
return std::cbrt(6. * cell_measure / numbers::PI, 1. / 3.) / fe_degree;
else
Assert("....")

The code does not support 1D anyway right now so might as well assert if the wrong number is called instead of returning something without an initial value.

@AmishgaAlphonius AmishgaAlphonius added Ready for review and removed WIP When a PR is open but not ready for review labels Aug 27, 2024
include/core/utilities.h Outdated Show resolved Hide resolved
include/core/utilities.h Outdated Show resolved Hide resolved
@AmishgaAlphonius AmishgaAlphonius force-pushed the refactor-cell-size-to-utilities branch from 2763a9f to cbe3b5c Compare August 28, 2024 17:45
@AmishgaAlphonius AmishgaAlphonius force-pushed the refactor-cell-size-to-utilities branch from cbe3b5c to 3a29bd9 Compare August 28, 2024 20:51
@blaisb blaisb merged commit a9099c0 into master Aug 29, 2024
10 of 11 checks passed
@blaisb blaisb deleted the refactor-cell-size-to-utilities branch August 29, 2024 00:18
M-Badri pushed a commit to M-Badri/lethe that referenced this pull request Sep 29, 2024
Description
The cell diameter calculation was repeated in every scratch data. This PR refactors it in an inline function in the utilities.

Testing
No impact on current tests.

Co-authored-by: Bruno Blais <[email protected]>
Former-commit-id: a9099c0
blaisb added a commit that referenced this pull request Sep 30, 2024
Description
The cell diameter calculation was repeated in every scratch data. This PR refactors it in an inline function in the utilities.

Testing
No impact on current tests.

Co-authored-by: Bruno Blais <[email protected]>
Former-commit-id: a9099c0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants