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

Numerically invert Jacobian in combined call #6223

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

nikwit
Copy link
Contributor

@nikwit nikwit commented Aug 15, 2024

In some maps like Shape and RotScaleTrans, the inverse jacobian is compute by computing the jacobian and inverting it numerically. This means that for BBH simulations, we currently compute these jacobians twice, invert them and multiply them together. In this PR, this is changed so that only the jacobian is computed for all maps and the final jacobian is inverted.

For BBH simulations, I found this speeds up the simulation between 10% and 18%, depending on the number of l-modes.

image

@nikwit nikwit mentioned this pull request Aug 16, 2024
Comment on lines +545 to +546
determinant_and_inverse(jac).second, std::move(jac),
std::move(frame_velocity)};
Copy link
Contributor

@knelli2 knelli2 Aug 16, 2024

Choose a reason for hiding this comment

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

Add in the CoordinateMap.hpp docs for this function that we don't call the individual inverse_jacobian functions and multiply them together, but rather just compute the jacobian and numerically invert it because most of our production time-dependent maps do this already.

Copy link
Member

Choose a reason for hiding this comment

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

Is there a reason to keep the inverse_jacobian implementations on the individual maps at all? Doesn't need to be done in this PR, but removing them would be nicer than documenting that they are unused.

Copy link
Contributor

Choose a reason for hiding this comment

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

Well they are still used in the individual inverse_jacobian function of CoordinateMap{Base}, correct? Whether or not that function is actually used in practice, I don't know. If not, then yes we can probably get rid of it

Copy link
Member

Choose a reason for hiding this comment

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

Or we could make it do the numerical inversion like this function now does.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah we could! Let's discuss on the Monday call

Copy link
Member

Choose a reason for hiding this comment

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

Another thing for a separate PR: this function could also return the Jacobian determinant. We need this a bit in the hydro cases.

Copy link
Contributor

Choose a reason for hiding this comment

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

From the Monday call: We can just numerically invert the jacobian in the individual function as well which means we don't need the individual inverse_jacobian functions. See #6233

Copy link
Member

@nilsdeppe nilsdeppe left a comment

Choose a reason for hiding this comment

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

I'm happy with the code. Thanks for doing this!

Comment on lines +545 to +546
determinant_and_inverse(jac).second, std::move(jac),
std::move(frame_velocity)};
Copy link
Member

Choose a reason for hiding this comment

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

Another thing for a separate PR: this function could also return the Jacobian determinant. We need this a bit in the hydro cases.

@nikwit nikwit force-pushed the speed-up-coord-map branch from bc43652 to e442112 Compare August 19, 2024 18:56
@nikwit
Copy link
Contributor Author

nikwit commented Aug 19, 2024

I added a comment about the inverse Jacobian being inverted numerically in CoordinateMap.hpp. @nilsdeppe the function can be altered to return the determinant (this is free now as you get it automatically with the inversion). I am not sure how much of a pain it is but probably not too bad, I can look into it later this week.

@nilsdeppe
Copy link
Member

Sounds good. Probably would require updating some tags. I think it's low priority :) Thank you!

@nilsdeppe nilsdeppe merged commit c9ba57b into sxs-collaboration:develop Aug 21, 2024
21 of 22 checks passed
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