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: 45e2817c63d4
Choose a base ref
...
head repository: mockingbirdnest/Principia
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6489f336cb71
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Dec 6, 2018

  1. Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    7cd3ab0 View commit details
  2. Merge pull request #2016 from mockingbirdnest/revert-2010-1931c

    Revert "Serialization of the Fine integrator"
    pleroy authored Dec 6, 2018

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
    Copy the full SHA
    6489f33 View commit details
Showing with 17 additions and 77 deletions.
  1. +15 −75 integrators/integrators_body.hpp
  2. +2 −1 integrators/methods.hpp
  3. +0 −1 serialization/integrators.proto
90 changes: 15 additions & 75 deletions integrators/integrators_body.hpp
Original file line number Diff line number Diff line change
@@ -4,7 +4,6 @@
#include "integrators/integrators.hpp"

#include <limits>
#include <vector>
#include <string>

#include "base/macros.hpp"
@@ -43,16 +42,18 @@ namespace integrators {
namespace internal_integrators {

template<typename ODE, typename Method, bool first_same_as_last>
struct SprkAsSrknDeserializer;
class SprkAsSrknDeserializer;

template<typename ODE, typename Method>
struct SprkAsSrknDeserializer<ODE, Method, false> {
class SprkAsSrknDeserializer<ODE, Method, false> {
public:
static FixedStepSizeIntegrator<ODE> const& ReadFromMessage(
serialization::FixedStepSizeIntegrator const& message);
};

template<typename ODE, typename Method>
struct SprkAsSrknDeserializer<ODE, Method, true> {
class SprkAsSrknDeserializer<ODE, Method, true> {
public:
static FixedStepSizeIntegrator<ODE> const& ReadFromMessage(
serialization::FixedStepSizeIntegrator const& message);
};
@@ -91,74 +92,6 @@ SprkAsSrknDeserializer<ODE, Method, true>::ReadFromMessage(
}
}

// The parameters of the |RightHandSideComputation| determines the type of the
// integrator when the method may be used for several kinds of integrators
// (this may not hold in general as we add more integrators).
template<typename RightHandSideComputation>
struct AdaptiveStepSizeIntegratorDeserializer;

template<typename Position, typename Acceleration>
struct AdaptiveStepSizeIntegratorDeserializer<
std::function<Status(Instant const& t,
std::vector<Position> const& positions,
std::vector<Acceleration>& accelerations)>> {
template<typename Integrator>
static Integrator const& ReadFromMessage(
serialization::AdaptiveStepSizeIntegrator const& message);
};

template<typename Position, typename Velocity, typename Acceleration>
struct AdaptiveStepSizeIntegratorDeserializer<
std::function<Status(Instant const& t,
std::vector<Position> const& positions,
std::vector<Velocity> const& velocities,
std::vector<Acceleration>& accelerations)>> {
template<typename Integrator>
static Integrator const& ReadFromMessage(
serialization::AdaptiveStepSizeIntegrator const& message);
};

template<typename Position, typename Acceleration>
template<typename Integrator>
Integrator const& AdaptiveStepSizeIntegratorDeserializer<
std::function<Status(Instant const& t,
std::vector<Position> const& positions,
std::vector<Acceleration>& accelerations)>>::
ReadFromMessage(serialization::AdaptiveStepSizeIntegrator const& message) {
using ASSI = serialization::AdaptiveStepSizeIntegrator;
switch (message.kind()) {
case ASSI::DORMAND_ELMIKKAWY_PRINCE_1986_RKN_434FM:
return EmbeddedExplicitRungeKuttaNyströmIntegrator<
methods::DormandالمكاوىPrince1986RKN434FM, Position>();
case ASSI::FINE_1987_RKNG_34:
return EmbeddedExplicitRungeKuttaNyströmIntegrator<
methods::Fine1987RKNG34, Position>();
default:
LOG(FATAL) << message.kind();
base::noreturn();
}
}

template<typename Position, typename Velocity, typename Acceleration>
template<typename Integrator>
Integrator const& AdaptiveStepSizeIntegratorDeserializer<
std::function<Status(Instant const& t,
std::vector<Position> const& positions,
std::vector<Velocity> const& velocities,
std::vector<Acceleration>& accelerations)>>::
ReadFromMessage(serialization::AdaptiveStepSizeIntegrator const& message) {
using ASSI = serialization::AdaptiveStepSizeIntegrator;
switch (message.kind()) {
case ASSI::FINE_1987_RKNG_34:
return EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<
methods::Fine1987RKNG34, Position>();
case ASSI::DORMAND_ELMIKKAWY_PRINCE_1986_RKN_434FM:
default:
LOG(FATAL) << message.kind();
base::noreturn();
}
}

template<typename ODE_>
Integrator<ODE_>::Instance::Instance(
IntegrationProblem<ODE> const& problem,
@@ -446,9 +379,16 @@ template<typename ODE_>
AdaptiveStepSizeIntegrator<ODE_> const&
AdaptiveStepSizeIntegrator<ODE_>::ReadFromMessage(
serialization::AdaptiveStepSizeIntegrator const& message) {
return AdaptiveStepSizeIntegratorDeserializer<
typename ODE_::RightHandSideComputation>::
ReadFromMessage<AdaptiveStepSizeIntegrator<ODE_>>(message);
using ASSI = serialization::AdaptiveStepSizeIntegrator;
switch (message.kind()) {
case ASSI::DORMAND_ELMIKKAWY_PRINCE_1986_RKN_434FM:
return EmbeddedExplicitRungeKuttaNyströmIntegrator<
methods::DormandالمكاوىPrince1986RKN434FM,
typename ODE::Position>();
default:
LOG(FATAL) << message.kind();
base::noreturn();
}
}

template<typename Equation>
3 changes: 2 additions & 1 deletion integrators/methods.hpp
Original file line number Diff line number Diff line change
@@ -351,7 +351,8 @@ struct Fine1987RKNG34 : EmbeddedExplicitGeneralizedRungeKuttaNyström {
static constexpr int stages = 5;
static constexpr bool first_same_as_last = false;
static constexpr serialization::AdaptiveStepSizeIntegrator::Kind kind =
serialization::AdaptiveStepSizeIntegrator::FINE_1987_RKNG_34;
serialization::AdaptiveStepSizeIntegrator::
DORMAND_ELMIKKAWY_PRINCE_1986_RKN_434FM;
static constexpr FixedVector<double, stages> c{{
{ 0 , 2 / 9.0, 1 / 3.0, 3 / 4.0, 1.0}}};
static constexpr FixedStrictlyLowerTriangularMatrix<double, stages> a{{
1 change: 0 additions & 1 deletion serialization/integrators.proto
Original file line number Diff line number Diff line change
@@ -18,7 +18,6 @@ message AdaptiveStepSizeIntegrator {
}
enum Kind {
DORMAND_ELMIKKAWY_PRINCE_1986_RKN_434FM = 1;
FINE_1987_RKNG_34 = 2;
}
required Kind kind = 1;
}