diff --git a/Documentation/Examples/cascade_example.cc b/Documentation/Examples/cascade_example.cc index 34b55476d9a4f869bd9a29c51688d0f49e680c37..5caff6b799fae41ec263c4646127f86df3233d3f 100644 --- a/Documentation/Examples/cascade_example.cc +++ b/Documentation/Examples/cascade_example.cc @@ -17,6 +17,8 @@ #include <corsika/setup/SetupStack.h> #include <corsika/setup/SetupTrajectory.h> +#include <corsika/environment/Environment.h> + #include <corsika/random/RNGManager.h> #include <corsika/cascade/SibStack.h> @@ -24,14 +26,18 @@ #include <corsika/process/sibyll/ParticleConversion.h> #include <corsika/units/PhysicalUnits.h> + +#include <iostream> +#include <typeinfo> + using namespace corsika; using namespace corsika::process; using namespace corsika::units; using namespace corsika::particles; using namespace corsika::random; +using namespace corsika::geometry; +using namespace corsika::environment; -#include <iostream> -#include <typeinfo> using namespace std; static int fCount = 0; @@ -236,9 +242,12 @@ double s_rndm_(int&) { return rmng() / (double)rmng.max(); } -int main() { - - tracking_line::TrackingLine<setup::Stack> tracking; +int main() { + Environment env; + + auto theMedium = env.GetUniverse()::CreateNode<Sphere>({Point{env.GetCS(), 0_m, 0_m, 0_m}, 100_km}); + + tracking_line::TrackingLine<setup::Stack> tracking(environment); stack_inspector::StackInspector<setup::Stack> p0(true); ProcessSplit p1; const auto sequence = p0 + p1; diff --git a/Environment/CMakeLists.txt b/Environment/CMakeLists.txt index c69ef36554cf8209b9f186200be47f26c8dd3e68..420fc20f087d0cb8ba3ab884f4ae0db7efc8c469 100644 --- a/Environment/CMakeLists.txt +++ b/Environment/CMakeLists.txt @@ -4,6 +4,7 @@ set ( IMediumModel.h NuclearComposition.h HomogeneousMedium.h + Environment.h ) set ( diff --git a/Environment/Environment.h b/Environment/Environment.h new file mode 100644 index 0000000000000000000000000000000000000000..3c20ba22a5040c2f3916995fb18a0d01c0a8b435 --- /dev/null +++ b/Environment/Environment.h @@ -0,0 +1,32 @@ +/** + * (c) Copyright 2018 CORSIKA Project, corsika-project@lists.kit.edu + * + * See file AUTHORS for a list of contributors. + * + * 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. + */ + +#ifndef _include_Environment_h +#define _include_Environment_h + +#include <corsika/environment/IMediumModel.h> +#include <corsika/environment/VolumeTreeNode.h> +#include <corsika/geometry/RootCoordinateSystem.h> +#include <corsika/setup/SetupEnvironment.h> + +namespace corsika::environment { + + class Environment { + public: + auto& GetUniverse() { return universe; } + auto const& GetCS() const { return corsika::geometry::RootCoordinateSystem::GetInstance().GetRootCS();} + + private: + VolumeTreeNode<corsika::setup::IEnvironmentModel>::VTNUPtr universe; + }; + +} // namespace corsika::environment + +#endif diff --git a/Environment/HomogeneousMedium.h b/Environment/HomogeneousMedium.h index dcb9a464206db8ff83294099b3aaae8fb6812711..bea6cd6181066697636bacd4ca34abec5391bda2 100644 --- a/Environment/HomogeneousMedium.h +++ b/Environment/HomogeneousMedium.h @@ -12,11 +12,11 @@ #define _include_HomogeneousMedium_h_ #include <corsika/environment/NuclearComposition.h> -#include <corsika/particles/ParticleProperties.h> -#include <corsika/units/PhysicalUnits.h> -#include <corsika/geometry/Trajectory.h> #include <corsika/geometry/Line.h> #include <corsika/geometry/Point.h> +#include <corsika/geometry/Trajectory.h> +#include <corsika/particles/ParticleProperties.h> +#include <corsika/units/PhysicalUnits.h> /** * a homogeneous medium diff --git a/Environment/IMediumModel.h b/Environment/IMediumModel.h index 74fc5161f8c397f1d4e1e9144b46eaa817db6495..a809508315621b652d502a38bbb04a05cd5ced9e 100644 --- a/Environment/IMediumModel.h +++ b/Environment/IMediumModel.h @@ -2,8 +2,8 @@ #define _include_IMediumModel_h #include <corsika/environment/NuclearComposition.h> -#include <corsika/geometry/Trajectory.h> #include <corsika/geometry/Point.h> +#include <corsika/geometry/Trajectory.h> #include <corsika/units/PhysicalUnits.h> namespace corsika::environment { @@ -14,16 +14,17 @@ namespace corsika::environment { virtual corsika::units::si::MassDensityType GetMassDensity( corsika::geometry::Point const&) const = 0; - - // todo: think about the mixin inheritance of the trajectory vs the BaseTrajectory approach - // for now, only lines are supported + + // todo: think about the mixin inheritance of the trajectory vs the BaseTrajectory + // approach for now, only lines are supported virtual corsika::units::si::GrammageType IntegratedGrammage( - corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::TimeType) const = 0; - + corsika::geometry::Trajectory<corsika::geometry::Line> const&, + corsika::units::si::TimeType) const = 0; + virtual corsika::units::si::TimeType FromGrammage( corsika::geometry::Trajectory<corsika::geometry::Line> const&, corsika::units::si::GrammageType) const = 0; - + virtual NuclearComposition const& GetNuclearComposition() const = 0; }; diff --git a/Environment/VolumeTreeNode.h b/Environment/VolumeTreeNode.h index 7bf7b87dc26d3897f927f89b45964ef399e7d2f4..523aebcd265bc455e32b82e202a03630d3323bfe 100644 --- a/Environment/VolumeTreeNode.h +++ b/Environment/VolumeTreeNode.h @@ -88,7 +88,8 @@ namespace corsika::environment { static_assert(std::is_base_of_v<IModelProperties, ModelProperties>, "unusable type provided"); - fModelProperties = std::make_unique<ModelProperties>(std::forward<Args>(args)...); + fModelProperties = std::make_shared<ModelProperties>(std::forward<Args>(args)...); + return fModelProperties; } void SetModelProperties(IMPSharedPtr ptr) { fModelProperties = ptr; } @@ -101,7 +102,7 @@ namespace corsika::environment { return std::make_shared<MediumType>(std::forward<Args>(args)...); } - // factory methods for creation of nodes + // factory method for creation of nodes template <class VolumeType, typename... Args> static auto CreateNode(Args&&... args) { static_assert(std::is_base_of_v<corsika::geometry::Volume, VolumeType>, diff --git a/Setup/SetupEnvironment.h b/Setup/SetupEnvironment.h index 1beb2748052770fc25b84991fdf3e651744c3dc8..e822b64ec0dd4b393fd7285360c96879ce2ccc0f 100644 --- a/Setup/SetupEnvironment.h +++ b/Setup/SetupEnvironment.h @@ -12,6 +12,10 @@ #ifndef _include_corsika_setup_environment_h_ #define _include_corsika_setup_environment_h_ -namespace corsika {} +#include <corsika/environment/IMediumModel.h> + +namespace corsika::setup { + using IEnvironmentModel = corsika::environment::IMediumModel; +} #endif