-
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
Enable time dependent translation with transition for Sphere domain #5576
Enable time dependent translation with transition for Sphere domain #5576
Conversation
: initial_time_(initial_time), | ||
initial_l_max_(shape_map_options.l_max), | ||
initial_shape_values_(shape_map_options.initial_values) {} | ||
initial_shape_values_(shape_map_options.initial_values), | ||
translation_velocity_(translation_velocity), |
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.
initial_translation_velocity
@@ -131,15 +139,47 @@ struct TimeDependentMapOptions { | |||
std::optional<std::variant<KerrSchildFromBoyerLindquist>> initial_values{}; | |||
}; | |||
|
|||
using options = tmpl::list<InitialTime, ShapeMapOptions>; | |||
struct TranslationMapVelocity { | |||
static std::string name() { return "Velocity"; } |
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.
InitialVelocity
using group = TranslationMapOptions; | ||
}; | ||
|
||
struct TranslationMapInnerRadius { |
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.
Don't take the inner and outer radii as options. Just apply the transition in the outer shell of the sphere, so inner radius is the last number in radial_partitions
and outer radius is the outer radius of the sphere. Add this translation map with the transition only to the blocks that make up the outer shell. Apply a rigid translation (no inner/outer radii) to all other blocks. If there is no partition (just one shell) and the interior of the sphere is filled with a cube then either error out or apply a rigid translation (because the transition only works with spherical inner and outer radii).
@@ -115,17 +133,21 @@ void TimeDependentMapOptions::build_maps(const std::array<double, 3>& center, | |||
shape_map_ = ShapeMap{center, initial_l_max_, | |||
initial_l_max_, std::move(transition_func), | |||
shape_name, size_name}; | |||
if (translation_inner_radius == translation_outer_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.
Take the translation radii as std::optional<std::pair<double, double>>
then you can either pass std::nullopt
or both radii.
You also have to build a second rigid translation map with no radii, which you can apply to the inner blocks. Then you don't need to remove asserts in the Translation map. I think it is necessary to have these two different maps because their Jacobian is discontinuous at the translation_inner_radius
.
std::make_unique<FunctionsOfTime::PiecewisePolynomial<2>>( | ||
initial_time_, | ||
std::array<DataVector, 3>{ | ||
{{3, 0.0}, initial_velocity_temp, {3, 0.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.
std::move(initial_velocity_temp)
return std::make_unique< | ||
IdentityForComposition<Frame::Distorted, Frame::Inertial>>( | ||
IdentityMap{}); | ||
return std::make_unique<DistortedToInertialComposition>(translation_map_); |
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.
Here you add the rigid translation (not the transition)
} else { | ||
return std::make_unique< | ||
IdentityForComposition<Frame::Grid, Frame::Inertial>>(IdentityMap{}); | ||
return std::make_unique<GridToInertialSimple>(translation_map_); |
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.
Take another bool like transition_translation_map
to determine if this block should use the transition or the rigid translation.
fff292d
to
f090181
Compare
f090181
to
0f3c17f
Compare
@nilsvu I think addressed all the comments |
c842318
to
e008c93
Compare
struct InitialVelocity { | ||
static std::string name() { return "InitialVelocity"; } |
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.
We probably also want to be able to specify the initial translation itself, not just the initial velocity, so we'll need an option for that. To keep things organized, make the translation options like the shape options. One struct that has
struct TranslationMapOptions {
using type = TranslationMapOptions;
static std::string name() { return "TranslationMap"; }
struct InitialValues {
using type = std::array<std::array<double, 3>, 2>;
...
};
...
using options = tmpl::list<InitialValues>;
std::array<std::array<double, 3>, 2> initial_values{};
};
TranslationMap rigid_translation_map_{}; | ||
TranslationMap translation_map_{}; |
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.
Use linear_falloff_translation_map_
instead of translation_map_
so it's clear. Or just make it a std::pair
of translation maps.
src/Domain/Creators/Sphere.cpp
Outdated
// The translation map linear transition occurs only in the outer-most | ||
// shell, such that the outer boundary is not translated. If there | ||
// is no radial partition, a uniform translation is applied instead, as | ||
// the transition requires spherical shape. |
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 don't think it makes sense to allow only a single spherical shell while also having a translation. I don't think we have boundary conditions that can handle that. We should probably just error if that happens and require we have two spherical shells (one radial partition).
src/Domain/Creators/Sphere.cpp
Outdated
radial_partitioning_.empty() | ||
? std::nullopt | ||
: std::optional<std::pair<double, double>>{ | ||
{radial_partitioning_.back(), outer_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.
Then these don't have to be optional, but can always be passed.
|
||
if (translation_transition_radii.has_value()) { |
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.
And then here you just always have a rigid translation map and a falloff translation map.
"an outflow-type boundary condition, you must use that.")); | ||
using TDMO = domain::creators::sphere::TimeDependentMapOptions; |
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 sphere test failed for one of the builds still.
ff9f425
to
4c11784
Compare
For some reason I am still getting the asserts (in the description) triggered with the Xcts Kerr input file. In particular for the inner shell. Maybe there is still a bug somewhere here or in Translation. As for the rest, I implemented the changes requested @knelli2 |
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 fixups look good. You can squash the existing changes plus these new ones. As for the error in the translation map, if the values are really off by 1e-14 then we just need to account for roundoff. Basically do this in two places in the translation map
diff --git a/src/Domain/CoordinateMaps/TimeDependent/Translation.cpp b/src/Domain/CoordinateMaps/TimeDependent/Translation.cpp
index de3f73ed2d..debb09ef7a 100644
--- a/src/Domain/CoordinateMaps/TimeDependent/Translation.cpp
+++ b/src/Domain/CoordinateMaps/TimeDependent/Translation.cpp
@@ -373,7 +373,8 @@ std::array<tt::remove_cvref_wrap_t<T>, Dim> Translation<Dim>::piecewise_helper(
get_element(gsl::at(result, i), k) +=
gsl::at(func_or_deriv_of_time, i) * radial_falloff_factor;
}
- ASSERT(max(magnitude(result)) <= outer_radius_.value(),
+ const double eps = std::numeric_limits<double>::epsilon() * 100.0;
+ ASSERT(max(magnitude(result)) - eps <= outer_radius_.value(),
"Coordinates translated outside outer radius, This should not "
"happen");
}
If that doesn't work, then we'll need to investigate more. While you're at it, please also print the numbers in that ASSERT message so we can see how off they are.
Also, please fix all clang-tidy errors when squashing.
src/Domain/Creators/Sphere.cpp
Outdated
const bool use_rigid_translation = | ||
block_id + num_blocks_per_shell_ < num_blocks_; |
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 think this is incorrect if fill_interior_
is true since the central cube is append at the end of the block list
4c11784
to
046741a
Compare
Running the Xcts input file with one partition I get:
whereas which is actually the same number -0.177636e-15 |
046741a
to
066f010
Compare
Add options Add rigid translation Fix clang tidy Fix tests Rename translation map member Reorganize translation map options Add initial translation parameter Fix tests Forbid single shell with hard coded time dep maps Fix Fix Allow for roundoff in translation asserts
066f010
to
b781510
Compare
@nilsvu Would it be ok if I set the spin to zero and remove the time dep maps in the Xcts KerrSchild test? In this PR I require at least two shells for hardcoded time dep maps and that test is timing out. Or how much can I increase the timeout time? |
@nilsvu Can you take another look at this? |
Closing because this feature has already been implemented in #5758. |
Proposed changes
Add a translation map acting on the outer most shell of the spherical domain. If there is no radial partition, apply a uniform translation (since the inner boundary of the translation needs to be spherical and the shape map could also be active).
Note: The test
Unit.Domain.Creators.Sphere
failed because of roundoff error in assetsASSERT(max(magnitude(result)) <= outer_radius_.value(), "Coordinates translated outside outer radius, This should not " "happen");
in
spectre/src/Domain/CoordinateMaps/TimeDependent/Translation.cpp
Line 376 in 06b2395
When I printed the values during a test, the assert failed by a factor of order 10e-15 of the
outer_radius_
and seemed to remain of the same order in time. Changed the assert to allow for roundoff error.Update: issue above fixed in #5601
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