SpECTRE Documentation Coverage Report
Current view: top level - Elliptic/Actions - InitializeBackgroundFields.hpp Coverage Total Hit
Commit: 0d1d717af84a81fb1284a20c4013708fe85cc2f0 Lines: 16.7 % 6 1
Test Date: 2026-10-22 17:29:42
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 <type_traits>
      10              : #include <utility>
      11              : 
      12              : #include "DataStructures/DataBox/DataBox.hpp"
      13              : #include "DataStructures/TaggedTuple.hpp"
      14              : #include "DataStructures/Tensor/Tensor.hpp"
      15              : #include "DataStructures/Variables.hpp"
      16              : #include "Domain/Tags.hpp"
      17              : #include "Parallel/AlgorithmExecution.hpp"
      18              : #include "ParallelAlgorithms/Initialization/MutateAssign.hpp"
      19              : #include "Utilities/Gsl.hpp"
      20              : #include "Utilities/TMPL.hpp"
      21              : 
      22              : /// \cond
      23              : namespace Parallel {
      24              : template <typename Metavariables>
      25              : struct GlobalCache;
      26              : }  // namespace Parallel
      27              : /// \endcond
      28              : 
      29              : namespace elliptic::Actions {
      30              : 
      31              : /*!
      32              :  * \brief Initialize the variable-independent background fields for an elliptic
      33              :  * solve.
      34              :  *
      35              :  * Examples for background fields would be a background metric, associated
      36              :  * curvature quantities, or matter sources such as a mass-density in the XCTS
      37              :  * equations.
      38              :  *
      39              :  * This action retrieves the `System::background_fields` from the
      40              :  * `BackgroundTag`. It invokes the `variables` function with the inertial
      41              :  * coordinates, the element's `Mesh` and the element's inverse Jacobian. These
      42              :  * arguments allow computing numeric derivatives, if necessary.
      43              :  *
      44              :  * Uses:
      45              :  * - System:
      46              :  *   - `background_fields`
      47              :  * - DataBox:
      48              :  *   - `BackgroundTag`
      49              :  *   - `domain::Tags::Coordinates<Dim, Frame::Inertial>`
      50              :  *
      51              :  * DataBox:
      52              :  * - Adds:
      53              :  *   - `::Tags::Variables<background_fields>`
      54              :  */
      55              : template <typename System, typename BackgroundTag>
      56            1 : struct InitializeBackgroundFields {
      57              :   static_assert(
      58              :       not std::is_same_v<typename System::background_fields, tmpl::list<>>,
      59              :       "The system has no background fields. Don't add the "
      60              :       "'InitializeBackgroundFields' action to the action list.");
      61              : 
      62              :  private:
      63            0 :   using background_fields_tag =
      64              :       ::Tags::Variables<typename System::background_fields>;
      65              : 
      66              :  public:
      67            0 :   using simple_tags = tmpl::list<background_fields_tag>;
      68            0 :   using compute_tags = tmpl::list<>;
      69              : 
      70              :   template <typename DbTags, typename... InboxTags, typename Metavariables,
      71              :             size_t Dim, typename ActionList, typename ParallelComponent>
      72            0 :   static Parallel::iterable_action_return_t apply(
      73              :       db::DataBox<DbTags>& box,
      74              :       const tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      75              :       const Parallel::GlobalCache<Metavariables>& /*cache*/,
      76              :       const ElementId<Dim>& /*array_index*/, const ActionList /*meta*/,
      77              :       const ParallelComponent* const /*meta*/) {
      78              :     const auto& background = db::get<BackgroundTag>(box);
      79              :     const auto& inertial_coords =
      80              :         get<domain::Tags::Coordinates<Dim, Frame::Inertial>>(box);
      81              :     const auto& mesh = get<domain::Tags::Mesh<Dim>>(box);
      82              :     const auto& inv_jacobian =
      83              :         get<domain::Tags::InverseJacobian<Dim, Frame::ElementLogical,
      84              :                                           Frame::Inertial>>(box);
      85              :     auto background_fields = variables_from_tagged_tuple(
      86              :         background.variables(inertial_coords, mesh, inv_jacobian,
      87              :                              typename background_fields_tag::tags_list{}));
      88              :     ::Initialization::mutate_assign<simple_tags>(make_not_null(&box),
      89              :                                                  std::move(background_fields));
      90              :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      91              :   }
      92              : };
      93              : 
      94              : }  // namespace elliptic::Actions
        

Generated by: LCOV version 2.0-1