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> // IWYU pragma: keep // for move 10 : 11 : #include "DataStructures/DataBox/DataBox.hpp" 12 : #include "Evolution/Initialization/InitialData.hpp" 13 : #include "Parallel/AlgorithmExecution.hpp" 14 : #include "Parallel/GlobalCache.hpp" 15 : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp" 16 : #include "Utilities/Gsl.hpp" 17 : #include "Utilities/TMPL.hpp" 18 : #include "Utilities/TaggedTuple.hpp" 19 : 20 : /// \cond 21 : namespace Frame { 22 : struct Inertial; 23 : } // namespace Frame 24 : namespace Tags { 25 : struct AnalyticSolutionOrData; 26 : struct Time; 27 : } // namespace Tags 28 : namespace domain { 29 : namespace Tags { 30 : template <size_t Dim, typename Frame> 31 : struct Coordinates; 32 : template <size_t VolumeDim> 33 : struct Mesh; 34 : } // namespace Tags 35 : } // namespace domain 36 : // IWYU pragma: no_forward_declare db::DataBox 37 : /// \endcond 38 : 39 : namespace RadiationTransport { 40 : namespace M1Grey { 41 0 : namespace Actions { 42 : 43 : template <typename System> 44 0 : struct InitializeM1Tags { 45 0 : using evolved_variables_tag = typename System::variables_tag; 46 0 : using hydro_variables_tag = typename System::hydro_variables_tag; 47 0 : using m1_variables_tag = typename System::primitive_variables_tag; 48 : // List of variables to be created... does NOT include 49 : // evolved_variables_tag because the evolved variables 50 : // are created by the ConservativeSystem initialization. 51 0 : using simple_tags = tmpl::list<hydro_variables_tag, m1_variables_tag>; 52 0 : using compute_tags = tmpl::list<>; 53 : 54 : template <typename DbTagsList, typename... InboxTags, typename Metavariables, 55 : typename ArrayIndex, typename ActionList, 56 : typename ParallelComponent> 57 0 : static Parallel::iterable_action_return_t apply( 58 : db::DataBox<DbTagsList>& box, 59 : const tuples::TaggedTuple<InboxTags...>& /*inboxes*/, 60 : const Parallel::GlobalCache<Metavariables>& cache, 61 : const ArrayIndex& /*array_index*/, ActionList /*meta*/, 62 : const ParallelComponent* const /*meta*/) { 63 : using EvolvedVars = typename evolved_variables_tag::type; 64 : using HydroVars = typename hydro_variables_tag::type; 65 : using M1Vars = typename m1_variables_tag::type; 66 : 67 : static constexpr size_t dim = System::volume_dim; 68 : const double initial_time = db::get<::Tags::Time>(box); 69 : const size_t num_grid_points = 70 : db::get<domain::Tags::Mesh<dim>>(box).number_of_grid_points(); 71 : const auto& inertial_coords = 72 : db::get<domain::Tags::Coordinates<dim, Frame::Inertial>>(box); 73 : 74 : db::mutate<evolved_variables_tag>( 75 : [&cache, initial_time, 76 : &inertial_coords](const gsl::not_null<EvolvedVars*> evolved_vars) { 77 : evolved_vars->assign_subset(evolution::Initialization::initial_data( 78 : Parallel::get<::Tags::AnalyticSolutionOrData>(cache), 79 : inertial_coords, initial_time, 80 : typename evolved_variables_tag::tags_list{})); 81 : }, 82 : make_not_null(&box)); 83 : 84 : // Get hydro variables 85 : HydroVars hydro_variables{num_grid_points}; 86 : hydro_variables.assign_subset(evolution::Initialization::initial_data( 87 : Parallel::get<::Tags::AnalyticSolutionOrData>(cache), inertial_coords, 88 : initial_time, typename hydro_variables_tag::tags_list{})); 89 : 90 : M1Vars m1_variables{num_grid_points, -1.}; 91 : Initialization::mutate_assign<simple_tags>(make_not_null(&box), 92 : std::move(hydro_variables), 93 : std::move(m1_variables)); 94 : 95 : return {Parallel::AlgorithmExecution::Continue, std::nullopt}; 96 : } 97 : }; 98 : 99 : } // namespace Actions 100 : } // namespace M1Grey 101 : } // namespace RadiationTransport