Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: d9c48a201687
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 614fb42ab1e8
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on May 2, 2021

  1. Copy the full SHA
    a032bd2 View commit details
  2. Merge pull request #2970 from pleroy/ContinuousTrajectory

    Documentation changes to ContinuousTrajectory
    pleroy authored May 2, 2021
    Copy the full SHA
    614fb42 View commit details
Showing with 19 additions and 14 deletions.
  1. +4 −4 physics/continuous_trajectory.hpp
  2. +11 −6 physics/continuous_trajectory_body.hpp
  3. +4 −4 physics/continuous_trajectory_test.cpp
8 changes: 4 additions & 4 deletions physics/continuous_trajectory.hpp
Original file line number Diff line number Diff line change
@@ -120,11 +120,11 @@ class ContinuousTrajectory : public Trajectory<Frame> {
const EXCLUDES(lock_);
template<typename F = Frame,
typename = std::enable_if_t<base::is_serializable_v<F>>>
// The parameter |using_checkpoint_at_or_before| indicates that the ephemeris
// must be restored at the state it had at the checkpoint that was taken at or
// immediately before that time.
// The parameter |desired_t_min| indicates that the trajectory must be
// restored at a checkpoint such that, once it is appended to, its t_min() is
// at or before |desired_t_min|.
static not_null<std::unique_ptr<ContinuousTrajectory>> ReadFromMessage(
Instant const& using_checkpoint_at_or_before,
Instant const& desired_t_min,
serialization::ContinuousTrajectory const& message);

// These members call the corresponding functions of the internal
17 changes: 11 additions & 6 deletions physics/continuous_trajectory_body.hpp
Original file line number Diff line number Diff line change
@@ -356,6 +356,11 @@ void ContinuousTrajectory<Frame>::WriteToMessage(
checkpointer_->WriteToMessage(message->mutable_checkpoint());
step_.WriteToMessage(message->mutable_step());
tolerance_.WriteToMessage(message->mutable_tolerance());

// TODO(phl): There should be no polynomials before the oldest checkpoint, see
// Ephemeris::AppendMassiveBodiesState. This has probably been true since
// Fatou (#2149) and possibly Burnside (#1029). This code should be removed,
// but "Beware the Compatibility, my son!".
for (auto const& pair : polynomials_) {
Instant const& t_max = pair.t_max;
auto const& polynomial = pair.polynomial;
@@ -376,7 +381,7 @@ template<typename Frame>
template<typename, typename>
not_null<std::unique_ptr<ContinuousTrajectory<Frame>>>
ContinuousTrajectory<Frame>::ReadFromMessage(
Instant const& using_checkpoint_at_or_before,
Instant const& desired_t_min,
serialization::ContinuousTrajectory const& message) {
bool const is_pre_cohen = message.series_size() > 0;
bool const is_pre_fatou = !message.has_checkpoint_time();
@@ -454,11 +459,11 @@ ContinuousTrajectory<Frame>::ReadFromMessage(
message.checkpoint());
}

// This has no effect if there is no checkpoint before
// |using_checkpoint_at_or_before|, and leaves the checkpointed fields in
// their default-constructed state.
continuous_trajectory->checkpointer_->ReadFromCheckpointAtOrBefore(
using_checkpoint_at_or_before);
// There should always be a checkpoint, either at the end of the trajectory,
// in the pre-Grassmann compatibility case; or at the first point of the
// trajectory, for modern saves (see the comment in WriteToMessage).
CHECK_OK(continuous_trajectory->checkpointer_->ReadFromCheckpointAtOrBefore(
desired_t_min));

return continuous_trajectory;
}
8 changes: 4 additions & 4 deletions physics/continuous_trajectory_test.cpp
Original file line number Diff line number Diff line change
@@ -729,7 +729,7 @@ TEST_F(ContinuousTrajectoryTest, Serialization) {
EXPECT_EQ(4, checkpoint.last_point_size());

auto const trajectory_read = ContinuousTrajectory<World>::ReadFromMessage(
/*using_checkpoint_at_or_before=*/InfiniteFuture,
/*desired_t_min=*/InfiniteFuture,
message);
EXPECT_EQ(trajectory->t_min(), trajectory_read->t_min());
EXPECT_EQ(trajectory->t_max(), trajectory_read->t_max());
@@ -809,7 +809,7 @@ TEST_F(ContinuousTrajectoryTest, PreCohenCompatibility) {
// that it has the form:
// -2 - 14 * t + 6 * t^2 + 16 * t^3.
auto const trajectory_read = ContinuousTrajectory<World>::ReadFromMessage(
/*using_checkpoint_at_or_before=*/InfiniteFuture,
/*desired_t_min=*/InfiniteFuture,
message);
serialization::ContinuousTrajectory message2;
trajectory_read->WriteToMessage(&message2);
@@ -882,7 +882,7 @@ TEST_F(ContinuousTrajectoryTest, PreGrassmannCompatibility) {
// Read from the pre-Grassmann message, write to a second message, and check
// that we get the same result.
auto const trajectory2 = ContinuousTrajectory<World>::ReadFromMessage(
/*using_checkpoint_at_or_before=*/InfiniteFuture,
/*desired_t_min=*/InfiniteFuture,
pre_grassmann);
serialization::ContinuousTrajectory message2;
trajectory2->WriteToMessage(&message2);
@@ -956,7 +956,7 @@ TEST_F(ContinuousTrajectoryTest, Checkpoint) {
// Read the trajectory and check that everything is identical up to the
// checkpoint.
auto const trajectory_read = ContinuousTrajectory<World>::ReadFromMessage(
/*using_checkpoint_at_or_before=*/InfiniteFuture,
/*desired_t_min=*/InfiniteFuture,
message);
EXPECT_EQ(trajectory_read->t_min(), trajectory->t_min());
EXPECT_EQ(trajectory_read->t_max(), checkpoint_time);