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

Performance improvements for Fix lots of clang-tidy issues in fv_ops #3037

Open
wants to merge 2 commits into
base: fvops-clang-tidy
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions include/bout/fv_ops.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,17 @@ Field3D D4DY4_index(const Field3D& f_in, bool bndry_flux = true);
*/
struct Stencil1D {
// Cell centre values
#if CHECK > 0
BoutReal c = BoutNaN, m = BoutNaN, p = BoutNaN, mm = BoutNaN, pp = BoutNaN;

// Left and right cell face values
BoutReal L = BoutNaN, R = BoutNaN;
#else
BoutReal c, m, p, mm, pp;

// Left and right cell face values
BoutReal L, R;
#endif
};

/*!
Expand Down Expand Up @@ -436,14 +443,12 @@ Field3D Div_f_v(const Field3D& n_in, const Vector3D& v, bool bndry_flux) {
if ((i.x() == mesh->xend) && (mesh->lastX())) {
// At right boundary in X
if (bndry_flux) {
BoutReal flux = BoutNaN;
if (v_R > 0.0) {
// Flux to boundary
flux = v_R * stencil.R;
} else {
// Flux in from boundary
flux = v_R * 0.5 * (n_in[i.xp()] + n_in[i]);
}
const BoutReal flux = v_R > 0.0 ?
// Flux to boundary
v_R * stencil.R
:
// Flux in from boundary
v_R * 0.5 * (n_in[i.xp()] + n_in[i]);
result[i] += flux / (coord->dx[i] * coord->J[i]);
result[i.xp()] -= flux / (coord->dx[i.xp()] * coord->J[i.xp()]);
}
Expand All @@ -463,14 +468,12 @@ Field3D Div_f_v(const Field3D& n_in, const Vector3D& v, bool bndry_flux) {
// At left boundary in X

if (bndry_flux) {
BoutReal flux = BoutNaN;
if (v_L < 0.0) {
// Flux to boundary
flux = v_L * stencil.L;
} else {
// Flux in from boundary
flux = v_L * 0.5 * (n_in[i.xm()] + n_in[i]);
}
const BoutReal flux = (v_L < 0.0) ?
// Flux to boundary
v_L * stencil.L
:
// Flux in from boundary
v_L * 0.5 * (n_in[i.xm()] + n_in[i]);
result[i] -= flux / (coord->dx[i] * coord->J[i]);
result[i.xm()] += flux / (coord->dx[i.xm()] * coord->J[i.xm()]);
}
Expand Down
Loading