CORSIKA  @c8_version@
The framework to simulate particle cascades for astroparticle physics
LayeredSphericalAtmosphereBuilder.hpp
1 /*
2  * (c) Copyright 2020 CORSIKA Project, corsika-project@lists.kit.edu
3  *
4  * This software is distributed under the terms of the GNU General Public
5  * Licence version 3 (GPL Version 3). See file LICENSE for a full version of
6  * the license.
7  */
8 
9 #pragma once
10 
12 #include <corsika/framework/geometry/Point.hpp>
13 #include <corsika/media/Environment.hpp>
14 #include <corsika/media/IMediumModel.hpp>
15 #include <corsika/media/NuclearComposition.hpp>
16 #include <corsika/media/VolumeTreeNode.hpp>
17 
18 // for detail namespace, NoExtraModelInner, NoExtraModel and traits
19 #include <corsika/detail/media/LayeredSphericalAtmosphereBuilder.hpp>
20 
21 #include <memory>
22 #include <stack>
23 #include <tuple>
24 #include <type_traits>
25 #include <functional>
26 
31 namespace corsika {
32 
43  template <typename TMediumInterface = IMediumModel,
44  template <typename> typename MExtraEnvirnoment = detail::NoExtraModel>
46 
58  template <typename TMediumInterface = IMediumModel,
59  template <typename> typename TMediumModelExtra = detail::NoExtraModel,
60  typename... TModelArgs>
62 
67  const LayeredSphericalAtmosphereBuilder&) = delete;
68 
69  // friend, to allow construction
70  template <typename, template <typename> typename>
72 
73  protected:
74  LayeredSphericalAtmosphereBuilder(TModelArgs... args, Point const& center,
75  LengthType const planetRadius)
76  : center_(center)
77  , planetRadius_(planetRadius)
78  , additionalModelArgs_{args...} {}
79 
80  public:
82  typedef typename VolumeTreeNode<TMediumInterface>::VTNUPtr volume_tree_node_uptr;
83 
84  void setNuclearComposition(NuclearComposition const& composition);
85  volume_tree_node* addExponentialLayer(GrammageType const b,
86  LengthType const scaleHeight,
87  LengthType const upperBoundary);
88  void addLinearLayer(GrammageType const b, LengthType const scaleHeight,
89  LengthType const upperBoundary);
90 
91  void addTabularLayer(std::function<MassDensityType(LengthType)> const& funcRho,
92  unsigned int const nBins, LengthType const deltaHeight,
93  LengthType const upperBoundary);
94 
95  int getSize() const { return layers_.size(); }
96 
97  void assemble(Environment<TMediumInterface>& env);
99 
103  LengthType getPlanetRadius() const { return planetRadius_; }
104 
105  private:
106  void checkRadius(LengthType const r) const;
107 
108  std::unique_ptr<NuclearComposition> composition_;
109  Point center_;
110  LengthType previousRadius_{LengthType::zero()};
111  LengthType planetRadius_;
112  std::tuple<TModelArgs...> const additionalModelArgs_;
113 
114  std::stack<volume_tree_node_uptr> layers_; // innermost layer first
115 
116  }; // end class LayeredSphericalAtmosphereBuilder
117 
118 } // namespace corsika
119 
120 #include <corsika/detail/media/LayeredSphericalAtmosphereBuilder.inl>
LengthType getPlanetRadius() const
Get the current planet radius.
Import and extend the phys::units package.
Helper class to setup concentric spheres of layered atmosphere with spcified density profiles (expone...
`, since they are used everywhere as integral part of the framework.
static constexpr quantity zero()
We need a "zero" of each type – for comparisons, to initialize running totals, etc.
Definition: quantity.hpp:359
Describes the composition of matter Allowes and handles the creation of custom matter compositions...
Base Environment class.
Definition: Environment.hpp:29