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

Generated by: LCOV version 1.14