SpECTRE Documentation Coverage Report
Current view: top level - Time - Tags.hpp Hit Total Coverage
Commit: 2ae2b99409ac582030d56a4560a92a3e066a7e54 Lines: 17 64 26.6 %
Date: 2022-01-15 08:40:38
Legend: Lines: hit not hit

          Line data    Source code
       1           1 : // Distributed under the MIT License.
       2             : // See LICENSE.txt for details.
       3             : 
       4             : /// \file
       5             : /// Defines tags related to Time quantities
       6             : 
       7             : #pragma once
       8             : 
       9             : #include <cstddef>
      10             : #include <memory>
      11             : #include <string>
      12             : #include <vector>
      13             : 
      14             : #include "DataStructures/DataBox/PrefixHelpers.hpp"
      15             : #include "DataStructures/DataBox/Prefixes.hpp"
      16             : #include "DataStructures/DataBox/Tag.hpp"
      17             : #include "Evolution/Tags.hpp"
      18             : #include "Options/Options.hpp"
      19             : #include "Parallel/Serialize.hpp"
      20             : #include "Time/BoundaryHistory.hpp"
      21             : #include "Time/History.hpp"
      22             : #include "Time/StepChoosers/StepChooser.hpp"        // IWYU pragma: keep
      23             : #include "Time/StepControllers/StepController.hpp"  // IWYU pragma: keep
      24             : #include "Time/Time.hpp"
      25             : #include "Time/TimeStepId.hpp"
      26             : #include "Utilities/TMPL.hpp"
      27             : 
      28             : namespace Tags {
      29             : 
      30             : /// \ingroup DataBoxTagsGroup
      31             : /// \ingroup TimeGroup
      32             : /// \brief Tag for ::TimeStepId for the algorithm state
      33           1 : struct TimeStepId : db::SimpleTag {
      34           0 :   using type = ::TimeStepId;
      35             :   template <typename Tag>
      36           0 :   using step_prefix = typename Tags::dt<Tag>;
      37             : };
      38             : 
      39             : /// \ingroup DataBoxTagsGroup
      40             : /// \ingroup TimeGroup
      41             : /// \brief Tag for step size
      42           1 : struct TimeStep : db::SimpleTag {
      43           0 :   using type = ::TimeDelta;
      44             : };
      45             : 
      46             : /// \ingroup DataBoxTagsGroup
      47             : /// \ingroup TimeGroup
      48             : /// \brief Tag for ::Time of the current substep
      49             : ///
      50             : /// \see SubstepTimeCompute
      51           1 : struct SubstepTime : db::SimpleTag {
      52           0 :   using type = ::Time;
      53             : };
      54             : 
      55             : /// \ingroup DataBoxTagsGroup
      56             : /// \ingroup TimeGroup
      57             : /// \brief Tag for computing the substep time from (from `Tags::TimeStepId`)
      58             : ///
      59             : /// \see SubstepTime
      60           1 : struct SubstepTimeCompute : SubstepTime, db::ComputeTag {
      61           0 :   using base = SubstepTime;
      62           0 :   using return_type = typename base::type;
      63           0 :   static void function(const gsl::not_null<return_type*> substep_time,
      64             :                        const ::TimeStepId& id) {
      65             :     *substep_time = id.substep_time();
      66             :   }
      67           0 :   using argument_tags = tmpl::list<TimeStepId>;
      68             : };
      69             : 
      70             : /// \ingroup DataBoxTagsGroup
      71             : /// \ingroup TimeGroup
      72             : /// \brief Tag for the current time as a double
      73           1 : struct Time : db::SimpleTag {
      74           0 :   using type = double;
      75             : };
      76             : 
      77             : /// \ingroup DataBoxTagsGroup
      78             : /// \ingroup TimeGroup
      79             : /// Tag for the TimeStepper history
      80             : ///
      81             : /// Leaving the template parameter unspecified gives a base tag.
      82             : ///
      83             : /// \tparam Tag tag for the variables
      84             : template <typename Tag = void>
      85           1 : struct HistoryEvolvedVariables;
      86             : 
      87             : /// \cond
      88             : template <>
      89             : struct HistoryEvolvedVariables<> : db::BaseTag {};
      90             : 
      91             : template <typename TagsList>
      92             : struct HistoryEvolvedVariables<::Tags::Variables<TagsList>>
      93             :     : HistoryEvolvedVariables<>, db::SimpleTag {
      94             :   using type =
      95             :       TimeSteppers::History<::Variables<TagsList>,
      96             :                             ::Variables<db::wrap_tags_in<Tags::dt, TagsList>>>;
      97             : };
      98             : 
      99             : template <typename Tag>
     100             : struct HistoryEvolvedVariables : HistoryEvolvedVariables<>, db::SimpleTag {
     101             :   using type =
     102             :       TimeSteppers::History<typename Tag::type, typename Tags::dt<Tag>::type>;
     103             : };
     104             : /// \endcond
     105             : 
     106             : /// \ingroup TimeGroup
     107             : /// From a list of tags `TagList`, extract all tags that are template
     108             : /// specializations of `HistoryEvolvedVariables`.
     109             : template <typename TagList>
     110           1 : using get_all_history_tags =
     111             :     tmpl::filter<TagList,
     112             :                  tt::is_a_lambda<::Tags::HistoryEvolvedVariables, tmpl::_1>>;
     113             : 
     114             : /// \ingroup DataBoxTagsGroup
     115             : /// \ingroup TimeGroup
     116             : /// \brief Tag for the stepper error measure.
     117             : template <typename Tag>
     118           1 : struct StepperError : db::PrefixTag, db::SimpleTag {
     119           0 :   static std::string name() {
     120             :     return "StepperError(" + db::tag_name<Tag>() + ")";
     121             :   }
     122           0 :   using type = typename Tag::type;
     123           0 :   using tag = Tag;
     124             : };
     125             : 
     126             : /// \ingroup TimeGroup
     127             : /// \brief Tag indicating whether the stepper error has been updated on the
     128             : /// current step
     129           1 : struct StepperErrorUpdated : db::SimpleTag {
     130           0 :   using type = bool;
     131             : };
     132             : 
     133             : /// \ingroup DataBoxTagsGroup
     134             : /// \ingroup TimeGroup
     135             : /// Tag for TimeStepper boundary history
     136             : template <typename LocalVars, typename RemoteVars, typename CouplingResult>
     137           1 : struct BoundaryHistory : db::SimpleTag {
     138           0 :   using type =
     139             :       TimeSteppers::BoundaryHistory<LocalVars, RemoteVars, CouplingResult>;
     140             : };
     141             : 
     142             : }  // namespace Tags
     143             : 
     144             : namespace OptionTags {
     145             : 
     146             : /// \ingroup OptionTagsGroup
     147             : /// \ingroup TimeGroup
     148             : template <typename StepperType>
     149           0 : struct TimeStepper {
     150           0 :   static std::string name() { return "TimeStepper"; }
     151           0 :   static constexpr Options::String help{"The time stepper"};
     152           0 :   using type = std::unique_ptr<StepperType>;
     153           0 :   using group = evolution::OptionTags::Group;
     154             : };
     155             : 
     156             : /// \ingroup OptionTagsGroup
     157             : /// \ingroup TimeGroup
     158           0 : struct StepChoosers {
     159           0 :   static constexpr Options::String help{"Limits on LTS step size"};
     160           0 :   using type =
     161             :       std::vector<std::unique_ptr<::StepChooser<StepChooserUse::LtsStep>>>;
     162           0 :   static size_t lower_bound_on_size() { return 1; }
     163           0 :   using group = evolution::OptionTags::Group;
     164             : };
     165             : 
     166             : /// \ingroup OptionTagsGroup
     167             : /// \ingroup TimeGroup
     168           0 : struct StepController {
     169           0 :   static constexpr Options::String help{"The LTS step controller"};
     170           0 :   using type = std::unique_ptr<::StepController>;
     171           0 :   using group = evolution::OptionTags::Group;
     172             : };
     173             : 
     174             : /// \ingroup OptionTagsGroup
     175             : /// \ingroup TimeGroup
     176             : /// \brief The time at which to start the simulation
     177           1 : struct InitialTime {
     178           0 :   using type = double;
     179           0 :   static constexpr Options::String help = {
     180             :       "The time at which the evolution is started."};
     181           0 :   static type suggested_value() { return 0.0; }
     182           0 :   using group = evolution::OptionTags::Group;
     183             : };
     184             : 
     185             : /// \ingroup OptionTagsGroup
     186             : /// \ingroup TimeGroup
     187             : /// \brief The initial time step taken by the time stepper. This may be
     188             : /// overridden by an adaptive stepper
     189           1 : struct InitialTimeStep {
     190           0 :   using type = double;
     191           0 :   static constexpr Options::String help =
     192             :       "The initial time step, before local stepping adjustment";
     193           0 :   using group = evolution::OptionTags::Group;
     194             : };
     195             : 
     196             : /// \ingroup OptionTagsGroup
     197             : /// \ingroup TimeGroup
     198             : /// \brief The initial slab size
     199           1 : struct InitialSlabSize {
     200           0 :   using type = double;
     201           0 :   static constexpr Options::String help = "The initial slab size";
     202           0 :   static type lower_bound() { return 0.; }
     203           0 :   using group = evolution::OptionTags::Group;
     204             : };
     205             : }  // namespace OptionTags
     206             : 
     207             : namespace Tags {
     208             : /// \ingroup DataBoxTagsGroup
     209             : /// \ingroup TimeGroup
     210             : /// \brief Tag for a ::TimeStepper of type `StepperType`.
     211             : ///
     212             : /// Leaving the template parameter unspecified gives a base tag.
     213             : template <typename StepperType = void>
     214           1 : struct TimeStepper;
     215             : 
     216             : /// \cond
     217             : template <>
     218             : struct TimeStepper<> : db::BaseTag {};
     219             : 
     220             : template <typename StepperType>
     221             : struct TimeStepper : TimeStepper<>, db::SimpleTag {
     222             :   using type = std::unique_ptr<StepperType>;
     223             :   using option_tags = tmpl::list<::OptionTags::TimeStepper<StepperType>>;
     224             : 
     225             :   static constexpr bool pass_metavariables = false;
     226             :   static std::unique_ptr<StepperType> create_from_options(
     227             :       const std::unique_ptr<StepperType>& time_stepper) {
     228             :     return deserialize<type>(serialize<type>(time_stepper).data());
     229             :   }
     230             : };
     231             : /// \endcond
     232             : 
     233             : /// \ingroup DataBoxTagsGroup
     234             : /// \ingroup TimeGroup
     235             : /// \brief Tag for a vector of ::StepChooser%s
     236           1 : struct StepChoosers : db::SimpleTag {
     237           0 :   using type =
     238             :       std::vector<std::unique_ptr<::StepChooser<StepChooserUse::LtsStep>>>;
     239           0 :   using option_tags = tmpl::list<::OptionTags::StepChoosers>;
     240             : 
     241           0 :   static constexpr bool pass_metavariables = false;
     242           0 :   static type create_from_options(const type& step_choosers) {
     243             :     return deserialize<type>(serialize<type>(step_choosers).data());
     244             :   }
     245             : };
     246             : 
     247             : /// \ingroup DataBoxTagsGroup
     248             : /// \ingroup TimeGroup
     249             : /// \brief Tag for a ::StepController
     250           1 : struct StepController : db::SimpleTag {
     251           0 :   using type = std::unique_ptr<::StepController>;
     252           0 :   using option_tags = tmpl::list<::OptionTags::StepController>;
     253             : 
     254           0 :   static constexpr bool pass_metavariables = false;
     255           0 :   static std::unique_ptr<::StepController> create_from_options(
     256             :       const std::unique_ptr<::StepController>& step_controller) {
     257             :     return deserialize<type>(serialize<type>(step_controller).data());
     258             :   }
     259             : };
     260             : }  // namespace Tags

Generated by: LCOV version 1.14