SpECTRE Documentation Coverage Report
Current view: top level - Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions - SetPiAndPhiFromConstraints.hpp Hit Total Coverage
Commit: 1f2210958b4f38fdc0400907ee7c6d5af5111418 Lines: 3 13 23.1 %
Date: 2025-12-05 05:03:31
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 <memory>
       9             : #include <random>
      10             : #include <string>
      11             : #include <unordered_map>
      12             : 
      13             : #include "DataStructures/DataBox/DataBox.hpp"
      14             : #include "DataStructures/DataVector.hpp"
      15             : #include "DataStructures/Tensor/Tensor.hpp"
      16             : #include "Domain/ElementMap.hpp"
      17             : #include "Domain/FunctionsOfTime/FunctionOfTime.hpp"
      18             : #include "Domain/FunctionsOfTime/Tags.hpp"
      19             : #include "Domain/Tags.hpp"
      20             : #include "Domain/TagsTimeDependent.hpp"
      21             : #include "Evolution/Initialization/Tags.hpp"
      22             : #include "Evolution/Systems/GeneralizedHarmonic/GaugeSourceFunctions/Tags/GaugeCondition.hpp"
      23             : #include "Evolution/Systems/GeneralizedHarmonic/Tags.hpp"
      24             : #include "Parallel/AlgorithmExecution.hpp"
      25             : #include "Parallel/GlobalCache.hpp"
      26             : #include "Utilities/TMPL.hpp"
      27             : 
      28             : /// \cond
      29             : namespace Tags {
      30             : struct Time;
      31             : }  // namespace Tags
      32             : /// \endcond
      33             : 
      34             : namespace gh {
      35             : namespace Tags {
      36             : /// DataBox tag for holding whether or not to set GH variables $\Pi$ and $\Phi$
      37             : /// from constraints.
      38           1 : struct SetPiAndPhiFromConstraints : db::SimpleTag {
      39           0 :   using type = bool;
      40             : 
      41           0 :   using option_tags = tmpl::list<>;
      42           0 :   static constexpr bool pass_metavariables = false;
      43             : 
      44           0 :   static bool create_from_options() { return true; }
      45             : };
      46             : }  // namespace Tags
      47             : 
      48             : namespace gauges {
      49             : /*!
      50             :  * \brief GlobalCache mutator to set the value of the
      51             :  * `gh::Tags::SetPiAndPhiFromConstraints` tag.
      52             :  */
      53           1 : struct SetPiAndPhiFromConstraintsCacheMutator {
      54           0 :   static void apply(gsl::not_null<bool*> value, bool new_value);
      55             : };
      56             : 
      57             : /*!
      58             :  * \brief Set \f$\Pi_{ab}\f$ from the gauge source function (or 1-index
      59             :  * constraint) and \f$\Phi_{iab}\f$ from the 3-index constraint.
      60             :  *
      61             :  * This is necessary to ensure the initial data is in the desired evolution
      62             :  * gauge and that the 1- and 3-index constraints are satisfied.
      63             :  */
      64             : template <class AllSolutionsForChristoffelAnalytic, size_t Dim>
      65           1 : struct SetPiAndPhiFromConstraints {
      66           0 :   using const_global_cache_tags = tmpl::list<gh::gauges::Tags::GaugeCondition>;
      67           0 :   using mutable_global_cache_tags =
      68             :       tmpl::list<gh::Tags::SetPiAndPhiFromConstraints>;
      69             : 
      70             :   template <typename DbTags, typename... InboxTags, typename Metavariables,
      71             :             typename ArrayIndex, typename ActionList,
      72             :             typename ParallelComponent>
      73           0 :   static Parallel::iterable_action_return_t apply(
      74             :       db::DataBox<DbTags>& box, tuples::TaggedTuple<InboxTags...>& /*inboxes*/,
      75             :       const Parallel::GlobalCache<Metavariables>& cache,
      76             :       const ArrayIndex& /*array_index*/, ActionList /*meta*/,
      77             :       const ParallelComponent* const /*meta*/) {
      78             :     db::mutate_apply<
      79             :         tmpl::list<gh::Tags::Pi<DataVector, Dim>,
      80             :                    gh::Tags::Phi<DataVector, Dim>>,
      81             :         tmpl::list<::Tags::Time, domain::Tags::Mesh<Dim>,
      82             :                    domain::Tags::ElementMap<Dim, Frame::Grid>,
      83             :                    domain::CoordinateMaps::Tags::CoordinateMap<Dim, Frame::Grid,
      84             :                                                                Frame::Inertial>,
      85             :                    domain::Tags::FunctionsOfTime,
      86             :                    domain::Tags::Coordinates<Dim, Frame::ElementLogical>,
      87             :                    gr::Tags::SpacetimeMetric<DataVector, Dim>,
      88             :                    gh::gauges::Tags::GaugeCondition>>(
      89             :         [](const auto&... args) { impl(args...); }, make_not_null(&box),
      90             :         Parallel::get<gh::Tags::SetPiAndPhiFromConstraints>(cache));
      91             :     return {Parallel::AlgorithmExecution::Continue, std::nullopt};
      92             :   }
      93             : 
      94           0 :   static void impl(
      95             :       gsl::not_null<tnsr::aa<DataVector, Dim, Frame::Inertial>*> pi,
      96             :       gsl::not_null<tnsr::iaa<DataVector, Dim, Frame::Inertial>*> phi,
      97             :       double time, const Mesh<Dim>& mesh,
      98             :       const ElementMap<Dim, Frame::Grid>& logical_to_grid_map,
      99             :       const domain::CoordinateMapBase<Frame::Grid, Frame::Inertial, Dim>&
     100             :           grid_to_inertial_map,
     101             :       const std::unordered_map<
     102             :           std::string,
     103             :           std::unique_ptr<domain::FunctionsOfTime::FunctionOfTime>>&
     104             :           functions_of_time,
     105             :       const tnsr::I<DataVector, Dim, Frame::ElementLogical>&
     106             :           logical_coordinates,
     107             :       const tnsr::aa<DataVector, Dim, Frame::Inertial>& spacetime_metric,
     108             :       const gauges::GaugeCondition& gauge_condition,
     109             :       bool set_pi_and_phi_from_constraints);
     110             : };
     111             : }  // namespace gauges
     112             : }  // namespace gh

Generated by: LCOV version 1.14