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

WIP: Another stab at more general coordinate support #1137

Open
wants to merge 9 commits into
base: develop
Choose a base branch
from

Conversation

jdolence
Copy link
Collaborator

PR Summary

Add support for spherical and cylindrical coordinates, as well as supporting downstream defined coordinate systems.

PR Checklist

  • Code passes cpplint
  • New features are documented.
  • Adds a test for any bugs fixed. Adds tests for new features.
  • Code is formatted
  • Changes are summarized in CHANGELOG.md
  • Change is breaking (API, behavior, ...)
    • Change is additionally added to CHANGELOG.md in the breaking section
    • PR is marked as breaking
    • Short summary API changes at the top of the PR (plus optionally with an automated update/fix script)
  • CI has been triggered on Darwin for performance regression tests.
  • Docs build
  • (@lanl.gov employees) Update copyright on changed files

Comment on lines +106 to +110
template <int dir>
KOKKOS_FORCEINLINE_FUNCTION Real Xc(const int idx) const {
static_assert(dir > 0 && dir < 4);
return xmin_[dir - 1] + (idx + 0.5) * dx_[dir - 1];
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

looks like you're shadowing these in derived classes. Should they be marked overload or something? Or is that not necessary due to CRTP?


template <int dir>
KOKKOS_FORCEINLINE_FUNCTION
Real hx(const Real r, const Real th, const Real phi) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

so this is the diagonal metric h factor but what is the x for in the name?

Copy link
Collaborator

Choose a reason for hiding this comment

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

And do we need any additional curvature terms we should track?

Comment on lines +82 to +84
if (dir == X1DIR) return static_cast<const System *>(this)->template Dxc<X1DIR>(k, j, i);
else if (dir == X2DIR) return static_cast<const System *>(this)->template Dxc<X2DIR>(k, j, i);
else if (dir == X3DIR) return static_cast<const System *>(this)->template Dxc<X3DIR>(k, j, i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Are the ifs necessary here?

template <int dir>
KOKKOS_FORCEINLINE_FUNCTION Real Dxc(const int k, const int j, const int i) const {
static_assert(dir > 0 && dir < 4);
if constexpr (dir == X1DIR) return static_cast<const System *>(this)->template Dxc<dir>(i);
Copy link
Collaborator

Choose a reason for hiding this comment

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

FWIW, could just have one line return static_cast<const System *>(this)->template Dxc<dir>(std::get<dir - 1>(std::make_tuple(i, j, k)));

// Xf: Positions on Faces
//----------------------------------------
template <int dir>
KOKKOS_FORCEINLINE_FUNCTION Real Xf(const int idx) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this still be supported?

}

template <int dir, TopologicalElement el>
KOKKOS_FORCEINLINE_FUNCTION Real X(const int idx) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this still be supported?

Comment on lines +270 to +306
using TE = TopologicalElement;
if (cl == CellLevel::same) {
if (el == TE::CC) {
return cell_volume_;
} else if (el == TE::F1) {
return area_[X1DIR - 1];
} else if (el == TE::F2) {
return area_[X2DIR - 1];
} else if (el == TE::F3) {
return area_[X3DIR - 1];
} else if (el == TE::E1) {
return dx_[X1DIR - 1];
} else if (el == TE::E2) {
return dx_[X2DIR - 1];
} else if (el == TE::E3) {
return dx_[X3DIR - 1];
} else if (el == TE::NN) {
return 1.0;
}
} else if (cl == CellLevel::fine) {
if (el == TE::CC) {
return cell_volume_ / 8.0;
} else if (el == TE::F1) {
return area_[X1DIR - 1] / 4.0;
} else if (el == TE::F2) {
return area_[X2DIR - 1] / 4.0;
} else if (el == TE::F3) {
return area_[X3DIR - 1] / 4.0;
} else if (el == TE::E1) {
return dx_[X1DIR - 1] / 2.0;
} else if (el == TE::E2) {
return dx_[X2DIR - 1] / 2.0;
} else if (el == TE::E3) {
return dx_[X3DIR - 1] / 2.0;
} else if (el == TE::NN) {
return 1.0;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I guess this still needs to be updated.

// Xc: Positions at cell centroids
//----------------------------------------
template <int dir>
KOKKOS_FORCEINLINE_FUNCTION Real Xc(const int idx) const {
Copy link
Collaborator

Choose a reason for hiding this comment

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

should this take k, j, i?

else if (el == TE::E3) return EdgeLength<X3DIR>(k, j, i);
else if (el == TE::NN) return 1.0;
} else {
PARTHENON_FAIL("Have not yet implemented fine fields for UniformSpherical coordinates.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

We could just have a coordinates object own another coordinates object that has twice the number of zones and then just call that for fine fields.

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.

3 participants