SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/Cce/Actions - InitializeFirstHypersurface.hpp Hit Total Coverage
Commit: aabde07399ba7837e5db64eedfd0a21f31f96922 Lines: 1 4 25.0 %
Date: 2024-04-26 02:38:13
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 "Evolution/Systems/Cce/Components/WorldtubeBoundary.hpp"
      13             : #include "Evolution/Systems/Cce/Initialize/InitializeJ.hpp"
      14             : #include "Evolution/Systems/Cce/OptionTags.hpp"
      15             : #include "Evolution/Systems/Cce/ScriPlusValues.hpp"
      16             : #include "IO/Observer/Actions/GetLockPointer.hpp"
      17             : #include "Parallel/AlgorithmExecution.hpp"
      18             : #include "Parallel/GlobalCache.hpp"
      19             : #include "Utilities/Gsl.hpp"
      20             : #include "Utilities/TMPL.hpp"
      21             : 
      22             : /// \cond
      23             : namespace Tags {
      24             : struct TimeStepId;
      25             : }  // namespace Tags
      26             : /// \endcond
      27             : 
      28             : namespace Cce {
      29             : namespace Actions {
      30             : 
      31             : /*!
      32             :  * \ingroup ActionsGroup
      33             :  * \brief Given initial boundary data for \f$J\f$ and \f$\partial_r J\f$,
      34             :  * computes the initial hypersurface quantities \f$J\f$ and gauge values.
      35             :  *
      36             :  * \details This action is to be called after boundary data has been received,
      37             :  * but before the time-stepping evolution loop. So, it should be either late in
      38             :  * an initialization phase or early (before a `Actions::Goto` loop or similar)
      39             :  * in the `Evolve` phase.
      40             :  *
      41             :  * Internally, this dispatches to the call function of
      42             :  * `Tags::InitializeJ`, which designates a hypersurface initial data generator
      43             :  * chosen by input file options, `InitializeGauge`, and
      44             :  * `InitializeScriPlusValue<Tags::InertialRetardedTime>` to perform the
      45             :  * computations. Refer to the documentation for those mutators for mathematical
      46             :  * details.
      47             :  *
      48             :  * \note This action accesses the base tag `Cce::Tags::InitializeJBase`,
      49             :  * trusting that a tag that inherits from that base tag is present in the box or
      50             :  * the global cache. Typically, this tag should be added by the worldtube
      51             :  * boundary component, as the type of initial data is decided by the type of the
      52             :  * worldtube boundary data.
      53             :  */
      54             : template <bool EvolveCcm, typename BoundaryComponent>
      55           1 : struct InitializeFirstHypersurface {
      56           0 :   using const_global_cache_tags =
      57             :       tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>;
      58             : 
      59             :   template <typename DbTags, typename... InboxTags, typename Metavariables,
      60             :             typename ArrayIndex, typename ActionList,
      61             :             typename ParallelComponent>
      62           0 :   static Parallel::iterable_action_return_t apply(
      63             :       db::DataBox<DbTags>& box,
      64             :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      65             :       Parallel::GlobalCache<Metavariables>& cache,
      66             :       const ArrayIndex& /*array_index*/, const ActionList /*meta*/,
      67             :       const ParallelComponent* const /*meta*/) {
      68             :     // In some contexts, this action may get re-run (e.g. self-start procedure)
      69             :     // In those cases, we do not want to alter the existing hypersurface data,
      70             :     // so we just exit. However, we do want to re-run the action each time
      71             :     // the self start 'reset's from the beginning
      72             :     if (db::get<::Tags::TimeStepId>(box).slab_number() > 0 or
      73             :         not db::get<::Tags::TimeStepId>(box).is_at_slab_boundary()) {
      74             :       return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      75             :     }
      76             :     // some initialization schemes need the hdf5_lock so that they can read
      77             :     // their own input data from disk.
      78             :     auto hdf5_lock = Parallel::local_branch(
      79             :                          Parallel::get_parallel_component<
      80             :                              observers::ObserverWriter<Metavariables>>(cache))
      81             :                          ->template local_synchronous_action<
      82             :                              observers::Actions::GetLockPointer<
      83             :                                  observers::Tags::H5FileLock>>();
      84             :     if constexpr (tt::is_a_v<AnalyticWorldtubeBoundary, BoundaryComponent>) {
      85             :       db::mutate_apply<typename InitializeJ::InitializeJ<false>::mutate_tags,
      86             :                        typename InitializeJ::InitializeJ<false>::argument_tags>(
      87             :           db::get<Tags::InitializeJBase>(box), make_not_null(&box),
      88             :           make_not_null(hdf5_lock));
      89             :     } else {
      90             :       db::mutate_apply<
      91             :           typename InitializeJ::InitializeJ<EvolveCcm>::mutate_tags,
      92             :           typename InitializeJ::InitializeJ<EvolveCcm>::argument_tags>(
      93             :           db::get<Tags::InitializeJBase>(box), make_not_null(&box),
      94             :           make_not_null(hdf5_lock));
      95             :     }
      96             :     db::mutate_apply<InitializeScriPlusValue<Tags::InertialRetardedTime>>(
      97             :         make_not_null(&box), db::get<::Tags::TimeStepId>(box).substep_time());
      98             :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      99             :   }
     100             : };
     101             : }  // namespace Actions
     102             : }  // namespace Cce

Generated by: LCOV version 1.14