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

Add 0th order puncture field to CurvedScalarWave #4760

Merged
merged 2 commits into from Feb 27, 2023

Conversation

nikwit
Copy link
Contributor

@nikwit nikwit commented Feb 20, 2023

Proposed changes

Adds the Detweiler-Whiting singular/puncture field expanded up to zeroth order in geodesic distance from a scalar charge.

Update: I vectorized the calculation of the puncture field which makes the calculation about 7x faster than before on a single core on my local machine.

@nikwit nikwit changed the title Add puncture field 0 Add 0th order puncture field to CurvedScalarWave Feb 20, 2023
evolved_vars->initialize(get<0>(coords).size());
const double r0 = orbital_radius;
const double M = BH_mass;
const double w = pow(r0, -1.5);
Copy link
Member

@nilsdeppe nilsdeppe Feb 20, 2023

Choose a reason for hiding this comment

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

not a full review, just a quick note. I realize most of this code probably comes from Mathematica, but assuming you'll be calling this quite frequently during the evolution you should go through and do optimizations like pow(x, 2) -> pow<2>(x), or pow(r0, -1.5)->1.0 / (r0 * sqrt(r0)) (pow is insanely expensive, you can do about 180 mult/add for one pow)

Edit: and also things like 10 -> 10.

@nikwit nikwit force-pushed the Add-Puncture-field-0 branch 3 times, most recently from 3131187 to 31ccd27 Compare February 22, 2023 14:17
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.

LGTM, couple questions. Squash anything you decide to change :)

DynamicBuffer<DataVector> temps(66, grid_size);

const double d_0 = 1.0 / r0;
const double d_1 = 3 * M;
Copy link
Member

Choose a reason for hiding this comment

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

is it easy to regex-replace [space][number][space with [space][number].0[space]? If not, I wouldn't worry about it... This is auto-generated code anyway

Copy link
Contributor Author

@nikwit nikwit Feb 24, 2023

Choose a reason for hiding this comment

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

it's not that easy unfortunately because the spaces only appear after I clang-format. Could probably be done with a bit of work but might not be worth the effort - should be the same binary after all.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

nevermind, fixed it now

@nikwit
Copy link
Contributor Author

nikwit commented Feb 24, 2023

thank you, I squashed it in :)

Comment on lines 37 to 40
gsl::not_null<Variables<tmpl::list<
Tags::Psi, ::Tags::dt<Tags::Psi>,
::Tags::deriv<Tags::Psi, tmpl::size_t<3>, Frame::Inertial>>>*>
evolved_vars,
Copy link
Member

@nilsvu nilsvu Feb 26, 2023

Choose a reason for hiding this comment

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

Question @nilsdeppe: do you have any preference these days on passing Variables vs individual Tensors to functions like this? I often found it easier to work exclusively with Tensors in pointwise functions because then the function is agnostic to where the Tensors are actually stored (could be in separate Variables or in one Variables together with other things, or on a Variables with prefixes tags). Now we have nonowning variables so we could create suitable Variables when calling this function. But overall my experience is that avoiding Variables and Tags in pointwise functions makes everything easier. Thoughts?

Copy link
Member

Choose a reason for hiding this comment

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

A quick reply now, I can elaborate more if you want. I've started adding Variables-based overloads to GRMHD and GH for things like time derivatives. The motivation there being that 1. there are fewer arguments 2. we can now use structured bindings to easily extract out of a Variables 3. non-owning Variables makes it easier to deal with and 4. the DataStructures/TaggedContainer.hpp code makes working with multiple tagged containers simultaneously very easy and so overcomes another hurdle we had with using Variables more.

Basically, I think there are cases in generic code where manipulating a Variables (or set of them) is significantly easier than trying to get the right Tensor from the right tagged container, and so I'm generally in favor of doing so when it make the code a lot easier to read and write. E.g. there were places in GHGRMHD where we would take a bunch of takes from 3 or so tagged containers, put references of them in a TuppleTuple, just so we could pull them out later. This was extremely parameter pack and template dense code that made it hard to read, but the recent additions I listed above make it so that isn't needed anymore.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds reasonable, I'll give the new tools a try. Maybe generic Variables would also be a way to add new evolution variables like recently the electron fraction without refactoring half the code base.

Copy link
Member

Choose a reason for hiding this comment

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

That was one of the main motivations for the added functionality.

* \brief Computes the puncture/singular field \f$\Psi^\mathcal{P}\f$ of a
* scalar charge in circular orbit around a Schwarzschild black hole as
* described in \cite Detweiler2003 expanded to order 0 in geodesic distance.
*/
Copy link
Member

Choose a reason for hiding this comment

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

Add \see puncture_field to reference the main function if you get the chance (not holding up this PR)

@nilsdeppe nilsdeppe merged commit 57e51ad into sxs-collaboration:develop Feb 27, 2023
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.

None yet

4 participants