-
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
Coordinates: Replacing sqrt(g_22) with JB #3027
base: refactor-coordinates
Are you sure you want to change the base?
Conversation
Aiming to consistently handle left-handed coordinate systems, where J is negative. These happen in the standard BOUT++ field-aligned coordinates when the poloidal field is negative.
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.
clang-tidy made some suggestions
BoutReal by = 1. / sqrt(metric->g_22(x, y, z)); | ||
|
||
// Note: by is negative in a left-handed coordinate system | ||
BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z)); |
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.
warning: no viable conversion from 'Field2D' to 'BoutReal' (aka 'double') [clang-diagnostic-error]
BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z));
^
BoutReal by = 1. / sqrt(metric->g_22(x, y, z)); | ||
|
||
// Note: by is negative in a left-handed coordinate system | ||
BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z)); |
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.
warning: variable name 'by' is too short, expected at least 3 characters [readability-identifier-length]
BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z));
^
BoutReal by = 1. / sqrt(metric->g_22(x, y, z)); | ||
|
||
// Note: by is negative in a left-handed coordinate system | ||
BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z)); |
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.
warning: too many arguments to function call, expected 0, have 3 [clang-diagnostic-error]
BoutReal by = 1. / (metric->J(x, y, z) * metric->Bxy(x, y, z));
^
Additional context
include/bout/coordinates.hxx:237: 'Bxy' declared here
const FieldMetric& Bxy() const { return Bxy_; }
^
@@ -258,14 +260,13 @@ | |||
BoutReal const vR = 0.5 * (v(i, j, k) + v.yup()(i, j + 1, k)); | |||
|
|||
// Calculate flux at right boundary (y+1/2) | |||
// Note: Magnitude of B at the midpoint used rather than J/sqrt(g_22) | |||
BoutReal const fluxRight = |
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.
warning: no viable conversion from 'Field2D' to 'const BoutReal' (aka 'const double') [clang-diagnostic-error]
BoutReal const fluxRight =
^
BoutReal const fluxRight = | ||
fR * vR * (coord->J(i, j, k) + coord->J(i, j + 1, k)) | ||
/ (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j + 1, k))); | ||
fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k)); |
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.
warning: too many arguments to function call, expected 0, have 3 [clang-diagnostic-error]
fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k));
^
Additional context
include/bout/coordinates.hxx:237: 'Bxy' declared here
const FieldMetric& Bxy() const { return Bxy_; }
^
BoutReal const fluxRight = | ||
fR * vR * (coord->J(i, j, k) + coord->J(i, j + 1, k)) | ||
/ (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j + 1, k))); | ||
fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k)); |
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.
warning: too many arguments to function call, expected 0, have 3 [clang-diagnostic-error]
fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k));
^
Additional context
include/bout/coordinates.hxx:237: 'Bxy' declared here
const FieldMetric& Bxy() const { return Bxy_; }
^
BoutReal const fluxRight = | ||
fR * vR * (coord->J(i, j, k) + coord->J(i, j + 1, k)) | ||
/ (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j + 1, k))); | ||
fR * vR * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j + 1, k)); | ||
|
||
// Calculate at left boundary (y-1/2) | ||
BoutReal const fluxLeft = |
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.
warning: no viable conversion from 'Field2D' to 'const BoutReal' (aka 'const double') [clang-diagnostic-error]
BoutReal const fluxLeft =
^
|
||
// Calculate at left boundary (y-1/2) | ||
BoutReal const fluxLeft = | ||
fL * vL * (coord->J(i, j, k) + coord->J(i, j - 1, k)) | ||
/ (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j - 1, k))); | ||
fL * vL * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j - 1, k)); |
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.
warning: too many arguments to function call, expected 0, have 3 [clang-diagnostic-error]
fL * vL * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j - 1, k));
^
Additional context
include/bout/coordinates.hxx:237: 'Bxy' declared here
const FieldMetric& Bxy() const { return Bxy_; }
^
|
||
// Calculate at left boundary (y-1/2) | ||
BoutReal const fluxLeft = | ||
fL * vL * (coord->J(i, j, k) + coord->J(i, j - 1, k)) | ||
/ (sqrt(coord->g_22(i, j, k)) + sqrt(coord->g_22(i, j - 1, k))); | ||
fL * vL * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j - 1, k)); |
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.
warning: too many arguments to function call, expected 0, have 3 [clang-diagnostic-error]
fL * vL * 2 / (coord->Bxy(i, j, k) + coord->Bxy(i, j - 1, k));
^
Additional context
include/bout/coordinates.hxx:237: 'Bxy' declared here
const FieldMetric& Bxy() const { return Bxy_; }
^
Aiming to consistently handle left-handed coordinate systems, where J is negative. These happen in the standard BOUT++ field-aligned coordinates when the poloidal field is negative.
Implemented on top of
refactor-coordinates
#2873