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

Refactor coordinates #2873

Open
wants to merge 504 commits into
base: next
Choose a base branch
from
Open

Refactor coordinates #2873

wants to merge 504 commits into from

Conversation

tomc271
Copy link
Collaborator

@tomc271 tomc271 commented Feb 23, 2024

Encapsulate all private members of Coordinates class.
New classes for metric tensor, Christoffel symbols.

@bendudson
Copy link
Contributor

Thanks @tomc271 ! This is quite an epic amount of work.

Copy link
Member

@ZedThree ZedThree left a comment

Choose a reason for hiding this comment

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

Thanks @tomc271! I've made a bunch of comments on things to work through. A couple of big things though:

  • this has diverged from next a bit, so that will need merging in and conflicts resolving. There's been some important bug fixes and CI changes in next that would be good to get in ASAP
  • some of the changes haven't propagated through to some subsystems, such as the various PETSc laplace operators. You will need to either build against PETSc locally to find them, or use some searching to find the remaining places

include/bout/mesh.hxx Outdated Show resolved Hide resolved
src/mesh/coordinates_accessor.cxx Outdated Show resolved Hide resolved
tools/pylib/_boutpp_build/boutcpp.pxd.jinja Outdated Show resolved Hide resolved
include/bout/mesh.hxx Outdated Show resolved Hide resolved
src/mesh/mesh.cxx Outdated Show resolved Hide resolved
src/mesh/christoffel_symbols.cxx Outdated Show resolved Hide resolved
src/mesh/christoffel_symbols.cxx Outdated Show resolved Hide resolved
src/mesh/coordinates.cxx Outdated Show resolved Hide resolved
src/mesh/coordinates.cxx Outdated Show resolved Hide resolved
examples/6field-simple/elm_6f.cxx Outdated Show resolved Hide resolved
…t be marked explicit to avoid unintentional implicit conversions.
…FakeMesh has no 'source', which causes a crash when the constructor leads to initialisation of FieldMetric objects).
@boutproject boutproject deleted a comment from github-actions bot Oct 23, 2024
@boutproject boutproject deleted a comment from github-actions bot Oct 23, 2024
@boutproject boutproject deleted a comment from github-actions bot Oct 23, 2024
@boutproject boutproject deleted a comment from github-actions bot Oct 23, 2024
@boutproject boutproject deleted a comment from github-actions bot Oct 23, 2024
@boutproject boutproject deleted a comment from github-actions bot Oct 23, 2024
* next: (72 commits)
  Make function signature match implementation in example
  Fix some clang-tidy issues in dalf3
  Apply suggestions from code review
  Apply clang-format changes
  prefer `auto *` for pointer types
  Fix: preserve regionID
  Fix exception message
  Ensure pointer is checked before dereferencing
  Try to do the right thing for linking netCDF::netcdf
  Add LC gitlab CI for GPU build/run tests
  BoutMask: Add non-const operator[](Ind3D)
  Use consistently signed char
  Apply clang-format changes
  naulin laplace: Acceptance tolerances after maxits
  CI: Remove test of deleted example
  CI: Bump all ubuntu images
  Read 2D variables into Field3D
  Fix "call to deleted constructor of 'Options' [clang-diagnostic-error]"
  Apply clang-format changes
  Revert change to reference for 'datadir'.
  ...
Copy link
Contributor

@github-actions github-actions bot left a 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

}
}
// Utility function for fixing up guard cells of zShift
void Coordinates::fixZShiftGuards(Field2D& zShift) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'fixZShiftGuards' can be made static [readability-convert-member-functions-to-static]

include/bout/coordinates.hxx:503:

-   void fixZShiftGuards(Field2D& zShift) const;
+   static void fixZShiftGuards(Field2D& zShift) ;
Suggested change
void Coordinates::fixZShiftGuards(Field2D& zShift) const {
void Coordinates::fixZShiftGuards(Field2D& zShift) {


BoutReal gp, gm;

// Vx = DDZ(f)
BoutReal vx = (f(x, y, zp) - f(x, y, zm)) / (2. * metric->dz(x, y, z));
BoutReal const vx = (f(x, y, zp) - f(x, y, zm)) / (2. * metric->dz(x, y, z));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable name 'vx' is too short, expected at least 3 characters [readability-identifier-length]

          BoutReal const vx = (f(x, y, zp) - f(x, y, zm)) / (2. * metric->dz(x, y, z));
                         ^


// Calculate gradients on cell faces -- assumes constant grid spacing

BoutReal gR =
BoutReal const gR =
(coords->g11(i, j, k) + coords->g11(i + 1, j, k))
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable name 'gR' is too short, expected at least 3 characters [readability-identifier-length]

st gR =
   ^

(coords->g11(i, j, k) + coords->g11(i + 1, j, k))
* (f(i + 1, j, k) - f(i, j, k))
/ (coords->dx(i + 1, j, k) + coords->dx(i, j, k))
+ 0.5 * (coords->g13(i, j, k) + coords->g13(i + 1, j, k))
* (f(i + 1, j, kp) - f(i + 1, j, km) + f(i, j, kp) - f(i, j, km))
/ (4. * coords->dz(i, j, k));

BoutReal gL =
BoutReal const gL =
(coords->g11(i - 1, j, k) + coords->g11(i, j, k))
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable name 'gL' is too short, expected at least 3 characters [readability-identifier-length]

st gL =
   ^

(coords->g11(i - 1, j, k) + coords->g11(i, j, k))
* (f(i, j, k) - f(i - 1, j, k))
/ (coords->dx(i - 1, j, k) + coords->dx(i, j, k))
+ 0.5 * (coords->g13(i - 1, j, k) + coords->g13(i, j, k))
* (f(i - 1, j, kp) - f(i - 1, j, km) + f(i, j, kp) - f(i, j, km))
/ (4 * coords->dz(i, j, k));

BoutReal gD =
BoutReal const gD =
coords->g13(i, j, k)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable name 'gD' is too short, expected at least 3 characters [readability-identifier-length]

st gD =
   ^

coords->g13(i, j, k)
* (f(i + 1, j, km) - f(i - 1, j, km) + f(i + 1, j, k) - f(i - 1, j, k))
/ (4. * coords->dx(i, j, k))
+ coords->g33(i, j, k) * (f(i, j, k) - f(i, j, km)) / coords->dz(i, j, k);

BoutReal gU =
BoutReal const gU =
coords->g13(i, j, k)
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable name 'gU' is too short, expected at least 3 characters [readability-identifier-length]

st gU =
   ^

dz4 = SQ(SQ(coords->dz));
dx4 = SQ(SQ(coords->dx()));
dy4 = SQ(SQ(coords->dy()));
dz4 = SQ(SQ(coords->dz()));
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: assigning to 'BoutReal' (aka 'double') from incompatible type 'Field2D' [clang-diagnostic-error]

  dz4 = SQ(SQ(coords->dz()));
        ^

Copy link
Contributor

@github-actions github-actions bot left a 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

}
}
// Utility function for fixing up guard cells of zShift
void Coordinates::fixZShiftGuards(Field2D& zShift) const {
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: method 'fixZShiftGuards' can be made static [readability-convert-member-functions-to-static]

include/bout/coordinates.hxx:479:

-   void fixZShiftGuards(Field2D& zShift) const;
+   static void fixZShiftGuards(Field2D& zShift) ;
Suggested change
void Coordinates::fixZShiftGuards(Field2D& zShift) const {
void Coordinates::fixZShiftGuards(Field2D& zShift) {

*coords_map[location] = std::move(new_coordinates);

auto recalculate_staggered = false;
new_coordinates.recalculateAndReset(recalculate_staggered,
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: 'new_coordinates' used after it was moved [bugprone-use-after-move]

    new_coordinates.recalculateAndReset(recalculate_staggered,
    ^
Additional context

src/mesh/mesh.cxx:790: move occurred here

    *coords_map[location] = std::move(new_coordinates);
                          ^

double yn = (double(y) + 0.5) / double(mesh->yend + 1);
{
auto dy = emptyFrom(coord->dx());
auto J = emptyFrom(coord->J());
Copy link
Contributor

Choose a reason for hiding this comment

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

warning: variable name 'J' is too short, expected at least 3 characters [readability-identifier-length]

      auto J = emptyFrom(coord->J());
           ^

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants