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

[WIP] FieldReduction.H : make volume calculation more compact using std::reduce over dx vector #5691

Conversation

lucafedeli88
Copy link
Member

This PR makes the calculation of the cell_volume here more readable.

@lucafedeli88 lucafedeli88 added the cleaning Clean code, improve readability label Feb 20, 2025
// If reduction operation is a sum, multiply the value by the cell volume so that the
// result is the integral of the function over the simulation domain.
const auto cell_volume = std::reduce(std::begin(dx), std::end(dx), 1.0_rt, std::multiplies<>());
reduce_value *= cell_volume;
}
Copy link
Member

Choose a reason for hiding this comment

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

I've done things like this, which is also compact

reduce_value *= AMREX_D_TERM(dx[0], *dx[1], *dx[2]);

In fact, I already make this change in PR #5189.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, I see... sorry! Then, this PR has no reason to exist. I will close it immediately!

@dpgrote
Copy link
Member

dpgrote commented Feb 21, 2025

@lucafedeli88 This PR could submit the small change. This would help reduce the size of PR #5189 a little, as it is a very large PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cleaning Clean code, improve readability
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants