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 : template <bool EvolveCcm, typename BoundaryComponent> 49 1 : struct InitializeFirstHypersurface { 50 0 : using const_global_cache_tags = 51 : tmpl::list<Tags::LMax, Tags::NumberOfRadialPoints>; 52 : 53 : template <typename DbTags, typename... InboxTags, typename Metavariables, 54 : typename ArrayIndex, typename ActionList, 55 : typename ParallelComponent> 56 0 : static Parallel::iterable_action_return_t apply( 57 : db::DataBox<DbTags>& box, 58 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/, 59 : Parallel::GlobalCache<Metavariables>& cache, 60 : const ArrayIndex& /*array_index*/, const ActionList /*meta*/, 61 : const ParallelComponent* const /*meta*/) { 62 : // In some contexts, this action may get re-run (e.g. self-start procedure) 63 : // In those cases, we do not want to alter the existing hypersurface data, 64 : // so we just exit. However, we do want to re-run the action each time 65 : // the self start 'reset's from the beginning 66 : if (db::get<::Tags::TimeStepId>(box).slab_number() > 0 or 67 : not db::get<::Tags::TimeStepId>(box).is_at_slab_boundary()) { 68 : return {Parallel::AlgorithmExecution::Continue, std::nullopt}; 69 : } 70 : // some initialization schemes need the hdf5_lock so that they can read 71 : // their own input data from disk. 72 : auto hdf5_lock = Parallel::local_branch( 73 : Parallel::get_parallel_component< 74 : observers::ObserverWriter<Metavariables>>(cache)) 75 : ->template local_synchronous_action< 76 : observers::Actions::GetLockPointer< 77 : observers::Tags::H5FileLock>>(); 78 : if constexpr (tt::is_a_v<AnalyticWorldtubeBoundary, BoundaryComponent>) { 79 : db::mutate_apply<typename InitializeJ::InitializeJ<false>::mutate_tags, 80 : typename InitializeJ::InitializeJ<false>::argument_tags>( 81 : db::get<Tags::InitializeJ<false>>(box), make_not_null(&box), 82 : make_not_null(hdf5_lock)); 83 : } else { 84 : db::mutate_apply< 85 : typename InitializeJ::InitializeJ<EvolveCcm>::mutate_tags, 86 : typename InitializeJ::InitializeJ<EvolveCcm>::argument_tags>( 87 : db::get<Tags::InitializeJ<EvolveCcm>>(box), make_not_null(&box), 88 : make_not_null(hdf5_lock)); 89 : } 90 : db::mutate_apply<InitializeScriPlusValue<Tags::InertialRetardedTime>>( 91 : make_not_null(&box), db::get<::Tags::TimeStepId>(box).substep_time()); 92 : return {Parallel::AlgorithmExecution::Continue, std::nullopt}; 93 : } 94 : }; 95 : } // namespace Actions 96 : } // namespace Cce