-
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
3D metrics #2025
3D metrics #2025
Conversation
Allows to compile and run all tests by running: make -j 4 build-check-all && make check-all
The shift-transform in staggered location requieres dz. To calculate the staggered dz in y direction, the parallel transform is requiered. Thus we special handel the case if dz is constant, and we can do a trivial staggering, without a parallel transform. For non-const dz, staggered dz needs to be given in an input file, so we don't have to interpolate. Also make isConst a free function, similar to min and max.
If we are deeper nested, omp_get_thread_num isn't unique anymore
* Add metric3D to cmake * cmake with -DENABLE_METRIC_3D=ON to get 3D metrics * Due to the out-of-source build we need to python dirs, one for noarch files, and one for arched ones
otherwise python finds boututils in one pythonpath, and does not look in other locations for the other file.
Some solver throw errors otherwise
Read the environment variable BOUT_SHOW_BACKTRACE. If the variable is set, show the backtrace, otherwise just show the message. The allows to get the backtrace without having to attache gdb, or catch the exception. The default behaviour is not changed.
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
There were too many comments to post at once. Showing the first 25 out of 195. Check the log or trigger a new build to see more.
Previously no boundary was detection because the index cannot be out of bounds in both directions
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
There were too many comments to post at once. Showing the first 25 out of 170. Check the log or trigger a new build to see more.
REGION region = RGN_NOBNDRY) { \ | ||
return func(f, outloc, toString(method), toString(region)); \ | ||
} | ||
#define DERIV_FUNC_REGION_ENUM_TO_STRING(func, T, Tr) \ |
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: function-like macro DERIV_FUNC_REGION_ENUM_TO_STRING
used; consider a constexpr
template function [cppcoreguidelines-macro-usage]
#define DERIV_FUNC_REGION_ENUM_TO_STRING(func, T, Tr) \
^
@@ -94,9 +94,9 @@ void Vector2D::toCovariant() { | |||
const auto metric = localmesh->getCoordinates(location); | |||
|
|||
// Need to use temporary arrays to store result | |||
Field2D gx{emptyFrom(x)}, gy{emptyFrom(y)}, gz{emptyFrom(z)}; | |||
Coordinates::FieldMetric gx{emptyFrom(x)}, gy{emptyFrom(y)}, gz{emptyFrom(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: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
Coordinates::FieldMetric gx{emptyFrom(x)}, gy{emptyFrom(y)}, gz{emptyFrom(z)};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -146,9 +146,9 @@ void Vector2D::toContravariant() { | |||
const auto metric = localmesh->getCoordinates(location); | |||
|
|||
// Need to use temporary arrays to store result | |||
Field2D gx{emptyFrom(x)}, gy{emptyFrom(y)}, gz{emptyFrom(z)}; | |||
Coordinates::FieldMetric gx{emptyFrom(x)}, gy{emptyFrom(y)}, gz{emptyFrom(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: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
Coordinates::FieldMetric gx{emptyFrom(x)}, gy{emptyFrom(y)}, gz{emptyFrom(z)};
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Returning non-const objects has no disadvantage for const correctness and is easier to read.
* Previously, only the inner-most boundary point was set, which could cause problems with interpolation
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
There were too many comments to post at once. Showing the first 25 out of 145. Check the log or trigger a new build to see more.
@@ -371,11 +371,11 @@ const Vector3D Vector2D::operator/(const Field3D &rhs) const { | |||
|
|||
////////////////// DOT PRODUCT /////////////////// | |||
|
|||
const Field2D Vector2D::operator*(const Vector2D &rhs) const { | |||
const Coordinates::FieldMetric Vector2D::operator*(const Vector2D& rhs) const { |
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: return type const Coordinates::FieldMetric
(aka const Field2D
) is const
-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]
const Coordinates::FieldMetric Vector2D::operator*(const Vector2D& rhs) const {
^~~~~~
@@ -474,7 +474,7 @@ const Vector3D operator*(const Field3D &lhs, const Vector2D &rhs) { | |||
***************************************************************/ | |||
|
|||
// Return the magnitude of a vector | |||
const Field2D abs(const Vector2D &v, const std::string& region) { | |||
const Coordinates::FieldMetric abs(const Vector2D& v, const std::string& region) { |
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: return type const Coordinates::FieldMetric
(aka const Field2D
) is const
-qualified at the top level, which may reduce code readability without improving const correctness [readability-const-return-type]
const Coordinates::FieldMetric abs(const Vector2D& v, const std::string& region) {
^~~~~~
BoutReal coef1=0.0, coef2=0.0, coef3=0.0, coef4=0.0, | ||
coef5=0.0, coef6=0.0, kwave; | ||
|
||
BoutReal coef1 = 0.0, coef2 = 0.0, coef3 = 0.0, coef4 = 0.0, coef5 = 0.0, coef6 = 0.0; |
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: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
BoutReal coef1 = 0.0, coef2 = 0.0, coef3 = 0.0, coef4 = 0.0, coef5 = 0.0, coef6 = 0.0;
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Return non-const should be preferred
…erged2 Conflicts: include/bout/invert/laplacexz.hxx src/invert/laplacexz/impls/petsc/laplacexz-petsc.cxx
After communication we might have invalid points, this is fixed by applying boundaries.
Merge recent changes to fix CI
[3D metric] Use Bxy.ydown() for div_a_laplace_perp
[3D metric] Ensure boundaries are valid
* next: Mark unused function arguments with MAYBE_UNUSED De-abbreviate exception message Use constants in setting default_dz for Coordinates unit test Fix expectation for default value Do not ignore default value Fix mpark_submodule if not called from local directory Add additional targets for submodules Some basic tests of Coordinates inputs Basic tests of Coordinates Enable FakeGridDataSource to provide values to Mesh
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
There were too many comments to post at once. Showing the first 25 out of 125. Check the log or trigger a new build to see more.
@@ -284,14 +304,13 @@ private: | |||
* Shift a 2D field in Z. | |||
* Since 2D fields are constant in Z, this has no effect | |||
*/ | |||
const Field2D shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), | |||
const std::string UNUSED(region) = "RGN_NOX") const { | |||
Field2D shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), |
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: method shiftZ
can be made static [readability-convert-member-functions-to-static]
Field2D shiftZ(const Field2D& f, const Field2D& UNUSED(zangle),
^
static
const Field2D shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), | ||
const std::string UNUSED(region) = "RGN_NOX") const { | ||
Field2D shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), | ||
const std::string UNUSED(region) = "RGN_NOX") const { |
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: the const qualified parameter UNUSED_region
is copied for each invocation; consider making it a reference [performance-unnecessary-value-param]
const std::string UNUSED(region) = "RGN_NOX") const {
^
&
/github/workspace/include/unused.hxx:29:20: note: expanded from macro 'UNUSED'
# define UNUSED(x) UNUSED_ ## x __attribute__((unused))
^
note: expanded from here
const Field2D shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), | ||
REGION UNUSED(region)) const { | ||
"const std::string& region = \"RGN_NOX\") instead")]] Field2D | ||
shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), REGION UNUSED(region)) const { |
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: method shiftZ
can be made static [readability-convert-member-functions-to-static]
shiftZ(const Field2D& f, const Field2D& UNUSED(zangle), REGION UNUSED(region)) const {
^ ~~~~~~
const YDirectionType y_direction_out, | ||
const std::string& region = "RGN_NOX") const; | ||
Field3D shiftZ(const Field3D& f, const Tensor<dcomplex>& phs, | ||
const YDirectionType y_direction_out, |
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: parameter y_direction_out
is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
const YDirectionType y_direction_out,
^~~~~~
const YDirectionType y_direction_out, | ||
const std::string& region = "RGN_NOX") const; | ||
FieldPerp shiftZ(const FieldPerp& f, const Tensor<dcomplex>& phs, | ||
const YDirectionType y_direction_out, |
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: parameter y_direction_out
is const-qualified in the function declaration; const-qualification of parameters only has an effect in function definitions [readability-avoid-const-params-in-decls]
const YDirectionType y_direction_out,
^~~~~~
void BoundaryFree::apply_ddt(Field2D& UNUSED(f)) { | ||
// Do nothing for free boundary | ||
} | ||
int jx, jy, jz, jzp, jzm; |
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: multiple declarations in a single statement reduces readability [readability-isolate-declaration]
int jx, jy, jz, jzp, jzm;
^~~~~~~~~~~~~~~~~~~~~~~~~
void BoundaryFree::apply_ddt(Field2D& UNUSED(f)) { | ||
// Do nothing for free boundary | ||
} | ||
int jx, jy, jz, jzp, jzm; |
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 jx
is not initialized [cppcoreguidelines-init-variables]
int jx, jy, jz, jzp, jzm;
^
= 0
void BoundaryFree::apply_ddt(Field2D& UNUSED(f)) { | ||
// Do nothing for free boundary | ||
} | ||
int jx, jy, jz, jzp, jzm; |
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 jy
is not initialized [cppcoreguidelines-init-variables]
int jx, jy, jz, jzp, jzm;
^
= 0
void BoundaryFree::apply_ddt(Field2D& UNUSED(f)) { | ||
// Do nothing for free boundary | ||
} | ||
int jx, jy, jz, jzp, jzm; |
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 jz
is not initialized [cppcoreguidelines-init-variables]
int jx, jy, jz, jzp, jzm;
^
= 0
void BoundaryFree::apply_ddt(Field2D& UNUSED(f)) { | ||
// Do nothing for free boundary | ||
} | ||
int jx, jy, jz, jzp, jzm; |
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 jzp
is not initialized [cppcoreguidelines-init-variables]
int jx, jy, jz, jzp, jzm;
^
= 0
@bshanahan @dschwoerer I'm happy to merge this when the tests pass, but between you please could you create one or two integrated 3D tests? Analytic answers would obviously be lovely, but a regression test would be fine! Maybe two waves in a rotating ellipsis? |
🥳 🍾 |
Fixes #1668
(copied from comment below for better visibility)
I tried to look at all open comments, and I think this is the list of stuff that needs to be done (feel free to edit)
@ZedThree 3D metrics #2025 (comment)
Commit f5dccc9 by @bshanahan