From 79c21d48db6203b45c4e6b12dbb8f6c3af95dc7e Mon Sep 17 00:00:00 2001 From: Nikos Karastathis <n.karastathis@kit.edu> Date: Thu, 28 Oct 2021 15:56:08 +0200 Subject: [PATCH] New getTime() method for start and end of track --- corsika/detail/framework/geometry/LeapFrogTrajectory.inl | 5 +++++ corsika/detail/framework/geometry/StraightTrajectory.inl | 5 +++++ corsika/framework/geometry/LeapFrogTrajectory.hpp | 4 ++++ corsika/framework/geometry/StraightTrajectory.hpp | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/corsika/detail/framework/geometry/LeapFrogTrajectory.inl b/corsika/detail/framework/geometry/LeapFrogTrajectory.inl index af31f8209..48ec83a24 100644 --- a/corsika/detail/framework/geometry/LeapFrogTrajectory.inl +++ b/corsika/detail/framework/geometry/LeapFrogTrajectory.inl @@ -54,6 +54,11 @@ namespace corsika { return step / 2 * (correction + 1); } + template <typename Particle> + inline TimeType LeapFrogTrajectory::getTime(Particle& particle, double const u) const { + return particle.getTime() + getDuration(u); + } + inline LengthType LeapFrogTrajectory::getLength(double const u) const { return getDuration(u) * initialVelocity_.getNorm(); } diff --git a/corsika/detail/framework/geometry/StraightTrajectory.inl b/corsika/detail/framework/geometry/StraightTrajectory.inl index a8fef9b03..9e54467b5 100644 --- a/corsika/detail/framework/geometry/StraightTrajectory.inl +++ b/corsika/detail/framework/geometry/StraightTrajectory.inl @@ -23,6 +23,11 @@ namespace corsika { return u * timeStep_; } + template <typename Particle> + inline TimeType StraightTrajectory::getTime(Particle& particle, double const u) const { + return particle.getTime() + getDuration(u);//timeStep_ * u; + } + inline LengthType StraightTrajectory::getLength(double const u) const { if (timeLength_ == 0_s) return 0_m; if (timeStep_ == std::numeric_limits<TimeType::value_type>::infinity() * 1_s) diff --git a/corsika/framework/geometry/LeapFrogTrajectory.hpp b/corsika/framework/geometry/LeapFrogTrajectory.hpp index 64bd50159..2db3233b8 100644 --- a/corsika/framework/geometry/LeapFrogTrajectory.hpp +++ b/corsika/framework/geometry/LeapFrogTrajectory.hpp @@ -72,6 +72,10 @@ namespace corsika { ///! duration along potentially bend trajectory TimeType getDuration(double const u = 1) const; + ///! 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; + ///! 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 4bed6b7f6..400572588 100644 --- a/corsika/framework/geometry/StraightTrajectory.hpp +++ b/corsika/framework/geometry/StraightTrajectory.hpp @@ -84,6 +84,10 @@ namespace corsika { ///! duration along potentially bend trajectory TimeType getDuration(double const u = 1) const; + ///! 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; + ///! total length along potentially bend trajectory LengthType getLength(double const u = 1) const; -- GitLab