Skip to content

Conversation

@jyoo1042
Copy link
Contributor

Proposed changes

Add an equatorial compression option for the spherical torus map using a simple cubic function. This is for PolarMagFmDisk runs which use spherical torus.

Upgrade instructions

Code review checklist

  • The code is documented and the documentation renders correctly. Run
    make doc to generate the documentation locally into BUILD_DIR/docs/html.
    Then open index.html.
  • The code follows the stylistic and code quality guidelines listed in the
    code review guide.
  • The PR lists upgrade instructions and is labeled bugfix or
    new feature if appropriate.

Further comments

@jyoo1042 jyoo1042 requested a review from wthrowe August 31, 2024 22:13
const auto theta =
M_PI_2 - (pi_over_2_minus_theta_min_ * get<1>(source_coords));
// intermediate variable for equatorial compression
const auto intermediate_val = cubic_compression(get<1>(source_coords));
Copy link
Member

Choose a reason for hiding this comment

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

Having a variable called intermediate_val that's only used once isn't adding clarity. Just call the function in the expression on the next line.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

okay.

auto& sin_theta = get<2, 1>(jacobian);
auto& cos_theta = get<2, 0>(jacobian);
// intermediate variable for equatorial compression
get<2, 2>(jacobian) = cubic_compression(get<1>(source_coords));
Copy link
Member

Choose a reason for hiding this comment

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

Again, just call this inline.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

auto& sin_theta = get<1, 2>(inv_jacobian);
auto& cos_theta = get<0, 2>(inv_jacobian);
// intermediate variable for equatorial compression
get<2, 2>(inv_jacobian) = cubic_compression(get<1>(source_coords));
Copy link
Member

Choose a reason for hiding this comment

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

Again. Go through and find all cases of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

// using p.228 of Numerical Recipe (cubic equation)
const double Q = (compression_level_ - 1.0) / (3.0 * compression_level_);
const double R = -0.5 * x / (compression_level_);
const double A =
Copy link
Member

Choose a reason for hiding this comment

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

Lowercase variable names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

return compression_level_ * pow<3>(x) + (1.0 - compression_level_) * x;
}

double SphericalTorus::cubic_inversion(const double& x) const {
Copy link
Member

Choose a reason for hiding this comment

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

Take double by value, not reference.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

const auto numerical_hessian = numerical_derivative(
[&i, &j, &partial_torus](const std::array<double, 3>& y) {
const auto y_tnsr = a2t(y);
CAPTURE(y);
Copy link
Member

Choose a reason for hiding this comment

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

This doesn't do anything. There are no checks before it goes out of scope.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

cubic_compression(get<1>(source_coords)));
const T compressed_coord = cubic_compression(get<1>(source_coords));
const auto theta = M_PI_2 - (pi_over_2_minus_theta_min_ * compressed_coord);
const auto phi = M_PI * fraction_of_torus_ * get<2>(source_coords);
Copy link
Member

Choose a reason for hiding this comment

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

Change these autos to Ts, and then it should work.

@wthrowe
Copy link
Member

wthrowe commented Sep 4, 2024

You have a syntax error typo, but otherwise looks good. You can squash when you fix it.

@wthrowe wthrowe merged commit dd3d32d into sxs-collaboration:develop Sep 4, 2024
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.

2 participants