-
Notifications
You must be signed in to change notification settings - Fork 192
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
Properly extend shape map into interior region #6477
base: develop
Are you sure you want to change the base?
Conversation
82f1113
to
a839da1
Compare
03d5644
to
3e38d85
Compare
interpolation_info); | ||
} | ||
|
||
auto transition_func_over_radius = |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this is G
or G/r
? Because my understanding from the dox change is this is G/r
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You are correct, this is G/r
. I'll add a small comment here to clarify
@@ -243,26 +276,21 @@ namespace domain::CoordinateMaps::ShapeMapTransitionFunctions { | |||
* \parblock | |||
* | |||
* \note If \p reverse is true, then the value multiplying $\Sigma$ in the | |||
* numerator is now $-|\vec x_0 - \vec P|$ and in the denomintor $\Sigma$ picks | |||
* numerator is now $-|\vec x_0 - \vec P|$ and in the denominator $\Sigma$ picks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
demonator? 😅 (JK I'm just teasing!)
if (multiple_real_roots) { | ||
// Numerical Recipes (3rd edition) pg 228, eqs 5.6.11 - 5.6.12 | ||
const double theta = acos(R / sqrt(cube(Q))); | ||
std::vector<double> roots{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not use an array? or a static vector? remove_if
returns an iterator to the end, so you can use it on an array.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had assumed remove_if
would resize the container, but I see I was incorrect. I think what I actually want is to use std::erase_if
so the vector actually contains the positive roots.
if (multiple_real_roots) { | ||
// Numerical Recipes (3rd edition) pg 228, eqs 5.6.11 - 5.6.12 | ||
const double theta = acos(R / sqrt(cube(Q))); | ||
std::vector<double> roots{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same question about array
This is only allowed when the inner surface is spherical and when we are using the "regular" transition (i.e. not reversed).
3e38d85
to
f13de35
Compare
|
||
// G / r | ||
auto transition_func_over_radius = | ||
transition_func_->operator()(centered_coords, {1}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) don't need the curly braces I think
*/ | ||
virtual double operator()( | ||
const std::array<double, 3>& source_coords) const = 0; | ||
const std::array<double, 3>& source_coords, | ||
const std::optional<size_t>& one_over_radius_power) const = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(optional) default to std::nullopt
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Quick google search says having default parameters in pure virtual functions is not recommended so I'll leave it as is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
const std::optional<size_t>& one_over_radius_power) const { | ||
DataVector result = source_coords[0]; | ||
// Go point by point | ||
for (size_t i = 0; i < source_coords[0].size(); i++) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The performance of this might actually be relevant, so if it's easy enough I'd stick with Blaze for this computation instead of doing the loop yourself.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well for each point, I'd still need to do the checks I do in the double
implementation since this can be called with any set of points and to ensure everything is consistent which would require this to still be a loop.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh hide the checks behind #ifdef SPECTRE_DEBUG
then their performance doesn't matter and you can do loops in them
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do these like the gradient_impl
function you did below, that's also how these functions were implemented before you split them into separate double
and DataVector
overloads in this PR. Otherwise the code can do something different in debug vs release, which seems very hard to debug 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok done
// a_ being positive is a sentinel for reversed. | ||
// If we aren't reversed, check near or within r_min_. | ||
if (a_ < 0.0) { | ||
if (mag + radial_distortion < (1.0 - eps_) * r_min_) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the + radial_distortion
here?
I think you have to be careful that you compare r_min and r_max only to the original radius, not the target radius. E.g. in line 157 there's a comparison to the target radius, which I think could be a problem.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's undoing the distortion assuming we are at the f=1 surface. Therefore if this condition is true, we are guaranteed to be within the excision and if not, we're outside of it. I ported this check over from SpEC.
Below on 157 should still be the target radius, but I forgot to add the radial distortion since I'm trying to see if we are exactly at the excision (because then the formula is simpler). In the Wedge it is correct
src/Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/SphereTransition.cpp
Outdated
Show resolved
Hide resolved
src/Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/Wedge.cpp
Outdated
Show resolved
Hide resolved
src/Domain/CoordinateMaps/TimeDependent/ShapeMapTransitionFunctions/Wedge.cpp
Outdated
Show resolved
Hide resolved
@nilsvu Pushed fixups |
This is only allowed when the inner surface is spherical and when we are using the "regular" transition (i.e. not reversed).
Proposed changes
Fixes #6451.
A previous PR (#6359) attempted to extend the shape map into the excision, but did so incorrectly. This PR implements this correctly. In order to do this, the meaning of the transition function had to be changed slightly. Previously, the shape map was
and the transition function was$f(r, \theta, \phi)$ . The functional form of the shape map hasn't changed, but now it reads
where$G(r, \theta, \phi)$ is the transition. The $1/r$ factor was just absorbed into the transition function because the full $G$ is different inside the excision, not just $f$ .
Also, the transition function inside the excisions is
which is different than it is in SpEC. The transition defined in SpEC causes the jacobian to be undefined at the center of the shape map, which means the full frame velocity of all the maps can't be computed at the center of the shape map. This new transition inside the excision allows for this and has the correct behavior.
Upgrade instructions
Code review checklist
make doc
to generate the documentation locally intoBUILD_DIR/docs/html
.Then open
index.html
.code review guide.
bugfix
ornew feature
if appropriate.Further comments