-
Notifications
You must be signed in to change notification settings - Fork 95
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
Fix lots of clang-tidy issues in fv_ops #3007
base: next
Are you sure you want to change the base?
Conversation
Mostly: - include required headers - rename some short identifiers - make some local variables `const` - in a few cases, this involved renaming them to avoid reuse of the same variable for different cases (e.g. left/right fluxes)
clang-tidy review says "All clean, LGTM! 👍" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am a bit worried about adding not-needed writes by default.
I would be fine if they would only be present with -DCHECK>0
as I do not expect that they add significant overhead, but it still does not feels like something we should be doing for -DCHECK=0
#include "bout/utils.hxx" | ||
#include <bout/mesh.hxx> | ||
#include <cmath> | ||
#include <cstdlib> | ||
|
||
namespace FV { | ||
/*! | ||
* Div ( a Grad_perp(f) ) -- ∇⊥ ( a ⋅ ∇⊥ f) -- Vorticity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
* Div ( a Grad_perp(f) ) -- ∇⊥ ( a ⋅ ∇⊥ f) -- Vorticity | |
* Div ( a Grad_perp(f) ) -- ∇⊥ ( a_coef ⋅ ∇⊥ f) -- Vorticity |
BoutReal c = BoutNaN, m = BoutNaN, p = BoutNaN, mm = BoutNaN, pp = BoutNaN; | ||
|
||
// Left and right cell face values | ||
BoutReal L, R; | ||
BoutReal L = BoutNaN, R = BoutNaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we not worried about performance implications?
|
||
//////////////////////////////////////////// | ||
// Right boundary | ||
|
||
// Calculate velocity at right boundary (y+1/2) | ||
BoutReal vpar = 0.5 * (v(i, j, k) + v(i, j + 1, k)); | ||
BoutReal flux; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
performance implications?
|
||
if ((i.x() == mesh->xend) && (mesh->lastX())) { | ||
// At right boundary in X | ||
if (bndry_flux) { | ||
BoutReal flux; | ||
if (vR > 0.0) { | ||
BoutReal flux = BoutNaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
performance? Apparently the compiler cannot deduct that flux is always written, and thus cannot optimize the not-needed write ...
@@ -451,21 +463,21 @@ const Field3D Div_f_v(const Field3D& n_in, const Vector3D& v, bool bndry_flux) { | |||
// At left boundary in X | |||
|
|||
if (bndry_flux) { | |||
BoutReal flux; | |||
if (vL < 0.0) { | |||
BoutReal flux = BoutNaN; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
performance?
Not too concerned about performance really, initialisation doesn't tend to have much a real world impact, especially given all the conditionals we've got in this loops. Initialising to zero (instead of NaN) is one option, this basically has no impact as it can be done for free using allocation via zero-pages. Some of these at least could be rewritten as ternaries, allowing us to make the variable |
Mostly:
const
same variable for different cases (e.g. left/right fluxes)
This is mostly to avoid getting the clang-tidy warnings in #2873