From c921e1127cb7546c3a63ed9e390c0628cd2c0c6c Mon Sep 17 00:00:00 2001 From: Nikos Karastathis <n.karastathis@kit.edu> Date: Mon, 1 Nov 2021 18:02:23 +0100 Subject: [PATCH] Particle references are const in getTime() method. --- corsika/detail/framework/geometry/LeapFrogTrajectory.inl | 2 +- corsika/detail/framework/geometry/StraightTrajectory.inl | 2 +- corsika/framework/geometry/LeapFrogTrajectory.hpp | 2 +- corsika/framework/geometry/StraightTrajectory.hpp | 2 +- tests/framework/testGeometry.cpp | 8 ++++---- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/corsika/detail/framework/geometry/LeapFrogTrajectory.inl b/corsika/detail/framework/geometry/LeapFrogTrajectory.inl index 48ec83a24..97340351e 100644 --- a/corsika/detail/framework/geometry/LeapFrogTrajectory.inl +++ b/corsika/detail/framework/geometry/LeapFrogTrajectory.inl @@ -55,7 +55,7 @@ namespace corsika { } template <typename Particle> - inline TimeType LeapFrogTrajectory::getTime(Particle& particle, double const u) const { + inline TimeType LeapFrogTrajectory::getTime(Particle const& particle, double const u) const { return particle.getTime() + getDuration(u); } diff --git a/corsika/detail/framework/geometry/StraightTrajectory.inl b/corsika/detail/framework/geometry/StraightTrajectory.inl index 9e54467b5..55ddbf9e0 100644 --- a/corsika/detail/framework/geometry/StraightTrajectory.inl +++ b/corsika/detail/framework/geometry/StraightTrajectory.inl @@ -24,7 +24,7 @@ namespace corsika { } template <typename Particle> - inline TimeType StraightTrajectory::getTime(Particle& particle, double const u) const { + inline TimeType StraightTrajectory::getTime(Particle const& particle, double const u) const { return particle.getTime() + getDuration(u);//timeStep_ * u; } diff --git a/corsika/framework/geometry/LeapFrogTrajectory.hpp b/corsika/framework/geometry/LeapFrogTrajectory.hpp index 2db3233b8..984097ac3 100644 --- a/corsika/framework/geometry/LeapFrogTrajectory.hpp +++ b/corsika/framework/geometry/LeapFrogTrajectory.hpp @@ -74,7 +74,7 @@ namespace corsika { ///! time at the start (u=0) or at the end (u=1) of the track of a particle template <typename Particle> - TimeType getTime(Particle& particle, double const u) const; + TimeType getTime(Particle const& particle, double const u) const; ///! total length along potentially bend trajectory LengthType getLength(double const u = 1) const; diff --git a/corsika/framework/geometry/StraightTrajectory.hpp b/corsika/framework/geometry/StraightTrajectory.hpp index 400572588..a47da0db5 100644 --- a/corsika/framework/geometry/StraightTrajectory.hpp +++ b/corsika/framework/geometry/StraightTrajectory.hpp @@ -86,7 +86,7 @@ namespace corsika { ///! time at the start (u=0) or at the end (u=1) of the track of a particle template <typename Particle> - TimeType getTime(Particle& particle, double const u) const; + TimeType getTime(Particle const& particle, double const u) const; ///! total length along potentially bend trajectory LengthType getLength(double const u = 1) const; diff --git a/tests/framework/testGeometry.cpp b/tests/framework/testGeometry.cpp index d688e8d74..e78ac878b 100644 --- a/tests/framework/testGeometry.cpp +++ b/tests/framework/testGeometry.cpp @@ -375,7 +375,7 @@ TEST_CASE("Geometry Trajectories") { StraightTrajectory base(line, t); CHECK(line.getPosition(t).getCoordinates() == base.getPosition(1.).getCoordinates()); // test the getTime() method for straight trajectory - CHECK( base.getTime(particle1, 1) / 1_s == Approx(1)); + CHECK(base.getTime(particle1, 1) / 1_s == Approx(1)); CHECK((base.getDirection(0).getComponents(rootCS) - QuantityVector<dimensionless_d>{1, 0, 0}) @@ -442,9 +442,9 @@ TEST_CASE("Geometry Trajectories") { LeapFrogTrajectory base(pos, v0, B0, k, t); // test the getTime() method for trajectories - CHECK( (base.getTime(particle1,1) - t) / 1_s == 0 ); - CHECK( base.getTime(particle1,0) / 1_s == Approx(0) ); - CHECK( (base.getTime(particle1,0) + t) / 1_s == Approx(1e-12) ); + CHECK((base.getTime(particle1,1) - t) / 1_s == Approx(0)); + CHECK(base.getTime(particle1,0) / 1_s == Approx(0)); + CHECK((base.getTime(particle1,0) + t) / 1_s == Approx(1e-12)); } } -- GitLab