SpECTRE Documentation Coverage Report
Current view: top level - Domain/Creators/TimeDependence - Composition.hpp Hit Total Coverage
Commit: 2ae2b99409ac582030d56a4560a92a3e066a7e54 Lines: 7 27 25.9 %
Date: 2022-01-15 08:40:38
Legend: Lines: hit not hit

          Line data    Source code
       1           0 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : #pragma once
       5             : 
       6             : #include <cstddef>
       7             : #include <limits>
       8             : #include <memory>
       9             : #include <string>
      10             : #include <type_traits>
      11             : #include <unordered_map>
      12             : #include <vector>
      13             : 
      14             : #include "Domain/CoordinateMaps/CoordinateMap.hpp"
      15             : #include "Domain/Creators/TimeDependence/GenerateCoordinateMap.hpp"
      16             : #include "Domain/Creators/TimeDependence/TimeDependence.hpp"
      17             : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
      18             : #include "Options/Options.hpp"
      19             : #include "Utilities/PrettyType.hpp"
      20             : #include "Utilities/TMPL.hpp"
      21             : 
      22             : namespace domain {
      23             : namespace creators {
      24           1 : namespace time_dependence {
      25             : /*!
      26             :  * \brief A tag used by the `Composition` class to generate a TimeDependence
      27             :  * that is a composition of existing `TimeDependences`.
      28             :  *
      29             :  * The first template parameter is the existing TimeDependence.
      30             :  */
      31             : template <typename TimeDep>
      32           1 : struct TimeDependenceCompositionTag {
      33           0 :   static constexpr size_t mesh_dim = TimeDep::mesh_dim;
      34           0 :   static std::string name() { return Options::name<TimeDep>(); }
      35           0 :   using type = TimeDep;
      36           0 :   static constexpr Options::String help = {
      37             :       "One of the maps in the composition."};
      38           0 :   using time_dependence = TimeDep;
      39             : };
      40             : 
      41             : /*!
      42             :  * \brief A TimeDependence that is a composition of various other
      43             :  * TimeDependences.
      44             :  *
      45             :  * To create a new Composition TimeDependence you must create an explicit
      46             :  * instantiation of the `Composition<Tags...>` TimeDependence in a `.cpp` file.
      47             :  * You must add the `Composition` to the `creatable_classes` list of
      48             :  * `TimeDependence` in order for the new Composition to be factory creatable.
      49             :  *
      50             :  * The tags in the template parameters must be `TimeDependenceCompositionTag`s.
      51             :  * See the documentation of the `TimeDependenceCompositionTag` class for details
      52             :  * on the tags.
      53             :  */
      54             : template <typename TimeDependenceCompTag0, typename... TimeDependenceCompTags>
      55           1 : class Composition final
      56             :     : public TimeDependence<TimeDependenceCompTag0::mesh_dim> {
      57             :  public:
      58           0 :   using CoordMap = detail::generate_coordinate_map_t<tmpl::flatten<
      59             :       tmpl::list<typename TimeDependenceCompTag0::time_dependence::
      60             :                      MapForComposition::maps_list,
      61             :                  typename TimeDependenceCompTags::time_dependence::
      62             :                      MapForComposition::maps_list...>>>;
      63           0 :   using maps_list = tmpl::list<CoordMap>;
      64           0 :   static constexpr Options::String help = {"A composition of TimeDependences."};
      65             : 
      66           0 :   static constexpr size_t mesh_dim = TimeDependenceCompTag0::mesh_dim;
      67             : 
      68             :   static_assert(
      69             :       tmpl::all<
      70             :           tmpl::integral_list<size_t, TimeDependenceCompTags::mesh_dim...>,
      71             :           std::is_same<tmpl::integral_constant<size_t, mesh_dim>,
      72             :                        tmpl::_1>>::value,
      73             :       "All TimeDependences passed to Composition must be of the same "
      74             :       "dimensionality.");
      75             : 
      76           0 :   using options = tmpl::list<TimeDependenceCompTag0, TimeDependenceCompTags...>;
      77             : 
      78           0 :   Composition() = default;
      79           0 :   ~Composition() override = default;
      80           0 :   Composition(const Composition&) = default;
      81           0 :   Composition& operator=(const Composition&) = default;
      82           0 :   Composition(Composition&&) = default;
      83           0 :   Composition& operator=(Composition&&) = default;
      84             : 
      85           0 :   explicit Composition(
      86             :       tmpl::type_from<TimeDependenceCompTag0> first_time_dep,
      87             :       tmpl::type_from<TimeDependenceCompTags>... rest_time_dep);
      88             : 
      89             :   // static_assert above guarantees that all the TimeDependences have the same
      90             :   // dimension so this is ok
      91             :   /// Constructor for copying the composition time dependence.
      92           1 :   Composition(
      93             :       CoordMap coord_map,
      94             :       const std::vector<
      95             :           std::unique_ptr<TimeDependence<TimeDependenceCompTag0::mesh_dim>>>&
      96             :           time_deps);
      97             : 
      98           1 :   auto get_clone() const -> std::unique_ptr<TimeDependence<mesh_dim>> override;
      99             : 
     100           1 :   auto block_maps(size_t number_of_blocks) const
     101             :       -> std::vector<std::unique_ptr<domain::CoordinateMapBase<
     102             :           Frame::Grid, Frame::Inertial, mesh_dim>>> override;
     103             : 
     104           1 :   auto functions_of_time(const std::unordered_map<std::string, double>&
     105             :                              initial_expiration_times = {}) const
     106             :       -> std::unordered_map<
     107             :           std::string,
     108             :           std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>> override;
     109             : 
     110             :  private:
     111           0 :   CoordMap coord_map_;
     112             : 
     113             :   // static_assert above guarantees that all the TimeDependences have the same
     114             :   // dimension so this is ok
     115             :   std::vector<std::unique_ptr<TimeDependence<TimeDependenceCompTag0::mesh_dim>>>
     116           0 :       time_deps_{};
     117             : };
     118             : }  // namespace time_dependence
     119             : }  // namespace creators
     120             : }  // namespace domain

Generated by: LCOV version 1.14