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

Commits on Jan 11, 2020

  1. A new serialization test.

    pleroy committed Jan 11, 2020
    Copy the full SHA
    f138adf View commit details
  2. Copy the full SHA
    0ec208c View commit details
  3. SFINAE.

    pleroy committed Jan 11, 2020
    Copy the full SHA
    a5a412e View commit details
  4. Handle ASSI like we do FSSI.

    pleroy committed Jan 11, 2020
    Copy the full SHA
    8bf6fd2 View commit details
  5. Fix construction check.

    pleroy committed Jan 11, 2020
    Copy the full SHA
    e91c16d View commit details
  6. Fix compilation errors.

    pleroy committed Jan 11, 2020
    Copy the full SHA
    5726aa2 View commit details

Commits on Jan 13, 2020

  1. After egg's review.

    pleroy committed Jan 13, 2020
    Copy the full SHA
    c733b40 View commit details

Commits on Jan 14, 2020

  1. Merge pull request #2437 from pleroy/Integrator

    Change the ReadFromMessage method of the adaptive-step size integrators to be static
    pleroy authored Jan 14, 2020
    Copy the full SHA
    d5eaccf View commit details
Original file line number Diff line number Diff line change
@@ -101,12 +101,28 @@ class EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator

void WriteToMessage(
not_null<serialization::IntegratorInstance*> message) const override;
template<typename P = Position,
typename = std::enable_if_t<base::is_serializable_v<P>>>
static not_null<std::unique_ptr<Instance>> ReadFromMessage(
serialization::
EmbeddedExplicitGeneralizedRungeKuttaNystromIntegratorInstance const&
extension,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters,
Time const& time_step,
bool first_use,
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator const&
integrator);

private:
Instance(IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& adaptive_step_size,
Parameters const& parameters,
Time const& time_step,
bool first_use,
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator const&
integrator);

@@ -125,14 +141,6 @@ class EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator
const override;

private:
not_null<std::unique_ptr<typename Integrator<ODE>::Instance>>
ReadFromMessage(
serialization::AdaptiveStepSizeIntegratorInstance const& message,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const override;

static constexpr auto stages_ = Method::stages;
static constexpr auto c_ = Method::c;
static constexpr auto a_ = Method::a;
Original file line number Diff line number Diff line change
@@ -291,67 +291,79 @@ Instance::WriteToMessage(
}

template<typename Method, typename Position>
template<typename, typename>
not_null<std::unique_ptr<
typename EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<
Method, Position>::Instance>>
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<Method, Position>::
Instance::Instance(
Instance::ReadFromMessage(
serialization::
EmbeddedExplicitGeneralizedRungeKuttaNystromIntegratorInstance const&
extension,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters,
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator const& integrator)
: AdaptiveStepSizeIntegrator<ODE>::Instance(
problem, append_state, tolerance_to_error_ratio, parameters),
integrator_(integrator) {}

template<typename Method, typename Position>
not_null<std::unique_ptr<typename Integrator<
ExplicitSecondOrderOrdinaryDifferentialEquation<Position>>::Instance>>
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<Method, Position>::
NewInstance(IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const {
Time const& time_step,
bool const first_use,
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator const&
integrator) {
// Cannot use |make_not_null_unique| because the constructor of |Instance| is
// private.
return std::unique_ptr<Instance>(new Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
*this));
time_step,
first_use,
integrator));
}

template<typename Method, typename Position>
void EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<Method, Position>::
WriteToMessage(not_null<serialization::AdaptiveStepSizeIntegrator*> message)
const {
message->set_kind(Method::kind);
}

template<typename Method, typename Position>
not_null<std::unique_ptr<typename Integrator<
ExplicitSecondOrderOrdinaryDifferentialEquation<Position>>::Instance>>
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<Method, Position>::
ReadFromMessage(
serialization::AdaptiveStepSizeIntegratorInstance const& message,
Instance::Instance(
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const {
CHECK(message.HasExtension(
serialization::
EmbeddedExplicitGeneralizedRungeKuttaNystromIntegratorInstance::
extension))
<< message.DebugString();
Parameters const& parameters,
Time const& time_step,
bool const first_use,
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator const& integrator)
: AdaptiveStepSizeIntegrator<ODE>::Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
time_step,
first_use),
integrator_(integrator) {}

template<typename Method, typename Position>
not_null<std::unique_ptr<typename Integrator<
ExplicitSecondOrderOrdinaryDifferentialEquation<Position>>::Instance>>
EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<Method, Position>::
NewInstance(IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const {
// Cannot use |make_not_null_unique| because the constructor of |Instance| is
// private.
return std::unique_ptr<typename AdaptiveStepSizeIntegrator<ODE>::Instance>(
return std::unique_ptr<Instance>(
new Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
/*time_step=*/parameters.first_time_step,
/*first_use=*/true,
*this));
}

template<typename Method, typename Position>
void EmbeddedExplicitGeneralizedRungeKuttaNyströmIntegrator<Method, Position>::
WriteToMessage(not_null<serialization::AdaptiveStepSizeIntegrator*> message)
const {
message->set_kind(Method::kind);
}

} // namespace internal_embedded_explicit_generalized_runge_kutta_nyström_integrator // NOLINT

template<typename Method, typename Position>
25 changes: 16 additions & 9 deletions integrators/embedded_explicit_runge_kutta_nyström_integrator.hpp
Original file line number Diff line number Diff line change
@@ -99,12 +99,27 @@ class EmbeddedExplicitRungeKuttaNyströmIntegrator

void WriteToMessage(
not_null<serialization::IntegratorInstance*> message) const override;
template<typename P = Position,
typename = std::enable_if_t<base::is_serializable_v<P>>>
static not_null<std::unique_ptr<Instance>> ReadFromMessage(
serialization::
EmbeddedExplicitRungeKuttaNystromIntegratorInstance const&
extension,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters,
Time const& time_step,
bool first_use,
EmbeddedExplicitRungeKuttaNyströmIntegrator const& integrator);

private:
Instance(IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& adaptive_step_size,
Parameters const& parameters,
Time const& time_step,
bool first_use,
EmbeddedExplicitRungeKuttaNyströmIntegrator const& integrator);

EmbeddedExplicitRungeKuttaNyströmIntegrator const& integrator_;
@@ -122,14 +137,6 @@ class EmbeddedExplicitRungeKuttaNyströmIntegrator
const override;

private:
not_null<std::unique_ptr<typename Integrator<ODE>::Instance>>
ReadFromMessage(
serialization::AdaptiveStepSizeIntegratorInstance const& message,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const override;

static constexpr auto stages_ = Method::stages;
static constexpr auto c_ = Method::c;
static constexpr auto a_ = Method::a;
Original file line number Diff line number Diff line change
@@ -285,16 +285,50 @@ Instance::WriteToMessage(
extension);
}

template<typename Method, typename Position>
template<typename, typename>
not_null<std::unique_ptr<
typename EmbeddedExplicitRungeKuttaNyströmIntegrator<Method,
Position>::Instance>>
EmbeddedExplicitRungeKuttaNyströmIntegrator<Method, Position>::Instance::
ReadFromMessage(
serialization::
EmbeddedExplicitRungeKuttaNystromIntegratorInstance const&
extension,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters,
Time const& time_step,
bool const first_use,
EmbeddedExplicitRungeKuttaNyströmIntegrator const& integrator) {
// Cannot use |make_not_null_unique| because the constructor of |Instance| is
// private.
return std::unique_ptr<Instance>(new Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
time_step,
first_use,
integrator));
}

template<typename Method, typename Position>
EmbeddedExplicitRungeKuttaNyströmIntegrator<Method, Position>::
Instance::Instance(
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters,
Time const& time_step,
bool const first_use,
EmbeddedExplicitRungeKuttaNyströmIntegrator const& integrator)
: AdaptiveStepSizeIntegrator<ODE>::Instance(
problem, append_state, tolerance_to_error_ratio, parameters),
: AdaptiveStepSizeIntegrator<ODE>::Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
time_step,
first_use),
integrator_(integrator) {}

template<typename Method, typename Position>
@@ -307,11 +341,14 @@ NewInstance(IntegrationProblem<ODE> const& problem,
Parameters const& parameters) const {
// Cannot use |make_not_null_unique| because the constructor of |Instance| is
// private.
return std::unique_ptr<Instance>(new Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
*this));
return std::unique_ptr<Instance>(
new Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
/*time_step=*/parameters.first_time_step,
/*first_use=*/true,
*this));
}

template<typename Method, typename Position>
@@ -321,31 +358,6 @@ WriteToMessage(not_null<serialization::AdaptiveStepSizeIntegrator*> message)
message->set_kind(Method::kind);
}

template<typename Method, typename Position>
not_null<std::unique_ptr<typename Integrator<
SpecialSecondOrderDifferentialEquation<Position>>::Instance>>
EmbeddedExplicitRungeKuttaNyströmIntegrator<Method, Position>::
ReadFromMessage(
serialization::AdaptiveStepSizeIntegratorInstance const& message,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const {
CHECK(message.HasExtension(
serialization::EmbeddedExplicitRungeKuttaNystromIntegratorInstance::
extension))
<< message.DebugString();

// Cannot use |make_not_null_unique| because the constructor of |Instance| is
// private.
return std::unique_ptr<typename AdaptiveStepSizeIntegrator<ODE>::Instance>(
new Instance(problem,
append_state,
tolerance_to_error_ratio,
parameters,
*this));
}

} // namespace internal_embedded_explicit_runge_kutta_nyström_integrator

template<typename Method, typename Position>
21 changes: 6 additions & 15 deletions integrators/integrators.hpp
Original file line number Diff line number Diff line change
@@ -112,8 +112,6 @@ class FixedStepSizeIntegrator : public Integrator<ODE_> {

virtual void WriteToMessage(
not_null<serialization::FixedStepSizeIntegrator*> message) const = 0;
template<typename S = typename ODE::SystemState,
typename = std::enable_if_t<base::is_serializable_v<S>>>
static FixedStepSizeIntegrator const& ReadFromMessage(
serialization::FixedStepSizeIntegrator const& message);

@@ -183,6 +181,8 @@ class AdaptiveStepSizeIntegrator : public Integrator<ODE_> {

void WriteToMessage(
not_null<serialization::IntegratorInstance*> message) const override;
template<typename S = typename ODE::SystemState,
typename = std::enable_if_t<base::is_serializable_v<S>>>
static not_null<std::unique_ptr<typename Integrator<ODE>::Instance>>
ReadFromMessage(serialization::IntegratorInstance const& message,
ODE const& equation,
@@ -193,12 +193,14 @@ class AdaptiveStepSizeIntegrator : public Integrator<ODE_> {
Instance(IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters);
Parameters const& parameters,
Time const& time_step,
bool first_use);

ToleranceToErrorRatio const tolerance_to_error_ratio_;
Parameters const parameters_;
Time time_step_;
bool first_use_ = true;
bool first_use_;
};

// The factory function for |Instance|, above. It ensures that the instance
@@ -215,17 +217,6 @@ class AdaptiveStepSizeIntegrator : public Integrator<ODE_> {
serialization::AdaptiveStepSizeIntegrator const& message);

protected:
// For convenience, deserialization is an instance member of the |Integrator|,
// not a static member of the |Instance|. Which makes sense if you see
// |Integrator| as a factory for |Instance|.
virtual not_null<std::unique_ptr<typename Integrator<ODE>::Instance>>
ReadFromMessage(
serialization::AdaptiveStepSizeIntegratorInstance const& message,
IntegrationProblem<ODE> const& problem,
AppendState const& append_state,
ToleranceToErrorRatio const& tolerance_to_error_ratio,
Parameters const& parameters) const = 0;

AdaptiveStepSizeIntegrator() = default;
};

Loading