SpECTRE Documentation Coverage Report
Current view: top level - ParallelAlgorithms/Amr/Actions - CreateParent.hpp Hit Total Coverage
Commit: 361cb8d8406bb752684a5f31c27320ec444a50e3 Lines: 1 3 33.3 %
Date: 2025-11-09 02:02:04
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 <deque>
       7             : #include <memory>
       8             : #include <utility>
       9             : 
      10             : #include "Domain/Structure/ElementId.hpp"
      11             : #include "Parallel/Callback.hpp"
      12             : #include "Parallel/GlobalCache.hpp"
      13             : #include "Parallel/Info.hpp"
      14             : #include "Parallel/Phase.hpp"
      15             : #include "ParallelAlgorithms/Amr/Actions/CollectDataFromChildren.hpp"
      16             : #include "Utilities/ErrorHandling/Error.hpp"
      17             : 
      18             : /// \cond
      19             : namespace db {
      20             : template <typename>
      21             : class DataBox;
      22             : }  // namespace db
      23             : /// \endcond
      24             : 
      25             : namespace amr::Actions {
      26             : /// \brief Creates a new element in an ArrayAlgorithm whose id is `parent_id`
      27             : ///
      28             : /// \details This action is meant to be initially invoked by
      29             : /// amr::Actions::AdjustDomain on the amr::Component.  This action inserts a
      30             : /// new element with id `parent_id` in the array referenced by
      31             : /// `element_proxy`.  A Parallel::SimpleActionCallback `callback` is passed to
      32             : /// the constructor of the new DistributedObject, which will invoke
      33             : /// amr::Actions::CollectDataFromChildren on the element with id `child_id`.
      34             : ///
      35             : /// This action does not modify anything in the DataBox
      36           1 : struct CreateParent {
      37             :   template <typename ParallelComponent, typename DbTagList,
      38             :             typename Metavariables, typename ElementProxy>
      39           0 :   static void apply(
      40             :       db::DataBox<DbTagList>& /*box*/,
      41             :       Parallel::GlobalCache<Metavariables>& cache, const int /*array_index*/,
      42             :       ElementProxy element_proxy,
      43             :       ElementId<Metavariables::volume_dim> parent_id,
      44             :       const ElementId<Metavariables::volume_dim>& child_id,
      45             :       std::deque<ElementId<Metavariables::volume_dim>> sibling_ids_to_collect,
      46             :       const std::unordered_map<Parallel::Phase, size_t> child_phase_bookmarks) {
      47             :     if (CHARM_VERSION_MAJOR < 8 and
      48             :         Parallel::number_of_procs<size_t>(cache) > 1) {
      49             :       ERROR_NO_TRACE(
      50             :           "Dynamically creating elements in parallel executables is broken "
      51             :           "until charm 8.");
      52             :     }
      53             :     auto child_proxy = element_proxy[child_id];
      54             :     element_proxy[parent_id].insert(
      55             :         cache.get_this_proxy(), Parallel::Phase::AdjustDomain,
      56             :         child_phase_bookmarks,
      57             :         std::make_unique<Parallel::SimpleActionCallback<
      58             :             CollectDataFromChildren, decltype(child_proxy),
      59             :             ElementId<Metavariables::volume_dim>,
      60             :             std::deque<ElementId<Metavariables::volume_dim>>>>(
      61             :             child_proxy, std::move(parent_id),
      62             :             std::move(sibling_ids_to_collect)));
      63             :   }
      64             : };
      65             : }  // namespace amr::Actions

Generated by: LCOV version 1.14