SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/Cce/Actions - InitializeCharacteristicEvolutionTime.hpp Hit Total Coverage
Commit: c3e43f8d41800b0ecefb9d1393f1de1d5a280c8f Lines: 1 8 12.5 %
Date: 2026-07-24 22:09:25
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 <optional>
       8             : #include <tuple>
       9             : #include <utility>
      10             : 
      11             : #include "DataStructures/DataBox/DataBox.hpp"
      12             : #include "DataStructures/TaggedTuple.hpp"
      13             : #include "DataStructures/VariablesTag.hpp"
      14             : #include "Evolution/Initialization/Tags.hpp"
      15             : #include "Evolution/Systems/Cce/OptionTags.hpp"
      16             : #include "Parallel/AlgorithmExecution.hpp"
      17             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      18             : #include "Time/ChooseLtsStepSize.hpp"
      19             : #include "Time/LtsMode.hpp"
      20             : #include "Time/Slab.hpp"
      21             : #include "Time/Tags/AdaptiveSteppingDiagnostics.hpp"
      22             : #include "Time/Tags/HistoryEvolvedVariables.hpp"
      23             : #include "Time/Tags/LtsMode.hpp"
      24             : #include "Time/Tags/StepNumberWithinSlab.hpp"
      25             : #include "Time/Tags/Time.hpp"
      26             : #include "Time/Tags/TimeStep.hpp"
      27             : #include "Time/Tags/TimeStepId.hpp"
      28             : #include "Time/Tags/TimeStepper.hpp"
      29             : #include "Time/Time.hpp"
      30             : #include "Time/TimeStepId.hpp"
      31             : #include "Time/TimeSteppers/LtsTimeStepper.hpp"
      32             : #include "Time/TimeSteppers/TimeStepper.hpp"
      33             : #include "Utilities/Rational.hpp"
      34             : #include "Utilities/Requires.hpp"
      35             : #include "Utilities/TMPL.hpp"
      36             : 
      37             : namespace Cce {
      38             : namespace Actions {
      39             : 
      40             : /*!
      41             :  * \ingroup ActionsGroup
      42             :  * \brief Initializes the contents of the `CharacteristicEvolution` component
      43             :  * for performing the time evolution of the system, which is the singleton that
      44             :  * handles the main evolution system for CCE computations.
      45             :  *
      46             :  * \details Sets up the \ref DataBoxGroup to be ready to perform the
      47             :  * time-stepping associated with the CCE system.
      48             :  *
      49             :  * \ref DataBoxGroup changes:
      50             :  * - Modifies: nothing
      51             :  * - Adds:
      52             :  *  - `Tags::TimeStepId`
      53             :  *  - `Tags::Next<Tags::TimeStepId>`
      54             :  *  - `Tags::TimeStep`
      55             :  *  - `Tags::Time`
      56             :  *  - `Tags::AdaptiveSteppingDiagnostics`
      57             :  * ```
      58             :  * Tags::HistoryEvolvedVariables<
      59             :  * metavariables::evolved_coordinates_variables_tag,
      60             :  * db::add_tag_prefix<Tags::dt,
      61             :  * metavariables::evolved_coordinates_variables_tag>>
      62             :  * ```
      63             :  *  -
      64             :  * ```
      65             :  * Tags::HistoryEvolvedVariables<
      66             :  * ::Tags::Variables<metavariables::evolved_swsh_tags>,
      67             :  * ::Tags::Variables<metavariables::evolved_swsh_dt_tags>>
      68             :  * ```
      69             :  * - Removes: nothing
      70             :  */
      71             : template <typename EvolvedCoordinatesVariablesTag, typename EvolvedSwshTag,
      72             :           bool local_time_stepping>
      73           1 : struct InitializeCharacteristicEvolutionTime {
      74           0 :   using simple_tags_from_options =
      75             :       tmpl::list<Initialization::Tags::InitialSlabSize<local_time_stepping>,
      76             :                  ::Initialization::Tags::InitialTimeDelta>;
      77             : 
      78           0 :   using const_global_cache_tags = tmpl::list<
      79             :       Tags::CceEvolutionPrefix<::Tags::ConcreteTimeStepper<LtsTimeStepper>>,
      80             :       Tags::CceEvolutionPrefix<::Tags::LtsModeForced<LtsMode::Conservative>>>;
      81             : 
      82           0 :   using evolved_swsh_variables_tag = ::Tags::Variables<EvolvedSwshTag>;
      83           0 :   using simple_tags = tmpl::list<
      84             :       ::Tags::TimeStepId, ::Tags::Next<::Tags::TimeStepId>, ::Tags::TimeStep,
      85             :       ::Tags::Time, ::Tags::StepNumberWithinSlab,
      86             :       ::Tags::AdaptiveSteppingDiagnostics,
      87             :       ::Tags::HistoryEvolvedVariables<EvolvedCoordinatesVariablesTag>,
      88             :       ::Tags::HistoryEvolvedVariables<evolved_swsh_variables_tag>>;
      89           0 :   using compute_tags =
      90             :       tmpl::transform<time_stepper_ref_tags<LtsTimeStepper>,
      91             :                       tmpl::bind<Tags::CceEvolutionPrefix, tmpl::_1>>;
      92             : 
      93             :   template <typename DbTags, typename... InboxTags, typename Metavariables,
      94             :             typename ArrayIndex, typename ActionList,
      95             :             typename ParallelComponent>
      96           0 :   static Parallel::iterable_action_return_t apply(
      97             :       db::DataBox<DbTags>& box,
      98             :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      99             :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
     100             :       const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
     101             :       const ParallelComponent* const /*meta*/) {
     102             :     const double initial_time_value = db::get<Tags::StartTime>(box);
     103             :     const double slab_size =
     104             :         db::get<::Initialization::Tags::InitialSlabSize<local_time_stepping>>(
     105             :             box);
     106             : 
     107             :     const Slab single_step_slab{initial_time_value,
     108             :                                 initial_time_value + slab_size};
     109             :     const Time initial_time = single_step_slab.start();
     110             :     TimeDelta initial_time_step;
     111             :     const double initial_time_delta =
     112             :         db::get<Initialization::Tags::InitialTimeDelta>(box);
     113             :     if constexpr (local_time_stepping) {
     114             :       initial_time_step =
     115             :           choose_lts_step_size(initial_time, initial_time_delta);
     116             :     } else {
     117             :       (void)initial_time_delta;
     118             :       initial_time_step = initial_time.slab().duration();
     119             :     }
     120             : 
     121             :     const auto& time_stepper =
     122             :         db::get<Tags::CceEvolutionPrefix<::Tags::TimeStepper<TimeStepper>>>(
     123             :             box);
     124             : 
     125             :     const size_t starting_order =
     126             :         visit(
     127             :             []<typename Tag>(
     128             :                 const std::pair<tmpl::type_<Tag>, typename Tag::type&&> order) {
     129             :               if constexpr (std::is_same_v<Tag,
     130             :                                            TimeSteppers::Tags::FixedOrder>) {
     131             :                 return order.second;
     132             :               } else {
     133             :                 return order.second.minimum;
     134             :               }
     135             :             },
     136             :             time_stepper.order()) -
     137             :         time_stepper.number_of_past_steps();
     138             : 
     139             :     typename ::Tags::HistoryEvolvedVariables<EvolvedCoordinatesVariablesTag>::
     140             :         type coordinate_history(starting_order);
     141             : 
     142             :     typename ::Tags::HistoryEvolvedVariables<evolved_swsh_variables_tag>::type
     143             :         swsh_history(starting_order);
     144             :     Initialization::mutate_assign<tmpl::list<
     145             :         ::Tags::TimeStepId, ::Tags::Next<::Tags::TimeStepId>, ::Tags::TimeStep,
     146             :         ::Tags::Time,
     147             :         ::Tags::HistoryEvolvedVariables<EvolvedCoordinatesVariablesTag>,
     148             :         ::Tags::HistoryEvolvedVariables<evolved_swsh_variables_tag>>>(
     149             :         make_not_null(&box), TimeStepId{},
     150             :         TimeStepId{true,
     151             :                    -static_cast<int64_t>(time_stepper.number_of_past_steps()),
     152             :                    initial_time},
     153             :         initial_time_step, initial_time_value, std::move(coordinate_history),
     154             :         std::move(swsh_history));
     155             :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
     156             :   }
     157             : };
     158             : 
     159             : }  // namespace Actions
     160             : }  // namespace Cce

Generated by: LCOV version 1.14