Skip to content

Refactor coordinates#2873

Open
tomc271 wants to merge 516 commits intonextfrom
refactor-coordinates
Open

Refactor coordinates#2873
tomc271 wants to merge 516 commits intonextfrom
refactor-coordinates

Conversation

@tomc271
Copy link
Copy Markdown
Collaborator

@tomc271 tomc271 commented Feb 23, 2024

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

@tomc271 tomc271 requested a review from ZedThree February 23, 2024 14:07
@bendudson
Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
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

…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).
…ntMetricTensor in Coordinates::setBoundaryCells method, to avoid recalculation of the christoffel symbols, which would (at this stage) involve field data at different locations (specifically the metric tensor and jacobian).
@ZedThree ZedThree force-pushed the refactor-coordinates branch from f970905 to 47cff9e Compare October 24, 2024 16:36
Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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());
           ^

tomchapman and others added 12 commits December 20, 2024 14:00
otherwise when Coordinates setters call mesh->communicate()
and that calls calcParallelSlices()
and that calls getCoordinates()
the coordinates field will be a null pointer.
…nd MetricTensor inverse() method

Add method Coordinates::communicateMetricTensor() and call after constructing Coordinates

to avoid circular dependency (between Mesh and Coordinates) as a result of the setter methods calling communicate()
to prevent getUniform(coords->zlength()) failing because the field is not const.
Update existing dy and J fields, to avoid invalid values in the guard cells.
…icate

Fixes to address failing tests after changes to refactor-coordinates
Include changes from commit: "Return `std::optional` from `invert3x3`"
SHA-1: c42dc24
which was not merged due to splitting files.
…erivatives::index::DDY()

as the former checks canToFromFieldAligned().
This reverts commit e5010e4.

Fix for failing fci tests.
@tomc271
Copy link
Copy Markdown
Collaborator Author

tomc271 commented Sep 30, 2025

Resolves #2128

@dschwoerer dschwoerer mentioned this pull request Mar 17, 2026
1 task
@dschwoerer
Copy link
Copy Markdown
Contributor

It was my understanding that you are going to re-enable to do coords->dy[i], instead of coords->dy()[i] - do you still plan to do that, or is that not planned?

That would not only make it mostly backwards compatible, but it would also reduce the diff hugely, as most of the BOUT++ code base would not need to be touched.

@tomc271
Copy link
Copy Markdown
Collaborator Author

tomc271 commented Mar 20, 2026

It was my understanding that you are going to re-enable to do coords->dy[i], instead of coords->dy()[i] - do you still plan to do that, or is that not planned?

That would not only make it mostly backwards compatible, but it would also reduce the diff hugely, as most of the BOUT++ code base would not need to be touched.

This summarises our thinking

@dschwoerer
Copy link
Copy Markdown
Contributor

This summarises our thinking

I get the error that this link is invalid or has been deleted.

@dschwoerer
Copy link
Copy Markdown
Contributor

This summarises our thinking

I get the error that this link is invalid or has been deleted.

It is working now with javascript enabled, google should fix there error messages.

This summarises our thinking
I would not call this "summarising" - this is a fairly length bit of text.

To summarise the link: Avoiding the explicit () call can cause issues with auto and templates - which can be very confusing, and as such should be avoided. Did I get that right?

@dschwoerer
Copy link
Copy Markdown
Contributor

If so, you do not plan to do this in the future, and this PR is not a WIP and ready for review?
I asked 2 years ago #2873 (comment) - and would have started with a review if I would have known the answer.

Did you address #2873 (comment) ?

If you get this updated, I will try to review this (and #3046 )

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