From b25342dd9c20e4de4246646598f62013607e2d23 Mon Sep 17 00:00:00 2001 From: Remy Prechelt <prechelt@hawaii.edu> Date: Tue, 18 May 2021 10:29:20 -1000 Subject: [PATCH] Remove Setup from media and switch to BaseTrajectory. --- corsika/detail/media/BaseExponential.inl | 4 +- corsika/detail/media/FlatExponential.inl | 4 +- corsika/detail/media/HomogeneousMedium.inl | 4 +- corsika/detail/media/InhomogeneousMedium.inl | 4 +- .../media/LinearApproximationIntegrator.inl | 6 +- .../detail/media/SlidingPlanarExponential.inl | 4 +- corsika/framework/geometry/BaseTrajectory.hpp | 57 +++++++++++++++++++ .../framework/geometry/LeapFrogTrajectory.hpp | 3 +- .../framework/geometry/StraightTrajectory.hpp | 17 +----- corsika/media/BaseExponential.hpp | 6 +- corsika/media/FlatExponential.hpp | 6 +- corsika/media/HomogeneousMedium.hpp | 7 +-- corsika/media/IEmpty.hpp | 8 ++- corsika/media/IMediumModel.hpp | 6 +- corsika/media/InhomogeneousMedium.hpp | 6 +- .../media/LinearApproximationIntegrator.hpp | 8 +-- corsika/media/SlidingPlanarExponential.hpp | 6 +- tests/common/SetupTestTrajectory.hpp | 1 + tests/media/testEnvironment.cpp | 1 + tests/media/testMagneticField.cpp | 1 + tests/media/testMedium.cpp | 1 + tests/media/testRefractiveIndex.cpp | 1 + tests/modules/testObservationPlane.cpp | 1 + 23 files changed, 108 insertions(+), 54 deletions(-) create mode 100644 corsika/framework/geometry/BaseTrajectory.hpp diff --git a/corsika/detail/media/BaseExponential.inl b/corsika/detail/media/BaseExponential.inl index a40981bef..3d7790c29 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 cdada02df..b64b2ded2 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 fd0148b02..94fb90cd4 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 48d1d266e..8706765ad 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 78b7733ed..ced2dee38 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 56d99404c..61911772a 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 000000000..433df38db --- /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 11e3534a1..ec281e5f7 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 b05746269..4bed6b7f6 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 c992d7807..9fe436cb0 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 a33c76496..71767d705 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 a659be228..95a9fb0ae 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 1912f90fc..ffd642fd0 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 2dcacffbb..87e702c5d 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 7c9f664aa..a257bc508 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 dfd9f0037..0e2eb0a29 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 9060dc876..a06c293a4 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 827231719..1bf4cd78f 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 9a5cfab0e..b39fbb357 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 73827dd92..b3ccf4d75 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 709185d18..a10348717 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 1aee5973e..acef32c4f 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 fc123722d..5b603982a 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; -- GitLab