SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Actions - InitializeChild.hpp Hit Total Coverage
Commit: eded15d6fcfa762a5dfde087b28df9bcedd8b386 Lines: 1 3 33.3 %
Date: 2024-04-15 22:23:51
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 <array>
       7             : #include <cstddef>
       8             : #include <unordered_map>
       9             : #include <utility>
      10             : 
      11             : #include "DataStructures/DataBox/DataBox.hpp"
      12             : #include "Domain/Amr/Flag.hpp"
      13             : #include "Domain/Amr/NeighborsOfChild.hpp"
      14             : #include "Domain/Amr/Tags/Flags.hpp"
      15             : #include "Domain/Amr/Tags/NeighborFlags.hpp"
      16             : #include "Domain/Structure/DirectionMap.hpp"
      17             : #include "Domain/Structure/DirectionalIdMap.hpp"
      18             : #include "Domain/Structure/Element.hpp"
      19             : #include "Domain/Structure/ElementId.hpp"
      20             : #include "Domain/Structure/Neighbors.hpp"
      21             : #include "Domain/Tags.hpp"
      22             : #include "Domain/Tags/NeighborMesh.hpp"
      23             : #include "NumericalAlgorithms/Spectral/Mesh.hpp"
      24             : #include "Parallel/ElementRegistration.hpp"
      25             : #include "ParallelAlgorithms/Amr/Projectors/Mesh.hpp"
      26             : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      27             : #include "Utilities/Gsl.hpp"
      28             : #include "Utilities/TMPL.hpp"
      29             : #include "Utilities/TaggedTuple.hpp"
      30             : 
      31             : /// \cond
      32             : namespace Parallel {
      33             : template <typename Metavariables>
      34             : class GlobalCache;
      35             : }  // namespace Parallel
      36             : /// \endcond
      37             : 
      38             : namespace amr::Actions {
      39             : /// \brief Initializes the data of a newly created child element from the data
      40             : /// of its parent element
      41             : ///
      42             : /// DataBox:
      43             : /// - Modifies:
      44             : ///   * domain::Tags::Element<volume_dim>
      45             : ///   * domain::Tags::Mesh<volume_dim>
      46             : ///   * all return_tags of Metavariables::amr::projectors
      47             : ///
      48             : /// \details This action is meant to be invoked by
      49             : /// amr::Actions::SendDataToChildren
      50           1 : struct InitializeChild {
      51             :   template <typename ParallelComponent, typename DbTagList,
      52             :             typename Metavariables, typename... Tags>
      53           0 :   static void apply(db::DataBox<DbTagList>& box,
      54             :                     Parallel::GlobalCache<Metavariables>& cache,
      55             :                     const ElementId<Metavariables::volume_dim>& child_id,
      56             :                     const tuples::TaggedTuple<Tags...>& parent_items) {
      57             :     constexpr size_t volume_dim = Metavariables::volume_dim;
      58             :     const auto& parent =
      59             :         tuples::get<::domain::Tags::Element<volume_dim>>(parent_items);
      60             :     const auto& parent_info =
      61             :         tuples::get<amr::Tags::Info<volume_dim>>(parent_items);
      62             :     const auto& parent_neighbor_info =
      63             :         tuples::get<amr::Tags::NeighborInfo<volume_dim>>(parent_items);
      64             :     const auto& parent_mesh =
      65             :         tuples::get<::domain::Tags::Mesh<volume_dim>>(parent_items);
      66             :     auto neighbors = amr::neighbors_of_child(parent, parent_info,
      67             :                                              parent_neighbor_info, child_id);
      68             :     Element<volume_dim> child(child_id, std::move(neighbors.first));
      69             :     Mesh<volume_dim> child_mesh =
      70             :         amr::projectors::mesh(parent_mesh, parent_info.flags);
      71             : 
      72             :     // Default initialization of amr::Tags::Info and amr::Tags::NeighborInfo
      73             :     // is okay
      74             :     ::Initialization::mutate_assign<tmpl::list<
      75             :         ::domain::Tags::Element<volume_dim>, ::domain::Tags::Mesh<volume_dim>,
      76             :         ::domain::Tags::NeighborMesh<volume_dim>>>(
      77             :         make_not_null(&box), std::move(child), std::move(child_mesh),
      78             :         std::move(neighbors.second));
      79             : 
      80             :     tmpl::for_each<typename Metavariables::amr::projectors>(
      81             :         [&box, &parent_items](auto projector_v) {
      82             :           using projector = typename decltype(projector_v)::type;
      83             :           try {
      84             :             db::mutate_apply<projector>(make_not_null(&box), parent_items);
      85             :           } catch (std::exception& e) {
      86             :             ERROR("Error in AMR projector '"
      87             :                   << pretty_type::get_name<projector>() << "':\n"
      88             :                   << e.what());
      89             :           }
      90             :         });
      91             : 
      92             :     Parallel::register_element<ParallelComponent>(box, cache, child_id);
      93             :   }
      94             : };
      95             : }  // namespace amr::Actions

Generated by: LCOV version 1.14