diff --git a/corsika/detail/media/BaseExponential.inl b/corsika/detail/media/BaseExponential.inl index a40981bef9feb867c082e0d43ddb791352d8768b..3d7790c29bf80479a275e8a7349953d31c65c557 100644 --- a/corsika/detail/media/BaseExponential.inl +++ b/corsika/detail/media/BaseExponential.inl @@ -21,7 +21,7 @@ namespace corsika { template <typename TDerived> inline GrammageType BaseExponential<TDerived>::getIntegratedGrammage( - setup::Trajectory const& traj, LengthType vL, DirectionVector const& axis) const { + BaseTrajectory const& traj, LengthType vL, DirectionVector const& axis) const { if (vL == LengthType::zero()) { return GrammageType::zero(); } auto const uDotA = traj.getDirection(0).dot(axis).magnitude(); @@ -36,7 +36,7 @@ namespace corsika { template <typename TDerived> inline LengthType BaseExponential<TDerived>::getArclengthFromGrammage( - setup::Trajectory const& traj, GrammageType grammage, + BaseTrajectory const& traj, GrammageType grammage, DirectionVector const& axis) const { auto const uDotA = traj.getDirection(0).dot(axis).magnitude(); auto const rhoStart = getImplementation().getMassDensity(traj.getPosition(0)); diff --git a/corsika/detail/media/FlatExponential.inl b/corsika/detail/media/FlatExponential.inl index cdada02df557031db3c80ce91eb1de75eca1415e..b64b2ded2f3546886f490fcfc9e3a37906609d01 100644 --- a/corsika/detail/media/FlatExponential.inl +++ b/corsika/detail/media/FlatExponential.inl @@ -40,13 +40,13 @@ namespace corsika { template <typename T> inline GrammageType FlatExponential<T>::getIntegratedGrammage( - setup::Trajectory const& line, LengthType to) const { + BaseTrajectory const& line, LengthType to) const { return BaseExponential<FlatExponential<T>>::getIntegratedGrammage(line, to, axis_); } template <typename T> inline LengthType FlatExponential<T>::getArclengthFromGrammage( - setup::Trajectory const& line, GrammageType grammage) const { + BaseTrajectory const& line, GrammageType grammage) const { return BaseExponential<FlatExponential<T>>::getArclengthFromGrammage(line, grammage, axis_); } diff --git a/corsika/detail/media/HomogeneousMedium.inl b/corsika/detail/media/HomogeneousMedium.inl index fd0148b0278dcbad64f5ae37ca4a1d9b01243ba6..94fb90cd4f39d958795bc1df681206430c725153 100644 --- a/corsika/detail/media/HomogeneousMedium.inl +++ b/corsika/detail/media/HomogeneousMedium.inl @@ -33,13 +33,13 @@ namespace corsika { template <typename T> inline GrammageType HomogeneousMedium<T>::getIntegratedGrammage( - setup::Trajectory const&, LengthType to) const { + BaseTrajectory const&, LengthType to) const { return to * density_; } template <typename T> inline LengthType HomogeneousMedium<T>::getArclengthFromGrammage( - setup::Trajectory const&, GrammageType grammage) const { + BaseTrajectory const&, GrammageType grammage) const { return grammage / density_; } } // namespace corsika diff --git a/corsika/detail/media/InhomogeneousMedium.inl b/corsika/detail/media/InhomogeneousMedium.inl index 48d1d266e5f308cddb6b990678aa6b66ace2e473..8706765addf54494958788dd5709a7bc2ab9094b 100644 --- a/corsika/detail/media/InhomogeneousMedium.inl +++ b/corsika/detail/media/InhomogeneousMedium.inl @@ -36,13 +36,13 @@ namespace corsika { template <typename T, typename TDensityFunction> inline GrammageType InhomogeneousMedium<T, TDensityFunction>::getIntegratedGrammage( - setup::Trajectory const& line, LengthType to) const { + BaseTrajectory const& line, LengthType to) const { return densityFunction_.getIntegrateGrammage(line, to); } template <typename T, typename TDensityFunction> inline LengthType InhomogeneousMedium<T, TDensityFunction>::getArclengthFromGrammage( - setup::Trajectory const& line, GrammageType grammage) const { + BaseTrajectory const& line, GrammageType grammage) const { return densityFunction_.getArclengthFromGrammage(line, grammage); } diff --git a/corsika/detail/media/LinearApproximationIntegrator.inl b/corsika/detail/media/LinearApproximationIntegrator.inl index 78b7733ed138f12ace9e99ed381776487094cadc..ced2dee38b7f477c7c81d9bc80c1fe27024094b6 100644 --- a/corsika/detail/media/LinearApproximationIntegrator.inl +++ b/corsika/detail/media/LinearApproximationIntegrator.inl @@ -19,7 +19,7 @@ namespace corsika { template <typename TDerived> inline auto LinearApproximationIntegrator<TDerived>::getIntegrateGrammage( - setup::Trajectory const& line, LengthType length) const { + BaseTrajectory const& line, LengthType length) const { auto const c0 = getImplementation().evaluateAt(line.getPosition(0)); auto const c1 = getImplementation().rho_.getFirstDerivative(line.getPosition(0), line.getDirection(0)); @@ -28,7 +28,7 @@ namespace corsika { template <typename TDerived> inline auto LinearApproximationIntegrator<TDerived>::getArclengthFromGrammage( - setup::Trajectory const& line, GrammageType grammage) const { + BaseTrajectory const& line, GrammageType grammage) const { auto const c0 = getImplementation().rho_(line.getPosition(0)); auto const c1 = getImplementation().rho_.getFirstDerivative(line.getPosition(0), line.getDirection(0)); @@ -38,7 +38,7 @@ namespace corsika { template <typename TDerived> inline auto LinearApproximationIntegrator<TDerived>::getMaximumLength( - setup::Trajectory const& line, [[maybe_unused]] double relError) const { + BaseTrajectory const& line, [[maybe_unused]] double relError) const { [[maybe_unused]] auto const c1 = getImplementation().rho_.getSecondDerivative( line.getPosition(0), line.getDirection(0)); diff --git a/corsika/detail/media/SlidingPlanarExponential.inl b/corsika/detail/media/SlidingPlanarExponential.inl index 56d99404ce835b860e93ba8db21ec2ce34462d4b..61911772a432e5d4d1c5b6cec3fc13f9ea2c8cdf 100644 --- a/corsika/detail/media/SlidingPlanarExponential.inl +++ b/corsika/detail/media/SlidingPlanarExponential.inl @@ -39,7 +39,7 @@ namespace corsika { template <typename T> inline GrammageType SlidingPlanarExponential<T>::getIntegratedGrammage( - setup::Trajectory const& traj, LengthType l) const { + BaseTrajectory const& traj, LengthType l) const { auto const axis = (traj.getPosition(0) - BaseExponential<SlidingPlanarExponential<T>>::getAnchorPoint()) .normalized(); @@ -49,7 +49,7 @@ namespace corsika { template <typename T> inline LengthType SlidingPlanarExponential<T>::getArclengthFromGrammage( - setup::Trajectory const& traj, GrammageType const grammage) const { + BaseTrajectory const& traj, GrammageType const grammage) const { auto const axis = (traj.getPosition(0) - BaseExponential<SlidingPlanarExponential<T>>::getAnchorPoint()) .normalized(); diff --git a/corsika/framework/geometry/BaseTrajectory.hpp b/corsika/framework/geometry/BaseTrajectory.hpp new file mode 100644 index 0000000000000000000000000000000000000000..433df38dbcfc27ed6ba72a502dc7690da1721690 --- /dev/null +++ b/corsika/framework/geometry/BaseTrajectory.hpp @@ -0,0 +1,57 @@ +/* + * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu + * + * This software is distributed under the terms of the GNU General Public + * Licence version 3 (GPL Version 3). See file LICENSE for a full version of + * the license. + */ + +#pragma once + +#include <corsika/framework/geometry/Line.hpp> +#include <corsika/framework/geometry/Point.hpp> + +namespace corsika { + + /** + * + * A Trajectory is a description of a momvement of an object in + * three-dimensional space that describes the trajectory (connection + * between two Points in space), as well as the direction of motion + * at any given point. + * + * A Trajectory has a start `0` and an end `1`, where + * e.g. getPosition(0) returns the start point and getDirection(1) + * the direction of motion at the end. Values outside 0...1 are not + * defined. + * + * A Trajectory has a length in [m], getLength, a duration in [s], getDuration. + * + * Note: so far it is assumed that the speed (d|vec{r}|/dt) between + * start and end does not change and is constant for the entire + * Trajectory. + * + **/ + + class BaseTrajectory { + + public: + + virtual Point getPosition(double const u) const = 0; + + virtual VelocityVector getVelocity(double const u) const = 0; + + virtual DirectionVector getDirection(double const u) const = 0; + + virtual TimeType getDuration(double const u = 1) const = 0; + + virtual LengthType getLength(double const u = 1) const = 0; + + virtual void setLength(LengthType const limit) = 0; + + virtual void setDuration(TimeType const limit) = 0; + + + }; + +} // namespace corsika diff --git a/corsika/framework/geometry/LeapFrogTrajectory.hpp b/corsika/framework/geometry/LeapFrogTrajectory.hpp index 11e3534a19ae6c8ead194077ae515afb194bbd4c..ec281e5f71d56c77602b2dd64b22d5e3e47ea8c9 100644 --- a/corsika/framework/geometry/LeapFrogTrajectory.hpp +++ b/corsika/framework/geometry/LeapFrogTrajectory.hpp @@ -12,6 +12,7 @@ #include <corsika/framework/geometry/Line.hpp> #include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/geometry/PhysicalGeometry.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { @@ -29,7 +30,7 @@ namespace corsika { * **/ - class LeapFrogTrajectory { + class LeapFrogTrajectory : public BaseTrajectory { public: LeapFrogTrajectory() = delete; diff --git a/corsika/framework/geometry/StraightTrajectory.hpp b/corsika/framework/geometry/StraightTrajectory.hpp index b05746269b017f7a80fe5c5807ca93c7afe336ab..4bed6b7f6ead06789a5712b11148f509b7eb5e9c 100644 --- a/corsika/framework/geometry/StraightTrajectory.hpp +++ b/corsika/framework/geometry/StraightTrajectory.hpp @@ -9,25 +9,14 @@ #pragma once #include <corsika/framework/core/PhysicalUnits.hpp> -#include <corsika/framework/geometry/Line.hpp> -#include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/geometry/PhysicalGeometry.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { /** * - * A Trajectory is a description of a momvement of an object in - * three-dimensional space that describes the trajectory (connection - * between two Points in space), as well as the direction of motion - * at any given point. - * - * A Trajectory has a start `0` and an end `1`, where - * e.g. getPosition(0) returns the start point and getDirection(1) - * the direction of motion at the end. Values outside 0...1 are not - * defined. - * - * A Trajectory has a length in [m], getLength, a duration in [s], getDuration. + * This implements a straight trajectory between two points. * * Note: so far it is assumed that the speed (d|vec{r}|/dt) between * start and end does not change and is constant for the entire @@ -35,7 +24,7 @@ namespace corsika { * **/ - class StraightTrajectory { + class StraightTrajectory : public BaseTrajectory { public: StraightTrajectory() = delete; diff --git a/corsika/media/BaseExponential.hpp b/corsika/media/BaseExponential.hpp index c992d7807d9f94a1a64f9a68d880ba35092b9f03..9fe436cb0cc88be8f76a3a7df2df121df7e8aa4e 100644 --- a/corsika/media/BaseExponential.hpp +++ b/corsika/media/BaseExponential.hpp @@ -12,7 +12,7 @@ #include <corsika/framework/core/PhysicalUnits.hpp> #include <corsika/framework/geometry/Line.hpp> #include <corsika/framework/geometry/Point.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> #include <limits> namespace corsika { @@ -40,7 +40,7 @@ namespace corsika { * \f] */ // clang-format on - GrammageType getIntegratedGrammage(setup::Trajectory const& line, LengthType vL, + GrammageType getIntegratedGrammage(BaseTrajectory const& line, LengthType vL, DirectionVector const& axis) const; // clang-format off @@ -61,7 +61,7 @@ namespace corsika { * \f] */ // clang-format on - LengthType getArclengthFromGrammage(setup::Trajectory const& line, + LengthType getArclengthFromGrammage(BaseTrajectory const& line, GrammageType grammage, DirectionVector const& axis) const; diff --git a/corsika/media/FlatExponential.hpp b/corsika/media/FlatExponential.hpp index a33c76496fb89d80b9a0e7a5747b6578bb5c9698..71767d705a030db91179ef70bb3441cfaf5c9d2d 100644 --- a/corsika/media/FlatExponential.hpp +++ b/corsika/media/FlatExponential.hpp @@ -13,7 +13,7 @@ #include <corsika/framework/geometry/Point.hpp> #include <corsika/media/BaseExponential.hpp> #include <corsika/media/NuclearComposition.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { @@ -41,10 +41,10 @@ namespace corsika { NuclearComposition const& getNuclearComposition() const override; - GrammageType getIntegratedGrammage(setup::Trajectory const& line, + GrammageType getIntegratedGrammage(BaseTrajectory const& line, LengthType to) const override; - LengthType getArclengthFromGrammage(setup::Trajectory const& line, + LengthType getArclengthFromGrammage(BaseTrajectory const& line, GrammageType grammage) const override; private: diff --git a/corsika/media/HomogeneousMedium.hpp b/corsika/media/HomogeneousMedium.hpp index a659be2288aef59492c9ab84922e6495c01a46d6..95a9fb0ae91ee41aa8b8f6036afbda3f105c8207 100644 --- a/corsika/media/HomogeneousMedium.hpp +++ b/corsika/media/HomogeneousMedium.hpp @@ -12,8 +12,7 @@ #include <corsika/framework/geometry/Line.hpp> #include <corsika/framework/geometry/Point.hpp> #include <corsika/media/NuclearComposition.hpp> - -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> /** * a homogeneous medium @@ -31,10 +30,10 @@ namespace corsika { NuclearComposition const& getNuclearComposition() const override; - GrammageType getIntegratedGrammage(setup::Trajectory const&, + GrammageType getIntegratedGrammage(BaseTrajectory const&, LengthType to) const override; - LengthType getArclengthFromGrammage(setup::Trajectory const&, + LengthType getArclengthFromGrammage(BaseTrajectory const&, GrammageType grammage) const override; private: diff --git a/corsika/media/IEmpty.hpp b/corsika/media/IEmpty.hpp index 1912f90fc5e09ce403ef9c4e33c163e63f96309f..ffd642fd04221be5f4939c6159a2e3105e9eea49 100644 --- a/corsika/media/IEmpty.hpp +++ b/corsika/media/IEmpty.hpp @@ -9,7 +9,7 @@ #pragma once #include <corsika/framework/core/PhysicalUnits.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { @@ -25,7 +25,8 @@ namespace corsika { class IEmpty { public: - virtual LengthType getArclengthFromGrammage(setup::Trajectory const&, + + virtual LengthType getArclengthFromGrammage(BaseTrajectory const&, GrammageType) const = 0; virtual ~IEmpty() {} @@ -34,7 +35,8 @@ namespace corsika { template <typename TModel = IEmpty> class Empty : public TModel { public: - LengthType getArclengthFromGrammage(setup::Trajectory const&, GrammageType) const { + + LengthType getArclengthFromGrammage(BaseTrajectory const&, GrammageType) const { return 0. * meter; } }; diff --git a/corsika/media/IMediumModel.hpp b/corsika/media/IMediumModel.hpp index 2dcacffbbf1cbfc80e634eea8a171e95b5bf31c6..87e702c5dba8cf7aafdbc0ac3fe0f5f9ba090e75 100644 --- a/corsika/media/IMediumModel.hpp +++ b/corsika/media/IMediumModel.hpp @@ -11,7 +11,7 @@ #include <corsika/media/NuclearComposition.hpp> #include <corsika/framework/geometry/Point.hpp> #include <corsika/framework/core/PhysicalUnits.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { @@ -23,10 +23,10 @@ namespace corsika { // todo: think about the mixin inheritance of the trajectory vs the BaseTrajectory // approach; for now, only lines are supported - virtual GrammageType getIntegratedGrammage(setup::Trajectory const&, + virtual GrammageType getIntegratedGrammage(BaseTrajectory const&, LengthType) const = 0; - virtual LengthType getArclengthFromGrammage(setup::Trajectory const&, + virtual LengthType getArclengthFromGrammage(BaseTrajectory const&, GrammageType) const = 0; virtual NuclearComposition const& getNuclearComposition() const = 0; diff --git a/corsika/media/InhomogeneousMedium.hpp b/corsika/media/InhomogeneousMedium.hpp index 7c9f664aaf589a311de7207d79a214125c8cdd15..a257bc508969c4620172b4dae45e0cf52fa06ae3 100644 --- a/corsika/media/InhomogeneousMedium.hpp +++ b/corsika/media/InhomogeneousMedium.hpp @@ -12,7 +12,7 @@ #include <corsika/framework/geometry/Line.hpp> #include <corsika/framework/geometry/Point.hpp> #include <corsika/media/NuclearComposition.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> /** * A general inhomogeneous medium. The mass density distribution TDensityFunction must be @@ -32,10 +32,10 @@ namespace corsika { NuclearComposition const& getNuclearComposition() const override; - GrammageType getIntegratedGrammage(setup::Trajectory const& line, + GrammageType getIntegratedGrammage(BaseTrajectory const& line, LengthType to) const override; - LengthType getArclengthFromGrammage(setup::Trajectory const& pLine, + LengthType getArclengthFromGrammage(BaseTrajectory const& pLine, GrammageType grammage) const override; private: diff --git a/corsika/media/LinearApproximationIntegrator.hpp b/corsika/media/LinearApproximationIntegrator.hpp index dfd9f0037476ea9d4e8dc8ed5ae3be6acccf8943..0e2eb0a295cc373c5749acb444b13a206c05622d 100644 --- a/corsika/media/LinearApproximationIntegrator.hpp +++ b/corsika/media/LinearApproximationIntegrator.hpp @@ -11,7 +11,7 @@ #include <limits> #include <corsika/framework/geometry/Line.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { @@ -20,12 +20,12 @@ namespace corsika { auto const& getImplementation() const; public: - auto getIntegrateGrammage(setup::Trajectory const& line, LengthType length) const; + auto getIntegrateGrammage(BaseTrajectory const& line, LengthType length) const; - auto getArclengthFromGrammage(setup::Trajectory const& line, + auto getArclengthFromGrammage(BaseTrajectory const& line, GrammageType grammage) const; - auto getMaximumLength(setup::Trajectory const& line, + auto getMaximumLength(BaseTrajectory const& line, [[maybe_unused]] double relError) const; }; diff --git a/corsika/media/SlidingPlanarExponential.hpp b/corsika/media/SlidingPlanarExponential.hpp index 9060dc8765abc90e05147503462f7a9b1de5afe9..a06c293a4d1056e74b40f52bb7fac7f3cf3a0070 100644 --- a/corsika/media/SlidingPlanarExponential.hpp +++ b/corsika/media/SlidingPlanarExponential.hpp @@ -15,7 +15,7 @@ #include <corsika/framework/random/RNGManager.hpp> #include <corsika/media/FlatExponential.hpp> #include <corsika/media/NuclearComposition.hpp> -#include <corsika/setup/SetupTrajectory.hpp> +#include <corsika/framework/geometry/BaseTrajectory.hpp> namespace corsika { @@ -46,10 +46,10 @@ namespace corsika { NuclearComposition const& getNuclearComposition() const override; - GrammageType getIntegratedGrammage(setup::Trajectory const& line, + GrammageType getIntegratedGrammage(BaseTrajectory const& line, LengthType l) const override; - LengthType getArclengthFromGrammage(setup::Trajectory const& line, + LengthType getArclengthFromGrammage(BaseTrajectory const& line, GrammageType grammage) const override; private: diff --git a/tests/common/SetupTestTrajectory.hpp b/tests/common/SetupTestTrajectory.hpp index 8272317193a1d1864b5c7928c22947dcc7243e2f..1bf4cd78f11be7c364328b49061e1520c8c6208c 100644 --- a/tests/common/SetupTestTrajectory.hpp +++ b/tests/common/SetupTestTrajectory.hpp @@ -43,4 +43,5 @@ namespace corsika::setup::testing { tEnd); } + } // namespace corsika::setup::testing diff --git a/tests/media/testEnvironment.cpp b/tests/media/testEnvironment.cpp index 9a5cfab0e81d99f816abfc7da29c31e4e8ebe378..b39fbb357757c28d51b6ff13b0a0f7dfceba480f 100644 --- a/tests/media/testEnvironment.cpp +++ b/tests/media/testEnvironment.cpp @@ -29,6 +29,7 @@ #include <corsika/media/VolumeTreeNode.hpp> #include <SetupTestTrajectory.hpp> +#include <corsika/setup/SetupTrajectory.hpp> #include <catch2/catch.hpp> diff --git a/tests/media/testMagneticField.cpp b/tests/media/testMagneticField.cpp index 73827dd92fbfafe5e0a697b3ce2e6f13757af5c6..b3ccf4d75c4ef8f98aff716b2be559775c3a0a3f 100644 --- a/tests/media/testMagneticField.cpp +++ b/tests/media/testMagneticField.cpp @@ -16,6 +16,7 @@ #include <corsika/media/VolumeTreeNode.hpp> #include <SetupTestTrajectory.hpp> +#include <corsika/setup/SetupTrajectory.hpp> #include <catch2/catch.hpp> diff --git a/tests/media/testMedium.cpp b/tests/media/testMedium.cpp index 709185d18524b7d5536657ffbd005bbafde9cfb9..a10348717921ded38235b69a81328c694b0b87fe 100644 --- a/tests/media/testMedium.cpp +++ b/tests/media/testMedium.cpp @@ -21,6 +21,7 @@ #include <catch2/catch.hpp> #include <SetupTestTrajectory.hpp> +#include <corsika/setup/SetupTrajectory.hpp> using namespace corsika; diff --git a/tests/media/testRefractiveIndex.cpp b/tests/media/testRefractiveIndex.cpp index 1aee5973e8dca12f3f45b743e47658ef324e5600..acef32c4f4fa5260ac841cf1db53a780f9f80900 100644 --- a/tests/media/testRefractiveIndex.cpp +++ b/tests/media/testRefractiveIndex.cpp @@ -19,6 +19,7 @@ #include <corsika/media/ExponentialRefractiveIndex.hpp> #include <SetupTestTrajectory.hpp> +#include <corsika/setup/SetupTrajectory.hpp> #include <catch2/catch.hpp> diff --git a/tests/modules/testObservationPlane.cpp b/tests/modules/testObservationPlane.cpp index fc123722d38f7b626674c6d80583be1ee9e8e401..5b603982aa2680e063cadc5b9e8ed2cf437b57d5 100644 --- a/tests/modules/testObservationPlane.cpp +++ b/tests/modules/testObservationPlane.cpp @@ -22,6 +22,7 @@ #include <SetupTestEnvironment.hpp> #include <SetupTestStack.hpp> #include <SetupTestTrajectory.hpp> +#include <corsika/setup/SetupTrajectory.hpp> using namespace corsika;