Skip to content

Commit

Permalink
Revert "Serialization of the Fine integrator"
Browse files Browse the repository at this point in the history
pleroy authored Dec 6, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 45e2817 commit 7cd3ab0
Showing 3 changed files with 17 additions and 77 deletions.
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;
}

0 comments on commit 7cd3ab0

Please sign in to comment.