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: 5253a03ee09f
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 70d5ec0cbbb0
Choose a head ref
  • 18 commits
  • 6 files changed
  • 1 contributor

Commits on Feb 27, 2017

  1. PileUp construction test.

    pleroy committed Feb 27, 2017
    Copy the full SHA
    bb7d55a View commit details
  2. Test tolerances.

    pleroy committed Feb 27, 2017
    Copy the full SHA
    c8d422e View commit details

Commits on Mar 1, 2017

  1. Copy the full SHA
    1f2d4f9 View commit details
  2. Copy the full SHA
    c41fe5e View commit details
  3. Running test.

    pleroy committed Mar 1, 2017
    Copy the full SHA
    79b5946 View commit details
  4. DeformPileUpIfNeeded.

    pleroy committed Mar 1, 2017
    Copy the full SHA
    d4c0779 View commit details
  5. Copy the full SHA
    4367de0 View commit details

Commits on Mar 3, 2017

  1. Merging.

    pleroy committed Mar 3, 2017
    Copy the full SHA
    51b8d52 View commit details
  2. Adjust tests.

    pleroy committed Mar 3, 2017
    Copy the full SHA
    3f47d32 View commit details
  3. Fix test.

    pleroy committed Mar 3, 2017
    Copy the full SHA
    b843da3 View commit details
  4. AdvanceTime

    pleroy committed Mar 3, 2017
    Copy the full SHA
    4f73715 View commit details
  5. More AdvanceTime testing.

    pleroy committed Mar 3, 2017
    Copy the full SHA
    81b2de3 View commit details
  6. AdvanceTime tested.

    pleroy committed Mar 3, 2017
    Copy the full SHA
    0bafddd View commit details
  7. Full lifecycle test.

    pleroy committed Mar 3, 2017
    Copy the full SHA
    4003df9 View commit details

Commits on Mar 4, 2017

  1. Copy the full SHA
    f67b8e2 View commit details
  2. Fix test.

    pleroy committed Mar 4, 2017
    Copy the full SHA
    9316987 View commit details
  3. After egg's review.

    pleroy committed Mar 4, 2017
    Copy the full SHA
    dcd3be8 View commit details
  4. Merge pull request #1221 from pleroy/Tests

    Basic test for the PileUp
    pleroy authored Mar 4, 2017
    Copy the full SHA
    70d5ec0 View commit details
Showing with 505 additions and 125 deletions.
  1. +3 −3 ksp_plugin/part.cpp
  2. +2 −1 ksp_plugin/part.hpp
  3. +28 −26 ksp_plugin/pile_up.cpp
  4. +10 −7 ksp_plugin/pile_up.hpp
  5. +7 −8 ksp_plugin_test/part_test.cpp
  6. +455 −80 ksp_plugin_test/pile_up_test.cpp
6 changes: 3 additions & 3 deletions ksp_plugin/part.cpp
Original file line number Diff line number Diff line change
@@ -120,14 +120,14 @@ void Part::WriteToMessage(not_null<serialization::Part*> const message) const {
}

not_null<std::unique_ptr<Part>> Part::ReadFromMessage(
serialization::Part const& message) {
// TODO(phl): Serialize/Deserialize the deletion callback.
serialization::Part const& message,
std::function<void()> deletion_callback) {
not_null<std::unique_ptr<Part>> part =
make_not_null_unique<Part>(message.part_id(),
Mass::ReadFromMessage(message.mass()),
DegreesOfFreedom<Barycentric>::ReadFromMessage(
message.degrees_of_freedom()),
/*TODO=*/nullptr);
std::move(deletion_callback));
part->increment_intrinsic_force(
Vector<Force, Barycentric>::ReadFromMessage(message.intrinsic_force()));
if (message.has_containing_pile_up()) {
3 changes: 2 additions & 1 deletion ksp_plugin/part.hpp
Original file line number Diff line number Diff line change
@@ -104,7 +104,8 @@ class Part final {

void WriteToMessage(not_null<serialization::Part*> message) const;
static not_null<std::unique_ptr<Part>> ReadFromMessage(
serialization::Part const& message);
serialization::Part const& message,
std::function<void()> deletion_callback);

private:
PartId const part_id_;
54 changes: 28 additions & 26 deletions ksp_plugin/pile_up.cpp
Original file line number Diff line number Diff line change
@@ -33,15 +33,16 @@ PileUp::PileUp(std::list<not_null<Part*>>&& parts, Instant const& t)
}
mass_ = calculator.weight();
intrinsic_force_ = total_intrinsic_force;
psychohistory_.Append(t, calculator.Get());
DegreesOfFreedom<Barycentric> const barycentre = calculator.Get();
psychohistory_.Append(t, barycentre);

RigidMotion<Barycentric, RigidPileUp> const barycentric_to_pile_up{
RigidTransformation<Barycentric, RigidPileUp>{
calculator.Get().position(),
barycentre.position(),
RigidPileUp::origin,
OrthogonalMap<Barycentric, RigidPileUp>::Identity()},
Identity<Barycentric, RigidPileUp>().Forget()},
AngularVelocity<Barycentric>{},
calculator.Get().velocity()};
barycentre.velocity()};
for (not_null<Part*> const part : parts_) {
actual_part_degrees_of_freedom_.emplace(
part,
@@ -135,27 +136,28 @@ void PileUp::AdvanceTime(
t,
fixed_step_parameters);
if (psychohistory_.last().time() < t) {
prolongation.Append(prolongation.last().time(),
prolongation.last().degrees_of_freedom());
ephemeris.FlowWithAdaptiveStep(
&prolongation,
Ephemeris<Barycentric>::NoIntrinsicAcceleration,
t,
adaptive_step_parameters,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/true);
// TODO(phl): Consider using forks.
prolongation.Append(psychohistory_.last().time(),
psychohistory_.last().degrees_of_freedom());
CHECK(ephemeris.FlowWithAdaptiveStep(
&prolongation,
Ephemeris<Barycentric>::NoIntrinsicAcceleration,
t,
adaptive_step_parameters,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/true));
CHECK_EQ(prolongation.Size(), 2);
}
} else {
auto const a = intrinsic_force_ / mass_;
auto const intrinsic_acceleration = [a](Instant const& t) { return a; };
ephemeris.FlowWithAdaptiveStep(
&psychohistory_,
intrinsic_acceleration,
t,
adaptive_step_parameters,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/false);
CHECK(ephemeris.FlowWithAdaptiveStep(
&psychohistory_,
intrinsic_acceleration,
t,
adaptive_step_parameters,
Ephemeris<Barycentric>::unlimited_max_ephemeris_steps,
/*last_point_only=*/false));
}
auto it = psychohistory_.Begin();
++it;
@@ -192,18 +194,18 @@ void PileUp::AppendToPartTails(
DiscreteTrajectory<Barycentric>::Iterator const it,
bool const authoritative) const {
auto const& pile_up_dof = it.degrees_of_freedom();
RigidMotion<Barycentric, RigidPileUp> const from_barycentric(
RigidMotion<Barycentric, RigidPileUp> const barycentric_to_pile_up(
RigidTransformation<Barycentric, RigidPileUp>(
pile_up_dof.position(),
RigidPileUp::origin,
OrthogonalMap<Barycentric, RigidPileUp>::Identity()),
Identity<Barycentric, RigidPileUp>().Forget()),
AngularVelocity<Barycentric>{},
pile_up_dof.velocity());
auto const to_barycentric = from_barycentric.Inverse();
auto const pile_up_to_barycentric = barycentric_to_pile_up.Inverse();
for (not_null<Part*> const part : parts_) {
part->tail().Append(
it.time(),
to_barycentric(FindOrDie(actual_part_degrees_of_freedom_, part)));
part->tail().Append(it.time(),
pile_up_to_barycentric(
FindOrDie(actual_part_degrees_of_freedom_, part)));
part->set_tail_is_authoritative(authoritative);
}
}
17 changes: 10 additions & 7 deletions ksp_plugin/pile_up.hpp
Original file line number Diff line number Diff line change
@@ -33,9 +33,10 @@ using quantities::Mass;
// A |PileUp| handles a connected component of the graph of |Parts| under
// physical contact. It advances the history and prolongation of its component
// |Parts|, modeling them as a massless body at their centre of mass.
class PileUp final {
class PileUp {
public:
PileUp(std::list<not_null<Part*>>&& parts, Instant const& t);
virtual ~PileUp() = default;

void set_mass(Mass const& mass);
void set_intrinsic_force(Vector<Force, Barycentric> const& intrinsic_force);
@@ -54,9 +55,8 @@ class PileUp final {
// matches that computed by integration.
// |SetPartApparentDegreesOfFreedom| must have been called for each part in
// the pile-up, or for none.
// The degrees of freedom set by |NudgePartsInPileUpIfNeeded| are used by
// |AdvanceTime|.
// NOTE(egg): Eventually, this will also nudge their velocities and angular
// The degrees of freedom set by this method are used by |NudgeParts|.
// NOTE(egg): Eventually, this will also change their velocities and angular
// velocities so that the angular momentum matches that which has been
// computed for |this| |PileUp|.
void DeformPileUpIfNeeded();
@@ -72,9 +72,10 @@ class PileUp final {
Ephemeris<Barycentric>::AdaptiveStepParameters const&
adaptive_step_parameters);

// Adjusts the |Bubble| degrees of freedom of all parts in this pile up based
// on the origin of |Bubble| given in |Barycentric|, and on the |RigidPileUp|
// degrees of freedom of the parts (as set by |DeformPileUpIfNeeded|).
// Adjusts the degrees of freedom of all parts in this pile up based on the
// degrees of freedom of the pile-up computed by |AdvanceTime| and on the
// |RigidPileUp| degrees of freedom of the parts, as set by
// |DeformPileUpIfNeeded|.
void NudgeParts() const;

private:
@@ -109,6 +110,8 @@ class PileUp final {
actual_part_degrees_of_freedom_;
std::map<not_null<Part*>, DegreesOfFreedom<ApparentBubble>>
apparent_part_degrees_of_freedom_;

friend class TestablePileUp;
};

} // namespace internal_pile_up
15 changes: 7 additions & 8 deletions ksp_plugin_test/part_test.cpp
Original file line number Diff line number Diff line change
@@ -18,9 +18,8 @@ using quantities::si::Second;

class PartTest : public testing::Test {
protected:
PartTest() : part_(part_id_, mass_) {
PartTest() : part_(part_id_, mass_, degrees_of_freedom_, /*deletion_callback=*/nullptr) {
part_.increment_intrinsic_force(intrinsic_force_);
part_.set_degrees_of_freedom(degrees_of_freedom_);
part_.tail().Append(
astronomy::J2000,
{Barycentric::origin +
@@ -29,9 +28,10 @@ class PartTest : public testing::Test {
{44 * Metre / Second, 55 * Metre / Second, 66 * Metre / Second})});
}

DegreesOfFreedom<Bubble> const degrees_of_freedom_ = {
Bubble::origin + Displacement<Bubble>({1 * Metre, 2 * Metre, 3 * Metre}),
Velocity<Bubble>(
DegreesOfFreedom<Barycentric> const degrees_of_freedom_ = {
Barycentric::origin +
Displacement<Barycentric>({1 * Metre, 2 * Metre, 3 * Metre}),
Velocity<Barycentric>(
{4 * Metre / Second, 5 * Metre / Second, 6 * Metre / Second})};
PartId const part_id_ = 666;
Mass const mass_ = 7 * Kilogram;
@@ -77,11 +77,10 @@ TEST_F(PartTest, Serialization) {
EXPECT_EQ(1, message.tail().timeline_size());
EXPECT_FALSE(message.tail_is_authoritative());

auto const p = Part::ReadFromMessage(message);
auto const p = Part::ReadFromMessage(message, /*deletion_callback=*/nullptr);
EXPECT_EQ(part_.mass(), p->mass());
EXPECT_EQ(part_.intrinsic_force(), p->intrinsic_force());
EXPECT_TRUE(p->degrees_of_freedom());
EXPECT_EQ(*part_.degrees_of_freedom(), *p->degrees_of_freedom());
EXPECT_EQ(part_.degrees_of_freedom(), p->degrees_of_freedom());

serialization::Part second_message;
p->WriteToMessage(&second_message);
535 changes: 455 additions & 80 deletions ksp_plugin_test/pile_up_test.cpp

Large diffs are not rendered by default.